@enos5/enos-vue-default 1.8.15 → 1.8.17

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 (51) hide show
  1. package/dist/code-Ber986DY.js +87 -0
  2. package/dist/code-Ber986DY.js.map +1 -0
  3. package/dist/components/TableList.vue.d.ts +11 -0
  4. package/dist/components/TableListForm.vue.d.ts +11 -0
  5. package/dist/components/TableSearch.vue.d.ts +11 -0
  6. package/dist/default-CIJCtYmL.js +276 -0
  7. package/dist/default-CIJCtYmL.js.map +1 -0
  8. package/dist/dom-DNRnXSoJ.js +7016 -0
  9. package/dist/dom-DNRnXSoJ.js.map +1 -0
  10. package/dist/image-BBEGvs_X.js +1408 -0
  11. package/dist/image-BBEGvs_X.js.map +1 -0
  12. package/dist/index.js +2 -62
  13. package/dist/index.node.js +2 -62
  14. package/dist/link-BCKWs7cm.js +1421 -0
  15. package/dist/link-BCKWs7cm.js.map +1 -0
  16. package/dist/lists-DO3bIHZE.js +496 -0
  17. package/dist/lists-DO3bIHZE.js.map +1 -0
  18. package/dist/plugin-DyVd9Eh7.js +6258 -0
  19. package/dist/plugin-DyVd9Eh7.js.map +1 -0
  20. package/dist/silver-DMBzT-QW.js +28483 -0
  21. package/dist/silver-DMBzT-QW.js.map +1 -0
  22. package/dist/styles.css +30 -0
  23. package/dist/table-CAjD5lLC.js +3169 -0
  24. package/dist/table-CAjD5lLC.js.map +1 -0
  25. package/dist/tinymce-DQF9Ibks.js +33699 -0
  26. package/dist/tinymce-DQF9Ibks.js.map +1 -0
  27. package/package.json +1 -1
  28. package/dist/_commonjsHelpers-CUmg6egw.js +0 -7
  29. package/dist/_commonjsHelpers-CUmg6egw.js.map +0 -1
  30. package/dist/index-1G1T4Qrv.js +0 -31373
  31. package/dist/index-1G1T4Qrv.js.map +0 -1
  32. package/dist/index-BBGZQp5w.js +0 -7816
  33. package/dist/index-BBGZQp5w.js.map +0 -1
  34. package/dist/index-BR_u7CCm.js +0 -3351
  35. package/dist/index-BR_u7CCm.js.map +0 -1
  36. package/dist/index-Bsqrrc8R.js +0 -315
  37. package/dist/index-Bsqrrc8R.js.map +0 -1
  38. package/dist/index-CiFpmPug.js +0 -122
  39. package/dist/index-CiFpmPug.js.map +0 -1
  40. package/dist/index-CuSlJQwq.js +0 -1581
  41. package/dist/index-CuSlJQwq.js.map +0 -1
  42. package/dist/index-D72Leh_x.js +0 -573
  43. package/dist/index-D72Leh_x.js.map +0 -1
  44. package/dist/index-ukywSRmc.js +0 -1581
  45. package/dist/index-ukywSRmc.js.map +0 -1
  46. package/dist/index.js.map +0 -1
  47. package/dist/index.node.js.map +0 -1
  48. package/dist/plugin-DGM-XlRe.js +0 -6545
  49. package/dist/plugin-DGM-XlRe.js.map +0 -1
  50. package/dist/tinymce-Dg510HCs.js +0 -35756
  51. package/dist/tinymce-Dg510HCs.js.map +0 -1
