@lotte-innovate/ui-component-test 0.0.108 → 0.0.110

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. package/dist/lib/components/Avatar/index.js +1 -1
  2. package/dist/lib/components/ContextMenu/ContextMenuItem.js +1 -1
  3. package/dist/lib/components/ContextMenu/ContextMenuSeparator.js +1 -1
  4. package/dist/lib/components/ContextMenu/ContextMenuSeparator.mjs +1 -1
  5. package/dist/lib/components/ContextMenu/ContextMenuSeparator.mjs.map +1 -1
  6. package/dist/lib/components/ContextMenu/ContextMenuTrigger.js +1 -1
  7. package/dist/lib/components/ContextMenu/ContextMenuTrigger.mjs +1 -1
  8. package/dist/lib/components/ContextMenu/ContextMenuTrigger.mjs.map +1 -1
  9. package/dist/lib/components/DropdownMenu/DropdownMenuItem.js +1 -1
  10. package/dist/lib/components/DropdownMenu/DropdownMenuSeparator.js +1 -1
  11. package/dist/lib/components/DropdownMenu/DropdownMenuSeparator.mjs +1 -1
  12. package/dist/lib/components/DropdownMenu/DropdownMenuSeparator.mjs.map +1 -1
  13. package/dist/lib/components/Editor/index.js +1 -1
  14. package/dist/lib/components/Editor/index.mjs +1 -1
  15. package/dist/lib/components/HoverCard/HoverCardContent.js +1 -1
  16. package/dist/lib/components/IconButton/index.js +1 -1
  17. package/dist/lib/components/Menubar/MenubarItem.js +1 -1
  18. package/dist/lib/components/Menubar/MenubarSeparator.js +1 -1
  19. package/dist/lib/components/Menubar/MenubarSeparator.mjs +1 -1
  20. package/dist/lib/components/Menubar/MenubarSeparator.mjs.map +1 -1
  21. package/dist/lib/tsconfig.tsbuildinfo +1 -1
  22. package/dist/tsconfig.tsbuildinfo +1 -1
  23. package/package.json +1 -2
  24. package/dist/public/tinymce/icons/default/icons.d.ts +0 -0
  25. package/dist/public/tinymce/icons/default/icons.js +0 -195
  26. package/dist/public/tinymce/icons/default/index.d.ts +0 -1
  27. package/dist/public/tinymce/icons/default/index.js +0 -8
  28. package/dist/public/tinymce/models/dom/index.d.ts +0 -1
  29. package/dist/public/tinymce/models/dom/index.js +0 -8
  30. package/dist/public/tinymce/models/dom/model.d.ts +0 -0
  31. package/dist/public/tinymce/models/dom/model.js +0 -7988
  32. package/dist/public/tinymce/plugins/advlist/index.d.ts +0 -1
  33. package/dist/public/tinymce/plugins/advlist/index.js +0 -8
  34. package/dist/public/tinymce/plugins/advlist/plugin.d.ts +0 -0
  35. package/dist/public/tinymce/plugins/advlist/plugin.js +0 -255
  36. package/dist/public/tinymce/plugins/autolink/index.d.ts +0 -1
  37. package/dist/public/tinymce/plugins/autolink/index.js +0 -8
  38. package/dist/public/tinymce/plugins/autolink/plugin.d.ts +0 -0
  39. package/dist/public/tinymce/plugins/autolink/plugin.js +0 -221
  40. package/dist/public/tinymce/plugins/code/index.d.ts +0 -1
  41. package/dist/public/tinymce/plugins/code/index.js +0 -8
  42. package/dist/public/tinymce/plugins/code/plugin.d.ts +0 -0
  43. package/dist/public/tinymce/plugins/code/plugin.js +0 -77
  44. package/dist/public/tinymce/plugins/codesample/index.d.ts +0 -1
  45. package/dist/public/tinymce/plugins/codesample/index.js +0 -8
  46. package/dist/public/tinymce/plugins/codesample/plugin.d.ts +0 -45
  47. package/dist/public/tinymce/plugins/codesample/plugin.js +0 -2462
  48. package/dist/public/tinymce/plugins/image/index.d.ts +0 -1
  49. package/dist/public/tinymce/plugins/image/index.js +0 -8
  50. package/dist/public/tinymce/plugins/image/plugin.d.ts +0 -0
  51. package/dist/public/tinymce/plugins/image/plugin.js +0 -1523
  52. package/dist/public/tinymce/plugins/link/index.d.ts +0 -1
  53. package/dist/public/tinymce/plugins/link/index.js +0 -8
  54. package/dist/public/tinymce/plugins/link/plugin.d.ts +0 -0
  55. package/dist/public/tinymce/plugins/link/plugin.js +0 -1246
  56. package/dist/public/tinymce/plugins/lists/index.d.ts +0 -1
  57. package/dist/public/tinymce/plugins/lists/index.js +0 -8
  58. package/dist/public/tinymce/plugins/lists/plugin.d.ts +0 -0
  59. package/dist/public/tinymce/plugins/lists/plugin.js +0 -2191
  60. package/dist/public/tinymce/plugins/table/index.d.ts +0 -1
  61. package/dist/public/tinymce/plugins/table/index.js +0 -8
  62. package/dist/public/tinymce/plugins/table/plugin.d.ts +0 -0
  63. package/dist/public/tinymce/plugins/table/plugin.js +0 -3399
  64. package/dist/public/tinymce/skins/content/default/content.d.ts +0 -0
  65. package/dist/public/tinymce/skins/content/default/content.js +0 -3
  66. package/dist/public/tinymce/skins/ui/oxide/content.d.ts +0 -0
  67. package/dist/public/tinymce/skins/ui/oxide/content.inline.d.ts +0 -0
  68. package/dist/public/tinymce/skins/ui/oxide/content.inline.js +0 -3
  69. package/dist/public/tinymce/skins/ui/oxide/content.js +0 -3
  70. package/dist/public/tinymce/skins/ui/oxide/skin.d.ts +0 -0
  71. package/dist/public/tinymce/skins/ui/oxide/skin.js +0 -3
  72. package/dist/public/tinymce/skins/ui/oxide/skin.shadowdom.d.ts +0 -0
  73. package/dist/public/tinymce/skins/ui/oxide/skin.shadowdom.js +0 -3
  74. package/dist/public/tinymce/skins/ui/oxide-dark/content.d.ts +0 -0
  75. package/dist/public/tinymce/skins/ui/oxide-dark/content.inline.d.ts +0 -0
  76. package/dist/public/tinymce/skins/ui/oxide-dark/content.inline.js +0 -3
  77. package/dist/public/tinymce/skins/ui/oxide-dark/content.js +0 -3
  78. package/dist/public/tinymce/skins/ui/oxide-dark/skin.d.ts +0 -0
  79. package/dist/public/tinymce/skins/ui/oxide-dark/skin.js +0 -3
  80. package/dist/public/tinymce/skins/ui/oxide-dark/skin.shadowdom.d.ts +0 -0
  81. package/dist/public/tinymce/skins/ui/oxide-dark/skin.shadowdom.js +0 -3
  82. package/dist/public/tinymce/themes/silver/index.d.ts +0 -1
  83. package/dist/public/tinymce/themes/silver/index.js +0 -8
  84. package/dist/public/tinymce/themes/silver/theme.d.ts +0 -0
  85. package/dist/public/tinymce/themes/silver/theme.js +0 -29731
  86. package/dist/public/tinymce/tinymce.d.ts +0 -1
  87. package/dist/public/tinymce/tinymce.js +0 -31974
  88. package/public/tinymce/CHANGELOG.md +0 -3453
  89. package/public/tinymce/README.md +0 -73
  90. package/public/tinymce/bower.json +0 -27
  91. package/public/tinymce/composer.json +0 -52
  92. package/public/tinymce/icons/default/icons.js +0 -194
  93. package/public/tinymce/icons/default/icons.min.js +0 -1
  94. package/public/tinymce/icons/default/index.js +0 -7
  95. package/public/tinymce/license.txt +0 -21
  96. package/public/tinymce/models/dom/index.js +0 -7
  97. package/public/tinymce/models/dom/model.js +0 -8040
  98. package/public/tinymce/models/dom/model.min.js +0 -4
  99. package/public/tinymce/package.json +0 -32
  100. package/public/tinymce/plugins/advlist/index.js +0 -7
  101. package/public/tinymce/plugins/advlist/plugin.js +0 -259
  102. package/public/tinymce/plugins/advlist/plugin.min.js +0 -4
  103. package/public/tinymce/plugins/autolink/index.js +0 -7
  104. package/public/tinymce/plugins/autolink/plugin.js +0 -228
  105. package/public/tinymce/plugins/autolink/plugin.min.js +0 -4
  106. package/public/tinymce/plugins/code/index.js +0 -7
  107. package/public/tinymce/plugins/code/plugin.js +0 -85
  108. package/public/tinymce/plugins/code/plugin.min.js +0 -4
  109. package/public/tinymce/plugins/codesample/index.js +0 -7
  110. package/public/tinymce/plugins/codesample/plugin.js +0 -2463
  111. package/public/tinymce/plugins/codesample/plugin.min.js +0 -4
  112. package/public/tinymce/plugins/image/index.js +0 -7
  113. package/public/tinymce/plugins/image/plugin.js +0 -1505
  114. package/public/tinymce/plugins/image/plugin.min.js +0 -4
  115. package/public/tinymce/plugins/link/index.js +0 -7
  116. package/public/tinymce/plugins/link/plugin.js +0 -1242
  117. package/public/tinymce/plugins/link/plugin.min.js +0 -4
  118. package/public/tinymce/plugins/lists/index.js +0 -7
  119. package/public/tinymce/plugins/lists/plugin.js +0 -2172
  120. package/public/tinymce/plugins/lists/plugin.min.js +0 -4
  121. package/public/tinymce/plugins/table/index.js +0 -7
  122. package/public/tinymce/plugins/table/plugin.js +0 -3462
  123. package/public/tinymce/plugins/table/plugin.min.js +0 -4
  124. package/public/tinymce/skins/content/default/content.css +0 -61
  125. package/public/tinymce/skins/content/default/content.js +0 -2
  126. package/public/tinymce/skins/content/default/content.min.css +0 -1
  127. package/public/tinymce/skins/ui/oxide/content.css +0 -785
  128. package/public/tinymce/skins/ui/oxide/content.inline.css +0 -779
  129. package/public/tinymce/skins/ui/oxide/content.inline.js +0 -2
  130. package/public/tinymce/skins/ui/oxide/content.inline.min.css +0 -1
  131. package/public/tinymce/skins/ui/oxide/content.js +0 -2
  132. package/public/tinymce/skins/ui/oxide/content.min.css +0 -1
  133. package/public/tinymce/skins/ui/oxide/skin.css +0 -3763
  134. package/public/tinymce/skins/ui/oxide/skin.js +0 -2
  135. package/public/tinymce/skins/ui/oxide/skin.min.css +0 -1
  136. package/public/tinymce/skins/ui/oxide/skin.shadowdom.css +0 -30
  137. package/public/tinymce/skins/ui/oxide/skin.shadowdom.js +0 -2
  138. package/public/tinymce/skins/ui/oxide/skin.shadowdom.min.css +0 -1
  139. package/public/tinymce/skins/ui/oxide-dark/content.css +0 -766
  140. package/public/tinymce/skins/ui/oxide-dark/content.inline.css +0 -779
  141. package/public/tinymce/skins/ui/oxide-dark/content.inline.js +0 -2
  142. package/public/tinymce/skins/ui/oxide-dark/content.inline.min.css +0 -1
  143. package/public/tinymce/skins/ui/oxide-dark/content.js +0 -2
  144. package/public/tinymce/skins/ui/oxide-dark/content.min.css +0 -1
  145. package/public/tinymce/skins/ui/oxide-dark/skin.css +0 -3766
  146. package/public/tinymce/skins/ui/oxide-dark/skin.js +0 -2
  147. package/public/tinymce/skins/ui/oxide-dark/skin.min.css +0 -1
  148. package/public/tinymce/skins/ui/oxide-dark/skin.shadowdom.css +0 -30
  149. package/public/tinymce/skins/ui/oxide-dark/skin.shadowdom.js +0 -2
  150. package/public/tinymce/skins/ui/oxide-dark/skin.shadowdom.min.css +0 -1
  151. package/public/tinymce/themes/silver/index.js +0 -7
  152. package/public/tinymce/themes/silver/theme.js +0 -30775
  153. package/public/tinymce/themes/silver/theme.min.js +0 -384
  154. package/public/tinymce/tinymce.d.ts +0 -3238
  155. package/public/tinymce/tinymce.js +0 -31779
  156. package/public/tinymce/tinymce.min.js +0 -384
