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
    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
 
22
    var global$1 = tinymce.util.Tools.resolve('tinymce.PluginManager');
23
 
24
    const constant = value => {
25
      return () => {
26
        return value;
27
      };
28
    };
29
 
30
    var global = tinymce.util.Tools.resolve('tinymce.Env');
31
 
32
    const fireResizeEditor = editor => editor.dispatch('ResizeEditor');
33
 
34
    const option = name => editor => editor.options.get(name);
35
    const register$1 = editor => {
36
      const registerOption = editor.options.register;
37
      registerOption('autoresize_overflow_padding', {
38
        processor: 'number',
39
        default: 1
40
      });
41
      registerOption('autoresize_bottom_margin', {
42
        processor: 'number',
43
        default: 50
44
      });
45
    };
46
    const getMinHeight = option('min_height');
47
    const getMaxHeight = option('max_height');
48
    const getAutoResizeOverflowPadding = option('autoresize_overflow_padding');
49
    const getAutoResizeBottomMargin = option('autoresize_bottom_margin');
50
 
51
    const isFullscreen = editor => editor.plugins.fullscreen && editor.plugins.fullscreen.isFullscreen();
52
    const toggleScrolling = (editor, state) => {
53
      const body = editor.getBody();
54
      if (body) {
55
        body.style.overflowY = state ? '' : 'hidden';
56
        if (!state) {
57
          body.scrollTop = 0;
58
        }
59
      }
60
    };
61
    const parseCssValueToInt = (dom, elm, name, computed) => {
62
      var _a;
63
      const value = parseInt((_a = dom.getStyle(elm, name, computed)) !== null && _a !== void 0 ? _a : '', 10);
64
      return isNaN(value) ? 0 : value;
65
    };
66
    const shouldScrollIntoView = trigger => {
67
      if ((trigger === null || trigger === void 0 ? void 0 : trigger.type.toLowerCase()) === 'setcontent') {
68
        const setContentEvent = trigger;
69
        return setContentEvent.selection === true || setContentEvent.paste === true;
70
      } else {
71
        return false;
72
      }
73
    };
74
    const resize = (editor, oldSize, trigger, getExtraMarginBottom) => {
75
      var _a;
76
      const dom = editor.dom;
77
      const doc = editor.getDoc();
78
      if (!doc) {
79
        return;
80
      }
81
      if (isFullscreen(editor)) {
82
        toggleScrolling(editor, true);
83
        return;
84
      }
85
      const docEle = doc.documentElement;
86
      const resizeBottomMargin = getExtraMarginBottom ? getExtraMarginBottom() : getAutoResizeOverflowPadding(editor);
87
      const minHeight = (_a = getMinHeight(editor)) !== null && _a !== void 0 ? _a : editor.getElement().offsetHeight;
88
      let resizeHeight = minHeight;
89
      const marginTop = parseCssValueToInt(dom, docEle, 'margin-top', true);
90
      const marginBottom = parseCssValueToInt(dom, docEle, 'margin-bottom', true);
91
      let contentHeight = docEle.offsetHeight + marginTop + marginBottom + resizeBottomMargin;
92
      if (contentHeight < 0) {
93
        contentHeight = 0;
94
      }
95
      const containerHeight = editor.getContainer().offsetHeight;
96
      const contentAreaHeight = editor.getContentAreaContainer().offsetHeight;
97
      const chromeHeight = containerHeight - contentAreaHeight;
98
      if (contentHeight + chromeHeight > minHeight) {
99
        resizeHeight = contentHeight + chromeHeight;
100
      }
101
      const maxHeight = getMaxHeight(editor);
102
      if (maxHeight && resizeHeight > maxHeight) {
103
        resizeHeight = maxHeight;
104
        toggleScrolling(editor, true);
105
      } else {
106
        toggleScrolling(editor, false);
107
      }
108
      if (resizeHeight !== oldSize.get()) {
109
        const deltaSize = resizeHeight - oldSize.get();
110
        dom.setStyle(editor.getContainer(), 'height', resizeHeight + 'px');
111
        oldSize.set(resizeHeight);
112
        fireResizeEditor(editor);
113
        if (global.browser.isSafari() && (global.os.isMacOS() || global.os.isiOS())) {
114
          const win = editor.getWin();
115
          win.scrollTo(win.pageXOffset, win.pageYOffset);
116
        }
117
        if (editor.hasFocus() && shouldScrollIntoView(trigger)) {
118
          editor.selection.scrollIntoView();
119
        }
120
        if ((global.browser.isSafari() || global.browser.isChromium()) && deltaSize < 0) {
121
          resize(editor, oldSize, trigger, getExtraMarginBottom);
122
        }
123
      }
124
    };
125
    const setup = (editor, oldSize) => {
126
      let getExtraMarginBottom = () => getAutoResizeBottomMargin(editor);
127
      let resizeCounter;
128
      let sizeAfterFirstResize;
129
      editor.on('init', e => {
130
        resizeCounter = 0;
131
        const overflowPadding = getAutoResizeOverflowPadding(editor);
132
        const dom = editor.dom;
133
        dom.setStyles(editor.getDoc().documentElement, { height: 'auto' });
134
        if (global.browser.isEdge() || global.browser.isIE()) {
135
          dom.setStyles(editor.getBody(), {
136
            'paddingLeft': overflowPadding,
137
            'paddingRight': overflowPadding,
138
            'min-height': 0
139
          });
140
        } else {
141
          dom.setStyles(editor.getBody(), {
142
            paddingLeft: overflowPadding,
143
            paddingRight: overflowPadding
144
          });
145
        }
146
        resize(editor, oldSize, e, getExtraMarginBottom);
147
        resizeCounter += 1;
148
      });
149
      editor.on('NodeChange SetContent keyup FullscreenStateChanged ResizeContent', e => {
150
        if (resizeCounter === 1) {
151
          sizeAfterFirstResize = editor.getContainer().offsetHeight;
152
          resize(editor, oldSize, e, getExtraMarginBottom);
153
          resizeCounter += 1;
154
        } else if (resizeCounter === 2) {
155
          const isLooping = sizeAfterFirstResize < editor.getContainer().offsetHeight;
156
          if (isLooping) {
157
            const dom = editor.dom;
158
            const doc = editor.getDoc();
159
            dom.setStyles(doc.documentElement, { 'min-height': 0 });
160
            dom.setStyles(editor.getBody(), { 'min-height': 'inherit' });
161
          }
162
          getExtraMarginBottom = isLooping ? constant(0) : getExtraMarginBottom;
163
          resizeCounter += 1;
164
        } else {
165
          resize(editor, oldSize, e, getExtraMarginBottom);
166
        }
167
      });
168
    };
169
 
170
    const register = (editor, oldSize) => {
171
      editor.addCommand('mceAutoResize', () => {
172
        resize(editor, oldSize);
173
      });
174
    };
175
 
176
    var Plugin = () => {
177
      global$1.add('autoresize', editor => {
178
        register$1(editor);
179
        if (!editor.options.isSet('resize')) {
180
          editor.options.set('resize', false);
181
        }
182
        if (!editor.inline) {
183
          const oldSize = Cell(0);
184
          register(editor, oldSize);
185
          setup(editor, oldSize);
186
        }
187
      });
188
    };
189
 
190
    Plugin();
191
 
192
})();