@enos5/enos-vue-default 1.8.16 → 1.8.18

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