fx-platform-ui 0.0.13-alpha13 → 0.0.13-alpha15

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 (114) hide show
  1. package/lib/fx-platform-ui.mjs +30783 -62614
  2. package/lib/fx-platform-ui.umd.js +68 -112
  3. package/lib/packages/components/editor/src/index.vue.d.ts +16 -0
  4. package/lib/style.css +1 -1
  5. package/lib/tinymce/CHANGELOG.md +2957 -0
  6. package/lib/tinymce/README.md +71 -0
  7. package/lib/tinymce/bower.json +27 -0
  8. package/lib/tinymce/composer.json +52 -0
  9. package/lib/tinymce/icons/default/icons.js +182 -0
  10. package/lib/tinymce/icons/default/icons.min.js +1 -0
  11. package/lib/tinymce/icons/default/index.js +7 -0
  12. package/lib/tinymce/license.txt +21 -0
  13. package/lib/tinymce/models/dom/index.js +7 -0
  14. package/lib/tinymce/models/dom/model.js +7975 -0
  15. package/lib/tinymce/models/dom/model.min.js +4 -0
  16. package/lib/tinymce/package.json +32 -0
  17. package/lib/tinymce/plugins/advlist/index.js +7 -0
  18. package/lib/tinymce/plugins/advlist/plugin.js +246 -0
  19. package/lib/tinymce/plugins/advlist/plugin.min.js +4 -0
  20. package/lib/tinymce/plugins/anchor/index.js +7 -0
  21. package/lib/tinymce/plugins/anchor/plugin.js +195 -0
  22. package/lib/tinymce/plugins/anchor/plugin.min.js +4 -0
  23. package/lib/tinymce/plugins/autolink/index.js +7 -0
  24. package/lib/tinymce/plugins/autolink/plugin.js +232 -0
  25. package/lib/tinymce/plugins/autolink/plugin.min.js +4 -0
  26. package/lib/tinymce/plugins/autoresize/index.js +7 -0
  27. package/lib/tinymce/plugins/autoresize/plugin.js +156 -0
  28. package/lib/tinymce/plugins/autoresize/plugin.min.js +4 -0
  29. package/lib/tinymce/plugins/autosave/index.js +7 -0
  30. package/lib/tinymce/plugins/autosave/plugin.js +232 -0
  31. package/lib/tinymce/plugins/autosave/plugin.min.js +4 -0
  32. package/lib/tinymce/plugins/charmap/index.js +7 -0
  33. package/lib/tinymce/plugins/charmap/plugin.js +1636 -0
  34. package/lib/tinymce/plugins/charmap/plugin.min.js +4 -0
  35. package/lib/tinymce/plugins/code/index.js +7 -0
  36. package/lib/tinymce/plugins/code/plugin.js +85 -0
  37. package/lib/tinymce/plugins/code/plugin.min.js +4 -0
  38. package/lib/tinymce/plugins/codesample/index.js +7 -0
  39. package/lib/tinymce/plugins/codesample/plugin.js +2451 -0
  40. package/lib/tinymce/plugins/codesample/plugin.min.js +4 -0
  41. package/lib/tinymce/plugins/directionality/index.js +7 -0
  42. package/lib/tinymce/plugins/directionality/plugin.js +384 -0
  43. package/lib/tinymce/plugins/directionality/plugin.min.js +4 -0
  44. package/lib/tinymce/plugins/emoticons/index.js +7 -0
  45. package/lib/tinymce/plugins/emoticons/js/emojiimages.js +1 -0
  46. package/lib/tinymce/plugins/emoticons/js/emojiimages.min.js +3 -0
  47. package/lib/tinymce/plugins/emoticons/js/emojis.js +1 -0
  48. package/lib/tinymce/plugins/emoticons/js/emojis.min.js +2 -0
  49. package/lib/tinymce/plugins/emoticons/plugin.js +577 -0
  50. package/lib/tinymce/plugins/emoticons/plugin.min.js +4 -0
  51. package/lib/tinymce/plugins/fullscreen/index.js +7 -0
  52. package/lib/tinymce/plugins/fullscreen/plugin.js +1190 -0
  53. package/lib/tinymce/plugins/fullscreen/plugin.min.js +4 -0
  54. package/lib/tinymce/plugins/help/index.js +7 -0
  55. package/lib/tinymce/plugins/help/plugin.js +848 -0
  56. package/lib/tinymce/plugins/help/plugin.min.js +4 -0
  57. package/lib/tinymce/plugins/image/index.js +7 -0
  58. package/lib/tinymce/plugins/image/plugin.js +1475 -0
  59. package/lib/tinymce/plugins/image/plugin.min.js +4 -0
  60. package/lib/tinymce/plugins/importcss/index.js +7 -0
  61. package/lib/tinymce/plugins/importcss/plugin.js +342 -0
  62. package/lib/tinymce/plugins/importcss/plugin.min.js +4 -0
  63. package/lib/tinymce/plugins/insertdatetime/index.js +7 -0
  64. package/lib/tinymce/plugins/insertdatetime/plugin.js +176 -0
  65. package/lib/tinymce/plugins/insertdatetime/plugin.min.js +4 -0
  66. package/lib/tinymce/plugins/link/index.js +7 -0
  67. package/lib/tinymce/plugins/link/plugin.js +1190 -0
  68. package/lib/tinymce/plugins/link/plugin.min.js +4 -0
  69. package/lib/tinymce/plugins/lists/index.js +7 -0
  70. package/lib/tinymce/plugins/lists/plugin.js +1820 -0
  71. package/lib/tinymce/plugins/lists/plugin.min.js +4 -0
  72. package/lib/tinymce/plugins/media/index.js +7 -0
  73. package/lib/tinymce/plugins/media/plugin.js +1157 -0
  74. package/lib/tinymce/plugins/media/plugin.min.js +4 -0
  75. package/lib/tinymce/plugins/nonbreaking/index.js +7 -0
  76. package/lib/tinymce/plugins/nonbreaking/plugin.js +111 -0
  77. package/lib/tinymce/plugins/nonbreaking/plugin.min.js +4 -0
  78. package/lib/tinymce/plugins/pagebreak/index.js +7 -0
  79. package/lib/tinymce/plugins/pagebreak/plugin.js +105 -0
  80. package/lib/tinymce/plugins/pagebreak/plugin.min.js +4 -0
  81. package/lib/tinymce/plugins/preview/index.js +7 -0
  82. package/lib/tinymce/plugins/preview/plugin.js +97 -0
  83. package/lib/tinymce/plugins/preview/plugin.min.js +4 -0
  84. package/lib/tinymce/plugins/quickbars/index.js +7 -0
  85. package/lib/tinymce/plugins/quickbars/plugin.js +421 -0
  86. package/lib/tinymce/plugins/quickbars/plugin.min.js +4 -0
  87. package/lib/tinymce/plugins/save/index.js +7 -0
  88. package/lib/tinymce/plugins/save/plugin.js +118 -0
  89. package/lib/tinymce/plugins/save/plugin.min.js +4 -0
  90. package/lib/tinymce/plugins/searchreplace/index.js +7 -0
  91. package/lib/tinymce/plugins/searchreplace/plugin.js +1079 -0
  92. package/lib/tinymce/plugins/searchreplace/plugin.min.js +4 -0
  93. package/lib/tinymce/plugins/table/index.js +7 -0
  94. package/lib/tinymce/plugins/table/plugin.js +3393 -0
  95. package/lib/tinymce/plugins/table/plugin.min.js +4 -0
  96. package/lib/tinymce/plugins/template/index.js +7 -0
  97. package/lib/tinymce/plugins/template/plugin.js +548 -0
  98. package/lib/tinymce/plugins/template/plugin.min.js +4 -0
  99. package/lib/tinymce/plugins/visualblocks/index.js +7 -0
  100. package/lib/tinymce/plugins/visualblocks/plugin.js +98 -0
  101. package/lib/tinymce/plugins/visualblocks/plugin.min.js +4 -0
  102. package/lib/tinymce/plugins/visualchars/index.js +7 -0
  103. package/lib/tinymce/plugins/visualchars/plugin.js +506 -0
  104. package/lib/tinymce/plugins/visualchars/plugin.min.js +4 -0
  105. package/lib/tinymce/plugins/wordcount/index.js +7 -0
  106. package/lib/tinymce/plugins/wordcount/plugin.js +404 -0
  107. package/lib/tinymce/plugins/wordcount/plugin.min.js +4 -0
  108. package/lib/tinymce/themes/silver/index.js +7 -0
  109. package/lib/tinymce/themes/silver/theme.js +26184 -0
  110. package/lib/tinymce/themes/silver/theme.min.js +4 -0
  111. package/lib/tinymce/tinymce.d.ts +2895 -0
  112. package/lib/tinymce/tinymce.js +29400 -0
  113. package/package.json +1 -1
  114. package/packages/components/editor/src/index.vue +24 -23
