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
    const Cell = initial => {
9
      let value = initial;
10
      const get = () => {
11
        return value;
12
      };
13
      const set = v => {
14
        value = v;
15
      };
16
      return {
17
        get,
18
        set
19
      };
20
    };
21
 
1441 ariadna 22
    var global$3 = tinymce.util.Tools.resolve('tinymce.PluginManager');
1 efrain 23
 
24
    const get$5 = fullscreenState => ({ isFullscreen: () => fullscreenState.get() !== null });
25
 
26
    const hasProto = (v, constructor, predicate) => {
27
      var _a;
28
      if (predicate(v, constructor.prototype)) {
29
        return true;
30
      } else {
31
        return ((_a = v.constructor) === null || _a === void 0 ? void 0 : _a.name) === constructor.name;
32
      }
33
    };
34
    const typeOf = x => {
35
      const t = typeof x;
36
      if (x === null) {
37
        return 'null';
38
      } else if (t === 'object' && Array.isArray(x)) {
39
        return 'array';
40
      } else if (t === 'object' && hasProto(x, String, (o, proto) => proto.isPrototypeOf(o))) {
41
        return 'string';
42
      } else {
43
        return t;
44
      }
45
    };
46
    const isType$1 = type => value => typeOf(value) === type;
47
    const isSimpleType = type => value => typeof value === type;
48
    const eq$1 = t => a => t === a;
49
    const isString = isType$1('string');
50
    const isObject = isType$1('object');
51
    const isArray = isType$1('array');
52
    const isNull = eq$1(null);
53
    const isBoolean = isSimpleType('boolean');
54
    const isUndefined = eq$1(undefined);
55
    const isNullable = a => a === null || a === undefined;
56
    const isNonNullable = a => !isNullable(a);
57
    const isFunction = isSimpleType('function');
58
    const isNumber = isSimpleType('number');
59
 
60
    const noop = () => {
61
    };
62
    const compose = (fa, fb) => {
63
      return (...args) => {
64
        return fa(fb.apply(null, args));
65
      };
66
    };
67
    const compose1 = (fbc, fab) => a => fbc(fab(a));
68
    const constant = value => {
69
      return () => {
70
        return value;
71
      };
72
    };
73
    function curry(fn, ...initialArgs) {
74
      return (...restArgs) => {
75
        const all = initialArgs.concat(restArgs);
76
        return fn.apply(null, all);
77
      };
78
    }
79
    const never = constant(false);
80
    const always = constant(true);
81
 
82
    class Optional {
83
      constructor(tag, value) {
84
        this.tag = tag;
85
        this.value = value;
86
      }
87
      static some(value) {
88
        return new Optional(true, value);
89
      }
90
      static none() {
91
        return Optional.singletonNone;
92
      }
93
      fold(onNone, onSome) {
94
        if (this.tag) {
95
          return onSome(this.value);
96
        } else {
97
          return onNone();
98
        }
99
      }
100
      isSome() {
101
        return this.tag;
102
      }
103
      isNone() {
104
        return !this.tag;
105
      }
106
      map(mapper) {
107
        if (this.tag) {
108
          return Optional.some(mapper(this.value));
109
        } else {
110
          return Optional.none();
111
        }
112
      }
113
      bind(binder) {
114
        if (this.tag) {
115
          return binder(this.value);
116
        } else {
117
          return Optional.none();
118
        }
119
      }
120
      exists(predicate) {
121
        return this.tag && predicate(this.value);
122
      }
123
      forall(predicate) {
124
        return !this.tag || predicate(this.value);
125
      }
126
      filter(predicate) {
127
        if (!this.tag || predicate(this.value)) {
128
          return this;
129
        } else {
130
          return Optional.none();
131
        }
132
      }
133
      getOr(replacement) {
134
        return this.tag ? this.value : replacement;
135
      }
136
      or(replacement) {
137
        return this.tag ? this : replacement;
138
      }
139
      getOrThunk(thunk) {
140
        return this.tag ? this.value : thunk();
141
      }
142
      orThunk(thunk) {
143
        return this.tag ? this : thunk();
144
      }
145
      getOrDie(message) {
146
        if (!this.tag) {
147
          throw new Error(message !== null && message !== void 0 ? message : 'Called getOrDie on None');
148
        } else {
149
          return this.value;
150
        }
151
      }
152
      static from(value) {
153
        return isNonNullable(value) ? Optional.some(value) : Optional.none();
154
      }
155
      getOrNull() {
156
        return this.tag ? this.value : null;
157
      }
158
      getOrUndefined() {
159
        return this.value;
160
      }
161
      each(worker) {
162
        if (this.tag) {
163
          worker(this.value);
164
        }
165
      }
166
      toArray() {
167
        return this.tag ? [this.value] : [];
168
      }
169
      toString() {
170
        return this.tag ? `some(${ this.value })` : 'none()';
171
      }
172
    }
173
    Optional.singletonNone = new Optional(false);
174
 
175
    const nativePush = Array.prototype.push;
176
    const map = (xs, f) => {
177
      const len = xs.length;
178
      const r = new Array(len);
179
      for (let i = 0; i < len; i++) {
180
        const x = xs[i];
181
        r[i] = f(x, i);
182
      }
183
      return r;
184
    };
185
    const each$1 = (xs, f) => {
186
      for (let i = 0, len = xs.length; i < len; i++) {
187
        const x = xs[i];
188
        f(x, i);
189
      }
190
    };
191
    const filter$1 = (xs, pred) => {
192
      const r = [];
193
      for (let i = 0, len = xs.length; i < len; i++) {
194
        const x = xs[i];
195
        if (pred(x, i)) {
196
          r.push(x);
197
        }
198
      }
199
      return r;
200
    };
201
    const findUntil = (xs, pred, until) => {
202
      for (let i = 0, len = xs.length; i < len; i++) {
203
        const x = xs[i];
204
        if (pred(x, i)) {
205
          return Optional.some(x);
206
        } else if (until(x, i)) {
207
          break;
208
        }
209
      }
210
      return Optional.none();
211
    };
