plugin.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. /**
  2. * TinyMCE version 8.0.2 (2025-08-14)
  3. */
  4. (function () {
  5. 'use strict';
  6. var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
  7. /* eslint-disable @typescript-eslint/no-wrapper-object-types */
  8. const hasProto = (v, constructor, predicate) => {
  9. var _a;
  10. if (predicate(v, constructor.prototype)) {
  11. return true;
  12. }
  13. else {
  14. // String-based fallback time
  15. return ((_a = v.constructor) === null || _a === void 0 ? void 0 : _a.name) === constructor.name;
  16. }
  17. };
  18. const typeOf = (x) => {
  19. const t = typeof x;
  20. if (x === null) {
  21. return 'null';
  22. }
  23. else if (t === 'object' && Array.isArray(x)) {
  24. return 'array';
  25. }
  26. else if (t === 'object' && hasProto(x, String, (o, proto) => proto.isPrototypeOf(o))) {
  27. return 'string';
  28. }
  29. else {
  30. return t;
  31. }
  32. };
  33. const isType$1 = (type) => (value) => typeOf(value) === type;
  34. const isSimpleType = (type) => (value) => typeof value === type;
  35. const isString = isType$1('string');
  36. const isBoolean = isSimpleType('boolean');
  37. const isNullable = (a) => a === null || a === undefined;
  38. const isNonNullable = (a) => !isNullable(a);
  39. const isFunction = isSimpleType('function');
  40. const isNumber = isSimpleType('number');
  41. /** Compose two unary functions. Similar to compose, but avoids using Function.prototype.apply. */
  42. const compose1 = (fbc, fab) => (a) => fbc(fab(a));
  43. const constant = (value) => {
  44. return () => {
  45. return value;
  46. };
  47. };
  48. const never = constant(false);
  49. /**
  50. * The `Optional` type represents a value (of any type) that potentially does
  51. * not exist. Any `Optional<T>` can either be a `Some<T>` (in which case the
  52. * value does exist) or a `None` (in which case the value does not exist). This
  53. * module defines a whole lot of FP-inspired utility functions for dealing with
  54. * `Optional` objects.
  55. *
  56. * Comparison with null or undefined:
  57. * - We don't get fancy null coalescing operators with `Optional`
  58. * - We do get fancy helper functions with `Optional`
  59. * - `Optional` support nesting, and allow for the type to still be nullable (or
  60. * another `Optional`)
  61. * - There is no option to turn off strict-optional-checks like there is for
  62. * strict-null-checks
  63. */
  64. class Optional {
  65. // The internal representation has a `tag` and a `value`, but both are
  66. // private: able to be console.logged, but not able to be accessed by code
  67. constructor(tag, value) {
  68. this.tag = tag;
  69. this.value = value;
  70. }
  71. // --- Identities ---
  72. /**
  73. * Creates a new `Optional<T>` that **does** contain a value.
  74. */
  75. static some(value) {
  76. return new Optional(true, value);
  77. }
  78. /**
  79. * Create a new `Optional<T>` that **does not** contain a value. `T` can be
  80. * any type because we don't actually have a `T`.
  81. */
  82. static none() {
  83. return Optional.singletonNone;
  84. }
  85. /**
  86. * Perform a transform on an `Optional` type. Regardless of whether this
  87. * `Optional` contains a value or not, `fold` will return a value of type `U`.
  88. * If this `Optional` does not contain a value, the `U` will be created by
  89. * calling `onNone`. If this `Optional` does contain a value, the `U` will be
  90. * created by calling `onSome`.
  91. *
  92. * For the FP enthusiasts in the room, this function:
  93. * 1. Could be used to implement all of the functions below
  94. * 2. Forms a catamorphism
  95. */
  96. fold(onNone, onSome) {
  97. if (this.tag) {
  98. return onSome(this.value);
  99. }
  100. else {
  101. return onNone();
  102. }
  103. }
  104. /**
  105. * Determine if this `Optional` object contains a value.
  106. */
  107. isSome() {
  108. return this.tag;
  109. }
  110. /**
  111. * Determine if this `Optional` object **does not** contain a value.
  112. */
  113. isNone() {
  114. return !this.tag;
  115. }
  116. // --- Functor (name stolen from Haskell / maths) ---
  117. /**
  118. * Perform a transform on an `Optional` object, **if** there is a value. If
  119. * you provide a function to turn a T into a U, this is the function you use
  120. * to turn an `Optional<T>` into an `Optional<U>`. If this **does** contain
  121. * a value then the output will also contain a value (that value being the
  122. * output of `mapper(this.value)`), and if this **does not** contain a value
  123. * then neither will the output.
  124. */
  125. map(mapper) {
  126. if (this.tag) {
  127. return Optional.some(mapper(this.value));
  128. }
  129. else {
  130. return Optional.none();
  131. }
  132. }
  133. // --- Monad (name stolen from Haskell / maths) ---
  134. /**
  135. * Perform a transform on an `Optional` object, **if** there is a value.
  136. * Unlike `map`, here the transform itself also returns an `Optional`.
  137. */
  138. bind(binder) {
  139. if (this.tag) {
  140. return binder(this.value);
  141. }
  142. else {
  143. return Optional.none();
  144. }
  145. }
  146. // --- Traversable (name stolen from Haskell / maths) ---
  147. /**
  148. * For a given predicate, this function finds out if there **exists** a value
  149. * inside this `Optional` object that meets the predicate. In practice, this
  150. * means that for `Optional`s that do not contain a value it returns false (as
  151. * no predicate-meeting value exists).
  152. */
  153. exists(predicate) {
  154. return this.tag && predicate(this.value);
  155. }
  156. /**
  157. * For a given predicate, this function finds out if **all** the values inside
  158. * this `Optional` object meet the predicate. In practice, this means that
  159. * for `Optional`s that do not contain a value it returns true (as all 0
  160. * objects do meet the predicate).
  161. */
  162. forall(predicate) {
  163. return !this.tag || predicate(this.value);
  164. }
  165. filter(predicate) {
  166. if (!this.tag || predicate(this.value)) {
  167. return this;
  168. }
  169. else {
  170. return Optional.none();
  171. }
  172. }
  173. // --- Getters ---
  174. /**
  175. * Get the value out of the inside of the `Optional` object, using a default
  176. * `replacement` value if the provided `Optional` object does not contain a
  177. * value.
  178. */
  179. getOr(replacement) {
  180. return this.tag ? this.value : replacement;
  181. }
  182. /**
  183. * Get the value out of the inside of the `Optional` object, using a default
  184. * `replacement` value if the provided `Optional` object does not contain a
  185. * value. Unlike `getOr`, in this method the `replacement` object is also
  186. * `Optional` - meaning that this method will always return an `Optional`.
  187. */
  188. or(replacement) {
  189. return this.tag ? this : replacement;
  190. }
  191. /**
  192. * Get the value out of the inside of the `Optional` object, using a default
  193. * `replacement` value if the provided `Optional` object does not contain a
  194. * value. Unlike `getOr`, in this method the `replacement` value is
  195. * "thunked" - that is to say that you don't pass a value to `getOrThunk`, you
  196. * pass a function which (if called) will **return** the `value` you want to
  197. * use.
  198. */
  199. getOrThunk(thunk) {
  200. return this.tag ? this.value : thunk();
  201. }
  202. /**
  203. * Get the value out of the inside of the `Optional` object, using a default
  204. * `replacement` value if the provided Optional object does not contain a
  205. * value.
  206. *
  207. * Unlike `or`, in this method the `replacement` value is "thunked" - that is
  208. * to say that you don't pass a value to `orThunk`, you pass a function which
  209. * (if called) will **return** the `value` you want to use.
  210. *
  211. * Unlike `getOrThunk`, in this method the `replacement` value is also
  212. * `Optional`, meaning that this method will always return an `Optional`.
  213. */
  214. orThunk(thunk) {
  215. return this.tag ? this : thunk();
  216. }
  217. /**
  218. * Get the value out of the inside of the `Optional` object, throwing an
  219. * exception if the provided `Optional` object does not contain a value.
  220. *
  221. * WARNING:
  222. * You should only be using this function if you know that the `Optional`
  223. * object **is not** empty (otherwise you're throwing exceptions in production
  224. * code, which is bad).
  225. *
  226. * In tests this is more acceptable.
  227. *
  228. * Prefer other methods to this, such as `.each`.
  229. */
  230. getOrDie(message) {
  231. if (!this.tag) {
  232. throw new Error(message !== null && message !== void 0 ? message : 'Called getOrDie on None');
  233. }
  234. else {
  235. return this.value;
  236. }
  237. }
  238. // --- Interop with null and undefined ---
  239. /**
  240. * Creates an `Optional` value from a nullable (or undefined-able) input.
  241. * Null, or undefined, is converted to `None`, and anything else is converted
  242. * to `Some`.
  243. */
  244. static from(value) {
  245. return isNonNullable(value) ? Optional.some(value) : Optional.none();
  246. }
  247. /**
  248. * Converts an `Optional` to a nullable type, by getting the value if it
  249. * exists, or returning `null` if it does not.
  250. */
  251. getOrNull() {
  252. return this.tag ? this.value : null;
  253. }
  254. /**
  255. * Converts an `Optional` to an undefined-able type, by getting the value if
  256. * it exists, or returning `undefined` if it does not.
  257. */
  258. getOrUndefined() {
  259. return this.value;
  260. }
  261. // --- Utilities ---
  262. /**
  263. * If the `Optional` contains a value, perform an action on that value.
  264. * Unlike the rest of the methods on this type, `.each` has side-effects. If
  265. * you want to transform an `Optional<T>` **into** something, then this is not
  266. * the method for you. If you want to use an `Optional<T>` to **do**
  267. * something, then this is the method for you - provided you're okay with not
  268. * doing anything in the case where the `Optional` doesn't have a value inside
  269. * it. If you're not sure whether your use-case fits into transforming
  270. * **into** something or **doing** something, check whether it has a return
  271. * value. If it does, you should be performing a transform.
  272. */
  273. each(worker) {
  274. if (this.tag) {
  275. worker(this.value);
  276. }
  277. }
  278. /**
  279. * Turn the `Optional` object into an array that contains all of the values
  280. * stored inside the `Optional`. In practice, this means the output will have
  281. * either 0 or 1 elements.
  282. */
  283. toArray() {
  284. return this.tag ? [this.value] : [];
  285. }
  286. /**
  287. * Turn the `Optional` object into a string for debugging or printing. Not
  288. * recommended for production code, but good for debugging. Also note that
  289. * these days an `Optional` object can be logged to the console directly, and
  290. * its inner value (if it exists) will be visible.
  291. */
  292. toString() {
  293. return this.tag ? `some(${this.value})` : 'none()';
  294. }
  295. }
  296. // Sneaky optimisation: every instance of Optional.none is identical, so just
  297. // reuse the same object
  298. Optional.singletonNone = new Optional(false);
  299. const nativeSlice = Array.prototype.slice;
  300. const map = (xs, f) => {
  301. // pre-allocating array size when it's guaranteed to be known
  302. // http://jsperf.com/push-allocated-vs-dynamic/22
  303. const len = xs.length;
  304. const r = new Array(len);
  305. for (let i = 0; i < len; i++) {
  306. const x = xs[i];
  307. r[i] = f(x, i);
  308. }
  309. return r;
  310. };
  311. // Unwound implementing other functions in terms of each.
  312. // The code size is roughly the same, and it should allow for better optimisation.
  313. // const each = function<T, U>(xs: T[], f: (x: T, i?: number, xs?: T[]) => void): void {
  314. const each = (xs, f) => {
  315. for (let i = 0, len = xs.length; i < len; i++) {
  316. const x = xs[i];
  317. f(x, i);
  318. }
  319. };
  320. const filter = (xs, pred) => {
  321. const r = [];
  322. for (let i = 0, len = xs.length; i < len; i++) {
  323. const x = xs[i];
  324. if (pred(x, i)) {
  325. r.push(x);
  326. }
  327. }
  328. return r;
  329. };
  330. isFunction(Array.from) ? Array.from : (x) => nativeSlice.call(x);
  331. const fromHtml = (html, scope) => {
  332. const doc = scope || document;
  333. const div = doc.createElement('div');
  334. div.innerHTML = html;
  335. if (!div.hasChildNodes() || div.childNodes.length > 1) {
  336. const message = 'HTML does not have a single root node';
  337. // eslint-disable-next-line no-console
  338. console.error(message, html);
  339. throw new Error(message);
  340. }
  341. return fromDom(div.childNodes[0]);
  342. };
  343. const fromTag = (tag, scope) => {
  344. const doc = scope || document;
  345. const node = doc.createElement(tag);
  346. return fromDom(node);
  347. };
  348. const fromText = (text, scope) => {
  349. const doc = scope || document;
  350. const node = doc.createTextNode(text);
  351. return fromDom(node);
  352. };
  353. const fromDom = (node) => {
  354. // TODO: Consider removing this check, but left atm for safety
  355. if (node === null || node === undefined) {
  356. throw new Error('Node cannot be null or undefined');
  357. }
  358. return {
  359. dom: node
  360. };
  361. };
  362. const fromPoint = (docElm, x, y) => Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom);
  363. // tslint:disable-next-line:variable-name
  364. const SugarElement = {
  365. fromHtml,
  366. fromTag,
  367. fromText,
  368. fromDom,
  369. fromPoint
  370. };
  371. const DOCUMENT_FRAGMENT = 11;
  372. const ELEMENT = 1;
  373. const TEXT = 3;
  374. const is = (element, selector) => {
  375. const dom = element.dom;
  376. if (dom.nodeType !== ELEMENT) {
  377. return false;
  378. }
  379. else {
  380. const elem = dom;
  381. if (elem.matches !== undefined) {
  382. return elem.matches(selector);
  383. }
  384. else if (elem.msMatchesSelector !== undefined) {
  385. return elem.msMatchesSelector(selector);
  386. }
  387. else if (elem.webkitMatchesSelector !== undefined) {
  388. return elem.webkitMatchesSelector(selector);
  389. }
  390. else if (elem.mozMatchesSelector !== undefined) {
  391. // cast to any as mozMatchesSelector doesn't exist in TS DOM lib
  392. return elem.mozMatchesSelector(selector);
  393. }
  394. else {
  395. throw new Error('Browser lacks native selectors');
  396. } // unfortunately we can't throw this on startup :(
  397. }
  398. };
  399. const name = (element) => {
  400. const r = element.dom.nodeName;
  401. return r.toLowerCase();
  402. };
  403. const type = (element) => element.dom.nodeType;
  404. const isType = (t) => (element) => type(element) === t;
  405. const isElement = isType(ELEMENT);
  406. const isText = isType(TEXT);
  407. const isDocumentFragment = isType(DOCUMENT_FRAGMENT);
  408. const isTag = (tag) => (e) => isElement(e) && name(e) === tag;
  409. const parent = (element) => Optional.from(element.dom.parentNode).map(SugarElement.fromDom);
  410. const children$2 = (element) => map(element.dom.childNodes, SugarElement.fromDom);
  411. /**
  412. * Is the element a ShadowRoot?
  413. *
  414. * Note: this is insufficient to test if any element is a shadow root, but it is sufficient to differentiate between
  415. * a Document and a ShadowRoot.
  416. */
  417. const isShadowRoot = (dos) => isDocumentFragment(dos) && isNonNullable(dos.dom.host);
  418. const getRootNode = (e) => SugarElement.fromDom(e.dom.getRootNode());
  419. /** If this element is in a ShadowRoot, return it. */
  420. const getShadowRoot = (e) => {
  421. const r = getRootNode(e);
  422. return isShadowRoot(r) ? Optional.some(r) : Optional.none();
  423. };
  424. /** Return the host of a ShadowRoot.
  425. *
  426. * This function will throw if Shadow DOM is unsupported in the browser, or if the host is null.
  427. * If you actually have a ShadowRoot, this shouldn't happen.
  428. */
  429. const getShadowHost = (e) => SugarElement.fromDom(e.dom.host);
  430. const rawSet = (dom, key, value) => {
  431. /*
  432. * JQuery coerced everything to a string, and silently did nothing on text node/null/undefined.
  433. *
  434. * We fail on those invalid cases, only allowing numbers and booleans.
  435. */
  436. if (isString(value) || isBoolean(value) || isNumber(value)) {
  437. dom.setAttribute(key, value + '');
  438. }
  439. else {
  440. // eslint-disable-next-line no-console
  441. console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom);
  442. throw new Error('Attribute value was not simple');
  443. }
  444. };
  445. const set = (element, key, value) => {
  446. rawSet(element.dom, key, value);
  447. };
  448. const remove = (element, key) => {
  449. element.dom.removeAttribute(key);
  450. };
  451. // some elements, such as mathml, don't have style attributes
  452. // others, such as angular elements, have style attributes that aren't a CSSStyleDeclaration
  453. const isSupported = (dom) => dom.style !== undefined && isFunction(dom.style.getPropertyValue);
  454. // Node.contains() is very, very, very good performance
  455. // http://jsperf.com/closest-vs-contains/5
  456. const inBody = (element) => {
  457. // Technically this is only required on IE, where contains() returns false for text nodes.
  458. // But it's cheap enough to run everywhere and Sugar doesn't have platform detection (yet).
  459. const dom = isText(element) ? element.dom.parentNode : element.dom;
  460. // use ownerDocument.body to ensure this works inside iframes.
  461. // Normally contains is bad because an element "contains" itself, but here we want that.
  462. if (dom === undefined || dom === null || dom.ownerDocument === null) {
  463. return false;
  464. }
  465. const doc = dom.ownerDocument;
  466. return getShadowRoot(SugarElement.fromDom(dom)).fold(() => doc.body.contains(dom), compose1(inBody, getShadowHost));
  467. };
  468. /*
  469. * NOTE: For certain properties, this returns the "used value" which is subtly different to the "computed value" (despite calling getComputedStyle).
  470. * Blame CSS 2.0.
  471. *
  472. * https://developer.mozilla.org/en-US/docs/Web/CSS/used_value
  473. */
  474. const get = (element, property) => {
  475. const dom = element.dom;
  476. /*
  477. * IE9 and above per
  478. * https://developer.mozilla.org/en/docs/Web/API/window.getComputedStyle
  479. *
  480. * Not in numerosity, because it doesn't memoize and looking this up dynamically in performance critical code would be horrendous.
  481. *
  482. * JQuery has some magic here for IE popups, but we don't really need that.
  483. * It also uses element.ownerDocument.defaultView to handle iframes but that hasn't been required since FF 3.6.
  484. */
  485. const styles = window.getComputedStyle(dom);
  486. const r = styles.getPropertyValue(property);
  487. // jquery-ism: If r is an empty string, check that the element is not in a document. If it isn't, return the raw value.
  488. // Turns out we do this a lot.
  489. return (r === '' && !inBody(element)) ? getUnsafeProperty(dom, property) : r;
  490. };
  491. // removed: support for dom().style[property] where prop is camel case instead of normal property name
  492. // empty string is what the browsers (IE11 and Chrome) return when the propertyValue doesn't exists.
  493. const getUnsafeProperty = (dom, property) => isSupported(dom) ? dom.style.getPropertyValue(property) : '';
  494. const getDirection = (element) => get(element, 'direction') === 'rtl' ? 'rtl' : 'ltr';
  495. const ancestor$1 = (scope, predicate, isRoot) => {
  496. let element = scope.dom;
  497. const stop = isFunction(isRoot) ? isRoot : never;
  498. while (element.parentNode) {
  499. element = element.parentNode;
  500. const el = SugarElement.fromDom(element);
  501. if (predicate(el)) {
  502. return Optional.some(el);
  503. }
  504. else if (stop(el)) {
  505. break;
  506. }
  507. }
  508. return Optional.none();
  509. };
  510. const ancestor = (scope, selector, isRoot) => ancestor$1(scope, (e) => is(e, selector), isRoot);
  511. const children$1 = (scope, predicate) => filter(children$2(scope), predicate);
  512. const children = (scope, selector) =>
  513. // It may surprise you to learn this is exactly what JQuery does
  514. // TODO: Avoid all the wrapping and unwrapping
  515. children$1(scope, (e) => is(e, selector));
  516. const getParentElement = (element) => parent(element).filter(isElement);
  517. // if the block is a list item, we need to get the parent of the list itself
  518. const getNormalizedBlock = (element, isListItem) => {
  519. const normalizedElement = isListItem ? ancestor(element, 'ol,ul') : Optional.some(element);
  520. return normalizedElement.getOr(element);
  521. };
  522. const isListItem = isTag('li');
  523. const setDirOnElements = (dom, blocks, dir) => {
  524. each(blocks, (block) => {
  525. const blockElement = SugarElement.fromDom(block);
  526. const isBlockElementListItem = isListItem(blockElement);
  527. const normalizedBlock = getNormalizedBlock(blockElement, isBlockElementListItem);
  528. const normalizedBlockParent = getParentElement(normalizedBlock);
  529. normalizedBlockParent.each((parent) => {
  530. // TINY-9314: Remove any inline direction style to ensure that it is only set when necessary and that
  531. // the dir attribute is favored
  532. dom.setStyle(normalizedBlock.dom, 'direction', null);
  533. const parentDirection = getDirection(parent);
  534. if (parentDirection === dir) {
  535. remove(normalizedBlock, 'dir');
  536. }
  537. else {
  538. set(normalizedBlock, 'dir', dir);
  539. }
  540. // TINY-9314: Set an inline direction style if computed css direction is still not as desired. This can
  541. // happen when the direction style is derived from a stylesheet.
  542. if (getDirection(normalizedBlock) !== dir) {
  543. dom.setStyle(normalizedBlock.dom, 'direction', dir);
  544. }
  545. // Remove dir attr and direction style from list children
  546. if (isBlockElementListItem) {
  547. const listItems = children(normalizedBlock, 'li[dir],li[style]');
  548. each(listItems, (listItem) => {
  549. remove(listItem, 'dir');
  550. dom.setStyle(listItem.dom, 'direction', null);
  551. });
  552. }
  553. });
  554. });
  555. };
  556. const setDir = (editor, dir) => {
  557. if (editor.selection.isEditable()) {
  558. setDirOnElements(editor.dom, editor.selection.getSelectedBlocks(), dir);
  559. editor.nodeChanged();
  560. }
  561. };
  562. const register$1 = (editor) => {
  563. editor.addCommand('mceDirectionLTR', () => {
  564. setDir(editor, 'ltr');
  565. });
  566. editor.addCommand('mceDirectionRTL', () => {
  567. setDir(editor, 'rtl');
  568. });
  569. };
  570. const getNodeChangeHandler = (editor, dir) => (api) => {
  571. const nodeChangeHandler = (e) => {
  572. const element = SugarElement.fromDom(e.element);
  573. api.setActive(getDirection(element) === dir);
  574. api.setEnabled(editor.selection.isEditable());
  575. };
  576. editor.on('NodeChange', nodeChangeHandler);
  577. api.setEnabled(editor.selection.isEditable());
  578. return () => editor.off('NodeChange', nodeChangeHandler);
  579. };
  580. const register = (editor) => {
  581. editor.ui.registry.addToggleButton('ltr', {
  582. tooltip: 'Left to right',
  583. icon: 'ltr',
  584. onAction: () => editor.execCommand('mceDirectionLTR'),
  585. onSetup: getNodeChangeHandler(editor, 'ltr')
  586. });
  587. editor.ui.registry.addToggleButton('rtl', {
  588. tooltip: 'Right to left',
  589. icon: 'rtl',
  590. onAction: () => editor.execCommand('mceDirectionRTL'),
  591. onSetup: getNodeChangeHandler(editor, 'rtl')
  592. });
  593. };
  594. var Plugin = () => {
  595. global.add('directionality', (editor) => {
  596. register$1(editor);
  597. register(editor);
  598. });
  599. };
  600. Plugin();
  601. /** *****
  602. * DO NOT EXPORT ANYTHING
  603. *
  604. * IF YOU DO ROLLUP WILL LEAVE A GLOBAL ON THE PAGE
  605. *******/
  606. })();