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
 
1441 ariadna 8
    var global$1 = tinymce.util.Tools.resolve('tinymce.PluginManager');
1 efrain 9
 
1441 ariadna 10
    const eq = t => a => t === a;
11
    const isUndefined = eq(undefined);
12
    const isNullable = a => a === null || a === undefined;
13
    const isNonNullable = a => !isNullable(a);
1 efrain 14
 
1441 ariadna 15
    class Optional {
16
      constructor(tag, value) {
17
        this.tag = tag;
18
        this.value = value;
19
      }
20
      static some(value) {
21
        return new Optional(true, value);
22
      }
23
      static none() {
24
        return Optional.singletonNone;
25
      }
26
      fold(onNone, onSome) {
27
        if (this.tag) {
28
          return onSome(this.value);
29
        } else {
30
          return onNone();
31
        }
32
      }
33
      isSome() {
34
        return this.tag;
35
      }
36
      isNone() {
37
        return !this.tag;
38
      }
39
      map(mapper) {
40
        if (this.tag) {
41
          return Optional.some(mapper(this.value));
42
        } else {
43
          return Optional.none();
44
        }
45
      }
46
      bind(binder) {
47
        if (this.tag) {
48
          return binder(this.value);
49
        } else {
50
          return Optional.none();
51
        }
52
      }
53
      exists(predicate) {
54
        return this.tag && predicate(this.value);
55
      }
56
      forall(predicate) {
57
        return !this.tag || predicate(this.value);
58
      }
59
      filter(predicate) {
60
        if (!this.tag || predicate(this.value)) {
61
          return this;
62
        } else {
63
          return Optional.none();
64
        }
65
      }
66
      getOr(replacement) {
67
        return this.tag ? this.value : replacement;
68
      }
69
      or(replacement) {
70
        return this.tag ? this : replacement;
71
      }
72
      getOrThunk(thunk) {
73
        return this.tag ? this.value : thunk();
74
      }
75
      orThunk(thunk) {
76
        return this.tag ? this : thunk();
77
      }
78
      getOrDie(message) {
79
        if (!this.tag) {
80
          throw new Error(message !== null && message !== void 0 ? message : 'Called getOrDie on None');
81
        } else {
82
          return this.value;
83
        }
84
      }
85
      static from(value) {
86
        return isNonNullable(value) ? Optional.some(value) : Optional.none();
87
      }
88
      getOrNull() {
89
        return this.tag ? this.value : null;
90
      }
91
      getOrUndefined() {
92
        return this.value;
93
      }
94
      each(worker) {
95
        if (this.tag) {
96
          worker(this.value);
97
        }
98
      }
99
      toArray() {
100
        return this.tag ? [this.value] : [];
101
      }
102
      toString() {
103
        return this.tag ? `some(${ this.value })` : 'none()';
104
      }
105
    }
106
    Optional.singletonNone = new Optional(false);
107
 
108
    const constant = value => {
109
      return () => {
110
        return value;
111
      };
112
    };
113
    const never = constant(false);
114
 
115
    const findUntil = (xs, pred, until) => {
116
      for (let i = 0, len = xs.length; i < len; i++) {
117
        const x = xs[i];
118
        if (pred(x, i)) {
119
          return Optional.some(x);
120
        } else if (until(x, i)) {
121
          break;
122
        }
123
      }
124
      return Optional.none();
125
    };
126
    const find$1 = (xs, pred) => {
127
      return findUntil(xs, pred, never);
128
    };
129
    const findMap = (arr, f) => {
130
      for (let i = 0; i < arr.length; i++) {
131
        const r = f(arr[i], i);
132
        if (r.isSome()) {
133
          return r;
134
        }
135
      }
136
      return Optional.none();
137
    };
138
 
139
    typeof window !== 'undefined' ? window : Function('return this;')();
140
 
141
    const cached = f => {
142
      let called = false;
143
      let r;
144
      return (...args) => {
145
        if (!called) {
146
          called = true;
147
          r = f.apply(null, args);
148
        }
149
        return r;
150
      };
151
    };
