@ckeditor/ckeditor5-autosave 48.2.0-alpha.7 → 48.3.0-alpha.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.
@@ -1,18 +1,18 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- import type { Autosave, AutosaveConfig } from './index.js';
6
- declare module '@ckeditor/ckeditor5-core' {
7
- interface PluginsMap {
8
- [Autosave.pluginName]: Autosave;
9
- }
10
- interface EditorConfig {
11
- /**
12
- * The configuration of the {@link module:autosave/autosave~Autosave autosave feature}.
13
- *
14
- * Read more in {@link module:autosave/autosave~AutosaveConfig}.
15
- */
16
- autosave?: AutosaveConfig;
17
- }
2
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
+ import type { Autosave, AutosaveConfig } from "./index.js";
6
+ declare module "@ckeditor/ckeditor5-core" {
7
+ interface PluginsMap {
8
+ [Autosave.pluginName]: Autosave;
9
+ }
10
+ interface EditorConfig {
11
+ /**
12
+ * The configuration of the {@link module:autosave/autosave~Autosave autosave feature}.
13
+ *
14
+ * Read more in {@link module:autosave/autosave~AutosaveConfig}.
15
+ */
16
+ autosave?: AutosaveConfig;
17
+ }
18
18
  }
@@ -1,227 +1,227 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
2
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
5
  /**
6
- * @module autosave/autosave
7
- */
8
- import { Plugin, PendingActions, type Editor } from '@ckeditor/ckeditor5-core';
6
+ * @module autosave/autosave
7
+ */
8
+ import { Plugin, PendingActions, type Editor, type PluginDependenciesOf } from "@ckeditor/ckeditor5-core";
9
9
  /**
10
- * The {@link module:autosave/autosave~Autosave} plugin allows you to automatically save the data (e.g. send it to the server)
11
- * when needed (when the user changed the content).
12
- *
13
- * It listens to the {@link module:engine/model/document~ModelDocument#event:change:data `editor.model.document#change:data`}
14
- * and `window#beforeunload` events and calls the
15
- * {@link module:autosave/autosave~AutosaveAdapter#save `config.autosave.save()`} function.
16
- *
17
- * ```ts
18
- * ClassicEditor
19
- * .create( {
20
- * attachTo: document.querySelector( '#editor' ),
21
- * plugins: [ ArticlePluginSet, Autosave ],
22
- * toolbar: [ 'heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'blockQuote', 'undo', 'redo' ],
23
- * image: {
24
- * toolbar: [ 'imageStyle:block', 'imageStyle:side', '|', 'toggleImageCaption', 'imageTextAlternative' ],
25
- * },
26
- * autosave: {
27
- * save( editor: Editor ) {
28
- * // The saveData() function must return a promise
29
- * // which should be resolved when the data is successfully saved.
30
- * return saveData( editor.getData() );
31
- * }
32
- * }
33
- * } );
34
- * ```
35
- *
36
- * Read more about this feature in the {@glink features/autosave Autosave} feature guide.
37
- */
10
+ * The {@link module:autosave/autosave~Autosave} plugin allows you to automatically save the data (e.g. send it to the server)
11
+ * when needed (when the user changed the content).
12
+ *
13
+ * It listens to the {@link module:engine/model/document~ModelDocument#event:change:data `editor.model.document#change:data`}
14
+ * and `window#beforeunload` events and calls the
15
+ * {@link module:autosave/autosave~AutosaveAdapter#save `config.autosave.save()`} function.
16
+ *
17
+ * ```ts
18
+ * ClassicEditor
19
+ * .create( {
20
+ * attachTo: document.querySelector( '#editor' ),
21
+ * plugins: [ ArticlePluginSet, Autosave ],
22
+ * toolbar: [ 'heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'blockQuote', 'undo', 'redo' ],
23
+ * image: {
24
+ * toolbar: [ 'imageStyle:block', 'imageStyle:side', '|', 'toggleImageCaption', 'imageTextAlternative' ],
25
+ * },
26
+ * autosave: {
27
+ * save( editor: Editor ) {
28
+ * // The saveData() function must return a promise
29
+ * // which should be resolved when the data is successfully saved.
30
+ * return saveData( editor.getData() );
31
+ * }
32
+ * }
33
+ * } );
34
+ * ```
35
+ *
36
+ * Read more about this feature in the {@glink features/autosave Autosave} feature guide.
37
+ */
38
38
  export declare class Autosave extends Plugin {
39
- /**
40
- * The adapter is an object with a `save()` method. That method will be called whenever
41
- * the data changes. It might be called some time after the change,
42
- * since the event is throttled for performance reasons.
43
- */
44
- adapter?: AutosaveAdapter;
45
- /**
46
- * The state of this plugin.
47
- *
48
- * The plugin can be in the following states:
49
- *
50
- * * synchronized – When all changes are saved.
51
- * * waiting – When the plugin is waiting for other changes before calling `adapter#save()` and `config.autosave.save()`.
52
- * * saving – When the provided save method is called and the plugin waits for the response.
53
- * * error &ndash When the provided save method will throw an error. This state immediately changes to the `saving` state and
54
- * the save method will be called again in the short period of time.
55
- *
56
- * @observable
57
- * @readonly
58
- */
59
- state: 'synchronized' | 'waiting' | 'saving' | 'error';
60
- /**
61
- * Debounced save method. The `save()` method is called the specified `waitingTime` after `debouncedSave()` is called,
62
- * unless a new action happens in the meantime.
63
- */
64
- private _debouncedSave;
65
- /**
66
- * The last saved document version.
67
- */
68
- private _lastDocumentVersion;
69
- /**
70
- * Promise used for asynchronous save calls.
71
- *
72
- * Created to handle the autosave call to an external data source. It resolves when that call is finished. It is re-used if
73
- * save is called before the promise has been resolved. It is set to `null` if there is no call in progress.
74
- */
75
- private _savePromise;
76
- /**
77
- * DOM emitter.
78
- */
79
- private _domEmitter;
80
- /**
81
- * The configuration of this plugins.
82
- */
83
- private _config;
84
- /**
85
- * Editor's pending actions manager.
86
- */
87
- private _pendingActions;
88
- /**
89
- * Informs whether there should be another autosave callback performed, immediately after current autosave callback finishes.
90
- *
91
- * This is set to `true` when there is a save request while autosave callback is already being processed
92
- * and the model has changed since the last save.
93
- */
94
- private _makeImmediateSave;
95
- /**
96
- * An action that will be added to the pending action manager for actions happening in that plugin.
97
- */
98
- private _action;
99
- /**
100
- * @inheritDoc
101
- */
102
- static get pluginName(): "Autosave";
103
- /**
104
- * @inheritDoc
105
- */
106
- static get isOfficialPlugin(): true;
107
- /**
108
- * @inheritDoc
109
- */
110
- static get requires(): readonly [typeof PendingActions];
111
- /**
112
- * @inheritDoc
113
- */
114
- constructor(editor: Editor);
115
- /**
116
- * @inheritDoc
117
- */
118
- init(): void;
119
- /**
120
- * @inheritDoc
121
- */
122
- destroy(): void;
123
- /**
124
- * Immediately calls autosave callback. All previously queued (debounced) callbacks are cleared. If there is already an autosave
125
- * callback in progress, then the requested save will be performed immediately after the current callback finishes.
126
- *
127
- * @returns A promise that will be resolved when the autosave callback is finished.
128
- */
129
- save(): Promise<void>;
130
- /**
131
- * Invokes the remaining `_save()` method call.
132
- */
133
- private _flush;
134
- /**
135
- * If the adapter is set and a new document version exists,
136
- * the `_save()` method creates a pending action and calls the `adapter.save()` method.
137
- * It waits for the result and then removes the created pending action.
138
- *
139
- * @returns A promise that will be resolved when the autosave callback is finished.
140
- */
141
- private _save;
142
- /**
143
- * Creates a pending action if it is not set already.
144
- */
145
- private _setPendingAction;
146
- /**
147
- * Saves callbacks.
148
- */
149
- private get _saveCallbacks();
39
+ /**
40
+ * The adapter is an object with a `save()` method. That method will be called whenever
41
+ * the data changes. It might be called some time after the change,
42
+ * since the event is throttled for performance reasons.
43
+ */
44
+ adapter?: AutosaveAdapter;
45
+ /**
46
+ * The state of this plugin.
47
+ *
48
+ * The plugin can be in the following states:
49
+ *
50
+ * * synchronized &ndash; When all changes are saved.
51
+ * * waiting &ndash; When the plugin is waiting for other changes before calling `adapter#save()` and `config.autosave.save()`.
52
+ * * saving &ndash; When the provided save method is called and the plugin waits for the response.
53
+ * * error &ndash When the provided save method will throw an error. This state immediately changes to the `saving` state and
54
+ * the save method will be called again in the short period of time.
55
+ *
56
+ * @observable
57
+ * @readonly
58
+ */
59
+ state: "synchronized" | "waiting" | "saving" | "error";
60
+ /**
61
+ * Debounced save method. The `save()` method is called the specified `waitingTime` after `debouncedSave()` is called,
62
+ * unless a new action happens in the meantime.
63
+ */
64
+ private _debouncedSave;
65
+ /**
66
+ * The last saved document version.
67
+ */
68
+ private _lastDocumentVersion;
69
+ /**
70
+ * Promise used for asynchronous save calls.
71
+ *
72
+ * Created to handle the autosave call to an external data source. It resolves when that call is finished. It is re-used if
73
+ * save is called before the promise has been resolved. It is set to `null` if there is no call in progress.
74
+ */
75
+ private _savePromise;
76
+ /**
77
+ * DOM emitter.
78
+ */
79
+ private _domEmitter;
80
+ /**
81
+ * The configuration of this plugins.
82
+ */
83
+ private _config;
84
+ /**
85
+ * Editor's pending actions manager.
86
+ */
87
+ private _pendingActions;
88
+ /**
89
+ * Informs whether there should be another autosave callback performed, immediately after current autosave callback finishes.
90
+ *
91
+ * This is set to `true` when there is a save request while autosave callback is already being processed
92
+ * and the model has changed since the last save.
93
+ */
94
+ private _makeImmediateSave;
95
+ /**
96
+ * An action that will be added to the pending action manager for actions happening in that plugin.
97
+ */
98
+ private _action;
99
+ /**
100
+ * @inheritDoc
101
+ */
102
+ static get pluginName(): "Autosave";
103
+ /**
104
+ * @inheritDoc
105
+ */
106
+ static override get isOfficialPlugin(): true;
107
+ /**
108
+ * @inheritDoc
109
+ */
110
+ static get requires(): PluginDependenciesOf<[PendingActions]>;
111
+ /**
112
+ * @inheritDoc
113
+ */
114
+ constructor(editor: Editor);
115
+ /**
116
+ * @inheritDoc
117
+ */
118
+ init(): void;
119
+ /**
120
+ * @inheritDoc
121
+ */
122
+ override destroy(): void;
123
+ /**
124
+ * Immediately calls autosave callback. All previously queued (debounced) callbacks are cleared. If there is already an autosave
125
+ * callback in progress, then the requested save will be performed immediately after the current callback finishes.
126
+ *
127
+ * @returns A promise that will be resolved when the autosave callback is finished.
128
+ */
129
+ save(): Promise<void>;
130
+ /**
131
+ * Invokes the remaining `_save()` method call.
132
+ */
133
+ private _flush;
134
+ /**
135
+ * If the adapter is set and a new document version exists,
136
+ * the `_save()` method creates a pending action and calls the `adapter.save()` method.
137
+ * It waits for the result and then removes the created pending action.
138
+ *
139
+ * @returns A promise that will be resolved when the autosave callback is finished.
140
+ */
141
+ private _save;
142
+ /**
143
+ * Creates a pending action if it is not set already.
144
+ */
145
+ private _setPendingAction;
146
+ /**
147
+ * Saves callbacks.
148
+ */
149
+ private get _saveCallbacks();
150
150
  }
151
151
  /**
152
- * An interface that requires the `save()` method.
153
- *
154
- * Used by {@link module:autosave/autosave~Autosave#adapter}.
155
- */
152
+ * An interface that requires the `save()` method.
153
+ *
154
+ * Used by {@link module:autosave/autosave~Autosave#adapter}.
155
+ */
156
156
  export interface AutosaveAdapter {
157
- /**
158
- * The method that will be called when the data changes. It should return a promise (e.g. in case of saving content to the database),
159
- * so the autosave plugin will wait for that action before removing it from pending actions.
160
- */
161
- save(editor: Editor): Promise<unknown>;
157
+ /**
158
+ * The method that will be called when the data changes. It should return a promise (e.g. in case of saving content to the database),
159
+ * so the autosave plugin will wait for that action before removing it from pending actions.
160
+ */
161
+ save(editor: Editor): Promise<unknown>;
162
162
  }
163
163
  /**
164
- * The configuration of the {@link module:autosave/autosave~Autosave autosave feature}.
165
- *
166
- * ```ts
167
- * ClassicEditor
168
- * .create( {
169
- * attachTo: editorElement,
170
- * autosave: {
171
- * save( editor: Editor ) {
172
- * // The saveData() function must return a promise
173
- * // which should be resolved when the data is successfully saved.
174
- * return saveData( editor.getData() );
175
- * }
176
- * }
177
- * } );
178
- * .then( ... )
179
- * .catch( ... );
180
- * ```
181
- *
182
- * See {@link module:core/editor/editorconfig~EditorConfig all editor configuration options}.
183
- *
184
- * See also the demo of the {@glink features/autosave autosave feature}.
185
- */
164
+ * The configuration of the {@link module:autosave/autosave~Autosave autosave feature}.
165
+ *
166
+ * ```ts
167
+ * ClassicEditor
168
+ * .create( {
169
+ * attachTo: editorElement,
170
+ * autosave: {
171
+ * save( editor: Editor ) {
172
+ * // The saveData() function must return a promise
173
+ * // which should be resolved when the data is successfully saved.
174
+ * return saveData( editor.getData() );
175
+ * }
176
+ * }
177
+ * } );
178
+ * .then( ... )
179
+ * .catch( ... );
180
+ * ```
181
+ *
182
+ * See {@link module:core/editor/editorconfig~EditorConfig all editor configuration options}.
183
+ *
184
+ * See also the demo of the {@glink features/autosave autosave feature}.
185
+ */
186
186
  export interface AutosaveConfig {
187
- /**
188
- * The callback to be executed when the data needs to be saved.
189
- *
190
- * This function must return a promise which should be resolved when the data is successfully saved.
191
- *
192
- * ```ts
193
- * ClassicEditor
194
- * .create( {
195
- * attachTo: editorElement,
196
- * autosave: {
197
- * save( editor: Editor ) {
198
- * return saveData( editor.getData() );
199
- * }
200
- * }
201
- * } );
202
- * .then( ... )
203
- * .catch( ... );
204
- * ```
205
- */
206
- save?: (editor: Editor) => Promise<unknown>;
207
- /**
208
- * The minimum amount of time that needs to pass after the last action to call the provided callback.
209
- * By default it is 1000 ms.
210
- *
211
- * ```ts
212
- * ClassicEditor
213
- * .create( {
214
- * attachTo: editorElement,
215
- * autosave: {
216
- * save( editor: Editor ) {
217
- * return saveData( editor.getData() );
218
- * },
219
- * waitingTime: 2000
220
- * }
221
- * } );
222
- * .then( ... )
223
- * .catch( ... );
224
- * ```
225
- */
226
- waitingTime?: number;
187
+ /**
188
+ * The callback to be executed when the data needs to be saved.
189
+ *
190
+ * This function must return a promise which should be resolved when the data is successfully saved.
191
+ *
192
+ * ```ts
193
+ * ClassicEditor
194
+ * .create( {
195
+ * attachTo: editorElement,
196
+ * autosave: {
197
+ * save( editor: Editor ) {
198
+ * return saveData( editor.getData() );
199
+ * }
200
+ * }
201
+ * } );
202
+ * .then( ... )
203
+ * .catch( ... );
204
+ * ```
205
+ */
206
+ save?: (editor: Editor) => Promise<unknown>;
207
+ /**
208
+ * The minimum amount of time that needs to pass after the last action to call the provided callback.
209
+ * By default it is 1000 ms.
210
+ *
211
+ * ```ts
212
+ * ClassicEditor
213
+ * .create( {
214
+ * attachTo: editorElement,
215
+ * autosave: {
216
+ * save( editor: Editor ) {
217
+ * return saveData( editor.getData() );
218
+ * },
219
+ * waitingTime: 2000
220
+ * }
221
+ * } );
222
+ * .then( ... )
223
+ * .catch( ... );
224
+ * ```
225
+ */
226
+ waitingTime?: number;
227
227
  }
@@ -2,3 +2,4 @@
2
2
  * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
+
@@ -2,3 +2,4 @@
2
2
  * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
+
package/dist/index.css CHANGED
@@ -3,5 +3,3 @@
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
 
6
-
7
- /*# sourceMappingURL=index.css.map */
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
2
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
5
  /**
6
- * @module autosave
7
- */
8
- export { Autosave, type AutosaveConfig, type AutosaveAdapter } from './autosave.js';
9
- import './augmentation.js';
6
+ * @module autosave
7
+ */
8
+ export { Autosave, type AutosaveConfig, type AutosaveAdapter } from "./autosave.js";
9
+ import "./augmentation.js";
package/dist/index.js CHANGED
@@ -2,251 +2,231 @@
2
2
  * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
- import { Plugin, PendingActions } from '@ckeditor/ckeditor5-core/dist/index.js';
6
- import { DomEmitterMixin } from '@ckeditor/ckeditor5-utils/dist/index.js';
7
- import { debounce } from 'es-toolkit/compat';
5
+ import { PendingActions, Plugin } from "@ckeditor/ckeditor5-core";
6
+ import { DomEmitterMixin } from "@ckeditor/ckeditor5-utils";
7
+ import { debounce } from "es-toolkit/compat";
8
8
 
9
9
  /**
10
- * The {@link module:autosave/autosave~Autosave} plugin allows you to automatically save the data (e.g. send it to the server)
11
- * when needed (when the user changed the content).
12
- *
13
- * It listens to the {@link module:engine/model/document~ModelDocument#event:change:data `editor.model.document#change:data`}
14
- * and `window#beforeunload` events and calls the
15
- * {@link module:autosave/autosave~AutosaveAdapter#save `config.autosave.save()`} function.
16
- *
17
- * ```ts
18
- * ClassicEditor
19
- * .create( {
20
- * attachTo: document.querySelector( '#editor' ),
21
- * plugins: [ ArticlePluginSet, Autosave ],
22
- * toolbar: [ 'heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'blockQuote', 'undo', 'redo' ],
23
- * image: {
24
- * toolbar: [ 'imageStyle:block', 'imageStyle:side', '|', 'toggleImageCaption', 'imageTextAlternative' ],
25
- * },
26
- * autosave: {
27
- * save( editor: Editor ) {
28
- * // The saveData() function must return a promise
29
- * // which should be resolved when the data is successfully saved.
30
- * return saveData( editor.getData() );
31
- * }
32
- * }
33
- * } );
34
- * ```
35
- *
36
- * Read more about this feature in the {@glink features/autosave Autosave} feature guide.
37
- */ class Autosave extends Plugin {
38
- /**
39
- * The adapter is an object with a `save()` method. That method will be called whenever
40
- * the data changes. It might be called some time after the change,
41
- * since the event is throttled for performance reasons.
42
- */ adapter;
43
- /**
44
- * Debounced save method. The `save()` method is called the specified `waitingTime` after `debouncedSave()` is called,
45
- * unless a new action happens in the meantime.
46
- */ _debouncedSave;
47
- /**
48
- * The last saved document version.
49
- */ _lastDocumentVersion;
50
- /**
51
- * Promise used for asynchronous save calls.
52
- *
53
- * Created to handle the autosave call to an external data source. It resolves when that call is finished. It is re-used if
54
- * save is called before the promise has been resolved. It is set to `null` if there is no call in progress.
55
- */ _savePromise;
56
- /**
57
- * DOM emitter.
58
- */ _domEmitter;
59
- /**
60
- * The configuration of this plugins.
61
- */ _config;
62
- /**
63
- * Editor's pending actions manager.
64
- */ _pendingActions;
65
- /**
66
- * Informs whether there should be another autosave callback performed, immediately after current autosave callback finishes.
67
- *
68
- * This is set to `true` when there is a save request while autosave callback is already being processed
69
- * and the model has changed since the last save.
70
- */ _makeImmediateSave;
71
- /**
72
- * An action that will be added to the pending action manager for actions happening in that plugin.
73
- */ _action = null;
74
- /**
75
- * @inheritDoc
76
- */ static get pluginName() {
77
- return 'Autosave';
78
- }
79
- /**
80
- * @inheritDoc
81
- */ static get isOfficialPlugin() {
82
- return true;
83
- }
84
- /**
85
- * @inheritDoc
86
- */ static get requires() {
87
- return [
88
- PendingActions
89
- ];
90
- }
91
- /**
92
- * @inheritDoc
93
- */ constructor(editor){
94
- super(editor);
95
- const config = editor.config.get('autosave') || {};
96
- // A minimum amount of time that needs to pass after the last action.
97
- // After that time the provided save callbacks are being called.
98
- const waitingTime = config.waitingTime || 1000;
99
- this.set('state', 'synchronized');
100
- this._debouncedSave = debounce(this._save.bind(this), waitingTime);
101
- this._lastDocumentVersion = editor.model.document.version;
102
- this._savePromise = null;
103
- this._domEmitter = new (DomEmitterMixin())();
104
- this._config = config;
105
- this._pendingActions = editor.plugins.get(PendingActions);
106
- this._makeImmediateSave = false;
107
- }
108
- /**
109
- * @inheritDoc
110
- */ init() {
111
- const editor = this.editor;
112
- const doc = editor.model.document;
113
- // Add the listener only after the editor is initialized to prevent firing save callback on data init.
114
- this.listenTo(editor, 'ready', ()=>{
115
- this.listenTo(doc, 'change:data', (evt, batch)=>{
116
- if (!this._saveCallbacks.length) {
117
- return;
118
- }
119
- if (!batch.isLocal) {
120
- return;
121
- }
122
- if (this.state === 'synchronized') {
123
- this.state = 'waiting';
124
- // Set pending action already when we are waiting for the autosave callback.
125
- this._setPendingAction();
126
- }
127
- if (this.state === 'waiting') {
128
- this._debouncedSave();
129
- }
130
- // If the plugin is in `saving` state, it will change its state later basing on the `document.version`.
131
- // If the `document.version` will be higher than stored `#_lastDocumentVersion`, then it means, that some `change:data`
132
- // event has fired in the meantime.
133
- });
134
- });
135
- // Flush on the editor's destroy listener with the highest priority to ensure that
136
- // `editor.getData()` will be called before plugins are destroyed.
137
- this.listenTo(editor, 'destroy', ()=>this._flush(), {
138
- priority: 'highest'
139
- });
140
- // It's not possible to easy test it because karma uses `beforeunload` event
141
- // to warn before full page reload and this event cannot be dispatched manually.
142
- /* istanbul ignore next -- @preserve */ this._domEmitter.listenTo(window, 'beforeunload', (evtInfo, domEvt)=>{
143
- if (this._pendingActions.hasAny) {
144
- domEvt.returnValue = this._pendingActions.first.message;
145
- }
146
- });
147
- }
148
- /**
149
- * @inheritDoc
150
- */ destroy() {
151
- // There's no need for canceling or flushing the throttled save, as
152
- // it's done on the editor's destroy event with the highest priority.
153
- this._domEmitter.stopListening();
154
- super.destroy();
155
- }
156
- /**
157
- * Immediately calls autosave callback. All previously queued (debounced) callbacks are cleared. If there is already an autosave
158
- * callback in progress, then the requested save will be performed immediately after the current callback finishes.
159
- *
160
- * @returns A promise that will be resolved when the autosave callback is finished.
161
- */ save() {
162
- this._debouncedSave.cancel();
163
- return this._save();
164
- }
165
- /**
166
- * Invokes the remaining `_save()` method call.
167
- */ _flush() {
168
- this._debouncedSave.flush();
169
- }
170
- /**
171
- * If the adapter is set and a new document version exists,
172
- * the `_save()` method creates a pending action and calls the `adapter.save()` method.
173
- * It waits for the result and then removes the created pending action.
174
- *
175
- * @returns A promise that will be resolved when the autosave callback is finished.
176
- */ _save() {
177
- if (this._savePromise) {
178
- this._makeImmediateSave = this.editor.model.document.version > this._lastDocumentVersion;
179
- return this._savePromise;
180
- }
181
- // Make sure there is a pending action (in case if `_save()` was called through manual `save()` call).
182
- this._setPendingAction();
183
- this.state = 'saving';
184
- this._lastDocumentVersion = this.editor.model.document.version;
185
- // Wait one promise cycle to be sure that save callbacks are not called inside a conversion or when the editor's state changes.
186
- this._savePromise = Promise.resolve()// Make autosave callback.
187
- .then(()=>Promise.all(this._saveCallbacks.map((cb)=>cb(this.editor))))// When the autosave callback is finished, always clear `this._savePromise`, no matter if it was successful or not.
188
- .finally(()=>{
189
- this._savePromise = null;
190
- })// If the save was successful, we have three scenarios:
191
- //
192
- // 1. If a save was requested when an autosave callback was already processed, we need to immediately call
193
- // another autosave callback. In this case, `this._savePromise` will not be resolved until the next callback is done.
194
- // 2. Otherwise, if changes happened to the model, make a delayed autosave callback (like the change just happened).
195
- // 3. If no changes happened to the model, return to the `synchronized` state.
196
- .then(()=>{
197
- if (this._makeImmediateSave) {
198
- this._makeImmediateSave = false;
199
- // Start another autosave callback. Return a promise that will be resolved after the new autosave callback.
200
- // This way promises returned by `_save()` will not be resolved until all changes are saved.
201
- //
202
- // If `save()` was called when another (most often automatic) autosave callback was already processed,
203
- // the promise returned by `save()` call will be resolved only after new changes have been saved.
204
- //
205
- // Note that it would not work correctly if `this._savePromise` is not cleared.
206
- return this._save();
207
- } else {
208
- if (this.editor.model.document.version > this._lastDocumentVersion) {
209
- this.state = 'waiting';
210
- this._debouncedSave();
211
- } else {
212
- this.state = 'synchronized';
213
- this._pendingActions.remove(this._action);
214
- this._action = null;
215
- }
216
- }
217
- })// In case of an error, retry the autosave callback after a delay (and also throw the original error).
218
- .catch((err)=>{
219
- // Change state to `error` so that listeners handling autosave error can be called.
220
- this.state = 'error';
221
- // Then, immediately change to the `saving` state as described above.
222
- // Being in the `saving` state ensures that the autosave callback won't be delayed further by the `change:data` listener.
223
- this.state = 'saving';
224
- this._debouncedSave();
225
- throw err;
226
- });
227
- return this._savePromise;
228
- }
229
- /**
230
- * Creates a pending action if it is not set already.
231
- */ _setPendingAction() {
232
- const t = this.editor.t;
233
- if (!this._action) {
234
- this._action = this._pendingActions.add(t('Saving changes'));
235
- }
236
- }
237
- /**
238
- * Saves callbacks.
239
- */ get _saveCallbacks() {
240
- const saveCallbacks = [];
241
- if (this.adapter && this.adapter.save) {
242
- saveCallbacks.push(this.adapter.save);
243
- }
244
- if (this._config.save) {
245
- saveCallbacks.push(this._config.save);
246
- }
247
- return saveCallbacks;
248
- }
249
- }
10
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
11
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
12
+ */
13
+ /**
14
+ * @module autosave/autosave
15
+ */
16
+ /**
17
+ * The {@link module:autosave/autosave~Autosave} plugin allows you to automatically save the data (e.g. send it to the server)
18
+ * when needed (when the user changed the content).
19
+ *
20
+ * It listens to the {@link module:engine/model/document~ModelDocument#event:change:data `editor.model.document#change:data`}
21
+ * and `window#beforeunload` events and calls the
22
+ * {@link module:autosave/autosave~AutosaveAdapter#save `config.autosave.save()`} function.
23
+ *
24
+ * ```ts
25
+ * ClassicEditor
26
+ * .create( {
27
+ * attachTo: document.querySelector( '#editor' ),
28
+ * plugins: [ ArticlePluginSet, Autosave ],
29
+ * toolbar: [ 'heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'blockQuote', 'undo', 'redo' ],
30
+ * image: {
31
+ * toolbar: [ 'imageStyle:block', 'imageStyle:side', '|', 'toggleImageCaption', 'imageTextAlternative' ],
32
+ * },
33
+ * autosave: {
34
+ * save( editor: Editor ) {
35
+ * // The saveData() function must return a promise
36
+ * // which should be resolved when the data is successfully saved.
37
+ * return saveData( editor.getData() );
38
+ * }
39
+ * }
40
+ * } );
41
+ * ```
42
+ *
43
+ * Read more about this feature in the {@glink features/autosave Autosave} feature guide.
44
+ */
45
+ var Autosave = class extends Plugin {
46
+ /**
47
+ * The adapter is an object with a `save()` method. That method will be called whenever
48
+ * the data changes. It might be called some time after the change,
49
+ * since the event is throttled for performance reasons.
50
+ */
51
+ adapter;
52
+ /**
53
+ * Debounced save method. The `save()` method is called the specified `waitingTime` after `debouncedSave()` is called,
54
+ * unless a new action happens in the meantime.
55
+ */
56
+ _debouncedSave;
57
+ /**
58
+ * The last saved document version.
59
+ */
60
+ _lastDocumentVersion;
61
+ /**
62
+ * Promise used for asynchronous save calls.
63
+ *
64
+ * Created to handle the autosave call to an external data source. It resolves when that call is finished. It is re-used if
65
+ * save is called before the promise has been resolved. It is set to `null` if there is no call in progress.
66
+ */
67
+ _savePromise;
68
+ /**
69
+ * DOM emitter.
70
+ */
71
+ _domEmitter;
72
+ /**
73
+ * The configuration of this plugins.
74
+ */
75
+ _config;
76
+ /**
77
+ * Editor's pending actions manager.
78
+ */
79
+ _pendingActions;
80
+ /**
81
+ * Informs whether there should be another autosave callback performed, immediately after current autosave callback finishes.
82
+ *
83
+ * This is set to `true` when there is a save request while autosave callback is already being processed
84
+ * and the model has changed since the last save.
85
+ */
86
+ _makeImmediateSave;
87
+ /**
88
+ * An action that will be added to the pending action manager for actions happening in that plugin.
89
+ */
90
+ _action = null;
91
+ /**
92
+ * @inheritDoc
93
+ */
94
+ static get pluginName() {
95
+ return "Autosave";
96
+ }
97
+ /**
98
+ * @inheritDoc
99
+ */
100
+ static get isOfficialPlugin() {
101
+ return true;
102
+ }
103
+ /**
104
+ * @inheritDoc
105
+ */
106
+ static get requires() {
107
+ return [PendingActions];
108
+ }
109
+ /**
110
+ * @inheritDoc
111
+ */
112
+ constructor(editor) {
113
+ super(editor);
114
+ const config = editor.config.get("autosave") || {};
115
+ const waitingTime = config.waitingTime || 1e3;
116
+ this.set("state", "synchronized");
117
+ this._debouncedSave = debounce(this._save.bind(this), waitingTime);
118
+ this._lastDocumentVersion = editor.model.document.version;
119
+ this._savePromise = null;
120
+ this._domEmitter = new (DomEmitterMixin())();
121
+ this._config = config;
122
+ this._pendingActions = editor.plugins.get(PendingActions);
123
+ this._makeImmediateSave = false;
124
+ }
125
+ /**
126
+ * @inheritDoc
127
+ */
128
+ init() {
129
+ const editor = this.editor;
130
+ const doc = editor.model.document;
131
+ this.listenTo(editor, "ready", () => {
132
+ this.listenTo(doc, "change:data", (evt, batch) => {
133
+ if (!this._saveCallbacks.length) return;
134
+ if (!batch.isLocal) return;
135
+ if (this.state === "synchronized") {
136
+ this.state = "waiting";
137
+ this._setPendingAction();
138
+ }
139
+ if (this.state === "waiting") this._debouncedSave();
140
+ });
141
+ });
142
+ this.listenTo(editor, "destroy", () => this._flush(), { priority: "highest" });
143
+ /* v8 ignore next -- @preserve */
144
+ this._domEmitter.listenTo(window, "beforeunload", (evtInfo, domEvt) => {
145
+ if (this._pendingActions.hasAny) domEvt.returnValue = this._pendingActions.first.message;
146
+ });
147
+ }
148
+ /**
149
+ * @inheritDoc
150
+ */
151
+ destroy() {
152
+ this._domEmitter.stopListening();
153
+ super.destroy();
154
+ }
155
+ /**
156
+ * Immediately calls autosave callback. All previously queued (debounced) callbacks are cleared. If there is already an autosave
157
+ * callback in progress, then the requested save will be performed immediately after the current callback finishes.
158
+ *
159
+ * @returns A promise that will be resolved when the autosave callback is finished.
160
+ */
161
+ save() {
162
+ this._debouncedSave.cancel();
163
+ return this._save();
164
+ }
165
+ /**
166
+ * Invokes the remaining `_save()` method call.
167
+ */
168
+ _flush() {
169
+ this._debouncedSave.flush();
170
+ }
171
+ /**
172
+ * If the adapter is set and a new document version exists,
173
+ * the `_save()` method creates a pending action and calls the `adapter.save()` method.
174
+ * It waits for the result and then removes the created pending action.
175
+ *
176
+ * @returns A promise that will be resolved when the autosave callback is finished.
177
+ */
178
+ _save() {
179
+ if (this._savePromise) {
180
+ this._makeImmediateSave = this.editor.model.document.version > this._lastDocumentVersion;
181
+ return this._savePromise;
182
+ }
183
+ this._setPendingAction();
184
+ this.state = "saving";
185
+ this._lastDocumentVersion = this.editor.model.document.version;
186
+ this._savePromise = Promise.resolve().then(() => Promise.all(this._saveCallbacks.map((cb) => cb(this.editor)))).finally(() => {
187
+ this._savePromise = null;
188
+ }).then(() => {
189
+ if (this._makeImmediateSave) {
190
+ this._makeImmediateSave = false;
191
+ return this._save();
192
+ } else if (this.editor.model.document.version > this._lastDocumentVersion) {
193
+ this.state = "waiting";
194
+ this._debouncedSave();
195
+ } else {
196
+ this.state = "synchronized";
197
+ this._pendingActions.remove(this._action);
198
+ this._action = null;
199
+ }
200
+ }).catch((err) => {
201
+ this.state = "error";
202
+ this.state = "saving";
203
+ this._debouncedSave();
204
+ throw err;
205
+ });
206
+ return this._savePromise;
207
+ }
208
+ /**
209
+ * Creates a pending action if it is not set already.
210
+ */
211
+ _setPendingAction() {
212
+ const t = this.editor.t;
213
+ if (!this._action) this._action = this._pendingActions.add(t("Saving changes"));
214
+ }
215
+ /**
216
+ * Saves callbacks.
217
+ */
218
+ get _saveCallbacks() {
219
+ const saveCallbacks = [];
220
+ if (this.adapter && this.adapter.save) saveCallbacks.push(this.adapter.save);
221
+ if (this._config.save) saveCallbacks.push(this._config.save);
222
+ return saveCallbacks;
223
+ }
224
+ };
225
+
226
+ /**
227
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
228
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
229
+ */
250
230
 
251
231
  export { Autosave };
252
- //# sourceMappingURL=index.js.map
232
+ //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["index.js","../src/autosave.ts"],"names":["Autosave","Plugin","adapter","_debouncedSave","_lastDocumentVersion","_savePromise","_domEmitter","_config","_pendingActions","_makeImmediateSave","_action","pluginName","isOfficialPlugin","requires","PendingActions","editor","config","get","waitingTime","set","debounce","_save","bind","model","document","version","DomEmitterMixin","plugins","init","doc","listenTo","evt","batch","_saveCallbacks","length","isLocal","state","_setPendingAction","_flush","priority","window","evtInfo","domEvt","hasAny","returnValue","first","message","destroy","stopListening","save","cancel","flush","Promise","resolve","then","all","map","cb","finally","remove","catch","err","t","add","saveCallbacks","push"],"mappings":";;;;AAAA,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC,CAAC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AA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAK,IAAI,CAAC1C,OAAO,CAAC0C,IAAI,CAAA,CAAG;AACxBe,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,aAAAA,CAAcC,IAAI,CAAE,IAAI,CAAC1D,OAAO,CAAC0C,IAAI,CAAA;AACtC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;ADvGF,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CCyGL,MAAA,CAAOe,aAAAA;AACR,CAAA,CAAA,CAAA,CAAA;AACD;;ADvGA,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;AACnB,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC","file":"index.js.map","sourcesContent":["import { Plugin, PendingActions } from '@ckeditor/ckeditor5-core/dist/index.js';\nimport { DomEmitterMixin } from '@ckeditor/ckeditor5-utils/dist/index.js';\nimport { debounce } from 'es-toolkit/compat';\n\n/**\n * The {@link module:autosave/autosave~Autosave} plugin allows you to automatically save the data (e.g. send it to the server)\n * when needed (when the user changed the content).\n *\n * It listens to the {@link module:engine/model/document~ModelDocument#event:change:data `editor.model.document#change:data`}\n * and `window#beforeunload` events and calls the\n * {@link module:autosave/autosave~AutosaveAdapter#save `config.autosave.save()`} function.\n *\n * ```ts\n * ClassicEditor\n * \t.create( {\n * \t\tattachTo: document.querySelector( '#editor' ),\n * \t\tplugins: [ ArticlePluginSet, Autosave ],\n * \t\ttoolbar: [ 'heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'blockQuote', 'undo', 'redo' ],\n * \t\timage: {\n * \t\t\ttoolbar: [ 'imageStyle:block', 'imageStyle:side', '|', 'toggleImageCaption', 'imageTextAlternative' ],\n * \t\t},\n * \t\tautosave: {\n * \t\t\tsave( editor: Editor ) {\n * \t\t\t\t// The saveData() function must return a promise\n * \t\t\t\t// which should be resolved when the data is successfully saved.\n * \t\t\t\treturn saveData( editor.getData() );\n * \t\t\t}\n * \t\t}\n * \t} );\n * ```\n *\n * Read more about this feature in the {@glink features/autosave Autosave} feature guide.\n */ class Autosave extends Plugin {\n /**\n\t * The adapter is an object with a `save()` method. That method will be called whenever\n\t * the data changes. It might be called some time after the change,\n\t * since the event is throttled for performance reasons.\n\t */ adapter;\n /**\n\t * Debounced save method. The `save()` method is called the specified `waitingTime` after `debouncedSave()` is called,\n\t * unless a new action happens in the meantime.\n\t */ _debouncedSave;\n /**\n\t * The last saved document version.\n\t */ _lastDocumentVersion;\n /**\n\t * Promise used for asynchronous save calls.\n\t *\n\t * Created to handle the autosave call to an external data source. It resolves when that call is finished. It is re-used if\n\t * save is called before the promise has been resolved. It is set to `null` if there is no call in progress.\n\t */ _savePromise;\n /**\n\t * DOM emitter.\n\t */ _domEmitter;\n /**\n\t * The configuration of this plugins.\n\t */ _config;\n /**\n\t * Editor's pending actions manager.\n\t */ _pendingActions;\n /**\n\t * Informs whether there should be another autosave callback performed, immediately after current autosave callback finishes.\n\t *\n\t * This is set to `true` when there is a save request while autosave callback is already being processed\n\t * and the model has changed since the last save.\n\t */ _makeImmediateSave;\n /**\n\t * An action that will be added to the pending action manager for actions happening in that plugin.\n\t */ _action = null;\n /**\n\t * @inheritDoc\n\t */ static get pluginName() {\n return 'Autosave';\n }\n /**\n\t * @inheritDoc\n\t */ static get isOfficialPlugin() {\n return true;\n }\n /**\n\t * @inheritDoc\n\t */ static get requires() {\n return [\n PendingActions\n ];\n }\n /**\n\t * @inheritDoc\n\t */ constructor(editor){\n super(editor);\n const config = editor.config.get('autosave') || {};\n // A minimum amount of time that needs to pass after the last action.\n // After that time the provided save callbacks are being called.\n const waitingTime = config.waitingTime || 1000;\n this.set('state', 'synchronized');\n this._debouncedSave = debounce(this._save.bind(this), waitingTime);\n this._lastDocumentVersion = editor.model.document.version;\n this._savePromise = null;\n this._domEmitter = new (DomEmitterMixin())();\n this._config = config;\n this._pendingActions = editor.plugins.get(PendingActions);\n this._makeImmediateSave = false;\n }\n /**\n\t * @inheritDoc\n\t */ init() {\n const editor = this.editor;\n const doc = editor.model.document;\n // Add the listener only after the editor is initialized to prevent firing save callback on data init.\n this.listenTo(editor, 'ready', ()=>{\n this.listenTo(doc, 'change:data', (evt, batch)=>{\n if (!this._saveCallbacks.length) {\n return;\n }\n if (!batch.isLocal) {\n return;\n }\n if (this.state === 'synchronized') {\n this.state = 'waiting';\n // Set pending action already when we are waiting for the autosave callback.\n this._setPendingAction();\n }\n if (this.state === 'waiting') {\n this._debouncedSave();\n }\n // If the plugin is in `saving` state, it will change its state later basing on the `document.version`.\n // If the `document.version` will be higher than stored `#_lastDocumentVersion`, then it means, that some `change:data`\n // event has fired in the meantime.\n });\n });\n // Flush on the editor's destroy listener with the highest priority to ensure that\n // `editor.getData()` will be called before plugins are destroyed.\n this.listenTo(editor, 'destroy', ()=>this._flush(), {\n priority: 'highest'\n });\n // It's not possible to easy test it because karma uses `beforeunload` event\n // to warn before full page reload and this event cannot be dispatched manually.\n /* istanbul ignore next -- @preserve */ this._domEmitter.listenTo(window, 'beforeunload', (evtInfo, domEvt)=>{\n if (this._pendingActions.hasAny) {\n domEvt.returnValue = this._pendingActions.first.message;\n }\n });\n }\n /**\n\t * @inheritDoc\n\t */ destroy() {\n // There's no need for canceling or flushing the throttled save, as\n // it's done on the editor's destroy event with the highest priority.\n this._domEmitter.stopListening();\n super.destroy();\n }\n /**\n\t * Immediately calls autosave callback. All previously queued (debounced) callbacks are cleared. If there is already an autosave\n\t * callback in progress, then the requested save will be performed immediately after the current callback finishes.\n\t *\n\t * @returns A promise that will be resolved when the autosave callback is finished.\n\t */ save() {\n this._debouncedSave.cancel();\n return this._save();\n }\n /**\n\t * Invokes the remaining `_save()` method call.\n\t */ _flush() {\n this._debouncedSave.flush();\n }\n /**\n\t * If the adapter is set and a new document version exists,\n\t * the `_save()` method creates a pending action and calls the `adapter.save()` method.\n\t * It waits for the result and then removes the created pending action.\n\t *\n\t * @returns A promise that will be resolved when the autosave callback is finished.\n\t */ _save() {\n if (this._savePromise) {\n this._makeImmediateSave = this.editor.model.document.version > this._lastDocumentVersion;\n return this._savePromise;\n }\n // Make sure there is a pending action (in case if `_save()` was called through manual `save()` call).\n this._setPendingAction();\n this.state = 'saving';\n this._lastDocumentVersion = this.editor.model.document.version;\n // Wait one promise cycle to be sure that save callbacks are not called inside a conversion or when the editor's state changes.\n this._savePromise = Promise.resolve()// Make autosave callback.\n .then(()=>Promise.all(this._saveCallbacks.map((cb)=>cb(this.editor))))// When the autosave callback is finished, always clear `this._savePromise`, no matter if it was successful or not.\n .finally(()=>{\n this._savePromise = null;\n })// If the save was successful, we have three scenarios:\n //\n // 1. If a save was requested when an autosave callback was already processed, we need to immediately call\n // another autosave callback. In this case, `this._savePromise` will not be resolved until the next callback is done.\n // 2. Otherwise, if changes happened to the model, make a delayed autosave callback (like the change just happened).\n // 3. If no changes happened to the model, return to the `synchronized` state.\n .then(()=>{\n if (this._makeImmediateSave) {\n this._makeImmediateSave = false;\n // Start another autosave callback. Return a promise that will be resolved after the new autosave callback.\n // This way promises returned by `_save()` will not be resolved until all changes are saved.\n //\n // If `save()` was called when another (most often automatic) autosave callback was already processed,\n // the promise returned by `save()` call will be resolved only after new changes have been saved.\n //\n // Note that it would not work correctly if `this._savePromise` is not cleared.\n return this._save();\n } else {\n if (this.editor.model.document.version > this._lastDocumentVersion) {\n this.state = 'waiting';\n this._debouncedSave();\n } else {\n this.state = 'synchronized';\n this._pendingActions.remove(this._action);\n this._action = null;\n }\n }\n })// In case of an error, retry the autosave callback after a delay (and also throw the original error).\n .catch((err)=>{\n // Change state to `error` so that listeners handling autosave error can be called.\n this.state = 'error';\n // Then, immediately change to the `saving` state as described above.\n // Being in the `saving` state ensures that the autosave callback won't be delayed further by the `change:data` listener.\n this.state = 'saving';\n this._debouncedSave();\n throw err;\n });\n return this._savePromise;\n }\n /**\n\t * Creates a pending action if it is not set already.\n\t */ _setPendingAction() {\n const t = this.editor.t;\n if (!this._action) {\n this._action = this._pendingActions.add(t('Saving changes'));\n }\n }\n /**\n\t * Saves callbacks.\n\t */ get _saveCallbacks() {\n const saveCallbacks = [];\n if (this.adapter && this.adapter.save) {\n saveCallbacks.push(this.adapter.save);\n }\n if (this._config.save) {\n saveCallbacks.push(this._config.save);\n }\n return saveCallbacks;\n }\n}\n\nexport { Autosave };\n//# sourceMappingURL=index.js.map\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n\n/**\n * @module autosave/autosave\n */\n\nimport {\n\tPlugin,\n\tPendingActions,\n\ttype Editor,\n\ttype PendingAction,\n\ttype EditorDestroyEvent,\n\ttype EditorReadyEvent\n} from '@ckeditor/ckeditor5-core';\n\nimport { DomEmitterMixin, type DomEmitter } from '@ckeditor/ckeditor5-utils';\n\nimport type { ModelDocumentChangeEvent } from '@ckeditor/ckeditor5-engine';\n\nimport { debounce } from 'es-toolkit/compat';\n\n/**\n * The {@link module:autosave/autosave~Autosave} plugin allows you to automatically save the data (e.g. send it to the server)\n * when needed (when the user changed the content).\n *\n * It listens to the {@link module:engine/model/document~ModelDocument#event:change:data `editor.model.document#change:data`}\n * and `window#beforeunload` events and calls the\n * {@link module:autosave/autosave~AutosaveAdapter#save `config.autosave.save()`} function.\n *\n * ```ts\n * ClassicEditor\n * \t.create( {\n * \t\tattachTo: document.querySelector( '#editor' ),\n * \t\tplugins: [ ArticlePluginSet, Autosave ],\n * \t\ttoolbar: [ 'heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'blockQuote', 'undo', 'redo' ],\n * \t\timage: {\n * \t\t\ttoolbar: [ 'imageStyle:block', 'imageStyle:side', '|', 'toggleImageCaption', 'imageTextAlternative' ],\n * \t\t},\n * \t\tautosave: {\n * \t\t\tsave( editor: Editor ) {\n * \t\t\t\t// The saveData() function must return a promise\n * \t\t\t\t// which should be resolved when the data is successfully saved.\n * \t\t\t\treturn saveData( editor.getData() );\n * \t\t\t}\n * \t\t}\n * \t} );\n * ```\n *\n * Read more about this feature in the {@glink features/autosave Autosave} feature guide.\n */\nexport class Autosave extends Plugin {\n\t/**\n\t * The adapter is an object with a `save()` method. That method will be called whenever\n\t * the data changes. It might be called some time after the change,\n\t * since the event is throttled for performance reasons.\n\t */\n\n\tpublic adapter?: AutosaveAdapter;\n\n\t/**\n\t * The state of this plugin.\n\t *\n\t * The plugin can be in the following states:\n\t *\n\t * * synchronized &ndash; When all changes are saved.\n\t * * waiting &ndash; When the plugin is waiting for other changes before calling `adapter#save()` and `config.autosave.save()`.\n\t * * saving &ndash; When the provided save method is called and the plugin waits for the response.\n\t * * error &ndash When the provided save method will throw an error. This state immediately changes to the `saving` state and\n\t * the save method will be called again in the short period of time.\n\t *\n\t * @observable\n\t * @readonly\n\t */\n\tdeclare public state: 'synchronized' | 'waiting' | 'saving' | 'error';\n\n\t/**\n\t * Debounced save method. The `save()` method is called the specified `waitingTime` after `debouncedSave()` is called,\n\t * unless a new action happens in the meantime.\n\t */\n\tprivate _debouncedSave: ReturnType<typeof debounce<() => void>>;\n\n\t/**\n\t * The last saved document version.\n\t */\n\tprivate _lastDocumentVersion: number;\n\n\t/**\n\t * Promise used for asynchronous save calls.\n\t *\n\t * Created to handle the autosave call to an external data source. It resolves when that call is finished. It is re-used if\n\t * save is called before the promise has been resolved. It is set to `null` if there is no call in progress.\n\t */\n\tprivate _savePromise: Promise<void> | null;\n\n\t/**\n\t * DOM emitter.\n\t */\n\tprivate _domEmitter: DomEmitter;\n\n\t/**\n\t * The configuration of this plugins.\n\t */\n\tprivate _config: AutosaveConfig;\n\n\t/**\n\t * Editor's pending actions manager.\n\t */\n\tprivate _pendingActions: PendingActions;\n\n\t/**\n\t * Informs whether there should be another autosave callback performed, immediately after current autosave callback finishes.\n\t *\n\t * This is set to `true` when there is a save request while autosave callback is already being processed\n\t * and the model has changed since the last save.\n\t */\n\tprivate _makeImmediateSave: boolean;\n\n\t/**\n\t * An action that will be added to the pending action manager for actions happening in that plugin.\n\t */\n\tprivate _action: PendingAction | null = null;\n\n\t/**\n\t * @inheritDoc\n\t */\n\tpublic static get pluginName() {\n\t\treturn 'Autosave' as const;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tpublic static override get isOfficialPlugin(): true {\n\t\treturn true;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tpublic static get requires() {\n\t\treturn [ PendingActions ] as const;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tconstructor( editor: Editor ) {\n\t\tsuper( editor );\n\n\t\tconst config: AutosaveConfig = editor.config.get( 'autosave' ) || {};\n\n\t\t// A minimum amount of time that needs to pass after the last action.\n\t\t// After that time the provided save callbacks are being called.\n\t\tconst waitingTime = config.waitingTime || 1000;\n\n\t\tthis.set( 'state', 'synchronized' );\n\n\t\tthis._debouncedSave = debounce( this._save.bind( this ), waitingTime );\n\t\tthis._lastDocumentVersion = editor.model.document.version;\n\t\tthis._savePromise = null;\n\t\tthis._domEmitter = new ( DomEmitterMixin() )();\n\t\tthis._config = config;\n\t\tthis._pendingActions = editor.plugins.get( PendingActions );\n\t\tthis._makeImmediateSave = false;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tpublic init(): void {\n\t\tconst editor = this.editor;\n\t\tconst doc = editor.model.document;\n\n\t\t// Add the listener only after the editor is initialized to prevent firing save callback on data init.\n\t\tthis.listenTo<EditorReadyEvent>( editor, 'ready', () => {\n\t\t\tthis.listenTo<ModelDocumentChangeEvent>( doc, 'change:data', ( evt, batch ) => {\n\t\t\t\tif ( !this._saveCallbacks.length ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( !batch.isLocal ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( this.state === 'synchronized' ) {\n\t\t\t\t\tthis.state = 'waiting';\n\t\t\t\t\t// Set pending action already when we are waiting for the autosave callback.\n\t\t\t\t\tthis._setPendingAction();\n\t\t\t\t}\n\n\t\t\t\tif ( this.state === 'waiting' ) {\n\t\t\t\t\tthis._debouncedSave();\n\t\t\t\t}\n\n\t\t\t\t// If the plugin is in `saving` state, it will change its state later basing on the `document.version`.\n\t\t\t\t// If the `document.version` will be higher than stored `#_lastDocumentVersion`, then it means, that some `change:data`\n\t\t\t\t// event has fired in the meantime.\n\t\t\t} );\n\t\t} );\n\n\t\t// Flush on the editor's destroy listener with the highest priority to ensure that\n\t\t// `editor.getData()` will be called before plugins are destroyed.\n\t\tthis.listenTo<EditorDestroyEvent>( editor, 'destroy', () => this._flush(), { priority: 'highest' } );\n\n\t\t// It's not possible to easy test it because karma uses `beforeunload` event\n\t\t// to warn before full page reload and this event cannot be dispatched manually.\n\t\t/* istanbul ignore next -- @preserve */\n\t\tthis._domEmitter.listenTo( window, 'beforeunload', ( evtInfo, domEvt ) => {\n\t\t\tif ( this._pendingActions.hasAny ) {\n\t\t\t\tdomEvt.returnValue = this._pendingActions.first!.message;\n\t\t\t}\n\t\t} );\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tpublic override destroy(): void {\n\t\t// There's no need for canceling or flushing the throttled save, as\n\t\t// it's done on the editor's destroy event with the highest priority.\n\n\t\tthis._domEmitter.stopListening();\n\t\tsuper.destroy();\n\t}\n\n\t/**\n\t * Immediately calls autosave callback. All previously queued (debounced) callbacks are cleared. If there is already an autosave\n\t * callback in progress, then the requested save will be performed immediately after the current callback finishes.\n\t *\n\t * @returns A promise that will be resolved when the autosave callback is finished.\n\t */\n\tpublic save(): Promise<void> {\n\t\tthis._debouncedSave.cancel();\n\n\t\treturn this._save();\n\t}\n\n\t/**\n\t * Invokes the remaining `_save()` method call.\n\t */\n\tprivate _flush(): void {\n\t\tthis._debouncedSave.flush();\n\t}\n\n\t/**\n\t * If the adapter is set and a new document version exists,\n\t * the `_save()` method creates a pending action and calls the `adapter.save()` method.\n\t * It waits for the result and then removes the created pending action.\n\t *\n\t * @returns A promise that will be resolved when the autosave callback is finished.\n\t */\n\tprivate _save(): Promise<void> {\n\t\tif ( this._savePromise ) {\n\t\t\tthis._makeImmediateSave = this.editor.model.document.version > this._lastDocumentVersion;\n\n\t\t\treturn this._savePromise;\n\t\t}\n\n\t\t// Make sure there is a pending action (in case if `_save()` was called through manual `save()` call).\n\t\tthis._setPendingAction();\n\n\t\tthis.state = 'saving';\n\t\tthis._lastDocumentVersion = this.editor.model.document.version;\n\n\t\t// Wait one promise cycle to be sure that save callbacks are not called inside a conversion or when the editor's state changes.\n\t\tthis._savePromise = Promise.resolve()\n\t\t\t// Make autosave callback.\n\t\t\t.then( () => Promise.all(\n\t\t\t\tthis._saveCallbacks.map( cb => cb( this.editor ) )\n\t\t\t) )\n\t\t\t// When the autosave callback is finished, always clear `this._savePromise`, no matter if it was successful or not.\n\t\t\t.finally( () => {\n\t\t\t\tthis._savePromise = null;\n\t\t\t} )\n\t\t\t// If the save was successful, we have three scenarios:\n\t\t\t//\n\t\t\t// 1. If a save was requested when an autosave callback was already processed, we need to immediately call\n\t\t\t// another autosave callback. In this case, `this._savePromise` will not be resolved until the next callback is done.\n\t\t\t// 2. Otherwise, if changes happened to the model, make a delayed autosave callback (like the change just happened).\n\t\t\t// 3. If no changes happened to the model, return to the `synchronized` state.\n\t\t\t.then( () => {\n\t\t\t\tif ( this._makeImmediateSave ) {\n\t\t\t\t\tthis._makeImmediateSave = false;\n\n\t\t\t\t\t// Start another autosave callback. Return a promise that will be resolved after the new autosave callback.\n\t\t\t\t\t// This way promises returned by `_save()` will not be resolved until all changes are saved.\n\t\t\t\t\t//\n\t\t\t\t\t// If `save()` was called when another (most often automatic) autosave callback was already processed,\n\t\t\t\t\t// the promise returned by `save()` call will be resolved only after new changes have been saved.\n\t\t\t\t\t//\n\t\t\t\t\t// Note that it would not work correctly if `this._savePromise` is not cleared.\n\t\t\t\t\treturn this._save();\n\t\t\t\t} else {\n\t\t\t\t\tif ( this.editor.model.document.version > this._lastDocumentVersion ) {\n\t\t\t\t\t\tthis.state = 'waiting';\n\t\t\t\t\t\tthis._debouncedSave();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.state = 'synchronized';\n\t\t\t\t\t\tthis._pendingActions.remove( this._action! );\n\t\t\t\t\t\tthis._action = null;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} )\n\t\t\t// In case of an error, retry the autosave callback after a delay (and also throw the original error).\n\t\t\t.catch( err => {\n\t\t\t\t// Change state to `error` so that listeners handling autosave error can be called.\n\t\t\t\tthis.state = 'error';\n\t\t\t\t// Then, immediately change to the `saving` state as described above.\n\t\t\t\t// Being in the `saving` state ensures that the autosave callback won't be delayed further by the `change:data` listener.\n\t\t\t\tthis.state = 'saving';\n\n\t\t\t\tthis._debouncedSave();\n\n\t\t\t\tthrow err;\n\t\t\t} );\n\n\t\treturn this._savePromise;\n\t}\n\n\t/**\n\t * Creates a pending action if it is not set already.\n\t */\n\tprivate _setPendingAction(): void {\n\t\tconst t = this.editor.t;\n\n\t\tif ( !this._action ) {\n\t\t\tthis._action = this._pendingActions.add( t( 'Saving changes' ) );\n\t\t}\n\t}\n\n\t/**\n\t * Saves callbacks.\n\t */\n\tprivate get _saveCallbacks(): Array<( editor: Editor ) => Promise<unknown>> {\n\t\tconst saveCallbacks: Array<( editor: Editor ) => Promise<unknown>> = [];\n\n\t\tif ( this.adapter && this.adapter.save ) {\n\t\t\tsaveCallbacks.push( this.adapter.save );\n\t\t}\n\n\t\tif ( this._config.save ) {\n\t\t\tsaveCallbacks.push( this._config.save );\n\t\t}\n\n\t\treturn saveCallbacks;\n\t}\n}\n\n/**\n * An interface that requires the `save()` method.\n *\n * Used by {@link module:autosave/autosave~Autosave#adapter}.\n */\nexport interface AutosaveAdapter {\n\n\t/**\n\t * The method that will be called when the data changes. It should return a promise (e.g. in case of saving content to the database),\n\t * so the autosave plugin will wait for that action before removing it from pending actions.\n\t */\n\tsave( editor: Editor ): Promise<unknown>;\n}\n\n/**\n * The configuration of the {@link module:autosave/autosave~Autosave autosave feature}.\n *\n * ```ts\n * ClassicEditor\n * \t.create( {\n * \t\tattachTo: editorElement,\n * \t\tautosave: {\n * \t\t\tsave( editor: Editor ) {\n * \t\t\t\t// The saveData() function must return a promise\n * \t\t\t\t// which should be resolved when the data is successfully saved.\n * \t\t\t\treturn saveData( editor.getData() );\n * \t\t\t}\n * \t\t}\n * \t} );\n * \t.then( ... )\n * \t.catch( ... );\n * ```\n *\n * See {@link module:core/editor/editorconfig~EditorConfig all editor configuration options}.\n *\n * See also the demo of the {@glink features/autosave autosave feature}.\n */\nexport interface AutosaveConfig {\n\n\t/**\n\t * The callback to be executed when the data needs to be saved.\n\t *\n\t * This function must return a promise which should be resolved when the data is successfully saved.\n\t *\n\t * ```ts\n\t * ClassicEditor\n\t * \t.create( {\n\t * \t\tattachTo: editorElement,\n\t * \t\tautosave: {\n\t * \t\t\tsave( editor: Editor ) {\n\t * \t\t\t\treturn saveData( editor.getData() );\n\t * \t\t\t}\n\t * \t\t}\n\t * \t} );\n\t * \t.then( ... )\n\t * \t.catch( ... );\n\t * ```\n\t */\n\tsave?: ( editor: Editor ) => Promise<unknown>;\n\n\t/**\n\t * The minimum amount of time that needs to pass after the last action to call the provided callback.\n\t * By default it is 1000 ms.\n\t *\n\t * ```ts\n\t * ClassicEditor\n\t * \t.create( {\n\t * \t\tattachTo: editorElement,\n\t * \t\tautosave: {\n\t * \t\t\tsave( editor: Editor ) {\n\t * \t\t\t\treturn saveData( editor.getData() );\n\t * \t\t\t},\n\t * \t\t\twaitingTime: 2000\n\t * \t\t}\n\t * \t} );\n\t * \t.then( ... )\n\t * \t.catch( ... );\n\t * ```\n\t */\n\twaitingTime?: number;\n}\n"]}
1
+ {"version":3,"sources":["index.js","../src/autosave.ts"],"names":[],"mappings":";;;;AAAA,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,CAA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.map","sourcesContent":["import { PendingActions, Plugin } from \"@ckeditor/ckeditor5-core\";\nimport { DomEmitterMixin } from \"@ckeditor/ckeditor5-utils\";\nimport { debounce } from \"es-toolkit/compat\";\n\n/**\n* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n*/\n/**\n* @module autosave/autosave\n*/\n/**\n* The {@link module:autosave/autosave~Autosave} plugin allows you to automatically save the data (e.g. send it to the server)\n* when needed (when the user changed the content).\n*\n* It listens to the {@link module:engine/model/document~ModelDocument#event:change:data `editor.model.document#change:data`}\n* and `window#beforeunload` events and calls the\n* {@link module:autosave/autosave~AutosaveAdapter#save `config.autosave.save()`} function.\n*\n* ```ts\n* ClassicEditor\n* \t.create( {\n* \t\tattachTo: document.querySelector( '#editor' ),\n* \t\tplugins: [ ArticlePluginSet, Autosave ],\n* \t\ttoolbar: [ 'heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'blockQuote', 'undo', 'redo' ],\n* \t\timage: {\n* \t\t\ttoolbar: [ 'imageStyle:block', 'imageStyle:side', '|', 'toggleImageCaption', 'imageTextAlternative' ],\n* \t\t},\n* \t\tautosave: {\n* \t\t\tsave( editor: Editor ) {\n* \t\t\t\t// The saveData() function must return a promise\n* \t\t\t\t// which should be resolved when the data is successfully saved.\n* \t\t\t\treturn saveData( editor.getData() );\n* \t\t\t}\n* \t\t}\n* \t} );\n* ```\n*\n* Read more about this feature in the {@glink features/autosave Autosave} feature guide.\n*/\nvar Autosave = class extends Plugin {\n\t/**\n\t* The adapter is an object with a `save()` method. That method will be called whenever\n\t* the data changes. It might be called some time after the change,\n\t* since the event is throttled for performance reasons.\n\t*/\n\tadapter;\n\t/**\n\t* Debounced save method. The `save()` method is called the specified `waitingTime` after `debouncedSave()` is called,\n\t* unless a new action happens in the meantime.\n\t*/\n\t_debouncedSave;\n\t/**\n\t* The last saved document version.\n\t*/\n\t_lastDocumentVersion;\n\t/**\n\t* Promise used for asynchronous save calls.\n\t*\n\t* Created to handle the autosave call to an external data source. It resolves when that call is finished. It is re-used if\n\t* save is called before the promise has been resolved. It is set to `null` if there is no call in progress.\n\t*/\n\t_savePromise;\n\t/**\n\t* DOM emitter.\n\t*/\n\t_domEmitter;\n\t/**\n\t* The configuration of this plugins.\n\t*/\n\t_config;\n\t/**\n\t* Editor's pending actions manager.\n\t*/\n\t_pendingActions;\n\t/**\n\t* Informs whether there should be another autosave callback performed, immediately after current autosave callback finishes.\n\t*\n\t* This is set to `true` when there is a save request while autosave callback is already being processed\n\t* and the model has changed since the last save.\n\t*/\n\t_makeImmediateSave;\n\t/**\n\t* An action that will be added to the pending action manager for actions happening in that plugin.\n\t*/\n\t_action = null;\n\t/**\n\t* @inheritDoc\n\t*/\n\tstatic get pluginName() {\n\t\treturn \"Autosave\";\n\t}\n\t/**\n\t* @inheritDoc\n\t*/\n\tstatic get isOfficialPlugin() {\n\t\treturn true;\n\t}\n\t/**\n\t* @inheritDoc\n\t*/\n\tstatic get requires() {\n\t\treturn [PendingActions];\n\t}\n\t/**\n\t* @inheritDoc\n\t*/\n\tconstructor(editor) {\n\t\tsuper(editor);\n\t\tconst config = editor.config.get(\"autosave\") || {};\n\t\tconst waitingTime = config.waitingTime || 1e3;\n\t\tthis.set(\"state\", \"synchronized\");\n\t\tthis._debouncedSave = debounce(this._save.bind(this), waitingTime);\n\t\tthis._lastDocumentVersion = editor.model.document.version;\n\t\tthis._savePromise = null;\n\t\tthis._domEmitter = new (DomEmitterMixin())();\n\t\tthis._config = config;\n\t\tthis._pendingActions = editor.plugins.get(PendingActions);\n\t\tthis._makeImmediateSave = false;\n\t}\n\t/**\n\t* @inheritDoc\n\t*/\n\tinit() {\n\t\tconst editor = this.editor;\n\t\tconst doc = editor.model.document;\n\t\tthis.listenTo(editor, \"ready\", () => {\n\t\t\tthis.listenTo(doc, \"change:data\", (evt, batch) => {\n\t\t\t\tif (!this._saveCallbacks.length) return;\n\t\t\t\tif (!batch.isLocal) return;\n\t\t\t\tif (this.state === \"synchronized\") {\n\t\t\t\t\tthis.state = \"waiting\";\n\t\t\t\t\tthis._setPendingAction();\n\t\t\t\t}\n\t\t\t\tif (this.state === \"waiting\") this._debouncedSave();\n\t\t\t});\n\t\t});\n\t\tthis.listenTo(editor, \"destroy\", () => this._flush(), { priority: \"highest\" });\n\t\t/* v8 ignore next -- @preserve */\n\t\tthis._domEmitter.listenTo(window, \"beforeunload\", (evtInfo, domEvt) => {\n\t\t\tif (this._pendingActions.hasAny) domEvt.returnValue = this._pendingActions.first.message;\n\t\t});\n\t}\n\t/**\n\t* @inheritDoc\n\t*/\n\tdestroy() {\n\t\tthis._domEmitter.stopListening();\n\t\tsuper.destroy();\n\t}\n\t/**\n\t* Immediately calls autosave callback. All previously queued (debounced) callbacks are cleared. If there is already an autosave\n\t* callback in progress, then the requested save will be performed immediately after the current callback finishes.\n\t*\n\t* @returns A promise that will be resolved when the autosave callback is finished.\n\t*/\n\tsave() {\n\t\tthis._debouncedSave.cancel();\n\t\treturn this._save();\n\t}\n\t/**\n\t* Invokes the remaining `_save()` method call.\n\t*/\n\t_flush() {\n\t\tthis._debouncedSave.flush();\n\t}\n\t/**\n\t* If the adapter is set and a new document version exists,\n\t* the `_save()` method creates a pending action and calls the `adapter.save()` method.\n\t* It waits for the result and then removes the created pending action.\n\t*\n\t* @returns A promise that will be resolved when the autosave callback is finished.\n\t*/\n\t_save() {\n\t\tif (this._savePromise) {\n\t\t\tthis._makeImmediateSave = this.editor.model.document.version > this._lastDocumentVersion;\n\t\t\treturn this._savePromise;\n\t\t}\n\t\tthis._setPendingAction();\n\t\tthis.state = \"saving\";\n\t\tthis._lastDocumentVersion = this.editor.model.document.version;\n\t\tthis._savePromise = Promise.resolve().then(() => Promise.all(this._saveCallbacks.map((cb) => cb(this.editor)))).finally(() => {\n\t\t\tthis._savePromise = null;\n\t\t}).then(() => {\n\t\t\tif (this._makeImmediateSave) {\n\t\t\t\tthis._makeImmediateSave = false;\n\t\t\t\treturn this._save();\n\t\t\t} else if (this.editor.model.document.version > this._lastDocumentVersion) {\n\t\t\t\tthis.state = \"waiting\";\n\t\t\t\tthis._debouncedSave();\n\t\t\t} else {\n\t\t\t\tthis.state = \"synchronized\";\n\t\t\t\tthis._pendingActions.remove(this._action);\n\t\t\t\tthis._action = null;\n\t\t\t}\n\t\t}).catch((err) => {\n\t\t\tthis.state = \"error\";\n\t\t\tthis.state = \"saving\";\n\t\t\tthis._debouncedSave();\n\t\t\tthrow err;\n\t\t});\n\t\treturn this._savePromise;\n\t}\n\t/**\n\t* Creates a pending action if it is not set already.\n\t*/\n\t_setPendingAction() {\n\t\tconst t = this.editor.t;\n\t\tif (!this._action) this._action = this._pendingActions.add(t(\"Saving changes\"));\n\t}\n\t/**\n\t* Saves callbacks.\n\t*/\n\tget _saveCallbacks() {\n\t\tconst saveCallbacks = [];\n\t\tif (this.adapter && this.adapter.save) saveCallbacks.push(this.adapter.save);\n\t\tif (this._config.save) saveCallbacks.push(this._config.save);\n\t\treturn saveCallbacks;\n\t}\n};\n\n/**\n* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n*/\n\nexport { Autosave };\n//# sourceMappingURL=index.js.map","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n\n/**\n * @module autosave/autosave\n */\n\nimport {\n\tPlugin,\n\tPendingActions,\n\ttype Editor,\n\ttype PendingAction,\n\ttype EditorDestroyEvent,\n\ttype EditorReadyEvent,\n\ttype PluginDependenciesOf\n} from '@ckeditor/ckeditor5-core';\n\nimport { DomEmitterMixin, type DomEmitter } from '@ckeditor/ckeditor5-utils';\n\nimport type { ModelDocumentChangeEvent } from '@ckeditor/ckeditor5-engine';\n\nimport { debounce } from 'es-toolkit/compat';\n\n/**\n * The {@link module:autosave/autosave~Autosave} plugin allows you to automatically save the data (e.g. send it to the server)\n * when needed (when the user changed the content).\n *\n * It listens to the {@link module:engine/model/document~ModelDocument#event:change:data `editor.model.document#change:data`}\n * and `window#beforeunload` events and calls the\n * {@link module:autosave/autosave~AutosaveAdapter#save `config.autosave.save()`} function.\n *\n * ```ts\n * ClassicEditor\n * \t.create( {\n * \t\tattachTo: document.querySelector( '#editor' ),\n * \t\tplugins: [ ArticlePluginSet, Autosave ],\n * \t\ttoolbar: [ 'heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'blockQuote', 'undo', 'redo' ],\n * \t\timage: {\n * \t\t\ttoolbar: [ 'imageStyle:block', 'imageStyle:side', '|', 'toggleImageCaption', 'imageTextAlternative' ],\n * \t\t},\n * \t\tautosave: {\n * \t\t\tsave( editor: Editor ) {\n * \t\t\t\t// The saveData() function must return a promise\n * \t\t\t\t// which should be resolved when the data is successfully saved.\n * \t\t\t\treturn saveData( editor.getData() );\n * \t\t\t}\n * \t\t}\n * \t} );\n * ```\n *\n * Read more about this feature in the {@glink features/autosave Autosave} feature guide.\n */\nexport class Autosave extends Plugin {\n\t/**\n\t * The adapter is an object with a `save()` method. That method will be called whenever\n\t * the data changes. It might be called some time after the change,\n\t * since the event is throttled for performance reasons.\n\t */\n\n\tpublic adapter?: AutosaveAdapter;\n\n\t/**\n\t * The state of this plugin.\n\t *\n\t * The plugin can be in the following states:\n\t *\n\t * * synchronized &ndash; When all changes are saved.\n\t * * waiting &ndash; When the plugin is waiting for other changes before calling `adapter#save()` and `config.autosave.save()`.\n\t * * saving &ndash; When the provided save method is called and the plugin waits for the response.\n\t * * error &ndash When the provided save method will throw an error. This state immediately changes to the `saving` state and\n\t * the save method will be called again in the short period of time.\n\t *\n\t * @observable\n\t * @readonly\n\t */\n\tdeclare public state: 'synchronized' | 'waiting' | 'saving' | 'error';\n\n\t/**\n\t * Debounced save method. The `save()` method is called the specified `waitingTime` after `debouncedSave()` is called,\n\t * unless a new action happens in the meantime.\n\t */\n\tprivate _debouncedSave: ReturnType<typeof debounce<() => void>>;\n\n\t/**\n\t * The last saved document version.\n\t */\n\tprivate _lastDocumentVersion: number;\n\n\t/**\n\t * Promise used for asynchronous save calls.\n\t *\n\t * Created to handle the autosave call to an external data source. It resolves when that call is finished. It is re-used if\n\t * save is called before the promise has been resolved. It is set to `null` if there is no call in progress.\n\t */\n\tprivate _savePromise: Promise<void> | null;\n\n\t/**\n\t * DOM emitter.\n\t */\n\tprivate _domEmitter: DomEmitter;\n\n\t/**\n\t * The configuration of this plugins.\n\t */\n\tprivate _config: AutosaveConfig;\n\n\t/**\n\t * Editor's pending actions manager.\n\t */\n\tprivate _pendingActions: PendingActions;\n\n\t/**\n\t * Informs whether there should be another autosave callback performed, immediately after current autosave callback finishes.\n\t *\n\t * This is set to `true` when there is a save request while autosave callback is already being processed\n\t * and the model has changed since the last save.\n\t */\n\tprivate _makeImmediateSave: boolean;\n\n\t/**\n\t * An action that will be added to the pending action manager for actions happening in that plugin.\n\t */\n\tprivate _action: PendingAction | null = null;\n\n\t/**\n\t * @inheritDoc\n\t */\n\tpublic static get pluginName() {\n\t\treturn 'Autosave' as const;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tpublic static override get isOfficialPlugin(): true {\n\t\treturn true;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tpublic static get requires(): PluginDependenciesOf<[ PendingActions ]> {\n\t\treturn [ PendingActions ];\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tconstructor( editor: Editor ) {\n\t\tsuper( editor );\n\n\t\tconst config: AutosaveConfig = editor.config.get( 'autosave' ) || {};\n\n\t\t// A minimum amount of time that needs to pass after the last action.\n\t\t// After that time the provided save callbacks are being called.\n\t\tconst waitingTime = config.waitingTime || 1000;\n\n\t\tthis.set( 'state', 'synchronized' );\n\n\t\tthis._debouncedSave = debounce( this._save.bind( this ), waitingTime );\n\t\tthis._lastDocumentVersion = editor.model.document.version;\n\t\tthis._savePromise = null;\n\t\tthis._domEmitter = new ( DomEmitterMixin() )();\n\t\tthis._config = config;\n\t\tthis._pendingActions = editor.plugins.get( PendingActions );\n\t\tthis._makeImmediateSave = false;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tpublic init(): void {\n\t\tconst editor = this.editor;\n\t\tconst doc = editor.model.document;\n\n\t\t// Add the listener only after the editor is initialized to prevent firing save callback on data init.\n\t\tthis.listenTo<EditorReadyEvent>( editor, 'ready', () => {\n\t\t\tthis.listenTo<ModelDocumentChangeEvent>( doc, 'change:data', ( evt, batch ) => {\n\t\t\t\tif ( !this._saveCallbacks.length ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( !batch.isLocal ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( this.state === 'synchronized' ) {\n\t\t\t\t\tthis.state = 'waiting';\n\t\t\t\t\t// Set pending action already when we are waiting for the autosave callback.\n\t\t\t\t\tthis._setPendingAction();\n\t\t\t\t}\n\n\t\t\t\tif ( this.state === 'waiting' ) {\n\t\t\t\t\tthis._debouncedSave();\n\t\t\t\t}\n\n\t\t\t\t// If the plugin is in `saving` state, it will change its state later basing on the `document.version`.\n\t\t\t\t// If the `document.version` will be higher than stored `#_lastDocumentVersion`, then it means, that some `change:data`\n\t\t\t\t// event has fired in the meantime.\n\t\t\t} );\n\t\t} );\n\n\t\t// Flush on the editor's destroy listener with the highest priority to ensure that\n\t\t// `editor.getData()` will be called before plugins are destroyed.\n\t\tthis.listenTo<EditorDestroyEvent>( editor, 'destroy', () => this._flush(), { priority: 'highest' } );\n\n\t\t// This is not easily testable because the `beforeunload` event cannot be dispatched manually\n\t\t// in a way that exercises the native full-page reload warning.\n\t\t/* v8 ignore next -- @preserve */\n\t\tthis._domEmitter.listenTo( window, 'beforeunload', ( evtInfo, domEvt ) => {\n\t\t\tif ( this._pendingActions.hasAny ) {\n\t\t\t\tdomEvt.returnValue = this._pendingActions.first!.message;\n\t\t\t}\n\t\t} );\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tpublic override destroy(): void {\n\t\t// There's no need for canceling or flushing the throttled save, as\n\t\t// it's done on the editor's destroy event with the highest priority.\n\n\t\tthis._domEmitter.stopListening();\n\t\tsuper.destroy();\n\t}\n\n\t/**\n\t * Immediately calls autosave callback. All previously queued (debounced) callbacks are cleared. If there is already an autosave\n\t * callback in progress, then the requested save will be performed immediately after the current callback finishes.\n\t *\n\t * @returns A promise that will be resolved when the autosave callback is finished.\n\t */\n\tpublic save(): Promise<void> {\n\t\tthis._debouncedSave.cancel();\n\n\t\treturn this._save();\n\t}\n\n\t/**\n\t * Invokes the remaining `_save()` method call.\n\t */\n\tprivate _flush(): void {\n\t\tthis._debouncedSave.flush();\n\t}\n\n\t/**\n\t * If the adapter is set and a new document version exists,\n\t * the `_save()` method creates a pending action and calls the `adapter.save()` method.\n\t * It waits for the result and then removes the created pending action.\n\t *\n\t * @returns A promise that will be resolved when the autosave callback is finished.\n\t */\n\tprivate _save(): Promise<void> {\n\t\tif ( this._savePromise ) {\n\t\t\tthis._makeImmediateSave = this.editor.model.document.version > this._lastDocumentVersion;\n\n\t\t\treturn this._savePromise;\n\t\t}\n\n\t\t// Make sure there is a pending action (in case if `_save()` was called through manual `save()` call).\n\t\tthis._setPendingAction();\n\n\t\tthis.state = 'saving';\n\t\tthis._lastDocumentVersion = this.editor.model.document.version;\n\n\t\t// Wait one promise cycle to be sure that save callbacks are not called inside a conversion or when the editor's state changes.\n\t\tthis._savePromise = Promise.resolve()\n\t\t\t// Make autosave callback.\n\t\t\t.then( () => Promise.all(\n\t\t\t\tthis._saveCallbacks.map( cb => cb( this.editor ) )\n\t\t\t) )\n\t\t\t// When the autosave callback is finished, always clear `this._savePromise`, no matter if it was successful or not.\n\t\t\t.finally( () => {\n\t\t\t\tthis._savePromise = null;\n\t\t\t} )\n\t\t\t// If the save was successful, we have three scenarios:\n\t\t\t//\n\t\t\t// 1. If a save was requested when an autosave callback was already processed, we need to immediately call\n\t\t\t// another autosave callback. In this case, `this._savePromise` will not be resolved until the next callback is done.\n\t\t\t// 2. Otherwise, if changes happened to the model, make a delayed autosave callback (like the change just happened).\n\t\t\t// 3. If no changes happened to the model, return to the `synchronized` state.\n\t\t\t.then( () => {\n\t\t\t\tif ( this._makeImmediateSave ) {\n\t\t\t\t\tthis._makeImmediateSave = false;\n\n\t\t\t\t\t// Start another autosave callback. Return a promise that will be resolved after the new autosave callback.\n\t\t\t\t\t// This way promises returned by `_save()` will not be resolved until all changes are saved.\n\t\t\t\t\t//\n\t\t\t\t\t// If `save()` was called when another (most often automatic) autosave callback was already processed,\n\t\t\t\t\t// the promise returned by `save()` call will be resolved only after new changes have been saved.\n\t\t\t\t\t//\n\t\t\t\t\t// Note that it would not work correctly if `this._savePromise` is not cleared.\n\t\t\t\t\treturn this._save();\n\t\t\t\t} else {\n\t\t\t\t\tif ( this.editor.model.document.version > this._lastDocumentVersion ) {\n\t\t\t\t\t\tthis.state = 'waiting';\n\t\t\t\t\t\tthis._debouncedSave();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.state = 'synchronized';\n\t\t\t\t\t\tthis._pendingActions.remove( this._action! );\n\t\t\t\t\t\tthis._action = null;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} )\n\t\t\t// In case of an error, retry the autosave callback after a delay (and also throw the original error).\n\t\t\t.catch( err => {\n\t\t\t\t// Change state to `error` so that listeners handling autosave error can be called.\n\t\t\t\tthis.state = 'error';\n\t\t\t\t// Then, immediately change to the `saving` state as described above.\n\t\t\t\t// Being in the `saving` state ensures that the autosave callback won't be delayed further by the `change:data` listener.\n\t\t\t\tthis.state = 'saving';\n\n\t\t\t\tthis._debouncedSave();\n\n\t\t\t\tthrow err;\n\t\t\t} );\n\n\t\treturn this._savePromise;\n\t}\n\n\t/**\n\t * Creates a pending action if it is not set already.\n\t */\n\tprivate _setPendingAction(): void {\n\t\tconst t = this.editor.t;\n\n\t\tif ( !this._action ) {\n\t\t\tthis._action = this._pendingActions.add( t( 'Saving changes' ) );\n\t\t}\n\t}\n\n\t/**\n\t * Saves callbacks.\n\t */\n\tprivate get _saveCallbacks(): Array<( editor: Editor ) => Promise<unknown>> {\n\t\tconst saveCallbacks: Array<( editor: Editor ) => Promise<unknown>> = [];\n\n\t\tif ( this.adapter && this.adapter.save ) {\n\t\t\tsaveCallbacks.push( this.adapter.save );\n\t\t}\n\n\t\tif ( this._config.save ) {\n\t\t\tsaveCallbacks.push( this._config.save );\n\t\t}\n\n\t\treturn saveCallbacks;\n\t}\n}\n\n/**\n * An interface that requires the `save()` method.\n *\n * Used by {@link module:autosave/autosave~Autosave#adapter}.\n */\nexport interface AutosaveAdapter {\n\n\t/**\n\t * The method that will be called when the data changes. It should return a promise (e.g. in case of saving content to the database),\n\t * so the autosave plugin will wait for that action before removing it from pending actions.\n\t */\n\tsave( editor: Editor ): Promise<unknown>;\n}\n\n/**\n * The configuration of the {@link module:autosave/autosave~Autosave autosave feature}.\n *\n * ```ts\n * ClassicEditor\n * \t.create( {\n * \t\tattachTo: editorElement,\n * \t\tautosave: {\n * \t\t\tsave( editor: Editor ) {\n * \t\t\t\t// The saveData() function must return a promise\n * \t\t\t\t// which should be resolved when the data is successfully saved.\n * \t\t\t\treturn saveData( editor.getData() );\n * \t\t\t}\n * \t\t}\n * \t} );\n * \t.then( ... )\n * \t.catch( ... );\n * ```\n *\n * See {@link module:core/editor/editorconfig~EditorConfig all editor configuration options}.\n *\n * See also the demo of the {@glink features/autosave autosave feature}.\n */\nexport interface AutosaveConfig {\n\n\t/**\n\t * The callback to be executed when the data needs to be saved.\n\t *\n\t * This function must return a promise which should be resolved when the data is successfully saved.\n\t *\n\t * ```ts\n\t * ClassicEditor\n\t * \t.create( {\n\t * \t\tattachTo: editorElement,\n\t * \t\tautosave: {\n\t * \t\t\tsave( editor: Editor ) {\n\t * \t\t\t\treturn saveData( editor.getData() );\n\t * \t\t\t}\n\t * \t\t}\n\t * \t} );\n\t * \t.then( ... )\n\t * \t.catch( ... );\n\t * ```\n\t */\n\tsave?: ( editor: Editor ) => Promise<unknown>;\n\n\t/**\n\t * The minimum amount of time that needs to pass after the last action to call the provided callback.\n\t * By default it is 1000 ms.\n\t *\n\t * ```ts\n\t * ClassicEditor\n\t * \t.create( {\n\t * \t\tattachTo: editorElement,\n\t * \t\tautosave: {\n\t * \t\t\tsave( editor: Editor ) {\n\t * \t\t\t\treturn saveData( editor.getData() );\n\t * \t\t\t},\n\t * \t\t\twaitingTime: 2000\n\t * \t\t}\n\t * \t} );\n\t * \t.then( ... )\n\t * \t.catch( ... );\n\t * ```\n\t */\n\twaitingTime?: number;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-autosave",
3
- "version": "48.2.0-alpha.7",
3
+ "version": "48.3.0-alpha.0",
4
4
  "description": "Autosave feature for CKEditor 5.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "author": "CKSource (http://cksource.com/)",
@@ -26,9 +26,9 @@
26
26
  "./package.json": "./package.json"
27
27
  },
28
28
  "dependencies": {
29
- "@ckeditor/ckeditor5-core": "48.2.0-alpha.7",
30
- "@ckeditor/ckeditor5-engine": "48.2.0-alpha.7",
31
- "@ckeditor/ckeditor5-utils": "48.2.0-alpha.7",
29
+ "@ckeditor/ckeditor5-core": "48.3.0-alpha.0",
30
+ "@ckeditor/ckeditor5-engine": "48.3.0-alpha.0",
31
+ "@ckeditor/ckeditor5-utils": "48.3.0-alpha.0",
32
32
  "es-toolkit": "1.45.1"
33
33
  },
34
34
  "files": [
@@ -1 +0,0 @@
1
- {"version":3,"sources":["index.css"],"names":[],"mappings":";;;;;;AAEA,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC","file":"index.css.map","sourcesContent":["\n\n/*# sourceMappingURL=index.css.map */"]}