mirror of
https://github.com/documize/community.git
synced 2025-08-04 13:05:23 +02:00
Update TinyMCE editor to v4.7.6 release
Fixes issue with double scroll bar and subsequent position of inline editing toolbar.
This commit is contained in:
parent
f967949513
commit
0f3de51ad5
156 changed files with 6555 additions and 69987 deletions
|
@ -1,226 +0,0 @@
|
|||
(function () {
|
||||
var autosave = (function () {
|
||||
'use strict';
|
||||
|
||||
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
|
||||
};
|
||||
};
|
||||
|
||||
var PluginManager = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
var LocalStorage = tinymce.util.Tools.resolve('tinymce.util.LocalStorage');
|
||||
|
||||
var Tools = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
||||
|
||||
var fireRestoreDraft = function (editor) {
|
||||
return editor.fire('RestoreDraft');
|
||||
};
|
||||
var fireStoreDraft = function (editor) {
|
||||
return editor.fire('StoreDraft');
|
||||
};
|
||||
var fireRemoveDraft = function (editor) {
|
||||
return editor.fire('RemoveDraft');
|
||||
};
|
||||
var $_c91wpd8bjcun3xgx = {
|
||||
fireRestoreDraft: fireRestoreDraft,
|
||||
fireStoreDraft: fireStoreDraft,
|
||||
fireRemoveDraft: fireRemoveDraft
|
||||
};
|
||||
|
||||
var parse = function (time, defaultTime) {
|
||||
var multiples = {
|
||||
s: 1000,
|
||||
m: 60000
|
||||
};
|
||||
time = /^(\d+)([ms]?)$/.exec('' + (time || defaultTime));
|
||||
return (time[2] ? multiples[time[2]] : 1) * parseInt(time, 10);
|
||||
};
|
||||
var $_3gl6778djcun3xh0 = { parse: parse };
|
||||
|
||||
var shouldAskBeforeUnload = function (editor) {
|
||||
return editor.getParam('autosave_ask_before_unload', true);
|
||||
};
|
||||
var getAutoSavePrefix = function (editor) {
|
||||
var prefix = editor.getParam('autosave_prefix', 'tinymce-autosave-{path}{query}{hash}-{id}-');
|
||||
prefix = prefix.replace(/\{path\}/g, document.location.pathname);
|
||||
prefix = prefix.replace(/\{query\}/g, document.location.search);
|
||||
prefix = prefix.replace(/\{hash\}/g, document.location.hash);
|
||||
prefix = prefix.replace(/\{id\}/g, editor.id);
|
||||
return prefix;
|
||||
};
|
||||
var shouldRestoreWhenEmpty = function (editor) {
|
||||
return editor.getParam('autosave_restore_when_empty', false);
|
||||
};
|
||||
var getAutoSaveInterval = function (editor) {
|
||||
return $_3gl6778djcun3xh0.parse(editor.settings.autosave_interval, '30s');
|
||||
};
|
||||
var getAutoSaveRetention = function (editor) {
|
||||
return $_3gl6778djcun3xh0.parse(editor.settings.autosave_retention, '20m');
|
||||
};
|
||||
var $_7inrsn8cjcun3xgy = {
|
||||
shouldAskBeforeUnload: shouldAskBeforeUnload,
|
||||
getAutoSavePrefix: getAutoSavePrefix,
|
||||
shouldRestoreWhenEmpty: shouldRestoreWhenEmpty,
|
||||
getAutoSaveInterval: getAutoSaveInterval,
|
||||
getAutoSaveRetention: getAutoSaveRetention
|
||||
};
|
||||
|
||||
var isEmpty = function (editor, html) {
|
||||
var forcedRootBlockName = editor.settings.forced_root_block;
|
||||
html = Tools.trim(typeof html === 'undefined' ? editor.getBody().innerHTML : html);
|
||||
return html === '' || new RegExp('^<' + forcedRootBlockName + '[^>]*>((\xA0| |[ \t]|<br[^>]*>)+?|)</' + forcedRootBlockName + '>|<br>$', 'i').test(html);
|
||||
};
|
||||
var hasDraft = function (editor) {
|
||||
var time = parseInt(LocalStorage.getItem($_7inrsn8cjcun3xgy.getAutoSavePrefix(editor) + 'time'), 10) || 0;
|
||||
if (new Date().getTime() - time > $_7inrsn8cjcun3xgy.getAutoSaveRetention(editor)) {
|
||||
removeDraft(editor, false);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
var removeDraft = function (editor, fire) {
|
||||
var prefix = $_7inrsn8cjcun3xgy.getAutoSavePrefix(editor);
|
||||
LocalStorage.removeItem(prefix + 'draft');
|
||||
LocalStorage.removeItem(prefix + 'time');
|
||||
if (fire !== false) {
|
||||
$_c91wpd8bjcun3xgx.fireRemoveDraft(editor);
|
||||
}
|
||||
};
|
||||
var storeDraft = function (editor) {
|
||||
var prefix = $_7inrsn8cjcun3xgy.getAutoSavePrefix(editor);
|
||||
if (!isEmpty(editor) && editor.isDirty()) {
|
||||
LocalStorage.setItem(prefix + 'draft', editor.getContent({
|
||||
format: 'raw',
|
||||
no_events: true
|
||||
}));
|
||||
LocalStorage.setItem(prefix + 'time', new Date().getTime().toString());
|
||||
$_c91wpd8bjcun3xgx.fireStoreDraft(editor);
|
||||
}
|
||||
};
|
||||
var restoreDraft = function (editor) {
|
||||
var prefix = $_7inrsn8cjcun3xgy.getAutoSavePrefix(editor);
|
||||
if (hasDraft(editor)) {
|
||||
editor.setContent(LocalStorage.getItem(prefix + 'draft'), { format: 'raw' });
|
||||
$_c91wpd8bjcun3xgx.fireRestoreDraft(editor);
|
||||
}
|
||||
};
|
||||
var startStoreDraft = function (editor, started) {
|
||||
var interval = $_7inrsn8cjcun3xgy.getAutoSaveInterval(editor);
|
||||
if (!started.get()) {
|
||||
setInterval(function () {
|
||||
if (!editor.removed) {
|
||||
storeDraft(editor);
|
||||
}
|
||||
}, interval);
|
||||
started.set(true);
|
||||
}
|
||||
};
|
||||
var restoreLastDraft = function (editor) {
|
||||
editor.undoManager.transact(function () {
|
||||
restoreDraft(editor);
|
||||
removeDraft(editor);
|
||||
});
|
||||
editor.focus();
|
||||
};
|
||||
var $_g0tuzv88jcun3xgt = {
|
||||
isEmpty: isEmpty,
|
||||
hasDraft: hasDraft,
|
||||
removeDraft: removeDraft,
|
||||
storeDraft: storeDraft,
|
||||
restoreDraft: restoreDraft,
|
||||
startStoreDraft: startStoreDraft,
|
||||
restoreLastDraft: restoreLastDraft
|
||||
};
|
||||
|
||||
var curry = function (f, editor) {
|
||||
return function () {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
return f.apply(null, [editor].concat(args));
|
||||
};
|
||||
};
|
||||
var get = function (editor) {
|
||||
return {
|
||||
hasDraft: curry($_g0tuzv88jcun3xgt.hasDraft, editor),
|
||||
storeDraft: curry($_g0tuzv88jcun3xgt.storeDraft, editor),
|
||||
restoreDraft: curry($_g0tuzv88jcun3xgt.restoreDraft, editor),
|
||||
removeDraft: curry($_g0tuzv88jcun3xgt.removeDraft, editor),
|
||||
isEmpty: curry($_g0tuzv88jcun3xgt.isEmpty, editor)
|
||||
};
|
||||
};
|
||||
var $_bfqhpx87jcun3xgs = { get: get };
|
||||
|
||||
var EditorManager = tinymce.util.Tools.resolve('tinymce.EditorManager');
|
||||
|
||||
EditorManager._beforeUnloadHandler = function () {
|
||||
var msg;
|
||||
Tools.each(EditorManager.get(), function (editor) {
|
||||
if (editor.plugins.autosave) {
|
||||
editor.plugins.autosave.storeDraft();
|
||||
}
|
||||
if (!msg && editor.isDirty() && $_7inrsn8cjcun3xgy.shouldAskBeforeUnload(editor)) {
|
||||
msg = editor.translate('You have unsaved changes are you sure you want to navigate away?');
|
||||
}
|
||||
});
|
||||
return msg;
|
||||
};
|
||||
var setup = function (editor) {
|
||||
window.onbeforeunload = EditorManager._beforeUnloadHandler;
|
||||
};
|
||||
var $_aq7it18ejcun3xh1 = { setup: setup };
|
||||
|
||||
var postRender = function (editor, started) {
|
||||
return function (e) {
|
||||
var ctrl = e.control;
|
||||
ctrl.disabled(!$_g0tuzv88jcun3xgt.hasDraft(editor));
|
||||
editor.on('StoreDraft RestoreDraft RemoveDraft', function () {
|
||||
ctrl.disabled(!$_g0tuzv88jcun3xgt.hasDraft(editor));
|
||||
});
|
||||
$_g0tuzv88jcun3xgt.startStoreDraft(editor, started);
|
||||
};
|
||||
};
|
||||
var register = function (editor, started) {
|
||||
editor.addButton('restoredraft', {
|
||||
title: 'Restore last draft',
|
||||
onclick: function () {
|
||||
$_g0tuzv88jcun3xgt.restoreLastDraft(editor);
|
||||
},
|
||||
onPostRender: postRender(editor, started)
|
||||
});
|
||||
editor.addMenuItem('restoredraft', {
|
||||
text: 'Restore last draft',
|
||||
onclick: function () {
|
||||
$_g0tuzv88jcun3xgt.restoreLastDraft(editor);
|
||||
},
|
||||
onPostRender: postRender(editor, started),
|
||||
context: 'file'
|
||||
});
|
||||
};
|
||||
var $_8xbf828gjcun3xh4 = { register: register };
|
||||
|
||||
PluginManager.add('autosave', function (editor) {
|
||||
var started = Cell(false);
|
||||
$_aq7it18ejcun3xh1.setup(editor);
|
||||
$_8xbf828gjcun3xh4.register(editor, started);
|
||||
return $_bfqhpx87jcun3xgs.get(editor);
|
||||
});
|
||||
var Plugin = function () {
|
||||
};
|
||||
|
||||
return Plugin;
|
||||
|
||||
}());
|
||||
})()
|
0
gui/public/tinymce/plugins/autosave/plugin.min.js
vendored
Normal file → Executable file
0
gui/public/tinymce/plugins/autosave/plugin.min.js
vendored
Normal file → Executable file
Loading…
Add table
Add a link
Reference in a new issue