152
 
153
    const DeviceType = (os, browser, userAgent, mediaMatch) => {
154
      const isiPad = os.isiOS() && /ipad/i.test(userAgent) === true;
155
      const isiPhone = os.isiOS() && !isiPad;
156
      const isMobile = os.isiOS() || os.isAndroid();
157
      const isTouch = isMobile || mediaMatch('(pointer:coarse)');
158
      const isTablet = isiPad || !isiPhone && isMobile && mediaMatch('(min-device-width:768px)');
159
      const isPhone = isiPhone || isMobile && !isTablet;
160
      const iOSwebview = browser.isSafari() && os.isiOS() && /safari/i.test(userAgent) === false;
161
      const isDesktop = !isPhone && !isTablet && !iOSwebview;
162
      return {
163
        isiPad: constant(isiPad),
164
        isiPhone: constant(isiPhone),
165
        isTablet: constant(isTablet),
166
        isPhone: constant(isPhone),
167
        isTouch: constant(isTouch),
168
        isAndroid: os.isAndroid,
169
        isiOS: os.isiOS,
170
        isWebView: constant(iOSwebview),
171
        isDesktop: constant(isDesktop)
172
      };
173
    };
174
 
175
    const firstMatch = (regexes, s) => {
176
      for (let i = 0; i < regexes.length; i++) {
177
        const x = regexes[i];
178
        if (x.test(s)) {
179
          return x;
180
        }
181
      }
182
      return undefined;
183
    };
184
    const find = (regexes, agent) => {
185
      const r = firstMatch(regexes, agent);
186
      if (!r) {
187
        return {
188
          major: 0,
189
          minor: 0
190
        };
191
      }
192
      const group = i => {
193
        return Number(agent.replace(r, '$' + i));
194
      };
195
      return nu$2(group(1), group(2));
196
    };
197
    const detect$3 = (versionRegexes, agent) => {
198
      const cleanedAgent = String(agent).toLowerCase();
199
      if (versionRegexes.length === 0) {
200
        return unknown$2();
201
      }
202
      return find(versionRegexes, cleanedAgent);
203
    };
204
    const unknown$2 = () => {
205
      return nu$2(0, 0);
206
    };
207
    const nu$2 = (major, minor) => {
208
      return {
209
        major,
210
        minor
211
      };
212
    };
213
    const Version = {
214
      nu: nu$2,
215
      detect: detect$3,
216
      unknown: unknown$2
217
    };
218
 
219
    const detectBrowser$1 = (browsers, userAgentData) => {
220
      return findMap(userAgentData.brands, uaBrand => {
221
        const lcBrand = uaBrand.brand.toLowerCase();
222
        return find$1(browsers, browser => {
223
          var _a;
224
          return lcBrand === ((_a = browser.brand) === null || _a === void 0 ? void 0 : _a.toLowerCase());
225
        }).map(info => ({
226
          current: info.name,
227
          version: Version.nu(parseInt(uaBrand.version, 10), 0)
228
        }));
229
      });
230
    };
231
 
232
    const detect$2 = (candidates, userAgent) => {
233
      const agent = String(userAgent).toLowerCase();
234
      return find$1(candidates, candidate => {
235
        return candidate.search(agent);
236
      });
237
    };
238
    const detectBrowser = (browsers, userAgent) => {
239
      return detect$2(browsers, userAgent).map(browser => {
240
        const version = Version.detect(browser.versionRegexes, userAgent);
241
        return {
242
          current: browser.name,
243
          version
244
        };
245
      });
246
    };
247
    const detectOs = (oses, userAgent) => {
248
      return detect$2(oses, userAgent).map(os => {
249
        const version = Version.detect(os.versionRegexes, userAgent);
250
        return {
251
          current: os.name,
252
          version
253
        };
254
      });
255
    };
256
 
257
    const contains = (str, substr, start = 0, end) => {
258
      const idx = str.indexOf(substr, start);
259
      if (idx !== -1) {
260
        return isUndefined(end) ? true : idx + substr.length <= end;
261
      } else {
262
        return false;
263
      }
264
    };