212
    const find$1 = (xs, pred) => {
213
      return findUntil(xs, pred, never);
214
    };
215
    const flatten = xs => {
216
      const r = [];
217
      for (let i = 0, len = xs.length; i < len; ++i) {
218
        if (!isArray(xs[i])) {
219
          throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
220
        }
221
        nativePush.apply(r, xs[i]);
222
      }
223
      return r;
224
    };
225
    const bind$3 = (xs, f) => flatten(map(xs, f));
226
    const get$4 = (xs, i) => i >= 0 && i < xs.length ? Optional.some(xs[i]) : Optional.none();
227
    const head = xs => get$4(xs, 0);
228
    const findMap = (arr, f) => {
229
      for (let i = 0; i < arr.length; i++) {
230
        const r = f(arr[i], i);
231
        if (r.isSome()) {
232
          return r;
233
        }
234
      }
235
      return Optional.none();
236
    };
237
 
238
    const lift2 = (oa, ob, f) => oa.isSome() && ob.isSome() ? Optional.some(f(oa.getOrDie(), ob.getOrDie())) : Optional.none();
239
 
240
    const singleton = doRevoke => {
241
      const subject = Cell(Optional.none());
242
      const revoke = () => subject.get().each(doRevoke);
243
      const clear = () => {
244
        revoke();
245
        subject.set(Optional.none());
246
      };
247
      const isSet = () => subject.get().isSome();
248
      const get = () => subject.get();
249
      const set = s => {
250
        revoke();
251
        subject.set(Optional.some(s));
252
      };
253
      return {
254
        clear,
255
        isSet,
256
        get,
257
        set
258
      };
259
    };
260
    const unbindable = () => singleton(s => s.unbind());
261
    const value = () => {
262
      const subject = singleton(noop);
263
      const on = f => subject.get().each(f);
264
      return {
265
        ...subject,
266
        on
267
      };
268
    };
269
 
270
    const first = (fn, rate) => {
271
      let timer = null;
272
      const cancel = () => {
273
        if (!isNull(timer)) {
274
          clearTimeout(timer);
275
          timer = null;
276
        }
277
      };
278
      const throttle = (...args) => {
279
        if (isNull(timer)) {
280
          timer = setTimeout(() => {
281
            timer = null;
282
            fn.apply(null, args);
283
          }, rate);
284
        }
285
      };
286
      return {
287
        cancel,
288
        throttle
289
      };
290
    };
291
 
292
    const keys = Object.keys;
293
    const each = (obj, f) => {
294
      const props = keys(obj);
295
      for (let k = 0, len = props.length; k < len; k++) {
296
        const i = props[k];
297
        const x = obj[i];
298
        f(x, i);
299
      }
300
    };
301
 
302
    const Global = typeof window !== 'undefined' ? window : Function('return this;')();
303
 
304
    const path = (parts, scope) => {
305
      let o = scope !== undefined && scope !== null ? scope : Global;
306
      for (let i = 0; i < parts.length && o !== undefined && o !== null; ++i) {
307
        o = o[parts[i]];
308
      }
309
      return o;
310
    };
311
    const resolve = (p, scope) => {
312
      const parts = p.split('.');
313
      return path(parts, scope);
314
    };
315
 
316
    const unsafe = (name, scope) => {
317
      return resolve(name, scope);
318
    };
319
    const getOrDie = (name, scope) => {
320
      const actual = unsafe(name, scope);
321
      if (actual === undefined || actual === null) {
322
        throw new Error(name + ' not available on this browser');
323
      }
324
      return actual;
325
    };
326
 
327
    const getPrototypeOf = Object.getPrototypeOf;
328
    const sandHTMLElement = scope => {
329
      return getOrDie('HTMLElement', scope);
330
    };
331
    const isPrototypeOf = x => {
332
      const scope = resolve('ownerDocument.defaultView', x);
333
      return isObject(x) && (sandHTMLElement(scope).prototype.isPrototypeOf(x) || /^HTML\w*Element$/.test(getPrototypeOf(x).constructor.name));
334
    };
335
 
336
    const DOCUMENT = 9;
337
    const DOCUMENT_FRAGMENT = 11;
338
    const ELEMENT = 1;
339
    const TEXT = 3;
340
 
341
    const type = element => element.dom.nodeType;
342
    const isType = t => element => type(element) === t;
343
    const isHTMLElement = element => isElement(element) && isPrototypeOf(element.dom);
344
    const isElement = isType(ELEMENT);
345
    const isText = isType(TEXT);
346
    const isDocumentFragment = isType(DOCUMENT_FRAGMENT);
347
 
348
    const rawSet = (dom, key, value) => {
349
      if (isString(value) || isBoolean(value) || isNumber(value)) {
350
        dom.setAttribute(key, value + '');
351
      } else {
352
        console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom);
353
        throw new Error('Attribute value was not simple');
354
      }
355
    };
356
    const set$1 = (element, key, value) => {
357
      rawSet(element.dom, key, value);
358
    };
359
    const get$3 = (element, key) => {
360
      const v = element.dom.getAttribute(key);
361
      return v === null ? undefined : v;
362
    };
363
    const remove = (element, key) => {
364
      element.dom.removeAttribute(key);
365
    };
366
 
367
    const supports = element => element.dom.classList !== undefined;
368
 
369
    const has = (element, clazz) => supports(element) && element.dom.classList.contains(clazz);
370
 
371
    const contains = (str, substr, start = 0, end) => {
372
      const idx = str.indexOf(substr, start);
373
      if (idx !== -1) {
374
        return isUndefined(end) ? true : idx + substr.length <= end;
375
      } else {
376
        return false;
377
      }
378
    };
379
 
1441 ariadna 380
    const isSupported = dom => dom.style !== undefined && isFunction(dom.style.getPropertyValue);
1 efrain 381
 
