@ckeditor/ckeditor5-upload 41.3.0-alpha.4 → 41.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. package/package.json +3 -5
  2. package/src/index.d.ts +0 -1
  3. package/src/index.js +0 -1
  4. package/dist/content-index.css +0 -4
  5. package/dist/editor-index.css +0 -4
  6. package/dist/index.css +0 -4
  7. package/dist/translations/ar.d.ts +0 -8
  8. package/dist/translations/ar.js +0 -5
  9. package/dist/translations/az.d.ts +0 -8
  10. package/dist/translations/az.js +0 -5
  11. package/dist/translations/bg.d.ts +0 -8
  12. package/dist/translations/bg.js +0 -5
  13. package/dist/translations/bn.d.ts +0 -8
  14. package/dist/translations/bn.js +0 -5
  15. package/dist/translations/ca.d.ts +0 -8
  16. package/dist/translations/ca.js +0 -5
  17. package/dist/translations/cs.d.ts +0 -8
  18. package/dist/translations/cs.js +0 -5
  19. package/dist/translations/da.d.ts +0 -8
  20. package/dist/translations/da.js +0 -5
  21. package/dist/translations/de-ch.d.ts +0 -8
  22. package/dist/translations/de-ch.js +0 -5
  23. package/dist/translations/de.d.ts +0 -8
  24. package/dist/translations/de.js +0 -5
  25. package/dist/translations/el.d.ts +0 -8
  26. package/dist/translations/el.js +0 -5
  27. package/dist/translations/en-au.d.ts +0 -8
  28. package/dist/translations/en-au.js +0 -5
  29. package/dist/translations/en-gb.d.ts +0 -8
  30. package/dist/translations/en-gb.js +0 -5
  31. package/dist/translations/en.d.ts +0 -8
  32. package/dist/translations/en.js +0 -5
  33. package/dist/translations/es-co.d.ts +0 -8
  34. package/dist/translations/es-co.js +0 -5
  35. package/dist/translations/es.d.ts +0 -8
  36. package/dist/translations/es.js +0 -5
  37. package/dist/translations/et.d.ts +0 -8
  38. package/dist/translations/et.js +0 -5
  39. package/dist/translations/fa.d.ts +0 -8
  40. package/dist/translations/fa.js +0 -5
  41. package/dist/translations/fi.d.ts +0 -8
  42. package/dist/translations/fi.js +0 -5
  43. package/dist/translations/fr.d.ts +0 -8
  44. package/dist/translations/fr.js +0 -5
  45. package/dist/translations/gl.d.ts +0 -8
  46. package/dist/translations/gl.js +0 -5
  47. package/dist/translations/he.d.ts +0 -8
  48. package/dist/translations/he.js +0 -5
  49. package/dist/translations/hi.d.ts +0 -8
  50. package/dist/translations/hi.js +0 -5
  51. package/dist/translations/hr.d.ts +0 -8
  52. package/dist/translations/hr.js +0 -5
  53. package/dist/translations/hu.d.ts +0 -8
  54. package/dist/translations/hu.js +0 -5
  55. package/dist/translations/id.d.ts +0 -8
  56. package/dist/translations/id.js +0 -5
  57. package/dist/translations/it.d.ts +0 -8
  58. package/dist/translations/it.js +0 -5
  59. package/dist/translations/ja.d.ts +0 -8
  60. package/dist/translations/ja.js +0 -5
  61. package/dist/translations/ko.d.ts +0 -8
  62. package/dist/translations/ko.js +0 -5
  63. package/dist/translations/ku.d.ts +0 -8
  64. package/dist/translations/ku.js +0 -5
  65. package/dist/translations/lt.d.ts +0 -8
  66. package/dist/translations/lt.js +0 -5
  67. package/dist/translations/lv.d.ts +0 -8
  68. package/dist/translations/lv.js +0 -5
  69. package/dist/translations/ms.d.ts +0 -8
  70. package/dist/translations/ms.js +0 -5
  71. package/dist/translations/nb.d.ts +0 -8
  72. package/dist/translations/nb.js +0 -5
  73. package/dist/translations/ne.d.ts +0 -8
  74. package/dist/translations/ne.js +0 -5
  75. package/dist/translations/nl.d.ts +0 -8
  76. package/dist/translations/nl.js +0 -5
  77. package/dist/translations/no.d.ts +0 -8
  78. package/dist/translations/no.js +0 -5
  79. package/dist/translations/pl.d.ts +0 -8
  80. package/dist/translations/pl.js +0 -5
  81. package/dist/translations/pt-br.d.ts +0 -8
  82. package/dist/translations/pt-br.js +0 -5
  83. package/dist/translations/pt.d.ts +0 -8
  84. package/dist/translations/pt.js +0 -5
  85. package/dist/translations/ro.d.ts +0 -8
  86. package/dist/translations/ro.js +0 -5
  87. package/dist/translations/ru.d.ts +0 -8
  88. package/dist/translations/ru.js +0 -5
  89. package/dist/translations/sk.d.ts +0 -8
  90. package/dist/translations/sk.js +0 -5
  91. package/dist/translations/sq.d.ts +0 -8
  92. package/dist/translations/sq.js +0 -5
  93. package/dist/translations/sr-latn.d.ts +0 -8
  94. package/dist/translations/sr-latn.js +0 -5
  95. package/dist/translations/sr.d.ts +0 -8
  96. package/dist/translations/sr.js +0 -5
  97. package/dist/translations/sv.d.ts +0 -8
  98. package/dist/translations/sv.js +0 -5
  99. package/dist/translations/th.d.ts +0 -8
  100. package/dist/translations/th.js +0 -5
  101. package/dist/translations/tk.d.ts +0 -8
  102. package/dist/translations/tk.js +0 -5
  103. package/dist/translations/tr.d.ts +0 -8
  104. package/dist/translations/tr.js +0 -5
  105. package/dist/translations/ug.d.ts +0 -8
  106. package/dist/translations/ug.js +0 -5
  107. package/dist/translations/uk.d.ts +0 -8
  108. package/dist/translations/uk.js +0 -5
  109. package/dist/translations/ur.d.ts +0 -8
  110. package/dist/translations/ur.js +0 -5
  111. package/dist/translations/uz.d.ts +0 -8
  112. package/dist/translations/uz.js +0 -5
  113. package/dist/translations/vi.d.ts +0 -8
  114. package/dist/translations/vi.js +0 -5
  115. package/dist/translations/zh-cn.d.ts +0 -8
  116. package/dist/translations/zh-cn.js +0 -5
  117. package/dist/translations/zh.d.ts +0 -8
  118. package/dist/translations/zh.js +0 -5
  119. package/dist/types/adapters/base64uploadadapter.d.ts +0 -37
  120. package/dist/types/adapters/simpleuploadadapter.d.ts +0 -52
  121. package/dist/types/augmentation.d.ts +0 -24
  122. package/dist/types/filereader.d.ts +0 -60
  123. package/dist/types/filerepository.d.ts +0 -346
  124. package/dist/types/index.d.ts +0 -17
  125. package/dist/types/ui/filedialogbuttonview.d.ts +0 -87
  126. package/dist/types/uploadconfig.d.ts +0 -94
  127. package/src/ui/filedialogbuttonview.d.ts +0 -83
  128. package/src/ui/filedialogbuttonview.js +0 -102