265
 
266
    const normalVersionRegex = /.*?version\/\ ?([0-9]+)\.([0-9]+).*/;
267
    const checkContains = target => {
268
      return uastring => {
269
        return contains(uastring, target);
270
      };
271
    };
272
    const browsers = [
273
      {
274
        name: 'Edge',
275
        versionRegexes: [/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],
276
        search: uastring => {
277
          return contains(uastring, 'edge/') && contains(uastring, 'chrome') && contains(uastring, 'safari') && contains(uastring, 'applewebkit');
278
        }
279
      },
280
      {
281
        name: 'Chromium',
282
        brand: 'Chromium',
283
        versionRegexes: [
284
          /.*?chrome\/([0-9]+)\.([0-9]+).*/,
285
          normalVersionRegex
286
        ],
287
        search: uastring => {
288
          return contains(uastring, 'chrome') && !contains(uastring, 'chromeframe');
289
        }
290
      },
291
      {
292
        name: 'IE',
293
        versionRegexes: [
294
          /.*?msie\ ?([0-9]+)\.([0-9]+).*/,
295
          /.*?rv:([0-9]+)\.([0-9]+).*/
296
        ],
297
        search: uastring => {
298
          return contains(uastring, 'msie') || contains(uastring, 'trident');
299
        }
300
      },
301
      {
302
        name: 'Opera',
303
        versionRegexes: [
304
          normalVersionRegex,
305
          /.*?opera\/([0-9]+)\.([0-9]+).*/
306
        ],
307
        search: checkContains('opera')
308
      },
309
      {
310
        name: 'Firefox',
311
        versionRegexes: [/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],
312
        search: checkContains('firefox')
313
      },
314
      {
315
        name: 'Safari',
316
        versionRegexes: [
317
          normalVersionRegex,
318
          /.*?cpu os ([0-9]+)_([0-9]+).*/
319
        ],
320
        search: uastring => {
321
          return (contains(uastring, 'safari') || contains(uastring, 'mobile/')) && contains(uastring, 'applewebkit');
322
        }
323
      }
324
    ];
325
    const oses = [
326
      {
327
        name: 'Windows',
328
        search: checkContains('win'),
329
        versionRegexes: [/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]
330
      },
331
      {
332
        name: 'iOS',
333
        search: uastring => {
334
          return contains(uastring, 'iphone') || contains(uastring, 'ipad');
335
        },
336
        versionRegexes: [
337
          /.*?version\/\ ?([0-9]+)\.([0-9]+).*/,
338
          /.*cpu os ([0-9]+)_([0-9]+).*/,
339
          /.*cpu iphone os ([0-9]+)_([0-9]+).*/
340
        ]
341
      },
342
      {
343
        name: 'Android',
344
        search: checkContains('android'),
345
        versionRegexes: [/.*?android\ ?([0-9]+)\.([0-9]+).*/]
346
      },
347
      {
348
        name: 'macOS',
349
        search: checkContains('mac os x'),
350
        versionRegexes: [/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]
351
      },
352
      {
353
        name: 'Linux',
354
        search: checkContains('linux'),
355
        versionRegexes: []
356
      },
357
      {
358
        name: 'Solaris',
359
        search: checkContains('sunos'),
360
        versionRegexes: []
361
      },
362
      {
363
        name: 'FreeBSD',
364
        search: checkContains('freebsd'),
365
        versionRegexes: []
366
      },
367
      {
368
        name: 'ChromeOS',
369
        search: checkContains('cros'),
370
        versionRegexes: [/.*?chrome\/([0-9]+)\.([0-9]+).*/]
371
      }
372
    ];
373
    const PlatformInfo = {
374
      browsers: constant(browsers),
375
      oses: constant(oses)
376
    };
377
 
378
    const edge = 'Edge';
379
    const chromium = 'Chromium';
380
    const ie = 'IE';
381
    const opera = 'Opera';
382
    const firefox = 'Firefox';
383
    const safari = 'Safari';
