Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 1... Línea 1...
1
/**
1
/**
2
 * TinyMCE version 6.8.3 (2024-02-08)
2
 * TinyMCE version 7.7.1 (2025-03-05)
3
 */
3
 */
Línea 4... Línea 4...
4
 
4
 
5
(function () {
5
(function () {
Línea 6... Línea 6...
6
    'use strict';
6
    'use strict';
Línea 7... Línea -...
7
 
-
 
8
    var global$1 = 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 isString = isType('string');
-
 
33
    const isBoolean = isSimpleType('boolean');
-
 
34
    const isNullable = a => a === null || a === undefined;
-
 
35
    const isNonNullable = a => !isNullable(a);
-
 
36
    const isFunction = isSimpleType('function');
-
 
37
 
-
 
38
    const option = name => editor => editor.options.get(name);
-
 
39
    const register = editor => {
-
 
40
      const registerOption = editor.options.register;
-
 
41
      const toolbarProcessor = defaultValue => value => {
-
 
42
        const valid = isBoolean(value) || isString(value);
-
 
43
        if (valid) {
-
 
44
          if (isBoolean(value)) {
-
 
45
            return {
-
 
46
              value: value ? defaultValue : '',
-
 
47
              valid
-
 
48
            };
-
 
49
          } else {
-
 
50
            return {
-
 
51
              value: value.trim(),
-
 
52
              valid
-
 
53
            };
-
 
54
          }
-
 
55
        } else {
-
 
56
          return {
-
 
57
            valid: false,
-
 
58
            message: 'Must be a boolean or string.'
-
 
59
          };
-
 
60
        }
-
 
61
      };
-
 
62
      const defaultSelectionToolbar = 'bold italic | quicklink h2 h3 blockquote';
-
 
63
      registerOption('quickbars_selection_toolbar', {
-
 
64
        processor: toolbarProcessor(defaultSelectionToolbar),
-
 
65
        default: defaultSelectionToolbar
-
 
66
      });
-
 
67
      const defaultInsertToolbar = 'quickimage quicktable';
-
 
68
      registerOption('quickbars_insert_toolbar', {
-
 
69
        processor: toolbarProcessor(defaultInsertToolbar),
-
 
70
        default: defaultInsertToolbar
-
 
71
      });
-
 
72
      const defaultImageToolbar = 'alignleft aligncenter alignright';
-
 
73
      registerOption('quickbars_image_toolbar', {
-
 
74
        processor: toolbarProcessor(defaultImageToolbar),
-
 
75
        default: defaultImageToolbar
7
 
76
      });
-
 
77
    };
-
 
Línea 78... Línea 8...
78
    const getTextSelectionToolbarItems = option('quickbars_selection_toolbar');
8
    var global$1 = tinymce.util.Tools.resolve('tinymce.PluginManager');
79
    const getInsertToolbarItems = option('quickbars_insert_toolbar');
9
 
80
    const getImageToolbarItems = option('quickbars_image_toolbar');
10
    const random = () => window.crypto.getRandomValues(new Uint32Array(1))[0] / 4294967295;
81
 
11
 
82
    let unique = 0;
12
    let unique = 0;
83
    const generate = prefix => {
13
    const generate = prefix => {
84
      const date = new Date();
14
      const date = new Date();
85
      const time = date.getTime();
15
      const time = date.getTime();
Línea 86... Línea 16...
86
      const random = Math.floor(Math.random() * 1000000000);
16
      const random$1 = Math.floor(random() * 1000000000);
87
      unique++;
17
      unique++;
88
      return prefix + '_' + random + unique + String(time);
18
      return prefix + '_' + random$1 + unique + String(time);
Línea 151... Línea 81...
151
      };
81
      };
152
      editor.on('focusin remove', cancelHandler);
82
      editor.on('focusin remove', cancelHandler);
153
      fileInput.click();
83
      fileInput.click();
154
    });
84
    });
Línea -... Línea 85...
-
 
85
 
-
 
86
    const register$1 = editor => {
-
 
87
      editor.on('PreInit', () => {
-
 
88
        if (!editor.queryCommandSupported('QuickbarInsertImage')) {
-
 
89
          editor.addCommand('QuickbarInsertImage', () => {
-
 
90
            pickFile(editor).then(files => {
-
 
91
              if (files.length > 0) {
-
 
92
                const blob = files[0];
-
 
93
                blobToBase64(blob).then(base64 => {
-
 
94
                  insertBlob(editor, base64, blob);
-
 
95
                });
-
 
96
              }
-
 
97
            });
-
 
98
          });
-
 
99
        }
-
 
100
      });
-
 
101
    };
-
 
102
 
-
 
103
    const hasProto = (v, constructor, predicate) => {
-
 
104
      var _a;
-
 
105
      if (predicate(v, constructor.prototype)) {
-
 
106
        return true;
-
 
107
      } else {
-
 
108
        return ((_a = v.constructor) === null || _a === void 0 ? void 0 : _a.name) === constructor.name;
-
 
109
      }
-
 
110
    };
