mirror of
https://github.com/documize/community.git
synced 2025-08-04 21:15:24 +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
608
gui/public/tinymce/plugins/autosave/plugin.js
Executable file
608
gui/public/tinymce/plugins/autosave/plugin.js
Executable file
|
@ -0,0 +1,608 @@
|
|||
(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.autosave.Plugin","ephox.katamari.api.Cell","tinymce.core.PluginManager","tinymce.plugins.autosave.api.Api","tinymce.plugins.autosave.core.BeforeUnload","tinymce.plugins.autosave.ui.Buttons","global!tinymce.util.Tools.resolve","tinymce.plugins.autosave.core.Storage","global!window","tinymce.core.EditorManager","tinymce.core.util.Tools","tinymce.plugins.autosave.api.Settings","global!setInterval","tinymce.core.util.LocalStorage","tinymce.plugins.autosave.api.Events","global!document","tinymce.plugins.autosave.core.Time"]
|
||||
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');
|
||||
}
|
||||
);
|
||||
|
||||
defineGlobal("global!setInterval", setInterval);
|
||||
/**
|
||||
* 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.LocalStorage',
|
||||
[
|
||||
'global!tinymce.util.Tools.resolve'
|
||||
],
|
||||
function (resolve) {
|
||||
return resolve('tinymce.util.LocalStorage');
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* 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.Tools',
|
||||
[
|
||||
'global!tinymce.util.Tools.resolve'
|
||||
],
|
||||
function (resolve) {
|
||||
return resolve('tinymce.util.Tools');
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Events.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.autosave.api.Events',
|
||||
[
|
||||
],
|
||||
function () {
|
||||
var fireRestoreDraft = function (editor) {
|
||||
return editor.fire('RestoreDraft');
|
||||
};
|
||||
|
||||
var fireStoreDraft = function (editor) {
|
||||
return editor.fire('StoreDraft');
|
||||
};
|
||||
|
||||
var fireRemoveDraft = function (editor) {
|
||||
return editor.fire('RemoveDraft');
|
||||
};
|
||||
|
||||
return {
|
||||
fireRestoreDraft: fireRestoreDraft,
|
||||
fireStoreDraft: fireStoreDraft,
|
||||
fireRemoveDraft: fireRemoveDraft
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
defineGlobal("global!document", document);
|
||||
/**
|
||||
* Time.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.autosave.core.Time',
|
||||
[
|
||||
],
|
||||
function () {
|
||||
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);
|
||||
};
|
||||
|
||||
return {
|
||||
parse: parse
|
||||
};
|
||||
}
|
||||
);
|
||||
/**
|
||||
* 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.autosave.api.Settings',
|
||||
[
|
||||
'global!document',
|
||||
'tinymce.plugins.autosave.core.Time'
|
||||
],
|
||||
function (document, Time) {
|
||||
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 Time.parse(editor.settings.autosave_interval, '30s');
|
||||
};
|
||||
|
||||
var getAutoSaveRetention = function (editor) {
|
||||
return Time.parse(editor.settings.autosave_retention, '20m');
|
||||
};
|
||||
|
||||
return {
|
||||
shouldAskBeforeUnload: shouldAskBeforeUnload,
|
||||
getAutoSavePrefix: getAutoSavePrefix,
|
||||
shouldRestoreWhenEmpty: shouldRestoreWhenEmpty,
|
||||
getAutoSaveInterval: getAutoSaveInterval,
|
||||
getAutoSaveRetention: getAutoSaveRetention
|
||||
};
|
||||
}
|
||||
);
|
||||
/**
|
||||
* Storage.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.autosave.core.Storage',
|
||||
[
|
||||
'global!setInterval',
|
||||
'tinymce.core.util.LocalStorage',
|
||||
'tinymce.core.util.Tools',
|
||||
'tinymce.plugins.autosave.api.Events',
|
||||
'tinymce.plugins.autosave.api.Settings'
|
||||
],
|
||||
function (setInterval, LocalStorage, Tools, Events, Settings) {
|
||||
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 + '[^>]*>((\u00a0| |[ \t]|<br[^>]*>)+?|)<\/' + forcedRootBlockName + '>|<br>$', 'i'
|
||||
).test(html);
|
||||
};
|
||||
|
||||
var hasDraft = function (editor) {
|
||||
var time = parseInt(LocalStorage.getItem(Settings.getAutoSavePrefix(editor) + "time"), 10) || 0;
|
||||
|
||||
if (new Date().getTime() - time > Settings.getAutoSaveRetention(editor)) {
|
||||
removeDraft(editor, false);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
var removeDraft = function (editor, fire) {
|
||||
var prefix = Settings.getAutoSavePrefix(editor);
|
||||
|
||||
LocalStorage.removeItem(prefix + "draft");
|
||||
LocalStorage.removeItem(prefix + "time");
|
||||
|
||||
if (fire !== false) {
|
||||
Events.fireRemoveDraft(editor);
|
||||
}
|
||||
};
|
||||
|
||||
var storeDraft = function (editor) {
|
||||
var prefix = Settings.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());
|
||||
Events.fireStoreDraft(editor);
|
||||
}
|
||||
};
|
||||
|
||||
var restoreDraft = function (editor) {
|
||||
var prefix = Settings.getAutoSavePrefix(editor);
|
||||
|
||||
if (hasDraft(editor)) {
|
||||
editor.setContent(LocalStorage.getItem(prefix + "draft"), { format: 'raw' });
|
||||
Events.fireRestoreDraft(editor);
|
||||
}
|
||||
};
|
||||
|
||||
var startStoreDraft = function (editor, started) {
|
||||
var interval = Settings.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();
|
||||
};
|
||||
|
||||
return {
|
||||
isEmpty: isEmpty,
|
||||
hasDraft: hasDraft,
|
||||
removeDraft: removeDraft,
|
||||
storeDraft: storeDraft,
|
||||
restoreDraft: restoreDraft,
|
||||
startStoreDraft: startStoreDraft,
|
||||
restoreLastDraft: restoreLastDraft
|
||||
};
|
||||
}
|
||||
);
|
||||
/**
|
||||
* Api.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.autosave.api.Api',
|
||||
[
|
||||
'tinymce.plugins.autosave.core.Storage'
|
||||
],
|
||||
function (Storage) {
|
||||
// Inlined the curry function since adding Fun without tree shaking to every plugin would produce a lot of bloat
|
||||
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(Storage.hasDraft, editor),
|
||||
storeDraft: curry(Storage.storeDraft, editor),
|
||||
restoreDraft: curry(Storage.restoreDraft, editor),
|
||||
removeDraft: curry(Storage.removeDraft, editor),
|
||||
isEmpty: curry(Storage.isEmpty, editor)
|
||||
};
|
||||
};
|
||||
|
||||
return {
|
||||
get: get
|
||||
};
|
||||
}
|
||||
);
|
||||
defineGlobal("global!window", window);
|
||||
/**
|
||||
* 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.EditorManager',
|
||||
[
|
||||
'global!tinymce.util.Tools.resolve'
|
||||
],
|
||||
function (resolve) {
|
||||
return resolve('tinymce.EditorManager');
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* BeforeUnload.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.autosave.core.BeforeUnload',
|
||||
[
|
||||
'global!window',
|
||||
'tinymce.core.EditorManager',
|
||||
'tinymce.core.util.Tools',
|
||||
'tinymce.plugins.autosave.api.Settings'
|
||||
],
|
||||
function (window, EditorManager, Tools, Settings) {
|
||||
EditorManager._beforeUnloadHandler = function () {
|
||||
var msg;
|
||||
|
||||
Tools.each(EditorManager.get(), function (editor) {
|
||||
// Store a draft for each editor instance
|
||||
if (editor.plugins.autosave) {
|
||||
editor.plugins.autosave.storeDraft();
|
||||
}
|
||||
|
||||
// Setup a return message if the editor is dirty
|
||||
if (!msg && editor.isDirty() && Settings.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;
|
||||
};
|
||||
|
||||
return {
|
||||
setup: setup
|
||||
};
|
||||
}
|
||||
);
|
||||
/**
|
||||
* Buttons.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.autosave.ui.Buttons',
|
||||
[
|
||||
'tinymce.plugins.autosave.core.Storage'
|
||||
],
|
||||
function (Storage) {
|
||||
var postRender = function (editor, started) {
|
||||
return function (e) {
|
||||
var ctrl = e.control;
|
||||
|
||||
ctrl.disabled(!Storage.hasDraft(editor));
|
||||
|
||||
editor.on('StoreDraft RestoreDraft RemoveDraft', function () {
|
||||
ctrl.disabled(!Storage.hasDraft(editor));
|
||||
});
|
||||
|
||||
// TODO: Investigate why this is only done on postrender that would
|
||||
// make the feature broken if only the menu item was rendered since
|
||||
// it is rendered when the menu appears
|
||||
Storage.startStoreDraft(editor, started);
|
||||
};
|
||||
};
|
||||
|
||||
var register = function (editor, started) {
|
||||
editor.addButton('restoredraft', {
|
||||
title: 'Restore last draft',
|
||||
onclick: function () {
|
||||
Storage.restoreLastDraft(editor);
|
||||
},
|
||||
onPostRender: postRender(editor, started)
|
||||
});
|
||||
|
||||
editor.addMenuItem('restoredraft', {
|
||||
text: 'Restore last draft',
|
||||
onclick: function () {
|
||||
Storage.restoreLastDraft(editor);
|
||||
},
|
||||
onPostRender: postRender(editor, started),
|
||||
context: 'file'
|
||||
});
|
||||
};
|
||||
|
||||
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 autosave plugin.
|
||||
*
|
||||
* @class tinymce.autosave.Plugin
|
||||
* @private
|
||||
*/
|
||||
define(
|
||||
'tinymce.plugins.autosave.Plugin',
|
||||
[
|
||||
'ephox.katamari.api.Cell',
|
||||
'tinymce.core.PluginManager',
|
||||
'tinymce.plugins.autosave.api.Api',
|
||||
'tinymce.plugins.autosave.core.BeforeUnload',
|
||||
'tinymce.plugins.autosave.ui.Buttons'
|
||||
],
|
||||
function (Cell, PluginManager, Api, BeforeUnload, Buttons) {
|
||||
PluginManager.add('autosave', function (editor) {
|
||||
var started = Cell(false);
|
||||
|
||||
BeforeUnload.setup(editor);
|
||||
Buttons.register(editor, started);
|
||||
|
||||
return Api.get(editor);
|
||||
});
|
||||
|
||||
return function () { };
|
||||
}
|
||||
);
|
||||
dem('tinymce.plugins.autosave.Plugin')();
|
||||
})();
|
|
@ -1 +1 @@
|
|||
tinymce._beforeUnloadHandler=function(){var e;return tinymce.each(tinymce.editors,function(t){t.plugins.autosave&&t.plugins.autosave.storeDraft(),!e&&t.isDirty()&&t.getParam("autosave_ask_before_unload",!0)&&(e=t.translate("You have unsaved changes are you sure you want to navigate away?"))}),e},tinymce.PluginManager.add("autosave",function(e){function t(e,t){var n={s:1e3,m:6e4};return e=/^(\d+)([ms]?)$/.exec(""+(e||t)),(e[2]?n[e[2]]:1)*parseInt(e,10)}function n(){var e=parseInt(p.getItem(c+"time"),10)||0;return!((new Date).getTime()-e>f.autosave_retention)||(r(!1),!1)}function r(t){p.removeItem(c+"draft"),p.removeItem(c+"time"),t!==!1&&e.fire("RemoveDraft")}function i(){!u()&&e.isDirty()&&(p.setItem(c+"draft",e.getContent({format:"raw",no_events:!0})),p.setItem(c+"time",(new Date).getTime()),e.fire("StoreDraft"))}function o(){n()&&(e.setContent(p.getItem(c+"draft"),{format:"raw"}),e.fire("RestoreDraft"))}function a(){d||(setInterval(function(){e.removed||i()},f.autosave_interval),d=!0)}function s(){var t=this;t.disabled(!n()),e.on("StoreDraft RestoreDraft RemoveDraft",function(){t.disabled(!n())}),a()}function l(){e.undoManager.beforeChange(),o(),r(),e.undoManager.add()}function u(t){var n=e.settings.forced_root_block;return t=tinymce.trim("undefined"==typeof t?e.getBody().innerHTML:t),""===t||new RegExp("^<"+n+"[^>]*>((\xa0| |[ \t]|<br[^>]*>)+?|)</"+n+">|<br>$","i").test(t)}var c,d,f=e.settings,p=tinymce.util.LocalStorage;c=f.autosave_prefix||"tinymce-autosave-{path}{query}-{id}-",c=c.replace(/\{path\}/g,document.location.pathname),c=c.replace(/\{query\}/g,document.location.search),c=c.replace(/\{id\}/g,e.id),f.autosave_interval=t(f.autosave_interval,"30s"),f.autosave_retention=t(f.autosave_retention,"20m"),e.addButton("restoredraft",{title:"Restore last draft",onclick:l,onPostRender:s}),e.addMenuItem("restoredraft",{text:"Restore last draft",onclick:l,onPostRender:s,context:"file"}),e.settings.autosave_restore_when_empty!==!1&&(e.on("init",function(){n()&&u()&&o()}),e.on("saveContent",function(){r()})),window.onbeforeunload=tinymce._beforeUnloadHandler,this.hasDraft=n,this.storeDraft=i,this.restoreDraft=o,this.removeDraft=r,this.isEmpty=u});
|
||||
!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("6",tinymce.util.Tools.resolve),g("2",["6"],function(a){return a("tinymce.PluginManager")}),h("c",setInterval),g("d",["6"],function(a){return a("tinymce.util.LocalStorage")}),g("a",["6"],function(a){return a("tinymce.util.Tools")}),g("e",[],function(){var a=function(a){return a.fire("RestoreDraft")},b=function(a){return a.fire("StoreDraft")},c=function(a){return a.fire("RemoveDraft")};return{fireRestoreDraft:a,fireStoreDraft:b,fireRemoveDraft:c}}),h("f",document),g("g",[],function(){var a=function(a,b){var c={s:1e3,m:6e4};return a=/^(\d+)([ms]?)$/.exec(""+(a||b)),(a[2]?c[a[2]]:1)*parseInt(a,10)};return{parse:a}}),g("b",["f","g"],function(a,b){var c=function(a){return a.getParam("autosave_ask_before_unload",!0)},d=function(b){var c=b.getParam("autosave_prefix","tinymce-autosave-{path}{query}{hash}-{id}-");return c=c.replace(/\{path\}/g,a.location.pathname),c=c.replace(/\{query\}/g,a.location.search),c=c.replace(/\{hash\}/g,a.location.hash),c=c.replace(/\{id\}/g,b.id)},e=function(a){return a.getParam("autosave_restore_when_empty",!1)},f=function(a){return b.parse(a.settings.autosave_interval,"30s")},g=function(a){return b.parse(a.settings.autosave_retention,"20m")};return{shouldAskBeforeUnload:c,getAutoSavePrefix:d,shouldRestoreWhenEmpty:e,getAutoSaveInterval:f,getAutoSaveRetention:g}}),g("7",["c","d","a","e","b"],function(a,b,c,d,e){var f=function(a,b){var d=a.settings.forced_root_block;return b=c.trim("undefined"==typeof b?a.getBody().innerHTML:b),""===b||new RegExp("^<"+d+"[^>]*>((\xa0| |[ \t]|<br[^>]*>)+?|)</"+d+">|<br>$","i").test(b)},g=function(a){var c=parseInt(b.getItem(e.getAutoSavePrefix(a)+"time"),10)||0;return!((new Date).getTime()-c>e.getAutoSaveRetention(a))||(h(a,!1),!1)},h=function(a,c){var f=e.getAutoSavePrefix(a);b.removeItem(f+"draft"),b.removeItem(f+"time"),c!==!1&&d.fireRemoveDraft(a)},i=function(a){var c=e.getAutoSavePrefix(a);!f(a)&&a.isDirty()&&(b.setItem(c+"draft",a.getContent({format:"raw",no_events:!0})),b.setItem(c+"time",(new Date).getTime()),d.fireStoreDraft(a))},j=function(a){var c=e.getAutoSavePrefix(a);g(a)&&(a.setContent(b.getItem(c+"draft"),{format:"raw"}),d.fireRestoreDraft(a))},k=function(b,c){var d=e.getAutoSaveInterval(b);c.get()||(a(function(){b.removed||i(b)},d),c.set(!0))},l=function(a){a.undoManager.transact(function(){j(a),h(a)}),a.focus()};return{isEmpty:f,hasDraft:g,removeDraft:h,storeDraft:i,restoreDraft:j,startStoreDraft:k,restoreLastDraft:l}}),g("3",["7"],function(a){var b=function(a,b){return function(){var c=Array.prototype.slice.call(arguments);return a.apply(null,[b].concat(c))}},c=function(c){return{hasDraft:b(a.hasDraft,c),storeDraft:b(a.storeDraft,c),restoreDraft:b(a.restoreDraft,c),removeDraft:b(a.removeDraft,c),isEmpty:b(a.isEmpty,c)}};return{get:c}}),h("8",window),g("9",["6"],function(a){return a("tinymce.EditorManager")}),g("4",["8","9","a","b"],function(a,b,c,d){b._beforeUnloadHandler=function(){var a;return c.each(b.get(),function(b){b.plugins.autosave&&b.plugins.autosave.storeDraft(),!a&&b.isDirty()&&d.shouldAskBeforeUnload(b)&&(a=b.translate("You have unsaved changes are you sure you want to navigate away?"))}),a};var e=function(c){a.onbeforeunload=b._beforeUnloadHandler};return{setup:e}}),g("5",["7"],function(a){var b=function(b,c){return function(d){var e=d.control;e.disabled(!a.hasDraft(b)),b.on("StoreDraft RestoreDraft RemoveDraft",function(){e.disabled(!a.hasDraft(b))}),a.startStoreDraft(b,c)}},c=function(c,d){c.addButton("restoredraft",{title:"Restore last draft",onclick:function(){a.restoreLastDraft(c)},onPostRender:b(c,d)}),c.addMenuItem("restoredraft",{text:"Restore last draft",onclick:function(){a.restoreLastDraft(c)},onPostRender:b(c,d),context:"file"})};return{register:c}}),g("0",["1","2","3","4","5"],function(a,b,c,d,e){return b.add("autosave",function(b){var f=a(!1);return d.setup(b),e.register(b,f),c.get(b)}),function(){}}),d("0")()}();
|
Loading…
Add table
Add a link
Reference in a new issue