@@ -1,346 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, 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
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
- */
9
- /**
10
- * @module upload/filerepository
11
- */
12
- import { Plugin, PendingActions } from '@ckeditor/ckeditor5-core';
13
- import { Collection } from '@ckeditor/ckeditor5-utils';
14
- /**
15
- * File repository plugin. A central point for managing file upload.
16
- *
17
- * To use it, first you need an upload adapter. Upload adapter's job is to handle communication with the server
18
- * (sending the file and handling server's response). You can use one of the existing plugins introducing upload adapters
19
- * (e.g. {@link module:easy-image/cloudservicesuploadadapter~CloudServicesUploadAdapter} or
20
- * {@link module:adapter-ckfinder/uploadadapter~CKFinderUploadAdapter}) or write your own one – see
21
- * the {@glink framework/deep-dive/upload-adapter Custom image upload adapter deep-dive} guide.
22
- *
23
- * Then, you can use {@link module:upload/filerepository~FileRepository#createLoader `createLoader()`} and the returned
24
- * {@link module:upload/filerepository~FileLoader} instance to load and upload files.
25
- */
26
- export default class FileRepository extends Plugin {
27
- /**
28
- * Collection of loaders associated with this repository.
29
- */
30
- loaders: Collection<FileLoader>;
31
- /**
32
- * A factory function which should be defined before using `FileRepository`.
33
- *
34
- * It should return a new instance of {@link module:upload/filerepository~UploadAdapter} that will be used to upload files.
35
- * {@link module:upload/filerepository~FileLoader} instance associated with the adapter
36
- * will be passed to that function.
37
- *
38
- * For more information and example see {@link module:upload/filerepository~UploadAdapter}.
39
- */
40
- createUploadAdapter?: (loader: FileLoader) => UploadAdapter;
41
- /**
42
- * Loaders mappings used to retrieve loaders references.
43
- */
44
- private _loadersMap;
45
- /**
46
- * Reference to a pending action registered in a {@link module:core/pendingactions~PendingActions} plugin
47
- * while upload is in progress. When there is no upload then value is `null`.
48
- */
49
- private _pendingAction;
50
- /**
51
- * Number of bytes uploaded.
52
- *
53
- * @readonly
54
- * @observable
55
- */
56
- uploaded: number;
57
- /**
58
- * Number of total bytes to upload.
59
- *
60
- * It might be different than the file size because of headers and additional data.
61
- * It contains `null` if value is not available yet, so it's better to use {@link #uploadedPercent} to monitor
62
- * the progress.
63
- *
64
- * @readonly
65
- * @observable
66
- */
67
- uploadTotal: number | null;
68
- /**
69
- * Upload progress in percents.
70
- *
71
- * @readonly
72
- * @observable
73
- */
74
- uploadedPercent: number;
75
- /**
76
- * @inheritDoc
77
- */
78
- static get pluginName(): "FileRepository";
79
- /**
80
- * @inheritDoc
81
- */
82
- static get requires(): readonly [typeof PendingActions];
83
- /**
84
- * @inheritDoc
85
- */
86
- init(): void;
87
- /**
88
- * Returns the loader associated with specified file or promise.
89
- *
90
- * To get loader by id use `fileRepository.loaders.get( id )`.
91
- *
92
- * @param fileOrPromise Native file or promise handle.
93
- */
94
- getLoader(fileOrPromise: File | Promise<File>): FileLoader | null;
95
- /**
96
- * Creates a loader instance for the given file.
97
- *
98
- * Requires {@link #createUploadAdapter} factory to be defined.
99
- *
100
- * @param fileOrPromise Native File object or native Promise object which resolves to a File.
101
- */
102
- createLoader(fileOrPromise: File | Promise<File>): FileLoader | null;
103
- /**
104
- * Destroys the given loader.
105
- *
106
- * @param fileOrPromiseOrLoader File or Promise associated with that loader or loader itself.
107
- */
108
- destroyLoader(fileOrPromiseOrLoader: File | Promise<File> | FileLoader): void;
109
- /**
110
- * Registers or deregisters pending action bound with upload progress.
111
- */
112
- private _updatePendingAction;
113
- }
114
- declare const FileLoader_base: {
115
- new (): import("@ckeditor/ckeditor5-utils").Observable;
116
- prototype: import("@ckeditor/ckeditor5-utils").Observable;
117
- };
118
- /**
119
- * File loader class.
120
- *
121
- * It is used to control the process of reading the file and uploading it using the specified upload adapter.
122
- */
123
- declare class FileLoader extends FileLoader_base {
124
- /**
125
- * Unique id of FileLoader instance.
126
- *
127
- * @readonly
128
- */
129
- readonly id: string;
130
- /**
131
- * Additional wrapper over the initial file promise passed to this loader.
132
- */
133
- private _filePromiseWrapper;
134
- /**
135
- * Adapter instance associated with this file loader.
136
- */
137
- private _adapter;
138
- /**
139
- * FileReader used by FileLoader.
140
- */
141
- private _reader;
142
- /**
143
- * Current status of FileLoader. It can be one of the following:
144
- *
145
- * * 'idle',
146
- * * 'reading',
147
- * * 'uploading',
148
- * * 'aborted',
149
- * * 'error'.
150
- *
151
- * When reading status can change in a following way:
152
- *
153
- * `idle` -> `reading` -> `idle`
154
- * `idle` -> `reading -> `aborted`
155
- * `idle` -> `reading -> `error`
156
- *
157
- * When uploading status can change in a following way:
158
- *
159
- * `idle` -> `uploading` -> `idle`
160
- * `idle` -> `uploading` -> `aborted`
161
- * `idle` -> `uploading` -> `error`
162
- *
163
- * @readonly
164
- * @observable
165
- */
166
- status: 'idle' | 'reading' | 'uploading' | 'aborted' | 'error';
167
- /**
168
- * Number of bytes uploaded.
169
- *
170
- * @readonly
171
- * @observable
172
- */
173
- uploaded: number;
174
- /**
175
- * Number of total bytes to upload.
176
- *
177
- * @readonly
178
- * @observable
179
- */
180
- uploadTotal: number | null;
181
- /**
182
- * Upload progress in percents.
183
- *
184
- * @readonly
185
- * @observable
186
- */
187
- uploadedPercent: number;
188
- /**
189
- * Response of the upload.
190
- *
191
- * @readonly
192
- * @observable
193
- */
194
- uploadResponse?: UploadResponse | null;
195
- /**
196
- * Creates a new instance of `FileLoader`.
197
- *
198
- * @param filePromise A promise which resolves to a file instance.
199
- * @param uploadAdapterCreator The function which returns {@link module:upload/filerepository~UploadAdapter} instance.
200
- */
201
- constructor(filePromise: Promise<File>, uploadAdapterCreator: (loader: FileLoader) => UploadAdapter);
202
- /**
203
- * A `Promise` which resolves to a `File` instance associated with this file loader.
204
- */
205
- get file(): Promise<File | null>;
206
- /**
207
- * Returns the file data. To read its data, you need for first load the file
208
- * by using the {@link module:upload/filerepository~FileLoader#read `read()`} method.
209
- */
210
- get data(): string | undefined;
211
- /**
212
- * Reads file using {@link module:upload/filereader~FileReader}.
213
- *
214
- * Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `filerepository-read-wrong-status` when status
215
- * is different than `idle`.
216
- *
217
- * Example usage:
218
- *
219
- * ```ts
220
- * fileLoader.read()
221
- * .then( data => { ... } )
222
- * .catch( err => {
223
- * if ( err === 'aborted' ) {
224
- * console.log( 'Reading aborted.' );
225
- * } else {
226
- * console.log( 'Reading error.', err );
227
- * }
228
- * } );
229
- * ```
230
- *
231
- * @returns Returns promise that will be resolved with read data. Promise will be rejected if error
232
- * occurs or if read process is aborted.
233
- */
234
- read(): Promise<string>;
235
- /**
236
- * Reads file using the provided {@link module:upload/filerepository~UploadAdapter}.
237
- *
238
- * Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `filerepository-upload-wrong-status` when status
239
- * is different than `idle`.
240
- * Example usage:
241
- *
242
- * ```ts
243
- * fileLoader.upload()
244
- * .then( data => { ... } )
245
- * .catch( e => {
246
- * if ( e === 'aborted' ) {
247
- * console.log( 'Uploading aborted.' );
248
- * } else {
249
- * console.log( 'Uploading error.', e );
250
- * }
251
- * } );
252
- * ```
253
- *
254
- * @returns Returns promise that will be resolved with response data. Promise will be rejected if error
255
- * occurs or if read process is aborted.
256
- */
257
- upload(): Promise<UploadResponse>;
258
- /**
259
- * Aborts loading process.
260
- */
261
- abort(): void;
262
- /**
263
- * Performs cleanup.
264
- *
265
- * @internal
266
- */
267
- _destroy(): void;
268
- /**
269
- * Wraps a given file promise into another promise giving additional
270
- * control (resolving, rejecting, checking if fulfilled) over it.
271
- *
272
- * @param filePromise The initial file promise to be wrapped.
273
- */
274
- private _createFilePromiseWrapper;
275
- }
276
- export type { FileLoader };
277
- /**
278
- * Upload adapter interface used by the {@link module:upload/filerepository~FileRepository file repository}
279
- * to handle file upload. An upload adapter is a bridge between the editor and server that handles file uploads.
280
- * It should contain a logic necessary to initiate an upload process and monitor its progress.
281
- *
282
- * Learn how to develop your own upload adapter for CKEditor 5 in the
283
- * {@glink framework/deep-dive/upload-adapter "Custom upload adapter"} guide.
284
- *
285
- * @interface UploadAdapter
286
- */
287
- export interface UploadAdapter {
288
- /**
289
- * Executes the upload process.
290
- * This method should return a promise that will resolve when data will be uploaded to server. Promise should be
291
- * resolved with an object containing information about uploaded file:
292
- *
293
- * ```json
294
- * {
295
- * default: 'http://server/default-size.image.png'
296
- * }
297
- * ```
298
- *
299
- * Additionally, other image sizes can be provided:
300
- *
301
- * ```json
302
- * {
303
- * default: 'http://server/default-size.image.png',
304
- * '160': 'http://server/size-160.image.png',
305
- * '500': 'http://server/size-500.image.png',
306
- * '1000': 'http://server/size-1000.image.png',
307
- * '1052': 'http://server/default-size.image.png'
308
- * }
309
- * ```
310
- *
311
- * You can also pass additional properties from the server. In this case you need to wrap URLs
312
- * in the `urls` object and pass additional properties along the `urls` property.
313
- *
314
- * ```json
315
- * {
316
- * myCustomProperty: 'foo',
317
- * urls: {
318
- * default: 'http://server/default-size.image.png',
319
- * '160': 'http://server/size-160.image.png',
320
- * '500': 'http://server/size-500.image.png',
321
- * '1000': 'http://server/size-1000.image.png',
322
- * '1052': 'http://server/default-size.image.png'
323
- * }
324
- * }
325
- * ```
326
- *
327
- * NOTE: When returning multiple images, the widest returned one should equal the default one. It is essential to
328
- * correctly set `width` attribute of the image. See this discussion:
329
- * https://github.com/ckeditor/ckeditor5-easy-image/issues/4 for more information.
330
- *
331
- * Take a look at {@link module:upload/filerepository~UploadAdapter example Adapter implementation} and
332
- * {@link module:upload/filerepository~FileRepository#createUploadAdapter createUploadAdapter method}.
333
- *
334
- * @returns Promise that should be resolved when data is uploaded.
335
- */
336
- upload(): Promise<UploadResponse>;
337
- /**
338
- * Aborts the upload process.
339
- * After aborting it should reject promise returned from {@link #upload upload()}.
340
- *
341
- * Take a look at {@link module:upload/filerepository~UploadAdapter example Adapter implementation} and
342
- * {@link module:upload/filerepository~FileRepository#createUploadAdapter createUploadAdapter method}.
343
- */
344
- abort?(): void;
345
- }
346
- export type UploadResponse = Record<string, unknown>;
@@ -1,17 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, 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
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
- */
9
- /**
10
- * @module upload
11
- */
12
- export { default as FileRepository, type UploadAdapter, type UploadResponse, type FileLoader } from './filerepository.js';
13
- export { default as FileDialogButtonView } from './ui/filedialogbuttonview.js';
14
- export { default as Base64UploadAdapter } from './adapters/base64uploadadapter.js';
15
- export { default as SimpleUploadAdapter } from './adapters/simpleuploadadapter.js';
16
- export type { SimpleUploadConfig } from './uploadconfig.js';
17
- import './augmentation.js';
@@ -1,87 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, 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
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
- */
9
- /**
10
- * @module upload/ui/filedialogbuttonview
11
- */
12
- import { ButtonView } from '@ckeditor/ckeditor5-ui';
13
- import type { Locale } from '@ckeditor/ckeditor5-utils';
14
- /**
15
- * The file dialog button view.
16
- *
17
- * This component provides a button that opens the native file selection dialog.
18
- * It can be used to implement the UI of a file upload feature.
19
- *
20
- * ```ts
21
- * const view = new FileDialogButtonView( locale );
22
- *
23
- * view.set( {
24
- * acceptedType: 'image/*',
25
- * allowMultipleFiles: true
26
- * label: t( 'Insert image' ),
27
- * icon: imageIcon,
28
- * tooltip: true
29
- * } );
30
- *
31
- * view.on( 'done', ( evt, files ) => {
32
- * for ( const file of Array.from( files ) ) {
33
- * console.log( 'Selected file', file );
34
- * }
35
- * } );
36
- * ```
37
- */
38
- export default class FileDialogButtonView extends ButtonView {
39
- /**
40
- * The button view of the component.
41
- *
42
- * @deprecated
43
- */
44
- buttonView: ButtonView;
45
- /**
46
- * A hidden `<input>` view used to execute file dialog.
47
- */
48
- private _fileInputView;
49
- /**
50
- * Accepted file types. Can be provided in form of file extensions, media type or one of:
51
- * * `audio/*`,
52
- * * `video/*`,
53
- * * `image/*`.
54
- *
55
- * @observable
56
- */
57
- acceptedType: string;
58
- /**
59
- * Indicates if multiple files can be selected. Defaults to `true`.
60
- *
61
- * @observable
62
- */
63
- allowMultipleFiles: boolean;
64
- /**
65
- * @inheritDoc
66
- */
67
- constructor(locale?: Locale);
68
- /**
69
- * @inheritDoc
70
- */
71
- render(): void;
72
- }
73
- /**
74
- * Fired when file dialog is closed with file selected.
75
- *
76
- * ```ts
77
- * view.on( 'done', ( evt, files ) => {
78
- * for ( const file of files ) {
79
- * console.log( 'Selected file', file );
80
- * }
81
- * }
82
- * ```
83
- */
84
- export type FileInputViewDoneEvent = {
85
- name: 'done';
86
- args: [files: FileList];
87
- };
@@ -1,94 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, 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
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
- */
9
- /**
10
- * @module upload/uploadconfig
11
- */
12
- /**
13
- * The configuration of the {@link module:upload/adapters/simpleuploadadapter~SimpleUploadAdapter simple upload adapter}.
14
- *
15
- * ```ts
16
- * ClassicEditor
17
- * .create( editorElement, {
18
- * simpleUpload: {
19
- * // The URL the images are uploaded to.
20
- * uploadUrl: 'http://example.com',
21
- *
22
- * // Headers sent along with the XMLHttpRequest to the upload server.
23
- * headers: {
24
- * ...
25
- * }
26
- * }
27
- * } );
28
- * .then( ... )
29
- * .catch( ... );
30
- * ```
31
- *
32
- * See the {@glink features/images/image-upload/simple-upload-adapter "Simple upload adapter"} guide to learn more.
33
- *
34
- * See {@link module:core/editor/editorconfig~EditorConfig all editor configuration options}.
35
- */
36
- export interface SimpleUploadConfig {
37
- /**
38
- * The path (URL) to the server (application) which handles the file upload. When specified, enables the automatic
39
- * upload of resources (images) inserted into the editor content.
40
- *
41
- * Learn more about the server application requirements in the
42
- * {@glink features/images/image-upload/simple-upload-adapter#server-side-configuration "Server-side configuration"} section
43
- * of the feature guide.
44
- */
45
- uploadUrl: string;
46
- /**
47
- * An object that defines additional [headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers) sent with
48
- * the request to the server during the upload. This is the right place to implement security mechanisms like
49
- * authentication and [CSRF](https://developer.mozilla.org/en-US/docs/Glossary/CSRF) protection.
50
- *
51
- * ```ts
52
- * ClassicEditor
53
- * .create( editorElement, {
54
- * simpleUpload: {
55
- * headers: {
56
- * 'X-CSRF-TOKEN': 'CSRF-Token',
57
- * Authorization: 'Bearer <JSON Web Token>'
58
- * }
59
- * }
60
- * } );
61
- * .then( ... )
62
- * .catch( ... );
63
- * ```
64
- *
65
- * Learn more about the server application requirements in the
66
- * {@glink features/images/image-upload/simple-upload-adapter#server-side-configuration "Server-side configuration"} section
67
- * of the feature guide.
68
- */
69
- headers?: Record<string, string>;
70
- /**
71
- * This flag enables the
72
- * [`withCredentials`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials)
73
- * property of the request sent to the server during the upload. It affects cross-site requests only and, for instance,
74
- * allows credentials such as cookies to be sent along with the request.
75
- *
76
- * ```ts
77
- * ClassicEditor
78
- * .create( editorElement, {
79
- * simpleUpload: {
80
- * withCredentials: true
81
- * }
82
- * } );
83
- * .then( ... )
84
- * .catch( ... );
85
- * ```
86
- *
87
- * Learn more about the server application requirements in the
88
- * {@glink features/images/image-upload/simple-upload-adapter#server-side-configuration "Server-side configuration"} section
89
- * of the feature guide.
90
- *
91
- * @default false
92
- */
93
- withCredentials?: boolean;
94
- }
@@ -1,83 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, 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 upload/ui/filedialogbuttonview
7
- */
8
- import { ButtonView } from '@ckeditor/ckeditor5-ui';
9
- import type { Locale } from '@ckeditor/ckeditor5-utils';
10
- /**
11
- * The file dialog button view.
12
- *
13
- * This component provides a button that opens the native file selection dialog.
14
- * It can be used to implement the UI of a file upload feature.
15
- *
16
- * ```ts
17
- * const view = new FileDialogButtonView( locale );
18
- *
19
- * view.set( {
20
- * acceptedType: 'image/*',
21
- * allowMultipleFiles: true
22
- * label: t( 'Insert image' ),
23
- * icon: imageIcon,
24
- * tooltip: true
25
- * } );
26
- *
27
- * view.on( 'done', ( evt, files ) => {
28
- * for ( const file of Array.from( files ) ) {
29
- * console.log( 'Selected file', file );
30
- * }
31
- * } );
32
- * ```
33
- */
34
- export default class FileDialogButtonView extends ButtonView {
35
- /**
36
- * The button view of the component.
37
- *
38
- * @deprecated
39
- */
40
- buttonView: ButtonView;
41
- /**
42
- * A hidden `<input>` view used to execute file dialog.
43
- */
44
- private _fileInputView;
45
- /**
46
- * Accepted file types. Can be provided in form of file extensions, media type or one of:
47
- * * `audio/*`,
48
- * * `video/*`,
49
- * * `image/*`.
50
- *
51
- * @observable
52
- */
53
- acceptedType: string;
54
- /**
55
- * Indicates if multiple files can be selected. Defaults to `true`.
56
- *
57
- * @observable
58
- */
59
- allowMultipleFiles: boolean;
60
- /**
61
- * @inheritDoc
62
- */
63
- constructor(locale?: Locale);
64
- /**
65
- * @inheritDoc
66
- */
67
- render(): void;
68
- }
69
- /**
70
- * Fired when file dialog is closed with file selected.
71
- *
72
- * ```ts
73
- * view.on( 'done', ( evt, files ) => {
74
- * for ( const file of files ) {
75
- * console.log( 'Selected file', file );
76
- * }
77
- * }
78
- * ```
79
- */
80
- export type FileInputViewDoneEvent = {
81
- name: 'done';
82
- args: [files: FileList];
83
- };