382
    const fromHtml = (html, scope) => {
383
      const doc = scope || document;
384
      const div = doc.createElement('div');
385
      div.innerHTML = html;
386
      if (!div.hasChildNodes() || div.childNodes.length > 1) {
387
        const message = 'HTML does not have a single root node';
388
        console.error(message, html);
389
        throw new Error(message);
390
      }
391
      return fromDom(div.childNodes[0]);
392
    };
393
    const fromTag = (tag, scope) => {
394
      const doc = scope || document;
395
      const node = doc.createElement(tag);
396
      return fromDom(node);
397
    };
398
    const fromText = (text, scope) => {
399
      const doc = scope || document;
400
      const node = doc.createTextNode(text);
401
      return fromDom(node);
402
    };
403
    const fromDom = node => {
404
      if (node === null || node === undefined) {
405
        throw new Error('Node cannot be null or undefined');
406
      }
407
      return { dom: node };
408
    };
409
    const fromPoint = (docElm, x, y) => Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom);
410
    const SugarElement = {
411
      fromHtml,
412
      fromTag,
413
      fromText,
414
      fromDom,
415
      fromPoint
416
    };
417
 
418
    const is = (element, selector) => {
419
      const dom = element.dom;
420
      if (dom.nodeType !== ELEMENT) {
421
        return false;
422
      } else {
423
        const elem = dom;
424
        if (elem.matches !== undefined) {
425
          return elem.matches(selector);
426
        } else if (elem.msMatchesSelector !== undefined) {
427
          return elem.msMatchesSelector(selector);
428
        } else if (elem.webkitMatchesSelector !== undefined) {
429
          return elem.webkitMatchesSelector(selector);
430
        } else if (elem.mozMatchesSelector !== undefined) {
431
          return elem.mozMatchesSelector(selector);
432
        } else {
433
          throw new Error('Browser lacks native selectors');
434
        }
435
      }
436
    };
437
    const bypassSelector = dom => dom.nodeType !== ELEMENT && dom.nodeType !== DOCUMENT && dom.nodeType !== DOCUMENT_FRAGMENT || dom.childElementCount === 0;
438
    const all$1 = (selector, scope) => {
439
      const base = scope === undefined ? document : scope.dom;
440
      return bypassSelector(base) ? [] : map(base.querySelectorAll(selector), SugarElement.fromDom);
441
    };
442
 
443
    const eq = (e1, e2) => e1.dom === e2.dom;
444
 
445
    const owner = element => SugarElement.fromDom(element.dom.ownerDocument);
446
    const parent = element => Optional.from(element.dom.parentNode).map(SugarElement.fromDom);
447
    const parents = (element, isRoot) => {
448
      const stop = isFunction(isRoot) ? isRoot : never;
449
      let dom = element.dom;
450
      const ret = [];
451
      while (dom.parentNode !== null && dom.parentNode !== undefined) {
452
        const rawParent = dom.parentNode;
453
        const p = SugarElement.fromDom(rawParent);
454
        ret.push(p);
455
        if (stop(p) === true) {
456
          break;
457
        } else {
458
          dom = rawParent;
459
        }
460
      }
461
      return ret;
462
    };
463
    const siblings$2 = element => {
464
      const filterSelf = elements => filter$1(elements, x => !eq(element, x));
465
      return parent(element).map(children).map(filterSelf).getOr([]);
466
    };
467
    const nextSibling = element => Optional.from(element.dom.nextSibling).map(SugarElement.fromDom);
468
    const children = element => map(element.dom.childNodes, SugarElement.fromDom);
469
 
470
    const isShadowRoot = dos => isDocumentFragment(dos) && isNonNullable(dos.dom.host);
1441 ariadna 471
    const getRootNode = e => SugarElement.fromDom(e.dom.getRootNode());
1 efrain 472
    const getShadowRoot = e => {
473
      const r = getRootNode(e);
474
      return isShadowRoot(r) ? Optional.some(r) : Optional.none();
475
    };
476
    const getShadowHost = e => SugarElement.fromDom(e.dom.host);
477
    const getOriginalEventTarget = event => {
1441 ariadna 478
      if (isNonNullable(event.target)) {
1 efrain 479
        const el = SugarElement.fromDom(event.target);
480
        if (isElement(el) && isOpenShadowHost(el)) {
481
          if (event.composed && event.composedPath) {
482
            const composedPath = event.composedPath();
483
            if (composedPath) {
484
              return head(composedPath);
485
            }
486
          }
487
        }
488
      }
489
      return Optional.from(event.target);
490
    };
491
    const isOpenShadowHost = element => isNonNullable(element.dom.shadowRoot);
492
 
493
    const inBody = element => {
494
      const dom = isText(element) ? element.dom.parentNode : element.dom;
495
      if (dom === undefined || dom === null || dom.ownerDocument === null) {
496
        return false;
497
      }
498
      const doc = dom.ownerDocument;
499
      return getShadowRoot(SugarElement.fromDom(dom)).fold(() => doc.body.contains(dom), compose1(inBody, getShadowHost));
500
    };
501
    const getBody = doc => {
502
      const b = doc.dom.body;
503
      if (b === null || b === undefined) {
504
        throw new Error('Body is not available yet');
505
      }
506
      return SugarElement.fromDom(b);
507
    };
508
 
509
    const internalSet = (dom, property, value) => {
510
      if (!isString(value)) {
511
        console.error('Invalid call to CSS.set. Property ', property, ':: Value ', value, ':: Element ', dom);
512
        throw new Error('CSS value must be a string: ' + value);
513
      }
1441 ariadna 514
      if (isSupported(dom)) {
1 efrain 515
        dom.style.setProperty(property, value);
516
      }
517
    };
518
    const set = (element, property, value) => {
519
      const dom = element.dom;
520
      internalSet(dom, property, value);
521
    };
522
    const setAll = (element, css) => {
523
      const dom = element.dom;
524
      each(css, (v, k) => {
525
        internalSet(dom, k, v);
526
      });
527
    };
