Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

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