[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 /** 2 * Copyright (c) Tiny Technologies, Inc. All rights reserved. 3 * Licensed under the LGPL or a commercial license. 4 * For LGPL see License.txt in the project root for license information. 5 * For commercial licenses see https://www.tiny.cloud/ 6 * 7 * Version: 5.10.5 (2022-05-25) 8 */ 9 (function () { 10 'use strict'; 11 12 var Cell = function (initial) { 13 var value = initial; 14 var get = function () { 15 return value; 16 }; 17 var set = function (v) { 18 value = v; 19 }; 20 return { 21 get: get, 22 set: set 23 }; 24 }; 25 26 var hasOwnProperty = Object.hasOwnProperty; 27 var has = function (obj, key) { 28 return hasOwnProperty.call(obj, key); 29 }; 30 31 var global$2 = tinymce.util.Tools.resolve('tinymce.PluginManager'); 32 33 var global$1 = tinymce.util.Tools.resolve('tinymce.Env'); 34 35 var global = tinymce.util.Tools.resolve('tinymce.util.Delay'); 36 37 var fireResizeEditor = function (editor) { 38 return editor.fire('ResizeEditor'); 39 }; 40 41 var getAutoResizeMinHeight = function (editor) { 42 return editor.getParam('min_height', editor.getElement().offsetHeight, 'number'); 43 }; 44 var getAutoResizeMaxHeight = function (editor) { 45 return editor.getParam('max_height', 0, 'number'); 46 }; 47 var getAutoResizeOverflowPadding = function (editor) { 48 return editor.getParam('autoresize_overflow_padding', 1, 'number'); 49 }; 50 var getAutoResizeBottomMargin = function (editor) { 51 return editor.getParam('autoresize_bottom_margin', 50, 'number'); 52 }; 53 var shouldAutoResizeOnInit = function (editor) { 54 return editor.getParam('autoresize_on_init', true, 'boolean'); 55 }; 56 57 var isFullscreen = function (editor) { 58 return editor.plugins.fullscreen && editor.plugins.fullscreen.isFullscreen(); 59 }; 60 var wait = function (editor, oldSize, times, interval, callback) { 61 global.setEditorTimeout(editor, function () { 62 resize(editor, oldSize); 63 if (times--) { 64 wait(editor, oldSize, times, interval, callback); 65 } else if (callback) { 66 callback(); 67 } 68 }, interval); 69 }; 70 var toggleScrolling = function (editor, state) { 71 var body = editor.getBody(); 72 if (body) { 73 body.style.overflowY = state ? '' : 'hidden'; 74 if (!state) { 75 body.scrollTop = 0; 76 } 77 } 78 }; 79 var parseCssValueToInt = function (dom, elm, name, computed) { 80 var value = parseInt(dom.getStyle(elm, name, computed), 10); 81 return isNaN(value) ? 0 : value; 82 }; 83 var shouldScrollIntoView = function (trigger) { 84 if ((trigger === null || trigger === void 0 ? void 0 : trigger.type.toLowerCase()) === 'setcontent') { 85 var setContentEvent = trigger; 86 return setContentEvent.selection === true || setContentEvent.paste === true; 87 } else { 88 return false; 89 } 90 }; 91 var resize = function (editor, oldSize, trigger) { 92 var dom = editor.dom; 93 var doc = editor.getDoc(); 94 if (!doc) { 95 return; 96 } 97 if (isFullscreen(editor)) { 98 toggleScrolling(editor, true); 99 return; 100 } 101 var docEle = doc.documentElement; 102 var resizeBottomMargin = getAutoResizeBottomMargin(editor); 103 var resizeHeight = getAutoResizeMinHeight(editor); 104 var marginTop = parseCssValueToInt(dom, docEle, 'margin-top', true); 105 var marginBottom = parseCssValueToInt(dom, docEle, 'margin-bottom', true); 106 var contentHeight = docEle.offsetHeight + marginTop + marginBottom + resizeBottomMargin; 107 if (contentHeight < 0) { 108 contentHeight = 0; 109 } 110 var containerHeight = editor.getContainer().offsetHeight; 111 var contentAreaHeight = editor.getContentAreaContainer().offsetHeight; 112 var chromeHeight = containerHeight - contentAreaHeight; 113 if (contentHeight + chromeHeight > getAutoResizeMinHeight(editor)) { 114 resizeHeight = contentHeight + chromeHeight; 115 } 116 var maxHeight = getAutoResizeMaxHeight(editor); 117 if (maxHeight && resizeHeight > maxHeight) { 118 resizeHeight = maxHeight; 119 toggleScrolling(editor, true); 120 } else { 121 toggleScrolling(editor, false); 122 } 123 if (resizeHeight !== oldSize.get()) { 124 var deltaSize = resizeHeight - oldSize.get(); 125 dom.setStyle(editor.getContainer(), 'height', resizeHeight + 'px'); 126 oldSize.set(resizeHeight); 127 fireResizeEditor(editor); 128 if (global$1.browser.isSafari() && global$1.mac) { 129 var win = editor.getWin(); 130 win.scrollTo(win.pageXOffset, win.pageYOffset); 131 } 132 if (editor.hasFocus() && shouldScrollIntoView(trigger)) { 133 editor.selection.scrollIntoView(); 134 } 135 if (global$1.webkit && deltaSize < 0) { 136 resize(editor, oldSize, trigger); 137 } 138 } 139 }; 140 var setup = function (editor, oldSize) { 141 editor.on('init', function () { 142 var overflowPadding = getAutoResizeOverflowPadding(editor); 143 var dom = editor.dom; 144 dom.setStyles(editor.getDoc().documentElement, { height: 'auto' }); 145 dom.setStyles(editor.getBody(), { 146 'paddingLeft': overflowPadding, 147 'paddingRight': overflowPadding, 148 'min-height': 0 149 }); 150 }); 151 editor.on('NodeChange SetContent keyup FullscreenStateChanged ResizeContent', function (e) { 152 resize(editor, oldSize, e); 153 }); 154 if (shouldAutoResizeOnInit(editor)) { 155 editor.on('init', function () { 156 wait(editor, oldSize, 20, 100, function () { 157 wait(editor, oldSize, 5, 1000); 158 }); 159 }); 160 } 161 }; 162 163 var register = function (editor, oldSize) { 164 editor.addCommand('mceAutoResize', function () { 165 resize(editor, oldSize); 166 }); 167 }; 168 169 function Plugin () { 170 global$2.add('autoresize', function (editor) { 171 if (!has(editor.settings, 'resize')) { 172 editor.settings.resize = false; 173 } 174 if (!editor.inline) { 175 var oldSize = Cell(0); 176 register(editor, oldSize); 177 setup(editor, oldSize); 178 } 179 }); 180 } 181 182 Plugin(); 183 184 }());
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |