@ckeditor/ckeditor5-upload 0.0.0-internal-20241017.0 → 0.0.0-internal-20241206.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.
Files changed (192) hide show
  1. package/LICENSE.md +7 -2
  2. package/README.md +17 -6
  3. package/dist/index.js +208 -238
  4. package/dist/index.js.map +1 -1
  5. package/dist/translations/af.d.ts +8 -0
  6. package/dist/translations/af.js +5 -0
  7. package/dist/translations/af.umd.js +11 -0
  8. package/dist/translations/ar.js +1 -1
  9. package/dist/translations/ar.umd.js +1 -1
  10. package/dist/translations/ast.d.ts +8 -0
  11. package/dist/translations/ast.js +5 -0
  12. package/dist/translations/ast.umd.js +11 -0
  13. package/dist/translations/bs.d.ts +8 -0
  14. package/dist/translations/bs.js +5 -0
  15. package/dist/translations/bs.umd.js +11 -0
  16. package/dist/translations/cs.js +1 -1
  17. package/dist/translations/cs.umd.js +1 -1
  18. package/dist/translations/en.js +1 -1
  19. package/dist/translations/en.umd.js +1 -1
  20. package/dist/translations/eo.d.ts +8 -0
  21. package/dist/translations/eo.js +5 -0
  22. package/dist/translations/eo.umd.js +11 -0
  23. package/dist/translations/es-co.js +1 -1
  24. package/dist/translations/es-co.umd.js +1 -1
  25. package/dist/translations/es.js +1 -1
  26. package/dist/translations/es.umd.js +1 -1
  27. package/dist/translations/eu.d.ts +8 -0
  28. package/dist/translations/eu.js +5 -0
  29. package/dist/translations/eu.umd.js +11 -0
  30. package/dist/translations/fa.js +1 -1
  31. package/dist/translations/fa.umd.js +1 -1
  32. package/dist/translations/fr.js +1 -1
  33. package/dist/translations/fr.umd.js +1 -1
  34. package/dist/translations/gu.d.ts +8 -0
  35. package/dist/translations/gu.js +5 -0
  36. package/dist/translations/gu.umd.js +11 -0
  37. package/dist/translations/he.js +1 -1
  38. package/dist/translations/he.umd.js +1 -1
  39. package/dist/translations/hr.js +1 -1
  40. package/dist/translations/hr.umd.js +1 -1
  41. package/dist/translations/hy.d.ts +8 -0
  42. package/dist/translations/hy.js +5 -0
  43. package/dist/translations/hy.umd.js +11 -0
  44. package/dist/translations/it.js +1 -1
  45. package/dist/translations/it.umd.js +1 -1
  46. package/dist/translations/jv.d.ts +8 -0
  47. package/dist/translations/jv.js +5 -0
  48. package/dist/translations/jv.umd.js +11 -0
  49. package/dist/translations/kk.d.ts +8 -0
  50. package/dist/translations/kk.js +5 -0
  51. package/dist/translations/kk.umd.js +11 -0
  52. package/dist/translations/km.d.ts +8 -0
  53. package/dist/translations/km.js +5 -0
  54. package/dist/translations/km.umd.js +11 -0
  55. package/dist/translations/kn.d.ts +8 -0
  56. package/dist/translations/kn.js +5 -0
  57. package/dist/translations/kn.umd.js +11 -0
  58. package/dist/translations/lt.js +1 -1
  59. package/dist/translations/lt.umd.js +1 -1
  60. package/dist/translations/lv.js +1 -1
  61. package/dist/translations/lv.umd.js +1 -1
  62. package/dist/translations/oc.d.ts +8 -0
  63. package/dist/translations/oc.js +5 -0
  64. package/dist/translations/oc.umd.js +11 -0
  65. package/dist/translations/pl.js +1 -1
  66. package/dist/translations/pl.umd.js +1 -1
  67. package/dist/translations/pt-br.js +1 -1
  68. package/dist/translations/pt-br.umd.js +1 -1
  69. package/dist/translations/pt.js +1 -1
  70. package/dist/translations/pt.umd.js +1 -1
  71. package/dist/translations/ro.js +1 -1
  72. package/dist/translations/ro.umd.js +1 -1
  73. package/dist/translations/ru.js +1 -1
  74. package/dist/translations/ru.umd.js +1 -1
  75. package/dist/translations/si.d.ts +8 -0
  76. package/dist/translations/si.js +5 -0
  77. package/dist/translations/si.umd.js +11 -0
  78. package/dist/translations/sk.js +1 -1
  79. package/dist/translations/sk.umd.js +1 -1
  80. package/dist/translations/sl.d.ts +8 -0
  81. package/dist/translations/sl.js +5 -0
  82. package/dist/translations/sl.umd.js +11 -0
  83. package/dist/translations/sr-latn.js +1 -1
  84. package/dist/translations/sr-latn.umd.js +1 -1
  85. package/dist/translations/sr.js +1 -1
  86. package/dist/translations/sr.umd.js +1 -1
  87. package/dist/translations/ti.d.ts +8 -0
  88. package/dist/translations/ti.js +5 -0
  89. package/dist/translations/ti.umd.js +11 -0
  90. package/dist/translations/tt.d.ts +8 -0
  91. package/dist/translations/tt.js +5 -0
  92. package/dist/translations/tt.umd.js +11 -0
  93. package/dist/translations/ug.js +1 -1
  94. package/dist/translations/ug.umd.js +1 -1
  95. package/dist/translations/uk.js +1 -1
  96. package/dist/translations/uk.umd.js +1 -1
  97. package/dist/translations/uz.js +1 -1
  98. package/dist/translations/uz.umd.js +1 -1
  99. package/lang/translations/af.po +16 -0
  100. package/lang/translations/ar.po +4 -10
  101. package/lang/translations/ast.po +16 -0
  102. package/lang/translations/az.po +3 -9
  103. package/lang/translations/bg.po +3 -9
  104. package/lang/translations/bn.po +3 -9
  105. package/lang/translations/bs.po +16 -0
  106. package/lang/translations/ca.po +3 -9
  107. package/lang/translations/cs.po +4 -10
  108. package/lang/translations/da.po +3 -9
  109. package/lang/translations/de-ch.po +3 -9
  110. package/lang/translations/de.po +3 -9
  111. package/lang/translations/el.po +3 -9
  112. package/lang/translations/en-au.po +3 -9
  113. package/lang/translations/en-gb.po +3 -9
  114. package/lang/translations/en.po +5 -11
  115. package/lang/translations/eo.po +16 -0
  116. package/lang/translations/es-co.po +4 -10
  117. package/lang/translations/es.po +4 -10
  118. package/lang/translations/et.po +3 -9
  119. package/lang/translations/eu.po +16 -0
  120. package/lang/translations/fa.po +4 -10
  121. package/lang/translations/fi.po +3 -9
  122. package/lang/translations/fr.po +4 -10
  123. package/lang/translations/gl.po +3 -9
  124. package/lang/translations/gu.po +16 -0
  125. package/lang/translations/he.po +4 -10
  126. package/lang/translations/hi.po +3 -9
  127. package/lang/translations/hr.po +4 -10
  128. package/lang/translations/hu.po +3 -9
  129. package/lang/translations/hy.po +16 -0
  130. package/lang/translations/id.po +3 -9
  131. package/lang/translations/it.po +4 -10
  132. package/lang/translations/ja.po +3 -9
  133. package/lang/translations/jv.po +16 -0
  134. package/lang/translations/kk.po +16 -0
  135. package/lang/translations/km.po +16 -0
  136. package/lang/translations/kn.po +16 -0
  137. package/lang/translations/ko.po +3 -9
  138. package/lang/translations/ku.po +3 -9
  139. package/lang/translations/lt.po +4 -10
  140. package/lang/translations/lv.po +4 -10
  141. package/lang/translations/ms.po +3 -9
  142. package/lang/translations/nb.po +3 -9
  143. package/lang/translations/ne.po +3 -9
  144. package/lang/translations/nl.po +3 -9
  145. package/lang/translations/no.po +3 -9
  146. package/lang/translations/oc.po +16 -0
  147. package/lang/translations/pl.po +4 -10
  148. package/lang/translations/pt-br.po +4 -10
  149. package/lang/translations/pt.po +4 -10
  150. package/lang/translations/ro.po +4 -10
  151. package/lang/translations/ru.po +4 -10
  152. package/lang/translations/si.po +16 -0
  153. package/lang/translations/sk.po +4 -10
  154. package/lang/translations/sl.po +16 -0
  155. package/lang/translations/sq.po +3 -9
  156. package/lang/translations/sr-latn.po +4 -10
  157. package/lang/translations/sr.po +4 -10
  158. package/lang/translations/sv.po +3 -9
  159. package/lang/translations/th.po +3 -9
  160. package/lang/translations/ti.po +16 -0
  161. package/lang/translations/tk.po +3 -9
  162. package/lang/translations/tr.po +3 -9
  163. package/lang/translations/tt.po +16 -0
  164. package/lang/translations/ug.po +4 -10
  165. package/lang/translations/uk.po +4 -10
  166. package/lang/translations/ur.po +3 -9
  167. package/lang/translations/uz.po +4 -10
  168. package/lang/translations/vi.po +3 -9
  169. package/lang/translations/zh-cn.po +3 -9
  170. package/lang/translations/zh.po +3 -9
  171. package/package.json +22 -5
  172. package/src/adapters/base64uploadadapter.d.ts +1 -1
  173. package/src/adapters/base64uploadadapter.js +1 -1
  174. package/src/adapters/simpleuploadadapter.d.ts +1 -1
  175. package/src/adapters/simpleuploadadapter.js +1 -1
  176. package/src/augmentation.d.ts +1 -1
  177. package/src/augmentation.js +1 -1
  178. package/src/filereader.d.ts +1 -1
  179. package/src/filereader.js +1 -1
  180. package/src/filerepository.d.ts +1 -1
  181. package/src/filerepository.js +1 -1
  182. package/src/index.d.ts +1 -1
  183. package/src/index.js +1 -1
  184. package/src/uploadconfig.d.ts +1 -1
  185. package/src/uploadconfig.js +1 -1
  186. package/dist/adapters/base64uploadadapter.d.ts +0 -41
  187. package/dist/adapters/simpleuploadadapter.d.ts +0 -56
  188. package/dist/augmentation.d.ts +0 -24
  189. package/dist/filereader.d.ts +0 -60
  190. package/dist/filerepository.d.ts +0 -350
  191. package/dist/index.d.ts +0 -16
  192. package/dist/uploadconfig.d.ts +0 -94
