@ckeditor/ckeditor5-autosave 39.0.1 → 40.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +3 -3
  3. package/build/autosave.js.map +1 -0
  4. package/build/translations/hy.js +1 -0
  5. package/lang/translations/af.po +1 -0
  6. package/lang/translations/ar.po +1 -0
  7. package/lang/translations/az.po +1 -0
  8. package/lang/translations/bg.po +1 -0
  9. package/lang/translations/bn.po +1 -0
  10. package/lang/translations/bs.po +1 -0
  11. package/lang/translations/ca.po +1 -0
  12. package/lang/translations/cs.po +1 -0
  13. package/lang/translations/da.po +1 -0
  14. package/lang/translations/de-ch.po +1 -0
  15. package/lang/translations/de.po +1 -0
  16. package/lang/translations/el.po +1 -0
  17. package/lang/translations/en-au.po +1 -0
  18. package/lang/translations/en-gb.po +1 -0
  19. package/lang/translations/en.po +1 -0
  20. package/lang/translations/es-co.po +1 -0
  21. package/lang/translations/es.po +1 -0
  22. package/lang/translations/et.po +1 -0
  23. package/lang/translations/fa.po +1 -0
  24. package/lang/translations/fi.po +1 -0
  25. package/lang/translations/fr.po +1 -0
  26. package/lang/translations/gl.po +1 -0
  27. package/lang/translations/he.po +1 -0
  28. package/lang/translations/hi.po +1 -0
  29. package/lang/translations/hr.po +1 -0
  30. package/lang/translations/hu.po +1 -0
  31. package/lang/translations/hy.po +22 -0
  32. package/lang/translations/id.po +1 -0
  33. package/lang/translations/it.po +1 -0
  34. package/lang/translations/ja.po +1 -0
  35. package/lang/translations/jv.po +1 -0
  36. package/lang/translations/km.po +1 -0
  37. package/lang/translations/ko.po +1 -0
  38. package/lang/translations/ku.po +1 -0
  39. package/lang/translations/lt.po +1 -0
  40. package/lang/translations/lv.po +1 -0
  41. package/lang/translations/ms.po +1 -0
  42. package/lang/translations/ne.po +1 -0
  43. package/lang/translations/nl.po +1 -0
  44. package/lang/translations/no.po +1 -0
  45. package/lang/translations/pl.po +1 -0
  46. package/lang/translations/pt-br.po +1 -0
  47. package/lang/translations/pt.po +1 -0
  48. package/lang/translations/ro.po +1 -0
  49. package/lang/translations/ru.po +1 -0
  50. package/lang/translations/sk.po +1 -0
  51. package/lang/translations/sl.po +1 -0
  52. package/lang/translations/sq.po +1 -0
  53. package/lang/translations/sr-latn.po +1 -0
  54. package/lang/translations/sr.po +1 -0
  55. package/lang/translations/sv.po +1 -0
  56. package/lang/translations/th.po +1 -0
  57. package/lang/translations/tk.po +1 -0
  58. package/lang/translations/tr.po +1 -0
  59. package/lang/translations/ug.po +1 -0
  60. package/lang/translations/uk.po +1 -0
  61. package/lang/translations/ur.po +1 -0
  62. package/lang/translations/uz.po +1 -0
  63. package/lang/translations/vi.po +1 -0
  64. package/lang/translations/zh-cn.po +1 -0
  65. package/lang/translations/zh.po +1 -0
  66. package/package.json +2 -6
  67. package/src/augmentation.d.ts +18 -18
  68. package/src/augmentation.js +5 -5
  69. package/src/autosave.d.ts +219 -219
  70. package/src/autosave.js +228 -228
  71. package/src/index.d.ts +9 -9
  72. package/src/index.js +9 -9
@@ -15,6 +15,7 @@ msgstr ""
15
15
  "Language-Team: Swedish (https://app.transifex.com/ckeditor/teams/11143/sv/)\n"
16
16
  "Language: sv\n"
17
17
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
18
+ "Content-Type: text/plain; charset=UTF-8\n"
18
19
 
19
20
  msgctxt "A message that the data is being saved."
20
21
  msgid "Saving changes"
@@ -15,6 +15,7 @@ msgstr ""
15
15
  "Language-Team: Thai (https://app.transifex.com/ckeditor/teams/11143/th/)\n"
16
16
  "Language: th\n"
17
17
  "Plural-Forms: nplurals=1; plural=0;\n"
18
+ "Content-Type: text/plain; charset=UTF-8\n"
18
19
 
19
20
  msgctxt "A message that the data is being saved."
20
21
  msgid "Saving changes"
@@ -15,6 +15,7 @@ msgstr ""
15
15
  "Language-Team: Turkmen (https://app.transifex.com/ckeditor/teams/11143/tk/)\n"
16
16
  "Language: tk\n"
17
17
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
18
+ "Content-Type: text/plain; charset=UTF-8\n"
18
19
 
19
20
  msgctxt "A message that the data is being saved."
20
21
  msgid "Saving changes"
@@ -15,6 +15,7 @@ msgstr ""
15
15
  "Language-Team: Turkish (https://app.transifex.com/ckeditor/teams/11143/tr/)\n"
16
16
  "Language: tr\n"
17
17
  "Plural-Forms: nplurals=2; plural=(n > 1);\n"
18
+ "Content-Type: text/plain; charset=UTF-8\n"
18
19
 
19
20
  msgctxt "A message that the data is being saved."
20
21
  msgid "Saving changes"
@@ -15,6 +15,7 @@ msgstr ""
15
15
  "Language-Team: Uyghur (https://app.transifex.com/ckeditor/teams/11143/ug/)\n"
16
16
  "Language: ug\n"
17
17
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
18
+ "Content-Type: text/plain; charset=UTF-8\n"
18
19
 
19
20
  msgctxt "A message that the data is being saved."
20
21
  msgid "Saving changes"
@@ -15,6 +15,7 @@ msgstr ""
15
15
  "Language-Team: Ukrainian (https://app.transifex.com/ckeditor/teams/11143/uk/)\n"
16
16
  "Language: uk\n"
17
17
  "Plural-Forms: nplurals=4; plural=(n % 1 == 0 && n % 10 == 1 && n % 100 != 11 ? 0 : n % 1 == 0 && n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 12 || n % 100 > 14) ? 1 : n % 1 == 0 && (n % 10 ==0 || (n % 10 >=5 && n % 10 <=9) || (n % 100 >=11 && n % 100 <=14 )) ? 2: 3);\n"
18
+ "Content-Type: text/plain; charset=UTF-8\n"
18
19
 
19
20
  msgctxt "A message that the data is being saved."
20
21
  msgid "Saving changes"
@@ -15,6 +15,7 @@ msgstr ""
15
15
  "Language-Team: Urdu (https://app.transifex.com/ckeditor/teams/11143/ur/)\n"
16
16
  "Language: ur\n"
17
17
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
18
+ "Content-Type: text/plain; charset=UTF-8\n"
18
19
 
19
20
  msgctxt "A message that the data is being saved."
20
21
  msgid "Saving changes"
@@ -15,6 +15,7 @@ msgstr ""
15
15
  "Language-Team: Uzbek (https://app.transifex.com/ckeditor/teams/11143/uz/)\n"
16
16
  "Language: uz\n"
17
17
  "Plural-Forms: nplurals=1; plural=0;\n"
18
+ "Content-Type: text/plain; charset=UTF-8\n"
18
19
 
19
20
  msgctxt "A message that the data is being saved."
20
21
  msgid "Saving changes"
@@ -15,6 +15,7 @@ msgstr ""
15
15
  "Language-Team: Vietnamese (https://app.transifex.com/ckeditor/teams/11143/vi/)\n"
16
16
  "Language: vi\n"
17
17
  "Plural-Forms: nplurals=1; plural=0;\n"
18
+ "Content-Type: text/plain; charset=UTF-8\n"
18
19
 