528
    const get$2 = (element, property) => {
529
      const dom = element.dom;
530
      const styles = window.getComputedStyle(dom);
531
      const r = styles.getPropertyValue(property);
532
      return r === '' && !inBody(element) ? getUnsafeProperty(dom, property) : r;
533
    };
1441 ariadna 534
    const getUnsafeProperty = (dom, property) => isSupported(dom) ? dom.style.getPropertyValue(property) : '';
1 efrain 535
 
536
    const mkEvent = (target, x, y, stop, prevent, kill, raw) => ({
537
      target,
538
      x,
539
      y,
540
      stop,
541
      prevent,
542
      kill,
543
      raw
544
    });
545
    const fromRawEvent = rawEvent => {
546
      const target = SugarElement.fromDom(getOriginalEventTarget(rawEvent).getOr(rawEvent.target));
547
      const stop = () => rawEvent.stopPropagation();
548
      const prevent = () => rawEvent.preventDefault();
549
      const kill = compose(prevent, stop);
550
      return mkEvent(target, rawEvent.clientX, rawEvent.clientY, stop, prevent, kill, rawEvent);
551
    };
552
    const handle = (filter, handler) => rawEvent => {
553
      if (filter(rawEvent)) {
554
        handler(fromRawEvent(rawEvent));
555
      }
556
    };
557
    const binder = (element, event, filter, handler, useCapture) => {
558
      const wrapped = handle(filter, handler);
559
      element.dom.addEventListener(event, wrapped, useCapture);
560
      return { unbind: curry(unbind, element, event, wrapped, useCapture) };
561
    };
562
    const bind$2 = (element, event, filter, handler) => binder(element, event, filter, handler, false);
563
    const unbind = (element, event, handler, useCapture) => {
564
      element.dom.removeEventListener(event, handler, useCapture);
565
    };
566
 
567
    const filter = always;
568
    const bind$1 = (element, event, handler) => bind$2(element, event, filter, handler);
569
 
570
    const cached = f => {
571
      let called = false;
572
      let r;
573
      return (...args) => {
574
        if (!called) {
575
          called = true;
576
          r = f.apply(null, args);
577
        }
578
        return r;
579
      };
580
    };
581
 
582
    const DeviceType = (os, browser, userAgent, mediaMatch) => {
583
      const isiPad = os.isiOS() && /ipad/i.test(userAgent) === true;
584
      const isiPhone = os.isiOS() && !isiPad;
585
      const isMobile = os.isiOS() || os.isAndroid();
586
      const isTouch = isMobile || mediaMatch('(pointer:coarse)');
587
      const isTablet = isiPad || !isiPhone && isMobile && mediaMatch('(min-device-width:768px)');
588
      const isPhone = isiPhone || isMobile && !isTablet;
589
      const iOSwebview = browser.isSafari() && os.isiOS() && /safari/i.test(userAgent) === false;
590
      const isDesktop = !isPhone && !isTablet && !iOSwebview;
591
      return {
592
        isiPad: constant(isiPad),
593
        isiPhone: constant(isiPhone),
594
        isTablet: constant(isTablet),
595
        isPhone: constant(isPhone),
596
        isTouch: constant(isTouch),
597
        isAndroid: os.isAndroid,
598
        isiOS: os.isiOS,
599
        isWebView: constant(iOSwebview),
600
        isDesktop: constant(isDesktop)
601
      };
602
    };
603
 
604
    const firstMatch = (regexes, s) => {
605
      for (let i = 0; i < regexes.length; i++) {
606
        const x = regexes[i];
607
        if (x.test(s)) {
608
          return x;
609
        }
610
      }
611
      return undefined;
612
    };
613
    const find = (regexes, agent) => {
614
      const r = firstMatch(regexes, agent);
615
      if (!r) {
616
        return {
617
          major: 0,
618
          minor: 0
619
        };
620
      }
621
      const group = i => {
622
        return Number(agent.replace(r, '$' + i));
623
      };
624
      return nu$2(group(1), group(2));
625
    };
626
    const detect$3 = (versionRegexes, agent) => {
627
      const cleanedAgent = String(agent).toLowerCase();
628
      if (versionRegexes.length === 0) {
629
        return unknown$2();
630
      }
631
      return find(versionRegexes, cleanedAgent);
632
    };
633
    const unknown$2 = () => {
634
      return nu$2(0, 0);
635
    };
636
    const nu$2 = (major, minor) => {
637
      return {
638
        major,
639
        minor
640
      };
641
    };
642
    const Version = {
643
      nu: nu$2,
644
      detect: detect$3,
645
      unknown: unknown$2
646
    };
647
 
648
    const detectBrowser$1 = (browsers, userAgentData) => {
649
      return findMap(userAgentData.brands, uaBrand => {
650
        const lcBrand = uaBrand.brand.toLowerCase();
651
        return find$1(browsers, browser => {
652
          var _a;
653
          return lcBrand === ((_a = browser.brand) === null || _a === void 0 ? void 0 : _a.toLowerCase());
654
        }).map(info => ({
655
          current: info.name,
656
          version: Version.nu(parseInt(uaBrand.version, 10), 0)
657
        }));
658
      });
659
    };
660
 
661
    const detect$2 = (candidates, userAgent) => {
662
      const agent = String(userAgent).toLowerCase();
663
      return find$1(candidates, candidate => {
664
        return candidate.search(agent);
665
      });
666
    };
667
    const detectBrowser = (browsers, userAgent) => {
668
      return detect$2(browsers, userAgent).map(browser => {
669
        const version = Version.detect(browser.versionRegexes, userAgent);
670
        return {
671
          current: browser.name,
672
          version
673
        };
674
      });
675
    };
676
    const detectOs = (oses, userAgent) => {
677
      return detect$2(oses, userAgent).map(os => {
678
        const version = Version.detect(os.versionRegexes, userAgent);
679
        return {
680
          current: os.name,
681
          version
682
        };
683
      });
684
    };
685
 
686
    const normalVersionRegex = /.*?version\/\ ?([0-9]+)\.([0-9]+).*/;
687
    const checkContains = target => {
688
      return uastring => {
689
        return contains(uastring, target);
690
      };
691
    };
692
    const browsers = [
693
      {
694
        name: 'Edge',
695
        versionRegexes: [/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],
696
        search: uastring => {
697
          return contains(uastring, 'edge/') && contains(uastring, 'chrome') && contains(uastring, 'safari') && contains(uastring, 'applewebkit');
698
        }
699
      },
700
      {
701
        name: 'Chromium',
702
        brand: 'Chromium',
703
        versionRegexes: [
704
          /.*?chrome\/([0-9]+)\.([0-9]+).*/,
705
          normalVersionRegex
706
        ],
707
        search: uastring => {
708
          return contains(uastring, 'chrome') && !contains(uastring, 'chromeframe');
709
        }
710
      },
711
      {
712
        name: 'IE',
713
        versionRegexes: [
714
          /.*?msie\ ?([0-9]+)\.([0-9]+).*/,
715
          /.*?rv:([0-9]+)\.([0-9]+).*/
716
        ],
717
        search: uastring => {
718
          return contains(uastring, 'msie') || contains(uastring, 'trident');
719
        }
720
      },
721
      {
722
        name: 'Opera',
723
        versionRegexes: [
724
          normalVersionRegex,
725
          /.*?opera\/([0-9]+)\.([0-9]+).*/
726
        ],
727
        search: checkContains('opera')
728
      },
729
      {
730
        name: 'Firefox',
731
        versionRegexes: [/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],
732
        search: checkContains('firefox')
733
      },
734
      {
735
        name: 'Safari',
736
        versionRegexes: [
737
          normalVersionRegex,
738
          /.*?cpu os ([0-9]+)_([0-9]+).*/
739
        ],
740
        search: uastring => {
741
          return (contains(uastring, 'safari') || contains(uastring, 'mobile/')) && contains(uastring, 'applewebkit');
742
        }
743
      }
744
    ];
745
    const oses = [
746
      {
747
        name: 'Windows',
748
        search: checkContains('win'),
749
        versionRegexes: [/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]
750
      },
751
      {
752
        name: 'iOS',
753
        search: uastring => {
754
          return contains(uastring, 'iphone') || contains(uastring, 'ipad');
755
        },
756
        versionRegexes: [
757
          /.*?version\/\ ?([0-9]+)\.([0-9]+).*/,
758
          /.*cpu os ([0-9]+)_([0-9]+).*/,
759
          /.*cpu iphone os ([0-9]+)_([0-9]+).*/
760
        ]
761
      },
762
      {
763
        name: 'Android',
764
        search: checkContains('android'),
765
        versionRegexes: [/.*?android\ ?([0-9]+)\.([0-9]+).*/]
766
      },
767
      {
768
        name: 'macOS',
769
        search: checkContains('mac os x'),
770
        versionRegexes: [/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]
771
      },
772
      {
773
        name: 'Linux',
774
        search: checkContains('linux'),
775
        versionRegexes: []
776
      },
777
      {
778
        name: 'Solaris',
779
        search: checkContains('sunos'),
780
        versionRegexes: []
781
      },
782
      {
783
        name: 'FreeBSD',
784
        search: checkContains('freebsd'),
785
        versionRegexes: []
786
      },
787
      {
788
        name: 'ChromeOS',
789
        search: checkContains('cros'),
790
        versionRegexes: [/.*?chrome\/([0-9]+)\.([0-9]+).*/]
791
      }
792
    ];
793
    const PlatformInfo = {
794
      browsers: constant(browsers),
795
      oses: constant(oses)
796
    };
797
 
798
    const edge = 'Edge';
799
    const chromium = 'Chromium';
800
    const ie = 'IE';
801
    const opera = 'Opera';
802
    const firefox = 'Firefox';
803
    const safari = 'Safari';
804
    const unknown$1 = () => {
805
      return nu$1({
806
        current: undefined,
807
        version: Version.unknown()
808
      });
809
    };
810
    const nu$1 = info => {
811
      const current = info.current;
812
      const version = info.version;
813
      const isBrowser = name => () => current === name;
814
      return {
815
        current,
816
        version,
817
        isEdge: isBrowser(edge),
818
        isChromium: isBrowser(chromium),
819
        isIE: isBrowser(ie),
820
        isOpera: isBrowser(opera),
821
        isFirefox: isBrowser(firefox),
822
        isSafari: isBrowser(safari)
823
      };
824
    };
825
    const Browser = {
826
      unknown: unknown$1,
827
      nu: nu$1,
828
      edge: constant(edge),
829
      chromium: constant(chromium),
830
      ie: constant(ie),
831
      opera: constant(opera),
832
      firefox: constant(firefox),
833
      safari: constant(safari)
834
    };
835
 
836
    const windows = 'Windows';
837
    const ios = 'iOS';
838
    const android = 'Android';
839
    const linux = 'Linux';
840
    const macos = 'macOS';
841
    const solaris = 'Solaris';
842
    const freebsd = 'FreeBSD';
843
    const chromeos = 'ChromeOS';
844
    const unknown = () => {
845
      return nu({
846
        current: undefined,
847
        version: Version.unknown()
848
      });
849
    };
850
    const nu = info => {
851
      const current = info.current;
852
      const version = info.version;
853
      const isOS = name => () => current === name;
854
      return {
855
        current,
856
        version,
857
        isWindows: isOS(windows),
858
        isiOS: isOS(ios),
859
        isAndroid: isOS(android),
860
        isMacOS: isOS(macos),
861
        isLinux: isOS(linux),
862
        isSolaris: isOS(solaris),
863
        isFreeBSD: isOS(freebsd),
864
        isChromeOS: isOS(chromeos)
865
      };
866
    };
867
    const OperatingSystem = {
868
      unknown,
869
      nu,
870
      windows: constant(windows),
871
      ios: constant(ios),
872
      android: constant(android),
873
      linux: constant(linux),
874
      macos: constant(macos),
875
      solaris: constant(solaris),
876
      freebsd: constant(freebsd),
877
      chromeos: constant(chromeos)
878
    };
879
 
880
    const detect$1 = (userAgent, userAgentDataOpt, mediaMatch) => {
881
      const browsers = PlatformInfo.browsers();
882
      const oses = PlatformInfo.oses();
883
      const browser = userAgentDataOpt.bind(userAgentData => detectBrowser$1(browsers, userAgentData)).orThunk(() => detectBrowser(browsers, userAgent)).fold(Browser.unknown, Browser.nu);
884
      const os = detectOs(oses, userAgent).fold(OperatingSystem.unknown, OperatingSystem.nu);
885
      const deviceType = DeviceType(os, browser, userAgent, mediaMatch);
886
      return {
887
        browser,
888
        os,
889
        deviceType
890
      };
891
    };
892
    const PlatformDetection = { detect: detect$1 };
893
 
894
    const mediaMatch = query => window.matchMedia(query).matches;
1441 ariadna 895
    let platform = cached(() => PlatformDetection.detect(window.navigator.userAgent, Optional.from(window.navigator.userAgentData), mediaMatch));
1 efrain 896
    const detect = () => platform();
897
 
898
    const r = (left, top) => {
899
      const translate = (x, y) => r(left + x, top + y);
900
      return {
901
        left,
902
        top,
903
        translate
904
      };
905
    };
906
    const SugarPosition = r;
907
 
908
    const get$1 = _DOC => {
909
      const doc = _DOC !== undefined ? _DOC.dom : document;
910
      const x = doc.body.scrollLeft || doc.documentElement.scrollLeft;
911
      const y = doc.body.scrollTop || doc.documentElement.scrollTop;
912
      return SugarPosition(x, y);
913
    };
914
 
915
    const get = _win => {
916
      const win = _win === undefined ? window : _win;
917
      if (detect().browser.isFirefox()) {
918
        return Optional.none();
919
      } else {
920
        return Optional.from(win.visualViewport);
921
      }
922
    };
923
    const bounds = (x, y, width, height) => ({
924
      x,
925
      y,
926
      width,
927
      height,
928
      right: x + width,
929
      bottom: y + height
930
    });
931
    const getBounds = _win => {
932
      const win = _win === undefined ? window : _win;
933
      const doc = win.document;
934
      const scroll = get$1(SugarElement.fromDom(doc));
935
      return get(win).fold(() => {
936
        const html = win.document.documentElement;
937
        const width = html.clientWidth;
938
        const height = html.clientHeight;
939
        return bounds(scroll.left, scroll.top, width, height);
940
      }, visualViewport => bounds(Math.max(visualViewport.pageLeft, scroll.left), Math.max(visualViewport.pageTop, scroll.top), visualViewport.width, visualViewport.height));
941
    };
942
    const bind = (name, callback, _win) => get(_win).map(visualViewport => {
943
      const handler = e => callback(fromRawEvent(e));
944
      visualViewport.addEventListener(name, handler);
945
      return { unbind: () => visualViewport.removeEventListener(name, handler) };
946
    }).getOrThunk(() => ({ unbind: noop }));
947
 
1441 ariadna 948
    var global$2 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
1 efrain 949
 
1441 ariadna 950
    var global$1 = tinymce.util.Tools.resolve('tinymce.Env');
1 efrain 951
 
952
    const fireFullscreenStateChanged = (editor, state) => {
953
      editor.dispatch('FullscreenStateChanged', { state });
954
      editor.dispatch('ResizeEditor');
955
    };
956
 
957
    const option = name => editor => editor.options.get(name);
958
    const register$2 = editor => {
959
      const registerOption = editor.options.register;
960
      registerOption('fullscreen_native', {
961
        processor: 'boolean',
962
        default: false
963
      });
964
    };
965
    const getFullscreenNative = option('fullscreen_native');
966
 
967
    const getFullscreenRoot = editor => {
968
      const elem = SugarElement.fromDom(editor.getElement());
969
      return getShadowRoot(elem).map(getShadowHost).getOrThunk(() => getBody(owner(elem)));
970
    };
971
    const getFullscreenElement = root => {
972
      if (root.fullscreenElement !== undefined) {
973
        return root.fullscreenElement;
974
      } else if (root.msFullscreenElement !== undefined) {
975
        return root.msFullscreenElement;
976
      } else if (root.webkitFullscreenElement !== undefined) {
977
        return root.webkitFullscreenElement;
978
      } else {
979
        return null;
980
      }
981
    };
982
    const getFullscreenchangeEventName = () => {
983
      if (document.fullscreenElement !== undefined) {
984
        return 'fullscreenchange';
985
      } else if (document.msFullscreenElement !== undefined) {
986
        return 'MSFullscreenChange';
987
      } else if (document.webkitFullscreenElement !== undefined) {
988
        return 'webkitfullscreenchange';
989
      } else {
990
        return 'fullscreenchange';
991
      }
992
    };
993
    const requestFullscreen = sugarElem => {
994
      const elem = sugarElem.dom;
995
      if (elem.requestFullscreen) {
996
        elem.requestFullscreen();
997
      } else if (elem.msRequestFullscreen) {
998
        elem.msRequestFullscreen();
999
      } else if (elem.webkitRequestFullScreen) {
1000
        elem.webkitRequestFullScreen();
1001
      }
1002
    };
1003
    const exitFullscreen = sugarDoc => {
1004
      const doc = sugarDoc.dom;
1005
      if (doc.exitFullscreen) {
1006
        doc.exitFullscreen();
1007
      } else if (doc.msExitFullscreen) {
1008
        doc.msExitFullscreen();
1009
      } else if (doc.webkitCancelFullScreen) {
1010
        doc.webkitCancelFullScreen();
1011
      }
1012
    };
1013
    const isFullscreenElement = elem => elem.dom === getFullscreenElement(owner(elem).dom);
1014
 
