@lotte-innovate/ui-component-test 0.0.109 → 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,1246 +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
- (function () {
17
- 'use strict';
18
- var global$5 = tinymce.util.Tools.resolve('tinymce.PluginManager');
19
- var hasProto = function (v, constructor, predicate) {
20
- var _a;
21
- if (predicate(v, constructor.prototype)) {
22
- return true;
23
- }
24
- else {
25
- return ((_a = v.constructor) === null || _a === void 0 ? void 0 : _a.name) === constructor.name;
26
- }
27
- };
28
- var typeOf = function (x) {
29
- var t = typeof x;
30
- if (x === null) {
31
- return 'null';
32
- }
33
- else if (t === 'object' && Array.isArray(x)) {
34
- return 'array';
35
- }
36
- else if (t === 'object' && hasProto(x, String, function (o, proto) { return proto.isPrototypeOf(o); })) {
37
- return 'string';
38
- }
39
- else {
40
- return t;
41
- }
42
- };
43
- var isType = function (type) { return function (value) { return typeOf(value) === type; }; };
44
- var isSimpleType = function (type) { return function (value) { return typeof value === type; }; };
45
- var eq = function (t) { return function (a) { return t === a; }; };
46
- var isString = isType('string');
47
- var isObject = isType('object');
48
- var isArray = isType('array');
49
- var isNull = eq(null);
50
- var isBoolean = isSimpleType('boolean');
51
- var isNullable = function (a) { return a === null || a === undefined; };
52
- var isNonNullable = function (a) { return !isNullable(a); };
53
- var isFunction = isSimpleType('function');
54
- var isArrayOf = function (value, pred) {
55
- if (isArray(value)) {
56
- for (var i = 0, len = value.length; i < len; ++i) {
57
- if (!pred(value[i])) {
58
- return false;
59
- }
60
- }
61
- return true;
62
- }
63
- return false;
64
- };
65
- var noop = function () {
66
- };
67
- var constant = function (value) {
68
- return function () {
69
- return value;
70
- };
71
- };
72
- var tripleEquals = function (a, b) {
73
- return a === b;
74
- };
75
- var Optional = /** @class */ (function () {
76
- function Optional(tag, value) {
77
- this.tag = tag;
78
- this.value = value;
79
- }
80
- Optional.some = function (value) {
81
- return new Optional(true, value);
82
- };
83
- Optional.none = function () {
84
- return Optional.singletonNone;
85
- };
86
- Optional.prototype.fold = function (onNone, onSome) {
87
- if (this.tag) {
88
- return onSome(this.value);
89
- }
90
- else {
91
- return onNone();
92
- }
93
- };
94
- Optional.prototype.isSome = function () {
95
- return this.tag;
96
- };
97
- Optional.prototype.isNone = function () {
98
- return !this.tag;
99
- };
100
- Optional.prototype.map = function (mapper) {
101
- if (this.tag) {
102
- return Optional.some(mapper(this.value));
103
- }
104
- else {
105
- return Optional.none();
106
- }
107
- };
108
- Optional.prototype.bind = function (binder) {
109
- if (this.tag) {
110
- return binder(this.value);
111
- }
112
- else {
113
- return Optional.none();
114
- }
115
- };
116
- Optional.prototype.exists = function (predicate) {
117
- return this.tag && predicate(this.value);
118
- };
119
- Optional.prototype.forall = function (predicate) {
120
- return !this.tag || predicate(this.value);
121
- };
122
- Optional.prototype.filter = function (predicate) {
123
- if (!this.tag || predicate(this.value)) {
124
- return this;
125
- }
126
- else {
127
- return Optional.none();
128
- }
129
- };
130
- Optional.prototype.getOr = function (replacement) {
131
- return this.tag ? this.value : replacement;
132
- };
133
- Optional.prototype.or = function (replacement) {
134
- return this.tag ? this : replacement;
135
- };
136
- Optional.prototype.getOrThunk = function (thunk) {
137
- return this.tag ? this.value : thunk();
138
- };
139
- Optional.prototype.orThunk = function (thunk) {
140
- return this.tag ? this : thunk();
141
- };
142
- Optional.prototype.getOrDie = function (message) {
143
- if (!this.tag) {
144
- throw new Error(message !== null && message !== void 0 ? message : 'Called getOrDie on None');
145
- }
146
- else {
147
- return this.value;
148
- }
149
- };
150
- Optional.from = function (value) {
151
- return isNonNullable(value) ? Optional.some(value) : Optional.none();
152
- };
153
- Optional.prototype.getOrNull = function () {
154
- return this.tag ? this.value : null;
155
- };
156
- Optional.prototype.getOrUndefined = function () {
157
- return this.value;
158
- };
159
- Optional.prototype.each = function (worker) {
160
- if (this.tag) {
161
- worker(this.value);
162
- }
163
- };
164
- Optional.prototype.toArray = function () {
165
- return this.tag ? [this.value] : [];
166
- };
167
- Optional.prototype.toString = function () {
168
- return this.tag ? "some(".concat(this.value, ")") : 'none()';
169
- };
170
- return Optional;
171
- }());
172
- Optional.singletonNone = new Optional(false);
173
- var nativeIndexOf = Array.prototype.indexOf;
174
- var nativePush = Array.prototype.push;
175
- var rawIndexOf = function (ts, t) { return nativeIndexOf.call(ts, t); };
176
- var contains = function (xs, x) { return rawIndexOf(xs, x) > -1; };
177
- var map = function (xs, f) {
178
- var len = xs.length;
179
- var r = new Array(len);
180
- for (var i = 0; i < len; i++) {
181
- var x = xs[i];
182
- r[i] = f(x, i);
183
- }
184
- return r;
185
- };
186
- var each$1 = function (xs, f) {
187
- for (var i = 0, len = xs.length; i < len; i++) {
188
- var x = xs[i];
189
- f(x, i);
190
- }
191
- };
192
- var foldl = function (xs, f, acc) {
193
- each$1(xs, function (x, i) {
194
- acc = f(acc, x, i);
195
- });
196
- return acc;
197
- };
198
- var flatten = function (xs) {
199
- var r = [];
200
- for (var i = 0, len = xs.length; i < len; ++i) {
201
- if (!isArray(xs[i])) {
202
- throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
203
- }
204
- nativePush.apply(r, xs[i]);
205
- }
206
- return r;
207
- };
208
- var bind = function (xs, f) { return flatten(map(xs, f)); };
209
- var findMap = function (arr, f) {
210
- for (var i = 0; i < arr.length; i++) {
211
- var r = f(arr[i], i);
212
- if (r.isSome()) {
213
- return r;
214
- }
215
- }
216
- return Optional.none();
217
- };
218
- var is = function (lhs, rhs, comparator) {
219
- if (comparator === void 0) { comparator = tripleEquals; }
220
- return lhs.exists(function (left) { return comparator(left, rhs); });
221
- };
222
- var cat = function (arr) {
223
- var r = [];
224
- var push = function (x) {
225
- r.push(x);
226
- };
227
- for (var i = 0; i < arr.length; i++) {
228
- arr[i].each(push);
229
- }
230
- return r;
231
- };
232
- var someIf = function (b, a) { return b ? Optional.some(a) : Optional.none(); };
233
- var option = function (name) { return function (editor) { return editor.options.get(name); }; };
234
- var register$1 = function (editor) {
235
- var registerOption = editor.options.register;
236
- registerOption('link_assume_external_targets', {
237
- processor: function (value) {
238
- var valid = isString(value) || isBoolean(value);
239
- if (valid) {
240
- if (value === true) {
241
- return {
242
- value: 1,
243
- valid: valid
244
- };
245
- }
246
- else if (value === 'http' || value === 'https') {
247
- return {
248
- value: value,
249
- valid: valid
250
- };
251
- }
252
- else {
253
- return {
254
- value: 0,
255
- valid: valid
256
- };
257
- }
258
- }
259
- else {
260
- return {
261
- valid: false,
262
- message: 'Must be a string or a boolean.'
263
- };
264
- }
265
- },
266
- default: false
267
- });
268
- registerOption('link_context_toolbar', {
269
- processor: 'boolean',
270
- default: false
271
- });
272
- registerOption('link_list', { processor: function (value) { return isString(value) || isFunction(value) || isArrayOf(value, isObject); } });
273
- registerOption('link_default_target', { processor: 'string' });
274
- registerOption('link_default_protocol', {
275
- processor: 'string',
276
- default: 'https'
277
- });
278
- registerOption('link_target_list', {
279
- processor: function (value) { return isBoolean(value) || isArrayOf(value, isObject); },
280
- default: true
281
- });
282
- registerOption('link_rel_list', {
283
- processor: 'object[]',
284
- default: []
285
- });
286
- registerOption('link_class_list', {
287
- processor: 'object[]',
288
- default: []
289
- });
290
- registerOption('link_title', {
291
- processor: 'boolean',
292
- default: true
293
- });
294
- registerOption('allow_unsafe_link_target', {
295
- processor: 'boolean',
296
- default: false
297
- });
298
- registerOption('link_quicklink', {
299
- processor: 'boolean',
300
- default: false
301
- });
302
- };
303
- var assumeExternalTargets = option('link_assume_external_targets');
304
- var hasContextToolbar = option('link_context_toolbar');
305
- var getLinkList = option('link_list');
306
- var getDefaultLinkTarget = option('link_default_target');
307
- var getDefaultLinkProtocol = option('link_default_protocol');
308
- var getTargetList = option('link_target_list');
309
- var getRelList = option('link_rel_list');
310
- var getLinkClassList = option('link_class_list');
311
- var shouldShowLinkTitle = option('link_title');
312
- var allowUnsafeLinkTarget = option('allow_unsafe_link_target');
313
- var useQuickLink = option('link_quicklink');
314
- var global$4 = tinymce.util.Tools.resolve('tinymce.util.Tools');
315
- var getValue = function (item) { return isString(item.value) ? item.value : ''; };
316
- var getText = function (item) {
317
- if (isString(item.text)) {
318
- return item.text;
319
- }
320
- else if (isString(item.title)) {
321
- return item.title;
322
- }
323
- else {
324
- return '';
325
- }
326
- };
327
- var sanitizeList = function (list, extractValue) {
328
- var out = [];
329
- global$4.each(list, function (item) {
330
- var text = getText(item);
331
- if (item.menu !== undefined) {
332
- var items = sanitizeList(item.menu, extractValue);
333
- out.push({
334
- text: text,
335
- items: items
336
- });
337
- }
338
- else {
339
- var value = extractValue(item);
340
- out.push({
341
- text: text,
342
- value: value
343
- });
344
- }
345
- });
346
- return out;
347
- };
348
- var sanitizeWith = function (extracter) {
349
- if (extracter === void 0) { extracter = getValue; }
350
- return function (list) { return Optional.from(list).map(function (list) { return sanitizeList(list, extracter); }); };
351
- };
352
- var sanitize = function (list) { return sanitizeWith(getValue)(list); };
353
- var createUi = function (name, label) { return function (items) { return ({
354
- name: name,
355
- type: 'listbox',
356
- label: label,
357
- items: items
358
- }); }; };
359
- var ListOptions = {
360
- sanitize: sanitize,
361
- sanitizeWith: sanitizeWith,
362
- createUi: createUi,
363
- getValue: getValue
364
- };
365
- var keys = Object.keys;
366
- var hasOwnProperty = Object.hasOwnProperty;
367
- var each = function (obj, f) {
368
- var props = keys(obj);
369
- for (var k = 0, len = props.length; k < len; k++) {
370
- var i = props[k];
371
- var x = obj[i];
372
- f(x, i);
373
- }
374
- };
375
- var objAcc = function (r) { return function (x, i) {
376
- r[i] = x;
377
- }; };
378
- var internalFilter = function (obj, pred, onTrue, onFalse) {
379
- each(obj, function (x, i) {
380
- (pred(x, i) ? onTrue : onFalse)(x, i);
381
- });
382
- };
383
- var filter = function (obj, pred) {
384
- var t = {};
385
- internalFilter(obj, pred, objAcc(t), noop);
386
- return t;
387
- };
388
- var has = function (obj, key) { return hasOwnProperty.call(obj, key); };
389
- var hasNonNullableKey = function (obj, key) { return has(obj, key) && obj[key] !== undefined && obj[key] !== null; };
390
- var global$3 = tinymce.util.Tools.resolve('tinymce.dom.TreeWalker');
391
- var global$2 = tinymce.util.Tools.resolve('tinymce.util.URI');
392
- var isAnchor = function (elm) { return isNonNullable(elm) && elm.nodeName.toLowerCase() === 'a'; };
393
- var isLink = function (elm) { return isAnchor(elm) && !!getHref(elm); };
394
- var collectNodesInRange = function (rng, predicate) {
395
- if (rng.collapsed) {
396
- return [];
397
- }
398
- else {
399
- var contents = rng.cloneContents();
400
- var firstChild = contents.firstChild;
401
- var walker = new global$3(firstChild, contents);
402
- var elements = [];
403
- var current = firstChild;
404
- do {
405
- if (predicate(current)) {
406
- elements.push(current);
407
- }
408
- } while (current = walker.next());
409
- return elements;
410
- }
411
- };
412
- var hasProtocol = function (url) { return /^\w+:/i.test(url); };
413
- var getHref = function (elm) {
414
- var _a, _b;
415
- return (_b = (_a = elm.getAttribute('data-mce-href')) !== null && _a !== void 0 ? _a : elm.getAttribute('href')) !== null && _b !== void 0 ? _b : '';
416
- };
417
- var applyRelTargetRules = function (rel, isUnsafe) {
418
- var rules = ['noopener'];
419
- var rels = rel ? rel.split(/\s+/) : [];
420
- var toString = function (rels) { return global$4.trim(rels.sort().join(' ')); };
421
- var addTargetRules = function (rels) {
422
- rels = removeTargetRules(rels);
423
- return rels.length > 0 ? rels.concat(rules) : rules;
424
- };
425
- var removeTargetRules = function (rels) { return rels.filter(function (val) { return global$4.inArray(rules, val) === -1; }); };
426
- var newRels = isUnsafe ? addTargetRules(rels) : removeTargetRules(rels);
427
- return newRels.length > 0 ? toString(newRels) : '';
428
- };
429
- var trimCaretContainers = function (text) { return text.replace(/\uFEFF/g, ''); };
430
- var getAnchorElement = function (editor, selectedElm) {
431
- selectedElm = selectedElm || getLinksInSelection(editor.selection.getRng())[0] || editor.selection.getNode();
432
- if (isImageFigure(selectedElm)) {
433
- return Optional.from(editor.dom.select('a[href]', selectedElm)[0]);
434
- }
435
- else {
436
- return Optional.from(editor.dom.getParent(selectedElm, 'a[href]'));
437
- }
438
- };
439
- var isInAnchor = function (editor, selectedElm) { return getAnchorElement(editor, selectedElm).isSome(); };
440
- var getAnchorText = function (selection, anchorElm) {
441
- var text = anchorElm.fold(function () { return selection.getContent({ format: 'text' }); }, function (anchorElm) { return anchorElm.innerText || anchorElm.textContent || ''; });
442
- return trimCaretContainers(text);
443
- };
444
- var getLinksInSelection = function (rng) { return collectNodesInRange(rng, isLink); };
445
- var getLinks$1 = function (elements) { return global$4.grep(elements, isLink); };
446
- var hasLinks = function (elements) { return getLinks$1(elements).length > 0; };
447
- var hasLinksInSelection = function (rng) { return getLinksInSelection(rng).length > 0; };
448
- var isOnlyTextSelected = function (editor) {
449
- var inlineTextElements = editor.schema.getTextInlineElements();
450
- var isElement = function (elm) { return elm.nodeType === 1 && !isAnchor(elm) && !has(inlineTextElements, elm.nodeName.toLowerCase()); };
451
- var isInBlockAnchor = getAnchorElement(editor).exists(function (anchor) { return anchor.hasAttribute('data-mce-block'); });
452
- if (isInBlockAnchor) {
453
- return false;
454
- }
455
- var rng = editor.selection.getRng();
456
- if (!rng.collapsed) {
457
- var elements = collectNodesInRange(rng, isElement);
458
- return elements.length === 0;
459
- }
460
- else {
461
- return true;
462
- }
463
- };
464
- var isImageFigure = function (elm) { return isNonNullable(elm) && elm.nodeName === 'FIGURE' && /\bimage\b/i.test(elm.className); };
465
- var getLinkAttrs = function (data) {
466
- var attrs = [
467
- 'title',
468
- 'rel',
469
- 'class',
470
- 'target'
471
- ];
472
- return foldl(attrs, function (acc, key) {
473
- data[key].each(function (value) {
474
- acc[key] = value.length > 0 ? value : null;
475
- });
476
- return acc;
477
- }, { href: data.href });
478
- };
479
- var handleExternalTargets = function (href, assumeExternalTargets) {
480
- if ((assumeExternalTargets === 'http' || assumeExternalTargets === 'https') && !hasProtocol(href)) {
481
- return assumeExternalTargets + '://' + href;
482
- }
483
- return href;
484
- };
485
- var applyLinkOverrides = function (editor, linkAttrs) {
486
- var newLinkAttrs = __assign({}, linkAttrs);
487
- if (getRelList(editor).length === 0 && !allowUnsafeLinkTarget(editor)) {
488
- var newRel = applyRelTargetRules(newLinkAttrs.rel, newLinkAttrs.target === '_blank');
489
- newLinkAttrs.rel = newRel ? newRel : null;
490
- }
491
- if (Optional.from(newLinkAttrs.target).isNone() && getTargetList(editor) === false) {
492
- newLinkAttrs.target = getDefaultLinkTarget(editor);
493
- }
494
- newLinkAttrs.href = handleExternalTargets(newLinkAttrs.href, assumeExternalTargets(editor));
495
- return newLinkAttrs;
496
- };
497
- var updateLink = function (editor, anchorElm, text, linkAttrs) {
498
- text.each(function (text) {
499
- if (has(anchorElm, 'innerText')) {
500
- anchorElm.innerText = text;
501
- }
502
- else {
503
- anchorElm.textContent = text;
504
- }
505
- });
506
- editor.dom.setAttribs(anchorElm, linkAttrs);
507
- editor.selection.select(anchorElm);
508
- };
509
- var createLink = function (editor, selectedElm, text, linkAttrs) {
510
- var dom = editor.dom;
511
- if (isImageFigure(selectedElm)) {
512
- linkImageFigure(dom, selectedElm, linkAttrs);
513
- }
514
- else {
515
- text.fold(function () {
516
- editor.execCommand('mceInsertLink', false, linkAttrs);
517
- }, function (text) {
518
- editor.insertContent(dom.createHTML('a', linkAttrs, dom.encode(text)));
519
- });
520
- }
521
- };
522
- var linkDomMutation = function (editor, attachState, data) {
523
- var selectedElm = editor.selection.getNode();
524
- var anchorElm = getAnchorElement(editor, selectedElm);
525
- var linkAttrs = applyLinkOverrides(editor, getLinkAttrs(data));
526
- editor.undoManager.transact(function () {
527
- if (data.href === attachState.href) {
528
- attachState.attach();
529
- }
530
- anchorElm.fold(function () {
531
- createLink(editor, selectedElm, data.text, linkAttrs);
532
- }, function (elm) {
533
- editor.focus();
534
- updateLink(editor, elm, data.text, linkAttrs);
535
- });
536
- });
537
- };
538
- var unlinkSelection = function (editor) {
539
- var dom = editor.dom, selection = editor.selection;
540
- var bookmark = selection.getBookmark();
541
- var rng = selection.getRng().cloneRange();
542
- var startAnchorElm = dom.getParent(rng.startContainer, 'a[href]', editor.getBody());
543
- var endAnchorElm = dom.getParent(rng.endContainer, 'a[href]', editor.getBody());
544
- if (startAnchorElm) {
545
- rng.setStartBefore(startAnchorElm);
546
- }
547
- if (endAnchorElm) {
548
- rng.setEndAfter(endAnchorElm);
549
- }
550
- selection.setRng(rng);
551
- editor.execCommand('unlink');
552
- selection.moveToBookmark(bookmark);
553
- };
554
- var unlinkDomMutation = function (editor) {
555
- editor.undoManager.transact(function () {
556
- var node = editor.selection.getNode();
557
- if (isImageFigure(node)) {
558
- unlinkImageFigure(editor, node);
559
- }
560
- else {
561
- unlinkSelection(editor);
562
- }
563
- editor.focus();
564
- });
565
- };
566
- var unwrapOptions = function (data) {
567
- var cls = data.class, href = data.href, rel = data.rel, target = data.target, text = data.text, title = data.title;
568
- return filter({
569
- class: cls.getOrNull(),
570
- href: href,
571
- rel: rel.getOrNull(),
572
- target: target.getOrNull(),
573
- text: text.getOrNull(),
574
- title: title.getOrNull()
575
- }, function (v, _k) { return isNull(v) === false; });
576
- };
577
- var sanitizeData = function (editor, data) {
578
- var getOption = editor.options.get;
579
- var uriOptions = {
580
- allow_html_data_urls: getOption('allow_html_data_urls'),
581
- allow_script_urls: getOption('allow_script_urls'),
582
- allow_svg_data_urls: getOption('allow_svg_data_urls')
583
- };
584
- var href = data.href;
585
- return __assign(__assign({}, data), { href: global$2.isDomSafe(href, 'a', uriOptions) ? href : '' });
586
- };
587
- var link = function (editor, attachState, data) {
588
- var sanitizedData = sanitizeData(editor, data);
589
- editor.hasPlugin('rtc', true) ? editor.execCommand('createlink', false, unwrapOptions(sanitizedData)) : linkDomMutation(editor, attachState, sanitizedData);
590
- };
591
- var unlink = function (editor) {
592
- editor.hasPlugin('rtc', true) ? editor.execCommand('unlink') : unlinkDomMutation(editor);
593
- };
594
- var unlinkImageFigure = function (editor, fig) {
595
- var _a;
596
- var img = editor.dom.select('img', fig)[0];
597
- if (img) {
598
- var a = editor.dom.getParents(img, 'a[href]', fig)[0];
599
- if (a) {
600
- (_a = a.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(img, a);
601
- editor.dom.remove(a);
602
- }
603
- }
604
- };
605
- var linkImageFigure = function (dom, fig, attrs) {
606
- var _a;
607
- var img = dom.select('img', fig)[0];
608
- if (img) {
609
- var a = dom.create('a', attrs);
610
- (_a = img.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(a, img);
611
- a.appendChild(img);
612
- }
613
- };
614
- var isListGroup = function (item) { return hasNonNullableKey(item, 'items'); };
615
- var findTextByValue = function (value, catalog) { return findMap(catalog, function (item) {
616
- if (isListGroup(item)) {
617
- return findTextByValue(value, item.items);
618
- }
619
- else {
620
- return someIf(item.value === value, item);
621
- }
622
- }); };
623
- var getDelta = function (persistentText, fieldName, catalog, data) {
624
- var value = data[fieldName];
625
- var hasPersistentText = persistentText.length > 0;
626
- return value !== undefined ? findTextByValue(value, catalog).map(function (i) { return ({
627
- url: {
628
- value: i.value,
629
- meta: {
630
- text: hasPersistentText ? persistentText : i.text,
631
- attach: noop
632
- }
633
- },
634
- text: hasPersistentText ? persistentText : i.text
635
- }); }) : Optional.none();
636
- };
637
- var findCatalog = function (catalogs, fieldName) {
638
- if (fieldName === 'link') {
639
- return catalogs.link;
640
- }
641
- else if (fieldName === 'anchor') {
642
- return catalogs.anchor;
643
- }
644
- else {
645
- return Optional.none();
646
- }
647
- };
648
- var init = function (initialData, linkCatalog) {
649
- var persistentData = {
650
- text: initialData.text,
651
- title: initialData.title
652
- };
653
- var getTitleFromUrlChange = function (url) {
654
- var _a;
655
- return someIf(persistentData.title.length <= 0, Optional.from((_a = url.meta) === null || _a === void 0 ? void 0 : _a.title).getOr(''));
656
- };
657
- var getTextFromUrlChange = function (url) {
658
- var _a;
659
- return someIf(persistentData.text.length <= 0, Optional.from((_a = url.meta) === null || _a === void 0 ? void 0 : _a.text).getOr(url.value));
660
- };
661
- var onUrlChange = function (data) {
662
- var text = getTextFromUrlChange(data.url);
663
- var title = getTitleFromUrlChange(data.url);
664
- if (text.isSome() || title.isSome()) {
665
- return Optional.some(__assign(__assign({}, text.map(function (text) { return ({ text: text }); }).getOr({})), title.map(function (title) { return ({ title: title }); }).getOr({})));
666
- }
667
- else {
668
- return Optional.none();
669
- }
670
- };
671
- var onCatalogChange = function (data, change) {
672
- var catalog = findCatalog(linkCatalog, change).getOr([]);
673
- return getDelta(persistentData.text, change, catalog, data);
674
- };
675
- var onChange = function (getData, change) {
676
- var name = change.name;
677
- if (name === 'url') {
678
- return onUrlChange(getData());
679
- }
680
- else if (contains([
681
- 'anchor',
682
- 'link'
683
- ], name)) {
684
- return onCatalogChange(getData(), name);
685
- }
686
- else if (name === 'text' || name === 'title') {
687
- persistentData[name] = getData()[name];
688
- return Optional.none();
689
- }
690
- else {
691
- return Optional.none();
692
- }
693
- };
694
- return { onChange: onChange };
695
- };
696
- var DialogChanges = {
697
- init: init,
698
- getDelta: getDelta
699
- };
700
- var global$1 = tinymce.util.Tools.resolve('tinymce.util.Delay');
701
- var delayedConfirm = function (editor, message, callback) {
702
- var rng = editor.selection.getRng();
703
- global$1.setEditorTimeout(editor, function () {
704
- editor.windowManager.confirm(message, function (state) {
705
- editor.selection.setRng(rng);
706
- callback(state);
707
- });
708
- });
709
- };
710
- var tryEmailTransform = function (data) {
711
- var url = data.href;
712
- var suggestMailTo = url.indexOf('@') > 0 && url.indexOf('/') === -1 && url.indexOf('mailto:') === -1;
713
- return suggestMailTo ? Optional.some({
714
- message: 'The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?',
715
- preprocess: function (oldData) { return (__assign(__assign({}, oldData), { href: 'mailto:' + url })); }
716
- }) : Optional.none();
717
- };
718
- var tryProtocolTransform = function (assumeExternalTargets, defaultLinkProtocol) { return function (data) {
719
- var url = data.href;
720
- var suggestProtocol = assumeExternalTargets === 1 && !hasProtocol(url) || assumeExternalTargets === 0 && /^\s*www(\.|\d\.)/i.test(url);
721
- return suggestProtocol ? Optional.some({
722
- message: "The URL you entered seems to be an external link. Do you want to add the required ".concat(defaultLinkProtocol, ":// prefix?"),
723
- preprocess: function (oldData) { return (__assign(__assign({}, oldData), { href: defaultLinkProtocol + '://' + url })); }
724
- }) : Optional.none();
725
- }; };
726
- var preprocess = function (editor, data) { return findMap([
727
- tryEmailTransform,
728
- tryProtocolTransform(assumeExternalTargets(editor), getDefaultLinkProtocol(editor))
729
- ], function (f) { return f(data); }).fold(function () { return Promise.resolve(data); }, function (transform) { return new Promise(function (callback) {
730
- delayedConfirm(editor, transform.message, function (state) {
731
- callback(state ? transform.preprocess(data) : data);
732
- });
733
- }); }); };
734
- var DialogConfirms = { preprocess: preprocess };
735
- var getAnchors = function (editor) {
736
- var anchorNodes = editor.dom.select('a:not([href])');
737
- var anchors = bind(anchorNodes, function (anchor) {
738
- var id = anchor.name || anchor.id;
739
- return id ? [{
740
- text: id,
741
- value: '#' + id
742
- }] : [];
743
- });
744
- return anchors.length > 0 ? Optional.some([{
745
- text: 'None',
746
- value: ''
747
- }].concat(anchors)) : Optional.none();
748
- };
749
- var AnchorListOptions = { getAnchors: getAnchors };
750
- var getClasses = function (editor) {
751
- var list = getLinkClassList(editor);
752
- if (list.length > 0) {
753
- return ListOptions.sanitize(list);
754
- }
755
- return Optional.none();
756
- };
757
- var ClassListOptions = { getClasses: getClasses };
758
- var parseJson = function (text) {
759
- try {
760
- return Optional.some(JSON.parse(text));
761
- }
762
- catch (err) {
763
- return Optional.none();
764
- }
765
- };
766
- var getLinks = function (editor) {
767
- var extractor = function (item) { return editor.convertURL(item.value || item.url || '', 'href'); };
768
- var linkList = getLinkList(editor);
769
- return new Promise(function (resolve) {
770
- if (isString(linkList)) {
771
- fetch(linkList).then(function (res) { return res.ok ? res.text().then(parseJson) : Promise.reject(); }).then(resolve, function () { return resolve(Optional.none()); });
772
- }
773
- else if (isFunction(linkList)) {
774
- linkList(function (output) { return resolve(Optional.some(output)); });
775
- }
776
- else {
777
- resolve(Optional.from(linkList));
778
- }
779
- }).then(function (optItems) { return optItems.bind(ListOptions.sanitizeWith(extractor)).map(function (items) {
780
- if (items.length > 0) {
781
- var noneItem = [{
782
- text: 'None',
783
- value: ''
784
- }];
785
- return noneItem.concat(items);
786
- }
787
- else {
788
- return items;
789
- }
790
- }); });
791
- };
792
- var LinkListOptions = { getLinks: getLinks };
793
- var getRels = function (editor, initialTarget) {
794
- var list = getRelList(editor);
795
- if (list.length > 0) {
796
- var isTargetBlank_1 = is(initialTarget, '_blank');
797
- var enforceSafe = allowUnsafeLinkTarget(editor) === false;
798
- var safeRelExtractor = function (item) { return applyRelTargetRules(ListOptions.getValue(item), isTargetBlank_1); };
799
- var sanitizer = enforceSafe ? ListOptions.sanitizeWith(safeRelExtractor) : ListOptions.sanitize;
800
- return sanitizer(list);
801
- }
802
- return Optional.none();
803
- };
804
- var RelOptions = { getRels: getRels };
805
- var fallbacks = [
806
- {
807
- text: 'Current window',
808
- value: ''
809
- },
810
- {
811
- text: 'New window',
812
- value: '_blank'
813
- }
814
- ];
815
- var getTargets = function (editor) {
816
- var list = getTargetList(editor);
817
- if (isArray(list)) {
818
- return ListOptions.sanitize(list).orThunk(function () { return Optional.some(fallbacks); });
819
- }
820
- else if (list === false) {
821
- return Optional.none();
822
- }
823
- return Optional.some(fallbacks);
824
- };
825
- var TargetOptions = { getTargets: getTargets };
826
- var nonEmptyAttr = function (dom, elem, name) {
827
- var val = dom.getAttrib(elem, name);
828
- return val !== null && val.length > 0 ? Optional.some(val) : Optional.none();
829
- };
830
- var extractFromAnchor = function (editor, anchor) {
831
- var dom = editor.dom;
832
- var onlyText = isOnlyTextSelected(editor);
833
- var text = onlyText ? Optional.some(getAnchorText(editor.selection, anchor)) : Optional.none();
834
- var url = anchor.bind(function (anchorElm) { return Optional.from(dom.getAttrib(anchorElm, 'href')); });
835
- var target = anchor.bind(function (anchorElm) { return Optional.from(dom.getAttrib(anchorElm, 'target')); });
836
- var rel = anchor.bind(function (anchorElm) { return nonEmptyAttr(dom, anchorElm, 'rel'); });
837
- var linkClass = anchor.bind(function (anchorElm) { return nonEmptyAttr(dom, anchorElm, 'class'); });
838
- var title = anchor.bind(function (anchorElm) { return nonEmptyAttr(dom, anchorElm, 'title'); });
839
- return {
840
- url: url,
841
- text: text,
842
- title: title,
843
- target: target,
844
- rel: rel,
845
- linkClass: linkClass
846
- };
847
- };
848
- var collect = function (editor, linkNode) { return LinkListOptions.getLinks(editor).then(function (links) {
849
- var anchor = extractFromAnchor(editor, linkNode);
850
- return {
851
- anchor: anchor,
852
- catalogs: {
853
- targets: TargetOptions.getTargets(editor),
854
- rels: RelOptions.getRels(editor, anchor.target),
855
- classes: ClassListOptions.getClasses(editor),
856
- anchor: AnchorListOptions.getAnchors(editor),
857
- link: links
858
- },
859
- optNode: linkNode,
860
- flags: { titleEnabled: shouldShowLinkTitle(editor) }
861
- };
862
- }); };
863
- var DialogInfo = { collect: collect };
864
- var handleSubmit = function (editor, info) { return function (api) {
865
- var data = api.getData();
866
- if (!data.url.value) {
867
- unlink(editor);
868
- api.close();
869
- return;
870
- }
871
- var getChangedValue = function (key) { return Optional.from(data[key]).filter(function (value) { return !is(info.anchor[key], value); }); };
872
- var changedData = {
873
- href: data.url.value,
874
- text: getChangedValue('text'),
875
- target: getChangedValue('target'),
876
- rel: getChangedValue('rel'),
877
- class: getChangedValue('linkClass'),
878
- title: getChangedValue('title')
879
- };
880
- var attachState = {
881
- href: data.url.value,
882
- attach: data.url.meta !== undefined && data.url.meta.attach ? data.url.meta.attach : noop
883
- };
884
- DialogConfirms.preprocess(editor, changedData).then(function (pData) {
885
- link(editor, attachState, pData);
886
- });
887
- api.close();
888
- }; };
889
- var collectData = function (editor) {
890
- var anchorNode = getAnchorElement(editor);
891
- return DialogInfo.collect(editor, anchorNode);
892
- };
893
- var getInitialData = function (info, defaultTarget) {
894
- var anchor = info.anchor;
895
- var url = anchor.url.getOr('');
896
- return {
897
- url: {
898
- value: url,
899
- meta: { original: { value: url } }
900
- },
901
- text: anchor.text.getOr(''),
902
- title: anchor.title.getOr(''),
903
- anchor: url,
904
- link: url,
905
- rel: anchor.rel.getOr(''),
906
- target: anchor.target.or(defaultTarget).getOr(''),
907
- linkClass: anchor.linkClass.getOr('')
908
- };
909
- };
910
- var makeDialog = function (settings, onSubmit, editor) {
911
- var urlInput = [{
912
- name: 'url',
913
- type: 'urlinput',
914
- filetype: 'file',
915
- label: 'URL',
916
- picker_text: 'Browse links'
917
- }];
918
- var displayText = settings.anchor.text.map(function () { return ({
919
- name: 'text',
920
- type: 'input',
921
- label: 'Text to display'
922
- }); }).toArray();
923
- var titleText = settings.flags.titleEnabled ? [{
924
- name: 'title',
925
- type: 'input',
926
- label: 'Title'
927
- }] : [];
928
- var defaultTarget = Optional.from(getDefaultLinkTarget(editor));
929
- var initialData = getInitialData(settings, defaultTarget);
930
- var catalogs = settings.catalogs;
931
- var dialogDelta = DialogChanges.init(initialData, catalogs);
932
- var body = {
933
- type: 'panel',
934
- items: flatten([
935
- urlInput,
936
- displayText,
937
- titleText,
938
- cat([
939
- catalogs.anchor.map(ListOptions.createUi('anchor', 'Anchors')),
940
- catalogs.rels.map(ListOptions.createUi('rel', 'Rel')),
941
- catalogs.targets.map(ListOptions.createUi('target', 'Open link in...')),
942
- catalogs.link.map(ListOptions.createUi('link', 'Link list')),
943
- catalogs.classes.map(ListOptions.createUi('linkClass', 'Class'))
944
- ])
945
- ])
946
- };
947
- return {
948
- title: 'Insert/Edit Link',
949
- size: 'normal',
950
- body: body,
951
- buttons: [
952
- {
953
- type: 'cancel',
954
- name: 'cancel',
955
- text: 'Cancel'
956
- },
957
- {
958
- type: 'submit',
959
- name: 'save',
960
- text: 'Save',
961
- primary: true
962
- }
963
- ],
964
- initialData: initialData,
965
- onChange: function (api, _c) {
966
- var name = _c.name;
967
- dialogDelta.onChange(api.getData, { name: name }).each(function (newData) {
968
- api.setData(newData);
969
- });
970
- },
971
- onSubmit: onSubmit
972
- };
973
- };
974
- var open$1 = function (editor) {
975
- var data = collectData(editor);
976
- data.then(function (info) {
977
- var onSubmit = handleSubmit(editor, info);
978
- return makeDialog(info, onSubmit, editor);
979
- }).then(function (spec) {
980
- editor.windowManager.open(spec);
981
- });
982
- };
983
- var register = function (editor) {
984
- editor.addCommand('mceLink', function (_ui, value) {
985
- if ((value === null || value === void 0 ? void 0 : value.dialog) === true || !useQuickLink(editor)) {
986
- open$1(editor);
987
- }
988
- else {
989
- editor.dispatch('contexttoolbar-show', { toolbarKey: 'quicklink' });
990
- }
991
- });
992
- };
993
- var global = tinymce.util.Tools.resolve('tinymce.util.VK');
994
- var appendClickRemove = function (link, evt) {
995
- document.body.appendChild(link);
996
- link.dispatchEvent(evt);
997
- document.body.removeChild(link);
998
- };
999
- var open = function (url) {
1000
- var link = document.createElement('a');
1001
- link.target = '_blank';
1002
- link.href = url;
1003
- link.rel = 'noreferrer noopener';
1004
- var evt = document.createEvent('MouseEvents');
1005
- evt.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
1006
- appendClickRemove(link, evt);
1007
- };
1008
- var getLink = function (editor, elm) { return editor.dom.getParent(elm, 'a[href]'); };
1009
- var getSelectedLink = function (editor) { return getLink(editor, editor.selection.getStart()); };
1010
- var hasOnlyAltModifier = function (e) {
1011
- return e.altKey === true && e.shiftKey === false && e.ctrlKey === false && e.metaKey === false;
1012
- };
1013
- var gotoLink = function (editor, a) {
1014
- if (a) {
1015
- var href = getHref(a);
1016
- if (/^#/.test(href)) {
1017
- var targetEl = editor.dom.select(href);
1018
- if (targetEl.length) {
1019
- editor.selection.scrollIntoView(targetEl[0], true);
1020
- }
1021
- }
1022
- else {
1023
- open(a.href);
1024
- }
1025
- }
1026
- };
1027
- var openDialog = function (editor) { return function () {
1028
- editor.execCommand('mceLink', false, { dialog: true });
1029
- }; };
1030
- var gotoSelectedLink = function (editor) { return function () {
1031
- gotoLink(editor, getSelectedLink(editor));
1032
- }; };
1033
- var setupGotoLinks = function (editor) {
1034
- editor.on('click', function (e) {
1035
- var link = getLink(editor, e.target);
1036
- if (link && global.metaKeyPressed(e)) {
1037
- e.preventDefault();
1038
- gotoLink(editor, link);
1039
- }
1040
- });
1041
- editor.on('keydown', function (e) {
1042
- if (!e.isDefaultPrevented() && e.keyCode === 13 && hasOnlyAltModifier(e)) {
1043
- var link_1 = getSelectedLink(editor);
1044
- if (link_1) {
1045
- e.preventDefault();
1046
- gotoLink(editor, link_1);
1047
- }
1048
- }
1049
- });
1050
- };
1051
- var toggleState = function (editor, toggler) {
1052
- editor.on('NodeChange', toggler);
1053
- return function () { return editor.off('NodeChange', toggler); };
1054
- };
1055
- var toggleLinkState = function (editor) { return function (api) {
1056
- var updateState = function () {
1057
- api.setActive(!editor.mode.isReadOnly() && isInAnchor(editor, editor.selection.getNode()));
1058
- api.setEnabled(editor.selection.isEditable());
1059
- };
1060
- updateState();
1061
- return toggleState(editor, updateState);
1062
- }; };
1063
- var toggleLinkMenuState = function (editor) { return function (api) {
1064
- var updateState = function () {
1065
- api.setEnabled(editor.selection.isEditable());
1066
- };
1067
- updateState();
1068
- return toggleState(editor, updateState);
1069
- }; };
1070
- var hasExactlyOneLinkInSelection = function (editor) {
1071
- var links = editor.selection.isCollapsed() ? getLinks$1(editor.dom.getParents(editor.selection.getStart())) : getLinksInSelection(editor.selection.getRng());
1072
- return links.length === 1;
1073
- };
1074
- var toggleGotoLinkState = function (editor) { return function (api) {
1075
- var updateState = function () { return api.setEnabled(hasExactlyOneLinkInSelection(editor)); };
1076
- updateState();
1077
- return toggleState(editor, updateState);
1078
- }; };
1079
- var toggleUnlinkState = function (editor) { return function (api) {
1080
- var hasLinks$1 = function (parents) { return hasLinks(parents) || hasLinksInSelection(editor.selection.getRng()); };
1081
- var parents = editor.dom.getParents(editor.selection.getStart());
1082
- var updateEnabled = function (parents) {
1083
- api.setEnabled(hasLinks$1(parents) && editor.selection.isEditable());
1084
- };
1085
- updateEnabled(parents);
1086
- return toggleState(editor, function (e) { return updateEnabled(e.parents); });
1087
- }; };
1088
- var setup = function (editor) {
1089
- editor.addShortcut('Meta+K', '', function () {
1090
- editor.execCommand('mceLink');
1091
- });
1092
- };
1093
- var setupButtons = function (editor) {
1094
- editor.ui.registry.addToggleButton('link', {
1095
- icon: 'link',
1096
- tooltip: 'Insert/edit link',
1097
- onAction: openDialog(editor),
1098
- onSetup: toggleLinkState(editor)
1099
- });
1100
- editor.ui.registry.addButton('openlink', {
1101
- icon: 'new-tab',
1102
- tooltip: 'Open link',
1103
- onAction: gotoSelectedLink(editor),
1104
- onSetup: toggleGotoLinkState(editor)
1105
- });
1106
- editor.ui.registry.addButton('unlink', {
1107
- icon: 'unlink',
1108
- tooltip: 'Remove link',
1109
- onAction: function () { return unlink(editor); },
1110
- onSetup: toggleUnlinkState(editor)
1111
- });
1112
- };
1113
- var setupMenuItems = function (editor) {
1114
- editor.ui.registry.addMenuItem('openlink', {
1115
- text: 'Open link',
1116
- icon: 'new-tab',
1117
- onAction: gotoSelectedLink(editor),
1118
- onSetup: toggleGotoLinkState(editor)
1119
- });
1120
- editor.ui.registry.addMenuItem('link', {
1121
- icon: 'link',
1122
- text: 'Link...',
1123
- shortcut: 'Meta+K',
1124
- onSetup: toggleLinkMenuState(editor),
1125
- onAction: openDialog(editor)
1126
- });
1127
- editor.ui.registry.addMenuItem('unlink', {
1128
- icon: 'unlink',
1129
- text: 'Remove link',
1130
- onAction: function () { return unlink(editor); },
1131
- onSetup: toggleUnlinkState(editor)
1132
- });
1133
- };
1134
- var setupContextMenu = function (editor) {
1135
- var inLink = 'link unlink openlink';
1136
- var noLink = 'link';
1137
- editor.ui.registry.addContextMenu('link', {
1138
- update: function (element) {
1139
- var isEditable = editor.dom.isEditable(element);
1140
- if (!isEditable) {
1141
- return '';
1142
- }
1143
- return hasLinks(editor.dom.getParents(element, 'a')) ? inLink : noLink;
1144
- }
1145
- });
1146
- };
1147
- var setupContextToolbars = function (editor) {
1148
- var collapseSelectionToEnd = function (editor) {
1149
- editor.selection.collapse(false);
1150
- };
1151
- var onSetupLink = function (buttonApi) {
1152
- var node = editor.selection.getNode();
1153
- buttonApi.setEnabled(isInAnchor(editor, node));
1154
- return noop;
1155
- };
1156
- var getLinkText = function (value) {
1157
- var anchor = getAnchorElement(editor);
1158
- var onlyText = isOnlyTextSelected(editor);
1159
- if (anchor.isNone() && onlyText) {
1160
- var text = getAnchorText(editor.selection, anchor);
1161
- return someIf(text.length === 0, value);
1162
- }
1163
- else {
1164
- return Optional.none();
1165
- }
1166
- };
1167
- editor.ui.registry.addContextForm('quicklink', {
1168
- launch: {
1169
- type: 'contextformtogglebutton',
1170
- icon: 'link',
1171
- tooltip: 'Link',
1172
- onSetup: toggleLinkState(editor)
1173
- },
1174
- label: 'Link',
1175
- predicate: function (node) { return hasContextToolbar(editor) && isInAnchor(editor, node); },
1176
- initValue: function () {
1177
- var elm = getAnchorElement(editor);
1178
- return elm.fold(constant(''), getHref);
1179
- },
1180
- commands: [
1181
- {
1182
- type: 'contextformtogglebutton',
1183
- icon: 'link',
1184
- tooltip: 'Link',
1185
- primary: true,
1186
- onSetup: function (buttonApi) {
1187
- var node = editor.selection.getNode();
1188
- buttonApi.setActive(isInAnchor(editor, node));
1189
- return toggleLinkState(editor)(buttonApi);
1190
- },
1191
- onAction: function (formApi) {
1192
- var value = formApi.getValue();
1193
- var text = getLinkText(value);
1194
- var attachState = {
1195
- href: value,
1196
- attach: noop
1197
- };
1198
- link(editor, attachState, {
1199
- href: value,
1200
- text: text,
1201
- title: Optional.none(),
1202
- rel: Optional.none(),
1203
- target: Optional.none(),
1204
- class: Optional.none()
1205
- });
1206
- collapseSelectionToEnd(editor);
1207
- formApi.hide();
1208
- }
1209
- },
1210
- {
1211
- type: 'contextformbutton',
1212
- icon: 'unlink',
1213
- tooltip: 'Remove link',
1214
- onSetup: onSetupLink,
1215
- onAction: function (formApi) {
1216
- unlink(editor);
1217
- formApi.hide();
1218
- }
1219
- },
1220
- {
1221
- type: 'contextformbutton',
1222
- icon: 'new-tab',
1223
- tooltip: 'Open link',
1224
- onSetup: onSetupLink,
1225
- onAction: function (formApi) {
1226
- gotoSelectedLink(editor)();
1227
- formApi.hide();
1228
- }
1229
- }
1230
- ]
1231
- });
1232
- };
1233
- var Plugin = function () {
1234
- global$5.add('link', function (editor) {
1235
- register$1(editor);
1236
- setupButtons(editor);
1237
- setupMenuItems(editor);
1238
- setupContextMenu(editor);
1239
- setupContextToolbars(editor);
1240
- setupGotoLinks(editor);
1241
- register(editor);
1242
- setup(editor);
1243
- });
1244
- };
1245
- Plugin();
1246
- })();