@ckeditor/ckeditor5-autosave 32.0.0 → 34.1.0

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/LICENSE.md CHANGED
@@ -2,7 +2,7 @@ Software License Agreement
2
2
  ==========================
3
3
 
4
4
  **CKEditor 5 autosave feature** – https://github.com/ckeditor/ckeditor5-autosave <br>
5
- Copyright (c) 2003-2022, [CKSource](http://cksource.com) Holding sp. z o.o. All rights reserved.
5
+ Copyright (c) 2003-2022, [CKSource Holding sp. z o.o.](https://cksource.com) All rights reserved.
6
6
 
7
7
  Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html).
8
8
 
@@ -14,4 +14,4 @@ Where not otherwise indicated, all CKEditor content is authored by CKSource engi
14
14
  Trademarks
15
15
  ----------
16
16
 
17
- **CKEditor** is a trademark of [CKSource](http://cksource.com) Holding sp. z o.o. All other brand and product names are trademarks, registered trademarks or service marks of their respective holders.
17
+ **CKEditor** is a trademark of [CKSource Holding sp. z o.o.](https://cksource.com) All other brand and product names are trademarks, registered trademarks or service marks of their respective holders.
package/README.md CHANGED
@@ -3,7 +3,8 @@ CKEditor 5 autosave feature
3
3
 
4
4
  [![npm version](https://badge.fury.io/js/%40ckeditor%2Fckeditor5-autosave.svg)](https://www.npmjs.com/package/@ckeditor/ckeditor5-autosave)
5
5
  [![Coverage Status](https://coveralls.io/repos/github/ckeditor/ckeditor5/badge.svg?branch=master)](https://coveralls.io/github/ckeditor/ckeditor5?branch=master)
6
- [![Build Status](https://travis-ci.com/ckeditor/ckeditor5.svg?branch=master)](https://travis-ci.com/ckeditor/ckeditor5)
6
+ [![Build Status](https://travis-ci.com/ckeditor/ckeditor5.svg?branch=master)](https://app.travis-ci.com/github/ckeditor/ckeditor5)
7
+ ![Dependency Status](https://img.shields.io/librariesio/release/npm/@ckeditor/ckeditor5-autosave)
7
8
 
8
9
  This package implements the autosave feature for CKEditor 5.
9
10
 
package/build/autosave.js CHANGED
@@ -1,5 +1,5 @@
1
1
  !function(t){const e=t.en=t.en||{};e.dictionary=Object.assign(e.dictionary||{},{"Saving changes":"Saving changes"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})),
2
2
  /*!
3
- * @license Copyright (c) 2003-2022, CKSource - Frederico Knabben. All rights reserved.
3
+ * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
4
4
  * For licensing, see LICENSE.md.
5
5
  */(()=>{var t={704:(t,e,i)=>{t.exports=i(79)("./src/core.js")},209:(t,e,i)=>{t.exports=i(79)("./src/utils.js")},79:t=>{"use strict";t.exports=CKEditor5.dll}},e={};function i(n){var s=e[n];if(void 0!==s)return s.exports;var o=e[n]={exports:{}};return t[n](o,o.exports,i),o.exports}i.d=(t,e)=>{for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};(()=>{"use strict";i.r(n),i.d(n,{Autosave:()=>D});var t=i(704),e=i(209);const s=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)};const o="object"==typeof global&&global&&global.Object===Object&&global;var r="object"==typeof self&&self&&self.Object===Object&&self;const a=o||r||Function("return this")();const c=function(){return a.Date.now()};var u=/\s/;const d=function(t){for(var e=t.length;e--&&u.test(t.charAt(e)););return e};var l=/^\s+/;const h=function(t){return t?t.slice(0,d(t)+1).replace(l,""):t};const v=a.Symbol;var f=Object.prototype,m=f.hasOwnProperty,g=f.toString,p=v?v.toStringTag:void 0;const _=function(t){var e=m.call(t,p),i=t[p];try{t[p]=void 0;var n=!0}catch(t){}var s=g.call(t);return n&&(e?t[p]=i:delete t[p]),s};var b=Object.prototype.toString;const y=function(t){return b.call(t)};var S=v?v.toStringTag:void 0;const j=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":S&&S in Object(t)?_(t):y(t)};const O=function(t){return null!=t&&"object"==typeof t};const T=function(t){return"symbol"==typeof t||O(t)&&"[object Symbol]"==j(t)};var w=/^[-+]0x[0-9a-f]+$/i,P=/^0b[01]+$/i,A=/^0o[0-7]+$/i,x=parseInt;const E=function(t){if("number"==typeof t)return t;if(T(t))return NaN;if(s(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=s(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=h(t);var i=P.test(t);return i||A.test(t)?x(t.slice(2),i?2:8):w.test(t)?NaN:+t};var N=Math.max,I=Math.min;const C=function(t,e,i){var n,o,r,a,u,d,l=0,h=!1,v=!1,f=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function m(e){var i=n,s=o;return n=o=void 0,l=e,a=t.apply(s,i)}function g(t){return l=t,u=setTimeout(_,e),h?m(t):a}function p(t){var i=t-d;return void 0===d||i>=e||i<0||v&&t-l>=r}function _(){var t=c();if(p(t))return b(t);u=setTimeout(_,function(t){var i=e-(t-d);return v?I(i,r-(t-l)):i}(t))}function b(t){return u=void 0,f&&n?m(t):(n=o=void 0,a)}function y(){var t=c(),i=p(t);if(n=arguments,o=this,d=t,i){if(void 0===u)return g(d);if(v)return clearTimeout(u),u=setTimeout(_,e),m(d)}return void 0===u&&(u=setTimeout(_,e)),a}return e=E(e)||0,s(i)&&(h=!!i.leading,r=(v="maxWait"in i)?N(E(i.maxWait)||0,e):r,f="trailing"in i?!!i.trailing:f),y.cancel=function(){void 0!==u&&clearTimeout(u),l=0,n=d=o=u=void 0},y.flush=function(){return void 0===u?a:b(c())},y};class D extends t.Plugin{static get pluginName(){return"Autosave"}static get requires(){return[t.PendingActions]}constructor(i){super(i);const n=i.config.get("autosave")||{},s=n.waitingTime||1e3;this.set("state","synchronized"),this._debouncedSave=C(this._save.bind(this),s),this._lastDocumentVersion=i.model.document.version,this._savePromise=null,this._domEmitter=Object.create(e.DomEmitterMixin),this._config=n,this._pendingActions=i.plugins.get(t.PendingActions),this._makeImmediateSave=!1}init(){const t=this.editor,e=t.model.document;this.listenTo(t,"ready",(()=>{this.listenTo(e,"change:data",((t,e)=>{this._saveCallbacks.length&&e.isLocal&&("synchronized"===this.state&&(this.state="waiting",this._setPendingAction()),"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(){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((t=>t(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((t=>{throw this.state="error",this.state="saving",this._debouncedSave(),t})),this._savePromise)}_setPendingAction(){const t=this.editor.t;this._action||(this._action=this._pendingActions.add(t("Saving changes")))}get _saveCallbacks(){const t=[];return this.adapter&&this.adapter.save&&t.push(this.adapter.save),this._config.save&&t.push(this._config.save),t}}(0,e.mix)(D,e.ObservableMixin)})(),(window.CKEditor5=window.CKEditor5||{}).autosave=n})();
@@ -0,0 +1 @@
1
+ !function(n){const i=n.el=n.el||{};i.dictionary=Object.assign(i.dictionary||{},{"Saving changes":"Αποθήκευση αλλαγών"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
@@ -0,0 +1 @@
1
+ !function(n){const i=n.jv=n.jv||{};i.dictionary=Object.assign(i.dictionary||{},{"Saving changes":"Nyimpen perubahan"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
@@ -0,0 +1 @@
1
+ !function(n){const i=n.ur=n.ur||{};i.dictionary=Object.assign(i.dictionary||{},{"Saving changes":"خودکار محفوظ"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
@@ -4,7 +4,7 @@
4
4
  "name": "Autosave",
5
5
  "className": "Autosave",
6
6
  "description": "Allows you to automatically save the data (e.g. send it to the server) when needed, for example, when the user changed the content.",
7
- "docs": "builds/guides/integration/saving-data.html#autosave-feature",
7
+ "docs": "installation/advanced/saving-data.html#autosave-feature",
8
8
  "path": "src/autosave.js"
9
9
  }
10
10
  ]
@@ -0,0 +1,21 @@
1
+ # Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ #
3
+ # !!! IMPORTANT !!!
4
+ #
5
+ # Before you edit this file, please keep in mind that contributing to the project
6
+ # translations is possible ONLY via the Transifex online service.
7
+ #
8
+ # To submit your translations, visit https://www.transifex.com/ckeditor/ckeditor5.
9
+ #
10
+ # To learn more, check out the official contributor's guide:
11
+ # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
12
+ #
13
+ msgid ""
14
+ msgstr ""
15
+ "Language-Team: Greek (https://www.transifex.com/ckeditor/teams/11143/el/)\n"
16
+ "Language: el\n"
17
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
18
+
19
+ msgctxt "A message that the data is being saved."
20
+ msgid "Saving changes"
21
+ msgstr "Αποθήκευση αλλαγών"
@@ -0,0 +1,21 @@
1
+ # Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ #
3
+ # !!! IMPORTANT !!!
4
+ #
5
+ # Before you edit this file, please keep in mind that contributing to the project
6
+ # translations is possible ONLY via the Transifex online service.
7
+ #
8
+ # To submit your translations, visit https://www.transifex.com/ckeditor/ckeditor5.
9
+ #
10
+ # To learn more, check out the official contributor's guide:
11
+ # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
12
+ #
13
+ msgid ""
14
+ msgstr ""
15
+ "Language-Team: Javanese (https://www.transifex.com/ckeditor/teams/11143/jv/)\n"
16
+ "Language: jv\n"
17
+ "Plural-Forms: nplurals=1; plural=0;\n"
18
+
19
+ msgctxt "A message that the data is being saved."
20
+ msgid "Saving changes"
21
+ msgstr "Nyimpen perubahan"
@@ -0,0 +1,21 @@
1
+ # Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ #
3
+ # !!! IMPORTANT !!!
4
+ #
5
+ # Before you edit this file, please keep in mind that contributing to the project
6
+ # translations is possible ONLY via the Transifex online service.
7
+ #
8
+ # To submit your translations, visit https://www.transifex.com/ckeditor/ckeditor5.
9
+ #
10
+ # To learn more, check out the official contributor's guide:
11
+ # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
12
+ #
13
+ msgid ""
14
+ msgstr ""
15
+ "Language-Team: Urdu (https://www.transifex.com/ckeditor/teams/11143/ur/)\n"
16
+ "Language: ur\n"
17
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
18
+
19
+ msgctxt "A message that the data is being saved."
20
+ msgid "Saving changes"
21
+ msgstr "خودکار محفوظ"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-autosave",
3
- "version": "32.0.0",
3
+ "version": "34.1.0",
4
4
  "description": "Autosave feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -12,16 +12,16 @@
12
12
  ],
13
13
  "main": "src/index.js",
14
14
  "dependencies": {
15
- "ckeditor5": "^32.0.0",
15
+ "ckeditor5": "^34.1.0",
16
16
  "lodash-es": "^4.17.15"
17
17
  },
18
18
  "devDependencies": {
19
- "@ckeditor/ckeditor5-core": "^32.0.0",
20
- "@ckeditor/ckeditor5-dev-utils": "^27.1.0",
21
- "@ckeditor/ckeditor5-editor-classic": "^32.0.0",
22
- "@ckeditor/ckeditor5-paragraph": "^32.0.0",
23
- "@ckeditor/ckeditor5-source-editing": "^32.0.0",
24
- "@ckeditor/ckeditor5-theme-lark": "^32.0.0",
19
+ "@ckeditor/ckeditor5-core": "^34.1.0",
20
+ "@ckeditor/ckeditor5-dev-utils": "^30.0.0",
21
+ "@ckeditor/ckeditor5-editor-classic": "^34.1.0",
22
+ "@ckeditor/ckeditor5-paragraph": "^34.1.0",
23
+ "@ckeditor/ckeditor5-source-editing": "^34.1.0",
24
+ "@ckeditor/ckeditor5-theme-lark": "^34.1.0",
25
25
  "webpack": "^5.58.1",
26
26
  "webpack-cli": "^4.9.0"
27
27
  },
package/src/autosave.js CHANGED
@@ -37,8 +37,8 @@ import { debounce } from 'lodash-es';
37
37
  * }
38
38
  * } );
39
39
  *
40
- * Read more about this feature in the {@glink builds/guides/integration/saving-data#autosave-feature Autosave feature}
41
- * section of the {@glink builds/guides/integration/saving-data Saving and getting data}.
40
+ * Read more about this feature in the {@glink installation/advanced/saving-data#autosave-feature Autosave feature}
41
+ * section of the {@glink installation/advanced/saving-data Saving and getting data}.
42
42
  *
43
43
  * @extends module:core/plugin~Plugin
44
44
  */
@@ -114,7 +114,7 @@ export default class Autosave extends Plugin {
114
114
  * Promise used for asynchronous save calls.
115
115
  *
116
116
  * Created to handle the autosave call to an external data source. It resolves when that call is finished. It is re-used if
117
- * save is called before the promise has resolved. It is set to `null` if there is no call in progress.
117
+ * save is called before the promise has been resolved. It is set to `null` if there is no call in progress.
118
118
  *
119
119
  * @type {Promise|null}
120
120
  * @private
@@ -148,8 +148,8 @@ export default class Autosave extends Plugin {
148
148
  /**
149
149
  * Informs whether there should be another autosave callback performed, immediately after current autosave callback finishes.
150
150
  *
151
- * This is set to `true` when there's a save request while autosave callback is already being processed and the model has changed
152
- * since the last save.
151
+ * This is set to `true` when there is a save request while autosave callback is already being processed
152
+ * and the model has changed since the last save.
153
153
  *
154
154
  * @private
155
155
  * @type {Boolean}
@@ -157,7 +157,7 @@ export default class Autosave extends Plugin {
157
157
  this._makeImmediateSave = false;
158
158
 
159
159
  /**
160
- * An action that will be added to pending action manager for actions happening in that plugin.
160
+ * An action that will be added to the pending action manager for actions happening in that plugin.
161
161
  *
162
162
  * @private
163
163
  * @member {Object} #_action
@@ -275,10 +275,10 @@ export default class Autosave extends Plugin {
275
275
  .finally( () => {
276
276
  this._savePromise = null;
277
277
  } )
278
- // If the save was successful we have three scenarios:
278
+ // If the save was successful, we have three scenarios:
279
279
  //
280
280
  // 1. If a save was requested when an autosave callback was already processed, we need to immediately call
281
- // another autosave callback. In this case, `this._savePromise` won't be resolved until the next callback is done.
281
+ // another autosave callback. In this case, `this._savePromise` will not be resolved until the next callback is done.
282
282
  // 2. Otherwise, if changes happened to the model, make a delayed autosave callback (like the change just happened).
283
283
  // 3. If no changes happened to the model, return to the `synchronized` state.
284
284
  .then( () => {
@@ -286,10 +286,10 @@ export default class Autosave extends Plugin {
286
286
  this._makeImmediateSave = false;
287
287
 
288
288
  // Start another autosave callback. Return a promise that will be resolved after the new autosave callback.
289
- // This way promises returned by `_save()` won't be resolved until all changes are saved.
289
+ // This way promises returned by `_save()` will not be resolved until all changes are saved.
290
290
  //
291
291
  // If `save()` was called when another (most often automatic) autosave callback was already processed,
292
- // the promise returned by `save()` call will be resolved only after new changes has been saved.
292
+ // the promise returned by `save()` call will be resolved only after new changes have been saved.
293
293
  //
294
294
  // Note that it would not work correctly if `this._savePromise` is not cleared.
295
295
  return this._save();
@@ -304,7 +304,7 @@ export default class Autosave extends Plugin {
304
304
  }
305
305
  }
306
306
  } )
307
- // In case of an error retry the autosave callback after a delay (and also throw the original error).
307
+ // In case of an error, retry the autosave callback after a delay (and also throw the original error).
308
308
  .catch( err => {
309
309
  // Change state to `error` so that listeners handling autosave error can be called.
310
310
  this.state = 'error';
@@ -399,7 +399,7 @@ mix( Autosave, ObservableMixin );
399
399
  *
400
400
  * See {@link module:core/editor/editorconfig~EditorConfig all editor configuration options}.
401
401
  *
402
- * See also the demo of the {@glink builds/guides/integration/saving-data#autosave-feature autosave feature}.
402
+ * See also the demo of the {@glink installation/advanced/saving-data#autosave-feature autosave feature}.
403
403
  *
404
404
  * @interface AutosaveConfig
405
405
  */