1015
    const ancestors$1 = (scope, predicate, isRoot) => filter$1(parents(scope, isRoot), predicate);
1016
    const siblings$1 = (scope, predicate) => filter$1(siblings$2(scope), predicate);
1017
 
1018
    const all = selector => all$1(selector);
1019
    const ancestors = (scope, selector, isRoot) => ancestors$1(scope, e => is(e, selector), isRoot);
1020
    const siblings = (scope, selector) => siblings$1(scope, e => is(e, selector));
1021
 
1022
    const attr = 'data-ephox-mobile-fullscreen-style';
1023
    const siblingStyles = 'display:none!important;';
1024
    const ancestorPosition = 'position:absolute!important;';
1025
    const ancestorStyles = 'top:0!important;left:0!important;margin:0!important;padding:0!important;width:100%!important;height:100%!important;overflow:visible!important;';
1026
    const bgFallback = 'background-color:rgb(255,255,255)!important;';
1441 ariadna 1027
    const isAndroid = global$1.os.isAndroid();
1 efrain 1028
    const matchColor = editorBody => {
1029
      const color = get$2(editorBody, 'background-color');
1030
      return color !== undefined && color !== '' ? 'background-color:' + color + '!important' : bgFallback;
1031
    };
1032
    const clobberStyles = (dom, container, editorBody) => {
1033
      const gatherSiblings = element => {
1034
        return siblings(element, '*:not(.tox-silver-sink)');
1035
      };
1036
      const clobber = clobberStyle => element => {
1037
        const styles = get$3(element, 'style');
1038
        const backup = styles === undefined ? 'no-styles' : styles.trim();
1039
        if (backup === clobberStyle) {
1040
          return;
1041
        } else {
1042
          set$1(element, attr, backup);
1043
          setAll(element, dom.parseStyle(clobberStyle));
1044
        }
1045
      };
1046
      const ancestors$1 = ancestors(container, '*');
1047
      const siblings$1 = bind$3(ancestors$1, gatherSiblings);
1048
      const bgColor = matchColor(editorBody);
1049
      each$1(siblings$1, clobber(siblingStyles));
1050
      each$1(ancestors$1, clobber(ancestorPosition + ancestorStyles + bgColor));
1051
      const containerStyles = isAndroid === true ? '' : ancestorPosition;
1052
      clobber(containerStyles + ancestorStyles + bgColor)(container);
1053
    };
1054
    const restoreStyles = dom => {
1055
      const clobberedEls = all('[' + attr + ']');
1056
      each$1(clobberedEls, element => {
1057
        const restore = get$3(element, attr);
1058
        if (restore && restore !== 'no-styles') {
1059
          setAll(element, dom.parseStyle(restore));
1060
        } else {
1061
          remove(element, 'style');
1062
        }
1063
        remove(element, attr);
1064
      });
1065
    };
1066
 
1441 ariadna 1067
    const DOM = global$2.DOM;
1 efrain 1068
    const getScrollPos = () => getBounds(window);
1069
    const setScrollPos = pos => window.scrollTo(pos.x, pos.y);
1070
    const viewportUpdate = get().fold(() => ({
1071
      bind: noop,
1072
      unbind: noop
1073
    }), visualViewport => {
1074
      const editorContainer = value();
1075
      const resizeBinder = unbindable();
1076
      const scrollBinder = unbindable();
1077
      const refreshScroll = () => {
1078
        document.body.scrollTop = 0;
1079
        document.documentElement.scrollTop = 0;
1080
      };
1081
      const refreshVisualViewport = () => {
1082
        window.requestAnimationFrame(() => {
1083
          editorContainer.on(container => setAll(container, {
1084
            top: visualViewport.offsetTop + 'px',
1085
            left: visualViewport.offsetLeft + 'px',
1086
            height: visualViewport.height + 'px',
1087
            width: visualViewport.width + 'px'
1088
          }));
1089
        });
1090
      };
1091
      const update = first(() => {
1092
        refreshScroll();
1093
        refreshVisualViewport();
1094
      }, 50);
1095
      const bind$1 = element => {
1096
        editorContainer.set(element);
1097
        update.throttle();
1098
        resizeBinder.set(bind('resize', update.throttle));
1099
        scrollBinder.set(bind('scroll', update.throttle));
1100
      };
1101
      const unbind = () => {
1102
        editorContainer.on(() => {
1103
          resizeBinder.clear();
1104
          scrollBinder.clear();
1105
        });
1106
        editorContainer.clear();
1107
      };
1108
      return {
1109
        bind: bind$1,
1110
        unbind
1111
      };
1112
    });