@@ -0,0 +1,1421 @@
1
+ import { at as __commonJSMin } from "./plugin-DyVd9Eh7.js";
2
+ //#endregion
3
+ //#region ../../node_modules/tinymce/plugins/link/index.js
4
+ (/* @__PURE__ */ __commonJSMin((() => {
5
+ /**
6
+ * TinyMCE version 8.6.0 (2026-06-03)
7
+ */
8
+ (function() {
9
+ "use strict";
10
+ var global$5 = tinymce.util.Tools.resolve("tinymce.PluginManager");
11
+ const hasProto = (v, constructor, predicate) => {
12
+ if (predicate(v, constructor.prototype)) return true;
13
+ else return v.constructor?.name === constructor.name;
14
+ };
15
+ const typeOf = (x) => {
16
+ const t = typeof x;
17
+ if (x === null) return "null";
18
+ else if (t === "object" && Array.isArray(x)) return "array";
19
+ else if (t === "object" && hasProto(x, String, (o, proto) => proto.isPrototypeOf(o))) return "string";
20
+ else return t;
21
+ };
22
+ const isType = (type) => (value) => typeOf(value) === type;
23
+ const isSimpleType = (type) => (value) => typeof value === type;
24
+ const eq = (t) => (a) => t === a;
25
+ const isString = isType("string");
26
+ const isObject = isType("object");
27
+ const isArray = isType("array");
28
+ const isNull = eq(null);
29
+ const isBoolean = isSimpleType("boolean");
30
+ const isNullable = (a) => a === null || a === void 0;
31
+ const isNonNullable = (a) => !isNullable(a);
32
+ const isFunction = isSimpleType("function");
33
+ const isArrayOf = (value, pred) => {
34
+ if (isArray(value)) {
35
+ for (let i = 0, len = value.length; i < len; ++i) if (!pred(value[i])) return false;
36
+ return true;
37
+ }
38
+ return false;
39
+ };
40
+ const noop = () => {};
41
+ const constant = (value) => {
42
+ return () => {
43
+ return value;
44
+ };
45
+ };
46
+ const identity = (x) => {
47
+ return x;
48
+ };
49
+ const tripleEquals = (a, b) => {
50
+ return a === b;
51
+ };
52
+ /**
53
+ * The `Optional` type represents a value (of any type) that potentially does
54
+ * not exist. Any `Optional<T>` can either be a `Some<T>` (in which case the
55
+ * value does exist) or a `None` (in which case the value does not exist). This
56
+ * module defines a whole lot of FP-inspired utility functions for dealing with
57
+ * `Optional` objects.
58
+ *
59
+ * Comparison with null or undefined:
60
+ * - We don't get fancy null coalescing operators with `Optional`
61
+ * - We do get fancy helper functions with `Optional`
62
+ * - `Optional` support nesting, and allow for the type to still be nullable (or
63
+ * another `Optional`)
64
+ * - There is no option to turn off strict-optional-checks like there is for
65
+ * strict-null-checks
66
+ */
67
+ class Optional {
68
+ tag;
69
+ value;
70
+ static singletonNone = new Optional(false);
71
+ constructor(tag, value) {
72
+ this.tag = tag;
73
+ this.value = value;
74
+ }
75
+ /**
76
+ * Creates a new `Optional<T>` that **does** contain a value.
77
+ */
78
+ static some(value) {
79
+ return new Optional(true, value);
80
+ }
81
+ /**
82
+ * Create a new `Optional<T>` that **does not** contain a value. `T` can be
83
+ * any type because we don't actually have a `T`.
84
+ */
85
+ static none() {
86
+ return Optional.singletonNone;
87
+ }
88
+ /**
89
+ * Perform a transform on an `Optional` type. Regardless of whether this
90
+ * `Optional` contains a value or not, `fold` will return a value of type `U`.
91
+ * If this `Optional` does not contain a value, the `U` will be created by
92
+ * calling `onNone`. If this `Optional` does contain a value, the `U` will be
93
+ * created by calling `onSome`.
94
+ *
95
+ * For the FP enthusiasts in the room, this function:
96
+ * 1. Could be used to implement all of the functions below
97
+ * 2. Forms a catamorphism
98
+ */
99
+ fold(onNone, onSome) {
100
+ if (this.tag) return onSome(this.value);
101
+ else return onNone();
102
+ }
103
+ /**
104
+ * Determine if this `Optional` object contains a value.
105
+ */
106
+ isSome() {
107
+ return this.tag;
108
+ }
109
+ /**
110
+ * Determine if this `Optional` object **does not** contain a value.
111
+ */
112
+ isNone() {
113
+ return !this.tag;
114
+ }
115
+ /**
116
+ * Perform a transform on an `Optional` object, **if** there is a value. If
117
+ * you provide a function to turn a T into a U, this is the function you use
118
+ * to turn an `Optional<T>` into an `Optional<U>`. If this **does** contain
119
+ * a value then the output will also contain a value (that value being the
120
+ * output of `mapper(this.value)`), and if this **does not** contain a value
121
+ * then neither will the output.
122
+ */
123
+ map(mapper) {
124
+ if (this.tag) return Optional.some(mapper(this.value));
125
+ else return Optional.none();
126
+ }
127
+ /**
128
+ * Perform a transform on an `Optional` object, **if** there is a value.
129
+ * Unlike `map`, here the transform itself also returns an `Optional`.
130
+ */
131
+ bind(binder) {
132
+ if (this.tag) return binder(this.value);
133
+ else return Optional.none();
134
+ }
135
+ /**
136
+ * For a given predicate, this function finds out if there **exists** a value
137
+ * inside this `Optional` object that meets the predicate. In practice, this
138
+ * means that for `Optional`s that do not contain a value it returns false (as
139
+ * no predicate-meeting value exists).
140
+ */
141
+ exists(predicate) {
142
+ return this.tag && predicate(this.value);
143
+ }
144
+ /**
145
+ * For a given predicate, this function finds out if **all** the values inside
146
+ * this `Optional` object meet the predicate. In practice, this means that
147
+ * for `Optional`s that do not contain a value it returns true (as all 0
148
+ * objects do meet the predicate).
149
+ */
150
+ forall(predicate) {
151
+ return !this.tag || predicate(this.value);
152
+ }
153
+ filter(predicate) {
154
+ if (!this.tag || predicate(this.value)) return this;
155
+ else return Optional.none();
156
+ }
157
+ /**
158
+ * Get the value out of the inside of the `Optional` object, using a default
159
+ * `replacement` value if the provided `Optional` object does not contain a
160
+ * value.
161
+ */
162
+ getOr(replacement) {
163
+ return this.tag ? this.value : replacement;
164
+ }
165
+ /**
166
+ * Get the value out of the inside of the `Optional` object, using a default
167
+ * `replacement` value if the provided `Optional` object does not contain a
168
+ * value. Unlike `getOr`, in this method the `replacement` object is also
169
+ * `Optional` - meaning that this method will always return an `Optional`.
170
+ */
171
+ or(replacement) {
172
+ return this.tag ? this : replacement;
173
+ }
174
+ /**
175
+ * Get the value out of the inside of the `Optional` object, using a default
176
+ * `replacement` value if the provided `Optional` object does not contain a
177
+ * value. Unlike `getOr`, in this method the `replacement` value is
178
+ * "thunked" - that is to say that you don't pass a value to `getOrThunk`, you
179
+ * pass a function which (if called) will **return** the `value` you want to
180
+ * use.
181
+ */
182
+ getOrThunk(thunk) {
183
+ return this.tag ? this.value : thunk();
184
+ }
185
+ /**
186
+ * Get the value out of the inside of the `Optional` object, using a default
187
+ * `replacement` value if the provided Optional object does not contain a
188
+ * value.
189
+ *
190
+ * Unlike `or`, in this method the `replacement` value is "thunked" - that is
191
+ * to say that you don't pass a value to `orThunk`, you pass a function which
192
+ * (if called) will **return** the `value` you want to use.
193
+ *
194
+ * Unlike `getOrThunk`, in this method the `replacement` value is also
195
+ * `Optional`, meaning that this method will always return an `Optional`.
196
+ */
197
+ orThunk(thunk) {
198
+ return this.tag ? this : thunk();
199
+ }
200
+ /**
201
+ * Get the value out of the inside of the `Optional` object, throwing an
202
+ * exception if the provided `Optional` object does not contain a value.
203
+ *
204
+ * WARNING:
205
+ * You should only be using this function if you know that the `Optional`
206
+ * object **is not** empty (otherwise you're throwing exceptions in production
207
+ * code, which is bad).
208
+ *
209
+ * In tests this is more acceptable.
210
+ *
211
+ * Prefer other methods to this, such as `.each`.
212
+ */
213
+ getOrDie(message) {
214
+ if (!this.tag) throw new Error(message ?? "Called getOrDie on None");
215
+ else return this.value;
216
+ }
217
+ /**
218
+ * Creates an `Optional` value from a nullable (or undefined-able) input.
219
+ * Null, or undefined, is converted to `None`, and anything else is converted
220
+ * to `Some`.
221
+ */
222
+ static from(value) {
223
+ return isNonNullable(value) ? Optional.some(value) : Optional.none();
224
+ }
225
+ /**
226
+ * Converts an `Optional` to a nullable type, by getting the value if it
227
+ * exists, or returning `null` if it does not.
228
+ */
229
+ getOrNull() {
230
+ return this.tag ? this.value : null;
231
+ }
232
+ /**
233
+ * Converts an `Optional` to an undefined-able type, by getting the value if
234
+ * it exists, or returning `undefined` if it does not.
235
+ */
236
+ getOrUndefined() {
237
+ return this.value;
238
+ }
239
+ /**
240
+ * If the `Optional` contains a value, perform an action on that value.
241
+ * Unlike the rest of the methods on this type, `.each` has side-effects. If
242
+ * you want to transform an `Optional<T>` **into** something, then this is not
243
+ * the method for you. If you want to use an `Optional<T>` to **do**
244
+ * something, then this is the method for you - provided you're okay with not
245
+ * doing anything in the case where the `Optional` doesn't have a value inside
246
+ * it. If you're not sure whether your use-case fits into transforming
247
+ * **into** something or **doing** something, check whether it has a return
248
+ * value. If it does, you should be performing a transform.
249
+ */
250
+ each(worker) {
251
+ if (this.tag) worker(this.value);
252
+ }
253
+ /**
254
+ * Turn the `Optional` object into an array that contains all of the values
255
+ * stored inside the `Optional`. In practice, this means the output will have
256
+ * either 0 or 1 elements.
257
+ */
258
+ toArray() {
259
+ return this.tag ? [this.value] : [];
260
+ }
261
+ /**
262
+ * Turn the `Optional` object into a string for debugging or printing. Not
263
+ * recommended for production code, but good for debugging. Also note that
264
+ * these days an `Optional` object can be logged to the console directly, and
265
+ * its inner value (if it exists) will be visible.
266
+ */
267
+ toString() {
268
+ return this.tag ? `some(${this.value})` : "none()";
269
+ }
270
+ }
271
+ Array.prototype.slice;
272
+ const nativeIndexOf = Array.prototype.indexOf;
273
+ const nativePush = Array.prototype.push;
274
+ const rawIndexOf = (ts, t) => nativeIndexOf.call(ts, t);
275
+ const contains = (xs, x) => rawIndexOf(xs, x) > -1;
276
+ const map = (xs, f) => {
277
+ const len = xs.length;
278
+ const r = new Array(len);
279
+ for (let i = 0; i < len; i++) {
280
+ const x = xs[i];
281
+ r[i] = f(x, i);
282
+ }
283
+ return r;
284
+ };
285
+ const each$1 = (xs, f) => {
286
+ for (let i = 0, len = xs.length; i < len; i++) {
287
+ const x = xs[i];
288
+ f(x, i);
289
+ }
290
+ };
291
+ const foldl = (xs, f, acc) => {
292
+ each$1(xs, (x, i) => {
293
+ acc = f(acc, x, i);
294
+ });
295
+ return acc;
296
+ };
297
+ const flatten = (xs) => {
298
+ const r = [];
299
+ for (let i = 0, len = xs.length; i < len; ++i) {
300
+ if (!isArray(xs[i])) throw new Error("Arr.flatten item " + i + " was not an array, input: " + xs);
301
+ nativePush.apply(r, xs[i]);
302
+ }
303
+ return r;
304
+ };
305
+ const bind = (xs, f) => flatten(map(xs, f));
306
+ const get = (xs, i) => i >= 0 && i < xs.length ? Optional.some(xs[i]) : Optional.none();
307
+ const head = (xs) => get(xs, 0);
308
+ isFunction(Array.from) && Array.from;
309
+ const findMap = (arr, f) => {
310
+ for (let i = 0; i < arr.length; i++) {
311
+ const r = f(arr[i], i);
312
+ if (r.isSome()) return r;
313
+ }
314
+ return Optional.none();
315
+ };
316
+ const keys = Object.keys;
317
+ const hasOwnProperty = Object.hasOwnProperty;
318
+ const each = (obj, f) => {
319
+ const props = keys(obj);
320
+ for (let k = 0, len = props.length; k < len; k++) {
321
+ const i = props[k];
322
+ const x = obj[i];
323
+ f(x, i);
324
+ }
325
+ };
326
+ const objAcc = (r) => (x, i) => {
327
+ r[i] = x;
328
+ };
329
+ const internalFilter = (obj, pred, onTrue, onFalse) => {
330
+ each(obj, (x, i) => {
331
+ (pred(x, i) ? onTrue : onFalse)(x, i);
332
+ });
333
+ };
334
+ const filter = (obj, pred) => {
335
+ const t = {};
336
+ internalFilter(obj, pred, objAcc(t), noop);
337
+ return t;
338
+ };
339
+ const has = (obj, key) => hasOwnProperty.call(obj, key);
340
+ const hasNonNullableKey = (obj, key) => has(obj, key) && obj[key] !== void 0 && obj[key] !== null;
341
+ const Cell = (initial) => {
342
+ let value = initial;
343
+ const get = () => {
344
+ return value;
345
+ };
346
+ const set = (v) => {
347
+ value = v;
348
+ };
349
+ return {
350
+ get,
351
+ set
352
+ };
353
+ };
354
+ /**
355
+ * **Is** the value stored inside this Optional object equal to `rhs`?
356
+ */
357
+ const is = (lhs, rhs, comparator = tripleEquals) => lhs.exists((left) => comparator(left, rhs));
358
+ const cat = (arr) => {
359
+ const r = [];
360
+ const push = (x) => {
361
+ r.push(x);
362
+ };
363
+ for (let i = 0; i < arr.length; i++) arr[i].each(push);
364
+ return r;
365
+ };
366
+ const someIf = (b, a) => b ? Optional.some(a) : Optional.none();
367
+ const singleton = (doRevoke) => {
368
+ const subject = Cell(Optional.none());
369
+ const revoke = () => subject.get().each(doRevoke);
370
+ const clear = () => {
371
+ revoke();
372
+ subject.set(Optional.none());
373
+ };
374
+ const isSet = () => subject.get().isSome();
375
+ const get = () => subject.get();
376
+ const set = (s) => {
377
+ revoke();
378
+ subject.set(Optional.some(s));
379
+ };
380
+ return {
381
+ clear,
382
+ isSet,
383
+ get,
384
+ set
385
+ };
386
+ };
387
+ const value = () => {
388
+ const subject = singleton(noop);
389
+ const on = (f) => subject.get().each(f);
390
+ return {
391
+ ...subject,
392
+ on
393
+ };
394
+ };
395
+ const removeFromStart = (str, numChars) => {
396
+ return str.substring(numChars);
397
+ };
398
+ const checkRange = (str, substr, start) => substr === "" || str.length >= substr.length && str.substr(start, start + substr.length) === substr;
399
+ const removeLeading = (str, prefix) => {
400
+ return startsWith(str, prefix) ? removeFromStart(str, prefix.length) : str;
401
+ };
402
+ /** Does 'str' start with 'prefix'?
403
+ * Note: all strings start with the empty string.
404
+ * More formally, for all strings x, startsWith(x, "").
405
+ * This is so that for all strings x and y, startsWith(y + x, y)
406
+ */
407
+ const startsWith = (str, prefix) => {
408
+ return checkRange(str, prefix, 0);
409
+ };
410
+ const option = (name) => (editor) => editor.options.get(name);
411
+ const register$1 = (editor) => {
412
+ const registerOption = editor.options.register;
413
+ registerOption("link_assume_external_targets", {
414
+ processor: (value) => {
415
+ const valid = isString(value) || isBoolean(value);
416
+ if (valid) if (value === true) return {
417
+ value: 1,
418
+ valid
419
+ };
420
+ else if (value === "http" || value === "https") return {
421
+ value,
422
+ valid
423
+ };
424
+ else return {
425
+ value: 0,
426
+ valid
427
+ };
428
+ else return {
429
+ valid: false,
430
+ message: "Must be a string or a boolean."
431
+ };
432
+ },
433
+ default: false
434
+ });
435
+ registerOption("link_context_toolbar", {
436
+ processor: "boolean",
437
+ default: false
438
+ });
439
+ registerOption("link_list", { processor: (value) => isString(value) || isFunction(value) || isArrayOf(value, isObject) });
440
+ registerOption("link_default_target", { processor: "string" });
441
+ registerOption("link_default_protocol", {
442
+ processor: "string",
443
+ default: "https"
444
+ });
445
+ registerOption("link_target_list", {
446
+ processor: (value) => isBoolean(value) || isArrayOf(value, isObject),
447
+ default: true
448
+ });
449
+ registerOption("link_rel_list", {
450
+ processor: "object[]",
451
+ default: []
452
+ });
453
+ registerOption("link_class_list", {
454
+ processor: "object[]",
455
+ default: []
456
+ });
457
+ registerOption("link_title", {
458
+ processor: "boolean",
459
+ default: true
460
+ });
461
+ registerOption("allow_unsafe_link_target", {
462
+ processor: "boolean",
463
+ default: false
464
+ });
465
+ registerOption("link_quicklink", {
466
+ processor: "boolean",
467
+ default: false
468
+ });
469
+ registerOption("link_attributes_postprocess", { processor: "function" });
470
+ registerOption("files_upload_handler", { processor: "function" });
471
+ registerOption("link_uploadtab", {
472
+ processor: "boolean",
473
+ default: true
474
+ });
475
+ };
476
+ const assumeExternalTargets = option("link_assume_external_targets");
477
+ const hasContextToolbar = option("link_context_toolbar");
478
+ const getLinkList = option("link_list");
479
+ const getDefaultLinkTarget = option("link_default_target");
480
+ const getDefaultLinkProtocol = option("link_default_protocol");
481
+ const getTargetList = option("link_target_list");
482
+ const getRelList = option("link_rel_list");
483
+ const getLinkClassList = option("link_class_list");
484
+ const shouldShowLinkTitle = option("link_title");
485
+ const allowUnsafeLinkTarget = option("allow_unsafe_link_target");
486
+ const useQuickLink = option("link_quicklink");
487
+ const attributesPostProcess = option("link_attributes_postprocess");
488
+ const getFilesUploadHandler = option("files_upload_handler");
489
+ const hasLinkUploadtab = option("link_uploadtab");
490
+ const getDocumentsFileTypes = option("documents_file_types");
491
+ const hasFilesUploadHandler = (editor) => isNonNullable(editor.options.get("files_upload_handler"));
492
+ const hasDocumentsFileTypes = (editor) => isNonNullable(editor.options.get("documents_file_types"));
493
+ var global$4 = tinymce.util.Tools.resolve("tinymce.util.URI");
494
+ var global$3 = tinymce.util.Tools.resolve("tinymce.dom.TreeWalker");
495
+ var global$2 = tinymce.util.Tools.resolve("tinymce.util.Tools");
496
+ const isAnchor = (elm) => isNonNullable(elm) && elm.nodeName.toLowerCase() === "a";
497
+ const isLink = (elm) => isAnchor(elm) && !!getHref(elm);
498
+ const collectNodesInRange = (rng, predicate) => {
499
+ if (rng.collapsed) return [];
500
+ else {
501
+ const contents = rng.cloneContents();
502
+ const firstChild = contents.firstChild;
503
+ const walker = new global$3(firstChild, contents);
504
+ const elements = [];
505
+ let current = firstChild;
506
+ do
507
+ if (predicate(current)) elements.push(current);
508
+ while (current = walker.next());
509
+ return elements;
510
+ }
511
+ };
512
+ const hasProtocol = (url) => /^\w+:/i.test(url);
513
+ const getHref = (elm) => {
514
+ return elm.getAttribute("data-mce-href") ?? elm.getAttribute("href") ?? "";
515
+ };
516
+ const applyRelTargetRules = (rel, isUnsafe) => {
517
+ const rules = ["noopener"];
518
+ const rels = rel ? rel.split(/\s+/) : [];
519
+ const toString = (rels) => global$2.trim(rels.sort().join(" "));
520
+ const addTargetRules = (rels) => {
521
+ rels = removeTargetRules(rels);
522
+ return rels.length > 0 ? rels.concat(rules) : rules;
523
+ };
524
+ const removeTargetRules = (rels) => rels.filter((val) => global$2.inArray(rules, val) === -1);
525
+ const newRels = isUnsafe ? addTargetRules(rels) : removeTargetRules(rels);
526
+ return newRels.length > 0 ? toString(newRels) : "";
527
+ };
528
+ const trimCaretContainers = (text) => text.replace(/\uFEFF/g, "");
529
+ const getAnchorElement = (editor, selectedElm) => {
530
+ selectedElm = selectedElm || getLinksInSelection(editor.selection.getRng())[0] || editor.selection.getNode();
531
+ if (isImageFigure(selectedElm)) return Optional.from(editor.dom.select("a[href]", selectedElm)[0]);
532
+ else return Optional.from(editor.dom.getParent(selectedElm, "a[href]"));
533
+ };
534
+ const isInAnchor = (editor, selectedElm) => getAnchorElement(editor, selectedElm).isSome();
535
+ const getAnchorText = (selection, anchorElm) => {
536
+ return trimCaretContainers(anchorElm.fold(() => selection.getContent({ format: "text" }), (anchorElm) => anchorElm.innerText || anchorElm.textContent || ""));
537
+ };
538
+ const getLinksInSelection = (rng) => collectNodesInRange(rng, isLink);
539
+ const getLinks$1 = (elements) => global$2.grep(elements, isLink);
540
+ const hasLinks = (elements) => getLinks$1(elements).length > 0;
541
+ const hasLinksInSelection = (rng) => getLinksInSelection(rng).length > 0;
542
+ const isOnlyTextSelected = (editor) => {
543
+ const inlineTextElements = editor.schema.getTextInlineElements();
544
+ const isElement = (elm) => elm.nodeType === 1 && !isAnchor(elm) && !has(inlineTextElements, elm.nodeName.toLowerCase());
545
+ if (getAnchorElement(editor).exists((anchor) => anchor.hasAttribute("data-mce-block"))) return false;
546
+ const rng = editor.selection.getRng();
547
+ if (!rng.collapsed) return collectNodesInRange(rng, isElement).length === 0;
548
+ else return true;
549
+ };
550
+ const isImageFigure = (elm) => isNonNullable(elm) && elm.nodeName === "FIGURE" && /\bimage\b/i.test(elm.className);
551
+ const blobToDataUri = (blob) => new Promise((resolve, reject) => {
552
+ const reader = new FileReader();
553
+ reader.onload = () => {
554
+ resolve(reader.result);
555
+ };
556
+ reader.onerror = () => {
557
+ reject(new Error(reader.error?.message ?? "Failed to convert blob to a data url"));
558
+ };
559
+ reader.readAsDataURL(blob);
560
+ });
561
+ const getLinkAttrs = (data) => {
562
+ return foldl([
563
+ "title",
564
+ "rel",
565
+ "class",
566
+ "target"
567
+ ], (acc, key) => {
568
+ data[key].each((value) => {
569
+ acc[key] = value.length > 0 ? value : null;
570
+ });
571
+ return acc;
572
+ }, { href: data.href });
573
+ };
574
+ const handleExternalTargets = (href, assumeExternalTargets) => {
575
+ if ((assumeExternalTargets === "http" || assumeExternalTargets === "https") && !hasProtocol(href)) return assumeExternalTargets + "://" + href;
576
+ return href;
577
+ };
578
+ const applyLinkOverrides = (editor, linkAttrs) => {
579
+ const newLinkAttrs = { ...linkAttrs };
580
+ if (getRelList(editor).length === 0 && !allowUnsafeLinkTarget(editor)) {
581
+ const newRel = applyRelTargetRules(newLinkAttrs.rel, newLinkAttrs.target === "_blank");
582
+ newLinkAttrs.rel = newRel ? newRel : null;
583
+ }
584
+ if (Optional.from(newLinkAttrs.target).isNone() && getTargetList(editor) === false) newLinkAttrs.target = getDefaultLinkTarget(editor);
585
+ newLinkAttrs.href = handleExternalTargets(newLinkAttrs.href, assumeExternalTargets(editor));
586
+ return newLinkAttrs;
587
+ };
588
+ const updateLink = (editor, anchorElm, text, linkAttrs) => {
589
+ text.each((text) => {
590
+ if (has(anchorElm, "innerText")) anchorElm.innerText = text;
591
+ else anchorElm.textContent = text;
592
+ });
593
+ editor.dom.setAttribs(anchorElm, linkAttrs);
594
+ const rng = editor.dom.createRng();
595
+ rng.setStartAfter(anchorElm);
596
+ rng.setEndAfter(anchorElm);
597
+ editor.selection.setRng(rng);
598
+ };
599
+ const createLink = (editor, selectedElm, text, linkAttrs) => {
600
+ const dom = editor.dom;
601
+ if (isImageFigure(selectedElm)) linkImageFigure(dom, selectedElm, linkAttrs);
602
+ else text.fold(() => {
603
+ editor.execCommand("mceInsertLink", false, linkAttrs);
604
+ const end = editor.selection.getEnd();
605
+ const rng = dom.createRng();
606
+ rng.setStartAfter(end);
607
+ rng.setEndAfter(end);
608
+ editor.selection.setRng(rng);
609
+ }, (text) => {
610
+ editor.insertContent(dom.createHTML("a", linkAttrs, dom.encode(text)));
611
+ });
612
+ };
613
+ const linkDomMutation = (editor, attachState, data) => {
614
+ const selectedElm = editor.selection.getNode();
615
+ const anchorElm = getAnchorElement(editor, selectedElm);
616
+ const linkAttrs = applyLinkOverrides(editor, getLinkAttrs(data));
617
+ const attributesPostProcess$1 = attributesPostProcess(editor);
618
+ if (isNonNullable(attributesPostProcess$1)) attributesPostProcess$1(linkAttrs);
619
+ editor.undoManager.transact(() => {
620
+ if (data.href === attachState.href) attachState.attach();
621
+ anchorElm.fold(() => {
622
+ createLink(editor, selectedElm, data.text, linkAttrs);
623
+ }, (elm) => {
624
+ editor.focus();
625
+ updateLink(editor, elm, data.text, linkAttrs);
626
+ });
627
+ });
628
+ };
629
+ const unlinkSelection = (editor) => {
630
+ const dom = editor.dom, selection = editor.selection;
631
+ const rng = selection.getRng().cloneRange();
632
+ const bookmark = selection.getBookmark();
633
+ const startAnchorElm = dom.getParent(rng.startContainer, "a[href]", editor.getBody());
634
+ const endAnchorElm = dom.getParent(rng.endContainer, "a[href]", editor.getBody());
635
+ if (startAnchorElm) rng.setStartBefore(startAnchorElm);
636
+ if (endAnchorElm) rng.setEndAfter(endAnchorElm);
637
+ selection.setRng(rng);
638
+ editor.execCommand("unlink");
639
+ selection.moveToBookmark(bookmark);
640
+ };
641
+ const unlinkDomMutation = (editor) => {
642
+ editor.undoManager.transact(() => {
643
+ const node = editor.selection.getNode();
644
+ if (isImageFigure(node)) unlinkImageFigure(editor, node);
645
+ else unlinkSelection(editor);
646
+ editor.focus();
647
+ });
648
+ };
649
+ const unwrapOptions = (data) => {
650
+ const { class: cls, href, rel, target, text, title } = data;
651
+ return filter({
652
+ class: cls.getOrNull(),
653
+ href,
654
+ rel: rel.getOrNull(),
655
+ target: target.getOrNull(),
656
+ text: text.getOrNull(),
657
+ title: title.getOrNull()
658
+ }, (v, _k) => isNull(v) === false);
659
+ };
660
+ const sanitizeData = (editor, data) => {
661
+ const getOption = editor.options.get;
662
+ const uriOptions = {
663
+ allow_html_data_urls: getOption("allow_html_data_urls"),
664
+ allow_script_urls: getOption("allow_script_urls"),
665
+ allow_svg_data_urls: getOption("allow_svg_data_urls")
666
+ };
667
+ const href = data.href;
668
+ return {
669
+ ...data,
670
+ href: global$4.isDomSafe(href, "a", uriOptions) ? href : ""
671
+ };
672
+ };
673
+ const link = (editor, attachState, data) => {
674
+ const sanitizedData = sanitizeData(editor, data);
675
+ editor.hasPlugin("rtc", true) ? editor.execCommand("createlink", false, unwrapOptions(sanitizedData)) : linkDomMutation(editor, attachState, sanitizedData);
676
+ };
677
+ const unlink = (editor) => {
678
+ editor.hasPlugin("rtc", true) ? editor.execCommand("unlink") : unlinkDomMutation(editor);
679
+ };
680
+ const unlinkImageFigure = (editor, fig) => {
681
+ const img = editor.dom.select("img", fig)[0];
682
+ if (img) {
683
+ const a = editor.dom.getParents(img, "a[href]", fig)[0];
684
+ if (a) {
685
+ a.parentNode?.insertBefore(img, a);
686
+ editor.dom.remove(a);
687
+ }
688
+ }
689
+ };
690
+ const linkImageFigure = (dom, fig, attrs) => {
691
+ const img = dom.select("img", fig)[0];
692
+ if (img) {
693
+ const a = dom.create("a", attrs);
694
+ img.parentNode?.insertBefore(a, img);
695
+ a.appendChild(img);
696
+ }
697
+ };
698
+ const getValue = (item) => isString(item.value) ? item.value : "";
699
+ const getText = (item) => {
700
+ if (isString(item.text)) return item.text;
701
+ else if (isString(item.title)) return item.title;
702
+ else return "";
703
+ };
704
+ const sanitizeList = (list, extractValue) => {
705
+ const out = [];
706
+ global$2.each(list, (item) => {
707
+ const text = getText(item);
708
+ if (item.menu !== void 0) {
709
+ const items = sanitizeList(item.menu, extractValue);
710
+ out.push({
711
+ text,
712
+ items
713
+ });
714
+ } else {
715
+ const value = extractValue(item);
716
+ out.push({
717
+ text,
718
+ value
719
+ });
720
+ }
721
+ });
722
+ return out;
723
+ };
724
+ const sanitizeWith = (extracter = getValue) => (list) => Optional.from(list).map((list) => sanitizeList(list, extracter));
725
+ const sanitize = (list) => sanitizeWith(getValue)(list);
726
+ const createUi = (name, label) => (items) => ({
727
+ name,
728
+ type: "listbox",
729
+ label,
730
+ items
731
+ });
732
+ const ListOptions = {
733
+ sanitize,
734
+ sanitizeWith,
735
+ createUi,
736
+ getValue
737
+ };
738
+ const isListGroup = (item) => hasNonNullableKey(item, "items");
739
+ const findTextByValue = (value, catalog) => findMap(catalog, (item) => {
740
+ if (isListGroup(item)) return findTextByValue(value, item.items);
741
+ else return someIf(item.value === value, item);
742
+ });
743
+ const getDelta = (persistentText, fieldName, catalog, data) => {
744
+ const value = data[fieldName];
745
+ const hasPersistentText = persistentText.length > 0;
746
+ return value !== void 0 ? findTextByValue(value, catalog).map((i) => ({
747
+ url: {
748
+ value: i.value,
749
+ meta: {
750
+ text: hasPersistentText ? persistentText : i.text,
751
+ attach: noop
752
+ }
753
+ },
754
+ text: hasPersistentText ? persistentText : i.text
755
+ })) : Optional.none();
756
+ };
757
+ const findCatalog = (catalogs, fieldName) => {
758
+ if (fieldName === "link") return catalogs.link;
759
+ else if (fieldName === "anchor") return catalogs.anchor;
760
+ else return Optional.none();
761
+ };
762
+ const init = (initialData, linkCatalog) => {
763
+ const persistentData = {
764
+ text: initialData.text,
765
+ title: initialData.title
766
+ };
767
+ const getTitleFromUrlChange = (url) => someIf(persistentData.title.length <= 0, Optional.from(url.meta?.title).getOr(""));
768
+ const getTextFromUrlChange = (url) => someIf(persistentData.text.length <= 0, Optional.from(url.meta?.text).getOr(url.value));
769
+ const onUrlChange = (data) => {
770
+ const text = getTextFromUrlChange(data.url);
771
+ const title = getTitleFromUrlChange(data.url);
772
+ if (text.isSome() || title.isSome()) return Optional.some({
773
+ ...text.map((text) => ({ text })).getOr({}),
774
+ ...title.map((title) => ({ title })).getOr({})
775
+ });
776
+ else return Optional.none();
777
+ };
778
+ const onCatalogChange = (data, change) => {
779
+ const catalog = findCatalog(linkCatalog, change).getOr([]);
780
+ return getDelta(persistentData.text, change, catalog, data);
781
+ };
782
+ const onChange = (getData, change) => {
783
+ const name = change.name;
784
+ if (name === "url") return onUrlChange(getData());
785
+ else if (contains(["anchor", "link"], name)) return onCatalogChange(getData(), name);
786
+ else if (name === "text" || name === "title") {
787
+ persistentData[name] = getData()[name];
788
+ return Optional.none();
789
+ } else return Optional.none();
790
+ };
791
+ return { onChange };
792
+ };
793
+ const DialogChanges = {
794
+ init,
795
+ getDelta
796
+ };
797
+ var global$1 = tinymce.util.Tools.resolve("tinymce.util.Delay");
798
+ const delayedConfirm = (editor, message, callback) => {
799
+ const rng = editor.selection.getRng();
800
+ global$1.setEditorTimeout(editor, () => {
801
+ editor.windowManager.confirm(message, (state) => {
802
+ editor.selection.setRng(rng);
803
+ callback(state);
804
+ });
805
+ });
806
+ };
807
+ const tryEmailTransform = (data) => {
808
+ const url = data.href;
809
+ return url.indexOf("@") > 0 && url.indexOf("/") === -1 && url.indexOf("mailto:") === -1 ? Optional.some({
810
+ message: "The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?",
811
+ preprocess: (oldData) => ({
812
+ ...oldData,
813
+ href: "mailto:" + url
814
+ })
815
+ }) : Optional.none();
816
+ };
817
+ const tryProtocolTransform = (assumeExternalTargets, defaultLinkProtocol) => (data) => {
818
+ const url = data.href;
819
+ return assumeExternalTargets === 1 && !hasProtocol(url) || assumeExternalTargets === 0 && /^\s*www(\.|\d\.)/i.test(url) ? Optional.some({
820
+ message: `The URL you entered seems to be an external link. Do you want to add the required ${defaultLinkProtocol}:// prefix?`,
821
+ preprocess: (oldData) => ({
822
+ ...oldData,
823
+ href: defaultLinkProtocol + "://" + url
824
+ })
825
+ }) : Optional.none();
826
+ };
827
+ const preprocess = (editor, data) => findMap([tryEmailTransform, tryProtocolTransform(assumeExternalTargets(editor), getDefaultLinkProtocol(editor))], (f) => f(data)).fold(() => Promise.resolve(data), (transform) => new Promise((callback) => {
828
+ delayedConfirm(editor, transform.message, (state) => {
829
+ callback(state ? transform.preprocess(data) : data);
830
+ });
831
+ }));
832
+ const DialogConfirms = { preprocess };
833
+ const getAnchors = (editor) => {
834
+ const anchors = bind(editor.dom.select("a:not([href])"), (anchor) => {
835
+ const id = anchor.name || anchor.id;
836
+ return id ? [{
837
+ text: id,
838
+ value: "#" + id
839
+ }] : [];
840
+ });
841
+ return anchors.length > 0 ? Optional.some([{
842
+ text: "None",
843
+ value: ""
844
+ }].concat(anchors)) : Optional.none();
845
+ };
846
+ const AnchorListOptions = { getAnchors };
847
+ const getClasses = (editor) => {
848
+ const list = getLinkClassList(editor);
849
+ if (list.length > 0) return ListOptions.sanitize(list);
850
+ return Optional.none();
851
+ };
852
+ const ClassListOptions = { getClasses };
853
+ const parseJson = (text) => {
854
+ try {
855
+ return Optional.some(JSON.parse(text));
856
+ } catch {
857
+ return Optional.none();
858
+ }
859
+ };
860
+ const getLinks = (editor) => {
861
+ const extractor = (item) => editor.convertURL(item.value || item.url || "", "href");
862
+ const linkList = getLinkList(editor);
863
+ return new Promise((resolve) => {
864
+ if (isString(linkList)) fetch(linkList).then((res) => res.ok ? res.text().then(parseJson) : Promise.reject()).then(resolve, () => resolve(Optional.none()));
865
+ else if (isFunction(linkList)) linkList((output) => resolve(Optional.some(output)));
866
+ else resolve(Optional.from(linkList));
867
+ }).then((optItems) => optItems.bind(ListOptions.sanitizeWith(extractor)).map((items) => {
868
+ if (items.length > 0) return [{
869
+ text: "None",
870
+ value: ""
871
+ }].concat(items);
872
+ else return items;
873
+ }));
874
+ };
875
+ const LinkListOptions = { getLinks };
876
+ const getRels = (editor, initialTarget) => {
877
+ const list = getRelList(editor);
878
+ if (list.length > 0) {
879
+ const isTargetBlank = is(initialTarget, "_blank");
880
+ const enforceSafe = allowUnsafeLinkTarget(editor) === false;
881
+ const safeRelExtractor = (item) => applyRelTargetRules(ListOptions.getValue(item), isTargetBlank);
882
+ return (enforceSafe ? ListOptions.sanitizeWith(safeRelExtractor) : ListOptions.sanitize)(list);
883
+ }
884
+ return Optional.none();
885
+ };
886
+ const RelOptions = { getRels };
887
+ const fallbacks = [{
888
+ text: "Current window",
889
+ value: ""
890
+ }, {
891
+ text: "New window",
892
+ value: "_blank"
893
+ }];
894
+ const getTargets = (editor) => {
895
+ const list = getTargetList(editor);
896
+ if (isArray(list)) return ListOptions.sanitize(list).orThunk(() => Optional.some(fallbacks));
897
+ else if (list === false) return Optional.none();
898
+ return Optional.some(fallbacks);
899
+ };
900
+ const TargetOptions = { getTargets };
901
+ const nonEmptyAttr = (dom, elem, name) => {
902
+ const val = dom.getAttrib(elem, name);
903
+ return val !== null && val.length > 0 ? Optional.some(val) : Optional.none();
904
+ };
905
+ const extractFromAnchor = (editor, anchor) => {
906
+ const dom = editor.dom;
907
+ const text = isOnlyTextSelected(editor) ? Optional.some(getAnchorText(editor.selection, anchor)) : Optional.none();
908
+ const url = anchor.bind((anchorElm) => Optional.from(dom.getAttrib(anchorElm, "href")));
909
+ const target = anchor.bind((anchorElm) => Optional.from(dom.getAttrib(anchorElm, "target")));
910
+ const rel = anchor.bind((anchorElm) => nonEmptyAttr(dom, anchorElm, "rel"));
911
+ const linkClass = anchor.bind((anchorElm) => nonEmptyAttr(dom, anchorElm, "class"));
912
+ return {
913
+ url,
914
+ text,
915
+ title: anchor.bind((anchorElm) => nonEmptyAttr(dom, anchorElm, "title")),
916
+ target,
917
+ rel,
918
+ linkClass
919
+ };
920
+ };
921
+ const collect = (editor, linkNode) => LinkListOptions.getLinks(editor).then((links) => {
922
+ const hasUploadPanel = hasFilesUploadHandler(editor) && hasDocumentsFileTypes(editor) && hasLinkUploadtab(editor);
923
+ const anchor = extractFromAnchor(editor, linkNode);
924
+ return {
925
+ anchor,
926
+ catalogs: {
927
+ targets: TargetOptions.getTargets(editor),
928
+ rels: RelOptions.getRels(editor, anchor.target),
929
+ classes: ClassListOptions.getClasses(editor),
930
+ anchor: AnchorListOptions.getAnchors(editor),
931
+ link: links
932
+ },
933
+ hasUploadPanel,
934
+ optNode: linkNode,
935
+ flags: { titleEnabled: shouldShowLinkTitle(editor) }
936
+ };
937
+ });
938
+ const DialogInfo = { collect };
939
+ const makeTab = (fileTypes, onInvalidFiles) => {
940
+ return {
941
+ title: "Upload",
942
+ name: "upload",
943
+ items: [{
944
+ type: "dropzone",
945
+ name: "fileinput",
946
+ buttonLabel: "Browse for a file",
947
+ dropAreaLabel: "Drop a file here",
948
+ allowedFileTypes: fileTypes.map((e) => e.mimeType).join(","),
949
+ allowedFileExtensions: flatten(fileTypes.map((e) => e.extensions)),
950
+ onInvalidFiles
951
+ }]
952
+ };
953
+ };
954
+ const UploadTab = { makeTab };
955
+ const handleSubmit = (editor, info) => (api) => {
956
+ const data = api.getData();
957
+ if (!data.url.value) {
958
+ unlink(editor);
959
+ api.close();
960
+ return;
961
+ }
962
+ const getChangedValue = (key) => Optional.from(data[key]).filter((value) => !is(info.anchor[key], value));
963
+ const changedData = {
964
+ href: data.url.value,
965
+ text: getChangedValue("text"),
966
+ target: getChangedValue("target"),
967
+ rel: getChangedValue("rel"),
968
+ class: getChangedValue("linkClass"),
969
+ title: getChangedValue("title")
970
+ };
971
+ const attachState = {
972
+ href: data.url.value,
973
+ attach: data.url.meta !== void 0 && data.url.meta.attach ? data.url.meta.attach : noop
974
+ };
975
+ DialogConfirms.preprocess(editor, changedData).then((pData) => {
976
+ link(editor, attachState, pData);
977
+ });
978
+ api.close();
979
+ };
980
+ const uploadFile = (editor) => (blobInfo, progress) => {
981
+ return getFilesUploadHandler(editor)(blobInfo, progress);
982
+ };
983
+ const dataUrlToBase64 = (dataUrl) => Optional.from(dataUrl.split(",")[1]).getOr("");
984
+ const changeFileInput = (helpers, api) => {
985
+ const data = api.getData();
986
+ api.block("Uploading file");
987
+ head(data.fileinput).fold(() => {
988
+ api.unblock();
989
+ }, (file) => {
990
+ const blobUri = URL.createObjectURL(file);
991
+ const updateUrlAndSwitchTab = ({ url, fileName }) => {
992
+ api.setData({
993
+ text: fileName,
994
+ title: fileName,
995
+ url: {
996
+ value: url,
997
+ meta: {}
998
+ }
999
+ });
1000
+ api.showTab("general");
1001
+ api.focus("url");
1002
+ };
1003
+ const finalize = () => {
1004
+ api.unblock();
1005
+ URL.revokeObjectURL(blobUri);
1006
+ };
1007
+ blobToDataUri(file).then((dataUrl) => {
1008
+ const existingBlobInfo = helpers.getExistingBlobInfo(dataUrlToBase64(dataUrl), file.type);
1009
+ const blobInfo = existingBlobInfo && existingBlobInfo.filename() === file.name ? existingBlobInfo : helpers.createBlobCache(file, blobUri, dataUrl);
1010
+ helpers.addToBlobCache(blobInfo);
1011
+ return helpers.uploadFile(blobInfo, identity);
1012
+ }).then((result) => {
1013
+ updateUrlAndSwitchTab(result);
1014
+ finalize();
1015
+ }).catch((err) => {
1016
+ finalize();
1017
+ helpers.alertErr(err, () => {
1018
+ api.focus("fileinput");
1019
+ });
1020
+ });
1021
+ });
1022
+ };
1023
+ const createBlobCache = (editor) => (file, blobUri, dataUrl) => editor.editorUpload.blobCache.create({
1024
+ blob: file,
1025
+ blobUri,
1026
+ name: file.name?.replace(/\.[^\.]+$/, ""),
1027
+ filename: file.name,
1028
+ base64: dataUrl.split(",")[1],
1029
+ allowEmptyFile: true
1030
+ });
1031
+ const addToBlobCache = (editor) => (blobInfo) => {
1032
+ editor.editorUpload.blobCache.add(blobInfo);
1033
+ };
1034
+ const getExistingBlobInfo = (editor) => (base64, type) => {
1035
+ return editor.editorUpload.blobCache.getByData(base64, type);
1036
+ };
1037
+ const alertErr = (editor) => (message, callback) => {
1038
+ editor.windowManager.alert(message, callback);
1039
+ };
1040
+ const collectData = (editor) => {
1041
+ const anchorNode = getAnchorElement(editor);
1042
+ return DialogInfo.collect(editor, anchorNode);
1043
+ };
1044
+ const getInitialData = (info, defaultTarget) => {
1045
+ const anchor = info.anchor;
1046
+ const url = anchor.url.getOr("");
1047
+ return {
1048
+ url: {
1049
+ value: url,
1050
+ meta: { original: { value: url } }
1051
+ },
1052
+ text: anchor.text.getOr(""),
1053
+ title: anchor.title.getOr(""),
1054
+ anchor: url,
1055
+ link: url,
1056
+ rel: anchor.rel.getOr(""),
1057
+ target: anchor.target.or(defaultTarget).getOr(""),
1058
+ linkClass: anchor.linkClass.getOr(""),
1059
+ fileinput: []
1060
+ };
1061
+ };
1062
+ const makeDialogBody = (urlInput, displayText, titleText, catalogs, hasUploadPanel, fileTypes, onInvalidFiles) => {
1063
+ const generalPanelItems = flatten([
1064
+ urlInput,
1065
+ displayText,
1066
+ titleText,
1067
+ cat([
1068
+ catalogs.anchor.map(ListOptions.createUi("anchor", "Anchors")),
1069
+ catalogs.rels.map(ListOptions.createUi("rel", "Rel")),
1070
+ catalogs.targets.map(ListOptions.createUi("target", "Open link in...")),
1071
+ catalogs.link.map(ListOptions.createUi("link", "Link list")),
1072
+ catalogs.classes.map(ListOptions.createUi("linkClass", "Class"))
1073
+ ])
1074
+ ]);
1075
+ if (hasUploadPanel) return {
1076
+ type: "tabpanel",
1077
+ tabs: flatten([[{
1078
+ title: "General",
1079
+ name: "general",
1080
+ items: generalPanelItems
1081
+ }], [UploadTab.makeTab(fileTypes, onInvalidFiles)]])
1082
+ };
1083
+ else return {
1084
+ type: "panel",
1085
+ items: generalPanelItems
1086
+ };
1087
+ };
1088
+ const makeDialog = (settings, onSubmit, editor) => {
1089
+ const urlInput = [{
1090
+ name: "url",
1091
+ type: "urlinput",
1092
+ filetype: "file",
1093
+ label: "URL",
1094
+ picker_text: "Browse links"
1095
+ }];
1096
+ const displayText = settings.anchor.text.map(() => ({
1097
+ name: "text",
1098
+ type: "input",
1099
+ label: "Text to display"
1100
+ })).toArray();
1101
+ const titleText = settings.flags.titleEnabled ? [{
1102
+ name: "title",
1103
+ type: "input",
1104
+ label: "Title"
1105
+ }] : [];
1106
+ const initialData = getInitialData(settings, Optional.from(getDefaultLinkTarget(editor)));
1107
+ const catalogs = settings.catalogs;
1108
+ const dialogDelta = DialogChanges.init(initialData, catalogs);
1109
+ const helpers = {
1110
+ addToBlobCache: addToBlobCache(editor),
1111
+ createBlobCache: createBlobCache(editor),
1112
+ alertErr: alertErr(editor),
1113
+ uploadFile: uploadFile(editor),
1114
+ getExistingBlobInfo: getExistingBlobInfo(editor)
1115
+ };
1116
+ return {
1117
+ title: "Insert/Edit Link",
1118
+ size: "normal",
1119
+ body: makeDialogBody(urlInput, displayText, titleText, catalogs, settings.hasUploadPanel, getDocumentsFileTypes(editor), () => new Promise((r) => helpers.alertErr("Selected files do not have allowed extensions", r))),
1120
+ buttons: [{
1121
+ type: "cancel",
1122
+ name: "cancel",
1123
+ text: "Cancel"
1124
+ }, {
1125
+ type: "submit",
1126
+ name: "save",
1127
+ text: "Save",
1128
+ primary: true
1129
+ }],
1130
+ initialData,
1131
+ onChange: (api, { name }) => {
1132
+ if (name === "fileinput") changeFileInput(helpers, api);
1133
+ else dialogDelta.onChange(api.getData, { name }).each((newData) => {
1134
+ api.setData(newData);
1135
+ });
1136
+ },
1137
+ onSubmit
1138
+ };
1139
+ };
1140
+ const open = (editor) => {
1141
+ collectData(editor).then((info) => {
1142
+ return makeDialog(info, handleSubmit(editor, info), editor);
1143
+ }).then((spec) => {
1144
+ editor.windowManager.open(spec);
1145
+ });
1146
+ };
1147
+ const register = (editor) => {
1148
+ editor.addCommand("mceLink", (_ui, value) => {
1149
+ if (value?.dialog === true || !useQuickLink(editor)) open(editor);
1150
+ else editor.dispatch("contexttoolbar-show", { toolbarKey: "quicklink" });
1151
+ });
1152
+ };
1153
+ const setup$2 = (editor) => {
1154
+ editor.addShortcut("Meta+K", "", () => {
1155
+ editor.execCommand("mceLink");
1156
+ });
1157
+ };
1158
+ var global = tinymce.util.Tools.resolve("tinymce.util.VK");
1159
+ const appendClickRemove = (link, evt) => {
1160
+ document.body.appendChild(link);
1161
+ link.dispatchEvent(evt);
1162
+ document.body.removeChild(link);
1163
+ };
1164
+ const openLink = (url) => {
1165
+ const link = document.createElement("a");
1166
+ link.target = "_blank";
1167
+ link.href = url;
1168
+ link.rel = "noreferrer noopener";
1169
+ const evt = new MouseEvent("click", {
1170
+ bubbles: true,
1171
+ cancelable: true,
1172
+ view: window
1173
+ });
1174
+ document.dispatchEvent(evt);
1175
+ appendClickRemove(link, evt);
1176
+ };
1177
+ const hasOnlyAltModifier = (e) => {
1178
+ return e.altKey === true && e.shiftKey === false && e.ctrlKey === false && e.metaKey === false;
1179
+ };
1180
+ const gotoLink = (editor, a) => {
1181
+ if (a) {
1182
+ const href = getHref(a);
1183
+ if (/^#/.test(href)) {
1184
+ const targetEl = editor.dom.select(`${href},[name="${removeLeading(href, "#")}"]`);
1185
+ if (targetEl.length) editor.selection.scrollIntoView(targetEl[0], true);
1186
+ } else openLink(a.href);
1187
+ }
1188
+ };
1189
+ const isSelectionOnImageWithEmbeddedLink = (editor) => {
1190
+ const rng = editor.selection.getRng();
1191
+ const node = rng.startContainer;
1192
+ return isLink(node) && rng.startContainer === rng.endContainer && editor.dom.select("img", node).length === 1;
1193
+ };
1194
+ const getLinkFromElement = (editor, element) => {
1195
+ const links = getLinks$1(editor.dom.getParents(element));
1196
+ return someIf(links.length === 1, links[0]);
1197
+ };
1198
+ const getLinkInSelection = (editor) => {
1199
+ const links = getLinksInSelection(editor.selection.getRng());
1200
+ return someIf(links.length > 0, links[0]).or(getLinkFromElement(editor, editor.selection.getNode()));
1201
+ };
1202
+ const getLinkFromSelection = (editor) => editor.selection.isCollapsed() || isSelectionOnImageWithEmbeddedLink(editor) ? getLinkFromElement(editor, editor.selection.getStart()) : getLinkInSelection(editor);
1203
+ const setup$1 = (editor) => {
1204
+ const selectedLink = value();
1205
+ const getSelectedLink = () => selectedLink.get().or(getLinkFromSelection(editor));
1206
+ const gotoSelectedLink = () => getSelectedLink().each((link) => gotoLink(editor, link));
1207
+ editor.on("contextmenu", (e) => {
1208
+ getLinkFromElement(editor, e.target).each(selectedLink.set);
1209
+ });
1210
+ editor.on("SelectionChange", () => {
1211
+ if (!selectedLink.isSet()) getLinkFromSelection(editor).each(selectedLink.set);
1212
+ });
1213
+ editor.on("click", (e) => {
1214
+ selectedLink.clear();
1215
+ const links = getLinks$1(editor.dom.getParents(e.target));
1216
+ if (links.length === 1 && global.metaKeyPressed(e)) {
1217
+ e.preventDefault();
1218
+ gotoLink(editor, links[0]);
1219
+ }
1220
+ });
1221
+ editor.on("keydown", (e) => {
1222
+ selectedLink.clear();
1223
+ if (!e.isDefaultPrevented() && e.keyCode === 13 && hasOnlyAltModifier(e)) getSelectedLink().each((link) => {
1224
+ e.preventDefault();
1225
+ gotoLink(editor, link);
1226
+ });
1227
+ });
1228
+ return { gotoSelectedLink };
1229
+ };
1230
+ const openDialog = (editor) => () => {
1231
+ editor.execCommand("mceLink", false, { dialog: true });
1232
+ };
1233
+ const toggleState = (editor, toggler) => {
1234
+ editor.on("NodeChange", toggler);
1235
+ return () => editor.off("NodeChange", toggler);
1236
+ };
1237
+ const toggleLinkState = (editor) => (api) => {
1238
+ const updateState = () => {
1239
+ api.setActive(!editor.mode.isReadOnly() && isInAnchor(editor, editor.selection.getNode()));
1240
+ api.setEnabled(editor.selection.isEditable());
1241
+ };
1242
+ updateState();
1243
+ return toggleState(editor, updateState);
1244
+ };
1245
+ const toggleLinkMenuState = (editor) => (api) => {
1246
+ const updateState = () => {
1247
+ api.setEnabled(editor.selection.isEditable());
1248
+ };
1249
+ updateState();
1250
+ return toggleState(editor, updateState);
1251
+ };
1252
+ const toggleRequiresLinkState = (editor) => (api) => {
1253
+ const hasLinks$1 = (parents) => hasLinks(parents) || hasLinksInSelection(editor.selection.getRng());
1254
+ const parents = editor.dom.getParents(editor.selection.getStart());
1255
+ const updateEnabled = (parents) => {
1256
+ api.setEnabled(hasLinks$1(parents) && editor.selection.isEditable());
1257
+ };
1258
+ updateEnabled(parents);
1259
+ return toggleState(editor, (e) => updateEnabled(e.parents));
1260
+ };
1261
+ const setupButtons = (editor, openLink) => {
1262
+ editor.ui.registry.addToggleButton("link", {
1263
+ icon: "link",
1264
+ tooltip: "Insert/edit link",
1265
+ shortcut: "Meta+K",
1266
+ onAction: openDialog(editor),
1267
+ onSetup: toggleLinkState(editor)
1268
+ });
1269
+ editor.ui.registry.addButton("openlink", {
1270
+ icon: "new-tab",
1271
+ tooltip: "Open link",
1272
+ onAction: openLink.gotoSelectedLink,
1273
+ onSetup: toggleRequiresLinkState(editor)
1274
+ });
1275
+ editor.ui.registry.addButton("unlink", {
1276
+ icon: "unlink",
1277
+ tooltip: "Remove link",
1278
+ onAction: () => unlink(editor),
1279
+ onSetup: toggleRequiresLinkState(editor)
1280
+ });
1281
+ };
1282
+ const setupMenuItems = (editor, openLink) => {
1283
+ editor.ui.registry.addMenuItem("openlink", {
1284
+ text: "Open link",
1285
+ icon: "new-tab",
1286
+ onAction: openLink.gotoSelectedLink,
1287
+ onSetup: toggleRequiresLinkState(editor)
1288
+ });
1289
+ editor.ui.registry.addMenuItem("link", {
1290
+ icon: "link",
1291
+ text: "Link...",
1292
+ shortcut: "Meta+K",
1293
+ onAction: openDialog(editor),
1294
+ onSetup: toggleLinkMenuState(editor)
1295
+ });
1296
+ editor.ui.registry.addMenuItem("unlink", {
1297
+ icon: "unlink",
1298
+ text: "Remove link",
1299
+ onAction: () => unlink(editor),
1300
+ onSetup: toggleRequiresLinkState(editor)
1301
+ });
1302
+ };
1303
+ const setupContextMenu = (editor) => {
1304
+ const inLink = "link unlink openlink";
1305
+ const noLink = "link";
1306
+ editor.ui.registry.addContextMenu("link", { update: (element) => {
1307
+ if (!editor.dom.isEditable(element)) return "";
1308
+ return hasLinks(editor.dom.getParents(element, "a")) ? inLink : noLink;
1309
+ } });
1310
+ };
1311
+ const setupContextToolbars = (editor, openLink) => {
1312
+ const collapseSelectionToEnd = (editor) => {
1313
+ editor.selection.collapse(false);
1314
+ };
1315
+ const onSetupLink = (buttonApi) => {
1316
+ const node = editor.selection.getNode();
1317
+ buttonApi.setEnabled(isInAnchor(editor, node) && editor.selection.isEditable());
1318
+ return noop;
1319
+ };
1320
+ /**
1321
+ * if we're editing a link, don't change the text.
1322
+ * if anything other than text is selected, don't change the text.
1323
+ * TINY-9593: If there is a text selection return `Optional.none`
1324
+ * because `mceInsertLink` command will handle the selection.
1325
+ */
1326
+ const getLinkText = (value) => {
1327
+ const anchor = getAnchorElement(editor);
1328
+ const onlyText = isOnlyTextSelected(editor);
1329
+ if (anchor.isNone() && onlyText) return someIf(getAnchorText(editor.selection, anchor).length === 0, value);
1330
+ else return Optional.none();
1331
+ };
1332
+ editor.ui.registry.addContextForm("quicklink", {
1333
+ launch: {
1334
+ type: "contextformtogglebutton",
1335
+ icon: "link",
1336
+ tooltip: "Link",
1337
+ onSetup: toggleLinkState(editor)
1338
+ },
1339
+ label: "Link",
1340
+ predicate: (node) => hasContextToolbar(editor) && isInAnchor(editor, node),
1341
+ initValue: () => {
1342
+ return getAnchorElement(editor).fold(constant(""), getHref);
1343
+ },
1344
+ commands: [
1345
+ {
1346
+ type: "contextformtogglebutton",
1347
+ icon: "link",
1348
+ tooltip: "Link",
1349
+ primary: true,
1350
+ onSetup: (buttonApi) => {
1351
+ const node = editor.selection.getNode();
1352
+ buttonApi.setActive(isInAnchor(editor, node));
1353
+ return toggleLinkState(editor)(buttonApi);
1354
+ },
1355
+ onAction: (formApi) => {
1356
+ const value = formApi.getValue();
1357
+ const text = getLinkText(value);
1358
+ link(editor, {
1359
+ href: value,
1360
+ attach: noop
1361
+ }, {
1362
+ href: value,
1363
+ text,
1364
+ title: Optional.none(),
1365
+ rel: Optional.none(),
1366
+ target: Optional.from(getDefaultLinkTarget(editor)),
1367
+ class: Optional.none()
1368
+ });
1369
+ collapseSelectionToEnd(editor);
1370
+ formApi.hide();
1371
+ }
1372
+ },
1373
+ {
1374
+ type: "contextformbutton",
1375
+ icon: "unlink",
1376
+ tooltip: "Remove link",
1377
+ onSetup: onSetupLink,
1378
+ onAction: (formApi) => {
1379
+ unlink(editor);
1380
+ formApi.hide();
1381
+ }
1382
+ },
1383
+ {
1384
+ type: "contextformbutton",
1385
+ icon: "new-tab",
1386
+ tooltip: "Open link",
1387
+ onSetup: onSetupLink,
1388
+ onAction: (formApi) => {
1389
+ openLink.gotoSelectedLink();
1390
+ formApi.hide();
1391
+ }
1392
+ }
1393
+ ]
1394
+ });
1395
+ };
1396
+ const setup = (editor) => {
1397
+ const openLink = setup$1(editor);
1398
+ setupButtons(editor, openLink);
1399
+ setupMenuItems(editor, openLink);
1400
+ setupContextMenu(editor);
1401
+ setupContextToolbars(editor, openLink);
1402
+ };
1403
+ var Plugin = () => {
1404
+ global$5.add("link", (editor) => {
1405
+ register$1(editor);
1406
+ register(editor);
1407
+ setup(editor);
1408
+ setup$2(editor);
1409
+ });
1410
+ };
1411
+ Plugin();
1412
+ /** *****
1413
+ * DO NOT EXPORT ANYTHING
1414
+ *
1415
+ * IF YOU DO ROLLUP WILL LEAVE A GLOBAL ON THE PAGE
1416
+ *******/
1417
+ })();
1418
+ })))();
1419
+ //#endregion
1420
+
1421
+ //# sourceMappingURL=link-BCKWs7cm.js.map