-
 
111
    const typeOf = x => {
-
 
112
      const t = typeof x;
-
 
113
      if (x === null) {
-
 
114
        return 'null';
-
 
115
      } else if (t === 'object' && Array.isArray(x)) {
-
 
116
        return 'array';
-
 
117
      } else if (t === 'object' && hasProto(x, String, (o, proto) => proto.isPrototypeOf(o))) {
-
 
118
        return 'string';
-
 
119
      } else {
-
 
120
        return t;
-
 
121
      }
-
 
122
    };
-
 
123
    const isType = type => value => typeOf(value) === type;
-
 
124
    const isSimpleType = type => value => typeof value === type;
-
 
125
    const isString = isType('string');
-
 
126
    const isBoolean = isSimpleType('boolean');
-
 
127
    const isNullable = a => a === null || a === undefined;
-
 
128
    const isNonNullable = a => !isNullable(a);
-
 
129
    const isFunction = isSimpleType('function');
-
 
130
 
-
 
131
    const option = name => editor => editor.options.get(name);
-
 
132
    const register = editor => {
-
 
133
      const registerOption = editor.options.register;
-
 
134
      const toolbarProcessor = defaultValue => value => {
-
 
135
        const valid = isBoolean(value) || isString(value);
-
 
136
        if (valid) {
-
 
137
          if (isBoolean(value)) {
-
 
138
            return {
-
 
139
              value: value ? defaultValue : '',
-
 
140
              valid
-
 
141
            };
-
 
142
          } else {
-
 
143
            return {
-
 
144
              value: value.trim(),
-
 
145
              valid
-
 
146
            };
-
 
147
          }
-
 
148
        } else {
-
 
149
          return {
-
 
150
            valid: false,
-
 
151
            message: 'Must be a boolean or string.'
-
 
152
          };
-
 
153
        }
-
 
154
      };
-
 
155
      const defaultSelectionToolbar = 'bold italic | quicklink h2 h3 blockquote';
-
 
156
      registerOption('quickbars_selection_toolbar', {
-
 
157
        processor: toolbarProcessor(defaultSelectionToolbar),
-
 
158
        default: defaultSelectionToolbar
-
 
159
      });
-
 
160
      const defaultInsertToolbar = 'quickimage quicktable';
-
 
161
      registerOption('quickbars_insert_toolbar', {
-
 
162
        processor: toolbarProcessor(defaultInsertToolbar),
-
 
163
        default: defaultInsertToolbar
-
 
164
      });
-
 
165
      const defaultImageToolbar = 'alignleft aligncenter alignright';
-
 
166
      registerOption('quickbars_image_toolbar', {
-
 
167
        processor: toolbarProcessor(defaultImageToolbar),
-
 
168
        default: defaultImageToolbar
-
 
169
      });
-
 
170
    };
-
 
171
    const getTextSelectionToolbarItems = option('quickbars_selection_toolbar');
-
 
172
    const getInsertToolbarItems = option('quickbars_insert_toolbar');
-
 
173
    const getImageToolbarItems = option('quickbars_image_toolbar');
155
 
174
 
156
    const setupButtons = editor => {
175
    const setupButtons = editor => {
157
      editor.ui.registry.addButton('quickimage', {
176
      editor.ui.registry.addButton('quickimage', {
158
        icon: 'image',
177
        icon: 'image',
159
        tooltip: 'Insert image',
-
 
160
        onAction: () => {
-
 
161
          pickFile(editor).then(files => {
-
 
162
            if (files.length > 0) {
-
 
163
              const blob = files[0];
-
 
164
              blobToBase64(blob).then(base64 => {
178
        tooltip: 'Insert image',
165
                insertBlob(editor, base64, blob);
-
 
166
              });
-
 
167
            }
-
 
168
          });
-
 
169
        }
179
        onAction: () => editor.execCommand('QuickbarInsertImage')
170
      });
180
      });
171
      editor.ui.registry.addButton('quicktable', {
181
      editor.ui.registry.addButton('quicktable', {
172
        icon: 'table',
182
        icon: 'table',
173
        tooltip: 'Insert table',
183
        tooltip: 'Insert table',
Línea 434... Línea 444...
434
    };
444
    };
Línea 435... Línea 445...
435
 
445
 
436
    var Plugin = () => {
446
    var Plugin = () => {
437
      global$1.add('quickbars', editor => {
447
      global$1.add('quickbars', editor => {
-
 
448
        register(editor);
438
        register(editor);
449
        register$1(editor);
439
        setupButtons(editor);
450
        setupButtons(editor);
440
        addToEditor$1(editor);
451
        addToEditor$1(editor);
441
        addToEditor(editor);
452
        addToEditor(editor);
442
      });
453
      });