package/dist/index.js CHANGED
@@ -8,17 +8,9 @@ import { ObservableMixin, Collection, logWarning, uid, CKEditorError } from '@ck
8
8
  /**
9
9
  * Wrapper over the native `FileReader`.
10
10
  */ class FileReader extends /* #__PURE__ */ ObservableMixin() {
11
- total;
12
11
  /**
13
- * Instance of native FileReader.
14
- */ _reader;
15
- /**
16
- * Holds the data of an already loaded file. The file must be first loaded
17
- * by using {@link module:upload/filereader~FileReader#read `read()`}.
18
- */ _data;
19
- /**
20
- * Creates an instance of the FileReader.
21
- */ constructor(){
12
+ * Creates an instance of the FileReader.
13
+ */ constructor(){
22
14
  super();
23
15
  const reader = new window.FileReader();
24
16
  this._reader = reader;
@@ -29,23 +21,23 @@ import { ObservableMixin, Collection, logWarning, uid, CKEditorError } from '@ck
29
21
  };
30
22
  }
31
23
  /**
32
- * Returns error that occurred during file reading.
33
- */ get error() {
24
+ * Returns error that occurred during file reading.
25
+ */ get error() {
34
26
  return this._reader.error;
35
27
  }
36
28
  /**
37
- * Holds the data of an already loaded file. The file must be first loaded
38
- * by using {@link module:upload/filereader~FileReader#read `read()`}.
39
- */ get data() {
29
+ * Holds the data of an already loaded file. The file must be first loaded
30
+ * by using {@link module:upload/filereader~FileReader#read `read()`}.
31
+ */ get data() {
40
32
  return this._data;
41
33
  }
42
34
  /**
43
- * Reads the provided file.
44
- *
45
- * @param file Native File object.
46
- * @returns Returns a promise that will be resolved with file's content.
47
- * The promise will be rejected in case of an error or when the reading process is aborted.
48
- */ read(file) {
35
+ * Reads the provided file.
36
+ *
37
+ * @param file Native File object.
38
+ * @returns Returns a promise that will be resolved with file's content.
39
+ * The promise will be rejected in case of an error or when the reading process is aborted.
40
+ */ read(file) {
49
41
  const reader = this._reader;
50
42
  this.total = file.size;
51
43
  return new Promise((resolve, reject)=>{
@@ -64,8 +56,8 @@ import { ObservableMixin, Collection, logWarning, uid, CKEditorError } from '@ck
64
56
  });
65
57
  }
66
58
  /**
67
- * Aborts file reader.
68
- */ abort() {
59
+ * Aborts file reader.
60
+ */ abort() {
69
61
  this._reader.abort();
70
62
  }
71
63
  }
@@ -82,36 +74,39 @@ import { ObservableMixin, Collection, logWarning, uid, CKEditorError } from '@ck
82
74
  * Then, you can use {@link module:upload/filerepository~FileRepository#createLoader `createLoader()`} and the returned
83
75
  * {@link module:upload/filerepository~FileLoader} instance to load and upload files.
84
76
  */ class FileRepository extends Plugin {
85
- /**
86
- * Collection of loaders associated with this repository.
87
- */ loaders = new Collection();
88
- /**
89
- * Loaders mappings used to retrieve loaders references.
90
- */ _loadersMap = new Map();
91
- /**
92
- * Reference to a pending action registered in a {@link module:core/pendingactions~PendingActions} plugin
93
- * while upload is in progress. When there is no upload then value is `null`.
94
- */ _pendingAction = null;
95
- /**
96
- * @inheritDoc
97
- */ static get pluginName() {
77
+ constructor(){
78
+ super(...arguments);
79
+ /**
80
+ * Collection of loaders associated with this repository.
81
+ */ this.loaders = new Collection();
82
+ /**
83
+ * Loaders mappings used to retrieve loaders references.
84
+ */ this._loadersMap = new Map();
85
+ /**
86
+ * Reference to a pending action registered in a {@link module:core/pendingactions~PendingActions} plugin
87
+ * while upload is in progress. When there is no upload then value is `null`.
88
+ */ this._pendingAction = null;
89
+ }
90
+ /**
91
+ * @inheritDoc
92
+ */ static get pluginName() {
98
93
  return 'FileRepository';
99
94
  }
100
95
  /**
101
- * @inheritDoc
102
- */ static get isOfficialPlugin() {
96
+ * @inheritDoc
97
+ */ static get isOfficialPlugin() {
103
98
  return true;
104
99
  }
105
100
  /**
106
- * @inheritDoc
107
- */ static get requires() {
101
+ * @inheritDoc
102
+ */ static get requires() {
108
103
  return [
109
104
  PendingActions
110
105
  ];
111
106
  }
112
107
  /**
113
- * @inheritDoc
114
- */ init() {
108
+ * @inheritDoc
109
+ */ init() {
115
110
  // Keeps upload in a sync with pending actions.
116
111
  this.loaders.on('change', ()=>this._updatePendingAction());
117
112
  this.set('uploaded', 0);
@@ -121,48 +116,48 @@ import { ObservableMixin, Collection, logWarning, uid, CKEditorError } from '@ck
121
116
  });
122
117
  }
123
118
  /**
124
- * Returns the loader associated with specified file or promise.
125
- *
126
- * To get loader by id use `fileRepository.loaders.get( id )`.
127
- *
128
- * @param fileOrPromise Native file or promise handle.
129
- */ getLoader(fileOrPromise) {
119
+ * Returns the loader associated with specified file or promise.
120
+ *
121
+ * To get loader by id use `fileRepository.loaders.get( id )`.
122
+ *
123
+ * @param fileOrPromise Native file or promise handle.
124
+ */ getLoader(fileOrPromise) {
130
125
  return this._loadersMap.get(fileOrPromise) || null;
131
126
  }
132
127
  /**
133
- * Creates a loader instance for the given file.
134
- *
135
- * Requires {@link #createUploadAdapter} factory to be defined.
136
- *
137
- * @param fileOrPromise Native File object or native Promise object which resolves to a File.
138
- */ createLoader(fileOrPromise) {
128
+ * Creates a loader instance for the given file.
129
+ *
130
+ * Requires {@link #createUploadAdapter} factory to be defined.
131
+ *
132
+ * @param fileOrPromise Native File object or native Promise object which resolves to a File.
133
+ */ createLoader(fileOrPromise) {
139
134
  if (!this.createUploadAdapter) {
140
135
  /**
141
- * You need to enable an upload adapter in order to be able to upload files.
142
- *
143
- * This warning shows up when {@link module:upload/filerepository~FileRepository} is being used
144
- * without {@link module:upload/filerepository~FileRepository#createUploadAdapter defining an upload adapter}.
145
- *
146
- * **If you see this warning when using one of the {@glink getting-started/legacy/installation-methods/predefined-builds
147
- * CKEditor 5 Builds}**
148
- * it means that you did not configure any of the upload adapters available by default in those builds.
149
- *
150
- * Predefined builds are a deprecated solution and we strongly advise
151
- * {@glink updating/nim-migration/migration-to-new-installation-methods migrating to new installation methods}.
152
- *
153
- * See the {@glink features/images/image-upload/image-upload comprehensive "Image upload overview"} to learn which upload
154
- * adapters are available in the builds and how to configure them.
155
- *
156
- * Otherwise, if you see this warning, there is a chance that you enabled
157
- * a feature like {@link module:image/imageupload~ImageUpload},
158
- * or {@link module:image/imageupload/imageuploadui~ImageUploadUI} but you did not enable any upload adapter.
159
- * You can choose one of the existing upload adapters listed in the
160
- * {@glink features/images/image-upload/image-upload "Image upload overview"}.
161
- *
162
- * You can also implement your {@glink framework/deep-dive/upload-adapter own image upload adapter}.
163
- *
164
- * @error filerepository-no-upload-adapter
165
- */ logWarning('filerepository-no-upload-adapter');
136
+ * You need to enable an upload adapter in order to be able to upload files.
137
+ *
138
+ * This warning shows up when {@link module:upload/filerepository~FileRepository} is being used
139
+ * without {@link module:upload/filerepository~FileRepository#createUploadAdapter defining an upload adapter}.
140
+ *
141
+ * **If you see this warning when using one of the {@glink getting-started/legacy/installation-methods/predefined-builds
142
+ * CKEditor 5 Builds}**
143
+ * it means that you did not configure any of the upload adapters available by default in those builds.
144
+ *
145
+ * Predefined builds are a deprecated solution and we strongly advise
146
+ * {@glink updating/nim-migration/migration-to-new-installation-methods migrating to new installation methods}.
147
+ *
148
+ * See the {@glink features/images/image-upload/image-upload comprehensive "Image upload overview"} to learn which upload
149
+ * adapters are available in the builds and how to configure them.
150
+ *
151
+ * Otherwise, if you see this warning, there is a chance that you enabled
152
+ * a feature like {@link module:image/imageupload~ImageUpload},
153
+ * or {@link module:image/imageupload/imageuploadui~ImageUploadUI} but you did not enable any upload adapter.
154
+ * You can choose one of the existing upload adapters listed in the
155
+ * {@glink features/images/image-upload/image-upload "Image upload overview"}.
156
+ *
157
+ * You can also implement your {@glink framework/deep-dive/upload-adapter own image upload adapter}.
158
+ *
159
+ * @error filerepository-no-upload-adapter
160
+ */ logWarning('filerepository-no-upload-adapter');
166
161
  return null;
167
162
  }
168
163
  const loader = new FileLoader(Promise.resolve(fileOrPromise), this.createUploadAdapter);
@@ -196,10 +191,10 @@ import { ObservableMixin, Collection, logWarning, uid, CKEditorError } from '@ck
196
191
  return loader;
197
192
  }
198
193
  /**
199
- * Destroys the given loader.
200
- *
201
- * @param fileOrPromiseOrLoader File or Promise associated with that loader or loader itself.
202
- */ destroyLoader(fileOrPromiseOrLoader) {
194
+ * Destroys the given loader.
195
+ *
196
+ * @param fileOrPromiseOrLoader File or Promise associated with that loader or loader itself.
197
+ */ destroyLoader(fileOrPromiseOrLoader) {
203
198
  const loader = fileOrPromiseOrLoader instanceof FileLoader ? fileOrPromiseOrLoader : this.getLoader(fileOrPromiseOrLoader);
204
199
  loader._destroy();
205
200
  this.loaders.remove(loader);
@@ -210,8 +205,8 @@ import { ObservableMixin, Collection, logWarning, uid, CKEditorError } from '@ck
210
205
  });
211
206
  }
212
207
  /**
213
- * Registers or deregisters pending action bound with upload progress.
214
- */ _updatePendingAction() {
208
+ * Registers or deregisters pending action bound with upload progress.
209
+ */ _updatePendingAction() {
215
210
  const pendingActions = this.editor.plugins.get(PendingActions);
216
211
  if (this.loaders.length) {
217
212
  if (!this._pendingAction) {
@@ -232,25 +227,11 @@ import { ObservableMixin, Collection, logWarning, uid, CKEditorError } from '@ck
232
227
  * It is used to control the process of reading the file and uploading it using the specified upload adapter.
233
228
  */ class FileLoader extends /* #__PURE__ */ ObservableMixin() {
234
229
  /**
235
- * Unique id of FileLoader instance.
236
- *
237
- * @readonly
238
- */ id;
239
- /**
240
- * Additional wrapper over the initial file promise passed to this loader.
241
- */ _filePromiseWrapper;
242
- /**
243
- * Adapter instance associated with this file loader.
244
- */ _adapter;
245
- /**
246
- * FileReader used by FileLoader.
247
- */ _reader;
248
- /**
249
- * Creates a new instance of `FileLoader`.
250
- *
251
- * @param filePromise A promise which resolves to a file instance.
252
- * @param uploadAdapterCreator The function which returns {@link module:upload/filerepository~UploadAdapter} instance.
253
- */ constructor(filePromise, uploadAdapterCreator){
230
+ * Creates a new instance of `FileLoader`.
231
+ *
232
+ * @param filePromise A promise which resolves to a file instance.
233
+ * @param uploadAdapterCreator The function which returns {@link module:upload/filerepository~UploadAdapter} instance.
234
+ */ constructor(filePromise, uploadAdapterCreator){
254
235
  super();
255
236
  this.id = uid();
256
237
  this._filePromiseWrapper = this._createFilePromiseWrapper(filePromise);
@@ -265,8 +246,8 @@ import { ObservableMixin, Collection, logWarning, uid, CKEditorError } from '@ck
265
246
  this.set('uploadResponse', null);
266
247
  }
267
248
  /**
268
- * A `Promise` which resolves to a `File` instance associated with this file loader.
269
- */ get file() {
249
+ * A `Promise` which resolves to a `File` instance associated with this file loader.
250
+ */ get file() {
270
251
  if (!this._filePromiseWrapper) {
271
252
  // Loader was destroyed, return promise which resolves to null.
272
253
  return Promise.resolve(null);
@@ -283,40 +264,40 @@ import { ObservableMixin, Collection, logWarning, uid, CKEditorError } from '@ck
283
264
  }
284
265
  }
285
266
  /**
286
- * Returns the file data. To read its data, you need for first load the file
287
- * by using the {@link module:upload/filerepository~FileLoader#read `read()`} method.
288
- */ get data() {
267
+ * Returns the file data. To read its data, you need for first load the file
268
+ * by using the {@link module:upload/filerepository~FileLoader#read `read()`} method.
269
+ */ get data() {
289
270
  return this._reader.data;
290
271
  }
291
272
  /**
292
- * Reads file using {@link module:upload/filereader~FileReader}.
293
- *
294
- * Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `filerepository-read-wrong-status` when status
295
- * is different than `idle`.
296
- *
297
- * Example usage:
298
- *
299
- * ```ts
300
- * fileLoader.read()
301
- * .then( data => { ... } )
302
- * .catch( err => {
303
- * if ( err === 'aborted' ) {
304
- * console.log( 'Reading aborted.' );
305
- * } else {
306
- * console.log( 'Reading error.', err );
307
- * }
308
- * } );
309
- * ```
310
- *
311
- * @returns Returns promise that will be resolved with read data. Promise will be rejected if error
312
- * occurs or if read process is aborted.
313
- */ read() {
273
+ * Reads file using {@link module:upload/filereader~FileReader}.
274
+ *
275
+ * Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `filerepository-read-wrong-status` when status
276
+ * is different than `idle`.
277
+ *
278
+ * Example usage:
279
+ *
280
+ * ```ts
281
+ * fileLoader.read()
282
+ * .then( data => { ... } )
283
+ * .catch( err => {
284
+ * if ( err === 'aborted' ) {
285
+ * console.log( 'Reading aborted.' );
286
+ * } else {
287
+ * console.log( 'Reading error.', err );
288
+ * }
289
+ * } );
290
+ * ```
291
+ *
292
+ * @returns Returns promise that will be resolved with read data. Promise will be rejected if error
293
+ * occurs or if read process is aborted.
294
+ */ read() {
314
295
  if (this.status != 'idle') {
315
296
  /**
316
- * You cannot call read if the status is different than idle.
317
- *
318
- * @error filerepository-read-wrong-status
319
- */ throw new CKEditorError('filerepository-read-wrong-status', this);
297
+ * You cannot call read if the status is different than idle.
298
+ *
299
+ * @error filerepository-read-wrong-status
300
+ */ throw new CKEditorError('filerepository-read-wrong-status', this);
320
301
  }
321
302
  this.status = 'reading';
322
303
  return this.file.then((file)=>this._reader.read(file)).then((data)=>{
@@ -337,33 +318,33 @@ import { ObservableMixin, Collection, logWarning, uid, CKEditorError } from '@ck
337
318
  });
338
319
  }
339
320
  /**
340
- * Reads file using the provided {@link module:upload/filerepository~UploadAdapter}.
341
- *
342
- * Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `filerepository-upload-wrong-status` when status
343
- * is different than `idle`.
344
- * Example usage:
345
- *
346
- * ```ts
347
- * fileLoader.upload()
348
- * .then( data => { ... } )
349
- * .catch( e => {
350
- * if ( e === 'aborted' ) {
351
- * console.log( 'Uploading aborted.' );
352
- * } else {
353
- * console.log( 'Uploading error.', e );
354
- * }
355
- * } );
356
- * ```
357
- *
358
- * @returns Returns promise that will be resolved with response data. Promise will be rejected if error
359
- * occurs or if read process is aborted.
360
- */ upload() {
321
+ * Reads file using the provided {@link module:upload/filerepository~UploadAdapter}.
322
+ *
323
+ * Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `filerepository-upload-wrong-status` when status
324
+ * is different than `idle`.
325
+ * Example usage:
326
+ *
327
+ * ```ts
328
+ * fileLoader.upload()
329
+ * .then( data => { ... } )
330
+ * .catch( e => {
331
+ * if ( e === 'aborted' ) {
332
+ * console.log( 'Uploading aborted.' );
333
+ * } else {
334
+ * console.log( 'Uploading error.', e );
335
+ * }
336
+ * } );
337
+ * ```
338
+ *
339
+ * @returns Returns promise that will be resolved with response data. Promise will be rejected if error
340
+ * occurs or if read process is aborted.
341
+ */ upload() {
361
342
  if (this.status != 'idle') {
362
343
  /**
363
- * You cannot call upload if the status is different than idle.
364
- *
365
- * @error filerepository-upload-wrong-status
366
- */ throw new CKEditorError('filerepository-upload-wrong-status', this);
344
+ * You cannot call upload if the status is different than idle.
345
+ *
346
+ * @error filerepository-upload-wrong-status
347
+ */ throw new CKEditorError('filerepository-upload-wrong-status', this);
367
348
  }
368
349
  this.status = 'uploading';
369
350
  return this.file.then(()=>this._adapter.upload()).then((data)=>{
@@ -379,8 +360,8 @@ import { ObservableMixin, Collection, logWarning, uid, CKEditorError } from '@ck
379
360
  });
380
361
  }
381
362
  /**
382
- * Aborts loading process.
383
- */ abort() {
363
+ * Aborts loading process.
364
+ */ abort() {
384
365
  const status = this.status;
385
366
  this.status = 'aborted';
386
367
  if (!this._filePromiseWrapper.isFulfilled) {
@@ -397,21 +378,21 @@ import { ObservableMixin, Collection, logWarning, uid, CKEditorError } from '@ck
397
378
  this._destroy();
398
379
  }
399
380
  /**
400
- * Performs cleanup.
401
- *
402
- * @internal
403
- */ _destroy() {
381
+ * Performs cleanup.
382
+ *
383
+ * @internal
384
+ */ _destroy() {
404
385
  this._filePromiseWrapper = undefined;
405
386
  this._reader = undefined;
406
387
  this._adapter = undefined;
407
388
  this.uploadResponse = undefined;
408
389
  }
409
390
  /**
410
- * Wraps a given file promise into another promise giving additional
411
- * control (resolving, rejecting, checking if fulfilled) over it.
412
- *
413
- * @param filePromise The initial file promise to be wrapped.
414
- */ _createFilePromiseWrapper(filePromise) {
391
+ * Wraps a given file promise into another promise giving additional
392
+ * control (resolving, rejecting, checking if fulfilled) over it.
393
+ *
394
+ * @param filePromise The initial file promise to be wrapped.
395
+ */ _createFilePromiseWrapper(filePromise) {
415
396
  const wrapper = {};
416
397
  wrapper.promise = new Promise((resolve, reject)=>{
417
398
  wrapper.rejecter = reject;
@@ -439,25 +420,25 @@ import { ObservableMixin, Collection, logWarning, uid, CKEditorError } from '@ck
439
420
  * other ways to upload images into CKEditor 5.
440
421
  */ class Base64UploadAdapter extends Plugin {
441
422
  /**
442
- * @inheritDoc
443
- */ static get requires() {
423
+ * @inheritDoc
424
+ */ static get requires() {
444
425
  return [
445
426
  FileRepository
446
427
  ];
447
428
  }
448
429
  /**
449
- * @inheritDoc
450
- */ static get pluginName() {
430
+ * @inheritDoc
431
+ */ static get pluginName() {
451
432
  return 'Base64UploadAdapter';
452
433
  }
453
434
  /**
454
- * @inheritDoc
455
- */ static get isOfficialPlugin() {
435
+ * @inheritDoc
436
+ */ static get isOfficialPlugin() {
456
437
  return true;
457
438
  }
458
439
  /**
459
- * @inheritDoc
460
- */ init() {
440
+ * @inheritDoc
441
+ */ init() {
461
442
  this.editor.plugins.get(FileRepository).createUploadAdapter = (loader)=>new Adapter$1(loader);
462
443
  }
463
444
  }
@@ -465,19 +446,15 @@ import { ObservableMixin, Collection, logWarning, uid, CKEditorError } from '@ck
465
446
  * The upload adapter that converts images inserted into the editor into Base64 strings.
466
447
  */ let Adapter$1 = class Adapter {
467
448
  /**
468
- * `FileLoader` instance to use during the upload.
469
- */ loader;
470
- reader;
471
- /**
472
- * Creates a new adapter instance.
473
- */ constructor(loader){
449
+ * Creates a new adapter instance.
450
+ */ constructor(loader){
474
451
  this.loader = loader;
475
452
  }
476
453
  /**
477
- * Starts the upload process.
478
- *
479
- * @see module:upload/filerepository~UploadAdapter#upload
480
- */ upload() {
454
+ * Starts the upload process.
455
+ *
456
+ * @see module:upload/filerepository~UploadAdapter#upload
457
+ */ upload() {
481
458
  return new Promise((resolve, reject)=>{
482
459
  const reader = this.reader = new window.FileReader();
483
460
  reader.addEventListener('load', ()=>{
@@ -497,10 +474,10 @@ import { ObservableMixin, Collection, logWarning, uid, CKEditorError } from '@ck
497
474
  });
498
475
  }
499
476
  /**
500
- * Aborts the upload process.
501
- *
502
- * @see module:upload/filerepository~UploadAdapter#abort
503
- */ abort() {
477
+ * Aborts the upload process.
478
+ *
479
+ * @see module:upload/filerepository~UploadAdapter#abort
480
+ */ abort() {
504
481
  this.reader.abort();
505
482
  }
506
483
  };
@@ -531,37 +508,37 @@ import { ObservableMixin, Collection, logWarning, uid, CKEditorError } from '@ck
531
508
  * other ways to upload images into CKEditor 5.
532
509
  */ class SimpleUploadAdapter extends Plugin {
533
510
  /**
534
- * @inheritDoc
535
- */ static get requires() {
511
+ * @inheritDoc
512
+ */ static get requires() {
536
513
  return [
537
514
  FileRepository
538
515
  ];
539
516
  }
540
517
  /**
541
- * @inheritDoc
542
- */ static get pluginName() {
518
+ * @inheritDoc
519
+ */ static get pluginName() {
543
520
  return 'SimpleUploadAdapter';
544
521
  }
545
522
  /**
546
- * @inheritDoc
547
- */ static get isOfficialPlugin() {
523
+ * @inheritDoc
524
+ */ static get isOfficialPlugin() {
548
525
  return true;
549
526
  }
550
527
  /**
551
- * @inheritDoc
552
- */ init() {
528
+ * @inheritDoc
529
+ */ init() {
553
530
  const options = this.editor.config.get('simpleUpload');
554
531
  if (!options) {
555
532
  return;
556
533
  }
557
534
  if (!options.uploadUrl) {
558
535
  /**
559
- * The {@link module:upload/uploadconfig~SimpleUploadConfig#uploadUrl `config.simpleUpload.uploadUrl`}
560
- * configuration required by the {@link module:upload/adapters/simpleuploadadapter~SimpleUploadAdapter `SimpleUploadAdapter`}
561
- * is missing. Make sure the correct URL is specified for the image upload to work properly.
562
- *
563
- * @error simple-upload-adapter-missing-uploadurl
564
- */ logWarning('simple-upload-adapter-missing-uploadurl');
536
+ * The {@link module:upload/uploadconfig~SimpleUploadConfig#uploadUrl `config.simpleUpload.uploadUrl`}
537
+ * configuration required by the {@link module:upload/adapters/simpleuploadadapter~SimpleUploadAdapter `SimpleUploadAdapter`}
538
+ * is missing. Make sure the correct URL is specified for the image upload to work properly.
539
+ *
540
+ * @error simple-upload-adapter-missing-uploadurl
541
+ */ logWarning('simple-upload-adapter-missing-uploadurl');
565
542
  return;
566
543
  }
567
544
  this.editor.plugins.get(FileRepository).createUploadAdapter = (loader)=>{
@@ -573,23 +550,16 @@ import { ObservableMixin, Collection, logWarning, uid, CKEditorError } from '@ck
573
550
  * Upload adapter.
574
551
  */ class Adapter {
575
552
  /**
576
- * FileLoader instance to use during the upload.
577
- */ loader;
578
- /**
579
- * The configuration of the adapter.
580
- */ options;
581
- xhr;
582
- /**
583
- * Creates a new adapter instance.
584
- */ constructor(loader, options){
553
+ * Creates a new adapter instance.
554
+ */ constructor(loader, options){
585
555
  this.loader = loader;
586
556
  this.options = options;
587
557
  }
588
558
  /**
589
- * Starts the upload process.
590
- *
591
- * @see module:upload/filerepository~UploadAdapter#upload
592
- */ upload() {
559
+ * Starts the upload process.
560
+ *
561
+ * @see module:upload/filerepository~UploadAdapter#upload
562
+ */ upload() {
593
563
  return this.loader.file.then((file)=>new Promise((resolve, reject)=>{
594
564
  this._initRequest();
595
565
  this._initListeners(resolve, reject, file);
@@ -597,30 +567,30 @@ import { ObservableMixin, Collection, logWarning, uid, CKEditorError } from '@ck
597
567
  }));
598
568
  }
599
569
  /**
600
- * Aborts the upload process.
601
- *
602
- * @see module:upload/filerepository~UploadAdapter#abort
603
- */ abort() {
570
+ * Aborts the upload process.
571
+ *
572
+ * @see module:upload/filerepository~UploadAdapter#abort
573
+ */ abort() {
604
574
  if (this.xhr) {
605
575
  this.xhr.abort();
606
576
  }
607
577
  }
608
578
  /**
609
- * Initializes the `XMLHttpRequest` object using the URL specified as
610
- * {@link module:upload/uploadconfig~SimpleUploadConfig#uploadUrl `simpleUpload.uploadUrl`} in the editor's
611
- * configuration.
612
- */ _initRequest() {
579
+ * Initializes the `XMLHttpRequest` object using the URL specified as
580
+ * {@link module:upload/uploadconfig~SimpleUploadConfig#uploadUrl `simpleUpload.uploadUrl`} in the editor's
581
+ * configuration.
582
+ */ _initRequest() {
613
583
  const xhr = this.xhr = new XMLHttpRequest();
614
584
  xhr.open('POST', this.options.uploadUrl, true);
615
585
  xhr.responseType = 'json';
616
586
  }
617
587
  /**
618
- * Initializes XMLHttpRequest listeners
619
- *
620
- * @param resolve Callback function to be called when the request is successful.
621
- * @param reject Callback function to be called when the request cannot be completed.
622
- * @param file Native File object.
623
- */ _initListeners(resolve, reject, file) {
588
+ * Initializes XMLHttpRequest listeners
589
+ *
590
+ * @param resolve Callback function to be called when the request is successful.
591
+ * @param reject Callback function to be called when the request cannot be completed.
592
+ * @param file Native File object.
593
+ */ _initListeners(resolve, reject, file) {
624
594
  const xhr = this.xhr;
625
595
  const loader = this.loader;
626
596
  const genericErrorText = `Couldn't upload file: ${file.name}.`;
@@ -652,10 +622,10 @@ import { ObservableMixin, Collection, logWarning, uid, CKEditorError } from '@ck
652
622
  }
653
623
  }
654
624
  /**
655
- * Prepares the data and sends the request.
656
- *
657
- * @param file File instance to be uploaded.
658
- */ _sendRequest(file) {
625
+ * Prepares the data and sends the request.
626
+ *
627
+ * @param file File instance to be uploaded.
628
+ */ _sendRequest(file) {
659
629
  // Set headers if specified.
660
630
  const headers = this.options.headers || {};
661
631
  // Use the withCredentials flag if specified.