@ckeditor/ckeditor5-autosave 48.8.1-alpha.3 → 49.0.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.
- package/LICENSE.md +1 -1
- package/dist/augmentation.d.ts +16 -16
- package/dist/autosave.d.ts +216 -216
- package/dist/index-content.css +3 -0
- package/dist/index-content.css.map +1 -0
- package/dist/index-editor.css +3 -0
- package/dist/index-editor.css.map +1 -0
- package/dist/index.d.ts +7 -7
- package/dist/index.js +224 -244
- package/dist/index.js.map +1 -1
- package/dist/translations/af.js +1 -1
- package/dist/translations/af.umd.js +5 -3
- package/dist/translations/ar.js +1 -1
- package/dist/translations/ar.umd.js +5 -3
- package/dist/translations/ast.js +1 -1
- package/dist/translations/ast.umd.js +5 -3
- package/dist/translations/az.js +1 -1
- package/dist/translations/az.umd.js +5 -3
- package/dist/translations/be.js +1 -1
- package/dist/translations/be.umd.js +5 -3
- package/dist/translations/bg.js +1 -1
- package/dist/translations/bg.umd.js +5 -3
- package/dist/translations/bn.js +1 -1
- package/dist/translations/bn.umd.js +5 -3
- package/dist/translations/bs.js +1 -1
- package/dist/translations/bs.umd.js +5 -3
- package/dist/translations/ca.js +1 -1
- package/dist/translations/ca.umd.js +5 -3
- package/dist/translations/cs.js +1 -1
- package/dist/translations/cs.umd.js +5 -3
- package/dist/translations/da.js +1 -1
- package/dist/translations/da.umd.js +5 -3
- package/dist/translations/de-ch.js +1 -1
- package/dist/translations/de-ch.umd.js +5 -3
- package/dist/translations/de.js +1 -1
- package/dist/translations/de.umd.js +5 -3
- package/dist/translations/el.js +1 -1
- package/dist/translations/el.umd.js +5 -3
- package/dist/translations/en-au.js +1 -1
- package/dist/translations/en-au.umd.js +5 -3
- package/dist/translations/en-gb.js +1 -1
- package/dist/translations/en-gb.umd.js +5 -3
- package/dist/translations/en.js +1 -1
- package/dist/translations/en.umd.js +5 -3
- package/dist/translations/eo.js +1 -1
- package/dist/translations/eo.umd.js +5 -3
- package/dist/translations/es-co.js +1 -1
- package/dist/translations/es-co.umd.js +5 -3
- package/dist/translations/es.js +1 -1
- package/dist/translations/es.umd.js +5 -3
- package/dist/translations/et.js +1 -1
- package/dist/translations/et.umd.js +5 -3
- package/dist/translations/eu.js +1 -1
- package/dist/translations/eu.umd.js +5 -3
- package/dist/translations/fa.js +1 -1
- package/dist/translations/fa.umd.js +5 -3
- package/dist/translations/fi.js +1 -1
- package/dist/translations/fi.umd.js +5 -3
- package/dist/translations/fr.js +1 -1
- package/dist/translations/fr.umd.js +5 -3
- package/dist/translations/gl.js +1 -1
- package/dist/translations/gl.umd.js +5 -3
- package/dist/translations/gu.js +1 -1
- package/dist/translations/gu.umd.js +5 -3
- package/dist/translations/he.js +1 -1
- package/dist/translations/he.umd.js +5 -3
- package/dist/translations/hi.js +1 -1
- package/dist/translations/hi.umd.js +5 -3
- package/dist/translations/hr.js +1 -1
- package/dist/translations/hr.umd.js +5 -3
- package/dist/translations/hu.js +1 -1
- package/dist/translations/hu.umd.js +5 -3
- package/dist/translations/hy.js +1 -1
- package/dist/translations/hy.umd.js +5 -3
- package/dist/translations/id.js +1 -1
- package/dist/translations/id.umd.js +5 -3
- package/dist/translations/it.js +1 -1
- package/dist/translations/it.umd.js +5 -3
- package/dist/translations/ja.js +1 -1
- package/dist/translations/ja.umd.js +5 -3
- package/dist/translations/jv.js +1 -1
- package/dist/translations/jv.umd.js +5 -3
- package/dist/translations/kk.js +1 -1
- package/dist/translations/kk.umd.js +5 -3
- package/dist/translations/km.js +1 -1
- package/dist/translations/km.umd.js +5 -3
- package/dist/translations/kn.js +1 -1
- package/dist/translations/kn.umd.js +5 -3
- package/dist/translations/ko.js +1 -1
- package/dist/translations/ko.umd.js +5 -3
- package/dist/translations/ku.js +1 -1
- package/dist/translations/ku.umd.js +5 -3
- package/dist/translations/lt.js +1 -1
- package/dist/translations/lt.umd.js +5 -3
- package/dist/translations/lv.js +1 -1
- package/dist/translations/lv.umd.js +5 -3
- package/dist/translations/ms.js +1 -1
- package/dist/translations/ms.umd.js +5 -3
- package/dist/translations/nb.js +1 -1
- package/dist/translations/nb.umd.js +5 -3
- package/dist/translations/ne.js +1 -1
- package/dist/translations/ne.umd.js +5 -3
- package/dist/translations/nl.js +1 -1
- package/dist/translations/nl.umd.js +5 -3
- package/dist/translations/no.js +1 -1
- package/dist/translations/no.umd.js +5 -3
- package/dist/translations/oc.js +1 -1
- package/dist/translations/oc.umd.js +5 -3
- package/dist/translations/pl.js +1 -1
- package/dist/translations/pl.umd.js +5 -3
- package/dist/translations/pt-br.js +1 -1
- package/dist/translations/pt-br.umd.js +5 -3
- package/dist/translations/pt.js +1 -1
- package/dist/translations/pt.umd.js +5 -3
- package/dist/translations/ro.js +1 -1
- package/dist/translations/ro.umd.js +5 -3
- package/dist/translations/ru.js +1 -1
- package/dist/translations/ru.umd.js +5 -3
- package/dist/translations/si.js +1 -1
- package/dist/translations/si.umd.js +5 -3
- package/dist/translations/sk.js +1 -1
- package/dist/translations/sk.umd.js +5 -3
- package/dist/translations/sl.js +1 -1
- package/dist/translations/sl.umd.js +5 -3
- package/dist/translations/sq.js +1 -1
- package/dist/translations/sq.umd.js +5 -3
- package/dist/translations/sr-latn.js +1 -1
- package/dist/translations/sr-latn.umd.js +5 -3
- package/dist/translations/sr.js +1 -1
- package/dist/translations/sr.umd.js +5 -3
- package/dist/translations/sv.js +1 -1
- package/dist/translations/sv.umd.js +5 -3
- package/dist/translations/th.js +1 -1
- package/dist/translations/th.umd.js +5 -3
- package/dist/translations/ti.js +1 -1
- package/dist/translations/ti.umd.js +5 -3
- package/dist/translations/tk.js +1 -1
- package/dist/translations/tk.umd.js +5 -3
- package/dist/translations/tr.js +1 -1
- package/dist/translations/tr.umd.js +5 -3
- package/dist/translations/tt.js +1 -1
- package/dist/translations/tt.umd.js +5 -3
- package/dist/translations/ug.js +1 -1
- package/dist/translations/ug.umd.js +5 -3
- package/dist/translations/uk.js +1 -1
- package/dist/translations/uk.umd.js +5 -3
- package/dist/translations/ur.js +1 -1
- package/dist/translations/ur.umd.js +5 -3
- package/dist/translations/uz.js +1 -1
- package/dist/translations/uz.umd.js +5 -3
- package/dist/translations/vi.js +1 -1
- package/dist/translations/vi.umd.js +5 -3
- package/dist/translations/zh-cn.js +1 -1
- package/dist/translations/zh-cn.umd.js +5 -3
- package/dist/translations/zh.js +1 -1
- package/dist/translations/zh.umd.js +5 -3
- package/package.json +5 -5
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 {
|
|
6
|
-
import { DomEmitterMixin } from
|
|
7
|
-
import { debounce } from
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
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
|