-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
uploadconfig.ts
95 lines (90 loc) · 2.95 KB
/
uploadconfig.ts
1
2
3
4
5
6
7
8
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
/**
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
/**
* @module upload/uploadconfig
*/
/**
* The configuration of the {@link module:upload/adapters/simpleuploadadapter~SimpleUploadAdapter simple upload adapter}.
*
* ```ts
* ClassicEditor
* .create( editorElement, {
* simpleUpload: {
* // The URL the images are uploaded to.
* uploadUrl: 'http://example.com',
*
* // Headers sent along with the XMLHttpRequest to the upload server.
* headers: {
* ...
* }
* }
* } );
* .then( ... )
* .catch( ... );
* ```
*
* See the {@glink features/images/image-upload/simple-upload-adapter "Simple upload adapter"} guide to learn more.
*
* See {@link module:core/editor/editorconfig~EditorConfig all editor configuration options}.
*/
export interface SimpleUploadConfig {
/**
* The path (URL) to the server (application) which handles the file upload. When specified, enables the automatic
* upload of resources (images) inserted into the editor content.
*
* Learn more about the server application requirements in the
* {@glink features/images/image-upload/simple-upload-adapter#server-side-configuration "Server-side configuration"} section
* of the feature guide.
*/
uploadUrl: string;
/**
* An object that defines additional [headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers) sent with
* the request to the server during the upload. This is the right place to implement security mechanisms like
* authentication and [CSRF](https://developer.mozilla.org/en-US/docs/Glossary/CSRF) protection.
*
* ```ts
* ClassicEditor
* .create( editorElement, {
* simpleUpload: {
* headers: {
* 'X-CSRF-TOKEN': 'CSRF-Token',
* Authorization: 'Bearer <JSON Web Token>'
* }
* }
* } );
* .then( ... )
* .catch( ... );
* ```
*
* Learn more about the server application requirements in the
* {@glink features/images/image-upload/simple-upload-adapter#server-side-configuration "Server-side configuration"} section
* of the feature guide.
*/
headers?: Record<string, string>;
/**
* This flag enables the
* [`withCredentials`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials)
* property of the request sent to the server during the upload. It affects cross-site requests only and, for instance,
* allows credentials such as cookies to be sent along with the request.
*
* ```ts
* ClassicEditor
* .create( editorElement, {
* simpleUpload: {
* withCredentials: true
* }
* } );
* .then( ... )
* .catch( ... );
* ```
*
* Learn more about the server application requirements in the
* {@glink features/images/image-upload/simple-upload-adapter#server-side-configuration "Server-side configuration"} section
* of the feature guide.
*
* @default false
*/
withCredentials?: boolean;
}