fx-platform-ui 0.0.13-alpha15 → 0.0.13-alpha17

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