avances en plantillas
This commit is contained in:
parent
0f84beacf1
commit
da0530d79b
2062 changed files with 598814 additions and 22 deletions
7
storage/public/dist/libs/hugerte/plugins/autosave/index.js
vendored
Normal file
7
storage/public/dist/libs/hugerte/plugins/autosave/index.js
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
// Exports the "autosave" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('hugerte/plugins/autosave')
|
||||
// ES2015:
|
||||
// import 'hugerte/plugins/autosave'
|
||||
require('./plugin.js');
|
||||
236
storage/public/dist/libs/hugerte/plugins/autosave/plugin.js
vendored
Normal file
236
storage/public/dist/libs/hugerte/plugins/autosave/plugin.js
vendored
Normal file
|
|
@ -0,0 +1,236 @@
|
|||
/**
|
||||
* HugeRTE version 1.0.10 (2026-02-16)
|
||||
* Copyright (c) 2022 Ephox Corporation DBA Tiny Technologies, Inc.
|
||||
* Copyright (c) 2024 HugeRTE contributors
|
||||
* Licensed under the MIT license (https://github.com/hugerte/hugerte/blob/main/LICENSE.TXT)
|
||||
*/
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var global$4 = hugerte.util.Tools.resolve('hugerte.PluginManager');
|
||||
|
||||
const hasProto = (v, constructor, predicate) => {
|
||||
var _a;
|
||||
if (predicate(v, constructor.prototype)) {
|
||||
return true;
|
||||
} else {
|
||||
return ((_a = v.constructor) === null || _a === void 0 ? void 0 : _a.name) === constructor.name;
|
||||
}
|
||||
};
|
||||
const typeOf = x => {
|
||||
const t = typeof x;
|
||||
if (x === null) {
|
||||
return 'null';
|
||||
} else if (t === 'object' && Array.isArray(x)) {
|
||||
return 'array';
|
||||
} else if (t === 'object' && hasProto(x, String, (o, proto) => proto.isPrototypeOf(o))) {
|
||||
return 'string';
|
||||
} else {
|
||||
return t;
|
||||
}
|
||||
};
|
||||
const isType = type => value => typeOf(value) === type;
|
||||
const eq = t => a => t === a;
|
||||
const isString = isType('string');
|
||||
const isUndefined = eq(undefined);
|
||||
|
||||
var global$3 = hugerte.util.Tools.resolve('hugerte.util.Delay');
|
||||
|
||||
var global$2 = hugerte.util.Tools.resolve('hugerte.util.LocalStorage');
|
||||
|
||||
var global$1 = hugerte.util.Tools.resolve('hugerte.util.Tools');
|
||||
|
||||
const fireRestoreDraft = editor => editor.dispatch('RestoreDraft');
|
||||
const fireStoreDraft = editor => editor.dispatch('StoreDraft');
|
||||
const fireRemoveDraft = editor => editor.dispatch('RemoveDraft');
|
||||
|
||||
const parse = timeString => {
|
||||
const multiples = {
|
||||
s: 1000,
|
||||
m: 60000
|
||||
};
|
||||
const parsedTime = /^(\d+)([ms]?)$/.exec(timeString);
|
||||
return (parsedTime && parsedTime[2] ? multiples[parsedTime[2]] : 1) * parseInt(timeString, 10);
|
||||
};
|
||||
|
||||
const option = name => editor => editor.options.get(name);
|
||||
const register$1 = editor => {
|
||||
const registerOption = editor.options.register;
|
||||
const timeProcessor = value => {
|
||||
const valid = isString(value);
|
||||
if (valid) {
|
||||
return {
|
||||
value: parse(value),
|
||||
valid
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
valid: false,
|
||||
message: 'Must be a string.'
|
||||
};
|
||||
}
|
||||
};
|
||||
registerOption('autosave_ask_before_unload', {
|
||||
processor: 'boolean',
|
||||
default: true
|
||||
});
|
||||
registerOption('autosave_prefix', {
|
||||
processor: 'string',
|
||||
default: 'hugerte-autosave-{path}{query}{hash}-{id}-'
|
||||
});
|
||||
registerOption('autosave_restore_when_empty', {
|
||||
processor: 'boolean',
|
||||
default: false
|
||||
});
|
||||
registerOption('autosave_interval', {
|
||||
processor: timeProcessor,
|
||||
default: '30s'
|
||||
});
|
||||
registerOption('autosave_retention', {
|
||||
processor: timeProcessor,
|
||||
default: '20m'
|
||||
});
|
||||
};
|
||||
const shouldAskBeforeUnload = option('autosave_ask_before_unload');
|
||||
const shouldRestoreWhenEmpty = option('autosave_restore_when_empty');
|
||||
const getAutoSaveInterval = option('autosave_interval');
|
||||
const getAutoSaveRetention = option('autosave_retention');
|
||||
const getAutoSavePrefix = editor => {
|
||||
const location = document.location;
|
||||
return editor.options.get('autosave_prefix').replace(/{path}/g, location.pathname).replace(/{query}/g, location.search).replace(/{hash}/g, location.hash).replace(/{id}/g, editor.id);
|
||||
};
|
||||
|
||||
const isEmpty = (editor, html) => {
|
||||
if (isUndefined(html)) {
|
||||
return editor.dom.isEmpty(editor.getBody());
|
||||
} else {
|
||||
const trimmedHtml = global$1.trim(html);
|
||||
if (trimmedHtml === '') {
|
||||
return true;
|
||||
} else {
|
||||
const fragment = new DOMParser().parseFromString(trimmedHtml, 'text/html');
|
||||
return editor.dom.isEmpty(fragment);
|
||||
}
|
||||
}
|
||||
};
|
||||
const hasDraft = editor => {
|
||||
var _a;
|
||||
const time = parseInt((_a = global$2.getItem(getAutoSavePrefix(editor) + 'time')) !== null && _a !== void 0 ? _a : '0', 10) || 0;
|
||||
if (new Date().getTime() - time > getAutoSaveRetention(editor)) {
|
||||
removeDraft(editor, false);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
const removeDraft = (editor, fire) => {
|
||||
const prefix = getAutoSavePrefix(editor);
|
||||
global$2.removeItem(prefix + 'draft');
|
||||
global$2.removeItem(prefix + 'time');
|
||||
if (fire !== false) {
|
||||
fireRemoveDraft(editor);
|
||||
}
|
||||
};
|
||||
const storeDraft = editor => {
|
||||
const prefix = getAutoSavePrefix(editor);
|
||||
if (!isEmpty(editor) && editor.isDirty()) {
|
||||
global$2.setItem(prefix + 'draft', editor.getContent({
|
||||
format: 'raw',
|
||||
no_events: true
|
||||
}));
|
||||
global$2.setItem(prefix + 'time', new Date().getTime().toString());
|
||||
fireStoreDraft(editor);
|
||||
}
|
||||
};
|
||||
const restoreDraft = editor => {
|
||||
var _a;
|
||||
const prefix = getAutoSavePrefix(editor);
|
||||
if (hasDraft(editor)) {
|
||||
editor.setContent((_a = global$2.getItem(prefix + 'draft')) !== null && _a !== void 0 ? _a : '', { format: 'raw' });
|
||||
fireRestoreDraft(editor);
|
||||
}
|
||||
};
|
||||
const startStoreDraft = editor => {
|
||||
const interval = getAutoSaveInterval(editor);
|
||||
global$3.setEditorInterval(editor, () => {
|
||||
storeDraft(editor);
|
||||
}, interval);
|
||||
};
|
||||
const restoreLastDraft = editor => {
|
||||
editor.undoManager.transact(() => {
|
||||
restoreDraft(editor);
|
||||
removeDraft(editor);
|
||||
});
|
||||
editor.focus();
|
||||
};
|
||||
|
||||
const get = editor => ({
|
||||
hasDraft: () => hasDraft(editor),
|
||||
storeDraft: () => storeDraft(editor),
|
||||
restoreDraft: () => restoreDraft(editor),
|
||||
removeDraft: fire => removeDraft(editor, fire),
|
||||
isEmpty: html => isEmpty(editor, html)
|
||||
});
|
||||
|
||||
var global = hugerte.util.Tools.resolve('hugerte.EditorManager');
|
||||
|
||||
const setup = editor => {
|
||||
editor.editorManager.on('BeforeUnload', e => {
|
||||
let msg;
|
||||
global$1.each(global.get(), editor => {
|
||||
if (editor.plugins.autosave) {
|
||||
editor.plugins.autosave.storeDraft();
|
||||
}
|
||||
if (!msg && editor.isDirty() && shouldAskBeforeUnload(editor)) {
|
||||
msg = editor.translate('You have unsaved changes are you sure you want to navigate away?');
|
||||
}
|
||||
});
|
||||
if (msg) {
|
||||
e.preventDefault();
|
||||
e.returnValue = msg;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const makeSetupHandler = editor => api => {
|
||||
api.setEnabled(hasDraft(editor));
|
||||
const editorEventCallback = () => api.setEnabled(hasDraft(editor));
|
||||
editor.on('StoreDraft RestoreDraft RemoveDraft', editorEventCallback);
|
||||
return () => editor.off('StoreDraft RestoreDraft RemoveDraft', editorEventCallback);
|
||||
};
|
||||
const register = editor => {
|
||||
startStoreDraft(editor);
|
||||
const onAction = () => {
|
||||
restoreLastDraft(editor);
|
||||
};
|
||||
editor.ui.registry.addButton('restoredraft', {
|
||||
tooltip: 'Restore last draft',
|
||||
icon: 'restore-draft',
|
||||
onAction,
|
||||
onSetup: makeSetupHandler(editor)
|
||||
});
|
||||
editor.ui.registry.addMenuItem('restoredraft', {
|
||||
text: 'Restore last draft',
|
||||
icon: 'restore-draft',
|
||||
onAction,
|
||||
onSetup: makeSetupHandler(editor)
|
||||
});
|
||||
};
|
||||
|
||||
var Plugin = () => {
|
||||
global$4.add('autosave', editor => {
|
||||
register$1(editor);
|
||||
setup(editor);
|
||||
register(editor);
|
||||
editor.on('init', () => {
|
||||
if (shouldRestoreWhenEmpty(editor) && editor.dom.isEmpty(editor.getBody())) {
|
||||
restoreDraft(editor);
|
||||
}
|
||||
});
|
||||
return get(editor);
|
||||
});
|
||||
};
|
||||
|
||||
Plugin();
|
||||
|
||||
})();
|
||||
7
storage/public/dist/libs/hugerte/plugins/autosave/plugin.min.js
vendored
Normal file
7
storage/public/dist/libs/hugerte/plugins/autosave/plugin.min.js
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
/**
|
||||
* HugeRTE version 1.0.10 (2026-02-16)
|
||||
* Copyright (c) 2022 Ephox Corporation DBA Tiny Technologies, Inc.
|
||||
* Copyright (c) 2024 HugeRTE contributors
|
||||
* Licensed under the MIT license (https://github.com/hugerte/hugerte/blob/main/LICENSE.TXT)
|
||||
*/
|
||||
!function(){"use strict";var e=hugerte.util.Tools.resolve("hugerte.PluginManager");const t=("string",e=>"string"===(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(r=o=e,(a=String).prototype.isPrototypeOf(r)||(null===(s=o.constructor)||void 0===s?void 0:s.name)===a.name)?"string":t;var r,o,a,s})(e));const r=(void 0,e=>undefined===e);var o=hugerte.util.Tools.resolve("hugerte.util.Delay"),a=hugerte.util.Tools.resolve("hugerte.util.LocalStorage"),s=hugerte.util.Tools.resolve("hugerte.util.Tools");const n=e=>{const t=/^(\d+)([ms]?)$/.exec(e);return(t&&t[2]?{s:1e3,m:6e4}[t[2]]:1)*parseInt(e,10)},u=e=>t=>t.options.get(e),i=u("autosave_ask_before_unload"),l=u("autosave_restore_when_empty"),d=u("autosave_interval"),c=u("autosave_retention"),g=e=>{const t=document.location;return e.options.get("autosave_prefix").replace(/{path}/g,t.pathname).replace(/{query}/g,t.search).replace(/{hash}/g,t.hash).replace(/{id}/g,e.id)},v=(e,t)=>{if(r(t))return e.dom.isEmpty(e.getBody());{const r=s.trim(t);if(""===r)return!0;{const t=(new DOMParser).parseFromString(r,"text/html");return e.dom.isEmpty(t)}}},f=e=>{var t;const r=parseInt(null!==(t=a.getItem(g(e)+"time"))&&void 0!==t?t:"0",10)||0;return!((new Date).getTime()-r>c(e)&&(m(e,!1),1))},m=(e,t)=>{const r=g(e);a.removeItem(r+"draft"),a.removeItem(r+"time"),!1!==t&&(e=>{e.dispatch("RemoveDraft")})(e)},p=e=>{const t=g(e);!v(e)&&e.isDirty()&&(a.setItem(t+"draft",e.getContent({format:"raw",no_events:!0})),a.setItem(t+"time",(new Date).getTime().toString()),(e=>{e.dispatch("StoreDraft")})(e))},h=e=>{var t;const r=g(e);f(e)&&(e.setContent(null!==(t=a.getItem(r+"draft"))&&void 0!==t?t:"",{format:"raw"}),(e=>{e.dispatch("RestoreDraft")})(e))};var y=hugerte.util.Tools.resolve("hugerte.EditorManager");const D=e=>t=>{t.setEnabled(f(e));const r=()=>t.setEnabled(f(e));return e.on("StoreDraft RestoreDraft RemoveDraft",r),()=>e.off("StoreDraft RestoreDraft RemoveDraft",r)};e.add("autosave",(e=>((e=>{const r=e.options.register,o=e=>{const r=t(e);return r?{value:n(e),valid:r}:{valid:!1,message:"Must be a string."}};r("autosave_ask_before_unload",{processor:"boolean",default:!0}),r("autosave_prefix",{processor:"string",default:"hugerte-autosave-{path}{query}{hash}-{id}-"}),r("autosave_restore_when_empty",{processor:"boolean",default:!1}),r("autosave_interval",{processor:o,default:"30s"}),r("autosave_retention",{processor:o,default:"20m"})})(e),(e=>{e.editorManager.on("BeforeUnload",(e=>{let t;s.each(y.get(),(e=>{e.plugins.autosave&&e.plugins.autosave.storeDraft(),!t&&e.isDirty()&&i(e)&&(t=e.translate("You have unsaved changes are you sure you want to navigate away?"))})),t&&(e.preventDefault(),e.returnValue=t)}))})(e),(e=>{(e=>{const t=d(e);o.setEditorInterval(e,(()=>{p(e)}),t)})(e);const t=()=>{(e=>{e.undoManager.transact((()=>{h(e),m(e)})),e.focus()})(e)};e.ui.registry.addButton("restoredraft",{tooltip:"Restore last draft",icon:"restore-draft",onAction:t,onSetup:D(e)}),e.ui.registry.addMenuItem("restoredraft",{text:"Restore last draft",icon:"restore-draft",onAction:t,onSetup:D(e)})})(e),e.on("init",(()=>{l(e)&&e.dom.isEmpty(e.getBody())&&h(e)})),(e=>({hasDraft:()=>f(e),storeDraft:()=>p(e),restoreDraft:()=>h(e),removeDraft:t=>m(e,t),isEmpty:t=>v(e,t)}))(e))))}();
|
||||
Loading…
Add table
Add a link
Reference in a new issue