19
20
  msgctxt "A message that the data is being saved."
20
21
  msgid "Saving changes"
@@ -15,6 +15,7 @@ msgstr ""
15
15
  "Language-Team: Chinese (China) (https://app.transifex.com/ckeditor/teams/11143/zh_CN/)\n"
16
16
  "Language: zh_CN\n"
17
17
  "Plural-Forms: nplurals=1; plural=0;\n"
18
+ "Content-Type: text/plain; charset=UTF-8\n"
18
19
 
19
20
  msgctxt "A message that the data is being saved."
20
21
  msgid "Saving changes"
@@ -15,6 +15,7 @@ msgstr ""
15
15
  "Language-Team: Chinese (Taiwan) (https://app.transifex.com/ckeditor/teams/11143/zh_TW/)\n"
16
16
  "Language: zh_TW\n"
17
17
  "Plural-Forms: nplurals=1; plural=0;\n"
18
+ "Content-Type: text/plain; charset=UTF-8\n"
18
19
 
19
20
  msgctxt "A message that the data is being saved."
20
21
  msgid "Saving changes"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-autosave",
3
- "version": "39.0.1",
3
+ "version": "40.0.0",
4
4
  "description": "Autosave feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -12,13 +12,9 @@
12
12
  ],
13
13
  "main": "src/index.js",
14
14
  "dependencies": {
15
- "ckeditor5": "39.0.1",
15
+ "ckeditor5": "40.0.0",
16
16
  "lodash-es": "4.17.21"
17
17
  },
18
- "engines": {
19
- "node": ">=16.0.0",
20
- "npm": ">=5.7.1"
21
- },
22
18
  "author": "CKSource (http://cksource.com/)",
23
19
  "license": "GPL-2.0-or-later",
24
20
  "homepage": "https://ckeditor.com/ckeditor-5",