384
    const unknown$1 = () => {
385
      return nu$1({
386
        current: undefined,
387
        version: Version.unknown()
388
      });
389
    };
390
    const nu$1 = info => {
391
      const current = info.current;
392
      const version = info.version;
393
      const isBrowser = name => () => current === name;
394
      return {
395
        current,
396
        version,
397
        isEdge: isBrowser(edge),
398
        isChromium: isBrowser(chromium),
399
        isIE: isBrowser(ie),
400
        isOpera: isBrowser(opera),
401
        isFirefox: isBrowser(firefox),
402
        isSafari: isBrowser(safari)
403
      };
404
    };
405
    const Browser = {
406
      unknown: unknown$1,
407
      nu: nu$1,
408
      edge: constant(edge),
409
      chromium: constant(chromium),
410
      ie: constant(ie),
411
      opera: constant(opera),
412
      firefox: constant(firefox),
413
      safari: constant(safari)
414
    };
415
 
416
    const windows = 'Windows';
417
    const ios = 'iOS';
418
    const android = 'Android';
419
    const linux = 'Linux';
420
    const macos = 'macOS';
421
    const solaris = 'Solaris';
422
    const freebsd = 'FreeBSD';
423
    const chromeos = 'ChromeOS';
424
    const unknown = () => {
425
      return nu({
426
        current: undefined,
427
        version: Version.unknown()
428
      });
429
    };
430
    const nu = info => {
431
      const current = info.current;
432
      const version = info.version;
433
      const isOS = name => () => current === name;
434
      return {
435
        current,
436
        version,
437
        isWindows: isOS(windows),
438
        isiOS: isOS(ios),
439
        isAndroid: isOS(android),
440
        isMacOS: isOS(macos),
441
        isLinux: isOS(linux),
442
        isSolaris: isOS(solaris),
443
        isFreeBSD: isOS(freebsd),
444
        isChromeOS: isOS(chromeos)
445
      };
446
    };
447
    const OperatingSystem = {
448
      unknown,
449
      nu,
450
      windows: constant(windows),
451
      ios: constant(ios),
452
      android: constant(android),
453
      linux: constant(linux),
454
      macos: constant(macos),
455
      solaris: constant(solaris),
456
      freebsd: constant(freebsd),
457
      chromeos: constant(chromeos)
458
    };
459
 
460
    const detect$1 = (userAgent, userAgentDataOpt, mediaMatch) => {
461
      const browsers = PlatformInfo.browsers();
462
      const oses = PlatformInfo.oses();
463
      const browser = userAgentDataOpt.bind(userAgentData => detectBrowser$1(browsers, userAgentData)).orThunk(() => detectBrowser(browsers, userAgent)).fold(Browser.unknown, Browser.nu);
464
      const os = detectOs(oses, userAgent).fold(OperatingSystem.unknown, OperatingSystem.nu);
465
      const deviceType = DeviceType(os, browser, userAgent, mediaMatch);
466
      return {
467
        browser,
468
        os,
469
        deviceType
470
      };
471
    };
472
    const PlatformDetection = { detect: detect$1 };
473
 
474
    const mediaMatch = query => window.matchMedia(query).matches;
475
    let platform = cached(() => PlatformDetection.detect(window.navigator.userAgent, Optional.from(window.navigator.userAgentData), mediaMatch));
476
    const detect = () => platform();
477
 
478
    const isMacOS = () => detect().os.isMacOS();
479
    const isiOS = () => detect().os.isiOS();
480
 
