@ckeditor/ckeditor5-upload 40.0.0 → 40.2.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/CHANGELOG.md CHANGED
@@ -5,33 +5,33 @@ All changes in the package are documented in the main repository. See: https://g
5
5
 
6
6
  Changes for the past releases are available below.
7
7
 
8
- ## [19.0.0](https://github.com/ckeditor/ckeditor5-upload/compare/v18.0.0...v19.0.0) (2020-04-29)
8
+ ## [19.0.0](https://github.com/ckeditor/ckeditor5-upload/compare/v18.0.0...v19.0.0) (April 29, 2020)
9
9
 
10
10
  ### Bug fixes
11
11
 
12
12
  * Restored a condition handling an edge case in upload when promise chains are aborted. Closes [ckeditor/ckeditor5#5892](https://github.com/ckeditor/ckeditor5/issues/5892). ([ed7187b](https://github.com/ckeditor/ckeditor5-upload/commit/ed7187b))
13
13
 
14
14
 
15
- ## [18.0.0](https://github.com/ckeditor/ckeditor5-upload/compare/v17.0.0...v18.0.0) (2020-03-19)
15
+ ## [18.0.0](https://github.com/ckeditor/ckeditor5-upload/compare/v17.0.0...v18.0.0) (March 19, 2020)
16
16
 
17
17
  Internal changes only (updated dependencies, documentation, etc.).
18
18
 
19
19
 
20
- ## [17.0.0](https://github.com/ckeditor/ckeditor5-upload/compare/v16.0.0...v17.0.0) (2020-02-19)
20
+ ## [17.0.0](https://github.com/ckeditor/ckeditor5-upload/compare/v16.0.0...v17.0.0) (February 19, 2020)
21
21
 
22
22
  ### Other changes
23
23
 
24
24
  * Updated translations. ([5be630b](https://github.com/ckeditor/ckeditor5-upload/commit/5be630b))
25
25
 
26
26
 
27
- ## [16.0.0](https://github.com/ckeditor/ckeditor5-upload/compare/v15.0.0...v16.0.0) (2019-12-04)
27
+ ## [16.0.0](https://github.com/ckeditor/ckeditor5-upload/compare/v15.0.0...v16.0.0) (December 4, 2019)
28
28
 
29
29
  ### Other changes
30
30
 
31
31
  * Updated translations. ([188255c](https://github.com/ckeditor/ckeditor5-upload/commit/188255c))
32
32
 
33
33
 
34
- ## [15.0.0](https://github.com/ckeditor/ckeditor5-upload/compare/v12.0.0...v15.0.0) (2019-10-23)
34
+ ## [15.0.0](https://github.com/ckeditor/ckeditor5-upload/compare/v12.0.0...v15.0.0) (October 23, 2019)
35
35
 
36
36
  ### Bug fixes
37
37
 
@@ -42,7 +42,7 @@ Internal changes only (updated dependencies, documentation, etc.).
42
42
  * Updated translations. ([290db0f](https://github.com/ckeditor/ckeditor5-upload/commit/290db0f)) ([1d7e907](https://github.com/ckeditor/ckeditor5-upload/commit/1d7e907))
43
43
 
44
44
 
45
- ## [12.0.0](https://github.com/ckeditor/ckeditor5-upload/compare/v11.1.1...v12.0.0) (2019-08-26)
45
+ ## [12.0.0](https://github.com/ckeditor/ckeditor5-upload/compare/v11.1.1...v12.0.0) (August 26, 2019)
46
46
 
47
47
  ### Features
48
48
 
@@ -68,33 +68,33 @@ import Base64UploadAdapter from '@ckeditor/ckeditor5-upload/src/adapters/base64u
68
68
  ```
69
69
 
70
70
 
71
- ## [11.1.1](https://github.com/ckeditor/ckeditor5-upload/compare/v11.1.0...v11.1.1) (2019-07-10)
71
+ ## [11.1.1](https://github.com/ckeditor/ckeditor5-upload/compare/v11.1.0...v11.1.1) (July 10, 2019)
72
72
 
73
73
  Internal changes only (updated dependencies, documentation, etc.).
74
74
 
75
75
 
76
- ## [11.1.0](https://github.com/ckeditor/ckeditor5-upload/compare/v11.0.2...v11.1.0) (2019-07-04)
76
+ ## [11.1.0](https://github.com/ckeditor/ckeditor5-upload/compare/v11.0.2...v11.1.0) (July 4, 2019)
77
77
 
78
78
  ### Features
79
79
 
80
80
  * Introduced the Base64 image upload adapter. Closes [ckeditor/ckeditor5#1378](https://github.com/ckeditor/ckeditor5/issues/1378). ([938f0f7](https://github.com/ckeditor/ckeditor5-upload/commit/938f0f7))
81
81
 
82
82
 
83
- ## [11.0.2](https://github.com/ckeditor/ckeditor5-upload/compare/v11.0.1...v11.0.2) (2019-06-05)
83
+ ## [11.0.2](https://github.com/ckeditor/ckeditor5-upload/compare/v11.0.1...v11.0.2) (June 6, 2019)
84
84
 
85
85
  ### Other changes
86
86
 
87
87
  * Updated translations. ([73c6761](https://github.com/ckeditor/ckeditor5-upload/commit/73c6761))
88
88
 
89
89
 
90
- ## [11.0.1](https://github.com/ckeditor/ckeditor5-upload/compare/v11.0.0...v11.0.1) (2019-04-10)
90
+ ## [11.0.1](https://github.com/ckeditor/ckeditor5-upload/compare/v11.0.0...v11.0.1) (April 4, 2019)
91
91
 
92
92
  ### Other changes
93
93
 
94
94
  * Updated translations. ([eac33b1](https://github.com/ckeditor/ckeditor5-upload/commit/eac33b1))
95
95
 
96
96
 
97
- ## [11.0.0](https://github.com/ckeditor/ckeditor5-upload/compare/v10.0.4...v11.0.0) (2019-02-28)
97
+ ## [11.0.0](https://github.com/ckeditor/ckeditor5-upload/compare/v10.0.4...v11.0.0) (February 28, 2019)
98
98
 
99
99
  ### Bug fixes
100
100
 
@@ -111,35 +111,35 @@ Internal changes only (updated dependencies, documentation, etc.).
111
111
  * The `FileLoader.file` property was changed to a getter which returns a native `Promise` instance instead of a `File` instance. The returned promise resolves to a `File` instance.
112
112
 
113
113
 
114
- ## [10.0.4](https://github.com/ckeditor/ckeditor5-upload/compare/v10.0.3...v10.0.4) (2018-12-05)
114
+ ## [10.0.4](https://github.com/ckeditor/ckeditor5-upload/compare/v10.0.3...v10.0.4) (December 5, 2018)
115
115
 
116
116
  ### Other changes
117
117
 
118
118
  * Updated translations. ([489b6fa](https://github.com/ckeditor/ckeditor5-upload/commit/489b6fa)) ([f435630](https://github.com/ckeditor/ckeditor5-upload/commit/f435630))
119
119
 
120
120
 
121
- ## [10.0.3](https://github.com/ckeditor/ckeditor5-upload/compare/v10.0.2...v10.0.3) (2018-10-08)
121
+ ## [10.0.3](https://github.com/ckeditor/ckeditor5-upload/compare/v10.0.2...v10.0.3) (October 8, 2018)
122
122
 
123
123
  ### Other changes
124
124
 
125
125
  * Updated translations. ([871eb44](https://github.com/ckeditor/ckeditor5-upload/commit/871eb44))
126
126
 
127
127
 
128
- ## [10.0.2](https://github.com/ckeditor/ckeditor5-upload/compare/v10.0.1...v10.0.2) (2018-07-18)
128
+ ## [10.0.2](https://github.com/ckeditor/ckeditor5-upload/compare/v10.0.1...v10.0.2) (July 18, 2018)
129
129
 
130
130
  ### Other changes
131
131
 
132
132
  * Updated translations. ([ce32eb2](https://github.com/ckeditor/ckeditor5-upload/commit/ce32eb2), [9adb325](https://github.com/ckeditor/ckeditor5-upload/commit/9adb325))
133
133
 
134
134
 
135
- ## [10.0.1](https://github.com/ckeditor/ckeditor5-upload/compare/v10.0.0...v10.0.1) (2018-06-21)
135
+ ## [10.0.1](https://github.com/ckeditor/ckeditor5-upload/compare/v10.0.0...v10.0.1) (June 21, 2018)
136
136
 
137
137
  ### Other changes
138
138
 
139
139
  * Updated translations.
140
140
 
141
141
 
142
- ## [10.0.0](https://github.com/ckeditor/ckeditor5-upload/compare/v1.0.0-beta.4...v10.0.0) (2018-04-25)
142
+ ## [10.0.0](https://github.com/ckeditor/ckeditor5-upload/compare/v1.0.0-beta.4...v10.0.0) (April 25, 2018)
143
143
 
144
144
  ### Other changes
145
145
 
@@ -150,17 +150,17 @@ Internal changes only (updated dependencies, documentation, etc.).
150
150
  * The license under which CKEditor 5 is released has been changed from a triple GPL, LGPL and MPL license to a GPL2+ only. See [ckeditor/ckeditor5#991](https://github.com/ckeditor/ckeditor5/issues/991) for more information.
151
151
 
152
152
 
153
- ## [1.0.0-beta.4](https://github.com/ckeditor/ckeditor5-upload/compare/v1.0.0-beta.2...v1.0.0-beta.4) (2018-04-19)
153
+ ## [1.0.0-beta.4](https://github.com/ckeditor/ckeditor5-upload/compare/v1.0.0-beta.2...v1.0.0-beta.4) (April 19, 2018)
154
154
 
155
155
  Internal changes only (updated dependencies, documentation, etc.).
156
156
 
157
157
 
158
- ## [1.0.0-beta.2](https://github.com/ckeditor/ckeditor5-upload/compare/v1.0.0-beta.1...v1.0.0-beta.2) (2018-04-10)
158
+ ## [1.0.0-beta.2](https://github.com/ckeditor/ckeditor5-upload/compare/v1.0.0-beta.1...v1.0.0-beta.2) (April 10, 2018)
159
159
 
160
160
  Internal changes only (updated dependencies, documentation, etc.).
161
161
 
162
162
 
163
- ## [1.0.0-beta.1](https://github.com/ckeditor/ckeditor5-upload/compare/v1.0.0-alpha.2...v1.0.0-beta.1) (2018-03-15)
163
+ ## [1.0.0-beta.1](https://github.com/ckeditor/ckeditor5-upload/compare/v1.0.0-alpha.2...v1.0.0-beta.1) (March 15, 2018)
164
164
 
165
165
  ### Bug fixes
166
166
 
@@ -183,12 +183,12 @@ Internal changes only (updated dependencies, documentation, etc.).
183
183
  * Renamed `filerepository-no-adapter` error to `filerepository-no-upload-adapter`.
184
184
 
185
185
 
186
- ## [1.0.0-alpha.2](https://github.com/ckeditor/ckeditor5-upload/compare/v1.0.0-alpha.1...v1.0.0-alpha.2) (2017-11-14)
186
+ ## [1.0.0-alpha.2](https://github.com/ckeditor/ckeditor5-upload/compare/v1.0.0-alpha.1...v1.0.0-alpha.2) (November 14, 2017)
187
187
 
188
188
  ### Bug fixes
189
189
 
190
190
  * Destroying `FileDialogButtonView` should not throw an error. Closes [#66](https://github.com/ckeditor/ckeditor5-upload/issues/66). ([2d4ba62](https://github.com/ckeditor/ckeditor5-upload/commit/2d4ba62))
191
- * Images pasted with additional HTML content will not be handled by the upload plugin which prevents data pasted from MS Word to be treated as an image. Closes [#68](https://github.com/ckeditor/ckeditor5-upload/issues/68). ([8d0644a](https://github.com/ckeditor/ckeditor5-upload/commit/8d0644a))
191
+ * Images pasted with additional HTML content will not be handled by the upload plugin which prevents data pasted from Microsoft Word to be treated as an image. Closes [#68](https://github.com/ckeditor/ckeditor5-upload/issues/68). ([8d0644a](https://github.com/ckeditor/ckeditor5-upload/commit/8d0644a))
192
192
 
193
193
  ### Other changes
194
194
 
@@ -200,24 +200,24 @@ Internal changes only (updated dependencies, documentation, etc.).
200
200
  * The `FileDialogButtonView` is not a `ButtonView` instance anymore but a wrapper instead. The button of the component is available under the `#buttonView` property.
201
201
 
202
202
 
203
- ## [1.0.0-alpha.1](https://github.com/ckeditor/ckeditor5-upload/compare/v0.2.0...v1.0.0-alpha.1) (2017-10-03)
203
+ ## [1.0.0-alpha.1](https://github.com/ckeditor/ckeditor5-upload/compare/v0.2.0...v1.0.0-alpha.1) (October 3, 2017)
204
204
 
205
205
  ### Bug fixes
206
206
 
207
- * Image placeholder is now correctly displayed on Firefox and Edge. Closes [#56](https://github.com/ckeditor/ckeditor5-upload/issues/56). ([785e88b](https://github.com/ckeditor/ckeditor5-upload/commit/785e88b))
207
+ * Image placeholder is now correctly displayed in Firefox and Edge. Closes [#56](https://github.com/ckeditor/ckeditor5-upload/issues/56). ([785e88b](https://github.com/ckeditor/ckeditor5-upload/commit/785e88b))
208
208
  * Upload command should not crash when upload adapter is not specified (instead, FileRepository logs an error). Closes [#59](https://github.com/ckeditor/ckeditor5-upload/issues/59). ([14b738b](https://github.com/ckeditor/ckeditor5-upload/commit/14b738b))
209
209
 
210
210
  ### Other changes
211
211
 
212
- * `FileRepository` will automatically warn when it's initialized but no upload adapter was enabled. Closes [#58](https://github.com/ckeditor/ckeditor5-upload/issues/58). ([29aa315](https://github.com/ckeditor/ckeditor5-upload/commit/29aa315))
213
- * Placeholder image will now look better on wider editors. Closes [#63](https://github.com/ckeditor/ckeditor5-upload/issues/63). ([edb5e81](https://github.com/ckeditor/ckeditor5-upload/commit/edb5e81))
212
+ * `FileRepository` will automatically warn when it is initialized but no upload adapter was enabled. Closes [#58](https://github.com/ckeditor/ckeditor5-upload/issues/58). ([29aa315](https://github.com/ckeditor/ckeditor5-upload/commit/29aa315))
213
+ * Placeholder images will now look better on wider editors. Closes [#63](https://github.com/ckeditor/ckeditor5-upload/issues/63). ([edb5e81](https://github.com/ckeditor/ckeditor5-upload/commit/edb5e81))
214
214
 
215
215
 
216
- ## [0.2.0](https://github.com/ckeditor/ckeditor5-upload/compare/v0.1.0...v0.2.0) (2017-09-03)
216
+ ## [0.2.0](https://github.com/ckeditor/ckeditor5-upload/compare/v0.1.0...v0.2.0) (September 3, 2017)
217
217
 
218
218
  ### Bug fixes
219
219
 
220
- * [Safari, Edge] The image upload (button) feature will not throw an error anymore when trying to access picked files. The feature should not use `for...of` loop on native `FileList` because Safari and Edge do not support `Symbol.iterator` for it yet. Closes [#35](https://github.com/ckeditor/ckeditor5-upload/issues/35). ([f4efd9b](https://github.com/ckeditor/ckeditor5-upload/commit/f4efd9b))
220
+ * [Safari, Edge] The image upload (button) feature will not throw an error anymore when trying to access picked files. The feature should not use the `for...of` loop on native `FileList` because Safari and Edge do not support `Symbol.iterator` for it yet. Closes [#35](https://github.com/ckeditor/ckeditor5-upload/issues/35). ([f4efd9b](https://github.com/ckeditor/ckeditor5-upload/commit/f4efd9b))
221
221
  * An image dropped on another image will not redirect the browser to the file's path. Closes [#32](https://github.com/ckeditor/ckeditor5-upload/issues/32). ([4f533be](https://github.com/ckeditor/ckeditor5-upload/commit/4f533be))
222
222
  * Bound `ImageUploadButton#isEnabled` to `ImageUploadCommand#isEnabled`. Closes [#43](https://github.com/ckeditor/ckeditor5-upload/issues/43). ([ba6de66](https://github.com/ckeditor/ckeditor5-upload/commit/ba6de66))
223
223
  * Fixed two issues related to dropping images. First, when dropping a file into an empty paragraph, that paragraph should be replaced with that image. Second, drop position should be read correctly when the editor is focused upon drop. Closes [#42](https://github.com/ckeditor/ckeditor5-upload/issues/42). Closes [#29](https://github.com/ckeditor/ckeditor5-upload/issues/29). ([fec452d](https://github.com/ckeditor/ckeditor5-upload/commit/fec452d))
@@ -239,12 +239,12 @@ Internal changes only (updated dependencies, documentation, etc.).
239
239
 
240
240
  ### BREAKING CHANGES
241
241
 
242
- * `UploadImageCommand` doesn't optimize the drop position itself anymore. Instead, a separate `findOptimalInsertionPosition()` function was introduced.
243
- * `UploadImageCommand` doesn't verify the type of file anymore. This needs to be done by the caller.
242
+ * `UploadImageCommand` does not optimize the drop position itself anymore. Instead, a separate `findOptimalInsertionPosition()` function was introduced.
243
+ * `UploadImageCommand` does not verify the type of file anymore. This needs to be done by the caller.
244
244
  * The command API has been changed.
245
245
 
246
246
 
247
- ## 0.1.0 (2017-05-07)
247
+ ## 0.1.0 (May 7, 2017)
248
248
 
249
249
  ### Features
250
250
 
package/LICENSE.md CHANGED
@@ -2,7 +2,7 @@ Software License Agreement
2
2
  ==========================
3
3
 
4
4
  **CKEditor&nbsp;5 upload feature** – https://github.com/ckeditor/ckeditor5-upload <br>
5
- Copyright (c) 2003-2023, [CKSource Holding sp. z o.o.](https://cksource.com) All rights reserved.
5
+ Copyright (c) 20032023, [CKSource Holding sp. z o.o.](https://cksource.com) All rights reserved.
6
6
 
7
7
  Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html).
8
8
 
@@ -14,4 +14,4 @@ Where not otherwise indicated, all CKEditor content is authored by CKSource engi
14
14
  Trademarks
15
15
  ----------
16
16
 
17
- **CKEditor** is a trademark of [CKSource Holding sp. z o.o.](https://cksource.com) All other brand and product names are trademarks, registered trademarks or service marks of their respective holders.
17
+ **CKEditor** is a trademark of [CKSource Holding sp. z o.o.](https://cksource.com) All other brand and product names are trademarks, registered trademarks, or service marks of their respective holders.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-upload",
3
- "version": "40.0.0",
3
+ "version": "40.2.0",
4
4
  "description": "Upload feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -11,9 +11,9 @@
11
11
  ],
12
12
  "main": "src/index.js",
13
13
  "dependencies": {
14
- "@ckeditor/ckeditor5-core": "40.0.0",
15
- "@ckeditor/ckeditor5-utils": "40.0.0",
16
- "@ckeditor/ckeditor5-ui": "40.0.0"
14
+ "@ckeditor/ckeditor5-core": "40.2.0",
15
+ "@ckeditor/ckeditor5-utils": "40.2.0",
16
+ "@ckeditor/ckeditor5-ui": "40.2.0"
17
17
  },
18
18
  "author": "CKSource (http://cksource.com/)",
19
19
  "license": "GPL-2.0-or-later",
@@ -1,33 +1,33 @@
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 upload/adapters/base64uploadadapter
7
- */
8
- import { Plugin } from '@ckeditor/ckeditor5-core';
9
- import FileRepository from '../filerepository';
10
- /**
11
- * A plugin that converts images inserted into the editor into [Base64 strings](https://en.wikipedia.org/wiki/Base64)
12
- * in the {@glink installation/getting-started/getting-and-setting-data editor output}.
13
- *
14
- * This kind of image upload does not require server processing – images are stored with the rest of the text and
15
- * displayed by the web browser without additional requests.
16
- *
17
- * Check out the {@glink features/images/image-upload/image-upload comprehensive "Image upload overview"} to learn about
18
- * other ways to upload images into CKEditor 5.
19
- */
20
- export default class Base64UploadAdapter extends Plugin {
21
- /**
22
- * @inheritDoc
23
- */
24
- static get requires(): readonly [typeof FileRepository];
25
- /**
26
- * @inheritDoc
27
- */
28
- static get pluginName(): "Base64UploadAdapter";
29
- /**
30
- * @inheritDoc
31
- */
32
- init(): void;
33
- }
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 upload/adapters/base64uploadadapter
7
+ */
8
+ import { Plugin } from '@ckeditor/ckeditor5-core';
9
+ import FileRepository from '../filerepository';
10
+ /**
11
+ * A plugin that converts images inserted into the editor into [Base64 strings](https://en.wikipedia.org/wiki/Base64)
12
+ * in the {@glink installation/getting-started/getting-and-setting-data editor output}.
13
+ *
14
+ * This kind of image upload does not require server processing – images are stored with the rest of the text and
15
+ * displayed by the web browser without additional requests.
16
+ *
17
+ * Check out the {@glink features/images/image-upload/image-upload comprehensive "Image upload overview"} to learn about
18
+ * other ways to upload images into CKEditor 5.
19
+ */
20
+ export default class Base64UploadAdapter extends Plugin {
21
+ /**
22
+ * @inheritDoc
23
+ */
24
+ static get requires(): readonly [typeof FileRepository];
25
+ /**
26
+ * @inheritDoc
27
+ */
28
+ static get pluginName(): "Base64UploadAdapter";
29
+ /**
30
+ * @inheritDoc
31
+ */
32
+ init(): void;
33
+ }
@@ -1,81 +1,81 @@
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 upload/adapters/base64uploadadapter
7
- */
8
- /* globals window */
9
- import { Plugin } from '@ckeditor/ckeditor5-core';
10
- import FileRepository from '../filerepository';
11
- /**
12
- * A plugin that converts images inserted into the editor into [Base64 strings](https://en.wikipedia.org/wiki/Base64)
13
- * in the {@glink installation/getting-started/getting-and-setting-data editor output}.
14
- *
15
- * This kind of image upload does not require server processing – images are stored with the rest of the text and
16
- * displayed by the web browser without additional requests.
17
- *
18
- * Check out the {@glink features/images/image-upload/image-upload comprehensive "Image upload overview"} to learn about
19
- * other ways to upload images into CKEditor 5.
20
- */
21
- export default class Base64UploadAdapter extends Plugin {
22
- /**
23
- * @inheritDoc
24
- */
25
- static get requires() {
26
- return [FileRepository];
27
- }
28
- /**
29
- * @inheritDoc
30
- */
31
- static get pluginName() {
32
- return 'Base64UploadAdapter';
33
- }
34
- /**
35
- * @inheritDoc
36
- */
37
- init() {
38
- this.editor.plugins.get(FileRepository).createUploadAdapter = loader => new Adapter(loader);
39
- }
40
- }
41
- /**
42
- * The upload adapter that converts images inserted into the editor into Base64 strings.
43
- */
44
- class Adapter {
45
- /**
46
- * Creates a new adapter instance.
47
- */
48
- constructor(loader) {
49
- this.loader = loader;
50
- }
51
- /**
52
- * Starts the upload process.
53
- *
54
- * @see module:upload/filerepository~UploadAdapter#upload
55
- */
56
- upload() {
57
- return new Promise((resolve, reject) => {
58
- const reader = this.reader = new window.FileReader();
59
- reader.addEventListener('load', () => {
60
- resolve({ default: reader.result });
61
- });
62
- reader.addEventListener('error', err => {
63
- reject(err);
64
- });
65
- reader.addEventListener('abort', () => {
66
- reject();
67
- });
68
- this.loader.file.then(file => {
69
- reader.readAsDataURL(file);
70
- });
71
- });
72
- }
73
- /**
74
- * Aborts the upload process.
75
- *
76
- * @see module:upload/filerepository~UploadAdapter#abort
77
- */
78
- abort() {
79
- this.reader.abort();
80
- }
81
- }
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 upload/adapters/base64uploadadapter
7
+ */
8
+ /* globals window */
9
+ import { Plugin } from '@ckeditor/ckeditor5-core';
10
+ import FileRepository from '../filerepository';
11
+ /**
12
+ * A plugin that converts images inserted into the editor into [Base64 strings](https://en.wikipedia.org/wiki/Base64)
13
+ * in the {@glink installation/getting-started/getting-and-setting-data editor output}.
14
+ *
15
+ * This kind of image upload does not require server processing – images are stored with the rest of the text and
16
+ * displayed by the web browser without additional requests.
17
+ *
18
+ * Check out the {@glink features/images/image-upload/image-upload comprehensive "Image upload overview"} to learn about
19
+ * other ways to upload images into CKEditor 5.
20
+ */
21
+ export default class Base64UploadAdapter extends Plugin {
22
+ /**
23
+ * @inheritDoc
24
+ */
25
+ static get requires() {
26
+ return [FileRepository];
27
+ }
28
+ /**
29
+ * @inheritDoc
30
+ */
31
+ static get pluginName() {
32
+ return 'Base64UploadAdapter';
33
+ }
34
+ /**
35
+ * @inheritDoc
36
+ */
37
+ init() {
38
+ this.editor.plugins.get(FileRepository).createUploadAdapter = loader => new Adapter(loader);
39
+ }
40
+ }
41
+ /**
42
+ * The upload adapter that converts images inserted into the editor into Base64 strings.
43
+ */
44
+ class Adapter {
45
+ /**
46
+ * Creates a new adapter instance.
47
+ */
48
+ constructor(loader) {
49
+ this.loader = loader;
50
+ }
51
+ /**
52
+ * Starts the upload process.
53
+ *
54
+ * @see module:upload/filerepository~UploadAdapter#upload
55
+ */
56
+ upload() {
57
+ return new Promise((resolve, reject) => {
58
+ const reader = this.reader = new window.FileReader();
59
+ reader.addEventListener('load', () => {
60
+ resolve({ default: reader.result });
61
+ });
62
+ reader.addEventListener('error', err => {
63
+ reject(err);
64
+ });
65
+ reader.addEventListener('abort', () => {
66
+ reject();
67
+ });
68
+ this.loader.file.then(file => {
69
+ reader.readAsDataURL(file);
70
+ });
71
+ });
72
+ }
73
+ /**
74
+ * Aborts the upload process.
75
+ *
76
+ * @see module:upload/filerepository~UploadAdapter#abort
77
+ */
78
+ abort() {
79
+ this.reader.abort();
80
+ }
81
+ }
@@ -1,48 +1,48 @@
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 upload/adapters/simpleuploadadapter
7
- */
8
- import { Plugin } from '@ckeditor/ckeditor5-core';
9
- import FileRepository from '../filerepository';
10
- /**
11
- * The Simple upload adapter allows uploading images to an application running on your server using
12
- * the [`XMLHttpRequest`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) API with a
13
- * minimal {@link module:upload/uploadconfig~SimpleUploadConfig editor configuration}.
14
- *
15
- * ```ts
16
- * ClassicEditor
17
- * .create( document.querySelector( '#editor' ), {
18
- * simpleUpload: {
19
- * uploadUrl: 'http://example.com',
20
- * headers: {
21
- * ...
22
- * }
23
- * }
24
- * } )
25
- * .then( ... )
26
- * .catch( ... );
27
- * ```
28
- *
29
- * See the {@glink features/images/image-upload/simple-upload-adapter "Simple upload adapter"} guide to learn how to
30
- * learn more about the feature (configuration, server–side requirements, etc.).
31
- *
32
- * Check out the {@glink features/images/image-upload/image-upload comprehensive "Image upload overview"} to learn about
33
- * other ways to upload images into CKEditor 5.
34
- */
35
- export default class SimpleUploadAdapter extends Plugin {
36
- /**
37
- * @inheritDoc
38
- */
39
- static get requires(): readonly [typeof FileRepository];
40
- /**
41
- * @inheritDoc
42
- */
43
- static get pluginName(): "SimpleUploadAdapter";
44
- /**
45
- * @inheritDoc
46
- */
47
- init(): void;
48
- }
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 upload/adapters/simpleuploadadapter
7
+ */
8
+ import { Plugin } from '@ckeditor/ckeditor5-core';
9
+ import FileRepository from '../filerepository';
10
+ /**
11
+ * The Simple upload adapter allows uploading images to an application running on your server using
12
+ * the [`XMLHttpRequest`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) API with a
13
+ * minimal {@link module:upload/uploadconfig~SimpleUploadConfig editor configuration}.
14
+ *
15
+ * ```ts
16
+ * ClassicEditor
17
+ * .create( document.querySelector( '#editor' ), {
18
+ * simpleUpload: {
19
+ * uploadUrl: 'http://example.com',
20
+ * headers: {
21
+ * ...
22
+ * }
23
+ * }
24
+ * } )
25
+ * .then( ... )
26
+ * .catch( ... );
27
+ * ```
28
+ *
29
+ * See the {@glink features/images/image-upload/simple-upload-adapter "Simple upload adapter"} guide to learn how to
30
+ * learn more about the feature (configuration, server–side requirements, etc.).
31
+ *
32
+ * Check out the {@glink features/images/image-upload/image-upload comprehensive "Image upload overview"} to learn about
33
+ * other ways to upload images into CKEditor 5.
34
+ */
35
+ export default class SimpleUploadAdapter extends Plugin {
36
+ /**
37
+ * @inheritDoc
38
+ */
39
+ static get requires(): readonly [typeof FileRepository];
40
+ /**
41
+ * @inheritDoc
42
+ */
43
+ static get pluginName(): "SimpleUploadAdapter";
44
+ /**
45
+ * @inheritDoc
46
+ */
47
+ init(): void;
48
+ }