@@ -1,3399 +0,0 @@
1
- "use strict";
2
- /**
3
- * TinyMCE version 6.8.5 (TBD)
4
- */
5
- var __assign = (this && this.__assign) || function () {
6
- __assign = Object.assign || function(t) {
7
- for (var s, i = 1, n = arguments.length; i < n; i++) {
8
- s = arguments[i];
9
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
10
- t[p] = s[p];
11
- }
12
- return t;
13
- };
14
- return __assign.apply(this, arguments);
15
- };
16
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
17
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
18
- if (ar || !(i in from)) {
19
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
20
- ar[i] = from[i];
21
- }
22
- }
23
- return to.concat(ar || Array.prototype.slice.call(from));
24
- };
25
- (function () {
26
- 'use strict';
27
- var global$3 = tinymce.util.Tools.resolve('tinymce.PluginManager');
28
- var hasProto = function (v, constructor, predicate) {
29
- var _a;
30
- if (predicate(v, constructor.prototype)) {
31
- return true;
32
- }
33
- else {
34
- return ((_a = v.constructor) === null || _a === void 0 ? void 0 : _a.name) === constructor.name;
35
- }
36
- };
37
- var typeOf = function (x) {
38
- var t = typeof x;
39
- if (x === null) {
40
- return 'null';
41
- }
42
- else if (t === 'object' && Array.isArray(x)) {
43
- return 'array';
44
- }
45
- else if (t === 'object' && hasProto(x, String, function (o, proto) { return proto.isPrototypeOf(o); })) {
46
- return 'string';
47
- }
48
- else {
49
- return t;
50
- }
51
- };
52
- var isType$1 = function (type) { return function (value) { return typeOf(value) === type; }; };
53
- var isSimpleType = function (type) { return function (value) { return typeof value === type; }; };
54
- var eq$1 = function (t) { return function (a) { return t === a; }; };
55
- var isString = isType$1('string');
56
- var isArray = isType$1('array');
57
- var isBoolean = isSimpleType('boolean');
58
- var isUndefined = eq$1(undefined);
59
- var isNullable = function (a) { return a === null || a === undefined; };
60
- var isNonNullable = function (a) { return !isNullable(a); };
61
- var isFunction = isSimpleType('function');
62
- var isNumber = isSimpleType('number');
63
- var noop = function () {
64
- };
65
- var compose1 = function (fbc, fab) { return function (a) { return fbc(fab(a)); }; };
66
- var constant = function (value) {
67
- return function () {
68
- return value;
69
- };
70
- };
71
- var identity = function (x) {
72
- return x;
73
- };
74
- var tripleEquals = function (a, b) {
75
- return a === b;
76
- };
77
- function curry(fn) {
78
- var initialArgs = [];
79
- for (var _i = 1; _i < arguments.length; _i++) {
80
- initialArgs[_i - 1] = arguments[_i];
81
- }
82
- return function () {
83
- var restArgs = [];
84
- for (var _i = 0; _i < arguments.length; _i++) {
85
- restArgs[_i] = arguments[_i];
86
- }
87
- var all = initialArgs.concat(restArgs);
88
- return fn.apply(null, all);
89
- };
90
- }
91
- var call = function (f) {
92
- f();
93
- };
94
- var never = constant(false);
95
- var always = constant(true);
96
- var Optional = /** @class */ (function () {
97
- function Optional(tag, value) {
98
- this.tag = tag;
99
- this.value = value;
100
- }
101
- Optional.some = function (value) {
102
- return new Optional(true, value);
103
- };
104
- Optional.none = function () {
105
- return Optional.singletonNone;
106
- };
107
- Optional.prototype.fold = function (onNone, onSome) {
108
- if (this.tag) {
109
- return onSome(this.value);
110
- }
111
- else {
112
- return onNone();
113
- }
114
- };
115
- Optional.prototype.isSome = function () {
116
- return this.tag;
117
- };
118
- Optional.prototype.isNone = function () {
119
- return !this.tag;
120
- };
121
- Optional.prototype.map = function (mapper) {
122
- if (this.tag) {
123
- return Optional.some(mapper(this.value));
124
- }
125
- else {
126
- return Optional.none();
127
- }
128
- };
129
- Optional.prototype.bind = function (binder) {
130
- if (this.tag) {
131
- return binder(this.value);
132
- }
133
- else {
134
- return Optional.none();
135
- }
136
- };
137
- Optional.prototype.exists = function (predicate) {
138
- return this.tag && predicate(this.value);
139
- };
140
- Optional.prototype.forall = function (predicate) {
141
- return !this.tag || predicate(this.value);
142
- };
143
- Optional.prototype.filter = function (predicate) {
144
- if (!this.tag || predicate(this.value)) {
145
- return this;
146
- }
147
- else {
148
- return Optional.none();
149
- }
150
- };
151
- Optional.prototype.getOr = function (replacement) {
152
- return this.tag ? this.value : replacement;
153
- };
154
- Optional.prototype.or = function (replacement) {
155
- return this.tag ? this : replacement;
156
- };
157
- Optional.prototype.getOrThunk = function (thunk) {
158
- return this.tag ? this.value : thunk();
159
- };
160
- Optional.prototype.orThunk = function (thunk) {
161
- return this.tag ? this : thunk();
162
- };
163
- Optional.prototype.getOrDie = function (message) {
164
- if (!this.tag) {
165
- throw new Error(message !== null && message !== void 0 ? message : 'Called getOrDie on None');
166
- }
167
- else {
168
- return this.value;
169
- }
170
- };
171
- Optional.from = function (value) {
172
- return isNonNullable(value) ? Optional.some(value) : Optional.none();
173
- };
174
- Optional.prototype.getOrNull = function () {
175
- return this.tag ? this.value : null;
176
- };
177
- Optional.prototype.getOrUndefined = function () {
178
- return this.value;
179
- };
180
- Optional.prototype.each = function (worker) {
181
- if (this.tag) {
182
- worker(this.value);
183
- }
184
- };
185
- Optional.prototype.toArray = function () {
186
- return this.tag ? [this.value] : [];
187
- };
188
- Optional.prototype.toString = function () {
189
- return this.tag ? "some(".concat(this.value, ")") : 'none()';
190
- };
191
- return Optional;
192
- }());
193
- Optional.singletonNone = new Optional(false);
194
- var keys = Object.keys;
195
- var hasOwnProperty = Object.hasOwnProperty;
196
- var each$1 = function (obj, f) {
197
- var props = keys(obj);
198
- for (var k = 0, len = props.length; k < len; k++) {
199
- var i = props[k];
200
- var x = obj[i];
201
- f(x, i);
202
- }
203
- };
204
- var objAcc = function (r) { return function (x, i) {
205
- r[i] = x;
206
- }; };
207
- var internalFilter = function (obj, pred, onTrue, onFalse) {
208
- each$1(obj, function (x, i) {
209
- (pred(x, i) ? onTrue : onFalse)(x, i);
210
- });
211
- };
212
- var filter$1 = function (obj, pred) {
213
- var t = {};
214
- internalFilter(obj, pred, objAcc(t), noop);
215
- return t;
216
- };
217
- var mapToArray = function (obj, f) {
218
- var r = [];
219
- each$1(obj, function (value, name) {
220
- r.push(f(value, name));
221
- });
222
- return r;
223
- };
224
- var values = function (obj) {
225
- return mapToArray(obj, identity);
226
- };
227
- var size = function (obj) {
228
- return keys(obj).length;
229
- };
230
- var get$4 = function (obj, key) {
231
- return has(obj, key) ? Optional.from(obj[key]) : Optional.none();
232
- };
233
- var has = function (obj, key) { return hasOwnProperty.call(obj, key); };
234
- var hasNonNullableKey = function (obj, key) { return has(obj, key) && obj[key] !== undefined && obj[key] !== null; };
235
- var isEmpty$1 = function (r) {
236
- for (var x in r) {
237
- if (hasOwnProperty.call(r, x)) {
238
- return false;
239
- }
240
- }
241
- return true;
242
- };
243
- var nativeIndexOf = Array.prototype.indexOf;
244
- var nativePush = Array.prototype.push;
245
- var rawIndexOf = function (ts, t) { return nativeIndexOf.call(ts, t); };
246
- var contains = function (xs, x) { return rawIndexOf(xs, x) > -1; };
247
- var exists = function (xs, pred) {
248
- for (var i = 0, len = xs.length; i < len; i++) {
249
- var x = xs[i];
250
- if (pred(x, i)) {
251
- return true;
252
- }
253
- }
254
- return false;
255
- };
256
- var range = function (num, f) {
257
- var r = [];
258
- for (var i = 0; i < num; i++) {
259
- r.push(f(i));
260
- }
261
- return r;
262
- };
263
- var map = function (xs, f) {
264
- var len = xs.length;
265
- var r = new Array(len);
266
- for (var i = 0; i < len; i++) {
267
- var x = xs[i];
268
- r[i] = f(x, i);
269
- }
270
- return r;
271
- };
272
- var each = function (xs, f) {
273
- for (var i = 0, len = xs.length; i < len; i++) {
274
- var x = xs[i];
275
- f(x, i);
276
- }
277
- };
278
- var eachr = function (xs, f) {
279
- for (var i = xs.length - 1; i >= 0; i--) {
280
- var x = xs[i];
281
- f(x, i);
282
- }
283
- };
284
- var partition = function (xs, pred) {
285
- var pass = [];
286
- var fail = [];
287
- for (var i = 0, len = xs.length; i < len; i++) {
288
- var x = xs[i];
289
- var arr = pred(x, i) ? pass : fail;
290
- arr.push(x);
291
- }
292
- return {
293
- pass: pass,
294
- fail: fail
295
- };
296
- };
297
- var filter = function (xs, pred) {
298
- var r = [];
299
- for (var i = 0, len = xs.length; i < len; i++) {
300
- var x = xs[i];
301
- if (pred(x, i)) {
302
- r.push(x);
303
- }
304
- }
305
- return r;
306
- };
307
- var foldr = function (xs, f, acc) {
308
- eachr(xs, function (x, i) {
309
- acc = f(acc, x, i);
310
- });
311
- return acc;
312
- };
313
- var foldl = function (xs, f, acc) {
314
- each(xs, function (x, i) {
315
- acc = f(acc, x, i);
316
- });
317
- return acc;
318
- };
319
- var findUntil = function (xs, pred, until) {
320
- for (var i = 0, len = xs.length; i < len; i++) {
321
- var x = xs[i];
322
- if (pred(x, i)) {
323
- return Optional.some(x);
324
- }
325
- else if (until(x, i)) {
326
- break;
327
- }
328
- }
329
- return Optional.none();
330
- };
331
- var find = function (xs, pred) {
332
- return findUntil(xs, pred, never);
333
- };
334
- var flatten$1 = function (xs) {
335
- var r = [];
336
- for (var i = 0, len = xs.length; i < len; ++i) {
337
- if (!isArray(xs[i])) {
338
- throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
339
- }
340
- nativePush.apply(r, xs[i]);
341
- }
342
- return r;
343
- };
344
- var bind = function (xs, f) { return flatten$1(map(xs, f)); };
345
- var forall = function (xs, pred) {
346
- for (var i = 0, len = xs.length; i < len; ++i) {
347
- var x = xs[i];
348
- if (pred(x, i) !== true) {
349
- return false;
350
- }
351
- }
352
- return true;
353
- };
354
- var mapToObject = function (xs, f) {
355
- var r = {};
356
- for (var i = 0, len = xs.length; i < len; i++) {
357
- var x = xs[i];
358
- r[String(x)] = f(x, i);
359
- }
360
- return r;
361
- };
362
- var get$3 = function (xs, i) { return i >= 0 && i < xs.length ? Optional.some(xs[i]) : Optional.none(); };
363
- var head = function (xs) { return get$3(xs, 0); };
364
- var last = function (xs) { return get$3(xs, xs.length - 1); };
365
- var findMap = function (arr, f) {
366
- for (var i = 0; i < arr.length; i++) {
367
- var r = f(arr[i], i);
368
- if (r.isSome()) {
369
- return r;
370
- }
371
- }
372
- return Optional.none();
373
- };
374
- var COMMENT = 8;
375
- var DOCUMENT = 9;
376
- var DOCUMENT_FRAGMENT = 11;
377
- var ELEMENT = 1;
378
- var TEXT = 3;
379
- var fromHtml = function (html, scope) {
380
- var doc = scope || document;
381
- var div = doc.createElement('div');
382
- div.innerHTML = html;
383
- if (!div.hasChildNodes() || div.childNodes.length > 1) {
384
- var message = 'HTML does not have a single root node';
385
- console.error(message, html);
386
- throw new Error(message);
387
- }
388
- return fromDom$1(div.childNodes[0]);
389
- };
390
- var fromTag = function (tag, scope) {
391
- var doc = scope || document;
392
- var node = doc.createElement(tag);
393
- return fromDom$1(node);
394
- };
395
- var fromText = function (text, scope) {
396
- var doc = scope || document;
397
- var node = doc.createTextNode(text);
398
- return fromDom$1(node);
399
- };
400
- var fromDom$1 = function (node) {
401
- if (node === null || node === undefined) {
402
- throw new Error('Node cannot be null or undefined');
403
- }
404
- return { dom: node };
405
- };
406
- var fromPoint = function (docElm, x, y) { return Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom$1); };
407
- var SugarElement = {
408
- fromHtml: fromHtml,
409
- fromTag: fromTag,
410
- fromText: fromText,
411
- fromDom: fromDom$1,
412
- fromPoint: fromPoint
413
- };
414
- var is$2 = function (element, selector) {
415
- var dom = element.dom;
416
- if (dom.nodeType !== ELEMENT) {
417
- return false;
418
- }
419
- else {
420
- var elem = dom;
421
- if (elem.matches !== undefined) {
422
- return elem.matches(selector);
423
- }
424
- else if (elem.msMatchesSelector !== undefined) {
425
- return elem.msMatchesSelector(selector);
426
- }
427
- else if (elem.webkitMatchesSelector !== undefined) {
428
- return elem.webkitMatchesSelector(selector);
429
- }
430
- else if (elem.mozMatchesSelector !== undefined) {
431
- return elem.mozMatchesSelector(selector);
432
- }
433
- else {
434
- throw new Error('Browser lacks native selectors');
435
- }
436
- }
437
- };
438
- var bypassSelector = function (dom) { return dom.nodeType !== ELEMENT && dom.nodeType !== DOCUMENT && dom.nodeType !== DOCUMENT_FRAGMENT || dom.childElementCount === 0; };
439
- var all$1 = function (selector, scope) {
440
- var base = scope === undefined ? document : scope.dom;
441
- return bypassSelector(base) ? [] : map(base.querySelectorAll(selector), SugarElement.fromDom);
442
- };
443
- var one = function (selector, scope) {
444
- var base = scope === undefined ? document : scope.dom;
445
- return bypassSelector(base) ? Optional.none() : Optional.from(base.querySelector(selector)).map(SugarElement.fromDom);
446
- };
447
- var eq = function (e1, e2) { return e1.dom === e2.dom; };
448
- var is$1 = is$2;
449
- typeof window !== 'undefined' ? window : Function('return this;')();
450
- var name = function (element) {
451
- var r = element.dom.nodeName;
452
- return r.toLowerCase();
453
- };
454
- var type = function (element) { return element.dom.nodeType; };
455
- var isType = function (t) { return function (element) { return type(element) === t; }; };
456
- var isComment = function (element) { return type(element) === COMMENT || name(element) === '#comment'; };
457
- var isElement = isType(ELEMENT);
458
- var isText = isType(TEXT);
459
- var isDocument = isType(DOCUMENT);
460
- var isDocumentFragment = isType(DOCUMENT_FRAGMENT);
461
- var isTag = function (tag) { return function (e) { return isElement(e) && name(e) === tag; }; };
462
- var owner = function (element) { return SugarElement.fromDom(element.dom.ownerDocument); };
463
- var documentOrOwner = function (dos) { return isDocument(dos) ? dos : owner(dos); };
464
- var parent = function (element) { return Optional.from(element.dom.parentNode).map(SugarElement.fromDom); };
465
- var parents = function (element, isRoot) {
466
- var stop = isFunction(isRoot) ? isRoot : never;
467
- var dom = element.dom;
468
- var ret = [];
469
- while (dom.parentNode !== null && dom.parentNode !== undefined) {
470
- var rawParent = dom.parentNode;
471
- var p = SugarElement.fromDom(rawParent);
472
- ret.push(p);
473
- if (stop(p) === true) {
474
- break;
475
- }
476
- else {
477
- dom = rawParent;
478
- }
479
- }
480
- return ret;
481
- };
482
- var prevSibling = function (element) { return Optional.from(element.dom.previousSibling).map(SugarElement.fromDom); };
483
- var nextSibling = function (element) { return Optional.from(element.dom.nextSibling).map(SugarElement.fromDom); };
484
- var children$3 = function (element) { return map(element.dom.childNodes, SugarElement.fromDom); };
485
- var child$3 = function (element, index) {
486
- var cs = element.dom.childNodes;
487
- return Optional.from(cs[index]).map(SugarElement.fromDom);
488
- };
489
- var firstChild = function (element) { return child$3(element, 0); };
490
- var isShadowRoot = function (dos) { return isDocumentFragment(dos) && isNonNullable(dos.dom.host); };
491
- var supported = isFunction(Element.prototype.attachShadow) && isFunction(Node.prototype.getRootNode);
492
- var getRootNode = supported ? function (e) { return SugarElement.fromDom(e.dom.getRootNode()); } : documentOrOwner;
493
- var getShadowRoot = function (e) {
494
- var r = getRootNode(e);
495
- return isShadowRoot(r) ? Optional.some(r) : Optional.none();
496
- };
497
- var getShadowHost = function (e) { return SugarElement.fromDom(e.dom.host); };
498
- var inBody = function (element) {
499
- var dom = isText(element) ? element.dom.parentNode : element.dom;
500
- if (dom === undefined || dom === null || dom.ownerDocument === null) {
501
- return false;
502
- }
503
- var doc = dom.ownerDocument;
504
- return getShadowRoot(SugarElement.fromDom(dom)).fold(function () { return doc.body.contains(dom); }, compose1(inBody, getShadowHost));
505
- };
506
- var ClosestOrAncestor = function (is, ancestor, scope, a, isRoot) {
507
- if (is(scope, a)) {
508
- return Optional.some(scope);
509
- }
510
- else if (isFunction(isRoot) && isRoot(scope)) {
511
- return Optional.none();
512
- }
513
- else {
514
- return ancestor(scope, a, isRoot);
515
- }
516
- };
517
- var ancestor$1 = function (scope, predicate, isRoot) {
518
- var element = scope.dom;
519
- var stop = isFunction(isRoot) ? isRoot : never;
520
- while (element.parentNode) {
521
- element = element.parentNode;
522
- var el = SugarElement.fromDom(element);
523
- if (predicate(el)) {
524
- return Optional.some(el);
525
- }
526
- else if (stop(el)) {
527
- break;
528
- }
529
- }
530
- return Optional.none();
531
- };
532
- var closest$2 = function (scope, predicate, isRoot) {
533
- var is = function (s, test) { return test(s); };
534
- return ClosestOrAncestor(is, ancestor$1, scope, predicate, isRoot);
535
- };
536
- var child$2 = function (scope, predicate) {
537
- var pred = function (node) { return predicate(SugarElement.fromDom(node)); };
538
- var result = find(scope.dom.childNodes, pred);
539
- return result.map(SugarElement.fromDom);
540
- };
541
- var ancestor = function (scope, selector, isRoot) { return ancestor$1(scope, function (e) { return is$2(e, selector); }, isRoot); };
542
- var child$1 = function (scope, selector) { return child$2(scope, function (e) { return is$2(e, selector); }); };
543
- var descendant = function (scope, selector) { return one(selector, scope); };
544
- var closest$1 = function (scope, selector, isRoot) {
545
- var is = function (element, selector) { return is$2(element, selector); };
546
- return ClosestOrAncestor(is, ancestor, scope, selector, isRoot);
547
- };
548
- var closest = function (target) { return closest$1(target, '[contenteditable]'); };
549
- var isEditable = function (element, assumeEditable) {
550
- if (assumeEditable === void 0) { assumeEditable = false; }
551
- if (inBody(element)) {
552
- return element.dom.isContentEditable;
553
- }
554
- else {
555
- return closest(element).fold(constant(assumeEditable), function (editable) { return getRaw$1(editable) === 'true'; });
556
- }
557
- };
558
- var getRaw$1 = function (element) { return element.dom.contentEditable; };
559
- var getNodeName = function (elm) { return elm.nodeName.toLowerCase(); };
560
- var getBody = function (editor) { return SugarElement.fromDom(editor.getBody()); };
561
- var getIsRoot = function (editor) { return function (element) { return eq(element, getBody(editor)); }; };
562
- var removePxSuffix = function (size) { return size ? size.replace(/px$/, '') : ''; };
563
- var addPxSuffix = function (size) { return /^\d+(\.\d+)?$/.test(size) ? size + 'px' : size; };
564
- var getSelectionStart = function (editor) { return SugarElement.fromDom(editor.selection.getStart()); };
565
- var getSelectionEnd = function (editor) { return SugarElement.fromDom(editor.selection.getEnd()); };
566
- var isInEditableContext = function (cell) { return closest$2(cell, isTag('table')).forall(isEditable); };
567
- var children$2 = function (scope, predicate) { return filter(children$3(scope), predicate); };
568
- var descendants$1 = function (scope, predicate) {
569
- var result = [];
570
- each(children$3(scope), function (x) {
571
- if (predicate(x)) {
572
- result = result.concat([x]);
573
- }
574
- result = result.concat(descendants$1(x, predicate));
575
- });
576
- return result;
577
- };
578
- var children$1 = function (scope, selector) { return children$2(scope, function (e) { return is$2(e, selector); }); };
579
- var descendants = function (scope, selector) { return all$1(selector, scope); };
580
- var rawSet = function (dom, key, value) {
581
- if (isString(value) || isBoolean(value) || isNumber(value)) {
582
- dom.setAttribute(key, value + '');
583
- }
584
- else {
585
- console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom);
586
- throw new Error('Attribute value was not simple');
587
- }
588
- };
589
- var set$2 = function (element, key, value) {
590
- rawSet(element.dom, key, value);
591
- };
592
- var setAll = function (element, attrs) {
593
- var dom = element.dom;
594
- each$1(attrs, function (v, k) {
595
- rawSet(dom, k, v);
596
- });
597
- };
598
- var get$2 = function (element, key) {
599
- var v = element.dom.getAttribute(key);
600
- return v === null ? undefined : v;
601
- };
602
- var getOpt = function (element, key) { return Optional.from(get$2(element, key)); };
603
- var remove$2 = function (element, key) {
604
- element.dom.removeAttribute(key);
605
- };
606
- var clone = function (element) { return foldl(element.dom.attributes, function (acc, attr) {
607
- acc[attr.name] = attr.value;
608
- return acc;
609
- }, {}); };
610
- var is = function (lhs, rhs, comparator) {
611
- if (comparator === void 0) { comparator = tripleEquals; }
612
- return lhs.exists(function (left) { return comparator(left, rhs); });
613
- };
614
- var cat = function (arr) {
615
- var r = [];
616
- var push = function (x) {
617
- r.push(x);
618
- };
619
- for (var i = 0; i < arr.length; i++) {
620
- arr[i].each(push);
621
- }
622
- return r;
623
- };
624
- var lift2 = function (oa, ob, f) { return oa.isSome() && ob.isSome() ? Optional.some(f(oa.getOrDie(), ob.getOrDie())) : Optional.none(); };
625
- var flatten = function (oot) { return oot.bind(identity); };
626
- var someIf = function (b, a) { return b ? Optional.some(a) : Optional.none(); };
627
- var removeFromStart = function (str, numChars) {
628
- return str.substring(numChars);
629
- };
630
- var checkRange = function (str, substr, start) { return substr === '' || str.length >= substr.length && str.substr(start, start + substr.length) === substr; };
631
- var removeLeading = function (str, prefix) {
632
- return startsWith(str, prefix) ? removeFromStart(str, prefix.length) : str;
633
- };
634
- var startsWith = function (str, prefix) {
635
- return checkRange(str, prefix, 0);
636
- };
637
- var blank = function (r) { return function (s) { return s.replace(r, ''); }; };
638
- var trim = blank(/^\s+|\s+$/g);
639
- var isNotEmpty = function (s) { return s.length > 0; };
640
- var isEmpty = function (s) { return !isNotEmpty(s); };
641
- var toInt = function (value, radix) {
642
- if (radix === void 0) { radix = 10; }
643
- var num = parseInt(value, radix);
644
- return isNaN(num) ? Optional.none() : Optional.some(num);
645
- };
646
- var toFloat = function (value) {
647
- var num = parseFloat(value);
648
- return isNaN(num) ? Optional.none() : Optional.some(num);
649
- };
650
- var isSupported = function (dom) { return dom.style !== undefined && isFunction(dom.style.getPropertyValue); };
651
- var internalSet = function (dom, property, value) {
652
- if (!isString(value)) {
653
- console.error('Invalid call to CSS.set. Property ', property, ':: Value ', value, ':: Element ', dom);
654
- throw new Error('CSS value must be a string: ' + value);
655
- }
656
- if (isSupported(dom)) {
657
- dom.style.setProperty(property, value);
658
- }
659
- };
660
- var internalRemove = function (dom, property) {
661
- if (isSupported(dom)) {
662
- dom.style.removeProperty(property);
663
- }
664
- };
665
- var set$1 = function (element, property, value) {
666
- var dom = element.dom;
667
- internalSet(dom, property, value);
668
- };
669
- var get$1 = function (element, property) {
670
- var dom = element.dom;
671
- var styles = window.getComputedStyle(dom);
672
- var r = styles.getPropertyValue(property);
673
- return r === '' && !inBody(element) ? getUnsafeProperty(dom, property) : r;
674
- };
675
- var getUnsafeProperty = function (dom, property) { return isSupported(dom) ? dom.style.getPropertyValue(property) : ''; };
676
- var getRaw = function (element, property) {
677
- var dom = element.dom;
678
- var raw = getUnsafeProperty(dom, property);
679
- return Optional.from(raw).filter(function (r) { return r.length > 0; });
680
- };
681
- var remove$1 = function (element, property) {
682
- var dom = element.dom;
683
- internalRemove(dom, property);
684
- if (is(getOpt(element, 'style').map(trim), '')) {
685
- remove$2(element, 'style');
686
- }
687
- };
688
- var getAttrValue = function (cell, name, fallback) {
689
- if (fallback === void 0) { fallback = 0; }
690
- return getOpt(cell, name).map(function (value) { return parseInt(value, 10); }).getOr(fallback);
691
- };
692
- var firstLayer = function (scope, selector) {
693
- return filterFirstLayer(scope, selector, always);
694
- };
695
- var filterFirstLayer = function (scope, selector, predicate) {
696
- return bind(children$3(scope), function (x) {
697
- if (is$2(x, selector)) {
698
- return predicate(x) ? [x] : [];
699
- }
700
- else {
701
- return filterFirstLayer(x, selector, predicate);
702
- }
703
- });
704
- };
705
- var validSectionList = [
706
- 'tfoot',
707
- 'thead',
708
- 'tbody',
709
- 'colgroup'
710
- ];
711
- var isValidSection = function (parentName) { return contains(validSectionList, parentName); };
712
- var grid = function (rows, columns) { return ({
713
- rows: rows,
714
- columns: columns
715
- }); };
716
- var detail = function (element, rowspan, colspan) { return ({
717
- element: element,
718
- rowspan: rowspan,
719
- colspan: colspan
720
- }); };
721
- var extended = function (element, rowspan, colspan, row, column, isLocked) { return ({
722
- element: element,
723
- rowspan: rowspan,
724
- colspan: colspan,
725
- row: row,
726
- column: column,
727
- isLocked: isLocked
728
- }); };
729
- var rowdetail = function (element, cells, section) { return ({
730
- element: element,
731
- cells: cells,
732
- section: section
733
- }); };
734
- var bounds = function (startRow, startCol, finishRow, finishCol) { return ({
735
- startRow: startRow,
736
- startCol: startCol,
737
- finishRow: finishRow,
738
- finishCol: finishCol
739
- }); };
740
- var columnext = function (element, colspan, column) { return ({
741
- element: element,
742
- colspan: colspan,
743
- column: column
744
- }); };
745
- var colgroup = function (element, columns) { return ({
746
- element: element,
747
- columns: columns
748
- }); };
749
- var lookup = function (tags, element, isRoot) {
750
- if (isRoot === void 0) { isRoot = never; }
751
- if (isRoot(element)) {
752
- return Optional.none();
753
- }
754
- if (contains(tags, name(element))) {
755
- return Optional.some(element);
756
- }
757
- var isRootOrUpperTable = function (elm) { return is$2(elm, 'table') || isRoot(elm); };
758
- return ancestor(element, tags.join(','), isRootOrUpperTable);
759
- };
760
- var cell = function (element, isRoot) { return lookup([
761
- 'td',
762
- 'th'
763
- ], element, isRoot); };
764
- var cells = function (ancestor) { return firstLayer(ancestor, 'th,td'); };
765
- var columns = function (ancestor) {
766
- if (is$2(ancestor, 'colgroup')) {
767
- return children$1(ancestor, 'col');
768
- }
769
- else {
770
- return bind(columnGroups(ancestor), function (columnGroup) { return children$1(columnGroup, 'col'); });
771
- }
772
- };
773
- var table = function (element, isRoot) { return closest$1(element, 'table', isRoot); };
774
- var rows = function (ancestor) { return firstLayer(ancestor, 'tr'); };
775
- var columnGroups = function (ancestor) { return table(ancestor).fold(constant([]), function (table) { return children$1(table, 'colgroup'); }); };
776
- var fromRowsOrColGroups = function (elems, getSection) { return map(elems, function (row) {
777
- if (name(row) === 'colgroup') {
778
- var cells_1 = map(columns(row), function (column) {
779
- var colspan = getAttrValue(column, 'span', 1);
780
- return detail(column, 1, colspan);
781
- });
782
- return rowdetail(row, cells_1, 'colgroup');
783
- }
784
- else {
785
- var cells$1 = map(cells(row), function (cell) {
786
- var rowspan = getAttrValue(cell, 'rowspan', 1);
787
- var colspan = getAttrValue(cell, 'colspan', 1);
788
- return detail(cell, rowspan, colspan);
789
- });
790
- return rowdetail(row, cells$1, getSection(row));
791
- }
792
- }); };
793
- var getParentSection = function (group) { return parent(group).map(function (parent) {
794
- var parentName = name(parent);
795
- return isValidSection(parentName) ? parentName : 'tbody';
796
- }).getOr('tbody'); };
797
- var fromTable$1 = function (table) {
798
- var rows$1 = rows(table);
799
- var columnGroups$1 = columnGroups(table);
800
- var elems = __spreadArray(__spreadArray([], columnGroups$1, true), rows$1, true);
801
- return fromRowsOrColGroups(elems, getParentSection);
802
- };
803
- var LOCKED_COL_ATTR = 'data-snooker-locked-cols';
804
- var getLockedColumnsFromTable = function (table) { return getOpt(table, LOCKED_COL_ATTR).bind(function (lockedColStr) { return Optional.from(lockedColStr.match(/\d+/g)); }).map(function (lockedCols) { return mapToObject(lockedCols, always); }); };
805
- var key = function (row, column) {
806
- return row + ',' + column;
807
- };
808
- var getAt = function (warehouse, row, column) { return Optional.from(warehouse.access[key(row, column)]); };
809
- var findItem = function (warehouse, item, comparator) {
810
- var filtered = filterItems(warehouse, function (detail) {
811
- return comparator(item, detail.element);
812
- });
813
- return filtered.length > 0 ? Optional.some(filtered[0]) : Optional.none();
814
- };
815
- var filterItems = function (warehouse, predicate) {
816
- var all = bind(warehouse.all, function (r) {
817
- return r.cells;
818
- });
819
- return filter(all, predicate);
820
- };
821
- var generateColumns = function (rowData) {
822
- var columnsGroup = {};
823
- var index = 0;
824
- each(rowData.cells, function (column) {
825
- var colspan = column.colspan;
826
- range(colspan, function (columnIndex) {
827
- var colIndex = index + columnIndex;
828
- columnsGroup[colIndex] = columnext(column.element, colspan, colIndex);
829
- });
830
- index += colspan;
831
- });
832
- return columnsGroup;
833
- };
834
- var generate$1 = function (list) {
835
- var access = {};
836
- var cells = [];
837
- var tableOpt = head(list).map(function (rowData) { return rowData.element; }).bind(table);
838
- var lockedColumns = tableOpt.bind(getLockedColumnsFromTable).getOr({});
839
- var maxRows = 0;
840
- var maxColumns = 0;
841
- var rowCount = 0;
842
- var _b = partition(list, function (rowData) { return rowData.section === 'colgroup'; }), colgroupRows = _b.pass, rows = _b.fail;
843
- each(rows, function (rowData) {
844
- var currentRow = [];
845
- each(rowData.cells, function (rowCell) {
846
- var start = 0;
847
- while (access[key(rowCount, start)] !== undefined) {
848
- start++;
849
- }
850
- var isLocked = hasNonNullableKey(lockedColumns, start.toString());
851
- var current = extended(rowCell.element, rowCell.rowspan, rowCell.colspan, rowCount, start, isLocked);
852
- for (var occupiedColumnPosition = 0; occupiedColumnPosition < rowCell.colspan; occupiedColumnPosition++) {
853
- for (var occupiedRowPosition = 0; occupiedRowPosition < rowCell.rowspan; occupiedRowPosition++) {
854
- var rowPosition = rowCount + occupiedRowPosition;
855
- var columnPosition = start + occupiedColumnPosition;
856
- var newpos = key(rowPosition, columnPosition);
857
- access[newpos] = current;
858
- maxColumns = Math.max(maxColumns, columnPosition + 1);
859
- }
860
- }
861
- currentRow.push(current);
862
- });
863
- maxRows++;
864
- cells.push(rowdetail(rowData.element, currentRow, rowData.section));
865
- rowCount++;
866
- });
867
- var _c = last(colgroupRows).map(function (rowData) {
868
- var columns = generateColumns(rowData);
869
- var colgroup$1 = colgroup(rowData.element, values(columns));
870
- return {
871
- colgroups: [colgroup$1],
872
- columns: columns
873
- };
874
- }).getOrThunk(function () { return ({
875
- colgroups: [],
876
- columns: {}
877
- }); }), columns = _c.columns, colgroups = _c.colgroups;
878
- var grid$1 = grid(maxRows, maxColumns);
879
- return {
880
- grid: grid$1,
881
- access: access,
882
- all: cells,
883
- columns: columns,
884
- colgroups: colgroups
885
- };
886
- };
887
- var fromTable = function (table) {
888
- var list = fromTable$1(table);
889
- return generate$1(list);
890
- };
891
- var justCells = function (warehouse) { return bind(warehouse.all, function (w) { return w.cells; }); };
892
- var justColumns = function (warehouse) { return values(warehouse.columns); };
893
- var hasColumns = function (warehouse) { return keys(warehouse.columns).length > 0; };
894
- var getColumnAt = function (warehouse, columnIndex) { return Optional.from(warehouse.columns[columnIndex]); };
895
- var Warehouse = {
896
- fromTable: fromTable,
897
- generate: generate$1,
898
- getAt: getAt,
899
- findItem: findItem,
900
- filterItems: filterItems,
901
- justCells: justCells,
902
- justColumns: justColumns,
903
- hasColumns: hasColumns,
904
- getColumnAt: getColumnAt
905
- };
906
- var global$2 = tinymce.util.Tools.resolve('tinymce.util.Tools');
907
- var getTDTHOverallStyle = function (dom, elm, name) {
908
- var cells = dom.select('td,th', elm);
909
- var firstChildStyle;
910
- for (var i = 0; i < cells.length; i++) {
911
- var currentStyle = dom.getStyle(cells[i], name);
912
- if (isUndefined(firstChildStyle)) {
913
- firstChildStyle = currentStyle;
914
- }
915
- if (firstChildStyle !== currentStyle) {
916
- return '';
917
- }
918
- }
919
- return firstChildStyle;
920
- };
921
- var setAlign = function (editor, elm, name) {
922
- global$2.each('left center right'.split(' '), function (align) {
923
- if (align !== name) {
924
- editor.formatter.remove('align' + align, {}, elm);
925
- }
926
- });
927
- if (name) {
928
- editor.formatter.apply('align' + name, {}, elm);
929
- }
930
- };
931
- var setVAlign = function (editor, elm, name) {
932
- global$2.each('top middle bottom'.split(' '), function (align) {
933
- if (align !== name) {
934
- editor.formatter.remove('valign' + align, {}, elm);
935
- }
936
- });
937
- if (name) {
938
- editor.formatter.apply('valign' + name, {}, elm);
939
- }
940
- };
941
- var fireTableModified = function (editor, table, data) {
942
- editor.dispatch('TableModified', __assign(__assign({}, data), { table: table }));
943
- };
944
- var toNumber = function (px, fallback) { return toFloat(px).getOr(fallback); };
945
- var getProp = function (element, name, fallback) { return toNumber(get$1(element, name), fallback); };
946
- var calcContentBoxSize = function (element, size, upper, lower) {
947
- var paddingUpper = getProp(element, "padding-".concat(upper), 0);
948
- var paddingLower = getProp(element, "padding-".concat(lower), 0);
949
- var borderUpper = getProp(element, "border-".concat(upper, "-width"), 0);
950
- var borderLower = getProp(element, "border-".concat(lower, "-width"), 0);
951
- return size - paddingUpper - paddingLower - borderUpper - borderLower;
952
- };
953
- var getCalculatedWidth = function (element, boxSizing) {
954
- var dom = element.dom;
955
- var width = dom.getBoundingClientRect().width || dom.offsetWidth;
956
- return boxSizing === 'border-box' ? width : calcContentBoxSize(element, width, 'left', 'right');
957
- };
958
- var getInnerWidth = function (element) { return getCalculatedWidth(element, 'content-box'); };
959
- var getInner = getInnerWidth;
960
- var global$1 = tinymce.util.Tools.resolve('tinymce.Env');
961
- var defaultTableToolbar = 'tableprops tabledelete | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol';
962
- var defaultCellBorderWidths = range(5, function (i) {
963
- var size = "".concat(i + 1, "px");
964
- return {
965
- title: size,
966
- value: size
967
- };
968
- });
969
- var defaultCellBorderStyles = map([
970
- 'Solid',
971
- 'Dotted',
972
- 'Dashed',
973
- 'Double',
974
- 'Groove',
975
- 'Ridge',
976
- 'Inset',
977
- 'Outset',
978
- 'None',
979
- 'Hidden'
980
- ], function (type) {
981
- return {
982
- title: type,
983
- value: type.toLowerCase()
984
- };
985
- });
986
- var defaultWidth = '100%';
987
- var getPixelForcedWidth = function (editor) {
988
- var _a;
989
- var dom = editor.dom;
990
- var parentBlock = (_a = dom.getParent(editor.selection.getStart(), dom.isBlock)) !== null && _a !== void 0 ? _a : editor.getBody();
991
- return getInner(SugarElement.fromDom(parentBlock)) + 'px';
992
- };
993
- var determineDefaultStyles = function (editor, defaultStyles) {
994
- if (isResponsiveForced(editor) || !shouldStyleWithCss(editor)) {
995
- return defaultStyles;
996
- }
997
- else if (isPixelsForced(editor)) {
998
- return __assign(__assign({}, defaultStyles), { width: getPixelForcedWidth(editor) });
999
- }
1000
- else {
1001
- return __assign(__assign({}, defaultStyles), { width: defaultWidth });
1002
- }
1003
- };
1004
- var determineDefaultAttributes = function (editor, defaultAttributes) {
1005
- if (isResponsiveForced(editor) || shouldStyleWithCss(editor)) {
1006
- return defaultAttributes;
1007
- }
1008
- else if (isPixelsForced(editor)) {
1009
- return __assign(__assign({}, defaultAttributes), { width: getPixelForcedWidth(editor) });
1010
- }
1011
- else {
1012
- return __assign(__assign({}, defaultAttributes), { width: defaultWidth });
1013
- }
1014
- };
1015
- var option = function (name) { return function (editor) { return editor.options.get(name); }; };
1016
- var register = function (editor) {
1017
- var registerOption = editor.options.register;
1018
- registerOption('table_border_widths', {
1019
- processor: 'object[]',
1020
- default: defaultCellBorderWidths
1021
- });
1022
- registerOption('table_border_styles', {
1023
- processor: 'object[]',
1024
- default: defaultCellBorderStyles
1025
- });
1026
- registerOption('table_cell_advtab', {
1027
- processor: 'boolean',
1028
- default: true
1029
- });
1030
- registerOption('table_row_advtab', {
1031
- processor: 'boolean',
1032
- default: true
1033
- });
1034
- registerOption('table_advtab', {
1035
- processor: 'boolean',
1036
- default: true
1037
- });
1038
- registerOption('table_appearance_options', {
1039
- processor: 'boolean',
1040
- default: true
1041
- });
1042
- registerOption('table_grid', {
1043
- processor: 'boolean',
1044
- default: !global$1.deviceType.isTouch()
1045
- });
1046
- registerOption('table_cell_class_list', {
1047
- processor: 'object[]',
1048
- default: []
1049
- });
1050
- registerOption('table_row_class_list', {
1051
- processor: 'object[]',
1052
- default: []
1053
- });
1054
- registerOption('table_class_list', {
1055
- processor: 'object[]',
1056
- default: []
1057
- });
1058
- registerOption('table_toolbar', {
1059
- processor: 'string',
1060
- default: defaultTableToolbar
1061
- });
1062
- registerOption('table_background_color_map', {
1063
- processor: 'object[]',
1064
- default: []
1065
- });
1066
- registerOption('table_border_color_map', {
1067
- processor: 'object[]',
1068
- default: []
1069
- });
1070
- };
1071
- var getTableSizingMode = option('table_sizing_mode');
1072
- var getTableBorderWidths = option('table_border_widths');
1073
- var getTableBorderStyles = option('table_border_styles');
1074
- var hasAdvancedCellTab = option('table_cell_advtab');
1075
- var hasAdvancedRowTab = option('table_row_advtab');
1076
- var hasAdvancedTableTab = option('table_advtab');
1077
- var hasAppearanceOptions = option('table_appearance_options');
1078
- var hasTableGrid = option('table_grid');
1079
- var shouldStyleWithCss = option('table_style_by_css');
1080
- var getCellClassList = option('table_cell_class_list');
1081
- var getRowClassList = option('table_row_class_list');
1082
- var getTableClassList = option('table_class_list');
1083
- var getToolbar = option('table_toolbar');
1084
- var getTableBackgroundColorMap = option('table_background_color_map');
1085
- var getTableBorderColorMap = option('table_border_color_map');
1086
- var isPixelsForced = function (editor) { return getTableSizingMode(editor) === 'fixed'; };
1087
- var isResponsiveForced = function (editor) { return getTableSizingMode(editor) === 'responsive'; };
1088
- var getDefaultStyles = function (editor) {
1089
- var options = editor.options;
1090
- var defaultStyles = options.get('table_default_styles');
1091
- return options.isSet('table_default_styles') ? defaultStyles : determineDefaultStyles(editor, defaultStyles);
1092
- };
1093
- var getDefaultAttributes = function (editor) {
1094
- var options = editor.options;
1095
- var defaultAttributes = options.get('table_default_attributes');
1096
- return options.isSet('table_default_attributes') ? defaultAttributes : determineDefaultAttributes(editor, defaultAttributes);
1097
- };
1098
- var isWithin = function (bounds, detail) {
1099
- return detail.column >= bounds.startCol && detail.column + detail.colspan - 1 <= bounds.finishCol && detail.row >= bounds.startRow && detail.row + detail.rowspan - 1 <= bounds.finishRow;
1100
- };
1101
- var isRectangular = function (warehouse, bounds) {
1102
- var isRect = true;
1103
- var detailIsWithin = curry(isWithin, bounds);
1104
- for (var i = bounds.startRow; i <= bounds.finishRow; i++) {
1105
- for (var j = bounds.startCol; j <= bounds.finishCol; j++) {
1106
- isRect = isRect && Warehouse.getAt(warehouse, i, j).exists(detailIsWithin);
1107
- }
1108
- }
1109
- return isRect ? Optional.some(bounds) : Optional.none();
1110
- };
1111
- var getBounds = function (detailA, detailB) {
1112
- return bounds(Math.min(detailA.row, detailB.row), Math.min(detailA.column, detailB.column), Math.max(detailA.row + detailA.rowspan - 1, detailB.row + detailB.rowspan - 1), Math.max(detailA.column + detailA.colspan - 1, detailB.column + detailB.colspan - 1));
1113
- };
1114
- var getAnyBox = function (warehouse, startCell, finishCell) {
1115
- var startCoords = Warehouse.findItem(warehouse, startCell, eq);
1116
- var finishCoords = Warehouse.findItem(warehouse, finishCell, eq);
1117
- return startCoords.bind(function (sc) {
1118
- return finishCoords.map(function (fc) {
1119
- return getBounds(sc, fc);
1120
- });
1121
- });
1122
- };
1123
- var getBox$1 = function (warehouse, startCell, finishCell) {
1124
- return getAnyBox(warehouse, startCell, finishCell).bind(function (bounds) {
1125
- return isRectangular(warehouse, bounds);
1126
- });
1127
- };
1128
- var getBox = function (table, first, last) {
1129
- var warehouse = getWarehouse(table);
1130
- return getBox$1(warehouse, first, last);
1131
- };
1132
- var getWarehouse = Warehouse.fromTable;
1133
- var before = function (marker, element) {
1134
- var parent$1 = parent(marker);
1135
- parent$1.each(function (v) {
1136
- v.dom.insertBefore(element.dom, marker.dom);
1137
- });
1138
- };
1139
- var after$1 = function (marker, element) {
1140
- var sibling = nextSibling(marker);
1141
- sibling.fold(function () {
1142
- var parent$1 = parent(marker);
1143
- parent$1.each(function (v) {
1144
- append$1(v, element);
1145
- });
1146
- }, function (v) {
1147
- before(v, element);
1148
- });
1149
- };
1150
- var prepend = function (parent, element) {
1151
- var firstChild$1 = firstChild(parent);
1152
- firstChild$1.fold(function () {
1153
- append$1(parent, element);
1154
- }, function (v) {
1155
- parent.dom.insertBefore(element.dom, v.dom);
1156
- });
1157
- };
1158
- var append$1 = function (parent, element) {
1159
- parent.dom.appendChild(element.dom);
1160
- };
1161
- var wrap = function (element, wrapper) {
1162
- before(element, wrapper);
1163
- append$1(wrapper, element);
1164
- };
1165
- var after = function (marker, elements) {
1166
- each(elements, function (x, i) {
1167
- var e = i === 0 ? marker : elements[i - 1];
1168
- after$1(e, x);
1169
- });
1170
- };
1171
- var append = function (parent, elements) {
1172
- each(elements, function (x) {
1173
- append$1(parent, x);
1174
- });
1175
- };
1176
- var remove = function (element) {
1177
- var dom = element.dom;
1178
- if (dom.parentNode !== null) {
1179
- dom.parentNode.removeChild(dom);
1180
- }
1181
- };
1182
- var unwrap = function (wrapper) {
1183
- var children = children$3(wrapper);
1184
- if (children.length > 0) {
1185
- after(wrapper, children);
1186
- }
1187
- remove(wrapper);
1188
- };
1189
- var NodeValue = function (is, name) {
1190
- var get = function (element) {
1191
- if (!is(element)) {
1192
- throw new Error('Can only get ' + name + ' value of a ' + name + ' node');
1193
- }
1194
- return getOption(element).getOr('');
1195
- };
1196
- var getOption = function (element) { return is(element) ? Optional.from(element.dom.nodeValue) : Optional.none(); };
1197
- var set = function (element, value) {
1198
- if (!is(element)) {
1199
- throw new Error('Can only set raw ' + name + ' value of a ' + name + ' node');
1200
- }
1201
- element.dom.nodeValue = value;
1202
- };
1203
- return {
1204
- get: get,
1205
- getOption: getOption,
1206
- set: set
1207
- };
1208
- };
1209
- var api = NodeValue(isText, 'text');
1210
- var get = function (element) { return api.get(element); };
1211
- var set = function (element, value) { return api.set(element, value); };
1212
- var TagBoundaries = [
1213
- 'body',
1214
- 'p',
1215
- 'div',
1216
- 'article',
1217
- 'aside',
1218
- 'figcaption',
1219
- 'figure',
1220
- 'footer',
1221
- 'header',
1222
- 'nav',
1223
- 'section',
1224
- 'ol',
1225
- 'ul',
1226
- 'li',
1227
- 'table',
1228
- 'thead',
1229
- 'tbody',
1230
- 'tfoot',
1231
- 'caption',
1232
- 'tr',
1233
- 'td',
1234
- 'th',
1235
- 'h1',
1236
- 'h2',
1237
- 'h3',
1238
- 'h4',
1239
- 'h5',
1240
- 'h6',
1241
- 'blockquote',
1242
- 'pre',
1243
- 'address'
1244
- ];
1245
- var DomUniverse = function () {
1246
- var clone$1 = function (element) {
1247
- return SugarElement.fromDom(element.dom.cloneNode(false));
1248
- };
1249
- var document = function (element) { return documentOrOwner(element).dom; };
1250
- var isBoundary = function (element) {
1251
- if (!isElement(element)) {
1252
- return false;
1253
- }
1254
- if (name(element) === 'body') {
1255
- return true;
1256
- }
1257
- return contains(TagBoundaries, name(element));
1258
- };
1259
- var isEmptyTag = function (element) {
1260
- if (!isElement(element)) {
1261
- return false;
1262
- }
1263
- return contains([
1264
- 'br',
1265
- 'img',
1266
- 'hr',
1267
- 'input'
1268
- ], name(element));
1269
- };
1270
- var isNonEditable = function (element) { return isElement(element) && get$2(element, 'contenteditable') === 'false'; };
1271
- var comparePosition = function (element, other) {
1272
- return element.dom.compareDocumentPosition(other.dom);
1273
- };
1274
- var copyAttributesTo = function (source, destination) {
1275
- var as = clone(source);
1276
- setAll(destination, as);
1277
- };
1278
- var isSpecial = function (element) {
1279
- var tag = name(element);
1280
- return contains([
1281
- 'script',
1282
- 'noscript',
1283
- 'iframe',
1284
- 'noframes',
1285
- 'noembed',
1286
- 'title',
1287
- 'style',
1288
- 'textarea',
1289
- 'xmp'
1290
- ], tag);
1291
- };
1292
- var getLanguage = function (element) { return isElement(element) ? getOpt(element, 'lang') : Optional.none(); };
1293
- return {
1294
- up: constant({
1295
- selector: ancestor,
1296
- closest: closest$1,
1297
- predicate: ancestor$1,
1298
- all: parents
1299
- }),
1300
- down: constant({
1301
- selector: descendants,
1302
- predicate: descendants$1
1303
- }),
1304
- styles: constant({
1305
- get: get$1,
1306
- getRaw: getRaw,
1307
- set: set$1,
1308
- remove: remove$1
1309
- }),
1310
- attrs: constant({
1311
- get: get$2,
1312
- set: set$2,
1313
- remove: remove$2,
1314
- copyTo: copyAttributesTo
1315
- }),
1316
- insert: constant({
1317
- before: before,
1318
- after: after$1,
1319
- afterAll: after,
1320
- append: append$1,
1321
- appendAll: append,
1322
- prepend: prepend,
1323
- wrap: wrap
1324
- }),
1325
- remove: constant({
1326
- unwrap: unwrap,
1327
- remove: remove
1328
- }),
1329
- create: constant({
1330
- nu: SugarElement.fromTag,
1331
- clone: clone$1,
1332
- text: SugarElement.fromText
1333
- }),
1334
- query: constant({
1335
- comparePosition: comparePosition,
1336
- prevSibling: prevSibling,
1337
- nextSibling: nextSibling
1338
- }),
1339
- property: constant({
1340
- children: children$3,
1341
- name: name,
1342
- parent: parent,
1343
- document: document,
1344
- isText: isText,
1345
- isComment: isComment,
1346
- isElement: isElement,
1347
- isSpecial: isSpecial,
1348
- getLanguage: getLanguage,
1349
- getText: get,
1350
- setText: set,
1351
- isBoundary: isBoundary,
1352
- isEmptyTag: isEmptyTag,
1353
- isNonEditable: isNonEditable
1354
- }),
1355
- eq: eq,
1356
- is: is$1
1357
- };
1358
- };
1359
- var all = function (universe, look, elements, f) {
1360
- var head = elements[0];
1361
- var tail = elements.slice(1);
1362
- return f(universe, look, head, tail);
1363
- };
1364
- var oneAll = function (universe, look, elements) {
1365
- return elements.length > 0 ? all(universe, look, elements, unsafeOne) : Optional.none();
1366
- };
1367
- var unsafeOne = function (universe, look, head, tail) {
1368
- var start = look(universe, head);
1369
- return foldr(tail, function (b, a) {
1370
- var current = look(universe, a);
1371
- return commonElement(universe, b, current);
1372
- }, start);
1373
- };
1374
- var commonElement = function (universe, start, end) {
1375
- return start.bind(function (s) {
1376
- return end.filter(curry(universe.eq, s));
1377
- });
1378
- };
1379
- var sharedOne$1 = oneAll;
1380
- var universe = DomUniverse();
1381
- var sharedOne = function (look, elements) {
1382
- return sharedOne$1(universe, function (_universe, element) {
1383
- return look(element);
1384
- }, elements);
1385
- };
1386
- var lookupTable = function (container) {
1387
- return ancestor(container, 'table');
1388
- };
1389
- var retrieve$1 = function (container, selector) {
1390
- var sels = descendants(container, selector);
1391
- return sels.length > 0 ? Optional.some(sels) : Optional.none();
1392
- };
1393
- var getEdges = function (container, firstSelectedSelector, lastSelectedSelector) {
1394
- return descendant(container, firstSelectedSelector).bind(function (first) {
1395
- return descendant(container, lastSelectedSelector).bind(function (last) {
1396
- return sharedOne(lookupTable, [
1397
- first,
1398
- last
1399
- ]).map(function (table) {
1400
- return {
1401
- first: first,
1402
- last: last,
1403
- table: table
1404
- };
1405
- });
1406
- });
1407
- });
1408
- };
1409
- var retrieve = function (container, selector) {
1410
- return retrieve$1(container, selector);
1411
- };
1412
- var retrieveBox = function (container, firstSelectedSelector, lastSelectedSelector) {
1413
- return getEdges(container, firstSelectedSelector, lastSelectedSelector).bind(function (edges) {
1414
- var isRoot = function (ancestor) {
1415
- return eq(container, ancestor);
1416
- };
1417
- var sectionSelector = 'thead,tfoot,tbody,table';
1418
- var firstAncestor = ancestor(edges.first, sectionSelector, isRoot);
1419
- var lastAncestor = ancestor(edges.last, sectionSelector, isRoot);
1420
- return firstAncestor.bind(function (fA) {
1421
- return lastAncestor.bind(function (lA) {
1422
- return eq(fA, lA) ? getBox(edges.table, edges.first, edges.last) : Optional.none();
1423
- });
1424
- });
1425
- });
1426
- };
1427
- var fromDom = function (nodes) { return map(nodes, SugarElement.fromDom); };
1428
- var strSelected = 'data-mce-selected';
1429
- var strSelectedSelector = 'td[' + strSelected + '],th[' + strSelected + ']';
1430
- var strFirstSelected = 'data-mce-first-selected';
1431
- var strFirstSelectedSelector = 'td[' + strFirstSelected + '],th[' + strFirstSelected + ']';
1432
- var strLastSelected = 'data-mce-last-selected';
1433
- var strLastSelectedSelector = 'td[' + strLastSelected + '],th[' + strLastSelected + ']';
1434
- var ephemera = {
1435
- selected: strSelected,
1436
- selectedSelector: strSelectedSelector,
1437
- firstSelected: strFirstSelected,
1438
- firstSelectedSelector: strFirstSelectedSelector,
1439
- lastSelected: strLastSelected,
1440
- lastSelectedSelector: strLastSelectedSelector
1441
- };
1442
- var getSelectionCellFallback = function (element) { return table(element).bind(function (table) { return retrieve(table, ephemera.firstSelectedSelector); }).fold(constant(element), function (cells) { return cells[0]; }); };
1443
- var getSelectionFromSelector = function (selector) { return function (initCell, isRoot) {
1444
- var cellName = name(initCell);
1445
- var cell = cellName === 'col' || cellName === 'colgroup' ? getSelectionCellFallback(initCell) : initCell;
1446
- return closest$1(cell, selector, isRoot);
1447
- }; };
1448
- var getSelectionCellOrCaption = getSelectionFromSelector('th,td,caption');
1449
- var getSelectionCell = getSelectionFromSelector('th,td');
1450
- var getCellsFromSelection = function (editor) { return fromDom(editor.model.table.getSelectedCells()); };
1451
- var getRowsFromSelection = function (selected, selector) {
1452
- var cellOpt = getSelectionCell(selected);
1453
- var rowsOpt = cellOpt.bind(function (cell) { return table(cell); }).map(function (table) { return rows(table); });
1454
- return lift2(cellOpt, rowsOpt, function (cell, rows) { return filter(rows, function (row) { return exists(fromDom(row.dom.cells), function (rowCell) { return get$2(rowCell, selector) === '1' || eq(rowCell, cell); }); }); }).getOr([]);
1455
- };
1456
- var verticalAlignValues = [
1457
- {
1458
- text: 'None',
1459
- value: ''
1460
- },
1461
- {
1462
- text: 'Top',
1463
- value: 'top'
1464
- },
1465
- {
1466
- text: 'Middle',
1467
- value: 'middle'
1468
- },
1469
- {
1470
- text: 'Bottom',
1471
- value: 'bottom'
1472
- }
1473
- ];
1474
- var hexColour = function (value) { return ({ value: normalizeHex(value) }); };
1475
- var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
1476
- var longformRegex = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i;
1477
- var isHexString = function (hex) { return shorthandRegex.test(hex) || longformRegex.test(hex); };
1478
- var normalizeHex = function (hex) { return removeLeading(hex, '#').toUpperCase(); };
1479
- var fromString$1 = function (hex) { return isHexString(hex) ? Optional.some({ value: normalizeHex(hex) }) : Optional.none(); };
1480
- var toHex = function (component) {
1481
- var hex = component.toString(16);
1482
- return (hex.length === 1 ? '0' + hex : hex).toUpperCase();
1483
- };
1484
- var fromRgba = function (rgbaColour) {
1485
- var value = toHex(rgbaColour.red) + toHex(rgbaColour.green) + toHex(rgbaColour.blue);
1486
- return hexColour(value);
1487
- };
1488
- var rgbRegex = /^\s*rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)\s*$/i;
1489
- var rgbaRegex = /^\s*rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?(?:\.\d+)?)\s*\)\s*$/i;
1490
- var rgbaColour = function (red, green, blue, alpha) { return ({
1491
- red: red,
1492
- green: green,
1493
- blue: blue,
1494
- alpha: alpha
1495
- }); };
1496
- var fromStringValues = function (red, green, blue, alpha) {
1497
- var r = parseInt(red, 10);
1498
- var g = parseInt(green, 10);
1499
- var b = parseInt(blue, 10);
1500
- var a = parseFloat(alpha);
1501
- return rgbaColour(r, g, b, a);
1502
- };
1503
- var fromString = function (rgbaString) {
1504
- if (rgbaString === 'transparent') {
1505
- return Optional.some(rgbaColour(0, 0, 0, 0));
1506
- }
1507
- var rgbMatch = rgbRegex.exec(rgbaString);
1508
- if (rgbMatch !== null) {
1509
- return Optional.some(fromStringValues(rgbMatch[1], rgbMatch[2], rgbMatch[3], '1'));
1510
- }
1511
- var rgbaMatch = rgbaRegex.exec(rgbaString);
1512
- if (rgbaMatch !== null) {
1513
- return Optional.some(fromStringValues(rgbaMatch[1], rgbaMatch[2], rgbaMatch[3], rgbaMatch[4]));
1514
- }
1515
- return Optional.none();
1516
- };
1517
- var anyToHex = function (color) { return fromString$1(color).orThunk(function () { return fromString(color).map(fromRgba); }).getOrThunk(function () {
1518
- var canvas = document.createElement('canvas');
1519
- canvas.height = 1;
1520
- canvas.width = 1;
1521
- var canvasContext = canvas.getContext('2d');
1522
- canvasContext.clearRect(0, 0, canvas.width, canvas.height);
1523
- canvasContext.fillStyle = '#FFFFFF';
1524
- canvasContext.fillStyle = color;
1525
- canvasContext.fillRect(0, 0, 1, 1);
1526
- var rgba = canvasContext.getImageData(0, 0, 1, 1).data;
1527
- var r = rgba[0];
1528
- var g = rgba[1];
1529
- var b = rgba[2];
1530
- var a = rgba[3];
1531
- return fromRgba(rgbaColour(r, g, b, a));
1532
- }); };
1533
- var rgbaToHexString = function (color) { return fromString(color).map(fromRgba).map(function (h) { return '#' + h.value; }).getOr(color); };
1534
- var Cell = function (initial) {
1535
- var value = initial;
1536
- var get = function () {
1537
- return value;
1538
- };
1539
- var set = function (v) {
1540
- value = v;
1541
- };
1542
- return {
1543
- get: get,
1544
- set: set
1545
- };
1546
- };
1547
- var singleton = function (doRevoke) {
1548
- var subject = Cell(Optional.none());
1549
- var revoke = function () { return subject.get().each(doRevoke); };
1550
- var clear = function () {
1551
- revoke();
1552
- subject.set(Optional.none());
1553
- };
1554
- var isSet = function () { return subject.get().isSome(); };
1555
- var get = function () { return subject.get(); };
1556
- var set = function (s) {
1557
- revoke();
1558
- subject.set(Optional.some(s));
1559
- };
1560
- return {
1561
- clear: clear,
1562
- isSet: isSet,
1563
- get: get,
1564
- set: set
1565
- };
1566
- };
1567
- var unbindable = function () { return singleton(function (s) { return s.unbind(); }); };
1568
- var onSetupToggle = function (editor, formatName, formatValue) {
1569
- return function (api) {
1570
- var boundCallback = unbindable();
1571
- var isNone = isEmpty(formatValue);
1572
- var init = function () {
1573
- var selectedCells = getCellsFromSelection(editor);
1574
- var checkNode = function (cell) { return editor.formatter.match(formatName, { value: formatValue }, cell.dom, isNone); };
1575
- if (isNone) {
1576
- api.setActive(!exists(selectedCells, checkNode));
1577
- boundCallback.set(editor.formatter.formatChanged(formatName, function (match) { return api.setActive(!match); }, true));
1578
- }
1579
- else {
1580
- api.setActive(forall(selectedCells, checkNode));
1581
- boundCallback.set(editor.formatter.formatChanged(formatName, api.setActive, false, { value: formatValue }));
1582
- }
1583
- };
1584
- editor.initialized ? init() : editor.on('init', init);
1585
- return boundCallback.clear;
1586
- };
1587
- };
1588
- var isListGroup = function (item) { return hasNonNullableKey(item, 'menu'); };
1589
- var buildListItems = function (items) { return map(items, function (item) {
1590
- var text = item.text || item.title || '';
1591
- if (isListGroup(item)) {
1592
- return {
1593
- text: text,
1594
- items: buildListItems(item.menu)
1595
- };
1596
- }
1597
- else {
1598
- return {
1599
- text: text,
1600
- value: item.value
1601
- };
1602
- }
1603
- }); };
1604
- var buildMenuItems = function (editor, items, format, onAction) { return map(items, function (item) {
1605
- var text = item.text || item.title;
1606
- if (isListGroup(item)) {
1607
- return {
1608
- type: 'nestedmenuitem',
1609
- text: text,
1610
- getSubmenuItems: function () { return buildMenuItems(editor, item.menu, format, onAction); }
1611
- };
1612
- }
1613
- else {
1614
- return {
1615
- text: text,
1616
- type: 'togglemenuitem',
1617
- onAction: function () { return onAction(item.value); },
1618
- onSetup: onSetupToggle(editor, format, item.value)
1619
- };
1620
- }
1621
- }); };
1622
- var applyTableCellStyle = function (editor, style) { return function (value) {
1623
- var _b;
1624
- editor.execCommand('mceTableApplyCellStyle', false, (_b = {}, _b[style] = value, _b));
1625
- }; };
1626
- var filterNoneItem = function (list) { return bind(list, function (item) {
1627
- if (isListGroup(item)) {
1628
- return [__assign(__assign({}, item), { menu: filterNoneItem(item.menu) })];
1629
- }
1630
- else {
1631
- return isNotEmpty(item.value) ? [item] : [];
1632
- }
1633
- }); };
1634
- var generateMenuItemsCallback = function (editor, items, format, onAction) { return function (callback) { return callback(buildMenuItems(editor, items, format, onAction)); }; };
1635
- var buildColorMenu = function (editor, colorList, style) {
1636
- var colorMap = map(colorList, function (entry) { return ({
1637
- text: entry.title,
1638
- value: '#' + anyToHex(entry.value).value,
1639
- type: 'choiceitem'
1640
- }); });
1641
- return [{
1642
- type: 'fancymenuitem',
1643
- fancytype: 'colorswatch',
1644
- initData: {
1645
- colors: colorMap.length > 0 ? colorMap : undefined,
1646
- allowCustomColors: false
1647
- },
1648
- onAction: function (data) {
1649
- var _b;
1650
- var value = data.value === 'remove' ? '' : data.value;
1651
- editor.execCommand('mceTableApplyCellStyle', false, (_b = {}, _b[style] = value, _b));
1652
- }
1653
- }];
1654
- };
1655
- var changeRowHeader = function (editor) { return function () {
1656
- var currentType = editor.queryCommandValue('mceTableRowType');
1657
- var newType = currentType === 'header' ? 'body' : 'header';
1658
- editor.execCommand('mceTableRowType', false, { type: newType });
1659
- }; };
1660
- var changeColumnHeader = function (editor) { return function () {
1661
- var currentType = editor.queryCommandValue('mceTableColType');
1662
- var newType = currentType === 'th' ? 'td' : 'th';
1663
- editor.execCommand('mceTableColType', false, { type: newType });
1664
- }; };
1665
- var getClassList$1 = function (editor) {
1666
- var classes = buildListItems(getCellClassList(editor));
1667
- if (classes.length > 0) {
1668
- return Optional.some({
1669
- name: 'class',
1670
- type: 'listbox',
1671
- label: 'Class',
1672
- items: classes
1673
- });
1674
- }
1675
- return Optional.none();
1676
- };
1677
- var children = [
1678
- {
1679
- name: 'width',
1680
- type: 'input',
1681
- label: 'Width'
1682
- },
1683
- {
1684
- name: 'height',
1685
- type: 'input',
1686
- label: 'Height'
1687
- },
1688
- {
1689
- name: 'celltype',
1690
- type: 'listbox',
1691
- label: 'Cell type',
1692
- items: [
1693
- {
1694
- text: 'Cell',
1695
- value: 'td'
1696
- },
1697
- {
1698
- text: 'Header cell',
1699
- value: 'th'
1700
- }
1701
- ]
1702
- },
1703
- {
1704
- name: 'scope',
1705
- type: 'listbox',
1706
- label: 'Scope',
1707
- items: [
1708
- {
1709
- text: 'None',
1710
- value: ''
1711
- },
1712
- {
1713
- text: 'Row',
1714
- value: 'row'
1715
- },
1716
- {
1717
- text: 'Column',
1718
- value: 'col'
1719
- },
1720
- {
1721
- text: 'Row group',
1722
- value: 'rowgroup'
1723
- },
1724
- {
1725
- text: 'Column group',
1726
- value: 'colgroup'
1727
- }
1728
- ]
1729
- },
1730
- {
1731
- name: 'halign',
1732
- type: 'listbox',
1733
- label: 'Horizontal align',
1734
- items: [
1735
- {
1736
- text: 'None',
1737
- value: ''
1738
- },
1739
- {
1740
- text: 'Left',
1741
- value: 'left'
1742
- },
1743
- {
1744
- text: 'Center',
1745
- value: 'center'
1746
- },
1747
- {
1748
- text: 'Right',
1749
- value: 'right'
1750
- }
1751
- ]
1752
- },
1753
- {
1754
- name: 'valign',
1755
- type: 'listbox',
1756
- label: 'Vertical align',
1757
- items: verticalAlignValues
1758
- }
1759
- ];
1760
- var getItems$2 = function (editor) { return children.concat(getClassList$1(editor).toArray()); };
1761
- var getAdvancedTab = function (editor, dialogName) {
1762
- var emptyBorderStyle = [{
1763
- text: 'Select...',
1764
- value: ''
1765
- }];
1766
- var advTabItems = [
1767
- {
1768
- name: 'borderstyle',
1769
- type: 'listbox',
1770
- label: 'Border style',
1771
- items: emptyBorderStyle.concat(buildListItems(getTableBorderStyles(editor)))
1772
- },
1773
- {
1774
- name: 'bordercolor',
1775
- type: 'colorinput',
1776
- label: 'Border color'
1777
- },
1778
- {
1779
- name: 'backgroundcolor',
1780
- type: 'colorinput',
1781
- label: 'Background color'
1782
- }
1783
- ];
1784
- var borderWidth = {
1785
- name: 'borderwidth',
1786
- type: 'input',
1787
- label: 'Border width'
1788
- };
1789
- var items = dialogName === 'cell' ? [borderWidth].concat(advTabItems) : advTabItems;
1790
- return {
1791
- title: 'Advanced',
1792
- name: 'advanced',
1793
- items: items
1794
- };
1795
- };
1796
- var normal = function (editor, element) {
1797
- var dom = editor.dom;
1798
- var setAttrib = function (attr, value) {
1799
- dom.setAttrib(element, attr, value);
1800
- };
1801
- var setStyle = function (prop, value) {
1802
- dom.setStyle(element, prop, value);
1803
- };
1804
- var setFormat = function (formatName, value) {
1805
- if (value === '') {
1806
- editor.formatter.remove(formatName, { value: null }, element, true);
1807
- }
1808
- else {
1809
- editor.formatter.apply(formatName, { value: value }, element);
1810
- }
1811
- };
1812
- return {
1813
- setAttrib: setAttrib,
1814
- setStyle: setStyle,
1815
- setFormat: setFormat
1816
- };
1817
- };
1818
- var DomModifier = { normal: normal };
1819
- var isHeaderCell = isTag('th');
1820
- var getRowHeaderType = function (isHeaderRow, isHeaderCells) {
1821
- if (isHeaderRow && isHeaderCells) {
1822
- return 'sectionCells';
1823
- }
1824
- else if (isHeaderRow) {
1825
- return 'section';
1826
- }
1827
- else {
1828
- return 'cells';
1829
- }
1830
- };
1831
- var getRowType$1 = function (row) {
1832
- var isHeaderRow = row.section === 'thead';
1833
- var isHeaderCells = is(findCommonCellType(row.cells), 'th');
1834
- if (row.section === 'tfoot') {
1835
- return { type: 'footer' };
1836
- }
1837
- else if (isHeaderRow || isHeaderCells) {
1838
- return {
1839
- type: 'header',
1840
- subType: getRowHeaderType(isHeaderRow, isHeaderCells)
1841
- };
1842
- }
1843
- else {
1844
- return { type: 'body' };
1845
- }
1846
- };
1847
- var findCommonCellType = function (cells) {
1848
- var headerCells = filter(cells, function (cell) { return isHeaderCell(cell.element); });
1849
- if (headerCells.length === 0) {
1850
- return Optional.some('td');
1851
- }
1852
- else if (headerCells.length === cells.length) {
1853
- return Optional.some('th');
1854
- }
1855
- else {
1856
- return Optional.none();
1857
- }
1858
- };
1859
- var findCommonRowType = function (rows) {
1860
- var rowTypes = map(rows, function (row) { return getRowType$1(row).type; });
1861
- var hasHeader = contains(rowTypes, 'header');
1862
- var hasFooter = contains(rowTypes, 'footer');
1863
- if (!hasHeader && !hasFooter) {
1864
- return Optional.some('body');
1865
- }
1866
- else {
1867
- var hasBody = contains(rowTypes, 'body');
1868
- if (hasHeader && !hasBody && !hasFooter) {
1869
- return Optional.some('header');
1870
- }
1871
- else if (!hasHeader && !hasBody && hasFooter) {
1872
- return Optional.some('footer');
1873
- }
1874
- else {
1875
- return Optional.none();
1876
- }
1877
- }
1878
- };
1879
- var cached = function (f) {
1880
- var called = false;
1881
- var r;
1882
- return function () {
1883
- var args = [];
1884
- for (var _i = 0; _i < arguments.length; _i++) {
1885
- args[_i] = arguments[_i];
1886
- }
1887
- if (!called) {
1888
- called = true;
1889
- r = f.apply(null, args);
1890
- }
1891
- return r;
1892
- };
1893
- };
1894
- var findInWarehouse = function (warehouse, element) { return findMap(warehouse.all, function (r) { return find(r.cells, function (e) { return eq(element, e.element); }); }); };
1895
- var extractCells = function (warehouse, target, predicate) {
1896
- var details = map(target.selection, function (cell$1) {
1897
- return cell(cell$1).bind(function (lc) { return findInWarehouse(warehouse, lc); }).filter(predicate);
1898
- });
1899
- var cells = cat(details);
1900
- return someIf(cells.length > 0, cells);
1901
- };
1902
- var onMergable = function (_warehouse, target) { return target.mergable; };
1903
- var onUnmergable = function (_warehouse, target) { return target.unmergable; };
1904
- var onCells = function (warehouse, target) { return extractCells(warehouse, target, always); };
1905
- var isUnlockedTableCell = function (warehouse, cell) { return findInWarehouse(warehouse, cell).exists(function (detail) { return !detail.isLocked; }); };
1906
- var allUnlocked = function (warehouse, cells) { return forall(cells, function (cell) { return isUnlockedTableCell(warehouse, cell); }); };
1907
- var onUnlockedMergable = function (warehouse, target) { return onMergable(warehouse, target).filter(function (mergeable) { return allUnlocked(warehouse, mergeable.cells); }); };
1908
- var onUnlockedUnmergable = function (warehouse, target) { return onUnmergable(warehouse, target).filter(function (cells) { return allUnlocked(warehouse, cells); }); };
1909
- var generate = function (cases) {
1910
- if (!isArray(cases)) {
1911
- throw new Error('cases must be an array');
1912
- }
1913
- if (cases.length === 0) {
1914
- throw new Error('there must be at least one case');
1915
- }
1916
- var constructors = [];
1917
- var adt = {};
1918
- each(cases, function (acase, count) {
1919
- var keys$1 = keys(acase);
1920
- if (keys$1.length !== 1) {
1921
- throw new Error('one and only one name per case');
1922
- }
1923
- var key = keys$1[0];
1924
- var value = acase[key];
1925
- if (adt[key] !== undefined) {
1926
- throw new Error('duplicate key detected:' + key);
1927
- }
1928
- else if (key === 'cata') {
1929
- throw new Error('cannot have a case named cata (sorry)');
1930
- }
1931
- else if (!isArray(value)) {
1932
- throw new Error('case arguments must be an array');
1933
- }
1934
- constructors.push(key);
1935
- adt[key] = function () {
1936
- var args = [];
1937
- for (var _i = 0; _i < arguments.length; _i++) {
1938
- args[_i] = arguments[_i];
1939
- }
1940
- var argLength = args.length;
1941
- if (argLength !== value.length) {
1942
- throw new Error('Wrong number of arguments to case ' + key + '. Expected ' + value.length + ' (' + value + '), got ' + argLength);
1943
- }
1944
- var match = function (branches) {
1945
- var branchKeys = keys(branches);
1946
- if (constructors.length !== branchKeys.length) {
1947
- throw new Error('Wrong number of arguments to match. Expected: ' + constructors.join(',') + '\nActual: ' + branchKeys.join(','));
1948
- }
1949
- var allReqd = forall(constructors, function (reqKey) {
1950
- return contains(branchKeys, reqKey);
1951
- });
1952
- if (!allReqd) {
1953
- throw new Error('Not all branches were specified when using match. Specified: ' + branchKeys.join(', ') + '\nRequired: ' + constructors.join(', '));
1954
- }
1955
- return branches[key].apply(null, args);
1956
- };
1957
- return {
1958
- fold: function () {
1959
- var foldArgs = [];
1960
- for (var _i = 0; _i < arguments.length; _i++) {
1961
- foldArgs[_i] = arguments[_i];
1962
- }
1963
- if (foldArgs.length !== cases.length) {
1964
- throw new Error('Wrong number of arguments to fold. Expected ' + cases.length + ', got ' + foldArgs.length);
1965
- }
1966
- var target = foldArgs[count];
1967
- return target.apply(null, args);
1968
- },
1969
- match: match,
1970
- log: function (label) {
1971
- console.log(label, {
1972
- constructors: constructors,
1973
- constructor: key,
1974
- params: args
1975
- });
1976
- }
1977
- };
1978
- };
1979
- });
1980
- return adt;
1981
- };
1982
- var Adt = { generate: generate };
1983
- var adt = Adt.generate([
1984
- { none: [] },
1985
- { only: ['index'] },
1986
- {
1987
- left: [
1988
- 'index',
1989
- 'next'
1990
- ]
1991
- },
1992
- {
1993
- middle: [
1994
- 'prev',
1995
- 'index',
1996
- 'next'
1997
- ]
1998
- },
1999
- {
2000
- right: [
2001
- 'prev',
2002
- 'index'
2003
- ]
2004
- }
2005
- ]);
2006
- (__assign({}, adt));
2007
- var opGetRowsType = function (table, target) {
2008
- var house = Warehouse.fromTable(table);
2009
- var details = onCells(house, target);
2010
- return details.bind(function (selectedCells) {
2011
- var lastSelectedCell = selectedCells[selectedCells.length - 1];
2012
- var minRowRange = selectedCells[0].row;
2013
- var maxRowRange = lastSelectedCell.row + lastSelectedCell.rowspan;
2014
- var selectedRows = house.all.slice(minRowRange, maxRowRange);
2015
- return findCommonRowType(selectedRows);
2016
- }).getOr('');
2017
- };
2018
- var getRowsType = opGetRowsType;
2019
- var rgbToHex = function (value) { return startsWith(value, 'rgb') ? rgbaToHexString(value) : value; };
2020
- var extractAdvancedStyles = function (elm) {
2021
- var element = SugarElement.fromDom(elm);
2022
- return {
2023
- borderwidth: getRaw(element, 'border-width').getOr(''),
2024
- borderstyle: getRaw(element, 'border-style').getOr(''),
2025
- bordercolor: getRaw(element, 'border-color').map(rgbToHex).getOr(''),
2026
- backgroundcolor: getRaw(element, 'background-color').map(rgbToHex).getOr('')
2027
- };
2028
- };
2029
- var getSharedValues = function (data) {
2030
- var baseData = data[0];
2031
- var comparisonData = data.slice(1);
2032
- each(comparisonData, function (items) {
2033
- each(keys(baseData), function (key) {
2034
- each$1(items, function (itemValue, itemKey) {
2035
- var comparisonValue = baseData[key];
2036
- if (comparisonValue !== '' && key === itemKey) {
2037
- if (comparisonValue !== itemValue) {
2038
- baseData[key] = '';
2039
- }
2040
- }
2041
- });
2042
- });
2043
- });
2044
- return baseData;
2045
- };
2046
- var getAlignment = function (formats, formatName, editor, elm) { return find(formats, function (name) { return !isUndefined(editor.formatter.matchNode(elm, formatName + name)); }).getOr(''); };
2047
- var getHAlignment = curry(getAlignment, [
2048
- 'left',
2049
- 'center',
2050
- 'right'
2051
- ], 'align');
2052
- var getVAlignment = curry(getAlignment, [
2053
- 'top',
2054
- 'middle',
2055
- 'bottom'
2056
- ], 'valign');
2057
- var extractDataFromSettings = function (editor, hasAdvTableTab) {
2058
- var style = getDefaultStyles(editor);
2059
- var attrs = getDefaultAttributes(editor);
2060
- var extractAdvancedStyleData = function () { return ({
2061
- borderstyle: get$4(style, 'border-style').getOr(''),
2062
- bordercolor: rgbToHex(get$4(style, 'border-color').getOr('')),
2063
- backgroundcolor: rgbToHex(get$4(style, 'background-color').getOr(''))
2064
- }); };
2065
- var defaultData = {
2066
- height: '',
2067
- width: '100%',
2068
- cellspacing: '',
2069
- cellpadding: '',
2070
- caption: false,
2071
- class: '',
2072
- align: '',
2073
- border: ''
2074
- };
2075
- var getBorder = function () {
2076
- var borderWidth = style['border-width'];
2077
- if (shouldStyleWithCss(editor) && borderWidth) {
2078
- return { border: borderWidth };
2079
- }
2080
- return get$4(attrs, 'border').fold(function () { return ({}); }, function (border) { return ({ border: border }); });
2081
- };
2082
- var advStyle = hasAdvTableTab ? extractAdvancedStyleData() : {};
2083
- var getCellPaddingCellSpacing = function () {
2084
- var spacing = get$4(style, 'border-spacing').or(get$4(attrs, 'cellspacing')).fold(function () { return ({}); }, function (cellspacing) { return ({ cellspacing: cellspacing }); });
2085
- var padding = get$4(style, 'border-padding').or(get$4(attrs, 'cellpadding')).fold(function () { return ({}); }, function (cellpadding) { return ({ cellpadding: cellpadding }); });
2086
- return __assign(__assign({}, spacing), padding);
2087
- };
2088
- var data = __assign(__assign(__assign(__assign(__assign(__assign({}, defaultData), style), attrs), advStyle), getBorder()), getCellPaddingCellSpacing());
2089
- return data;
2090
- };
2091
- var getRowType = function (elm) { return table(SugarElement.fromDom(elm)).map(function (table) {
2092
- var target = { selection: fromDom(elm.cells) };
2093
- return getRowsType(table, target);
2094
- }).getOr(''); };
2095
- var extractDataFromTableElement = function (editor, elm, hasAdvTableTab) {
2096
- var getBorder = function (dom, elm) {
2097
- var optBorderWidth = getRaw(SugarElement.fromDom(elm), 'border-width');
2098
- if (shouldStyleWithCss(editor) && optBorderWidth.isSome()) {
2099
- return optBorderWidth.getOr('');
2100
- }
2101
- return dom.getAttrib(elm, 'border') || getTDTHOverallStyle(editor.dom, elm, 'border-width') || getTDTHOverallStyle(editor.dom, elm, 'border') || '';
2102
- };
2103
- var dom = editor.dom;
2104
- var cellspacing = shouldStyleWithCss(editor) ? dom.getStyle(elm, 'border-spacing') || dom.getAttrib(elm, 'cellspacing') : dom.getAttrib(elm, 'cellspacing') || dom.getStyle(elm, 'border-spacing');
2105
- var cellpadding = shouldStyleWithCss(editor) ? getTDTHOverallStyle(dom, elm, 'padding') || dom.getAttrib(elm, 'cellpadding') : dom.getAttrib(elm, 'cellpadding') || getTDTHOverallStyle(dom, elm, 'padding');
2106
- return __assign({ width: dom.getStyle(elm, 'width') || dom.getAttrib(elm, 'width'), height: dom.getStyle(elm, 'height') || dom.getAttrib(elm, 'height'), cellspacing: cellspacing !== null && cellspacing !== void 0 ? cellspacing : '', cellpadding: cellpadding !== null && cellpadding !== void 0 ? cellpadding : '', border: getBorder(dom, elm), caption: !!dom.select('caption', elm)[0], class: dom.getAttrib(elm, 'class', ''), align: getHAlignment(editor, elm) }, hasAdvTableTab ? extractAdvancedStyles(elm) : {});
2107
- };
2108
- var extractDataFromRowElement = function (editor, elm, hasAdvancedRowTab) {
2109
- var dom = editor.dom;
2110
- return __assign({ height: dom.getStyle(elm, 'height') || dom.getAttrib(elm, 'height'), class: dom.getAttrib(elm, 'class', ''), type: getRowType(elm), align: getHAlignment(editor, elm) }, hasAdvancedRowTab ? extractAdvancedStyles(elm) : {});
2111
- };
2112
- var extractDataFromCellElement = function (editor, cell, hasAdvancedCellTab, column) {
2113
- var dom = editor.dom;
2114
- var colElm = column.getOr(cell);
2115
- var getStyle = function (element, style) { return dom.getStyle(element, style) || dom.getAttrib(element, style); };
2116
- return __assign({ width: getStyle(colElm, 'width'), height: getStyle(cell, 'height'), scope: dom.getAttrib(cell, 'scope'), celltype: getNodeName(cell), class: dom.getAttrib(cell, 'class', ''), halign: getHAlignment(editor, cell), valign: getVAlignment(editor, cell) }, hasAdvancedCellTab ? extractAdvancedStyles(cell) : {});
2117
- };
2118
- var getSelectedCells = function (table, cells) {
2119
- var warehouse = Warehouse.fromTable(table);
2120
- var allCells = Warehouse.justCells(warehouse);
2121
- var filtered = filter(allCells, function (cellA) { return exists(cells, function (cellB) { return eq(cellA.element, cellB); }); });
2122
- return map(filtered, function (cell) { return ({
2123
- element: cell.element.dom,
2124
- column: Warehouse.getColumnAt(warehouse, cell.column).map(function (col) { return col.element.dom; })
2125
- }); });
2126
- };
2127
- var updateSimpleProps$1 = function (modifier, colModifier, data, shouldUpdate) {
2128
- if (shouldUpdate('scope')) {
2129
- modifier.setAttrib('scope', data.scope);
2130
- }
2131
- if (shouldUpdate('class')) {
2132
- modifier.setAttrib('class', data.class);
2133
- }
2134
- if (shouldUpdate('height')) {
2135
- modifier.setStyle('height', addPxSuffix(data.height));
2136
- }
2137
- if (shouldUpdate('width')) {
2138
- colModifier.setStyle('width', addPxSuffix(data.width));
2139
- }
2140
- };
2141
- var updateAdvancedProps$1 = function (modifier, data, shouldUpdate) {
2142
- if (shouldUpdate('backgroundcolor')) {
2143
- modifier.setFormat('tablecellbackgroundcolor', data.backgroundcolor);
2144
- }
2145
- if (shouldUpdate('bordercolor')) {
2146
- modifier.setFormat('tablecellbordercolor', data.bordercolor);
2147
- }
2148
- if (shouldUpdate('borderstyle')) {
2149
- modifier.setFormat('tablecellborderstyle', data.borderstyle);
2150
- }
2151
- if (shouldUpdate('borderwidth')) {
2152
- modifier.setFormat('tablecellborderwidth', addPxSuffix(data.borderwidth));
2153
- }
2154
- };
2155
- var applyStyleData$1 = function (editor, cells, data, wasChanged) {
2156
- var isSingleCell = cells.length === 1;
2157
- each(cells, function (item) {
2158
- var cellElm = item.element;
2159
- var shouldOverrideCurrentValue = isSingleCell ? always : wasChanged;
2160
- var modifier = DomModifier.normal(editor, cellElm);
2161
- var colModifier = item.column.map(function (col) { return DomModifier.normal(editor, col); }).getOr(modifier);
2162
- updateSimpleProps$1(modifier, colModifier, data, shouldOverrideCurrentValue);
2163
- if (hasAdvancedCellTab(editor)) {
2164
- updateAdvancedProps$1(modifier, data, shouldOverrideCurrentValue);
2165
- }
2166
- if (wasChanged('halign')) {
2167
- setAlign(editor, cellElm, data.halign);
2168
- }
2169
- if (wasChanged('valign')) {
2170
- setVAlign(editor, cellElm, data.valign);
2171
- }
2172
- });
2173
- };
2174
- var applyStructureData$1 = function (editor, data) {
2175
- editor.execCommand('mceTableCellType', false, {
2176
- type: data.celltype,
2177
- no_events: true
2178
- });
2179
- };
2180
- var applyCellData = function (editor, cells, oldData, data) {
2181
- var modifiedData = filter$1(data, function (value, key) { return oldData[key] !== value; });
2182
- if (size(modifiedData) > 0 && cells.length >= 1) {
2183
- table(cells[0]).each(function (table) {
2184
- var selectedCells = getSelectedCells(table, cells);
2185
- var styleModified = size(filter$1(modifiedData, function (_value, key) { return key !== 'scope' && key !== 'celltype'; })) > 0;
2186
- var structureModified = has(modifiedData, 'celltype');
2187
- if (styleModified || has(modifiedData, 'scope')) {
2188
- applyStyleData$1(editor, selectedCells, data, curry(has, modifiedData));
2189
- }
2190
- if (structureModified) {
2191
- applyStructureData$1(editor, data);
2192
- }
2193
- fireTableModified(editor, table.dom, {
2194
- structure: structureModified,
2195
- style: styleModified
2196
- });
2197
- });
2198
- }
2199
- };
2200
- var onSubmitCellForm = function (editor, cells, oldData, api) {
2201
- var data = api.getData();
2202
- api.close();
2203
- editor.undoManager.transact(function () {
2204
- applyCellData(editor, cells, oldData, data);
2205
- editor.focus();
2206
- });
2207
- };
2208
- var getData$1 = function (editor, cells) {
2209
- var cellsData = table(cells[0]).map(function (table) { return map(getSelectedCells(table, cells), function (item) { return extractDataFromCellElement(editor, item.element, hasAdvancedCellTab(editor), item.column); }); });
2210
- return getSharedValues(cellsData.getOrDie());
2211
- };
2212
- var open$2 = function (editor) {
2213
- var cells = getCellsFromSelection(editor);
2214
- if (cells.length === 0) {
2215
- return;
2216
- }
2217
- var data = getData$1(editor, cells);
2218
- var dialogTabPanel = {
2219
- type: 'tabpanel',
2220
- tabs: [
2221
- {
2222
- title: 'General',
2223
- name: 'general',
2224
- items: getItems$2(editor)
2225
- },
2226
- getAdvancedTab(editor, 'cell')
2227
- ]
2228
- };
2229
- var dialogPanel = {
2230
- type: 'panel',
2231
- items: [{
2232
- type: 'grid',
2233
- columns: 2,
2234
- items: getItems$2(editor)
2235
- }]
2236
- };
2237
- editor.windowManager.open({
2238
- title: 'Cell Properties',
2239
- size: 'normal',
2240
- body: hasAdvancedCellTab(editor) ? dialogTabPanel : dialogPanel,
2241
- buttons: [
2242
- {
2243
- type: 'cancel',
2244
- name: 'cancel',
2245
- text: 'Cancel'
2246
- },
2247
- {
2248
- type: 'submit',
2249
- name: 'save',
2250
- text: 'Save',
2251
- primary: true
2252
- }
2253
- ],
2254
- initialData: data,
2255
- onSubmit: curry(onSubmitCellForm, editor, cells, data)
2256
- });
2257
- };
2258
- var getClassList = function (editor) {
2259
- var classes = buildListItems(getRowClassList(editor));
2260
- if (classes.length > 0) {
2261
- return Optional.some({
2262
- name: 'class',
2263
- type: 'listbox',
2264
- label: 'Class',
2265
- items: classes
2266
- });
2267
- }
2268
- return Optional.none();
2269
- };
2270
- var formChildren = [
2271
- {
2272
- type: 'listbox',
2273
- name: 'type',
2274
- label: 'Row type',
2275
- items: [
2276
- {
2277
- text: 'Header',
2278
- value: 'header'
2279
- },
2280
- {
2281
- text: 'Body',
2282
- value: 'body'
2283
- },
2284
- {
2285
- text: 'Footer',
2286
- value: 'footer'
2287
- }
2288
- ]
2289
- },
2290
- {
2291
- type: 'listbox',
2292
- name: 'align',
2293
- label: 'Alignment',
2294
- items: [
2295
- {
2296
- text: 'None',
2297
- value: ''
2298
- },
2299
- {
2300
- text: 'Left',
2301
- value: 'left'
2302
- },
2303
- {
2304
- text: 'Center',
2305
- value: 'center'
2306
- },
2307
- {
2308
- text: 'Right',
2309
- value: 'right'
2310
- }
2311
- ]
2312
- },
2313
- {
2314
- label: 'Height',
2315
- name: 'height',
2316
- type: 'input'
2317
- }
2318
- ];
2319
- var getItems$1 = function (editor) { return formChildren.concat(getClassList(editor).toArray()); };
2320
- var updateSimpleProps = function (modifier, data, shouldUpdate) {
2321
- if (shouldUpdate('class')) {
2322
- modifier.setAttrib('class', data.class);
2323
- }
2324
- if (shouldUpdate('height')) {
2325
- modifier.setStyle('height', addPxSuffix(data.height));
2326
- }
2327
- };
2328
- var updateAdvancedProps = function (modifier, data, shouldUpdate) {
2329
- if (shouldUpdate('backgroundcolor')) {
2330
- modifier.setStyle('background-color', data.backgroundcolor);
2331
- }
2332
- if (shouldUpdate('bordercolor')) {
2333
- modifier.setStyle('border-color', data.bordercolor);
2334
- }
2335
- if (shouldUpdate('borderstyle')) {
2336
- modifier.setStyle('border-style', data.borderstyle);
2337
- }
2338
- };
2339
- var applyStyleData = function (editor, rows, data, wasChanged) {
2340
- var isSingleRow = rows.length === 1;
2341
- var shouldOverrideCurrentValue = isSingleRow ? always : wasChanged;
2342
- each(rows, function (rowElm) {
2343
- var modifier = DomModifier.normal(editor, rowElm);
2344
- updateSimpleProps(modifier, data, shouldOverrideCurrentValue);
2345
- if (hasAdvancedRowTab(editor)) {
2346
- updateAdvancedProps(modifier, data, shouldOverrideCurrentValue);
2347
- }
2348
- if (wasChanged('align')) {
2349
- setAlign(editor, rowElm, data.align);
2350
- }
2351
- });
2352
- };
2353
- var applyStructureData = function (editor, data) {
2354
- editor.execCommand('mceTableRowType', false, {
2355
- type: data.type,
2356
- no_events: true
2357
- });
2358
- };
2359
- var applyRowData = function (editor, rows, oldData, data) {
2360
- var modifiedData = filter$1(data, function (value, key) { return oldData[key] !== value; });
2361
- if (size(modifiedData) > 0) {
2362
- var typeModified_1 = has(modifiedData, 'type');
2363
- var styleModified_1 = typeModified_1 ? size(modifiedData) > 1 : true;
2364
- if (styleModified_1) {
2365
- applyStyleData(editor, rows, data, curry(has, modifiedData));
2366
- }
2367
- if (typeModified_1) {
2368
- applyStructureData(editor, data);
2369
- }
2370
- table(SugarElement.fromDom(rows[0])).each(function (table) { return fireTableModified(editor, table.dom, {
2371
- structure: typeModified_1,
2372
- style: styleModified_1
2373
- }); });
2374
- }
2375
- };
2376
- var onSubmitRowForm = function (editor, rows, oldData, api) {
2377
- var data = api.getData();
2378
- api.close();
2379
- editor.undoManager.transact(function () {
2380
- applyRowData(editor, rows, oldData, data);
2381
- editor.focus();
2382
- });
2383
- };
2384
- var open$1 = function (editor) {
2385
- var rows = getRowsFromSelection(getSelectionStart(editor), ephemera.selected);
2386
- if (rows.length === 0) {
2387
- return;
2388
- }
2389
- var rowsData = map(rows, function (rowElm) { return extractDataFromRowElement(editor, rowElm.dom, hasAdvancedRowTab(editor)); });
2390
- var data = getSharedValues(rowsData);
2391
- var dialogTabPanel = {
2392
- type: 'tabpanel',
2393
- tabs: [
2394
- {
2395
- title: 'General',
2396
- name: 'general',
2397
- items: getItems$1(editor)
2398
- },
2399
- getAdvancedTab(editor, 'row')
2400
- ]
2401
- };
2402
- var dialogPanel = {
2403
- type: 'panel',
2404
- items: [{
2405
- type: 'grid',
2406
- columns: 2,
2407
- items: getItems$1(editor)
2408
- }]
2409
- };
2410
- editor.windowManager.open({
2411
- title: 'Row Properties',
2412
- size: 'normal',
2413
- body: hasAdvancedRowTab(editor) ? dialogTabPanel : dialogPanel,
2414
- buttons: [
2415
- {
2416
- type: 'cancel',
2417
- name: 'cancel',
2418
- text: 'Cancel'
2419
- },
2420
- {
2421
- type: 'submit',
2422
- name: 'save',
2423
- text: 'Save',
2424
- primary: true
2425
- }
2426
- ],
2427
- initialData: data,
2428
- onSubmit: curry(onSubmitRowForm, editor, map(rows, function (r) { return r.dom; }), data)
2429
- });
2430
- };
2431
- var getItems = function (editor, classes, insertNewTable) {
2432
- var rowColCountItems = !insertNewTable ? [] : [
2433
- {
2434
- type: 'input',
2435
- name: 'cols',
2436
- label: 'Cols',
2437
- inputMode: 'numeric'
2438
- },
2439
- {
2440
- type: 'input',
2441
- name: 'rows',
2442
- label: 'Rows',
2443
- inputMode: 'numeric'
2444
- }
2445
- ];
2446
- var alwaysItems = [
2447
- {
2448
- type: 'input',
2449
- name: 'width',
2450
- label: 'Width'
2451
- },
2452
- {
2453
- type: 'input',
2454
- name: 'height',
2455
- label: 'Height'
2456
- }
2457
- ];
2458
- var appearanceItems = hasAppearanceOptions(editor) ? [
2459
- {
2460
- type: 'input',
2461
- name: 'cellspacing',
2462
- label: 'Cell spacing',
2463
- inputMode: 'numeric'
2464
- },
2465
- {
2466
- type: 'input',
2467
- name: 'cellpadding',
2468
- label: 'Cell padding',
2469
- inputMode: 'numeric'
2470
- },
2471
- {
2472
- type: 'input',
2473
- name: 'border',
2474
- label: 'Border width'
2475
- },
2476
- {
2477
- type: 'label',
2478
- label: 'Caption',
2479
- items: [{
2480
- type: 'checkbox',
2481
- name: 'caption',
2482
- label: 'Show caption'
2483
- }]
2484
- }
2485
- ] : [];
2486
- var alignmentItem = [{
2487
- type: 'listbox',
2488
- name: 'align',
2489
- label: 'Alignment',
2490
- items: [
2491
- {
2492
- text: 'None',
2493
- value: ''
2494
- },
2495
- {
2496
- text: 'Left',
2497
- value: 'left'
2498
- },
2499
- {
2500
- text: 'Center',
2501
- value: 'center'
2502
- },
2503
- {
2504
- text: 'Right',
2505
- value: 'right'
2506
- }
2507
- ]
2508
- }];
2509
- var classListItem = classes.length > 0 ? [{
2510
- type: 'listbox',
2511
- name: 'class',
2512
- label: 'Class',
2513
- items: classes
2514
- }] : [];
2515
- return rowColCountItems.concat(alwaysItems).concat(appearanceItems).concat(alignmentItem).concat(classListItem);
2516
- };
2517
- var styleTDTH = function (dom, elm, name, value) {
2518
- if (elm.tagName === 'TD' || elm.tagName === 'TH') {
2519
- if (isString(name) && isNonNullable(value)) {
2520
- dom.setStyle(elm, name, value);
2521
- }
2522
- else {
2523
- dom.setStyles(elm, name);
2524
- }
2525
- }
2526
- else {
2527
- if (elm.children) {
2528
- for (var i = 0; i < elm.children.length; i++) {
2529
- styleTDTH(dom, elm.children[i], name, value);
2530
- }
2531
- }
2532
- }
2533
- };
2534
- var applyDataToElement = function (editor, tableElm, data, shouldApplyOnCell) {
2535
- var dom = editor.dom;
2536
- var attrs = {};
2537
- var styles = {};
2538
- var shouldStyleWithCss$1 = shouldStyleWithCss(editor);
2539
- var hasAdvancedTableTab$1 = hasAdvancedTableTab(editor);
2540
- if (!isUndefined(data.class)) {
2541
- attrs.class = data.class;
2542
- }
2543
- styles.height = addPxSuffix(data.height);
2544
- if (shouldStyleWithCss$1) {
2545
- styles.width = addPxSuffix(data.width);
2546
- }
2547
- else if (dom.getAttrib(tableElm, 'width')) {
2548
- attrs.width = removePxSuffix(data.width);
2549
- }
2550
- if (shouldStyleWithCss$1) {
2551
- styles['border-width'] = addPxSuffix(data.border);
2552
- styles['border-spacing'] = addPxSuffix(data.cellspacing);
2553
- }
2554
- else {
2555
- attrs.border = data.border;
2556
- attrs.cellpadding = data.cellpadding;
2557
- attrs.cellspacing = data.cellspacing;
2558
- }
2559
- if (shouldStyleWithCss$1 && tableElm.children) {
2560
- var cellStyles = {};
2561
- if (shouldApplyOnCell.border) {
2562
- cellStyles['border-width'] = addPxSuffix(data.border);
2563
- }
2564
- if (shouldApplyOnCell.cellpadding) {
2565
- cellStyles.padding = addPxSuffix(data.cellpadding);
2566
- }
2567
- if (hasAdvancedTableTab$1 && shouldApplyOnCell.bordercolor) {
2568
- cellStyles['border-color'] = data.bordercolor;
2569
- }
2570
- if (!isEmpty$1(cellStyles)) {
2571
- for (var i = 0; i < tableElm.children.length; i++) {
2572
- styleTDTH(dom, tableElm.children[i], cellStyles);
2573
- }
2574
- }
2575
- }
2576
- if (hasAdvancedTableTab$1) {
2577
- var advData = data;
2578
- styles['background-color'] = advData.backgroundcolor;
2579
- styles['border-color'] = advData.bordercolor;
2580
- styles['border-style'] = advData.borderstyle;
2581
- }
2582
- dom.setStyles(tableElm, __assign(__assign({}, getDefaultStyles(editor)), styles));
2583
- dom.setAttribs(tableElm, __assign(__assign({}, getDefaultAttributes(editor)), attrs));
2584
- };
2585
- var onSubmitTableForm = function (editor, tableElm, oldData, api) {
2586
- var dom = editor.dom;
2587
- var data = api.getData();
2588
- var modifiedData = filter$1(data, function (value, key) { return oldData[key] !== value; });
2589
- api.close();
2590
- if (data.class === '') {
2591
- delete data.class;
2592
- }
2593
- editor.undoManager.transact(function () {
2594
- if (!tableElm) {
2595
- var cols = toInt(data.cols).getOr(1);
2596
- var rows_1 = toInt(data.rows).getOr(1);
2597
- editor.execCommand('mceInsertTable', false, {
2598
- rows: rows_1,
2599
- columns: cols
2600
- });
2601
- tableElm = getSelectionCell(getSelectionStart(editor), getIsRoot(editor)).bind(function (cell) { return table(cell, getIsRoot(editor)); }).map(function (table) { return table.dom; }).getOrDie();
2602
- }
2603
- if (size(modifiedData) > 0) {
2604
- var applicableCellProperties = {
2605
- border: has(modifiedData, 'border'),
2606
- bordercolor: has(modifiedData, 'bordercolor'),
2607
- cellpadding: has(modifiedData, 'cellpadding')
2608
- };
2609
- applyDataToElement(editor, tableElm, data, applicableCellProperties);
2610
- var captionElm = dom.select('caption', tableElm)[0];
2611
- if (captionElm && !data.caption || !captionElm && data.caption) {
2612
- editor.execCommand('mceTableToggleCaption');
2613
- }
2614
- setAlign(editor, tableElm, data.align);
2615
- }
2616
- editor.focus();
2617
- editor.addVisual();
2618
- if (size(modifiedData) > 0) {
2619
- var captionModified = has(modifiedData, 'caption');
2620
- var styleModified = captionModified ? size(modifiedData) > 1 : true;
2621
- fireTableModified(editor, tableElm, {
2622
- structure: captionModified,
2623
- style: styleModified
2624
- });
2625
- }
2626
- });
2627
- };
2628
- var open = function (editor, insertNewTable) {
2629
- var dom = editor.dom;
2630
- var tableElm;
2631
- var data = extractDataFromSettings(editor, hasAdvancedTableTab(editor));
2632
- if (insertNewTable) {
2633
- data.cols = '1';
2634
- data.rows = '1';
2635
- if (hasAdvancedTableTab(editor)) {
2636
- data.borderstyle = '';
2637
- data.bordercolor = '';
2638
- data.backgroundcolor = '';
2639
- }
2640
- }
2641
- else {
2642
- tableElm = dom.getParent(editor.selection.getStart(), 'table', editor.getBody());
2643
- if (tableElm) {
2644
- data = extractDataFromTableElement(editor, tableElm, hasAdvancedTableTab(editor));
2645
- }
2646
- else {
2647
- if (hasAdvancedTableTab(editor)) {
2648
- data.borderstyle = '';
2649
- data.bordercolor = '';
2650
- data.backgroundcolor = '';
2651
- }
2652
- }
2653
- }
2654
- var classes = buildListItems(getTableClassList(editor));
2655
- if (classes.length > 0) {
2656
- if (data.class) {
2657
- data.class = data.class.replace(/\s*mce\-item\-table\s*/g, '');
2658
- }
2659
- }
2660
- var generalPanel = {
2661
- type: 'grid',
2662
- columns: 2,
2663
- items: getItems(editor, classes, insertNewTable)
2664
- };
2665
- var nonAdvancedForm = function () { return ({
2666
- type: 'panel',
2667
- items: [generalPanel]
2668
- }); };
2669
- var advancedForm = function () { return ({
2670
- type: 'tabpanel',
2671
- tabs: [
2672
- {
2673
- title: 'General',
2674
- name: 'general',
2675
- items: [generalPanel]
2676
- },
2677
- getAdvancedTab(editor, 'table')
2678
- ]
2679
- }); };
2680
- var dialogBody = hasAdvancedTableTab(editor) ? advancedForm() : nonAdvancedForm();
2681
- editor.windowManager.open({
2682
- title: 'Table Properties',
2683
- size: 'normal',
2684
- body: dialogBody,
2685
- onSubmit: curry(onSubmitTableForm, editor, tableElm, data),
2686
- buttons: [
2687
- {
2688
- type: 'cancel',
2689
- name: 'cancel',
2690
- text: 'Cancel'
2691
- },
2692
- {
2693
- type: 'submit',
2694
- name: 'save',
2695
- text: 'Save',
2696
- primary: true
2697
- }
2698
- ],
2699
- initialData: data
2700
- });
2701
- };
2702
- var registerCommands = function (editor) {
2703
- var runAction = function (f) {
2704
- if (isInEditableContext(getSelectionStart(editor))) {
2705
- f();
2706
- }
2707
- };
2708
- each$1({
2709
- mceTableProps: curry(open, editor, false),
2710
- mceTableRowProps: curry(open$1, editor),
2711
- mceTableCellProps: curry(open$2, editor),
2712
- mceInsertTableDialog: curry(open, editor, true)
2713
- }, function (func, name) { return editor.addCommand(name, function () { return runAction(func); }); });
2714
- };
2715
- var child = function (scope, selector) { return child$1(scope, selector).isSome(); };
2716
- var selection = identity;
2717
- var unmergable = function (selectedCells) {
2718
- var hasSpan = function (elem, type) { return getOpt(elem, type).exists(function (span) { return parseInt(span, 10) > 1; }); };
2719
- var hasRowOrColSpan = function (elem) { return hasSpan(elem, 'rowspan') || hasSpan(elem, 'colspan'); };
2720
- return selectedCells.length > 0 && forall(selectedCells, hasRowOrColSpan) ? Optional.some(selectedCells) : Optional.none();
2721
- };
2722
- var mergable = function (table, selectedCells, ephemera) {
2723
- if (selectedCells.length <= 1) {
2724
- return Optional.none();
2725
- }
2726
- else {
2727
- return retrieveBox(table, ephemera.firstSelectedSelector, ephemera.lastSelectedSelector).map(function (bounds) { return ({
2728
- bounds: bounds,
2729
- cells: selectedCells
2730
- }); });
2731
- }
2732
- };
2733
- var noMenu = function (cell) { return ({
2734
- element: cell,
2735
- mergable: Optional.none(),
2736
- unmergable: Optional.none(),
2737
- selection: [cell]
2738
- }); };
2739
- var forMenu = function (selectedCells, table, cell) { return ({
2740
- element: cell,
2741
- mergable: mergable(table, selectedCells, ephemera),
2742
- unmergable: unmergable(selectedCells),
2743
- selection: selection(selectedCells)
2744
- }); };
2745
- var getSelectionTargets = function (editor) {
2746
- var targets = Cell(Optional.none());
2747
- var changeHandlers = Cell([]);
2748
- var selectionDetails = Optional.none();
2749
- var isCaption = isTag('caption');
2750
- var isDisabledForSelection = function (key) { return selectionDetails.forall(function (details) { return !details[key]; }); };
2751
- var getStart = function () { return getSelectionCellOrCaption(getSelectionStart(editor), getIsRoot(editor)); };
2752
- var getEnd = function () { return getSelectionCellOrCaption(getSelectionEnd(editor), getIsRoot(editor)); };
2753
- var findTargets = function () { return getStart().bind(function (startCellOrCaption) { return flatten(lift2(table(startCellOrCaption), getEnd().bind(table), function (startTable, endTable) {
2754
- if (eq(startTable, endTable)) {
2755
- if (isCaption(startCellOrCaption)) {
2756
- return Optional.some(noMenu(startCellOrCaption));
2757
- }
2758
- else {
2759
- return Optional.some(forMenu(getCellsFromSelection(editor), startTable, startCellOrCaption));
2760
- }
2761
- }
2762
- return Optional.none();
2763
- })); }); };
2764
- var getExtractedDetails = function (targets) {
2765
- var tableOpt = table(targets.element);
2766
- return tableOpt.map(function (table) {
2767
- var warehouse = Warehouse.fromTable(table);
2768
- var selectedCells = onCells(warehouse, targets).getOr([]);
2769
- var locked = foldl(selectedCells, function (acc, cell) {
2770
- if (cell.isLocked) {
2771
- acc.onAny = true;
2772
- if (cell.column === 0) {
2773
- acc.onFirst = true;
2774
- }
2775
- else if (cell.column + cell.colspan >= warehouse.grid.columns) {
2776
- acc.onLast = true;
2777
- }
2778
- }
2779
- return acc;
2780
- }, {
2781
- onAny: false,
2782
- onFirst: false,
2783
- onLast: false
2784
- });
2785
- return {
2786
- mergeable: onUnlockedMergable(warehouse, targets).isSome(),
2787
- unmergeable: onUnlockedUnmergable(warehouse, targets).isSome(),
2788
- locked: locked
2789
- };
2790
- });
2791
- };
2792
- var resetTargets = function () {
2793
- targets.set(cached(findTargets)());
2794
- selectionDetails = targets.get().bind(getExtractedDetails);
2795
- each(changeHandlers.get(), call);
2796
- };
2797
- var setupHandler = function (handler) {
2798
- handler();
2799
- changeHandlers.set(changeHandlers.get().concat([handler]));
2800
- return function () {
2801
- changeHandlers.set(filter(changeHandlers.get(), function (h) { return h !== handler; }));
2802
- };
2803
- };
2804
- var onSetup = function (api, isDisabled) { return setupHandler(function () { return targets.get().fold(function () {
2805
- api.setEnabled(false);
2806
- }, function (targets) {
2807
- api.setEnabled(!isDisabled(targets) && editor.selection.isEditable());
2808
- }); }); };
2809
- var onSetupWithToggle = function (api, isDisabled, isActive) { return setupHandler(function () { return targets.get().fold(function () {
2810
- api.setEnabled(false);
2811
- api.setActive(false);
2812
- }, function (targets) {
2813
- api.setEnabled(!isDisabled(targets) && editor.selection.isEditable());
2814
- api.setActive(isActive(targets));
2815
- }); }); };
2816
- var isDisabledFromLocked = function (lockedDisable) { return selectionDetails.exists(function (details) { return details.locked[lockedDisable]; }); };
2817
- var onSetupTable = function (api) { return onSetup(api, function (_) { return false; }); };
2818
- var onSetupCellOrRow = function (api) { return onSetup(api, function (targets) { return isCaption(targets.element); }); };
2819
- var onSetupColumn = function (lockedDisable) { return function (api) { return onSetup(api, function (targets) { return isCaption(targets.element) || isDisabledFromLocked(lockedDisable); }); }; };
2820
- var onSetupPasteable = function (getClipboardData) { return function (api) { return onSetup(api, function (targets) { return isCaption(targets.element) || getClipboardData().isNone(); }); }; };
2821
- var onSetupPasteableColumn = function (getClipboardData, lockedDisable) { return function (api) { return onSetup(api, function (targets) { return isCaption(targets.element) || getClipboardData().isNone() || isDisabledFromLocked(lockedDisable); }); }; };
2822
- var onSetupMergeable = function (api) { return onSetup(api, function (_targets) { return isDisabledForSelection('mergeable'); }); };
2823
- var onSetupUnmergeable = function (api) { return onSetup(api, function (_targets) { return isDisabledForSelection('unmergeable'); }); };
2824
- var onSetupTableWithCaption = function (api) {
2825
- return onSetupWithToggle(api, never, function (targets) {
2826
- var tableOpt = table(targets.element, getIsRoot(editor));
2827
- return tableOpt.exists(function (table) { return child(table, 'caption'); });
2828
- });
2829
- };
2830
- var onSetupTableHeaders = function (command, headerType) { return function (api) {
2831
- return onSetupWithToggle(api, function (targets) { return isCaption(targets.element); }, function () { return editor.queryCommandValue(command) === headerType; });
2832
- }; };
2833
- var onSetupTableRowHeaders = onSetupTableHeaders('mceTableRowType', 'header');
2834
- var onSetupTableColumnHeaders = onSetupTableHeaders('mceTableColType', 'th');
2835
- editor.on('NodeChange ExecCommand TableSelectorChange', resetTargets);
2836
- return {
2837
- onSetupTable: onSetupTable,
2838
- onSetupCellOrRow: onSetupCellOrRow,
2839
- onSetupColumn: onSetupColumn,
2840
- onSetupPasteable: onSetupPasteable,
2841
- onSetupPasteableColumn: onSetupPasteableColumn,
2842
- onSetupMergeable: onSetupMergeable,
2843
- onSetupUnmergeable: onSetupUnmergeable,
2844
- resetTargets: resetTargets,
2845
- onSetupTableWithCaption: onSetupTableWithCaption,
2846
- onSetupTableRowHeaders: onSetupTableRowHeaders,
2847
- onSetupTableColumnHeaders: onSetupTableColumnHeaders,
2848
- targets: targets.get
2849
- };
2850
- };
2851
- var global = tinymce.util.Tools.resolve('tinymce.FakeClipboard');
2852
- var tableTypeBase = 'x-tinymce/dom-table-';
2853
- var tableTypeRow = tableTypeBase + 'rows';
2854
- var tableTypeColumn = tableTypeBase + 'columns';
2855
- var getData = function (type) {
2856
- var _a;
2857
- var items = (_a = global.read()) !== null && _a !== void 0 ? _a : [];
2858
- return findMap(items, function (item) { return Optional.from(item.getType(type)); });
2859
- };
2860
- var getRows = function () { return getData(tableTypeRow); };
2861
- var getColumns = function () { return getData(tableTypeColumn); };
2862
- var onSetupEditable$1 = function (editor) { return function (api) {
2863
- var nodeChanged = function () {
2864
- api.setEnabled(editor.selection.isEditable());
2865
- };
2866
- editor.on('NodeChange', nodeChanged);
2867
- nodeChanged();
2868
- return function () {
2869
- editor.off('NodeChange', nodeChanged);
2870
- };
2871
- }; };
2872
- var addButtons = function (editor, selectionTargets) {
2873
- editor.ui.registry.addMenuButton('table', {
2874
- tooltip: 'Table',
2875
- icon: 'table',
2876
- onSetup: onSetupEditable$1(editor),
2877
- fetch: function (callback) { return callback('inserttable | cell row column | advtablesort | tableprops deletetable'); }
2878
- });
2879
- var cmd = function (command) { return function () { return editor.execCommand(command); }; };
2880
- var addButtonIfRegistered = function (name, spec) {
2881
- if (editor.queryCommandSupported(spec.command)) {
2882
- editor.ui.registry.addButton(name, __assign(__assign({}, spec), { onAction: isFunction(spec.onAction) ? spec.onAction : cmd(spec.command) }));
2883
- }
2884
- };
2885
- var addToggleButtonIfRegistered = function (name, spec) {
2886
- if (editor.queryCommandSupported(spec.command)) {
2887
- editor.ui.registry.addToggleButton(name, __assign(__assign({}, spec), { onAction: isFunction(spec.onAction) ? spec.onAction : cmd(spec.command) }));
2888
- }
2889
- };
2890
- addButtonIfRegistered('tableprops', {
2891
- tooltip: 'Table properties',
2892
- command: 'mceTableProps',
2893
- icon: 'table',
2894
- onSetup: selectionTargets.onSetupTable
2895
- });
2896
- addButtonIfRegistered('tabledelete', {
2897
- tooltip: 'Delete table',
2898
- command: 'mceTableDelete',
2899
- icon: 'table-delete-table',
2900
- onSetup: selectionTargets.onSetupTable
2901
- });
2902
- addButtonIfRegistered('tablecellprops', {
2903
- tooltip: 'Cell properties',
2904
- command: 'mceTableCellProps',
2905
- icon: 'table-cell-properties',
2906
- onSetup: selectionTargets.onSetupCellOrRow
2907
- });
2908
- addButtonIfRegistered('tablemergecells', {
2909
- tooltip: 'Merge cells',
2910
- command: 'mceTableMergeCells',
2911
- icon: 'table-merge-cells',
2912
- onSetup: selectionTargets.onSetupMergeable
2913
- });
2914
- addButtonIfRegistered('tablesplitcells', {
2915
- tooltip: 'Split cell',
2916
- command: 'mceTableSplitCells',
2917
- icon: 'table-split-cells',
2918
- onSetup: selectionTargets.onSetupUnmergeable
2919
- });
2920
- addButtonIfRegistered('tableinsertrowbefore', {
2921
- tooltip: 'Insert row before',
2922
- command: 'mceTableInsertRowBefore',
2923
- icon: 'table-insert-row-above',
2924
- onSetup: selectionTargets.onSetupCellOrRow
2925
- });
2926
- addButtonIfRegistered('tableinsertrowafter', {
2927
- tooltip: 'Insert row after',
2928
- command: 'mceTableInsertRowAfter',
2929
- icon: 'table-insert-row-after',
2930
- onSetup: selectionTargets.onSetupCellOrRow
2931
- });
2932
- addButtonIfRegistered('tabledeleterow', {
2933
- tooltip: 'Delete row',
2934
- command: 'mceTableDeleteRow',
2935
- icon: 'table-delete-row',
2936
- onSetup: selectionTargets.onSetupCellOrRow
2937
- });
2938
- addButtonIfRegistered('tablerowprops', {
2939
- tooltip: 'Row properties',
2940
- command: 'mceTableRowProps',
2941
- icon: 'table-row-properties',
2942
- onSetup: selectionTargets.onSetupCellOrRow
2943
- });
2944
- addButtonIfRegistered('tableinsertcolbefore', {
2945
- tooltip: 'Insert column before',
2946
- command: 'mceTableInsertColBefore',
2947
- icon: 'table-insert-column-before',
2948
- onSetup: selectionTargets.onSetupColumn('onFirst')
2949
- });
2950
- addButtonIfRegistered('tableinsertcolafter', {
2951
- tooltip: 'Insert column after',
2952
- command: 'mceTableInsertColAfter',
2953
- icon: 'table-insert-column-after',
2954
- onSetup: selectionTargets.onSetupColumn('onLast')
2955
- });
2956
- addButtonIfRegistered('tabledeletecol', {
2957
- tooltip: 'Delete column',
2958
- command: 'mceTableDeleteCol',
2959
- icon: 'table-delete-column',
2960
- onSetup: selectionTargets.onSetupColumn('onAny')
2961
- });
2962
- addButtonIfRegistered('tablecutrow', {
2963
- tooltip: 'Cut row',
2964
- command: 'mceTableCutRow',
2965
- icon: 'cut-row',
2966
- onSetup: selectionTargets.onSetupCellOrRow
2967
- });
2968
- addButtonIfRegistered('tablecopyrow', {
2969
- tooltip: 'Copy row',
2970
- command: 'mceTableCopyRow',
2971
- icon: 'duplicate-row',
2972
- onSetup: selectionTargets.onSetupCellOrRow
2973
- });
2974
- addButtonIfRegistered('tablepasterowbefore', {
2975
- tooltip: 'Paste row before',
2976
- command: 'mceTablePasteRowBefore',
2977
- icon: 'paste-row-before',
2978
- onSetup: selectionTargets.onSetupPasteable(getRows)
2979
- });
2980
- addButtonIfRegistered('tablepasterowafter', {
2981
- tooltip: 'Paste row after',
2982
- command: 'mceTablePasteRowAfter',
2983
- icon: 'paste-row-after',
2984
- onSetup: selectionTargets.onSetupPasteable(getRows)
2985
- });
2986
- addButtonIfRegistered('tablecutcol', {
2987
- tooltip: 'Cut column',
2988
- command: 'mceTableCutCol',
2989
- icon: 'cut-column',
2990
- onSetup: selectionTargets.onSetupColumn('onAny')
2991
- });
2992
- addButtonIfRegistered('tablecopycol', {
2993
- tooltip: 'Copy column',
2994
- command: 'mceTableCopyCol',
2995
- icon: 'duplicate-column',
2996
- onSetup: selectionTargets.onSetupColumn('onAny')
2997
- });
2998
- addButtonIfRegistered('tablepastecolbefore', {
2999
- tooltip: 'Paste column before',
3000
- command: 'mceTablePasteColBefore',
3001
- icon: 'paste-column-before',
3002
- onSetup: selectionTargets.onSetupPasteableColumn(getColumns, 'onFirst')
3003
- });
3004
- addButtonIfRegistered('tablepastecolafter', {
3005
- tooltip: 'Paste column after',
3006
- command: 'mceTablePasteColAfter',
3007
- icon: 'paste-column-after',
3008
- onSetup: selectionTargets.onSetupPasteableColumn(getColumns, 'onLast')
3009
- });
3010
- addButtonIfRegistered('tableinsertdialog', {
3011
- tooltip: 'Insert table',
3012
- command: 'mceInsertTableDialog',
3013
- icon: 'table',
3014
- onSetup: onSetupEditable$1(editor)
3015
- });
3016
- var tableClassList = filterNoneItem(getTableClassList(editor));
3017
- if (tableClassList.length !== 0 && editor.queryCommandSupported('mceTableToggleClass')) {
3018
- editor.ui.registry.addMenuButton('tableclass', {
3019
- icon: 'table-classes',
3020
- tooltip: 'Table styles',
3021
- fetch: generateMenuItemsCallback(editor, tableClassList, 'tableclass', function (value) { return editor.execCommand('mceTableToggleClass', false, value); }),
3022
- onSetup: selectionTargets.onSetupTable
3023
- });
3024
- }
3025
- var tableCellClassList = filterNoneItem(getCellClassList(editor));
3026
- if (tableCellClassList.length !== 0 && editor.queryCommandSupported('mceTableCellToggleClass')) {
3027
- editor.ui.registry.addMenuButton('tablecellclass', {
3028
- icon: 'table-cell-classes',
3029
- tooltip: 'Cell styles',
3030
- fetch: generateMenuItemsCallback(editor, tableCellClassList, 'tablecellclass', function (value) { return editor.execCommand('mceTableCellToggleClass', false, value); }),
3031
- onSetup: selectionTargets.onSetupCellOrRow
3032
- });
3033
- }
3034
- if (editor.queryCommandSupported('mceTableApplyCellStyle')) {
3035
- editor.ui.registry.addMenuButton('tablecellvalign', {
3036
- icon: 'vertical-align',
3037
- tooltip: 'Vertical align',
3038
- fetch: generateMenuItemsCallback(editor, verticalAlignValues, 'tablecellverticalalign', applyTableCellStyle(editor, 'vertical-align')),
3039
- onSetup: selectionTargets.onSetupCellOrRow
3040
- });
3041
- editor.ui.registry.addMenuButton('tablecellborderwidth', {
3042
- icon: 'border-width',
3043
- tooltip: 'Border width',
3044
- fetch: generateMenuItemsCallback(editor, getTableBorderWidths(editor), 'tablecellborderwidth', applyTableCellStyle(editor, 'border-width')),
3045
- onSetup: selectionTargets.onSetupCellOrRow
3046
- });
3047
- editor.ui.registry.addMenuButton('tablecellborderstyle', {
3048
- icon: 'border-style',
3049
- tooltip: 'Border style',
3050
- fetch: generateMenuItemsCallback(editor, getTableBorderStyles(editor), 'tablecellborderstyle', applyTableCellStyle(editor, 'border-style')),
3051
- onSetup: selectionTargets.onSetupCellOrRow
3052
- });
3053
- editor.ui.registry.addMenuButton('tablecellbackgroundcolor', {
3054
- icon: 'cell-background-color',
3055
- tooltip: 'Background color',
3056
- fetch: function (callback) { return callback(buildColorMenu(editor, getTableBackgroundColorMap(editor), 'background-color')); },
3057
- onSetup: selectionTargets.onSetupCellOrRow
3058
- });
3059
- editor.ui.registry.addMenuButton('tablecellbordercolor', {
3060
- icon: 'cell-border-color',
3061
- tooltip: 'Border color',
3062
- fetch: function (callback) { return callback(buildColorMenu(editor, getTableBorderColorMap(editor), 'border-color')); },
3063
- onSetup: selectionTargets.onSetupCellOrRow
3064
- });
3065
- }
3066
- addToggleButtonIfRegistered('tablecaption', {
3067
- tooltip: 'Table caption',
3068
- icon: 'table-caption',
3069
- command: 'mceTableToggleCaption',
3070
- onSetup: selectionTargets.onSetupTableWithCaption
3071
- });
3072
- addToggleButtonIfRegistered('tablerowheader', {
3073
- tooltip: 'Row header',
3074
- icon: 'table-top-header',
3075
- command: 'mceTableRowType',
3076
- onAction: changeRowHeader(editor),
3077
- onSetup: selectionTargets.onSetupTableRowHeaders
3078
- });
3079
- addToggleButtonIfRegistered('tablecolheader', {
3080
- tooltip: 'Column header',
3081
- icon: 'table-left-header',
3082
- command: 'mceTableColType',
3083
- onAction: changeColumnHeader(editor),
3084
- onSetup: selectionTargets.onSetupTableColumnHeaders
3085
- });
3086
- };
3087
- var addToolbars = function (editor) {
3088
- var isEditableTable = function (table) { return editor.dom.is(table, 'table') && editor.getBody().contains(table) && editor.dom.isEditable(table.parentNode); };
3089
- var toolbar = getToolbar(editor);
3090
- if (toolbar.length > 0) {
3091
- editor.ui.registry.addContextToolbar('table', {
3092
- predicate: isEditableTable,
3093
- items: toolbar,
3094
- scope: 'node',
3095
- position: 'node'
3096
- });
3097
- }
3098
- };
3099
- var onSetupEditable = function (editor) { return function (api) {
3100
- var nodeChanged = function () {
3101
- api.setEnabled(editor.selection.isEditable());
3102
- };
3103
- editor.on('NodeChange', nodeChanged);
3104
- nodeChanged();
3105
- return function () {
3106
- editor.off('NodeChange', nodeChanged);
3107
- };
3108
- }; };
3109
- var addMenuItems = function (editor, selectionTargets) {
3110
- var cmd = function (command) { return function () { return editor.execCommand(command); }; };
3111
- var addMenuIfRegistered = function (name, spec) {
3112
- if (editor.queryCommandSupported(spec.command)) {
3113
- editor.ui.registry.addMenuItem(name, __assign(__assign({}, spec), { onAction: isFunction(spec.onAction) ? spec.onAction : cmd(spec.command) }));
3114
- return true;
3115
- }
3116
- else {
3117
- return false;
3118
- }
3119
- };
3120
- var addToggleMenuIfRegistered = function (name, spec) {
3121
- if (editor.queryCommandSupported(spec.command)) {
3122
- editor.ui.registry.addToggleMenuItem(name, __assign(__assign({}, spec), { onAction: isFunction(spec.onAction) ? spec.onAction : cmd(spec.command) }));
3123
- }
3124
- };
3125
- var insertTableAction = function (data) {
3126
- editor.execCommand('mceInsertTable', false, {
3127
- rows: data.numRows,
3128
- columns: data.numColumns
3129
- });
3130
- };
3131
- var hasRowMenuItems = [
3132
- addMenuIfRegistered('tableinsertrowbefore', {
3133
- text: 'Insert row before',
3134
- icon: 'table-insert-row-above',
3135
- command: 'mceTableInsertRowBefore',
3136
- onSetup: selectionTargets.onSetupCellOrRow
3137
- }),
3138
- addMenuIfRegistered('tableinsertrowafter', {
3139
- text: 'Insert row after',
3140
- icon: 'table-insert-row-after',
3141
- command: 'mceTableInsertRowAfter',
3142
- onSetup: selectionTargets.onSetupCellOrRow
3143
- }),
3144
- addMenuIfRegistered('tabledeleterow', {
3145
- text: 'Delete row',
3146
- icon: 'table-delete-row',
3147
- command: 'mceTableDeleteRow',
3148
- onSetup: selectionTargets.onSetupCellOrRow
3149
- }),
3150
- addMenuIfRegistered('tablerowprops', {
3151
- text: 'Row properties',
3152
- icon: 'table-row-properties',
3153
- command: 'mceTableRowProps',
3154
- onSetup: selectionTargets.onSetupCellOrRow
3155
- }),
3156
- addMenuIfRegistered('tablecutrow', {
3157
- text: 'Cut row',
3158
- icon: 'cut-row',
3159
- command: 'mceTableCutRow',
3160
- onSetup: selectionTargets.onSetupCellOrRow
3161
- }),
3162
- addMenuIfRegistered('tablecopyrow', {
3163
- text: 'Copy row',
3164
- icon: 'duplicate-row',
3165
- command: 'mceTableCopyRow',
3166
- onSetup: selectionTargets.onSetupCellOrRow
3167
- }),
3168
- addMenuIfRegistered('tablepasterowbefore', {
3169
- text: 'Paste row before',
3170
- icon: 'paste-row-before',
3171
- command: 'mceTablePasteRowBefore',
3172
- onSetup: selectionTargets.onSetupPasteable(getRows)
3173
- }),
3174
- addMenuIfRegistered('tablepasterowafter', {
3175
- text: 'Paste row after',
3176
- icon: 'paste-row-after',
3177
- command: 'mceTablePasteRowAfter',
3178
- onSetup: selectionTargets.onSetupPasteable(getRows)
3179
- })
3180
- ];
3181
- var hasColumnMenuItems = [
3182
- addMenuIfRegistered('tableinsertcolumnbefore', {
3183
- text: 'Insert column before',
3184
- icon: 'table-insert-column-before',
3185
- command: 'mceTableInsertColBefore',
3186
- onSetup: selectionTargets.onSetupColumn('onFirst')
3187
- }),
3188
- addMenuIfRegistered('tableinsertcolumnafter', {
3189
- text: 'Insert column after',
3190
- icon: 'table-insert-column-after',
3191
- command: 'mceTableInsertColAfter',
3192
- onSetup: selectionTargets.onSetupColumn('onLast')
3193
- }),
3194
- addMenuIfRegistered('tabledeletecolumn', {
3195
- text: 'Delete column',
3196
- icon: 'table-delete-column',
3197
- command: 'mceTableDeleteCol',
3198
- onSetup: selectionTargets.onSetupColumn('onAny')
3199
- }),
3200
- addMenuIfRegistered('tablecutcolumn', {
3201
- text: 'Cut column',
3202
- icon: 'cut-column',
3203
- command: 'mceTableCutCol',
3204
- onSetup: selectionTargets.onSetupColumn('onAny')
3205
- }),
3206
- addMenuIfRegistered('tablecopycolumn', {
3207
- text: 'Copy column',
3208
- icon: 'duplicate-column',
3209
- command: 'mceTableCopyCol',
3210
- onSetup: selectionTargets.onSetupColumn('onAny')
3211
- }),
3212
- addMenuIfRegistered('tablepastecolumnbefore', {
3213
- text: 'Paste column before',
3214
- icon: 'paste-column-before',
3215
- command: 'mceTablePasteColBefore',
3216
- onSetup: selectionTargets.onSetupPasteableColumn(getColumns, 'onFirst')
3217
- }),
3218
- addMenuIfRegistered('tablepastecolumnafter', {
3219
- text: 'Paste column after',
3220
- icon: 'paste-column-after',
3221
- command: 'mceTablePasteColAfter',
3222
- onSetup: selectionTargets.onSetupPasteableColumn(getColumns, 'onLast')
3223
- })
3224
- ];
3225
- var hasCellMenuItems = [
3226
- addMenuIfRegistered('tablecellprops', {
3227
- text: 'Cell properties',
3228
- icon: 'table-cell-properties',
3229
- command: 'mceTableCellProps',
3230
- onSetup: selectionTargets.onSetupCellOrRow
3231
- }),
3232
- addMenuIfRegistered('tablemergecells', {
3233
- text: 'Merge cells',
3234
- icon: 'table-merge-cells',
3235
- command: 'mceTableMergeCells',
3236
- onSetup: selectionTargets.onSetupMergeable
3237
- }),
3238
- addMenuIfRegistered('tablesplitcells', {
3239
- text: 'Split cell',
3240
- icon: 'table-split-cells',
3241
- command: 'mceTableSplitCells',
3242
- onSetup: selectionTargets.onSetupUnmergeable
3243
- })
3244
- ];
3245
- if (!hasTableGrid(editor)) {
3246
- editor.ui.registry.addMenuItem('inserttable', {
3247
- text: 'Table',
3248
- icon: 'table',
3249
- onAction: cmd('mceInsertTableDialog'),
3250
- onSetup: onSetupEditable(editor)
3251
- });
3252
- }
3253
- else {
3254
- editor.ui.registry.addNestedMenuItem('inserttable', {
3255
- text: 'Table',
3256
- icon: 'table',
3257
- getSubmenuItems: function () { return [{
3258
- type: 'fancymenuitem',
3259
- fancytype: 'inserttable',
3260
- onAction: insertTableAction
3261
- }]; },
3262
- onSetup: onSetupEditable(editor)
3263
- });
3264
- }
3265
- editor.ui.registry.addMenuItem('inserttabledialog', {
3266
- text: 'Insert table',
3267
- icon: 'table',
3268
- onAction: cmd('mceInsertTableDialog'),
3269
- onSetup: onSetupEditable(editor)
3270
- });
3271
- addMenuIfRegistered('tableprops', {
3272
- text: 'Table properties',
3273
- onSetup: selectionTargets.onSetupTable,
3274
- command: 'mceTableProps'
3275
- });
3276
- addMenuIfRegistered('deletetable', {
3277
- text: 'Delete table',
3278
- icon: 'table-delete-table',
3279
- onSetup: selectionTargets.onSetupTable,
3280
- command: 'mceTableDelete'
3281
- });
3282
- if (contains(hasRowMenuItems, true)) {
3283
- editor.ui.registry.addNestedMenuItem('row', {
3284
- type: 'nestedmenuitem',
3285
- text: 'Row',
3286
- getSubmenuItems: constant('tableinsertrowbefore tableinsertrowafter tabledeleterow tablerowprops | tablecutrow tablecopyrow tablepasterowbefore tablepasterowafter')
3287
- });
3288
- }
3289
- if (contains(hasColumnMenuItems, true)) {
3290
- editor.ui.registry.addNestedMenuItem('column', {
3291
- type: 'nestedmenuitem',
3292
- text: 'Column',
3293
- getSubmenuItems: constant('tableinsertcolumnbefore tableinsertcolumnafter tabledeletecolumn | tablecutcolumn tablecopycolumn tablepastecolumnbefore tablepastecolumnafter')
3294
- });
3295
- }
3296
- if (contains(hasCellMenuItems, true)) {
3297
- editor.ui.registry.addNestedMenuItem('cell', {
3298
- type: 'nestedmenuitem',
3299
- text: 'Cell',
3300
- getSubmenuItems: constant('tablecellprops tablemergecells tablesplitcells')
3301
- });
3302
- }
3303
- editor.ui.registry.addContextMenu('table', {
3304
- update: function () {
3305
- selectionTargets.resetTargets();
3306
- return selectionTargets.targets().fold(constant(''), function (targets) {
3307
- if (name(targets.element) === 'caption') {
3308
- return 'tableprops deletetable';
3309
- }
3310
- else {
3311
- return 'cell row column | advtablesort | tableprops deletetable';
3312
- }
3313
- });
3314
- }
3315
- });
3316
- var tableClassList = filterNoneItem(getTableClassList(editor));
3317
- if (tableClassList.length !== 0 && editor.queryCommandSupported('mceTableToggleClass')) {
3318
- editor.ui.registry.addNestedMenuItem('tableclass', {
3319
- icon: 'table-classes',
3320
- text: 'Table styles',
3321
- getSubmenuItems: function () { return buildMenuItems(editor, tableClassList, 'tableclass', function (value) { return editor.execCommand('mceTableToggleClass', false, value); }); },
3322
- onSetup: selectionTargets.onSetupTable
3323
- });
3324
- }
3325
- var tableCellClassList = filterNoneItem(getCellClassList(editor));
3326
- if (tableCellClassList.length !== 0 && editor.queryCommandSupported('mceTableCellToggleClass')) {
3327
- editor.ui.registry.addNestedMenuItem('tablecellclass', {
3328
- icon: 'table-cell-classes',
3329
- text: 'Cell styles',
3330
- getSubmenuItems: function () { return buildMenuItems(editor, tableCellClassList, 'tablecellclass', function (value) { return editor.execCommand('mceTableCellToggleClass', false, value); }); },
3331
- onSetup: selectionTargets.onSetupCellOrRow
3332
- });
3333
- }
3334
- if (editor.queryCommandSupported('mceTableApplyCellStyle')) {
3335
- editor.ui.registry.addNestedMenuItem('tablecellvalign', {
3336
- icon: 'vertical-align',
3337
- text: 'Vertical align',
3338
- getSubmenuItems: function () { return buildMenuItems(editor, verticalAlignValues, 'tablecellverticalalign', applyTableCellStyle(editor, 'vertical-align')); },
3339
- onSetup: selectionTargets.onSetupCellOrRow
3340
- });
3341
- editor.ui.registry.addNestedMenuItem('tablecellborderwidth', {
3342
- icon: 'border-width',
3343
- text: 'Border width',
3344
- getSubmenuItems: function () { return buildMenuItems(editor, getTableBorderWidths(editor), 'tablecellborderwidth', applyTableCellStyle(editor, 'border-width')); },
3345
- onSetup: selectionTargets.onSetupCellOrRow
3346
- });
3347
- editor.ui.registry.addNestedMenuItem('tablecellborderstyle', {
3348
- icon: 'border-style',
3349
- text: 'Border style',
3350
- getSubmenuItems: function () { return buildMenuItems(editor, getTableBorderStyles(editor), 'tablecellborderstyle', applyTableCellStyle(editor, 'border-style')); },
3351
- onSetup: selectionTargets.onSetupCellOrRow
3352
- });
3353
- editor.ui.registry.addNestedMenuItem('tablecellbackgroundcolor', {
3354
- icon: 'cell-background-color',
3355
- text: 'Background color',
3356
- getSubmenuItems: function () { return buildColorMenu(editor, getTableBackgroundColorMap(editor), 'background-color'); },
3357
- onSetup: selectionTargets.onSetupCellOrRow
3358
- });
3359
- editor.ui.registry.addNestedMenuItem('tablecellbordercolor', {
3360
- icon: 'cell-border-color',
3361
- text: 'Border color',
3362
- getSubmenuItems: function () { return buildColorMenu(editor, getTableBorderColorMap(editor), 'border-color'); },
3363
- onSetup: selectionTargets.onSetupCellOrRow
3364
- });
3365
- }
3366
- addToggleMenuIfRegistered('tablecaption', {
3367
- icon: 'table-caption',
3368
- text: 'Table caption',
3369
- command: 'mceTableToggleCaption',
3370
- onSetup: selectionTargets.onSetupTableWithCaption
3371
- });
3372
- addToggleMenuIfRegistered('tablerowheader', {
3373
- text: 'Row header',
3374
- icon: 'table-top-header',
3375
- command: 'mceTableRowType',
3376
- onAction: changeRowHeader(editor),
3377
- onSetup: selectionTargets.onSetupTableRowHeaders
3378
- });
3379
- addToggleMenuIfRegistered('tablecolheader', {
3380
- text: 'Column header',
3381
- icon: 'table-left-header',
3382
- command: 'mceTableColType',
3383
- onAction: changeColumnHeader(editor),
3384
- onSetup: selectionTargets.onSetupTableRowHeaders
3385
- });
3386
- };
3387
- var Plugin = function (editor) {
3388
- var selectionTargets = getSelectionTargets(editor);
3389
- register(editor);
3390
- registerCommands(editor);
3391
- addMenuItems(editor, selectionTargets);
3392
- addButtons(editor, selectionTargets);
3393
- addToolbars(editor);
3394
- };
3395
- var Plugin$1 = function () {
3396
- global$3.add('table', Plugin);
3397
- };
3398
- Plugin$1();
3399
- })();