@@ -0,0 +1,1820 @@
1
+ /**
2
+ * TinyMCE version 6.1.2 (2022-07-29)
3
+ */
4
+
5
+ (function () {
6
+ 'use strict';
7
+
8
+ var global$6 = tinymce.util.Tools.resolve('tinymce.PluginManager');
9
+
10
+ const hasProto = (v, constructor, predicate) => {
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
+ }
17
+ };
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
+ }
29
+ };
30
+ const isType$1 = type => value => typeOf(value) === type;
31
+ const isSimpleType = type => value => typeof value === type;
32
+ const isString = isType$1('string');
33
+ const isObject = isType$1('object');
34
+ const isArray = isType$1('array');
35
+ const isBoolean = isSimpleType('boolean');
36
+ const isNullable = a => a === null || a === undefined;
37
+ const isNonNullable = a => !isNullable(a);
38
+ const isFunction = isSimpleType('function');
39
+ const isNumber = isSimpleType('number');
40
+
41
+ const noop = () => {
42
+ };
43
+ const constant = value => {
44
+ return () => {
45
+ return value;
46
+ };
47
+ };
48
+ const tripleEquals = (a, b) => {
49
+ return a === b;
50
+ };
51
+ const not = f => t => !f(t);
52
+ const never = constant(false);
53
+
54
+ class Optional {
55
+ constructor(tag, value) {
56
+ this.tag = tag;
57
+ this.value = value;
58
+ }
59
+ static some(value) {
60
+ return new Optional(true, value);
61
+ }
62
+ static none() {
63
+ return Optional.singletonNone;
64
+ }
65
+ fold(onNone, onSome) {
66
+ if (this.tag) {
67
+ return onSome(this.value);
68
+ } else {
69
+ return onNone();
70
+ }
71
+ }
72
+ isSome() {
73
+ return this.tag;
74
+ }
75
+ isNone() {
76
+ return !this.tag;
77
+ }
78
+ map(mapper) {
79
+ if (this.tag) {
80
+ return Optional.some(mapper(this.value));
81
+ } else {
82
+ return Optional.none();
83
+ }
84
+ }
85
+ bind(binder) {
86
+ if (this.tag) {
87
+ return binder(this.value);
88
+ } else {
89
+ return Optional.none();
90
+ }
91
+ }
92
+ exists(predicate) {
93
+ return this.tag && predicate(this.value);
94
+ }
95
+ forall(predicate) {
96
+ return !this.tag || predicate(this.value);
97
+ }
98
+ filter(predicate) {
99
+ if (!this.tag || predicate(this.value)) {
100
+ return this;
101
+ } else {
102
+ return Optional.none();
103
+ }
104
+ }
105
+ getOr(replacement) {
106
+ return this.tag ? this.value : replacement;
107
+ }
108
+ or(replacement) {
109
+ return this.tag ? this : replacement;
110
+ }
111
+ getOrThunk(thunk) {
112
+ return this.tag ? this.value : thunk();
113
+ }
114
+ orThunk(thunk) {
115
+ return this.tag ? this : thunk();
116
+ }
117
+ getOrDie(message) {
118
+ if (!this.tag) {
119
+ throw new Error(message !== null && message !== void 0 ? message : 'Called getOrDie on None');
120
+ } else {
121
+ return this.value;
122
+ }
123
+ }
124
+ static from(value) {
125
+ return isNonNullable(value) ? Optional.some(value) : Optional.none();
126
+ }
127
+ getOrNull() {
128
+ return this.tag ? this.value : null;
129
+ }
130
+ getOrUndefined() {
131
+ return this.value;
132
+ }
133
+ each(worker) {
134
+ if (this.tag) {
135
+ worker(this.value);
136
+ }
137
+ }
138
+ toArray() {
139
+ return this.tag ? [this.value] : [];
140
+ }
141
+ toString() {
142
+ return this.tag ? `some(${ this.value })` : 'none()';
143
+ }
144
+ }
145
+ Optional.singletonNone = new Optional(false);
146
+
147
+ const nativeSlice = Array.prototype.slice;
148
+ const nativeIndexOf = Array.prototype.indexOf;
149
+ const nativePush = Array.prototype.push;
150
+ const rawIndexOf = (ts, t) => nativeIndexOf.call(ts, t);
151
+ const contains$1 = (xs, x) => rawIndexOf(xs, x) > -1;
152
+ const exists = (xs, pred) => {
153
+ for (let i = 0, len = xs.length; i < len; i++) {
154
+ const x = xs[i];
155
+ if (pred(x, i)) {
156
+ return true;
157
+ }
158
+ }
159
+ return false;
160
+ };
161
+ const map = (xs, f) => {
162
+ const len = xs.length;
163
+ const r = new Array(len);
164
+ for (let i = 0; i < len; i++) {
165
+ const x = xs[i];
166
+ r[i] = f(x, i);
167
+ }
168
+ return r;
169
+ };
170
+ const each$1 = (xs, f) => {
171
+ for (let i = 0, len = xs.length; i < len; i++) {
172
+ const x = xs[i];
173
+ f(x, i);
174
+ }
175
+ };
176
+ const filter$1 = (xs, pred) => {
177
+ const r = [];
178
+ for (let i = 0, len = xs.length; i < len; i++) {
179
+ const x = xs[i];
180
+ if (pred(x, i)) {
181
+ r.push(x);
182
+ }
183
+ }
184
+ return r;
185
+ };
186
+ const groupBy = (xs, f) => {
187
+ if (xs.length === 0) {
188
+ return [];
189
+ } else {
190
+ let wasType = f(xs[0]);
191
+ const r = [];
192
+ let group = [];
193
+ for (let i = 0, len = xs.length; i < len; i++) {
194
+ const x = xs[i];
195
+ const type = f(x);
196
+ if (type !== wasType) {
197
+ r.push(group);
198
+ group = [];
199
+ }
200
+ wasType = type;
201
+ group.push(x);
202
+ }
203
+ if (group.length !== 0) {
204
+ r.push(group);
205
+ }
206
+ return r;
207
+ }
208
+ };
209
+ const foldl = (xs, f, acc) => {
210
+ each$1(xs, (x, i) => {
211
+ acc = f(acc, x, i);
212
+ });
213
+ return acc;
214
+ };
215
+ const findUntil = (xs, pred, until) => {
216
+ for (let i = 0, len = xs.length; i < len; i++) {
217
+ const x = xs[i];
218
+ if (pred(x, i)) {
219
+ return Optional.some(x);
220
+ } else if (until(x, i)) {
221
+ break;
222
+ }
223
+ }
224
+ return Optional.none();
225
+ };
226
+ const find = (xs, pred) => {
227
+ return findUntil(xs, pred, never);
228
+ };
229
+ const flatten = xs => {
230
+ const r = [];
231
+ for (let i = 0, len = xs.length; i < len; ++i) {
232
+ if (!isArray(xs[i])) {
233
+ throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
234
+ }
235
+ nativePush.apply(r, xs[i]);
236
+ }
237
+ return r;
238
+ };
239
+ const bind = (xs, f) => flatten(map(xs, f));
240
+ const reverse = xs => {
241
+ const r = nativeSlice.call(xs, 0);
242
+ r.reverse();
243
+ return r;
244
+ };
245
+ const get$1 = (xs, i) => i >= 0 && i < xs.length ? Optional.some(xs[i]) : Optional.none();
246
+ const head = xs => get$1(xs, 0);
247
+ const last = xs => get$1(xs, xs.length - 1);
248
+ const unique = (xs, comparator) => {
249
+ const r = [];
250
+ const isDuplicated = isFunction(comparator) ? x => exists(r, i => comparator(i, x)) : x => contains$1(r, x);
251
+ for (let i = 0, len = xs.length; i < len; i++) {
252
+ const x = xs[i];
253
+ if (!isDuplicated(x)) {
254
+ r.push(x);
255
+ }
256
+ }
257
+ return r;
258
+ };
259
+
260
+ const is$2 = (lhs, rhs, comparator = tripleEquals) => lhs.exists(left => comparator(left, rhs));
261
+ const equals = (lhs, rhs, comparator = tripleEquals) => lift2(lhs, rhs, comparator).getOr(lhs.isNone() && rhs.isNone());
262
+ const lift2 = (oa, ob, f) => oa.isSome() && ob.isSome() ? Optional.some(f(oa.getOrDie(), ob.getOrDie())) : Optional.none();
263
+
264
+ const ELEMENT = 1;
265
+
266
+ const fromHtml = (html, scope) => {
267
+ const doc = scope || document;
268
+ const div = doc.createElement('div');
269
+ div.innerHTML = html;
270
+ if (!div.hasChildNodes() || div.childNodes.length > 1) {
271
+ const message = 'HTML does not have a single root node';
272
+ console.error(message, html);
273
+ throw new Error(message);
274
+ }
275
+ return fromDom(div.childNodes[0]);
276
+ };
277
+ const fromTag = (tag, scope) => {
278
+ const doc = scope || document;
279
+ const node = doc.createElement(tag);
280
+ return fromDom(node);
281
+ };
282
+ const fromText = (text, scope) => {
283
+ const doc = scope || document;
284
+ const node = doc.createTextNode(text);
285
+ return fromDom(node);
286
+ };
287
+ const fromDom = node => {
288
+ if (node === null || node === undefined) {
289
+ throw new Error('Node cannot be null or undefined');
290
+ }
291
+ return { dom: node };
292
+ };
293
+ const fromPoint = (docElm, x, y) => Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom);
294
+ const SugarElement = {
295
+ fromHtml,
296
+ fromTag,
297
+ fromText,
298
+ fromDom,
299
+ fromPoint
300
+ };
301
+
302
+ const is$1 = (element, selector) => {
303
+ const dom = element.dom;
304
+ if (dom.nodeType !== ELEMENT) {
305
+ return false;
306
+ } else {
307
+ const elem = dom;
308
+ if (elem.matches !== undefined) {
309
+ return elem.matches(selector);
310
+ } else if (elem.msMatchesSelector !== undefined) {
311
+ return elem.msMatchesSelector(selector);
312
+ } else if (elem.webkitMatchesSelector !== undefined) {
313
+ return elem.webkitMatchesSelector(selector);
314
+ } else if (elem.mozMatchesSelector !== undefined) {
315
+ return elem.mozMatchesSelector(selector);
316
+ } else {
317
+ throw new Error('Browser lacks native selectors');
318
+ }
319
+ }
320
+ };
321
+
322
+ const eq = (e1, e2) => e1.dom === e2.dom;
323
+ const contains = (e1, e2) => {
324
+ const d1 = e1.dom;
325
+ const d2 = e2.dom;
326
+ return d1 === d2 ? false : d1.contains(d2);
327
+ };
328
+ const is = is$1;
329
+
330
+ var ClosestOrAncestor = (is, ancestor, scope, a, isRoot) => {
331
+ if (is(scope, a)) {
332
+ return Optional.some(scope);
333
+ } else if (isFunction(isRoot) && isRoot(scope)) {
334
+ return Optional.none();
335
+ } else {
336
+ return ancestor(scope, a, isRoot);
337
+ }
338
+ };
339
+
340
+ typeof window !== 'undefined' ? window : Function('return this;')();
341
+
342
+ const name = element => {
343
+ const r = element.dom.nodeName;
344
+ return r.toLowerCase();
345
+ };
346
+ const type = element => element.dom.nodeType;
347
+ const isType = t => element => type(element) === t;
348
+ const isElement = isType(ELEMENT);
349
+ const isTag = tag => e => isElement(e) && name(e) === tag;
350
+
351
+ const parent = element => Optional.from(element.dom.parentNode).map(SugarElement.fromDom);
352
+ const nextSibling = element => Optional.from(element.dom.nextSibling).map(SugarElement.fromDom);
353
+ const children = element => map(element.dom.childNodes, SugarElement.fromDom);
354
+ const child = (element, index) => {
355
+ const cs = element.dom.childNodes;
356
+ return Optional.from(cs[index]).map(SugarElement.fromDom);
357
+ };
358
+ const firstChild = element => child(element, 0);
359
+ const lastChild = element => child(element, element.dom.childNodes.length - 1);
360
+
361
+ const ancestor = (scope, predicate, isRoot) => {
362
+ let element = scope.dom;
363
+ const stop = isFunction(isRoot) ? isRoot : never;
364
+ while (element.parentNode) {
365
+ element = element.parentNode;
366
+ const el = SugarElement.fromDom(element);
367
+ if (predicate(el)) {
368
+ return Optional.some(el);
369
+ } else if (stop(el)) {
370
+ break;
371
+ }
372
+ }
373
+ return Optional.none();
374
+ };
375
+ const closest = (scope, predicate, isRoot) => {
376
+ const is = (s, test) => test(s);
377
+ return ClosestOrAncestor(is, ancestor, scope, predicate, isRoot);
378
+ };
379
+
380
+ const before$1 = (marker, element) => {
381
+ const parent$1 = parent(marker);
382
+ parent$1.each(v => {
383
+ v.dom.insertBefore(element.dom, marker.dom);
384
+ });
385
+ };
386
+ const after = (marker, element) => {
387
+ const sibling = nextSibling(marker);
388
+ sibling.fold(() => {
389
+ const parent$1 = parent(marker);
390
+ parent$1.each(v => {
391
+ append$1(v, element);
392
+ });
393
+ }, v => {
394
+ before$1(v, element);
395
+ });
396
+ };
397
+ const append$1 = (parent, element) => {
398
+ parent.dom.appendChild(element.dom);
399
+ };
400
+
401
+ const before = (marker, elements) => {
402
+ each$1(elements, x => {
403
+ before$1(marker, x);
404
+ });
405
+ };
406
+ const append = (parent, elements) => {
407
+ each$1(elements, x => {
408
+ append$1(parent, x);
409
+ });
410
+ };
411
+
412
+ const empty = element => {
413
+ element.dom.textContent = '';
414
+ each$1(children(element), rogue => {
415
+ remove(rogue);
416
+ });
417
+ };
418
+ const remove = element => {
419
+ const dom = element.dom;
420
+ if (dom.parentNode !== null) {
421
+ dom.parentNode.removeChild(dom);
422
+ }
423
+ };
424
+
425
+ var global$5 = tinymce.util.Tools.resolve('tinymce.dom.RangeUtils');
426
+
427
+ var global$4 = tinymce.util.Tools.resolve('tinymce.dom.TreeWalker');
428
+
429
+ var global$3 = tinymce.util.Tools.resolve('tinymce.util.VK');
430
+
431
+ const keys = Object.keys;
432
+ const each = (obj, f) => {
433
+ const props = keys(obj);
434
+ for (let k = 0, len = props.length; k < len; k++) {
435
+ const i = props[k];
436
+ const x = obj[i];
437
+ f(x, i);
438
+ }
439
+ };
440
+ const objAcc = r => (x, i) => {
441
+ r[i] = x;
442
+ };
443
+ const internalFilter = (obj, pred, onTrue, onFalse) => {
444
+ const r = {};
445
+ each(obj, (x, i) => {
446
+ (pred(x, i) ? onTrue : onFalse)(x, i);
447
+ });
448
+ return r;
449
+ };
450
+ const filter = (obj, pred) => {
451
+ const t = {};
452
+ internalFilter(obj, pred, objAcc(t), noop);
453
+ return t;
454
+ };
455
+
456
+ const rawSet = (dom, key, value) => {
457
+ if (isString(value) || isBoolean(value) || isNumber(value)) {
458
+ dom.setAttribute(key, value + '');
459
+ } else {
460
+ console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom);
461
+ throw new Error('Attribute value was not simple');
462
+ }
463
+ };
464
+ const setAll = (element, attrs) => {
465
+ const dom = element.dom;
466
+ each(attrs, (v, k) => {
467
+ rawSet(dom, k, v);
468
+ });
469
+ };
470
+ const clone$1 = element => foldl(element.dom.attributes, (acc, attr) => {
471
+ acc[attr.name] = attr.value;
472
+ return acc;
473
+ }, {});
474
+
475
+ const clone = (original, isDeep) => SugarElement.fromDom(original.dom.cloneNode(isDeep));
476
+ const deep = original => clone(original, true);
477
+ const shallowAs = (original, tag) => {
478
+ const nu = SugarElement.fromTag(tag);
479
+ const attributes = clone$1(original);
480
+ setAll(nu, attributes);
481
+ return nu;
482
+ };
483
+ const mutate = (original, tag) => {
484
+ const nu = shallowAs(original, tag);
485
+ after(original, nu);
486
+ const children$1 = children(original);
487
+ append(nu, children$1);
488
+ remove(original);
489
+ return nu;
490
+ };
491
+
492
+ var global$2 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
493
+
494
+ var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools');
495
+
496
+ const matchNodeName = name => node => node && node.nodeName.toLowerCase() === name;
497
+ const matchNodeNames = regex => node => node && regex.test(node.nodeName);
498
+ const isTextNode = node => node && node.nodeType === 3;
499
+ const isListNode = matchNodeNames(/^(OL|UL|DL)$/);
500
+ const isOlUlNode = matchNodeNames(/^(OL|UL)$/);
501
+ const isOlNode = matchNodeName('ol');
502
+ const isListItemNode = matchNodeNames(/^(LI|DT|DD)$/);
503
+ const isDlItemNode = matchNodeNames(/^(DT|DD)$/);
504
+ const isTableCellNode = matchNodeNames(/^(TH|TD)$/);
505
+ const isBr = matchNodeName('br');
506
+ const isFirstChild = node => node.parentNode.firstChild === node;
507
+ const isTextBlock = (editor, node) => node && !!editor.schema.getTextBlockElements()[node.nodeName];
508
+ const isBlock = (node, blockElements) => node && node.nodeName in blockElements;
509
+ const isBogusBr = (dom, node) => {
510
+ if (!isBr(node)) {
511
+ return false;
512
+ }
513
+ return dom.isBlock(node.nextSibling) && !isBr(node.previousSibling);
514
+ };
515
+ const isEmpty$1 = (dom, elm, keepBookmarks) => {
516
+ const empty = dom.isEmpty(elm);
517
+ if (keepBookmarks && dom.select('span[data-mce-type=bookmark]', elm).length > 0) {
518
+ return false;
519
+ }
520
+ return empty;
521
+ };
522
+ const isChildOfBody = (dom, elm) => dom.isChildOf(elm, dom.getRoot());
523
+
524
+ const option = name => editor => editor.options.get(name);
525
+ const register$3 = editor => {
526
+ const registerOption = editor.options.register;
527
+ registerOption('lists_indent_on_tab', {
528
+ processor: 'boolean',
529
+ default: true
530
+ });
531
+ };
532
+ const shouldIndentOnTab = option('lists_indent_on_tab');
533
+ const getForcedRootBlock = option('forced_root_block');
534
+ const getForcedRootBlockAttrs = option('forced_root_block_attrs');
535
+
536
+ const createTextBlock = (editor, contentNode) => {
537
+ const dom = editor.dom;
538
+ const blockElements = editor.schema.getBlockElements();
539
+ const fragment = dom.createFragment();
540
+ const blockName = getForcedRootBlock(editor);
541
+ const blockAttrs = getForcedRootBlockAttrs(editor);
542
+ let node, textBlock, hasContentNode;
543
+ textBlock = dom.create(blockName, blockAttrs);
544
+ if (!isBlock(contentNode.firstChild, blockElements)) {
545
+ fragment.appendChild(textBlock);
546
+ }
547
+ while (node = contentNode.firstChild) {
548
+ const nodeName = node.nodeName;
549
+ if (!hasContentNode && (nodeName !== 'SPAN' || node.getAttribute('data-mce-type') !== 'bookmark')) {
550
+ hasContentNode = true;
551
+ }
552
+ if (isBlock(node, blockElements)) {
553
+ fragment.appendChild(node);
554
+ textBlock = null;
555
+ } else {
556
+ if (!textBlock) {
557
+ textBlock = dom.create(blockName, blockAttrs);
558
+ fragment.appendChild(textBlock);
559
+ }
560
+ textBlock.appendChild(node);
561
+ }
562
+ }
563
+ if (!hasContentNode) {
564
+ textBlock.appendChild(dom.create('br', { 'data-mce-bogus': '1' }));
565
+ }
566
+ return fragment;
567
+ };
568
+
569
+ const DOM$2 = global$2.DOM;
570
+ const splitList = (editor, list, li) => {
571
+ const removeAndKeepBookmarks = targetNode => {
572
+ global$1.each(bookmarks, node => {
573
+ targetNode.parentNode.insertBefore(node, li.parentNode);
574
+ });
575
+ DOM$2.remove(targetNode);
576
+ };
577
+ const bookmarks = DOM$2.select('span[data-mce-type="bookmark"]', list);
578
+ const newBlock = createTextBlock(editor, li);
579
+ const tmpRng = DOM$2.createRng();
580
+ tmpRng.setStartAfter(li);
581
+ tmpRng.setEndAfter(list);
582
+ const fragment = tmpRng.extractContents();
583
+ for (let node = fragment.firstChild; node; node = node.firstChild) {
584
+ if (node.nodeName === 'LI' && editor.dom.isEmpty(node)) {
585
+ DOM$2.remove(node);
586
+ break;
587
+ }
588
+ }
589
+ if (!editor.dom.isEmpty(fragment)) {
590
+ DOM$2.insertAfter(fragment, list);
591
+ }
592
+ DOM$2.insertAfter(newBlock, list);
593
+ if (isEmpty$1(editor.dom, li.parentNode)) {
594
+ removeAndKeepBookmarks(li.parentNode);
595
+ }
596
+ DOM$2.remove(li);
597
+ if (isEmpty$1(editor.dom, list)) {
598
+ DOM$2.remove(list);
599
+ }
600
+ };
601
+
602
+ const isDescriptionDetail = isTag('dd');
603
+ const isDescriptionTerm = isTag('dt');
604
+ const outdentDlItem = (editor, item) => {
605
+ if (isDescriptionDetail(item)) {
606
+ mutate(item, 'dt');
607
+ } else if (isDescriptionTerm(item)) {
608
+ parent(item).each(dl => splitList(editor, dl.dom, item.dom));
609
+ }
610
+ };
611
+ const indentDlItem = item => {
612
+ if (isDescriptionTerm(item)) {
613
+ mutate(item, 'dd');
614
+ }
615
+ };
616
+ const dlIndentation = (editor, indentation, dlItems) => {
617
+ if (indentation === 'Indent') {
618
+ each$1(dlItems, indentDlItem);
619
+ } else {
620
+ each$1(dlItems, item => outdentDlItem(editor, item));
621
+ }
622
+ };
623
+
624
+ const getNormalizedPoint = (container, offset) => {
625
+ if (isTextNode(container)) {
626
+ return {
627
+ container,
628
+ offset
629
+ };
630
+ }
631
+ const node = global$5.getNode(container, offset);
632
+ if (isTextNode(node)) {
633
+ return {
634
+ container: node,
635
+ offset: offset >= container.childNodes.length ? node.data.length : 0
636
+ };
637
+ } else if (node.previousSibling && isTextNode(node.previousSibling)) {
638
+ return {
639
+ container: node.previousSibling,
640
+ offset: node.previousSibling.data.length
641
+ };
642
+ } else if (node.nextSibling && isTextNode(node.nextSibling)) {
643
+ return {
644
+ container: node.nextSibling,
645
+ offset: 0
646
+ };
647
+ }
648
+ return {
649
+ container,
650
+ offset
651
+ };
652
+ };
653
+ const normalizeRange = rng => {
654
+ const outRng = rng.cloneRange();
655
+ const rangeStart = getNormalizedPoint(rng.startContainer, rng.startOffset);
656
+ outRng.setStart(rangeStart.container, rangeStart.offset);
657
+ const rangeEnd = getNormalizedPoint(rng.endContainer, rng.endOffset);
658
+ outRng.setEnd(rangeEnd.container, rangeEnd.offset);
659
+ return outRng;
660
+ };
661
+
662
+ const listNames = [
663
+ 'OL',
664
+ 'UL',
665
+ 'DL'
666
+ ];
667
+ const listSelector = listNames.join(',');
668
+ const getParentList = (editor, node) => {
669
+ const selectionStart = node || editor.selection.getStart(true);
670
+ return editor.dom.getParent(selectionStart, listSelector, getClosestListHost(editor, selectionStart));
671
+ };
672
+ const isParentListSelected = (parentList, selectedBlocks) => parentList && selectedBlocks.length === 1 && selectedBlocks[0] === parentList;
673
+ const findSubLists = parentList => filter$1(parentList.querySelectorAll(listSelector), isListNode);
674
+ const getSelectedSubLists = editor => {
675
+ const parentList = getParentList(editor);
676
+ const selectedBlocks = editor.selection.getSelectedBlocks();
677
+ if (isParentListSelected(parentList, selectedBlocks)) {
678
+ return findSubLists(parentList);
679
+ } else {
680
+ return filter$1(selectedBlocks, elm => {
681
+ return isListNode(elm) && parentList !== elm;
682
+ });
683
+ }
684
+ };
685
+ const findParentListItemsNodes = (editor, elms) => {
686
+ const listItemsElms = global$1.map(elms, elm => {
687
+ const parentLi = editor.dom.getParent(elm, 'li,dd,dt', getClosestListHost(editor, elm));
688
+ return parentLi ? parentLi : elm;
689
+ });
690
+ return unique(listItemsElms);
691
+ };
692
+ const getSelectedListItems = editor => {
693
+ const selectedBlocks = editor.selection.getSelectedBlocks();
694
+ return filter$1(findParentListItemsNodes(editor, selectedBlocks), isListItemNode);
695
+ };
696
+ const getSelectedDlItems = editor => filter$1(getSelectedListItems(editor), isDlItemNode);
697
+ const getClosestEditingHost = (editor, elm) => {
698
+ const parentTableCell = editor.dom.getParents(elm, 'TD,TH');
699
+ return parentTableCell.length > 0 ? parentTableCell[0] : editor.getBody();
700
+ };
701
+ const isListHost = (schema, node) => !isListNode(node) && !isListItemNode(node) && exists(listNames, listName => schema.isValidChild(node.nodeName, listName));
702
+ const getClosestListHost = (editor, elm) => {
703
+ const parentBlocks = editor.dom.getParents(elm, editor.dom.isBlock);
704
+ const parentBlock = find(parentBlocks, elm => isListHost(editor.schema, elm));
705
+ return parentBlock.getOr(editor.getBody());
706
+ };
707
+ const findLastParentListNode = (editor, elm) => {
708
+ const parentLists = editor.dom.getParents(elm, 'ol,ul', getClosestListHost(editor, elm));
709
+ return last(parentLists);
710
+ };
711
+ const getSelectedLists = editor => {
712
+ const firstList = findLastParentListNode(editor, editor.selection.getStart());
713
+ const subsequentLists = filter$1(editor.selection.getSelectedBlocks(), isOlUlNode);
714
+ return firstList.toArray().concat(subsequentLists);
715
+ };
716
+ const getSelectedListRoots = editor => {
717
+ const selectedLists = getSelectedLists(editor);
718
+ return getUniqueListRoots(editor, selectedLists);
719
+ };
720
+ const getUniqueListRoots = (editor, lists) => {
721
+ const listRoots = map(lists, list => findLastParentListNode(editor, list).getOr(list));
722
+ return unique(listRoots);
723
+ };
724
+
725
+ const fromElements = (elements, scope) => {
726
+ const doc = scope || document;
727
+ const fragment = doc.createDocumentFragment();
728
+ each$1(elements, element => {
729
+ fragment.appendChild(element.dom);
730
+ });
731
+ return SugarElement.fromDom(fragment);
732
+ };
733
+
734
+ const fireListEvent = (editor, action, element) => editor.dispatch('ListMutation', {
735
+ action,
736
+ element
737
+ });
738
+
739
+ const blank = r => s => s.replace(r, '');
740
+ const trim = blank(/^\s+|\s+$/g);
741
+ const isNotEmpty = s => s.length > 0;
742
+ const isEmpty = s => !isNotEmpty(s);
743
+
744
+ const isSupported = dom => dom.style !== undefined && isFunction(dom.style.getPropertyValue);
745
+
746
+ const internalSet = (dom, property, value) => {
747
+ if (!isString(value)) {
748
+ console.error('Invalid call to CSS.set. Property ', property, ':: Value ', value, ':: Element ', dom);
749
+ throw new Error('CSS value must be a string: ' + value);
750
+ }
751
+ if (isSupported(dom)) {
752
+ dom.style.setProperty(property, value);
753
+ }
754
+ };
755
+ const set = (element, property, value) => {
756
+ const dom = element.dom;
757
+ internalSet(dom, property, value);
758
+ };
759
+
760
+ const joinSegment = (parent, child) => {
761
+ append$1(parent.item, child.list);
762
+ };
763
+ const joinSegments = segments => {
764
+ for (let i = 1; i < segments.length; i++) {
765
+ joinSegment(segments[i - 1], segments[i]);
766
+ }
767
+ };
768
+ const appendSegments = (head$1, tail) => {
769
+ lift2(last(head$1), head(tail), joinSegment);
770
+ };
771
+ const createSegment = (scope, listType) => {
772
+ const segment = {
773
+ list: SugarElement.fromTag(listType, scope),
774
+ item: SugarElement.fromTag('li', scope)
775
+ };
776
+ append$1(segment.list, segment.item);
777
+ return segment;
778
+ };
779
+ const createSegments = (scope, entry, size) => {
780
+ const segments = [];
781
+ for (let i = 0; i < size; i++) {
782
+ segments.push(createSegment(scope, entry.listType));
783
+ }
784
+ return segments;
785
+ };
786
+ const populateSegments = (segments, entry) => {
787
+ for (let i = 0; i < segments.length - 1; i++) {
788
+ set(segments[i].item, 'list-style-type', 'none');
789
+ }
790
+ last(segments).each(segment => {
791
+ setAll(segment.list, entry.listAttributes);
792
+ setAll(segment.item, entry.itemAttributes);
793
+ append(segment.item, entry.content);
794
+ });
795
+ };
796
+ const normalizeSegment = (segment, entry) => {
797
+ if (name(segment.list) !== entry.listType) {
798
+ segment.list = mutate(segment.list, entry.listType);
799
+ }
800
+ setAll(segment.list, entry.listAttributes);
801
+ };
802
+ const createItem = (scope, attr, content) => {
803
+ const item = SugarElement.fromTag('li', scope);
804
+ setAll(item, attr);
805
+ append(item, content);
806
+ return item;
807
+ };
808
+ const appendItem = (segment, item) => {
809
+ append$1(segment.list, item);
810
+ segment.item = item;
811
+ };
812
+ const writeShallow = (scope, cast, entry) => {
813
+ const newCast = cast.slice(0, entry.depth);
814
+ last(newCast).each(segment => {
815
+ const item = createItem(scope, entry.itemAttributes, entry.content);
816
+ appendItem(segment, item);
817
+ normalizeSegment(segment, entry);
818
+ });
819
+ return newCast;
820
+ };
821
+ const writeDeep = (scope, cast, entry) => {
822
+ const segments = createSegments(scope, entry, entry.depth - cast.length);
823
+ joinSegments(segments);
824
+ populateSegments(segments, entry);
825
+ appendSegments(cast, segments);
826
+ return cast.concat(segments);
827
+ };
828
+ const composeList = (scope, entries) => {
829
+ const cast = foldl(entries, (cast, entry) => {
830
+ return entry.depth > cast.length ? writeDeep(scope, cast, entry) : writeShallow(scope, cast, entry);
831
+ }, []);
832
+ return head(cast).map(segment => segment.list);
833
+ };
834
+
835
+ const isList = el => is(el, 'OL,UL');
836
+ const hasFirstChildList = el => firstChild(el).exists(isList);
837
+ const hasLastChildList = el => lastChild(el).exists(isList);
838
+
839
+ const isIndented = entry => entry.depth > 0;
840
+ const isSelected = entry => entry.isSelected;
841
+ const cloneItemContent = li => {
842
+ const children$1 = children(li);
843
+ const content = hasLastChildList(li) ? children$1.slice(0, -1) : children$1;
844
+ return map(content, deep);
845
+ };
846
+ const createEntry = (li, depth, isSelected) => parent(li).filter(isElement).map(list => ({
847
+ depth,
848
+ dirty: false,
849
+ isSelected,
850
+ content: cloneItemContent(li),
851
+ itemAttributes: clone$1(li),
852
+ listAttributes: clone$1(list),
853
+ listType: name(list)
854
+ }));
855
+
856
+ const indentEntry = (indentation, entry) => {
857
+ switch (indentation) {
858
+ case 'Indent':
859
+ entry.depth++;
860
+ break;
861
+ case 'Outdent':
862
+ entry.depth--;
863
+ break;
864
+ case 'Flatten':
865
+ entry.depth = 0;
866
+ }
867
+ entry.dirty = true;
868
+ };
869
+
870
+ const cloneListProperties = (target, source) => {
871
+ target.listType = source.listType;
872
+ target.listAttributes = { ...source.listAttributes };
873
+ };
874
+ const cleanListProperties = entry => {
875
+ entry.listAttributes = filter(entry.listAttributes, (_value, key) => key !== 'start');
876
+ };
877
+ const closestSiblingEntry = (entries, start) => {
878
+ const depth = entries[start].depth;
879
+ const matches = entry => entry.depth === depth && !entry.dirty;
880
+ const until = entry => entry.depth < depth;
881
+ return findUntil(reverse(entries.slice(0, start)), matches, until).orThunk(() => findUntil(entries.slice(start + 1), matches, until));
882
+ };
883
+ const normalizeEntries = entries => {
884
+ each$1(entries, (entry, i) => {
885
+ closestSiblingEntry(entries, i).fold(() => {
886
+ if (entry.dirty) {
887
+ cleanListProperties(entry);
888
+ }
889
+ }, matchingEntry => cloneListProperties(entry, matchingEntry));
890
+ });
891
+ return entries;
892
+ };
893
+
894
+ const Cell = initial => {
895
+ let value = initial;
896
+ const get = () => {
897
+ return value;
898
+ };
899
+ const set = v => {
900
+ value = v;
901
+ };
902
+ return {
903
+ get,
904
+ set
905
+ };
906
+ };
907
+
908
+ const parseItem = (depth, itemSelection, selectionState, item) => firstChild(item).filter(isList).fold(() => {
909
+ itemSelection.each(selection => {
910
+ if (eq(selection.start, item)) {
911
+ selectionState.set(true);
912
+ }
913
+ });
914
+ const currentItemEntry = createEntry(item, depth, selectionState.get());
915
+ itemSelection.each(selection => {
916
+ if (eq(selection.end, item)) {
917
+ selectionState.set(false);
918
+ }
919
+ });
920
+ const childListEntries = lastChild(item).filter(isList).map(list => parseList(depth, itemSelection, selectionState, list)).getOr([]);
921
+ return currentItemEntry.toArray().concat(childListEntries);
922
+ }, list => parseList(depth, itemSelection, selectionState, list));
923
+ const parseList = (depth, itemSelection, selectionState, list) => bind(children(list), element => {
924
+ const parser = isList(element) ? parseList : parseItem;
925
+ const newDepth = depth + 1;
926
+ return parser(newDepth, itemSelection, selectionState, element);
927
+ });
928
+ const parseLists = (lists, itemSelection) => {
929
+ const selectionState = Cell(false);
930
+ const initialDepth = 0;
931
+ return map(lists, list => ({
932
+ sourceList: list,
933
+ entries: parseList(initialDepth, itemSelection, selectionState, list)
934
+ }));
935
+ };
936
+
937
+ const outdentedComposer = (editor, entries) => {
938
+ const normalizedEntries = normalizeEntries(entries);
939
+ return map(normalizedEntries, entry => {
940
+ const content = fromElements(entry.content);
941
+ return SugarElement.fromDom(createTextBlock(editor, content.dom));
942
+ });
943
+ };
944
+ const indentedComposer = (editor, entries) => {
945
+ const normalizedEntries = normalizeEntries(entries);
946
+ return composeList(editor.contentDocument, normalizedEntries).toArray();
947
+ };
948
+ const composeEntries = (editor, entries) => bind(groupBy(entries, isIndented), entries => {
949
+ const groupIsIndented = head(entries).exists(isIndented);
950
+ return groupIsIndented ? indentedComposer(editor, entries) : outdentedComposer(editor, entries);
951
+ });
952
+ const indentSelectedEntries = (entries, indentation) => {
953
+ each$1(filter$1(entries, isSelected), entry => indentEntry(indentation, entry));
954
+ };
955
+ const getItemSelection = editor => {
956
+ const selectedListItems = map(getSelectedListItems(editor), SugarElement.fromDom);
957
+ return lift2(find(selectedListItems, not(hasFirstChildList)), find(reverse(selectedListItems), not(hasFirstChildList)), (start, end) => ({
958
+ start,
959
+ end
960
+ }));
961
+ };
962
+ const listIndentation = (editor, lists, indentation) => {
963
+ const entrySets = parseLists(lists, getItemSelection(editor));
964
+ each$1(entrySets, entrySet => {
965
+ indentSelectedEntries(entrySet.entries, indentation);
966
+ const composedLists = composeEntries(editor, entrySet.entries);
967
+ each$1(composedLists, composedList => {
968
+ fireListEvent(editor, indentation === 'Indent' ? 'IndentList' : 'OutdentList', composedList.dom);
969
+ });
970
+ before(entrySet.sourceList, composedLists);
971
+ remove(entrySet.sourceList);
972
+ });
973
+ };
974
+
975
+ const selectionIndentation = (editor, indentation) => {
976
+ const lists = map(getSelectedListRoots(editor), SugarElement.fromDom);
977
+ const dlItems = map(getSelectedDlItems(editor), SugarElement.fromDom);
978
+ let isHandled = false;
979
+ if (lists.length || dlItems.length) {
980
+ const bookmark = editor.selection.getBookmark();
981
+ listIndentation(editor, lists, indentation);
982
+ dlIndentation(editor, indentation, dlItems);
983
+ editor.selection.moveToBookmark(bookmark);
984
+ editor.selection.setRng(normalizeRange(editor.selection.getRng()));
985
+ editor.nodeChanged();
986
+ isHandled = true;
987
+ }
988
+ return isHandled;
989
+ };
990
+ const indentListSelection = editor => selectionIndentation(editor, 'Indent');
991
+ const outdentListSelection = editor => selectionIndentation(editor, 'Outdent');
992
+ const flattenListSelection = editor => selectionIndentation(editor, 'Flatten');
993
+
994
+ var global = tinymce.util.Tools.resolve('tinymce.dom.BookmarkManager');
995
+
996
+ const DOM$1 = global$2.DOM;
997
+ const createBookmark = rng => {
998
+ const bookmark = {};
999
+ const setupEndPoint = start => {
1000
+ let container = rng[start ? 'startContainer' : 'endContainer'];
1001
+ let offset = rng[start ? 'startOffset' : 'endOffset'];
1002
+ if (container.nodeType === 1) {
1003
+ const offsetNode = DOM$1.create('span', { 'data-mce-type': 'bookmark' });
1004
+ if (container.hasChildNodes()) {
1005
+ offset = Math.min(offset, container.childNodes.length - 1);
1006
+ if (start) {
1007
+ container.insertBefore(offsetNode, container.childNodes[offset]);
1008
+ } else {
1009
+ DOM$1.insertAfter(offsetNode, container.childNodes[offset]);
1010
+ }
1011
+ } else {
1012
+ container.appendChild(offsetNode);
1013
+ }
1014
+ container = offsetNode;
1015
+ offset = 0;
1016
+ }
1017
+ bookmark[start ? 'startContainer' : 'endContainer'] = container;
1018
+ bookmark[start ? 'startOffset' : 'endOffset'] = offset;
1019
+ };
1020
+ setupEndPoint(true);
1021
+ if (!rng.collapsed) {
1022
+ setupEndPoint();
1023
+ }
1024
+ return bookmark;
1025
+ };
1026
+ const resolveBookmark = bookmark => {
1027
+ const restoreEndPoint = start => {
1028
+ let node;
1029
+ const nodeIndex = container => {
1030
+ let node = container.parentNode.firstChild, idx = 0;
1031
+ while (node) {
1032
+ if (node === container) {
1033
+ return idx;
1034
+ }
1035
+ if (node.nodeType !== 1 || node.getAttribute('data-mce-type') !== 'bookmark') {
1036
+ idx++;
1037
+ }
1038
+ node = node.nextSibling;
1039
+ }
1040
+ return -1;
1041
+ };
1042
+ let container = node = bookmark[start ? 'startContainer' : 'endContainer'];
1043
+ let offset = bookmark[start ? 'startOffset' : 'endOffset'];
1044
+ if (!container) {
1045
+ return;
1046
+ }
1047
+ if (container.nodeType === 1) {
1048
+ offset = nodeIndex(container);
1049
+ container = container.parentNode;
1050
+ DOM$1.remove(node);
1051
+ if (!container.hasChildNodes() && DOM$1.isBlock(container)) {
1052
+ container.appendChild(DOM$1.create('br'));
1053
+ }
1054
+ }
1055
+ bookmark[start ? 'startContainer' : 'endContainer'] = container;
1056
+ bookmark[start ? 'startOffset' : 'endOffset'] = offset;
1057
+ };
1058
+ restoreEndPoint(true);
1059
+ restoreEndPoint();
1060
+ const rng = DOM$1.createRng();
1061
+ rng.setStart(bookmark.startContainer, bookmark.startOffset);
1062
+ if (bookmark.endContainer) {
1063
+ rng.setEnd(bookmark.endContainer, bookmark.endOffset);
1064
+ }
1065
+ return normalizeRange(rng);
1066
+ };
1067
+
1068
+ const listToggleActionFromListName = listName => {
1069
+ switch (listName) {
1070
+ case 'UL':
1071
+ return 'ToggleUlList';
1072
+ case 'OL':
1073
+ return 'ToggleOlList';
1074
+ case 'DL':
1075
+ return 'ToggleDLList';
1076
+ }
1077
+ };
1078
+
1079
+ const isCustomList = list => /\btox\-/.test(list.className);
1080
+ const listState = (editor, listName, activate) => {
1081
+ const nodeChangeHandler = e => {
1082
+ const inList = findUntil(e.parents, isListNode, isTableCellNode).filter(list => list.nodeName === listName && !isCustomList(list)).isSome();
1083
+ activate(inList);
1084
+ };
1085
+ const parents = editor.dom.getParents(editor.selection.getNode());
1086
+ nodeChangeHandler({ parents });
1087
+ editor.on('NodeChange', nodeChangeHandler);
1088
+ return () => editor.off('NodeChange', nodeChangeHandler);
1089
+ };
1090
+
1091
+ const updateListStyle = (dom, el, detail) => {
1092
+ const type = detail['list-style-type'] ? detail['list-style-type'] : null;
1093
+ dom.setStyle(el, 'list-style-type', type);
1094
+ };
1095
+ const setAttribs = (elm, attrs) => {
1096
+ global$1.each(attrs, (value, key) => {
1097
+ elm.setAttribute(key, value);
1098
+ });
1099
+ };
1100
+ const updateListAttrs = (dom, el, detail) => {
1101
+ setAttribs(el, detail['list-attributes']);
1102
+ global$1.each(dom.select('li', el), li => {
1103
+ setAttribs(li, detail['list-item-attributes']);
1104
+ });
1105
+ };
1106
+ const updateListWithDetails = (dom, el, detail) => {
1107
+ updateListStyle(dom, el, detail);
1108
+ updateListAttrs(dom, el, detail);
1109
+ };
1110
+ const removeStyles = (dom, element, styles) => {
1111
+ global$1.each(styles, style => dom.setStyle(element, style, ''));
1112
+ };
1113
+ const getEndPointNode = (editor, rng, start, root) => {
1114
+ let container = rng[start ? 'startContainer' : 'endContainer'];
1115
+ const offset = rng[start ? 'startOffset' : 'endOffset'];
1116
+ if (container.nodeType === 1) {
1117
+ container = container.childNodes[Math.min(offset, container.childNodes.length - 1)] || container;
1118
+ }
1119
+ if (!start && isBr(container.nextSibling)) {
1120
+ container = container.nextSibling;
1121
+ }
1122
+ while (container.parentNode !== root) {
1123
+ if (isTextBlock(editor, container)) {
1124
+ return container;
1125
+ }
1126
+ if (/^(TD|TH)$/.test(container.parentNode.nodeName)) {
1127
+ return container;
1128
+ }
1129
+ container = container.parentNode;
1130
+ }
1131
+ return container;
1132
+ };
1133
+ const getSelectedTextBlocks = (editor, rng, root) => {
1134
+ const textBlocks = [];
1135
+ const dom = editor.dom;
1136
+ const startNode = getEndPointNode(editor, rng, true, root);
1137
+ const endNode = getEndPointNode(editor, rng, false, root);
1138
+ let block;
1139
+ const siblings = [];
1140
+ for (let node = startNode; node; node = node.nextSibling) {
1141
+ siblings.push(node);
1142
+ if (node === endNode) {
1143
+ break;
1144
+ }
1145
+ }
1146
+ global$1.each(siblings, node => {
1147
+ if (isTextBlock(editor, node)) {
1148
+ textBlocks.push(node);
1149
+ block = null;
1150
+ return;
1151
+ }
1152
+ if (dom.isBlock(node) || isBr(node)) {
1153
+ if (isBr(node)) {
1154
+ dom.remove(node);
1155
+ }
1156
+ block = null;
1157
+ return;
1158
+ }
1159
+ const nextSibling = node.nextSibling;
1160
+ if (global.isBookmarkNode(node)) {
1161
+ if (isListNode(nextSibling) || isTextBlock(editor, nextSibling) || !nextSibling && node.parentNode === root) {
1162
+ block = null;
1163
+ return;
1164
+ }
1165
+ }
1166
+ if (!block) {
1167
+ block = dom.create('p');
1168
+ node.parentNode.insertBefore(block, node);
1169
+ textBlocks.push(block);
1170
+ }
1171
+ block.appendChild(node);
1172
+ });
1173
+ return textBlocks;
1174
+ };
1175
+ const hasCompatibleStyle = (dom, sib, detail) => {
1176
+ const sibStyle = dom.getStyle(sib, 'list-style-type');
1177
+ let detailStyle = detail ? detail['list-style-type'] : '';
1178
+ detailStyle = detailStyle === null ? '' : detailStyle;
1179
+ return sibStyle === detailStyle;
1180
+ };
1181
+ const applyList = (editor, listName, detail) => {
1182
+ const rng = editor.selection.getRng();
1183
+ let listItemName = 'LI';
1184
+ const root = getClosestListHost(editor, editor.selection.getStart(true));
1185
+ const dom = editor.dom;
1186
+ if (dom.getContentEditable(editor.selection.getNode()) === 'false') {
1187
+ return;
1188
+ }
1189
+ listName = listName.toUpperCase();
1190
+ if (listName === 'DL') {
1191
+ listItemName = 'DT';
1192
+ }
1193
+ const bookmark = createBookmark(rng);
1194
+ const selectedTextBlocks = getSelectedTextBlocks(editor, rng, root);
1195
+ global$1.each(selectedTextBlocks, block => {
1196
+ let listBlock;
1197
+ const sibling = block.previousSibling;
1198
+ const parent = block.parentNode;
1199
+ if (!isListItemNode(parent)) {
1200
+ if (sibling && isListNode(sibling) && sibling.nodeName === listName && hasCompatibleStyle(dom, sibling, detail)) {
1201
+ listBlock = sibling;
1202
+ block = dom.rename(block, listItemName);
1203
+ sibling.appendChild(block);
1204
+ } else {
1205
+ listBlock = dom.create(listName);
1206
+ block.parentNode.insertBefore(listBlock, block);
1207
+ listBlock.appendChild(block);
1208
+ block = dom.rename(block, listItemName);
1209
+ }
1210
+ removeStyles(dom, block, [
1211
+ 'margin',
1212
+ 'margin-right',
1213
+ 'margin-bottom',
1214
+ 'margin-left',
1215
+ 'margin-top',
1216
+ 'padding',
1217
+ 'padding-right',
1218
+ 'padding-bottom',
1219
+ 'padding-left',
1220
+ 'padding-top'
1221
+ ]);
1222
+ updateListWithDetails(dom, listBlock, detail);
1223
+ mergeWithAdjacentLists(editor.dom, listBlock);
1224
+ }
1225
+ });
1226
+ editor.selection.setRng(resolveBookmark(bookmark));
1227
+ };
1228
+ const isValidLists = (list1, list2) => {
1229
+ return list1 && list2 && isListNode(list1) && list1.nodeName === list2.nodeName;
1230
+ };
1231
+ const hasSameListStyle = (dom, list1, list2) => {
1232
+ const targetStyle = dom.getStyle(list1, 'list-style-type', true);
1233
+ const style = dom.getStyle(list2, 'list-style-type', true);
1234
+ return targetStyle === style;
1235
+ };
1236
+ const hasSameClasses = (elm1, elm2) => {
1237
+ return elm1.className === elm2.className;
1238
+ };
1239
+ const shouldMerge = (dom, list1, list2) => {
1240
+ return isValidLists(list1, list2) && hasSameListStyle(dom, list1, list2) && hasSameClasses(list1, list2);
1241
+ };
1242
+ const mergeWithAdjacentLists = (dom, listBlock) => {
1243
+ let sibling, node;
1244
+ sibling = listBlock.nextSibling;
1245
+ if (shouldMerge(dom, listBlock, sibling)) {
1246
+ while (node = sibling.firstChild) {
1247
+ listBlock.appendChild(node);
1248
+ }
1249
+ dom.remove(sibling);
1250
+ }
1251
+ sibling = listBlock.previousSibling;
1252
+ if (shouldMerge(dom, listBlock, sibling)) {
1253
+ while (node = sibling.lastChild) {
1254
+ listBlock.insertBefore(node, listBlock.firstChild);
1255
+ }
1256
+ dom.remove(sibling);
1257
+ }
1258
+ };
1259
+ const updateList$1 = (editor, list, listName, detail) => {
1260
+ if (list.nodeName !== listName) {
1261
+ const newList = editor.dom.rename(list, listName);
1262
+ updateListWithDetails(editor.dom, newList, detail);
1263
+ fireListEvent(editor, listToggleActionFromListName(listName), newList);
1264
+ } else {
1265
+ updateListWithDetails(editor.dom, list, detail);
1266
+ fireListEvent(editor, listToggleActionFromListName(listName), list);
1267
+ }
1268
+ };
1269
+ const toggleMultipleLists = (editor, parentList, lists, listName, detail) => {
1270
+ const parentIsList = isListNode(parentList);
1271
+ if (parentIsList && parentList.nodeName === listName && !hasListStyleDetail(detail)) {
1272
+ flattenListSelection(editor);
1273
+ } else {
1274
+ applyList(editor, listName, detail);
1275
+ const bookmark = createBookmark(editor.selection.getRng());
1276
+ const allLists = parentIsList ? [
1277
+ parentList,
1278
+ ...lists
1279
+ ] : lists;
1280
+ global$1.each(allLists, elm => {
1281
+ updateList$1(editor, elm, listName, detail);
1282
+ });
1283
+ editor.selection.setRng(resolveBookmark(bookmark));
1284
+ }
1285
+ };
1286
+ const hasListStyleDetail = detail => {
1287
+ return 'list-style-type' in detail;
1288
+ };
1289
+ const toggleSingleList = (editor, parentList, listName, detail) => {
1290
+ if (parentList === editor.getBody()) {
1291
+ return;
1292
+ }
1293
+ if (parentList) {
1294
+ if (parentList.nodeName === listName && !hasListStyleDetail(detail) && !isCustomList(parentList)) {
1295
+ flattenListSelection(editor);
1296
+ } else {
1297
+ const bookmark = createBookmark(editor.selection.getRng());
1298
+ updateListWithDetails(editor.dom, parentList, detail);
1299
+ const newList = editor.dom.rename(parentList, listName);
1300
+ mergeWithAdjacentLists(editor.dom, newList);
1301
+ editor.selection.setRng(resolveBookmark(bookmark));
1302
+ applyList(editor, listName, detail);
1303
+ fireListEvent(editor, listToggleActionFromListName(listName), newList);
1304
+ }
1305
+ } else {
1306
+ applyList(editor, listName, detail);
1307
+ fireListEvent(editor, listToggleActionFromListName(listName), parentList);
1308
+ }
1309
+ };
1310
+ const toggleList = (editor, listName, _detail) => {
1311
+ const parentList = getParentList(editor);
1312
+ const selectedSubLists = getSelectedSubLists(editor);
1313
+ const detail = isObject(_detail) ? _detail : {};
1314
+ if (selectedSubLists.length > 0) {
1315
+ toggleMultipleLists(editor, parentList, selectedSubLists, listName, detail);
1316
+ } else {
1317
+ toggleSingleList(editor, parentList, listName, detail);
1318
+ }
1319
+ };
1320
+
1321
+ const DOM = global$2.DOM;
1322
+ const normalizeList = (dom, list) => {
1323
+ const parentNode = list.parentNode;
1324
+ if (parentNode.nodeName === 'LI' && parentNode.firstChild === list) {
1325
+ const sibling = parentNode.previousSibling;
1326
+ if (sibling && sibling.nodeName === 'LI') {
1327
+ sibling.appendChild(list);
1328
+ if (isEmpty$1(dom, parentNode)) {
1329
+ DOM.remove(parentNode);
1330
+ }
1331
+ } else {
1332
+ DOM.setStyle(parentNode, 'listStyleType', 'none');
1333
+ }
1334
+ }
1335
+ if (isListNode(parentNode)) {
1336
+ const sibling = parentNode.previousSibling;
1337
+ if (sibling && sibling.nodeName === 'LI') {
1338
+ sibling.appendChild(list);
1339
+ }
1340
+ }
1341
+ };
1342
+ const normalizeLists = (dom, element) => {
1343
+ const lists = global$1.grep(dom.select('ol,ul', element));
1344
+ global$1.each(lists, list => {
1345
+ normalizeList(dom, list);
1346
+ });
1347
+ };
1348
+
1349
+ const findNextCaretContainer = (editor, rng, isForward, root) => {
1350
+ let node = rng.startContainer;
1351
+ const offset = rng.startOffset;
1352
+ if (isTextNode(node) && (isForward ? offset < node.data.length : offset > 0)) {
1353
+ return node;
1354
+ }
1355
+ const nonEmptyBlocks = editor.schema.getNonEmptyElements();
1356
+ if (node.nodeType === 1) {
1357
+ node = global$5.getNode(node, offset);
1358
+ }
1359
+ const walker = new global$4(node, root);
1360
+ if (isForward) {
1361
+ if (isBogusBr(editor.dom, node)) {
1362
+ walker.next();
1363
+ }
1364
+ }
1365
+ const walkFn = isForward ? walker.next.bind(walker) : walker.prev2.bind(walker);
1366
+ while (node = walkFn()) {
1367
+ if (node.nodeName === 'LI' && !node.hasChildNodes()) {
1368
+ return node;
1369
+ }
1370
+ if (nonEmptyBlocks[node.nodeName]) {
1371
+ return node;
1372
+ }
1373
+ if (isTextNode(node) && node.data.length > 0) {
1374
+ return node;
1375
+ }
1376
+ }
1377
+ };
1378
+ const hasOnlyOneBlockChild = (dom, elm) => {
1379
+ const childNodes = elm.childNodes;
1380
+ return childNodes.length === 1 && !isListNode(childNodes[0]) && dom.isBlock(childNodes[0]);
1381
+ };
1382
+ const unwrapSingleBlockChild = (dom, elm) => {
1383
+ if (hasOnlyOneBlockChild(dom, elm)) {
1384
+ dom.remove(elm.firstChild, true);
1385
+ }
1386
+ };
1387
+ const moveChildren = (dom, fromElm, toElm) => {
1388
+ let node;
1389
+ const targetElm = hasOnlyOneBlockChild(dom, toElm) ? toElm.firstChild : toElm;
1390
+ unwrapSingleBlockChild(dom, fromElm);
1391
+ if (!isEmpty$1(dom, fromElm, true)) {
1392
+ while (node = fromElm.firstChild) {
1393
+ targetElm.appendChild(node);
1394
+ }
1395
+ }
1396
+ };
1397
+ const mergeLiElements = (dom, fromElm, toElm) => {
1398
+ let listNode;
1399
+ const ul = fromElm.parentNode;
1400
+ if (!isChildOfBody(dom, fromElm) || !isChildOfBody(dom, toElm)) {
1401
+ return;
1402
+ }
1403
+ if (isListNode(toElm.lastChild)) {
1404
+ listNode = toElm.lastChild;
1405
+ }
1406
+ if (ul === toElm.lastChild) {
1407
+ if (isBr(ul.previousSibling)) {
1408
+ dom.remove(ul.previousSibling);
1409
+ }
1410
+ }
1411
+ const node = toElm.lastChild;
1412
+ if (node && isBr(node) && fromElm.hasChildNodes()) {
1413
+ dom.remove(node);
1414
+ }
1415
+ if (isEmpty$1(dom, toElm, true)) {
1416
+ empty(SugarElement.fromDom(toElm));
1417
+ }
1418
+ moveChildren(dom, fromElm, toElm);
1419
+ if (listNode) {
1420
+ toElm.appendChild(listNode);
1421
+ }
1422
+ const contains$1 = contains(SugarElement.fromDom(toElm), SugarElement.fromDom(fromElm));
1423
+ const nestedLists = contains$1 ? dom.getParents(fromElm, isListNode, toElm) : [];
1424
+ dom.remove(fromElm);
1425
+ each$1(nestedLists, list => {
1426
+ if (isEmpty$1(dom, list) && list !== dom.getRoot()) {
1427
+ dom.remove(list);
1428
+ }
1429
+ });
1430
+ };
1431
+ const mergeIntoEmptyLi = (editor, fromLi, toLi) => {
1432
+ empty(SugarElement.fromDom(toLi));
1433
+ mergeLiElements(editor.dom, fromLi, toLi);
1434
+ editor.selection.setCursorLocation(toLi, 0);
1435
+ };
1436
+ const mergeForward = (editor, rng, fromLi, toLi) => {
1437
+ const dom = editor.dom;
1438
+ if (dom.isEmpty(toLi)) {
1439
+ mergeIntoEmptyLi(editor, fromLi, toLi);
1440
+ } else {
1441
+ const bookmark = createBookmark(rng);
1442
+ mergeLiElements(dom, fromLi, toLi);
1443
+ editor.selection.setRng(resolveBookmark(bookmark));
1444
+ }
1445
+ };
1446
+ const mergeBackward = (editor, rng, fromLi, toLi) => {
1447
+ const bookmark = createBookmark(rng);
1448
+ mergeLiElements(editor.dom, fromLi, toLi);
1449
+ const resolvedBookmark = resolveBookmark(bookmark);
1450
+ editor.selection.setRng(resolvedBookmark);
1451
+ };
1452
+ const backspaceDeleteFromListToListCaret = (editor, isForward) => {
1453
+ const dom = editor.dom, selection = editor.selection;
1454
+ const selectionStartElm = selection.getStart();
1455
+ const root = getClosestEditingHost(editor, selectionStartElm);
1456
+ const li = dom.getParent(selection.getStart(), 'LI', root);
1457
+ if (li) {
1458
+ const ul = li.parentNode;
1459
+ if (ul === editor.getBody() && isEmpty$1(dom, ul)) {
1460
+ return true;
1461
+ }
1462
+ const rng = normalizeRange(selection.getRng());
1463
+ const otherLi = dom.getParent(findNextCaretContainer(editor, rng, isForward, root), 'LI', root);
1464
+ if (otherLi && otherLi !== li) {
1465
+ editor.undoManager.transact(() => {
1466
+ if (isForward) {
1467
+ mergeForward(editor, rng, otherLi, li);
1468
+ } else {
1469
+ if (isFirstChild(li)) {
1470
+ outdentListSelection(editor);
1471
+ } else {
1472
+ mergeBackward(editor, rng, li, otherLi);
1473
+ }
1474
+ }
1475
+ });
1476
+ return true;
1477
+ } else if (!otherLi) {
1478
+ if (!isForward && rng.startOffset === 0 && rng.endOffset === 0) {
1479
+ editor.undoManager.transact(() => {
1480
+ flattenListSelection(editor);
1481
+ });
1482
+ return true;
1483
+ }
1484
+ }
1485
+ }
1486
+ return false;
1487
+ };
1488
+ const removeBlock = (dom, block, root) => {
1489
+ const parentBlock = dom.getParent(block.parentNode, dom.isBlock, root);
1490
+ dom.remove(block);
1491
+ if (parentBlock && dom.isEmpty(parentBlock)) {
1492
+ dom.remove(parentBlock);
1493
+ }
1494
+ };
1495
+ const backspaceDeleteIntoListCaret = (editor, isForward) => {
1496
+ const dom = editor.dom;
1497
+ const selectionStartElm = editor.selection.getStart();
1498
+ const root = getClosestEditingHost(editor, selectionStartElm);
1499
+ const block = dom.getParent(selectionStartElm, dom.isBlock, root);
1500
+ if (block && dom.isEmpty(block)) {
1501
+ const rng = normalizeRange(editor.selection.getRng());
1502
+ const otherLi = dom.getParent(findNextCaretContainer(editor, rng, isForward, root), 'LI', root);
1503
+ if (otherLi) {
1504
+ const findValidElement = element => contains$1([
1505
+ 'td',
1506
+ 'th',
1507
+ 'caption'
1508
+ ], name(element));
1509
+ const findRoot = node => node.dom === root;
1510
+ const otherLiCell = closest(SugarElement.fromDom(otherLi), findValidElement, findRoot);
1511
+ const caretCell = closest(SugarElement.fromDom(rng.startContainer), findValidElement, findRoot);
1512
+ if (!equals(otherLiCell, caretCell, eq)) {
1513
+ return false;
1514
+ }
1515
+ editor.undoManager.transact(() => {
1516
+ removeBlock(dom, block, root);
1517
+ mergeWithAdjacentLists(dom, otherLi.parentNode);
1518
+ editor.selection.select(otherLi, true);
1519
+ editor.selection.collapse(isForward);
1520
+ });
1521
+ return true;
1522
+ }
1523
+ }
1524
+ return false;
1525
+ };
1526
+ const backspaceDeleteCaret = (editor, isForward) => {
1527
+ return backspaceDeleteFromListToListCaret(editor, isForward) || backspaceDeleteIntoListCaret(editor, isForward);
1528
+ };
1529
+ const hasListSelection = editor => {
1530
+ const selectionStartElm = editor.selection.getStart();
1531
+ const root = getClosestEditingHost(editor, selectionStartElm);
1532
+ const startListParent = editor.dom.getParent(selectionStartElm, 'LI,DT,DD', root);
1533
+ return startListParent || getSelectedListItems(editor).length > 0;
1534
+ };
1535
+ const backspaceDeleteRange = editor => {
1536
+ if (hasListSelection(editor)) {
1537
+ editor.undoManager.transact(() => {
1538
+ editor.execCommand('Delete');
1539
+ normalizeLists(editor.dom, editor.getBody());
1540
+ });
1541
+ return true;
1542
+ }
1543
+ return false;
1544
+ };
1545
+ const backspaceDelete = (editor, isForward) => {
1546
+ return editor.selection.isCollapsed() ? backspaceDeleteCaret(editor, isForward) : backspaceDeleteRange(editor);
1547
+ };
1548
+ const setup$1 = editor => {
1549
+ editor.on('ExecCommand', e => {
1550
+ const cmd = e.command.toLowerCase();
1551
+ if ((cmd === 'delete' || cmd === 'forwarddelete') && hasListSelection(editor)) {
1552
+ normalizeLists(editor.dom, editor.getBody());
1553
+ }
1554
+ });
1555
+ editor.on('keydown', e => {
1556
+ if (e.keyCode === global$3.BACKSPACE) {
1557
+ if (backspaceDelete(editor, false)) {
1558
+ e.preventDefault();
1559
+ }
1560
+ } else if (e.keyCode === global$3.DELETE) {
1561
+ if (backspaceDelete(editor, true)) {
1562
+ e.preventDefault();
1563
+ }
1564
+ }
1565
+ });
1566
+ };
1567
+
1568
+ const get = editor => ({
1569
+ backspaceDelete: isForward => {
1570
+ backspaceDelete(editor, isForward);
1571
+ }
1572
+ });
1573
+
1574
+ const updateList = (editor, update) => {
1575
+ const parentList = getParentList(editor);
1576
+ editor.undoManager.transact(() => {
1577
+ if (isObject(update.styles)) {
1578
+ editor.dom.setStyles(parentList, update.styles);
1579
+ }
1580
+ if (isObject(update.attrs)) {
1581
+ each(update.attrs, (v, k) => editor.dom.setAttrib(parentList, k, v));
1582
+ }
1583
+ });
1584
+ };
1585
+
1586
+ const parseAlphabeticBase26 = str => {
1587
+ const chars = reverse(trim(str).split(''));
1588
+ const values = map(chars, (char, i) => {
1589
+ const charValue = char.toUpperCase().charCodeAt(0) - 'A'.charCodeAt(0) + 1;
1590
+ return Math.pow(26, i) * charValue;
1591
+ });
1592
+ return foldl(values, (sum, v) => sum + v, 0);
1593
+ };
1594
+ const composeAlphabeticBase26 = value => {
1595
+ value--;
1596
+ if (value < 0) {
1597
+ return '';
1598
+ } else {
1599
+ const remainder = value % 26;
1600
+ const quotient = Math.floor(value / 26);
1601
+ const rest = composeAlphabeticBase26(quotient);
1602
+ const char = String.fromCharCode('A'.charCodeAt(0) + remainder);
1603
+ return rest + char;
1604
+ }
1605
+ };
1606
+ const isUppercase = str => /^[A-Z]+$/.test(str);
1607
+ const isLowercase = str => /^[a-z]+$/.test(str);
1608
+ const isNumeric = str => /^[0-9]+$/.test(str);
1609
+ const deduceListType = start => {
1610
+ if (isNumeric(start)) {
1611
+ return 2;
1612
+ } else if (isUppercase(start)) {
1613
+ return 0;
1614
+ } else if (isLowercase(start)) {
1615
+ return 1;
1616
+ } else if (isEmpty(start)) {
1617
+ return 3;
1618
+ } else {
1619
+ return 4;
1620
+ }
1621
+ };
1622
+ const parseStartValue = start => {
1623
+ switch (deduceListType(start)) {
1624
+ case 2:
1625
+ return Optional.some({
1626
+ listStyleType: Optional.none(),
1627
+ start
1628
+ });
1629
+ case 0:
1630
+ return Optional.some({
1631
+ listStyleType: Optional.some('upper-alpha'),
1632
+ start: parseAlphabeticBase26(start).toString()
1633
+ });
1634
+ case 1:
1635
+ return Optional.some({
1636
+ listStyleType: Optional.some('lower-alpha'),
1637
+ start: parseAlphabeticBase26(start).toString()
1638
+ });
1639
+ case 3:
1640
+ return Optional.some({
1641
+ listStyleType: Optional.none(),
1642
+ start: ''
1643
+ });
1644
+ case 4:
1645
+ return Optional.none();
1646
+ }
1647
+ };
1648
+ const parseDetail = detail => {
1649
+ const start = parseInt(detail.start, 10);
1650
+ if (is$2(detail.listStyleType, 'upper-alpha')) {
1651
+ return composeAlphabeticBase26(start);
1652
+ } else if (is$2(detail.listStyleType, 'lower-alpha')) {
1653
+ return composeAlphabeticBase26(start).toLowerCase();
1654
+ } else {
1655
+ return detail.start;
1656
+ }
1657
+ };
1658
+
1659
+ const open = editor => {
1660
+ const currentList = getParentList(editor);
1661
+ if (!isOlNode(currentList)) {
1662
+ return;
1663
+ }
1664
+ editor.windowManager.open({
1665
+ title: 'List Properties',
1666
+ body: {
1667
+ type: 'panel',
1668
+ items: [{
1669
+ type: 'input',
1670
+ name: 'start',
1671
+ label: 'Start list at number',
1672
+ inputMode: 'numeric'
1673
+ }]
1674
+ },
1675
+ initialData: {
1676
+ start: parseDetail({
1677
+ start: editor.dom.getAttrib(currentList, 'start', '1'),
1678
+ listStyleType: Optional.some(editor.dom.getStyle(currentList, 'list-style-type'))
1679
+ })
1680
+ },
1681
+ buttons: [
1682
+ {
1683
+ type: 'cancel',
1684
+ name: 'cancel',
1685
+ text: 'Cancel'
1686
+ },
1687
+ {
1688
+ type: 'submit',
1689
+ name: 'save',
1690
+ text: 'Save',
1691
+ primary: true
1692
+ }
1693
+ ],
1694
+ onSubmit: api => {
1695
+ const data = api.getData();
1696
+ parseStartValue(data.start).each(detail => {
1697
+ editor.execCommand('mceListUpdate', false, {
1698
+ attrs: { start: detail.start === '1' ? '' : detail.start },
1699
+ styles: { 'list-style-type': detail.listStyleType.getOr('') }
1700
+ });
1701
+ });
1702
+ api.close();
1703
+ }
1704
+ });
1705
+ };
1706
+
1707
+ const queryListCommandState = (editor, listName) => () => {
1708
+ const parentList = getParentList(editor);
1709
+ return parentList && parentList.nodeName === listName;
1710
+ };
1711
+ const registerDialog = editor => {
1712
+ editor.addCommand('mceListProps', () => {
1713
+ open(editor);
1714
+ });
1715
+ };
1716
+ const register$2 = editor => {
1717
+ editor.on('BeforeExecCommand', e => {
1718
+ const cmd = e.command.toLowerCase();
1719
+ if (cmd === 'indent') {
1720
+ indentListSelection(editor);
1721
+ } else if (cmd === 'outdent') {
1722
+ outdentListSelection(editor);
1723
+ }
1724
+ });
1725
+ editor.addCommand('InsertUnorderedList', (ui, detail) => {
1726
+ toggleList(editor, 'UL', detail);
1727
+ });
1728
+ editor.addCommand('InsertOrderedList', (ui, detail) => {
1729
+ toggleList(editor, 'OL', detail);
1730
+ });
1731
+ editor.addCommand('InsertDefinitionList', (ui, detail) => {
1732
+ toggleList(editor, 'DL', detail);
1733
+ });
1734
+ editor.addCommand('RemoveList', () => {
1735
+ flattenListSelection(editor);
1736
+ });
1737
+ registerDialog(editor);
1738
+ editor.addCommand('mceListUpdate', (ui, detail) => {
1739
+ if (isObject(detail)) {
1740
+ updateList(editor, detail);
1741
+ }
1742
+ });
1743
+ editor.addQueryStateHandler('InsertUnorderedList', queryListCommandState(editor, 'UL'));
1744
+ editor.addQueryStateHandler('InsertOrderedList', queryListCommandState(editor, 'OL'));
1745
+ editor.addQueryStateHandler('InsertDefinitionList', queryListCommandState(editor, 'DL'));
1746
+ };
1747
+
1748
+ const setupTabKey = editor => {
1749
+ editor.on('keydown', e => {
1750
+ if (e.keyCode !== global$3.TAB || global$3.metaKeyPressed(e)) {
1751
+ return;
1752
+ }
1753
+ editor.undoManager.transact(() => {
1754
+ if (e.shiftKey ? outdentListSelection(editor) : indentListSelection(editor)) {
1755
+ e.preventDefault();
1756
+ }
1757
+ });
1758
+ });
1759
+ };
1760
+ const setup = editor => {
1761
+ if (shouldIndentOnTab(editor)) {
1762
+ setupTabKey(editor);
1763
+ }
1764
+ setup$1(editor);
1765
+ };
1766
+
1767
+ const register$1 = editor => {
1768
+ const exec = command => () => editor.execCommand(command);
1769
+ if (!editor.hasPlugin('advlist')) {
1770
+ editor.ui.registry.addToggleButton('numlist', {
1771
+ icon: 'ordered-list',
1772
+ active: false,
1773
+ tooltip: 'Numbered list',
1774
+ onAction: exec('InsertOrderedList'),
1775
+ onSetup: api => listState(editor, 'OL', api.setActive)
1776
+ });
1777
+ editor.ui.registry.addToggleButton('bullist', {
1778
+ icon: 'unordered-list',
1779
+ active: false,
1780
+ tooltip: 'Bullet list',
1781
+ onAction: exec('InsertUnorderedList'),
1782
+ onSetup: api => listState(editor, 'UL', api.setActive)
1783
+ });
1784
+ }
1785
+ };
1786
+
1787
+ const register = editor => {
1788
+ const listProperties = {
1789
+ text: 'List properties...',
1790
+ icon: 'ordered-list',
1791
+ onAction: () => editor.execCommand('mceListProps'),
1792
+ onSetup: api => listState(editor, 'OL', api.setEnabled)
1793
+ };
1794
+ editor.ui.registry.addMenuItem('listprops', listProperties);
1795
+ editor.ui.registry.addContextMenu('lists', {
1796
+ update: node => {
1797
+ const parentList = getParentList(editor, node);
1798
+ return isOlNode(parentList) ? ['listprops'] : [];
1799
+ }
1800
+ });
1801
+ };
1802
+
1803
+ var Plugin = () => {
1804
+ global$6.add('lists', editor => {
1805
+ register$3(editor);
1806
+ if (editor.hasPlugin('rtc', true) === false) {
1807
+ setup(editor);
1808
+ register$2(editor);
1809
+ } else {
1810
+ registerDialog(editor);
1811
+ }
1812
+ register$1(editor);
1813
+ register(editor);
1814
+ return get(editor);
1815
+ });
1816
+ };
1817
+
1818
+ Plugin();
1819
+
1820
+ })();