@dangl/angular-material-shared 2.9.0-beta0047 → 2.9.0-beta0048

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