1113
    const toggleFullscreen = (editor, fullscreenState) => {
1114
      const body = document.body;
1115
      const documentElement = document.documentElement;
1116
      const editorContainer = editor.getContainer();
1117
      const editorContainerS = SugarElement.fromDom(editorContainer);
1118
      const sinkContainerS = nextSibling(editorContainerS).filter(elm => isHTMLElement(elm) && has(elm, 'tox-silver-sink'));
1119
      const fullscreenRoot = getFullscreenRoot(editor);
1120
      const fullscreenInfo = fullscreenState.get();
1121
      const editorBody = SugarElement.fromDom(editor.getBody());
1441 ariadna 1122
      const isTouch = global$1.deviceType.isTouch();
1 efrain 1123
      const editorContainerStyle = editorContainer.style;
1124
      const iframe = editor.iframeElement;
1125
      const iframeStyle = iframe === null || iframe === void 0 ? void 0 : iframe.style;
1126
      const handleClasses = handler => {
1127
        handler(body, 'tox-fullscreen');
1128
        handler(documentElement, 'tox-fullscreen');
1129
        handler(editorContainer, 'tox-fullscreen');
1130
        getShadowRoot(editorContainerS).map(root => getShadowHost(root).dom).each(host => {
1131
          handler(host, 'tox-fullscreen');
1132
          handler(host, 'tox-shadowhost');
1133
        });
1134
      };
1135
      const cleanup = () => {
1136
        if (isTouch) {
1137
          restoreStyles(editor.dom);
1138
        }
1139
        handleClasses(DOM.removeClass);
1140
        viewportUpdate.unbind();
1141
        Optional.from(fullscreenState.get()).each(info => info.fullscreenChangeHandler.unbind());
1142
      };
1143
      if (!fullscreenInfo) {
1144
        const fullscreenChangeHandler = bind$1(owner(fullscreenRoot), getFullscreenchangeEventName(), _evt => {
1145
          if (getFullscreenNative(editor)) {
1146
            if (!isFullscreenElement(fullscreenRoot) && fullscreenState.get() !== null) {
1147
              toggleFullscreen(editor, fullscreenState);
1148
            }
1149
          }
1150
        });
1151
        const newFullScreenInfo = {
1152
          scrollPos: getScrollPos(),
1153
          containerWidth: editorContainerStyle.width,
1154
          containerHeight: editorContainerStyle.height,
1155
          containerTop: editorContainerStyle.top,
1156
          containerLeft: editorContainerStyle.left,
1157
          iframeWidth: iframeStyle.width,
1158
          iframeHeight: iframeStyle.height,
1159
          fullscreenChangeHandler,
1160
          sinkCssPosition: sinkContainerS.map(elm => get$2(elm, 'position'))
1161
        };
1162
        if (isTouch) {
1163
          clobberStyles(editor.dom, editorContainerS, editorBody);
1164
        }
1165
        iframeStyle.width = iframeStyle.height = '100%';
1166
        editorContainerStyle.width = editorContainerStyle.height = '';
1167
        handleClasses(DOM.addClass);
1168
        sinkContainerS.each(elm => {
1169
          set(elm, 'position', 'fixed');
1170
        });
1171
        viewportUpdate.bind(editorContainerS);
1172
        editor.on('remove', cleanup);
1173
        fullscreenState.set(newFullScreenInfo);
1174
        if (getFullscreenNative(editor)) {
1175
          requestFullscreen(fullscreenRoot);
1176
        }
1177
        fireFullscreenStateChanged(editor, true);
1178
      } else {
1179
        fullscreenInfo.fullscreenChangeHandler.unbind();
1180
        if (getFullscreenNative(editor) && isFullscreenElement(fullscreenRoot)) {
1181
          exitFullscreen(owner(fullscreenRoot));
1182
        }
1183
        iframeStyle.width = fullscreenInfo.iframeWidth;
1184
        iframeStyle.height = fullscreenInfo.iframeHeight;
1185
        editorContainerStyle.width = fullscreenInfo.containerWidth;
1186
        editorContainerStyle.height = fullscreenInfo.containerHeight;
1187
        editorContainerStyle.top = fullscreenInfo.containerTop;
1188
        editorContainerStyle.left = fullscreenInfo.containerLeft;
1189
        lift2(sinkContainerS, fullscreenInfo.sinkCssPosition, (elm, val) => {
1190
          set(elm, 'position', val);
1191
        });
1192
        cleanup();
1193
        setScrollPos(fullscreenInfo.scrollPos);
1194
        fullscreenState.set(null);
1195
        fireFullscreenStateChanged(editor, false);
1196
        editor.off('remove', cleanup);
1197
      }
1198
    };
1199
 
1200
    const register$1 = (editor, fullscreenState) => {
1201
      editor.addCommand('mceFullScreen', () => {
1202
        toggleFullscreen(editor, fullscreenState);
1203
      });
1204
    };
1205
 
1441 ariadna 1206
    var global = tinymce.util.Tools.resolve('tinymce.util.VK');
1207
 
1208
    const setup = (editor, fullscreenState) => {
1209
      editor.on('init', () => {
1210
        editor.on('keydown', e => {
1211
          if (e.keyCode === global.TAB && !(e.metaKey || e.ctrlKey) && fullscreenState.get()) {
1212
            e.preventDefault();
1213
          }
1214
        });
1215
      });
1216
    };
1217
 
1 efrain 1218
    const makeSetupHandler = (editor, fullscreenState) => api => {
1219
      api.setActive(fullscreenState.get() !== null);
1220
      const editorEventCallback = e => api.setActive(e.state);
1221
      editor.on('FullscreenStateChanged', editorEventCallback);
1222
      return () => editor.off('FullscreenStateChanged', editorEventCallback);
1223
    };
1224
    const register = (editor, fullscreenState) => {
1225
      const onAction = () => editor.execCommand('mceFullScreen');
1226
      editor.ui.registry.addToggleMenuItem('fullscreen', {
1227
        text: 'Fullscreen',
1228
        icon: 'fullscreen',
1229
        shortcut: 'Meta+Shift+F',
1230
        onAction,
1441 ariadna 1231
        onSetup: makeSetupHandler(editor, fullscreenState),
1232
        context: 'any'
1 efrain 1233
      });
1234
      editor.ui.registry.addToggleButton('fullscreen', {
1235
        tooltip: 'Fullscreen',
1236
        icon: 'fullscreen',
1237
        onAction,
1441 ariadna 1238
        onSetup: makeSetupHandler(editor, fullscreenState),
1239
        shortcut: 'Meta+Shift+F',
1240
        context: 'any'
1 efrain 1241
      });
1242
    };
1243
 
1244
    var Plugin = () => {
1441 ariadna 1245
      global$3.add('fullscreen', editor => {
1 efrain 1246
        const fullscreenState = Cell(null);
1247
        if (editor.inline) {
1248
          return get$5(fullscreenState);
1249
        }
1250
        register$2(editor);
1251
        register$1(editor, fullscreenState);
1252
        register(editor, fullscreenState);
1441 ariadna 1253
        setup(editor, fullscreenState);
1 efrain 1254
        editor.addShortcut('Meta+Shift+F', '', 'mceFullScreen');
1255
        return get$5(fullscreenState);
1256
      });
1257
    };
1258
 
1259
    Plugin();
1260
 
1261
})();