Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ckeditor/ckeditor5-autosave

Package Overview
Dependencies
Maintainers
1
Versions
701
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ckeditor/ckeditor5-autosave - npm Package Compare versions

Comparing version 29.0.0 to 29.1.0

ckeditor5-metadata.json

2

build/autosave.js

@@ -5,2 +5,2 @@ /*!

*/
window.CKEditor5=window.CKEditor5||{},window.CKEditor5.autosave=function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=5)}([function(t,e,n){t.exports=n(2)("./src/core.js")},function(t,e,n){t.exports=n(2)("./src/utils.js")},function(t,e){t.exports=CKEditor5.dll},function(t,e,n){"use strict";(function(t){var n="object"==typeof t&&t&&t.Object===Object&&t;e.a=n}).call(this,n(4))},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";n.r(e),n.d(e,"Autosave",(function(){return V}));var i=n(0),r=n(1);var o=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)},s=n(3),a="object"==typeof self&&self&&self.Object===Object&&self,u=s.a||a||Function("return this")(),c=function(){return u.Date.now()},l=/\s/;var d=function(t){for(var e=t.length;e--&&l.test(t.charAt(e)););return e},f=/^\s+/;var h=function(t){return t?t.slice(0,d(t)+1).replace(f,""):t},v=u.Symbol,p=Object.prototype,g=p.hasOwnProperty,b=p.toString,m=v?v.toStringTag:void 0;var y=function(t){var e=g.call(t,m),n=t[m];try{t[m]=void 0;var i=!0}catch(t){}var r=b.call(t);return i&&(e?t[m]=n:delete t[m]),r},_=Object.prototype.toString;var j=function(t){return _.call(t)},w=v?v.toStringTag:void 0;var O=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":w&&w in Object(t)?y(t):j(t)};var S=function(t){return null!=t&&"object"==typeof t};var x=function(t){return"symbol"==typeof t||S(t)&&"[object Symbol]"==O(t)},T=/^[-+]0x[0-9a-f]+$/i,A=/^0b[01]+$/i,P=/^0o[0-7]+$/i,E=parseInt;var M=function(t){if("number"==typeof t)return t;if(x(t))return NaN;if(o(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=o(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=h(t);var n=A.test(t);return n||P.test(t)?E(t.slice(2),n?2:8):T.test(t)?NaN:+t},C=Math.max,D=Math.min;var N=function(t,e,n){var i,r,s,a,u,l,d=0,f=!1,h=!1,v=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function p(e){var n=i,o=r;return i=r=void 0,d=e,a=t.apply(o,n)}function g(t){return d=t,u=setTimeout(m,e),f?p(t):a}function b(t){var n=t-l;return void 0===l||n>=e||n<0||h&&t-d>=s}function m(){var t=c();if(b(t))return y(t);u=setTimeout(m,function(t){var n=e-(t-l);return h?D(n,s-(t-d)):n}(t))}function y(t){return u=void 0,v&&i?p(t):(i=r=void 0,a)}function _(){var t=c(),n=b(t);if(i=arguments,r=this,l=t,n){if(void 0===u)return g(l);if(h)return clearTimeout(u),u=setTimeout(m,e),p(l)}return void 0===u&&(u=setTimeout(m,e)),a}return e=M(e)||0,o(n)&&(f=!!n.leading,s=(h="maxWait"in n)?C(M(n.maxWait)||0,e):s,v="trailing"in n?!!n.trailing:v),_.cancel=function(){void 0!==u&&clearTimeout(u),d=0,i=l=r=u=void 0},_.flush=function(){return void 0===u?a:y(c())},_};class V extends i.Plugin{static get pluginName(){return"Autosave"}static get requires(){return[i.PendingActions]}constructor(t){super(t);const e=t.config.get("autosave")||{},n=e.waitingTime||1e3;this.set("state","synchronized"),this._debouncedSave=N(this._save.bind(this),n),this._lastDocumentVersion=t.model.document.version,this._domEmitter=Object.create(r.DomEmitterMixin),this._config=e}init(){const t=this.editor,e=t.model.document,n=t.t;this._pendingActions=t.plugins.get(i.PendingActions),this.listenTo(e,"change:data",()=>{this._saveCallbacks.length&&("synchronized"==this.state?(this._action=this._pendingActions.add(n("Saving changes")),this.state="waiting",this._debouncedSave()):"waiting"==this.state&&this._debouncedSave())}),this.listenTo(t,"destroy",()=>this._flush(),{priority:"highest"}),this._domEmitter.listenTo(window,"beforeunload",(t,e)=>{this._pendingActions.hasAny&&(e.returnValue=this._pendingActions.first.message)})}destroy(){this._domEmitter.stopListening(),super.destroy()}_flush(){this._debouncedSave.flush()}_save(){const t=this.editor.model.document.version;t<this._lastDocumentVersion||"initializing"===this.editor.state?this._debouncedSave.cancel():(this._lastDocumentVersion=t,this.state="saving",Promise.resolve().then(()=>Promise.all(this._saveCallbacks.map(t=>t(this.editor)))).catch(t=>{throw this.state="error",this.state="saving",this._debouncedSave(),t}).then(()=>{this.editor.model.document.version>this._lastDocumentVersion?(this.state="waiting",this._debouncedSave()):(this.state="synchronized",this._pendingActions.remove(this._action),this._action=null)}))}get _saveCallbacks(){const t=[];return this.adapter&&this.adapter.save&&t.push(this.adapter.save),this._config.save&&t.push(this._config.save),t}}Object(r.mix)(V,r.ObservableMixin)}]);
window.CKEditor5=window.CKEditor5||{},window.CKEditor5.autosave=function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=5)}([function(t,e,n){t.exports=n(2)("./src/core.js")},function(t,e,n){t.exports=n(2)("./src/utils.js")},function(t,e){t.exports=CKEditor5.dll},function(t,e,n){"use strict";(function(t){var n="object"==typeof t&&t&&t.Object===Object&&t;e.a=n}).call(this,n(4))},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";n.r(e),n.d(e,"Autosave",(function(){return K}));var i=n(0),r=n(1);var o=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)},s=n(3),a="object"==typeof self&&self&&self.Object===Object&&self,u=s.a||a||Function("return this")(),c=function(){return u.Date.now()},l=/\s/;var d=function(t){for(var e=t.length;e--&&l.test(t.charAt(e)););return e},f=/^\s+/;var h=function(t){return t?t.slice(0,d(t)+1).replace(f,""):t},v=u.Symbol,p=Object.prototype,b=p.hasOwnProperty,g=p.toString,m=v?v.toStringTag:void 0;var y=function(t){var e=b.call(t,m),n=t[m];try{t[m]=void 0;var i=!0}catch(t){}var r=g.call(t);return i&&(e?t[m]=n:delete t[m]),r},_=Object.prototype.toString;var j=function(t){return _.call(t)},w=v?v.toStringTag:void 0;var O=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":w&&w in Object(t)?y(t):j(t)};var S=function(t){return null!=t&&"object"==typeof t};var x=function(t){return"symbol"==typeof t||S(t)&&"[object Symbol]"==O(t)},T=/^[-+]0x[0-9a-f]+$/i,A=/^0b[01]+$/i,P=/^0o[0-7]+$/i,E=parseInt;var M=function(t){if("number"==typeof t)return t;if(x(t))return NaN;if(o(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=o(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=h(t);var n=A.test(t);return n||P.test(t)?E(t.slice(2),n?2:8):T.test(t)?NaN:+t},C=Math.max,N=Math.min;var D=function(t,e,n){var i,r,s,a,u,l,d=0,f=!1,h=!1,v=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function p(e){var n=i,o=r;return i=r=void 0,d=e,a=t.apply(o,n)}function b(t){return d=t,u=setTimeout(m,e),f?p(t):a}function g(t){var n=t-l;return void 0===l||n>=e||n<0||h&&t-d>=s}function m(){var t=c();if(g(t))return y(t);u=setTimeout(m,function(t){var n=e-(t-l);return h?N(n,s-(t-d)):n}(t))}function y(t){return u=void 0,v&&i?p(t):(i=r=void 0,a)}function _(){var t=c(),n=g(t);if(i=arguments,r=this,l=t,n){if(void 0===u)return b(l);if(h)return clearTimeout(u),u=setTimeout(m,e),p(l)}return void 0===u&&(u=setTimeout(m,e)),a}return e=M(e)||0,o(n)&&(f=!!n.leading,s=(h="maxWait"in n)?C(M(n.maxWait)||0,e):s,v="trailing"in n?!!n.trailing:v),_.cancel=function(){void 0!==u&&clearTimeout(u),d=0,i=l=r=u=void 0},_.flush=function(){return void 0===u?a:y(c())},_};class K extends i.Plugin{static get pluginName(){return"Autosave"}static get requires(){return[i.PendingActions]}constructor(t){super(t);const e=t.config.get("autosave")||{},n=e.waitingTime||1e3;this.set("state","synchronized"),this._debouncedSave=D(this._save.bind(this),n),this._lastDocumentVersion=t.model.document.version,this._domEmitter=Object.create(r.DomEmitterMixin),this._config=e}init(){const t=this.editor,e=t.model.document,n=t.t;this._pendingActions=t.plugins.get(i.PendingActions),this.listenTo(t,"ready",()=>{this.listenTo(e,"change:data",()=>{this._saveCallbacks.length&&("synchronized"==this.state?(this._action=this._pendingActions.add(n("Saving changes")),this.state="waiting",this._debouncedSave()):"waiting"==this.state&&this._debouncedSave())})}),this.listenTo(t,"destroy",()=>this._flush(),{priority:"highest"}),this._domEmitter.listenTo(window,"beforeunload",(t,e)=>{this._pendingActions.hasAny&&(e.returnValue=this._pendingActions.first.message)})}destroy(){this._domEmitter.stopListening(),super.destroy()}save(){this._debouncedSave.cancel(),this._save()}_flush(){this._debouncedSave.flush()}_save(){this.state="saving",this._lastDocumentVersion=this.editor.model.document.version,Promise.resolve().then(()=>Promise.all(this._saveCallbacks.map(t=>t(this.editor)))).catch(t=>{throw this.state="error",this.state="saving",this._debouncedSave(),t}).then(()=>{this.editor.model.document.version>this._lastDocumentVersion?(this.state="waiting",this._debouncedSave()):(this.state="synchronized",this._pendingActions.remove(this._action),this._action=null)})}get _saveCallbacks(){const t=[];return this.adapter&&this.adapter.save&&t.push(this.adapter.save),this._config.save&&t.push(this._config.save),t}}Object(r.mix)(K,r.ObservableMixin)}]);
Software License Agreement
==========================
**ckeditor5-autosave** – https://github.com/ckeditor/ckeditor5-autosave <br>
**CKEditor 5 autosave feature** – https://github.com/ckeditor/ckeditor5-autosave <br>
Copyright (c) 2003-2021, [CKSource](http://cksource.com) Frederico Knabben. All rights reserved.

@@ -6,0 +6,0 @@

{
"name": "@ckeditor/ckeditor5-autosave",
"version": "29.0.0",
"version": "29.1.0",
"description": "Autosave feature for CKEditor 5.",

@@ -10,15 +10,16 @@ "keywords": [

"ckeditor5-feature",
"ckeditor5-plugin"
"ckeditor5-plugin",
"ckeditor5-dll"
],
"main": "src/index.js",
"dependencies": {
"ckeditor5": "^29.0.0",
"ckeditor5": "^29.1.0",
"lodash-es": "^4.17.15"
},
"devDependencies": {
"@ckeditor/ckeditor5-core": "^29.0.0",
"@ckeditor/ckeditor5-dev-utils": "^25.0.0",
"@ckeditor/ckeditor5-editor-classic": "^29.0.0",
"@ckeditor/ckeditor5-paragraph": "^29.0.0",
"@ckeditor/ckeditor5-theme-lark": "^29.0.0",
"@ckeditor/ckeditor5-core": "^29.1.0",
"@ckeditor/ckeditor5-dev-utils": "^25.3.0",
"@ckeditor/ckeditor5-editor-classic": "^29.1.0",
"@ckeditor/ckeditor5-paragraph": "^29.1.0",
"@ckeditor/ckeditor5-theme-lark": "^29.1.0",
"webpack": "^4.43.0",

@@ -44,3 +45,4 @@ "webpack-cli": "^3.3.11"

"theme",
"build"
"build",
"ckeditor5-metadata.json"
],

@@ -47,0 +49,0 @@ "scripts": {

@@ -105,3 +105,3 @@ /**

/**
* The last document version.
* The last saved document version.
*

@@ -154,21 +154,24 @@ * @private

this.listenTo( doc, 'change:data', () => {
if ( !this._saveCallbacks.length ) {
return;
}
// Add the listener only after the editor is initialized to prevent firing save callback on data init.
this.listenTo( editor, 'ready', () => {
this.listenTo( doc, 'change:data', () => {
if ( !this._saveCallbacks.length ) {
return;
}
if ( this.state == 'synchronized' ) {
this._action = this._pendingActions.add( t( 'Saving changes' ) );
this.state = 'waiting';
if ( this.state == 'synchronized' ) {
this._action = this._pendingActions.add( t( 'Saving changes' ) );
this.state = 'waiting';
this._debouncedSave();
}
this._debouncedSave();
}
else if ( this.state == 'waiting' ) {
this._debouncedSave();
}
else if ( this.state == 'waiting' ) {
this._debouncedSave();
}
// If the plugin is in `saving` state, it will change its state later basing on the `document.version`.
// If the `document.version` will be higher than stored `#_lastDocumentVersion`, then it means, that some `change:data`
// event has fired in the meantime.
// If the plugin is in `saving` state, it will change its state later basing on the `document.version`.
// If the `document.version` will be higher than stored `#_lastDocumentVersion`, then it means, that some `change:data`
// event has fired in the meantime.
} );
} );

@@ -202,2 +205,10 @@

/**
* Calls autosave plugin callback and cancels any delayed callbacks that may have been already triggered.
*/
save() {
this._debouncedSave.cancel();
this._save();
}
/**
* Invokes the remaining `_save()` method call.

@@ -219,18 +230,4 @@ *

_save() {
const version = this.editor.model.document.version;
// Change may not produce an operation, so the document's version
// can be the same after that change.
if (
version < this._lastDocumentVersion ||
this.editor.state === 'initializing'
) {
this._debouncedSave.cancel();
return;
}
this._lastDocumentVersion = version;
this.state = 'saving';
this._lastDocumentVersion = this.editor.model.document.version;

@@ -237,0 +234,0 @@ // Wait one promise cycle to be sure that save callbacks are not called

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc