@ckeditor/ckeditor5-autosave 45.2.1-alpha.4 → 45.2.1-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/autosave.js +1 -1
- package/package.json +4 -4
package/build/autosave.js
CHANGED
@@ -2,4 +2,4 @@
|
|
2
2
|
/*!
|
3
3
|
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
4
4
|
* For licensing, see LICENSE.md.
|
5
|
-
*/(()=>{var e={237:e=>{"use strict";e.exports=CKEditor5.dll},584:(e,t,i)=>{e.exports=i(237)("./src/utils.js")},782:(e,t,i)=>{e.exports=i(237)("./src/core.js")}},t={};function i(s){var n=t[s];if(void 0!==n)return n.exports;var o=t[s]={exports:{}};return e[s](o,o.exports,i),o.exports}i.d=(e,t)=>{for(var s in t)i.o(t,s)&&!i.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};(()=>{"use strict";i.r(s),i.d(s,{Autosave:()=>o});var e=i(782),t=i(584);function n(e,t,{signal:i,edges:s}={}){let n,o=null;const a=null!=s&&s.includes("leading"),r=null==s||s.includes("trailing"),l=()=>{null!==o&&(e.apply(n,o),n=void 0,o=null)};let c=null;const d=()=>{null!=c&&clearTimeout(c),c=setTimeout((
|
5
|
+
*/(()=>{var e={237:e=>{"use strict";e.exports=CKEditor5.dll},584:(e,t,i)=>{e.exports=i(237)("./src/utils.js")},782:(e,t,i)=>{e.exports=i(237)("./src/core.js")}},t={};function i(s){var n=t[s];if(void 0!==n)return n.exports;var o=t[s]={exports:{}};return e[s](o,o.exports,i),o.exports}i.d=(e,t)=>{for(var s in t)i.o(t,s)&&!i.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};(()=>{"use strict";i.r(s),i.d(s,{Autosave:()=>o});var e=i(782),t=i(584);function n(e,t,{signal:i,edges:s}={}){let n,o=null;const a=null!=s&&s.includes("leading"),r=null==s||s.includes("trailing"),l=()=>{null!==o&&(e.apply(n,o),n=void 0,o=null)};let c=null;const d=()=>{null!=c&&clearTimeout(c),c=setTimeout(()=>{c=null,r&&l(),h()},t)},u=()=>{null!==c&&(clearTimeout(c),c=null)},h=()=>{u(),n=void 0,o=null},m=function(...e){if(i?.aborted)return;n=this,o=e;const t=null==c;d(),a&&t&&l()};return m.schedule=d,m.cancel=h,m.flush=()=>{u(),l()},i?.addEventListener("abort",h,{once:!0}),m}class o extends e.Plugin{adapter;_debouncedSave;_lastDocumentVersion;_savePromise;_domEmitter;_config;_pendingActions;_makeImmediateSave;_action=null;static get pluginName(){return"Autosave"}static get isOfficialPlugin(){return!0}static get requires(){return[e.PendingActions]}constructor(i){super(i);const s=i.config.get("autosave")||{},o=s.waitingTime||1e3;this.set("state","synchronized"),this._debouncedSave=function(e,t=0,i={}){"object"!=typeof i&&(i={});const{signal:s,leading:o=!1,trailing:a=!0,maxWait:r}=i,l=Array(2);let c;o&&(l[0]="leading"),a&&(l[1]="trailing");let d=null;const u=n(function(...t){c=e.apply(this,t),d=null},t,{signal:s,edges:l}),h=function(...t){if(null!=r)if(null===d)d=Date.now();else if(Date.now()-d>=r)return c=e.apply(this,t),d=Date.now(),u.cancel(),u.schedule(),c;return u.apply(this,t),c};return h.cancel=u.cancel,h.flush=()=>(u.flush(),c),h}(this._save.bind(this),o),this._lastDocumentVersion=i.model.document.version,this._savePromise=null,this._domEmitter=new((0,t.DomEmitterMixin)()),this._config=s,this._pendingActions=i.plugins.get(e.PendingActions),this._makeImmediateSave=!1}init(){const e=this.editor,t=e.model.document;this.listenTo(e,"ready",()=>{this.listenTo(t,"change:data",(e,t)=>{this._saveCallbacks.length&&t.isLocal&&("synchronized"===this.state&&(this.state="waiting",this._setPendingAction()),"waiting"===this.state&&this._debouncedSave())})}),this.listenTo(e,"destroy",()=>this._flush(),{priority:"highest"}),this._domEmitter.listenTo(window,"beforeunload",(e,t)=>{this._pendingActions.hasAny&&(t.returnValue=this._pendingActions.first.message)})}destroy(){this._domEmitter.stopListening(),super.destroy()}save(){return this._debouncedSave.cancel(),this._save()}_flush(){this._debouncedSave.flush()}_save(){return this._savePromise?(this._makeImmediateSave=this.editor.model.document.version>this._lastDocumentVersion,this._savePromise):(this._setPendingAction(),this.state="saving",this._lastDocumentVersion=this.editor.model.document.version,this._savePromise=Promise.resolve().then(()=>Promise.all(this._saveCallbacks.map(e=>e(this.editor)))).finally(()=>{this._savePromise=null}).then(()=>{if(this._makeImmediateSave)return this._makeImmediateSave=!1,this._save();this.editor.model.document.version>this._lastDocumentVersion?(this.state="waiting",this._debouncedSave()):(this.state="synchronized",this._pendingActions.remove(this._action),this._action=null)}).catch(e=>{throw this.state="error",this.state="saving",this._debouncedSave(),e}),this._savePromise)}_setPendingAction(){const e=this.editor.t;this._action||(this._action=this._pendingActions.add(e("Saving changes")))}get _saveCallbacks(){const e=[];return this.adapter&&this.adapter.save&&e.push(this.adapter.save),this._config.save&&e.push(this._config.save),e}}})(),(window.CKEditor5=window.CKEditor5||{}).autosave=s})();
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ckeditor/ckeditor5-autosave",
|
3
|
-
"version": "45.2.1-alpha.
|
3
|
+
"version": "45.2.1-alpha.5",
|
4
4
|
"description": "Autosave feature for CKEditor 5.",
|
5
5
|
"keywords": [
|
6
6
|
"ckeditor",
|
@@ -13,9 +13,9 @@
|
|
13
13
|
"type": "module",
|
14
14
|
"main": "src/index.js",
|
15
15
|
"dependencies": {
|
16
|
-
"@ckeditor/ckeditor5-core": "45.2.1-alpha.
|
17
|
-
"@ckeditor/ckeditor5-utils": "45.2.1-alpha.
|
18
|
-
"ckeditor5": "45.2.1-alpha.
|
16
|
+
"@ckeditor/ckeditor5-core": "45.2.1-alpha.5",
|
17
|
+
"@ckeditor/ckeditor5-utils": "45.2.1-alpha.5",
|
18
|
+
"ckeditor5": "45.2.1-alpha.5",
|
19
19
|
"es-toolkit": "1.32.0"
|
20
20
|
},
|
21
21
|
"author": "CKSource (http://cksource.com/)",
|