@@ -1,18 +1,18 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- import type { Autosave, AutosaveConfig } from './index';
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
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ import type { Autosave, AutosaveConfig } from './index';
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
+ }
@@ -1,5 +1,5 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- export {};
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ export {};
package/src/autosave.d.ts CHANGED
@@ -1,219 +1,219 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module autosave/autosave
7
- */
8
- import { Plugin, PendingActions, type Editor } from 'ckeditor5/src/core';
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~Document#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( document.querySelector( '#editor' ), {
20
- * plugins: [ ArticlePluginSet, Autosave ],
21
- * toolbar: [ 'heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'blockQuote', 'undo', 'redo' ],
22
- * image: {
23
- * toolbar: [ 'imageStyle:block', 'imageStyle:side', '|', 'toggleImageCaption', 'imageTextAlternative' ],
24
- * },
25
- * autosave: {
26
- * save( editor: Editor ) {
27
- * // The saveData() function must return a promise
28
- * // which should be resolved when the data is successfully saved.
29
- * return saveData( editor.getData() );
30
- * }
31
- * }
32
- * } );
33
- * ```
34
- *
35
- * Read more about this feature in the {@glink features/autosave Autosave} feature guide.
36
- */
37
- export default 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
- */
43
- adapter?: AutosaveAdapter;
44
- /**
45
- * The state of this plugin.
46
- *
47
- * The plugin can be in the following states:
48
- *
49
- * * synchronized &ndash; When all changes are saved.
50
- * * waiting &ndash; When the plugin is waiting for other changes before calling `adapter#save()` and `config.autosave.save()`.
51
- * * saving &ndash; When the provided save method is called and the plugin waits for the response.
52
- * * error &ndash When the provided save method will throw an error. This state immediately changes to the `saving` state and
53
- * the save method will be called again in the short period of time.
54
- *
55
- * @observable
56
- * @readonly
57
- */
58
- state: 'synchronized' | 'waiting' | 'saving' | 'error';
59
- /**
60
- * Debounced save method. The `save()` method is called the specified `waitingTime` after `debouncedSave()` is called,
61
- * unless a new action happens in the meantime.
62
- */
63
- private _debouncedSave;
64
- /**
65
- * The last saved document version.
66
- */
67
- private _lastDocumentVersion;
68
- /**
69
- * Promise used for asynchronous save calls.
70
- *
71
- * Created to handle the autosave call to an external data source. It resolves when that call is finished. It is re-used if
72
- * save is called before the promise has been resolved. It is set to `null` if there is no call in progress.
73
- */
74
- private _savePromise;
75
- /**
76
- * DOM emitter.
77
- */
78
- private _domEmitter;
79
- /**
80
- * The configuration of this plugins.
81
- */
82
- private _config;
83
- /**
84
- * Editor's pending actions manager.
85
- */
86
- private _pendingActions;
87
- /**
88
- * Informs whether there should be another autosave callback performed, immediately after current autosave callback finishes.
89
- *
90
- * This is set to `true` when there is a save request while autosave callback is already being processed
91
- * and the model has changed since the last save.
92
- */
93
- private _makeImmediateSave;
94
- /**
95
- * An action that will be added to the pending action manager for actions happening in that plugin.
96
- */
97
- private _action;
98
- /**
99
- * @inheritDoc
100
- */
101
- static get pluginName(): "Autosave";
102
- /**
103
- * @inheritDoc
104
- */
105
- static get requires(): readonly [typeof PendingActions];
106
- /**
107
- * @inheritDoc
108
- */
109
- constructor(editor: Editor);
110
- /**
111
- * @inheritDoc
112
- */
113
- init(): void;
114
- /**
115
- * @inheritDoc
116
- */
117
- destroy(): void;
118
- /**
119
- * Immediately calls autosave callback. All previously queued (debounced) callbacks are cleared. If there is already an autosave
120
- * callback in progress, then the requested save will be performed immediately after the current callback finishes.
121
- *
122
- * @returns A promise that will be resolved when the autosave callback is finished.
123
- */
124
- save(): Promise<void>;
125
- /**
126
- * Invokes the remaining `_save()` method call.
127
- */
128
- private _flush;
129
- /**
130
- * If the adapter is set and a new document version exists,
131
- * the `_save()` method creates a pending action and calls the `adapter.save()` method.
132
- * It waits for the result and then removes the created pending action.
133
- *
134
- * @returns A promise that will be resolved when the autosave callback is finished.
135
- */
136
- private _save;
137
- /**
138
- * Creates a pending action if it is not set already.
139
- */
140
- private _setPendingAction;
141
- /**
142
- * Saves callbacks.
143
- */
144
- private get _saveCallbacks();
145
- }
146
- /**
147
- * An interface that requires the `save()` method.
148
- *
149
- * Used by {@link module:autosave/autosave~Autosave#adapter}.
150
- */
151
- export interface AutosaveAdapter {
152
- /**
153
- * 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),
154
- * so the autosave plugin will wait for that action before removing it from pending actions.
155
- */
156
- save(editor: Editor): Promise<unknown>;
157
- }
158
- /**
159
- * The configuration of the {@link module:autosave/autosave~Autosave autosave feature}.
160
- *
161
- * ```ts
162
- * ClassicEditor
163
- * .create( editorElement, {
164
- * autosave: {
165
- * save( editor: Editor ) {
166
- * // The saveData() function must return a promise
167
- * // which should be resolved when the data is successfully saved.
168
- * return saveData( editor.getData() );
169
- * }
170
- * }
171
- * } );
172
- * .then( ... )
173
- * .catch( ... );
174
- * ```
175
- *
176
- * See {@link module:core/editor/editorconfig~EditorConfig all editor configuration options}.
177
- *
178
- * See also the demo of the {@glink features/autosave autosave feature}.
179
- */
180
- export interface AutosaveConfig {
181
- /**
182
- * The callback to be executed when the data needs to be saved.
183
- *
184
- * This function must return a promise which should be resolved when the data is successfully saved.
185
- *
186
- * ```ts
187
- * ClassicEditor
188
- * .create( editorElement, {
189
- * autosave: {
190
- * save( editor: Editor ) {
191
- * return saveData( editor.getData() );
192
- * }
193
- * }
194
- * } );
195
- * .then( ... )
196
- * .catch( ... );
197
- * ```
198
- */
199
- save?: (editor: Editor) => Promise<unknown>;
200
- /**
201
- * The minimum amount of time that needs to pass after the last action to call the provided callback.
202
- * By default it is 1000 ms.
203
- *
204
- * ```ts
205
- * ClassicEditor
206
- * .create( editorElement, {
207
- * autosave: {
208
- * save( editor: Editor ) {
209
- * return saveData( editor.getData() );
210
- * },
211
- * waitingTime: 2000
212
- * }
213
- * } );
214
- * .then( ... )
215
- * .catch( ... );
216
- * ```
217
- */
218
- waitingTime?: number;
219
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module autosave/autosave
7
+ */
8
+ import { Plugin, PendingActions, type Editor } from 'ckeditor5/src/core';
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~Document#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( document.querySelector( '#editor' ), {
20
+ * plugins: [ ArticlePluginSet, Autosave ],
21
+ * toolbar: [ 'heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'blockQuote', 'undo', 'redo' ],
22
+ * image: {
23
+ * toolbar: [ 'imageStyle:block', 'imageStyle:side', '|', 'toggleImageCaption', 'imageTextAlternative' ],
24
+ * },
25
+ * autosave: {
26
+ * save( editor: Editor ) {
27
+ * // The saveData() function must return a promise
28
+ * // which should be resolved when the data is successfully saved.
29
+ * return saveData( editor.getData() );
30
+ * }
31
+ * }
32
+ * } );
33
+ * ```
34
+ *
35
+ * Read more about this feature in the {@glink features/autosave Autosave} feature guide.
36
+ */
37
+ export default 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
+ */
43
+ adapter?: AutosaveAdapter;
44
+ /**
45
+ * The state of this plugin.
46
+ *
47
+ * The plugin can be in the following states:
48
+ *
49
+ * * synchronized &ndash; When all changes are saved.
50
+ * * waiting &ndash; When the plugin is waiting for other changes before calling `adapter#save()` and `config.autosave.save()`.
51
+ * * saving &ndash; When the provided save method is called and the plugin waits for the response.
52
+ * * error &ndash When the provided save method will throw an error. This state immediately changes to the `saving` state and
53
+ * the save method will be called again in the short period of time.
54
+ *
55
+ * @observable
56
+ * @readonly
57
+ */
58
+ state: 'synchronized' | 'waiting' | 'saving' | 'error';
59
+ /**
60
+ * Debounced save method. The `save()` method is called the specified `waitingTime` after `debouncedSave()` is called,
61
+ * unless a new action happens in the meantime.
62
+ */
63
+ private _debouncedSave;
64
+ /**
65
+ * The last saved document version.
66
+ */
67
+ private _lastDocumentVersion;
68
+ /**
69
+ * Promise used for asynchronous save calls.
70
+ *
71
+ * Created to handle the autosave call to an external data source. It resolves when that call is finished. It is re-used if
72
+ * save is called before the promise has been resolved. It is set to `null` if there is no call in progress.
73
+ */
74
+ private _savePromise;
75
+ /**
76
+ * DOM emitter.
77
+ */
78
+ private _domEmitter;
79
+ /**
80
+ * The configuration of this plugins.
81
+ */
82
+ private _config;
83
+ /**
84
+ * Editor's pending actions manager.
85
+ */
86
+ private _pendingActions;
87
+ /**
88
+ * Informs whether there should be another autosave callback performed, immediately after current autosave callback finishes.
89
+ *
90
+ * This is set to `true` when there is a save request while autosave callback is already being processed
91
+ * and the model has changed since the last save.
92
+ */
93
+ private _makeImmediateSave;
94
+ /**
95
+ * An action that will be added to the pending action manager for actions happening in that plugin.
96
+ */
97
+ private _action;
98
+ /**
99
+ * @inheritDoc
100
+ */
101
+ static get pluginName(): "Autosave";
102
+ /**
103
+ * @inheritDoc
104
+ */
105
+ static get requires(): readonly [typeof PendingActions];
106
+ /**
107
+ * @inheritDoc
108
+ */
109
+ constructor(editor: Editor);
110
+ /**
111
+ * @inheritDoc
112
+ */
113
+ init(): void;
114
+ /**
115
+ * @inheritDoc
116
+ */
117
+ destroy(): void;
118
+ /**
119
+ * Immediately calls autosave callback. All previously queued (debounced) callbacks are cleared. If there is already an autosave
120
+ * callback in progress, then the requested save will be performed immediately after the current callback finishes.
121
+ *
122
+ * @returns A promise that will be resolved when the autosave callback is finished.
123
+ */
124
+ save(): Promise<void>;
125
+ /**
126
+ * Invokes the remaining `_save()` method call.
127
+ */
128
+ private _flush;
129
+ /**
130
+ * If the adapter is set and a new document version exists,
131
+ * the `_save()` method creates a pending action and calls the `adapter.save()` method.
132
+ * It waits for the result and then removes the created pending action.
133
+ *
134
+ * @returns A promise that will be resolved when the autosave callback is finished.
135
+ */
136
+ private _save;
137
+ /**
138
+ * Creates a pending action if it is not set already.
139
+ */
140
+ private _setPendingAction;
141
+ /**
142
+ * Saves callbacks.
143
+ */
144
+ private get _saveCallbacks();
145
+ }
146
+ /**
147
+ * An interface that requires the `save()` method.
148
+ *
149
+ * Used by {@link module:autosave/autosave~Autosave#adapter}.
150
+ */
151
+ export interface AutosaveAdapter {
152
+ /**
153
+ * 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),
154
+ * so the autosave plugin will wait for that action before removing it from pending actions.
155
+ */
156
+ save(editor: Editor): Promise<unknown>;
157
+ }
158
+ /**
159
+ * The configuration of the {@link module:autosave/autosave~Autosave autosave feature}.
160
+ *
161
+ * ```ts
162
+ * ClassicEditor
163
+ * .create( editorElement, {
164
+ * autosave: {
165
+ * save( editor: Editor ) {
166
+ * // The saveData() function must return a promise
167
+ * // which should be resolved when the data is successfully saved.
168
+ * return saveData( editor.getData() );
169
+ * }
170
+ * }
171
+ * } );
172
+ * .then( ... )
173
+ * .catch( ... );
174
+ * ```
175
+ *
176
+ * See {@link module:core/editor/editorconfig~EditorConfig all editor configuration options}.
177
+ *
178
+ * See also the demo of the {@glink features/autosave autosave feature}.
179
+ */
180
+ export interface AutosaveConfig {
181
+ /**
182
+ * The callback to be executed when the data needs to be saved.
183
+ *
184
+ * This function must return a promise which should be resolved when the data is successfully saved.
185
+ *
186
+ * ```ts
187
+ * ClassicEditor
188
+ * .create( editorElement, {
189
+ * autosave: {
190
+ * save( editor: Editor ) {
191
+ * return saveData( editor.getData() );
192
+ * }
193
+ * }
194
+ * } );
195
+ * .then( ... )
196
+ * .catch( ... );
197
+ * ```
198
+ */
199
+ save?: (editor: Editor) => Promise<unknown>;
200
+ /**
201
+ * The minimum amount of time that needs to pass after the last action to call the provided callback.
202
+ * By default it is 1000 ms.
203
+ *
204
+ * ```ts
205
+ * ClassicEditor
206
+ * .create( editorElement, {
207
+ * autosave: {
208
+ * save( editor: Editor ) {
209
+ * return saveData( editor.getData() );
210
+ * },
211
+ * waitingTime: 2000
212
+ * }
213
+ * } );
214
+ * .then( ... )
215
+ * .catch( ... );
216
+ * ```
217
+ */
218
+ waitingTime?: number;
219
+ }