481
    const getPreventClicksOnLinksScript = () => {
482
      const isMacOSOrIOS = isMacOS() || isiOS();
483
      const fn = isMacOSOrIOS => {
484
        document.addEventListener('click', e => {
485
          for (let elm = e.target; elm; elm = elm.parentNode) {
486
            if (elm.nodeName === 'A') {
487
              const anchor = elm;
488
              const href = anchor.getAttribute('href');
489
              if (href && href.startsWith('#')) {
490
                e.preventDefault();
491
                const targetElement = document.getElementById(href.substring(1));
492
                if (targetElement) {
493
                  targetElement.scrollIntoView({ behavior: 'smooth' });
494
                }
495
                return;
496
              }
497
              const isMetaKeyPressed = isMacOSOrIOS ? e.metaKey : e.ctrlKey && !e.altKey;
498
              if (!isMetaKeyPressed) {
499
                e.preventDefault();
500
              }
501
            }
502
          }
503
        }, false);
504
      };
505
      return `<script>(${ fn.toString() })(${ isMacOSOrIOS })</script>`;
506
    };
507
 
1 efrain 508
    var global = tinymce.util.Tools.resolve('tinymce.util.Tools');
509
 
510
    const option = name => editor => editor.options.get(name);
511
    const getContentStyle = option('content_style');
512
    const shouldUseContentCssCors = option('content_css_cors');
513
    const getBodyClass = option('body_class');
514
    const getBodyId = option('body_id');
515
 
516
    const getPreviewHtml = editor => {
517
      var _a;
518
      let headHtml = '';
519
      const encode = editor.dom.encode;
520
      const contentStyle = (_a = getContentStyle(editor)) !== null && _a !== void 0 ? _a : '';
1441 ariadna 521
      headHtml += `<base href="${ encode(editor.documentBaseURI.getURI()) }">`;
1 efrain 522
      const cors = shouldUseContentCssCors(editor) ? ' crossorigin="anonymous"' : '';
523
      global.each(editor.contentCSS, url => {
524
        headHtml += '<link type="text/css" rel="stylesheet" href="' + encode(editor.documentBaseURI.toAbsolute(url)) + '"' + cors + '>';
525
      });
526
      if (contentStyle) {
527
        headHtml += '<style type="text/css">' + contentStyle + '</style>';
528
      }
529
      const bodyId = getBodyId(editor);
530
      const bodyClass = getBodyClass(editor);
531
      const directionality = editor.getBody().dir;
532
      const dirAttr = directionality ? ' dir="' + encode(directionality) + '"' : '';
1441 ariadna 533
      const previewHtml = '<!DOCTYPE html>' + '<html>' + '<head>' + headHtml + '</head>' + '<body id="' + encode(bodyId) + '" class="mce-content-body ' + encode(bodyClass) + '"' + dirAttr + '>' + editor.getContent() + getPreventClicksOnLinksScript() + '</body>' + '</html>';
1 efrain 534
      return previewHtml;
535
    };
536
 
537
    const open = editor => {
538
      const content = getPreviewHtml(editor);
539
      const dataApi = editor.windowManager.open({
540
        title: 'Preview',
541
        size: 'large',
542
        body: {
543
          type: 'panel',
544
          items: [{
545
              name: 'preview',
546
              type: 'iframe',
547
              sandboxed: true,
548
              transparent: false
549
            }]
550
        },
551
        buttons: [{
552
            type: 'cancel',
553
            name: 'close',
554
            text: 'Close',
555
            primary: true
556
          }],
557
        initialData: { preview: content }
558
      });
559
      dataApi.focus('close');
560
    };
561
 
562
    const register$1 = editor => {
563
      editor.addCommand('mcePreview', () => {
564
        open(editor);
565
      });
566
    };
567
 
568
    const register = editor => {
569
      const onAction = () => editor.execCommand('mcePreview');
570
      editor.ui.registry.addButton('preview', {
571
        icon: 'preview',
572
        tooltip: 'Preview',
1441 ariadna 573
        onAction,
574
        context: 'any'
1 efrain 575
      });
576
      editor.ui.registry.addMenuItem('preview', {
577
        icon: 'preview',
578
        text: 'Preview',
1441 ariadna 579
        onAction,
580
        context: 'any'
1 efrain 581
      });
582
    };
583
 
584
    var Plugin = () => {
1441 ariadna 585
      global$1.add('preview', editor => {
1 efrain 586
        register$1(editor);
587
        register(editor);
588
      });
589
    };
590
 
591
    Plugin();
592
 
593
})();