Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
/**
2
 * TinyMCE version 6.8.3 (2024-02-08)
3
 */
4
 
5
(function () {
6
    'use strict';
7
 
8
    var global$1 = tinymce.util.Tools.resolve('tinymce.PluginManager');
9
 
10
    const isSimpleType = type => value => typeof value === type;
11
    const isBoolean = isSimpleType('boolean');
12
    const isNumber = isSimpleType('number');
13
 
14
    const option = name => editor => editor.options.get(name);
15
    const register$2 = editor => {
16
      const registerOption = editor.options.register;
17
      registerOption('nonbreaking_force_tab', {
18
        processor: value => {
19
          if (isBoolean(value)) {
20
            return {
21
              value: value ? 3 : 0,
22
              valid: true
23
            };
24
          } else if (isNumber(value)) {
25
            return {
26
              value,
27
              valid: true
28
            };
29
          } else {
30
            return {
31
              valid: false,
32
              message: 'Must be a boolean or number.'
33
            };
34
          }
35
        },
36
        default: false
37
      });
38
      registerOption('nonbreaking_wrap', {
39
        processor: 'boolean',
40
        default: true
41
      });
42
    };
43
    const getKeyboardSpaces = option('nonbreaking_force_tab');
44
    const wrapNbsps = option('nonbreaking_wrap');
45
 
46
    const stringRepeat = (string, repeats) => {
47
      let str = '';
48
      for (let index = 0; index < repeats; index++) {
49
        str += string;
50
      }
51
      return str;
52
    };
53
    const isVisualCharsEnabled = editor => editor.plugins.visualchars ? editor.plugins.visualchars.isEnabled() : false;
54
    const insertNbsp = (editor, times) => {
55
      const classes = () => isVisualCharsEnabled(editor) ? 'mce-nbsp-wrap mce-nbsp' : 'mce-nbsp-wrap';
56
      const nbspSpan = () => `<span class="${ classes() }" contenteditable="false">${ stringRepeat('&nbsp;', times) }</span>`;
57
      const shouldWrap = wrapNbsps(editor);
58
      const html = shouldWrap || editor.plugins.visualchars ? nbspSpan() : stringRepeat('&nbsp;', times);
59
      editor.undoManager.transact(() => editor.insertContent(html));
60
    };
61
 
62
    const register$1 = editor => {
63
      editor.addCommand('mceNonBreaking', () => {
64
        insertNbsp(editor, 1);
65
      });
66
    };
67
 
68
    var global = tinymce.util.Tools.resolve('tinymce.util.VK');
69
 
70
    const setup = editor => {
71
      const spaces = getKeyboardSpaces(editor);
72
      if (spaces > 0) {
73
        editor.on('keydown', e => {
74
          if (e.keyCode === global.TAB && !e.isDefaultPrevented()) {
75
            if (e.shiftKey) {
76
              return;
77
            }
78
            e.preventDefault();
79
            e.stopImmediatePropagation();
80
            insertNbsp(editor, spaces);
81
          }
82
        });
83
      }
84
    };
85
 
86
    const onSetupEditable = editor => api => {
87
      const nodeChanged = () => {
88
        api.setEnabled(editor.selection.isEditable());
89
      };
90
      editor.on('NodeChange', nodeChanged);
91
      nodeChanged();
92
      return () => {
93
        editor.off('NodeChange', nodeChanged);
94
      };
95
    };
96
    const register = editor => {
97
      const onAction = () => editor.execCommand('mceNonBreaking');
98
      editor.ui.registry.addButton('nonbreaking', {
99
        icon: 'non-breaking',
100
        tooltip: 'Nonbreaking space',
101
        onAction,
102
        onSetup: onSetupEditable(editor)
103
      });
104
      editor.ui.registry.addMenuItem('nonbreaking', {
105
        icon: 'non-breaking',
106
        text: 'Nonbreaking space',
107
        onAction,
108
        onSetup: onSetupEditable(editor)
109
      });
110
    };
111
 
112
    var Plugin = () => {
113
      global$1.add('nonbreaking', editor => {
114
        register$2(editor);
115
        register$1(editor);
116
        register(editor);
117
        setup(editor);
118
      });
119
    };
120
 
121
    Plugin();
122
 
123
})();