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