mirror of
https://github.com/documize/community.git
synced 2025-07-24 15:49:44 +02:00
inymce upgrade 4.7.4
This commit is contained in:
parent
9dcaf697a8
commit
2da0089c1c
119 changed files with 113279 additions and 183 deletions
451
gui/public/tinymce/plugins/autoresize/plugin.js
Executable file
451
gui/public/tinymce/plugins/autoresize/plugin.js
Executable file
|
@ -0,0 +1,451 @@
|
|||
(function () {
|
||||
|
||||
var defs = {}; // id -> {dependencies, definition, instance (possibly undefined)}
|
||||
|
||||
// Used when there is no 'main' module.
|
||||
// The name is probably (hopefully) unique so minification removes for releases.
|
||||
var register_3795 = function (id) {
|
||||
var module = dem(id);
|
||||
var fragments = id.split('.');
|
||||
var target = Function('return this;')();
|
||||
for (var i = 0; i < fragments.length - 1; ++i) {
|
||||
if (target[fragments[i]] === undefined)
|
||||
target[fragments[i]] = {};
|
||||
target = target[fragments[i]];
|
||||
}
|
||||
target[fragments[fragments.length - 1]] = module;
|
||||
};
|
||||
|
||||
var instantiate = function (id) {
|
||||
var actual = defs[id];
|
||||
var dependencies = actual.deps;
|
||||
var definition = actual.defn;
|
||||
var len = dependencies.length;
|
||||
var instances = new Array(len);
|
||||
for (var i = 0; i < len; ++i)
|
||||
instances[i] = dem(dependencies[i]);
|
||||
var defResult = definition.apply(null, instances);
|
||||
if (defResult === undefined)
|
||||
throw 'module [' + id + '] returned undefined';
|
||||
actual.instance = defResult;
|
||||
};
|
||||
|
||||
var def = function (id, dependencies, definition) {
|
||||
if (typeof id !== 'string')
|
||||
throw 'module id must be a string';
|
||||
else if (dependencies === undefined)
|
||||
throw 'no dependencies for ' + id;
|
||||
else if (definition === undefined)
|
||||
throw 'no definition function for ' + id;
|
||||
defs[id] = {
|
||||
deps: dependencies,
|
||||
defn: definition,
|
||||
instance: undefined
|
||||
};
|
||||
};
|
||||
|
||||
var dem = function (id) {
|
||||
var actual = defs[id];
|
||||
if (actual === undefined)
|
||||
throw 'module [' + id + '] was undefined';
|
||||
else if (actual.instance === undefined)
|
||||
instantiate(id);
|
||||
return actual.instance;
|
||||
};
|
||||
|
||||
var req = function (ids, callback) {
|
||||
var len = ids.length;
|
||||
var instances = new Array(len);
|
||||
for (var i = 0; i < len; ++i)
|
||||
instances[i] = dem(ids[i]);
|
||||
callback.apply(null, instances);
|
||||
};
|
||||
|
||||
var ephox = {};
|
||||
|
||||
ephox.bolt = {
|
||||
module: {
|
||||
api: {
|
||||
define: def,
|
||||
require: req,
|
||||
demand: dem
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var define = def;
|
||||
var require = req;
|
||||
var demand = dem;
|
||||
// this helps with minification when using a lot of global references
|
||||
var defineGlobal = function (id, ref) {
|
||||
define(id, [], function () { return ref; });
|
||||
};
|
||||
/*jsc
|
||||
["tinymce.plugins.autoresize.Plugin","ephox.katamari.api.Cell","tinymce.core.PluginManager","tinymce.plugins.autoresize.api.Commands","tinymce.plugins.autoresize.core.Resize","global!tinymce.util.Tools.resolve","tinymce.core.Env","tinymce.core.util.Delay","tinymce.plugins.autoresize.api.Settings"]
|
||||
jsc*/
|
||||
define(
|
||||
'ephox.katamari.api.Cell',
|
||||
|
||||
[
|
||||
],
|
||||
|
||||
function () {
|
||||
var Cell = function (initial) {
|
||||
var value = initial;
|
||||
|
||||
var get = function () {
|
||||
return value;
|
||||
};
|
||||
|
||||
var set = function (v) {
|
||||
value = v;
|
||||
};
|
||||
|
||||
var clone = function () {
|
||||
return Cell(get());
|
||||
};
|
||||
|
||||
return {
|
||||
get: get,
|
||||
set: set,
|
||||
clone: clone
|
||||
};
|
||||
};
|
||||
|
||||
return Cell;
|
||||
}
|
||||
);
|
||||
|
||||
defineGlobal("global!tinymce.util.Tools.resolve", tinymce.util.Tools.resolve);
|
||||
/**
|
||||
* ResolveGlobal.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2017 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
define(
|
||||
'tinymce.core.PluginManager',
|
||||
[
|
||||
'global!tinymce.util.Tools.resolve'
|
||||
],
|
||||
function (resolve) {
|
||||
return resolve('tinymce.PluginManager');
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* ResolveGlobal.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2017 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
define(
|
||||
'tinymce.core.Env',
|
||||
[
|
||||
'global!tinymce.util.Tools.resolve'
|
||||
],
|
||||
function (resolve) {
|
||||
return resolve('tinymce.Env');
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* ResolveGlobal.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2017 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
define(
|
||||
'tinymce.core.util.Delay',
|
||||
[
|
||||
'global!tinymce.util.Tools.resolve'
|
||||
],
|
||||
function (resolve) {
|
||||
return resolve('tinymce.util.Delay');
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Settings.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2017 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
define(
|
||||
'tinymce.plugins.autoresize.api.Settings',
|
||||
[
|
||||
],
|
||||
function () {
|
||||
var getAutoResizeMinHeight = function (editor) {
|
||||
return parseInt(editor.getParam('autoresize_min_height', editor.getElement().offsetHeight), 10);
|
||||
};
|
||||
|
||||
var getAutoResizeMaxHeight = function (editor) {
|
||||
return parseInt(editor.getParam('autoresize_max_height', 0), 10);
|
||||
};
|
||||
|
||||
var getAutoResizeOverflowPadding = function (editor) {
|
||||
return editor.getParam('autoresize_overflow_padding', 1);
|
||||
};
|
||||
|
||||
var getAutoResizeBottomMargin = function (editor) {
|
||||
return editor.getParam('autoresize_bottom_margin', 50);
|
||||
};
|
||||
|
||||
var shouldAutoResizeOnInit = function (editor) {
|
||||
return editor.getParam('autoresize_on_init', true);
|
||||
};
|
||||
|
||||
return {
|
||||
getAutoResizeMinHeight: getAutoResizeMinHeight,
|
||||
getAutoResizeMaxHeight: getAutoResizeMaxHeight,
|
||||
getAutoResizeOverflowPadding: getAutoResizeOverflowPadding,
|
||||
getAutoResizeBottomMargin: getAutoResizeBottomMargin,
|
||||
shouldAutoResizeOnInit: shouldAutoResizeOnInit
|
||||
};
|
||||
}
|
||||
);
|
||||
/**
|
||||
* Plugin.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2017 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class contains all core logic for the autoresize plugin.
|
||||
*
|
||||
* @class tinymce.autoresize.Plugin
|
||||
* @private
|
||||
*/
|
||||
define(
|
||||
'tinymce.plugins.autoresize.core.Resize',
|
||||
[
|
||||
'tinymce.core.Env',
|
||||
'tinymce.core.util.Delay',
|
||||
'tinymce.plugins.autoresize.api.Settings'
|
||||
],
|
||||
function (Env, Delay, Settings) {
|
||||
var isFullscreen = function (editor) {
|
||||
return editor.plugins.fullscreen && editor.plugins.fullscreen.isFullscreen();
|
||||
};
|
||||
|
||||
/**
|
||||
* Calls the resize x times in 100ms intervals. We can't wait for load events since
|
||||
* the CSS files might load async.
|
||||
*/
|
||||
var wait = function (editor, oldSize, times, interval, callback) {
|
||||
Delay.setEditorTimeout(editor, function () {
|
||||
resize(editor, oldSize);
|
||||
|
||||
if (times--) {
|
||||
wait(editor, oldSize, times, interval, callback);
|
||||
} else if (callback) {
|
||||
callback();
|
||||
}
|
||||
}, interval);
|
||||
};
|
||||
|
||||
var toggleScrolling = function (editor, state) {
|
||||
var body = editor.getBody();
|
||||
if (body) {
|
||||
body.style.overflowY = state ? '' : 'hidden';
|
||||
if (!state) {
|
||||
body.scrollTop = 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This method gets executed each time the editor needs to resize.
|
||||
*/
|
||||
var resize = function (editor, oldSize) {
|
||||
var deltaSize, doc, body, resizeHeight, myHeight;
|
||||
var marginTop, marginBottom, paddingTop, paddingBottom, borderTop, borderBottom;
|
||||
var dom = editor.dom;
|
||||
|
||||
doc = editor.getDoc();
|
||||
if (!doc) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isFullscreen(editor)) {
|
||||
toggleScrolling(editor, true);
|
||||
return;
|
||||
}
|
||||
|
||||
body = doc.body;
|
||||
resizeHeight = Settings.getAutoResizeMinHeight(editor);
|
||||
|
||||
// Calculate outer height of the body element using CSS styles
|
||||
marginTop = dom.getStyle(body, 'margin-top', true);
|
||||
marginBottom = dom.getStyle(body, 'margin-bottom', true);
|
||||
paddingTop = dom.getStyle(body, 'padding-top', true);
|
||||
paddingBottom = dom.getStyle(body, 'padding-bottom', true);
|
||||
borderTop = dom.getStyle(body, 'border-top-width', true);
|
||||
borderBottom = dom.getStyle(body, 'border-bottom-width', true);
|
||||
myHeight = body.offsetHeight + parseInt(marginTop, 10) + parseInt(marginBottom, 10) +
|
||||
parseInt(paddingTop, 10) + parseInt(paddingBottom, 10) +
|
||||
parseInt(borderTop, 10) + parseInt(borderBottom, 10);
|
||||
|
||||
// Make sure we have a valid height
|
||||
if (isNaN(myHeight) || myHeight <= 0) {
|
||||
// Get height differently depending on the browser used
|
||||
// eslint-disable-next-line no-nested-ternary
|
||||
myHeight = Env.ie ? body.scrollHeight : (Env.webkit && body.clientHeight === 0 ? 0 : body.offsetHeight);
|
||||
}
|
||||
|
||||
// Don't make it smaller than the minimum height
|
||||
if (myHeight > Settings.getAutoResizeMinHeight(editor)) {
|
||||
resizeHeight = myHeight;
|
||||
}
|
||||
|
||||
// If a maximum height has been defined don't exceed this height
|
||||
var maxHeight = Settings.getAutoResizeMaxHeight(editor);
|
||||
if (maxHeight && myHeight > maxHeight) {
|
||||
resizeHeight = maxHeight;
|
||||
toggleScrolling(editor, true);
|
||||
} else {
|
||||
toggleScrolling(editor, false);
|
||||
}
|
||||
|
||||
// Resize content element
|
||||
if (resizeHeight !== oldSize.get()) {
|
||||
deltaSize = resizeHeight - oldSize.get();
|
||||
dom.setStyle(editor.iframeElement, 'height', resizeHeight + 'px');
|
||||
oldSize.set(resizeHeight);
|
||||
|
||||
// WebKit doesn't decrease the size of the body element until the iframe gets resized
|
||||
// So we need to continue to resize the iframe down until the size gets fixed
|
||||
if (Env.webKit && deltaSize < 0) {
|
||||
resize(editor);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var setup = function (editor, oldSize) {
|
||||
editor.on("init", function () {
|
||||
var overflowPadding, bottomMargin, dom = editor.dom;
|
||||
|
||||
overflowPadding = Settings.getAutoResizeOverflowPadding(editor);
|
||||
bottomMargin = Settings.getAutoResizeBottomMargin(editor);
|
||||
|
||||
if (overflowPadding !== false) {
|
||||
dom.setStyles(editor.getBody(), {
|
||||
paddingLeft: overflowPadding,
|
||||
paddingRight: overflowPadding
|
||||
});
|
||||
}
|
||||
|
||||
if (bottomMargin !== false) {
|
||||
dom.setStyles(editor.getBody(), {
|
||||
paddingBottom: bottomMargin
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
editor.on('nodechange setcontent keyup FullscreenStateChanged', function (e) {
|
||||
resize(editor, oldSize);
|
||||
});
|
||||
|
||||
if (Settings.shouldAutoResizeOnInit(editor)) {
|
||||
editor.on('init', function () {
|
||||
// Hit it 20 times in 100 ms intervals
|
||||
wait(editor, oldSize, 20, 100, function () {
|
||||
// Hit it 5 times in 1 sec intervals
|
||||
wait(editor, oldSize, 5, 1000);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
setup: setup,
|
||||
resize: resize
|
||||
};
|
||||
}
|
||||
);
|
||||
/**
|
||||
* Commands.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2017 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
define(
|
||||
'tinymce.plugins.autoresize.api.Commands',
|
||||
[
|
||||
'tinymce.plugins.autoresize.core.Resize'
|
||||
],
|
||||
function (Resize) {
|
||||
var register = function (editor, oldSize) {
|
||||
editor.addCommand('mceAutoResize', function () {
|
||||
Resize.resize(editor, oldSize);
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
register: register
|
||||
};
|
||||
}
|
||||
);
|
||||
/**
|
||||
* Plugin.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2017 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class contains all core logic for the autoresize plugin.
|
||||
*
|
||||
* @class tinymce.autoresize.Plugin
|
||||
* @private
|
||||
*/
|
||||
define(
|
||||
'tinymce.plugins.autoresize.Plugin',
|
||||
[
|
||||
'ephox.katamari.api.Cell',
|
||||
'tinymce.core.PluginManager',
|
||||
'tinymce.plugins.autoresize.api.Commands',
|
||||
'tinymce.plugins.autoresize.core.Resize'
|
||||
],
|
||||
function (Cell, PluginManager, Commands, Resize) {
|
||||
PluginManager.add('autoresize', function (editor) {
|
||||
if (!editor.inline) {
|
||||
var oldSize = Cell(0);
|
||||
Commands.register(editor, oldSize);
|
||||
Resize.setup(editor, oldSize);
|
||||
}
|
||||
});
|
||||
|
||||
return function () {};
|
||||
}
|
||||
);
|
||||
dem('tinymce.plugins.autoresize.Plugin')();
|
||||
})();
|
|
@ -1 +1 @@
|
|||
tinymce.PluginManager.add("autoresize",function(e){function t(){return e.plugins.fullscreen&&e.plugins.fullscreen.isFullscreen()}function n(r){var a,s,l,u,c,d,f,p,h,m,g,v,y=tinymce.DOM;if(s=e.getDoc()){if(l=s.body,u=s.documentElement,c=i.autoresize_min_height,!l||r&&"setcontent"===r.type&&r.initial||t())return void(l&&u&&(l.style.overflowY="auto",u.style.overflowY="auto"));f=e.dom.getStyle(l,"margin-top",!0),p=e.dom.getStyle(l,"margin-bottom",!0),h=e.dom.getStyle(l,"padding-top",!0),m=e.dom.getStyle(l,"padding-bottom",!0),g=e.dom.getStyle(l,"border-top-width",!0),v=e.dom.getStyle(l,"border-bottom-width",!0),d=l.offsetHeight+parseInt(f,10)+parseInt(p,10)+parseInt(h,10)+parseInt(m,10)+parseInt(g,10)+parseInt(v,10),(isNaN(d)||d<=0)&&(d=tinymce.Env.ie?l.scrollHeight:tinymce.Env.webkit&&0===l.clientHeight?0:l.offsetHeight),d>i.autoresize_min_height&&(c=d),i.autoresize_max_height&&d>i.autoresize_max_height?(c=i.autoresize_max_height,l.style.overflowY="auto",u.style.overflowY="auto"):(l.style.overflowY="hidden",u.style.overflowY="hidden",l.scrollTop=0),c!==o&&(a=c-o,y.setStyle(e.iframeElement,"height",c+"px"),o=c,tinymce.isWebKit&&a<0&&n(r))}}function r(t,i,o){tinymce.util.Delay.setEditorTimeout(e,function(){n({}),t--?r(t,i,o):o&&o()},i)}var i=e.settings,o=0;e.settings.inline||(i.autoresize_min_height=parseInt(e.getParam("autoresize_min_height",e.getElement().offsetHeight),10),i.autoresize_max_height=parseInt(e.getParam("autoresize_max_height",0),10),e.on("init",function(){var t,n;t=e.getParam("autoresize_overflow_padding",1),n=e.getParam("autoresize_bottom_margin",50),t!==!1&&e.dom.setStyles(e.getBody(),{paddingLeft:t,paddingRight:t}),n!==!1&&e.dom.setStyles(e.getBody(),{paddingBottom:n})}),e.on("nodechange setcontent keyup FullscreenStateChanged",n),e.getParam("autoresize_on_init",!0)&&e.on("init",function(){r(20,100,function(){r(5,1e3)})}),e.addCommand("mceAutoResize",n))});
|
||||
!function(){var a={},b=function(b){for(var c=a[b],e=c.deps,f=c.defn,g=e.length,h=new Array(g),i=0;i<g;++i)h[i]=d(e[i]);var j=f.apply(null,h);if(void 0===j)throw"module ["+b+"] returned undefined";c.instance=j},c=function(b,c,d){if("string"!=typeof b)throw"module id must be a string";if(void 0===c)throw"no dependencies for "+b;if(void 0===d)throw"no definition function for "+b;a[b]={deps:c,defn:d,instance:void 0}},d=function(c){var d=a[c];if(void 0===d)throw"module ["+c+"] was undefined";return void 0===d.instance&&b(c),d.instance},e=function(a,b){for(var c=a.length,e=new Array(c),f=0;f<c;++f)e[f]=d(a[f]);b.apply(null,e)},f={};f.bolt={module:{api:{define:c,require:e,demand:d}}};var g=c,h=function(a,b){g(a,[],function(){return b})};g("1",[],function(){var a=function(b){var c=b,d=function(){return c},e=function(a){c=a},f=function(){return a(d())};return{get:d,set:e,clone:f}};return a}),h("5",tinymce.util.Tools.resolve),g("2",["5"],function(a){return a("tinymce.PluginManager")}),g("6",["5"],function(a){return a("tinymce.Env")}),g("7",["5"],function(a){return a("tinymce.util.Delay")}),g("8",[],function(){var a=function(a){return parseInt(a.getParam("autoresize_min_height",a.getElement().offsetHeight),10)},b=function(a){return parseInt(a.getParam("autoresize_max_height",0),10)},c=function(a){return a.getParam("autoresize_overflow_padding",1)},d=function(a){return a.getParam("autoresize_bottom_margin",50)},e=function(a){return a.getParam("autoresize_on_init",!0)};return{getAutoResizeMinHeight:a,getAutoResizeMaxHeight:b,getAutoResizeOverflowPadding:c,getAutoResizeBottomMargin:d,shouldAutoResizeOnInit:e}}),g("4",["6","7","8"],function(a,b,c){var d=function(a){return a.plugins.fullscreen&&a.plugins.fullscreen.isFullscreen()},e=function(a,c,d,f,h){b.setEditorTimeout(a,function(){g(a,c),d--?e(a,c,d,f,h):h&&h()},f)},f=function(a,b){var c=a.getBody();c&&(c.style.overflowY=b?"":"hidden",b||(c.scrollTop=0))},g=function(b,e){var h,i,j,k,l,m,n,o,p,q,r,s=b.dom;if(i=b.getDoc()){if(d(b))return void f(b,!0);j=i.body,k=c.getAutoResizeMinHeight(b),m=s.getStyle(j,"margin-top",!0),n=s.getStyle(j,"margin-bottom",!0),o=s.getStyle(j,"padding-top",!0),p=s.getStyle(j,"padding-bottom",!0),q=s.getStyle(j,"border-top-width",!0),r=s.getStyle(j,"border-bottom-width",!0),l=j.offsetHeight+parseInt(m,10)+parseInt(n,10)+parseInt(o,10)+parseInt(p,10)+parseInt(q,10)+parseInt(r,10),(isNaN(l)||l<=0)&&(l=a.ie?j.scrollHeight:a.webkit&&0===j.clientHeight?0:j.offsetHeight),l>c.getAutoResizeMinHeight(b)&&(k=l);var t=c.getAutoResizeMaxHeight(b);t&&l>t?(k=t,f(b,!0)):f(b,!1),k!==e.get()&&(h=k-e.get(),s.setStyle(b.iframeElement,"height",k+"px"),e.set(k),a.webKit&&h<0&&g(b))}},h=function(a,b){a.on("init",function(){var b,d,e=a.dom;b=c.getAutoResizeOverflowPadding(a),d=c.getAutoResizeBottomMargin(a),b!==!1&&e.setStyles(a.getBody(),{paddingLeft:b,paddingRight:b}),d!==!1&&e.setStyles(a.getBody(),{paddingBottom:d})}),a.on("nodechange setcontent keyup FullscreenStateChanged",function(c){g(a,b)}),c.shouldAutoResizeOnInit(a)&&a.on("init",function(){e(a,b,20,100,function(){e(a,b,5,1e3)})})};return{setup:h,resize:g}}),g("3",["4"],function(a){var b=function(b,c){b.addCommand("mceAutoResize",function(){a.resize(b,c)})};return{register:b}}),g("0",["1","2","3","4"],function(a,b,c,d){return b.add("autoresize",function(b){if(!b.inline){var e=a(0);c.register(b,e),d.setup(b,e)}}),function(){}}),d("0")()}();
|
Loading…
Add table
Add a link
Reference in a new issue