@ckeditor/ckeditor5-adapter-ckfinder 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 +23 -23
- package/LICENSE.md +2 -2
- package/package.json +2 -2
- package/src/augmentation.d.ts +10 -10
- package/src/augmentation.js +5 -5
- package/src/index.d.ts +9 -9
- package/src/index.js +9 -9
- package/src/uploadadapter.d.ts +33 -33
- package/src/uploadadapter.js +138 -138
- package/src/utils.d.ts +18 -18
- package/src/utils.js +58 -58
- package/build/adapter-ckfinder.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,38 +5,38 @@ 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-adapter-ckfinder/compare/v18.0.0...v19.0.0) (2020
|
|
8
|
+
## [19.0.0](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v18.0.0...v19.0.0) (April 29, 2020)
|
|
9
9
|
|
|
10
10
|
Internal changes only (updated dependencies, documentation, etc.).
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
## [18.0.0](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v17.0.0...v18.0.0) (2020
|
|
13
|
+
## [18.0.0](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v17.0.0...v18.0.0) (March 19, 2020)
|
|
14
14
|
|
|
15
15
|
Internal changes only (updated dependencies, documentation, etc.).
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
## [17.0.0](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v16.0.0...v17.0.0) (2020
|
|
18
|
+
## [17.0.0](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v16.0.0...v17.0.0) (February 18, 2020)
|
|
19
19
|
|
|
20
20
|
### Other changes
|
|
21
21
|
|
|
22
22
|
* Updated translations. ([b3bc679](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/commit/b3bc679))
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
## [16.0.0](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v15.0.0...v16.0.0) (2019
|
|
25
|
+
## [16.0.0](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v15.0.0...v16.0.0) (December 4, 2019)
|
|
26
26
|
|
|
27
27
|
### Other changes
|
|
28
28
|
|
|
29
29
|
* Updated translations. ([5249150](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/commit/5249150))
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
## [15.0.0](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v11.0.5...v15.0.0) (2019
|
|
32
|
+
## [15.0.0](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v11.0.5...v15.0.0) (October 23, 2019)
|
|
33
33
|
|
|
34
34
|
### Other changes
|
|
35
35
|
|
|
36
36
|
* Updated translations. ([b7ae885](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/commit/b7ae885)) ([f03c652](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/commit/f03c652))
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
## [11.0.5](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v11.0.4...v11.0.5) (2019
|
|
39
|
+
## [11.0.5](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v11.0.4...v11.0.5) (August 26, 2019)
|
|
40
40
|
|
|
41
41
|
### Other changes
|
|
42
42
|
|
|
@@ -44,31 +44,31 @@ Internal changes only (updated dependencies, documentation, etc.).
|
|
|
44
44
|
* Updated translations. ([8fb4cc2](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/commit/8fb4cc2))
|
|
45
45
|
|
|
46
46
|
|
|
47
|
-
## [11.0.4](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v11.0.3...v11.0.4) (2019
|
|
47
|
+
## [11.0.4](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v11.0.3...v11.0.4) (July 10, 2019)
|
|
48
48
|
|
|
49
49
|
Internal changes only (updated dependencies, documentation, etc.).
|
|
50
50
|
|
|
51
51
|
|
|
52
|
-
## [11.0.3](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v11.0.2...v11.0.3) (2019
|
|
52
|
+
## [11.0.3](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v11.0.2...v11.0.3) (July 4, 2019)
|
|
53
53
|
|
|
54
54
|
Internal changes only (updated dependencies, documentation, etc.).
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
## [11.0.2](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v11.0.1...v11.0.2) (2019
|
|
57
|
+
## [11.0.2](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v11.0.1...v11.0.2) (June 6, 2019)
|
|
58
58
|
|
|
59
59
|
### Other changes
|
|
60
60
|
|
|
61
61
|
* Updated translations. ([7d00af1](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/commit/7d00af1))
|
|
62
62
|
|
|
63
63
|
|
|
64
|
-
## [11.0.1](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v11.0.0...v11.0.1) (2019
|
|
64
|
+
## [11.0.1](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v11.0.0...v11.0.1) (April 4, 2019)
|
|
65
65
|
|
|
66
66
|
### Other changes
|
|
67
67
|
|
|
68
68
|
* Updated translations. ([3a0fe51](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/commit/3a0fe51))
|
|
69
69
|
|
|
70
70
|
|
|
71
|
-
## [11.0.0](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v10.0.4...v11.0.0) (2019
|
|
71
|
+
## [11.0.0](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v10.0.4...v11.0.0) (February 28, 2019)
|
|
72
72
|
|
|
73
73
|
### Other changes
|
|
74
74
|
|
|
@@ -79,33 +79,33 @@ Internal changes only (updated dependencies, documentation, etc.).
|
|
|
79
79
|
* Upgraded minimal versions of Node to `8.0.0` and npm to `5.7.1`. See: [ckeditor/ckeditor5#1507](https://github.com/ckeditor/ckeditor5/issues/1507). ([612ea3c](https://github.com/ckeditor/ckeditor5-cloud-services/commit/612ea3c))
|
|
80
80
|
|
|
81
81
|
|
|
82
|
-
## [10.0.4](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v10.0.3...v10.0.4) (2018
|
|
82
|
+
## [10.0.4](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v10.0.3...v10.0.4) (December 5, 2018)
|
|
83
83
|
|
|
84
84
|
Internal changes only (updated dependencies, documentation, etc.).
|
|
85
85
|
|
|
86
86
|
|
|
87
|
-
## [10.0.3](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v10.0.2...v10.0.3) (2018
|
|
87
|
+
## [10.0.3](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v10.0.2...v10.0.3) (October 8, 2018)
|
|
88
88
|
|
|
89
89
|
### Other changes
|
|
90
90
|
|
|
91
91
|
* Updated translations. ([896412d](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/commit/896412d))
|
|
92
92
|
|
|
93
93
|
|
|
94
|
-
## [10.0.2](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v10.0.1...v10.0.2) (2018
|
|
94
|
+
## [10.0.2](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v10.0.1...v10.0.2) (July 18, 2018)
|
|
95
95
|
|
|
96
96
|
### Other changes
|
|
97
97
|
|
|
98
98
|
* Updated translations. ([69db8e3](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/commit/69db8e3))
|
|
99
99
|
|
|
100
100
|
|
|
101
|
-
## [10.0.1](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v10.0.0...v10.0.1) (2018
|
|
101
|
+
## [10.0.1](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v10.0.0...v10.0.1) (June 21, 2018)
|
|
102
102
|
|
|
103
103
|
### Other changes
|
|
104
104
|
|
|
105
105
|
* Updated translations. ([6360b78](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/commit/6360b78))
|
|
106
106
|
|
|
107
107
|
|
|
108
|
-
## [10.0.0](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v1.0.0-beta.4...v10.0.0) (2018
|
|
108
|
+
## [10.0.0](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v1.0.0-beta.4...v10.0.0) (April 25, 2018)
|
|
109
109
|
|
|
110
110
|
### Other changes
|
|
111
111
|
|
|
@@ -116,45 +116,45 @@ Internal changes only (updated dependencies, documentation, etc.).
|
|
|
116
116
|
* 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.
|
|
117
117
|
|
|
118
118
|
|
|
119
|
-
## [1.0.0-beta.4](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v1.0.0-beta.2...v1.0.0-beta.4) (2018
|
|
119
|
+
## [1.0.0-beta.4](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v1.0.0-beta.2...v1.0.0-beta.4) (April 19, 2018)
|
|
120
120
|
|
|
121
121
|
### Other changes
|
|
122
122
|
|
|
123
123
|
* Updated translations. ([02712bb](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/commit/02712bb))
|
|
124
124
|
|
|
125
125
|
|
|
126
|
-
## [1.0.0-beta.2](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v1.0.0-beta.1...v1.0.0-beta.2) (2018
|
|
126
|
+
## [1.0.0-beta.2](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v1.0.0-beta.1...v1.0.0-beta.2) (April 10, 2018)
|
|
127
127
|
|
|
128
128
|
Internal changes only (updated dependencies, documentation, etc.).
|
|
129
129
|
|
|
130
130
|
|
|
131
|
-
## [1.0.0-beta.1](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v1.0.0-alpha.2...v1.0.0-beta.1) (2018
|
|
131
|
+
## [1.0.0-beta.1](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v1.0.0-alpha.2...v1.0.0-beta.1) (March 15, 2018)
|
|
132
132
|
|
|
133
133
|
Internal changes only (updated dependencies, documentation, etc.).
|
|
134
134
|
|
|
135
135
|
|
|
136
|
-
## [1.0.0-alpha.2](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v1.0.0-alpha.1...v1.0.0-alpha.2) (2017
|
|
136
|
+
## [1.0.0-alpha.2](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v1.0.0-alpha.1...v1.0.0-alpha.2) (November 14, 2017)
|
|
137
137
|
|
|
138
138
|
### Other changes
|
|
139
139
|
|
|
140
140
|
* Updated translations. ([7f80868](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/commit/7f80868))
|
|
141
141
|
|
|
142
142
|
|
|
143
|
-
## [1.0.0-alpha.1](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v0.1.1...v1.0.0-alpha.1) (2017
|
|
143
|
+
## [1.0.0-alpha.1](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v0.1.1...v1.0.0-alpha.1) (October 3, 2017)
|
|
144
144
|
|
|
145
145
|
### Other changes
|
|
146
146
|
|
|
147
147
|
* The plugin will not log a warning when `config.ckfinder.uploadUrl` is not specified (because `FileRepository` will do it itself). Closes [#5](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/issues/5). ([1a15688](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/commit/1a15688))
|
|
148
148
|
|
|
149
149
|
|
|
150
|
-
## [0.1.1](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v0.1.0...v0.1.1) (2017
|
|
150
|
+
## [0.1.1](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/compare/v0.1.0...v0.1.1) (September 3, 2017)
|
|
151
151
|
|
|
152
152
|
### Other changes
|
|
153
153
|
|
|
154
154
|
* Aligned the implementation to changes in the image upload. ([eb456ac](https://github.com/ckeditor/ckeditor5-adapter-ckfinder/commit/eb456ac))
|
|
155
155
|
|
|
156
156
|
|
|
157
|
-
## 0.1.0 (2017
|
|
157
|
+
## 0.1.0 (May 8, 2017)
|
|
158
158
|
|
|
159
159
|
### Features
|
|
160
160
|
|
package/LICENSE.md
CHANGED
|
@@ -2,7 +2,7 @@ Software License Agreement
|
|
|
2
2
|
==========================
|
|
3
3
|
|
|
4
4
|
**CKEditor 5 CKFinder adapter** – https://github.com/ckeditor/ckeditor5-adapter-ckfinder <br>
|
|
5
|
-
Copyright (c) 2003
|
|
5
|
+
Copyright (c) 2003–2023, [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-adapter-ckfinder",
|
|
3
|
-
"version": "40.
|
|
3
|
+
"version": "40.2.0",
|
|
4
4
|
"description": "CKFinder adapter for CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
],
|
|
13
13
|
"main": "src/index.js",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"ckeditor5": "40.
|
|
15
|
+
"ckeditor5": "40.2.0"
|
|
16
16
|
},
|
|
17
17
|
"author": "CKSource (http://cksource.com/)",
|
|
18
18
|
"license": "GPL-2.0-or-later",
|
package/src/augmentation.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
import type { UploadAdapter } from './index';
|
|
6
|
-
declare module '@ckeditor/ckeditor5-core' {
|
|
7
|
-
interface PluginsMap {
|
|
8
|
-
[UploadAdapter.pluginName]: UploadAdapter;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
import type { UploadAdapter } from './index';
|
|
6
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
7
|
+
interface PluginsMap {
|
|
8
|
+
[UploadAdapter.pluginName]: UploadAdapter;
|
|
9
|
+
}
|
|
10
|
+
}
|
package/src/augmentation.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
export {};
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
export {};
|
package/src/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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 adapter-ckfinder
|
|
7
|
-
*/
|
|
8
|
-
export { default as UploadAdapter } from './uploadadapter';
|
|
9
|
-
import './augmentation';
|
|
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 adapter-ckfinder
|
|
7
|
+
*/
|
|
8
|
+
export { default as UploadAdapter } from './uploadadapter';
|
|
9
|
+
import './augmentation';
|
package/src/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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 adapter-ckfinder
|
|
7
|
-
*/
|
|
8
|
-
export { default as UploadAdapter } from './uploadadapter';
|
|
9
|
-
import './augmentation';
|
|
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 adapter-ckfinder
|
|
7
|
+
*/
|
|
8
|
+
export { default as UploadAdapter } from './uploadadapter';
|
|
9
|
+
import './augmentation';
|
package/src/uploadadapter.d.ts
CHANGED
|
@@ -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 adapter-ckfinder/uploadadapter
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
-
import { FileRepository } from 'ckeditor5/src/upload';
|
|
10
|
-
/**
|
|
11
|
-
* A plugin that enables file uploads in CKEditor 5 using the CKFinder server–side connector.
|
|
12
|
-
*
|
|
13
|
-
* See the {@glink features/file-management/ckfinder "CKFinder file manager integration"} guide to learn how to configure
|
|
14
|
-
* and use this feature as well as find out more about the full integration with the file manager
|
|
15
|
-
* provided by the {@link module:ckfinder/ckfinder~CKFinder} plugin.
|
|
16
|
-
*
|
|
17
|
-
* Check out the {@glink features/images/image-upload/image-upload comprehensive "Image upload overview"} guide to learn
|
|
18
|
-
* about other ways to upload images into CKEditor 5.
|
|
19
|
-
*/
|
|
20
|
-
export default class CKFinderUploadAdapter extends Plugin {
|
|
21
|
-
/**
|
|
22
|
-
* @inheritDoc
|
|
23
|
-
*/
|
|
24
|
-
static get requires(): readonly [typeof FileRepository];
|
|
25
|
-
/**
|
|
26
|
-
* @inheritDoc
|
|
27
|
-
*/
|
|
28
|
-
static get pluginName(): "CKFinderUploadAdapter";
|
|
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 adapter-ckfinder/uploadadapter
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
+
import { FileRepository } from 'ckeditor5/src/upload';
|
|
10
|
+
/**
|
|
11
|
+
* A plugin that enables file uploads in CKEditor 5 using the CKFinder server–side connector.
|
|
12
|
+
*
|
|
13
|
+
* See the {@glink features/file-management/ckfinder "CKFinder file manager integration"} guide to learn how to configure
|
|
14
|
+
* and use this feature as well as find out more about the full integration with the file manager
|
|
15
|
+
* provided by the {@link module:ckfinder/ckfinder~CKFinder} plugin.
|
|
16
|
+
*
|
|
17
|
+
* Check out the {@glink features/images/image-upload/image-upload comprehensive "Image upload overview"} guide to learn
|
|
18
|
+
* about other ways to upload images into CKEditor 5.
|
|
19
|
+
*/
|
|
20
|
+
export default class CKFinderUploadAdapter extends Plugin {
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
static get requires(): readonly [typeof FileRepository];
|
|
25
|
+
/**
|
|
26
|
+
* @inheritDoc
|
|
27
|
+
*/
|
|
28
|
+
static get pluginName(): "CKFinderUploadAdapter";
|
|
29
|
+
/**
|
|
30
|
+
* @inheritDoc
|
|
31
|
+
*/
|
|
32
|
+
init(): void;
|
|
33
|
+
}
|
package/src/uploadadapter.js
CHANGED
|
@@ -1,138 +1,138 @@
|
|
|
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
|
-
/* globals XMLHttpRequest, FormData */
|
|
6
|
-
/**
|
|
7
|
-
* @module adapter-ckfinder/uploadadapter
|
|
8
|
-
*/
|
|
9
|
-
import { Plugin } from 'ckeditor5/src/core';
|
|
10
|
-
import { FileRepository } from 'ckeditor5/src/upload';
|
|
11
|
-
import { getCsrfToken } from './utils';
|
|
12
|
-
/**
|
|
13
|
-
* A plugin that enables file uploads in CKEditor 5 using the CKFinder server–side connector.
|
|
14
|
-
*
|
|
15
|
-
* See the {@glink features/file-management/ckfinder "CKFinder file manager integration"} guide to learn how to configure
|
|
16
|
-
* and use this feature as well as find out more about the full integration with the file manager
|
|
17
|
-
* provided by the {@link module:ckfinder/ckfinder~CKFinder} plugin.
|
|
18
|
-
*
|
|
19
|
-
* Check out the {@glink features/images/image-upload/image-upload comprehensive "Image upload overview"} guide to learn
|
|
20
|
-
* about other ways to upload images into CKEditor 5.
|
|
21
|
-
*/
|
|
22
|
-
export default class CKFinderUploadAdapter extends Plugin {
|
|
23
|
-
/**
|
|
24
|
-
* @inheritDoc
|
|
25
|
-
*/
|
|
26
|
-
static get requires() {
|
|
27
|
-
return [FileRepository];
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* @inheritDoc
|
|
31
|
-
*/
|
|
32
|
-
static get pluginName() {
|
|
33
|
-
return 'CKFinderUploadAdapter';
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* @inheritDoc
|
|
37
|
-
*/
|
|
38
|
-
init() {
|
|
39
|
-
const url = this.editor.config.get('ckfinder.uploadUrl');
|
|
40
|
-
if (!url) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
// Register CKFinderAdapter
|
|
44
|
-
this.editor.plugins.get(FileRepository).createUploadAdapter = loader => new UploadAdapter(loader, url, this.editor.t);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Upload adapter for CKFinder.
|
|
49
|
-
*/
|
|
50
|
-
class UploadAdapter {
|
|
51
|
-
/**
|
|
52
|
-
* Creates a new adapter instance.
|
|
53
|
-
*/
|
|
54
|
-
constructor(loader, url, t) {
|
|
55
|
-
this.loader = loader;
|
|
56
|
-
this.url = url;
|
|
57
|
-
this.t = t;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Starts the upload process.
|
|
61
|
-
*
|
|
62
|
-
* @see module:upload/filerepository~UploadAdapter#upload
|
|
63
|
-
*/
|
|
64
|
-
upload() {
|
|
65
|
-
return this.loader.file.then(file => {
|
|
66
|
-
return new Promise((resolve, reject) => {
|
|
67
|
-
this._initRequest();
|
|
68
|
-
this._initListeners(resolve, reject, file);
|
|
69
|
-
this._sendRequest(file);
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Aborts the upload process.
|
|
75
|
-
*
|
|
76
|
-
* @see module:upload/filerepository~UploadAdapter#abort
|
|
77
|
-
*/
|
|
78
|
-
abort() {
|
|
79
|
-
if (this.xhr) {
|
|
80
|
-
this.xhr.abort();
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Initializes the XMLHttpRequest object.
|
|
85
|
-
*/
|
|
86
|
-
_initRequest() {
|
|
87
|
-
const xhr = this.xhr = new XMLHttpRequest();
|
|
88
|
-
xhr.open('POST', this.url, true);
|
|
89
|
-
xhr.responseType = 'json';
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Initializes XMLHttpRequest listeners.
|
|
93
|
-
*
|
|
94
|
-
* @param resolve Callback function to be called when the request is successful.
|
|
95
|
-
* @param reject Callback function to be called when the request cannot be completed.
|
|
96
|
-
* @param file File instance to be uploaded.
|
|
97
|
-
*/
|
|
98
|
-
_initListeners(resolve, reject, file) {
|
|
99
|
-
const xhr = this.xhr;
|
|
100
|
-
const loader = this.loader;
|
|
101
|
-
const t = this.t;
|
|
102
|
-
const genericError = t('Cannot upload file:') + ` ${file.name}.`;
|
|
103
|
-
xhr.addEventListener('error', () => reject(genericError));
|
|
104
|
-
xhr.addEventListener('abort', () => reject());
|
|
105
|
-
xhr.addEventListener('load', () => {
|
|
106
|
-
const response = xhr.response;
|
|
107
|
-
if (!response || !response.uploaded) {
|
|
108
|
-
return reject(response && response.error && response.error.message ? response.error.message : genericError);
|
|
109
|
-
}
|
|
110
|
-
resolve({
|
|
111
|
-
default: response.url
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
// Upload progress when it's supported.
|
|
115
|
-
/* istanbul ignore else -- @preserve */
|
|
116
|
-
if (xhr.upload) {
|
|
117
|
-
xhr.upload.addEventListener('progress', evt => {
|
|
118
|
-
if (evt.lengthComputable) {
|
|
119
|
-
loader.uploadTotal = evt.total;
|
|
120
|
-
loader.uploaded = evt.loaded;
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Prepares the data and sends the request.
|
|
127
|
-
*
|
|
128
|
-
* @param file File instance to be uploaded.
|
|
129
|
-
*/
|
|
130
|
-
_sendRequest(file) {
|
|
131
|
-
// Prepare form data.
|
|
132
|
-
const data = new FormData();
|
|
133
|
-
data.append('upload', file);
|
|
134
|
-
data.append('ckCsrfToken', getCsrfToken());
|
|
135
|
-
// Send request.
|
|
136
|
-
this.xhr.send(data);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
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
|
+
/* globals XMLHttpRequest, FormData */
|
|
6
|
+
/**
|
|
7
|
+
* @module adapter-ckfinder/uploadadapter
|
|
8
|
+
*/
|
|
9
|
+
import { Plugin } from 'ckeditor5/src/core';
|
|
10
|
+
import { FileRepository } from 'ckeditor5/src/upload';
|
|
11
|
+
import { getCsrfToken } from './utils';
|
|
12
|
+
/**
|
|
13
|
+
* A plugin that enables file uploads in CKEditor 5 using the CKFinder server–side connector.
|
|
14
|
+
*
|
|
15
|
+
* See the {@glink features/file-management/ckfinder "CKFinder file manager integration"} guide to learn how to configure
|
|
16
|
+
* and use this feature as well as find out more about the full integration with the file manager
|
|
17
|
+
* provided by the {@link module:ckfinder/ckfinder~CKFinder} plugin.
|
|
18
|
+
*
|
|
19
|
+
* Check out the {@glink features/images/image-upload/image-upload comprehensive "Image upload overview"} guide to learn
|
|
20
|
+
* about other ways to upload images into CKEditor 5.
|
|
21
|
+
*/
|
|
22
|
+
export default class CKFinderUploadAdapter extends Plugin {
|
|
23
|
+
/**
|
|
24
|
+
* @inheritDoc
|
|
25
|
+
*/
|
|
26
|
+
static get requires() {
|
|
27
|
+
return [FileRepository];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* @inheritDoc
|
|
31
|
+
*/
|
|
32
|
+
static get pluginName() {
|
|
33
|
+
return 'CKFinderUploadAdapter';
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* @inheritDoc
|
|
37
|
+
*/
|
|
38
|
+
init() {
|
|
39
|
+
const url = this.editor.config.get('ckfinder.uploadUrl');
|
|
40
|
+
if (!url) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
// Register CKFinderAdapter
|
|
44
|
+
this.editor.plugins.get(FileRepository).createUploadAdapter = loader => new UploadAdapter(loader, url, this.editor.t);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Upload adapter for CKFinder.
|
|
49
|
+
*/
|
|
50
|
+
class UploadAdapter {
|
|
51
|
+
/**
|
|
52
|
+
* Creates a new adapter instance.
|
|
53
|
+
*/
|
|
54
|
+
constructor(loader, url, t) {
|
|
55
|
+
this.loader = loader;
|
|
56
|
+
this.url = url;
|
|
57
|
+
this.t = t;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Starts the upload process.
|
|
61
|
+
*
|
|
62
|
+
* @see module:upload/filerepository~UploadAdapter#upload
|
|
63
|
+
*/
|
|
64
|
+
upload() {
|
|
65
|
+
return this.loader.file.then(file => {
|
|
66
|
+
return new Promise((resolve, reject) => {
|
|
67
|
+
this._initRequest();
|
|
68
|
+
this._initListeners(resolve, reject, file);
|
|
69
|
+
this._sendRequest(file);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Aborts the upload process.
|
|
75
|
+
*
|
|
76
|
+
* @see module:upload/filerepository~UploadAdapter#abort
|
|
77
|
+
*/
|
|
78
|
+
abort() {
|
|
79
|
+
if (this.xhr) {
|
|
80
|
+
this.xhr.abort();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Initializes the XMLHttpRequest object.
|
|
85
|
+
*/
|
|
86
|
+
_initRequest() {
|
|
87
|
+
const xhr = this.xhr = new XMLHttpRequest();
|
|
88
|
+
xhr.open('POST', this.url, true);
|
|
89
|
+
xhr.responseType = 'json';
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Initializes XMLHttpRequest listeners.
|
|
93
|
+
*
|
|
94
|
+
* @param resolve Callback function to be called when the request is successful.
|
|
95
|
+
* @param reject Callback function to be called when the request cannot be completed.
|
|
96
|
+
* @param file File instance to be uploaded.
|
|
97
|
+
*/
|
|
98
|
+
_initListeners(resolve, reject, file) {
|
|
99
|
+
const xhr = this.xhr;
|
|
100
|
+
const loader = this.loader;
|
|
101
|
+
const t = this.t;
|
|
102
|
+
const genericError = t('Cannot upload file:') + ` ${file.name}.`;
|
|
103
|
+
xhr.addEventListener('error', () => reject(genericError));
|
|
104
|
+
xhr.addEventListener('abort', () => reject());
|
|
105
|
+
xhr.addEventListener('load', () => {
|
|
106
|
+
const response = xhr.response;
|
|
107
|
+
if (!response || !response.uploaded) {
|
|
108
|
+
return reject(response && response.error && response.error.message ? response.error.message : genericError);
|
|
109
|
+
}
|
|
110
|
+
resolve({
|
|
111
|
+
default: response.url
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
// Upload progress when it's supported.
|
|
115
|
+
/* istanbul ignore else -- @preserve */
|
|
116
|
+
if (xhr.upload) {
|
|
117
|
+
xhr.upload.addEventListener('progress', evt => {
|
|
118
|
+
if (evt.lengthComputable) {
|
|
119
|
+
loader.uploadTotal = evt.total;
|
|
120
|
+
loader.uploaded = evt.loaded;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Prepares the data and sends the request.
|
|
127
|
+
*
|
|
128
|
+
* @param file File instance to be uploaded.
|
|
129
|
+
*/
|
|
130
|
+
_sendRequest(file) {
|
|
131
|
+
// Prepare form data.
|
|
132
|
+
const data = new FormData();
|
|
133
|
+
data.append('upload', file);
|
|
134
|
+
data.append('ckCsrfToken', getCsrfToken());
|
|
135
|
+
// Send request.
|
|
136
|
+
this.xhr.send(data);
|
|
137
|
+
}
|
|
138
|
+
}
|
package/src/utils.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Returns the CSRF token value. The value is a hash stored in `document.cookie`
|
|
7
|
-
* under the `ckCsrfToken` key. The CSRF token can be used to secure the communication
|
|
8
|
-
* between the web browser and the CKFinder server.
|
|
9
|
-
*/
|
|
10
|
-
export declare function getCsrfToken(): string;
|
|
11
|
-
/**
|
|
12
|
-
* Returns the value of the cookie with a given name or `null` if the cookie is not found.
|
|
13
|
-
*/
|
|
14
|
-
export declare function getCookie(name: string): string | null;
|
|
15
|
-
/**
|
|
16
|
-
* Sets the value of the cookie with a given name.
|
|
17
|
-
*/
|
|
18
|
-
export declare function setCookie(name: string, value: string): void;
|
|
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
|
+
* Returns the CSRF token value. The value is a hash stored in `document.cookie`
|
|
7
|
+
* under the `ckCsrfToken` key. The CSRF token can be used to secure the communication
|
|
8
|
+
* between the web browser and the CKFinder server.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getCsrfToken(): string;
|
|
11
|
+
/**
|
|
12
|
+
* Returns the value of the cookie with a given name or `null` if the cookie is not found.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getCookie(name: string): string | null;
|
|
15
|
+
/**
|
|
16
|
+
* Sets the value of the cookie with a given name.
|
|
17
|
+
*/
|
|
18
|
+
export declare function setCookie(name: string, value: string): void;
|
package/src/utils.js
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
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
|
-
/* globals window, document */
|
|
6
|
-
/**
|
|
7
|
-
* @module adapter-ckfinder/utils
|
|
8
|
-
*/
|
|
9
|
-
const TOKEN_COOKIE_NAME = 'ckCsrfToken';
|
|
10
|
-
const TOKEN_LENGTH = 40;
|
|
11
|
-
const tokenCharset = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
|
12
|
-
/**
|
|
13
|
-
* Returns the CSRF token value. The value is a hash stored in `document.cookie`
|
|
14
|
-
* under the `ckCsrfToken` key. The CSRF token can be used to secure the communication
|
|
15
|
-
* between the web browser and the CKFinder server.
|
|
16
|
-
*/
|
|
17
|
-
export function getCsrfToken() {
|
|
18
|
-
let token = getCookie(TOKEN_COOKIE_NAME);
|
|
19
|
-
if (!token || token.length != TOKEN_LENGTH) {
|
|
20
|
-
token = generateToken(TOKEN_LENGTH);
|
|
21
|
-
setCookie(TOKEN_COOKIE_NAME, token);
|
|
22
|
-
}
|
|
23
|
-
return token;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Returns the value of the cookie with a given name or `null` if the cookie is not found.
|
|
27
|
-
*/
|
|
28
|
-
export function getCookie(name) {
|
|
29
|
-
name = name.toLowerCase();
|
|
30
|
-
const parts = document.cookie.split(';');
|
|
31
|
-
for (const part of parts) {
|
|
32
|
-
const pair = part.split('=');
|
|
33
|
-
const key = decodeURIComponent(pair[0].trim().toLowerCase());
|
|
34
|
-
if (key === name) {
|
|
35
|
-
return decodeURIComponent(pair[1]);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Sets the value of the cookie with a given name.
|
|
42
|
-
*/
|
|
43
|
-
export function setCookie(name, value) {
|
|
44
|
-
document.cookie = encodeURIComponent(name) + '=' + encodeURIComponent(value) + ';path=/';
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Generates the CSRF token with the given length.
|
|
48
|
-
*/
|
|
49
|
-
function generateToken(length) {
|
|
50
|
-
let result = '';
|
|
51
|
-
const randValues = new Uint8Array(length);
|
|
52
|
-
window.crypto.getRandomValues(randValues);
|
|
53
|
-
for (let j = 0; j < randValues.length; j++) {
|
|
54
|
-
const character = tokenCharset.charAt(randValues[j] % tokenCharset.length);
|
|
55
|
-
result += Math.random() > 0.5 ? character.toUpperCase() : character;
|
|
56
|
-
}
|
|
57
|
-
return result;
|
|
58
|
-
}
|
|
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
|
+
/* globals window, document */
|
|
6
|
+
/**
|
|
7
|
+
* @module adapter-ckfinder/utils
|
|
8
|
+
*/
|
|
9
|
+
const TOKEN_COOKIE_NAME = 'ckCsrfToken';
|
|
10
|
+
const TOKEN_LENGTH = 40;
|
|
11
|
+
const tokenCharset = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
|
12
|
+
/**
|
|
13
|
+
* Returns the CSRF token value. The value is a hash stored in `document.cookie`
|
|
14
|
+
* under the `ckCsrfToken` key. The CSRF token can be used to secure the communication
|
|
15
|
+
* between the web browser and the CKFinder server.
|
|
16
|
+
*/
|
|
17
|
+
export function getCsrfToken() {
|
|
18
|
+
let token = getCookie(TOKEN_COOKIE_NAME);
|
|
19
|
+
if (!token || token.length != TOKEN_LENGTH) {
|
|
20
|
+
token = generateToken(TOKEN_LENGTH);
|
|
21
|
+
setCookie(TOKEN_COOKIE_NAME, token);
|
|
22
|
+
}
|
|
23
|
+
return token;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns the value of the cookie with a given name or `null` if the cookie is not found.
|
|
27
|
+
*/
|
|
28
|
+
export function getCookie(name) {
|
|
29
|
+
name = name.toLowerCase();
|
|
30
|
+
const parts = document.cookie.split(';');
|
|
31
|
+
for (const part of parts) {
|
|
32
|
+
const pair = part.split('=');
|
|
33
|
+
const key = decodeURIComponent(pair[0].trim().toLowerCase());
|
|
34
|
+
if (key === name) {
|
|
35
|
+
return decodeURIComponent(pair[1]);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Sets the value of the cookie with a given name.
|
|
42
|
+
*/
|
|
43
|
+
export function setCookie(name, value) {
|
|
44
|
+
document.cookie = encodeURIComponent(name) + '=' + encodeURIComponent(value) + ';path=/';
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Generates the CSRF token with the given length.
|
|
48
|
+
*/
|
|
49
|
+
function generateToken(length) {
|
|
50
|
+
let result = '';
|
|
51
|
+
const randValues = new Uint8Array(length);
|
|
52
|
+
window.crypto.getRandomValues(randValues);
|
|
53
|
+
for (let j = 0; j < randValues.length; j++) {
|
|
54
|
+
const character = tokenCharset.charAt(randValues[j] % tokenCharset.length);
|
|
55
|
+
result += Math.random() > 0.5 ? character.toUpperCase() : character;
|
|
56
|
+
}
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapter-ckfinder.js","mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAE4C;AACU;;AAEf;;AAEvC;AACA;AACA;AACA,YAAY,wFAAwF;AACpG;AACA,oBAAoB,yCAAyC;AAC7D;AACA,kBAAkB,wFAAwF;AAC1G;AACA;AACA;AACA;AACe,oCAAoC,sDAAM;AACzD;AACA;AACA;AACA;AACA,WAAW,gEAAc;AACzB;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,2BAA2B,gEAAc;AACzC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,yCAAyC;AACrD,YAAY,QAAQ;AACpB,YAAY,8BAA8B;AAC1C;AACA;AACA;AACA;AACA;AACA,cAAc,yCAAyC;AACvD;AACA;;AAEA;AACA;AACA;AACA,cAAc,QAAQ;AACtB;AACA;;AAEA;AACA;AACA;AACA,cAAc,8BAA8B;AAC5C;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,IAAI;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,UAAU;AACtB,YAAY,UAAU;AACtB,YAAY,MAAM;AAClB;AACA;AACA;AACA;AACA;AACA,yDAAyD,WAAW;;AAEpE;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL,IAAI;;AAEJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,MAAM;AAClB;AACA;AACA;AACA;AACA;AACA,8BAA8B,oDAAY;;AAE1C;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;AC7LA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACO;AACP;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,QAAQ;AACnB,aAAa;AACb;AACO;AACP;AACA,wCAAwC;;AAExC;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB;AACO;AACP,sFAAsF;AACtF;;AAEA;AACA;AACA;AACA,WAAW,QAAQ;AACnB,aAAa;AACb;AACA;AACA;;AAEA;;AAEA,kBAAkB,uBAAuB;AACzC;AACA;AACA;;AAEA;AACA;;;;;;;;;;;AClFA;;;;;;;;;;ACAA;;;;;;;;;;;ACAA;;;;;;UCAA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;;WCtBA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA;;;;;WCPA;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D;;;;;;;;;;;;;;;;ACNA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAE2D","sources":["webpack://CKEditor5.adapterCkfinder/./src/uploadadapter.js","webpack://CKEditor5.adapterCkfinder/./src/utils.js","webpack://CKEditor5.adapterCkfinder/delegated \"./src/core.js\" from dll-reference CKEditor5.dll","webpack://CKEditor5.adapterCkfinder/delegated \"./src/upload.js\" from dll-reference CKEditor5.dll","webpack://CKEditor5.adapterCkfinder/external var \"CKEditor5.dll\"","webpack://CKEditor5.adapterCkfinder/webpack/bootstrap","webpack://CKEditor5.adapterCkfinder/webpack/runtime/define property getters","webpack://CKEditor5.adapterCkfinder/webpack/runtime/hasOwnProperty shorthand","webpack://CKEditor5.adapterCkfinder/webpack/runtime/make namespace object","webpack://CKEditor5.adapterCkfinder/./src/index.js"],"sourcesContent":["/**\n * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/* globals XMLHttpRequest, FormData */\n\n/**\n * @module adapter-ckfinder/uploadadapter\n */\n\nimport { Plugin } from 'ckeditor5/src/core';\nimport { FileRepository } from 'ckeditor5/src/upload';\n\nimport { getCsrfToken } from './utils';\n\n/**\n * A plugin that enables file uploads in CKEditor 5 using the CKFinder server–side connector.\n *\n * See the {@glink features/images/image-upload/ckfinder \"CKFinder file manager integration\" guide} to learn how to configure\n * and use this feature as well as find out more about the full integration with the file manager\n * provided by the {@link module:ckfinder/ckfinder~CKFinder} plugin.\n *\n * Check out the {@glink features/images/image-upload/image-upload comprehensive \"Image upload overview\"} to learn about\n * other ways to upload images into CKEditor 5.\n *\n * @extends module:core/plugin~Plugin\n */\nexport default class CKFinderUploadAdapter extends Plugin {\n\t/**\n\t * @inheritDoc\n\t */\n\tstatic get requires() {\n\t\treturn [ FileRepository ];\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tstatic get pluginName() {\n\t\treturn 'CKFinderUploadAdapter';\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tinit() {\n\t\tconst url = this.editor.config.get( 'ckfinder.uploadUrl' );\n\n\t\tif ( !url ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Register CKFinderAdapter\n\t\tthis.editor.plugins.get( FileRepository ).createUploadAdapter = loader => new UploadAdapter( loader, url, this.editor.t );\n\t}\n}\n\n/**\n * Upload adapter for CKFinder.\n *\n * @private\n * @implements module:upload/filerepository~UploadAdapter\n */\nclass UploadAdapter {\n\t/**\n\t * Creates a new adapter instance.\n\t *\n\t * @param {module:upload/filerepository~FileLoader} loader\n\t * @param {String} url\n\t * @param {module:utils/locale~Locale#t} t\n\t */\n\tconstructor( loader, url, t ) {\n\t\t/**\n\t\t * FileLoader instance to use during the upload.\n\t\t *\n\t\t * @member {module:upload/filerepository~FileLoader} #loader\n\t\t */\n\t\tthis.loader = loader;\n\n\t\t/**\n\t\t * Upload URL.\n\t\t *\n\t\t * @member {String} #url\n\t\t */\n\t\tthis.url = url;\n\n\t\t/**\n\t\t * Locale translation method.\n\t\t *\n\t\t * @member {module:utils/locale~Locale#t} #t\n\t\t */\n\t\tthis.t = t;\n\t}\n\n\t/**\n\t * Starts the upload process.\n\t *\n\t * @see module:upload/filerepository~UploadAdapter#upload\n\t * @returns {Promise.<Object>}\n\t */\n\tupload() {\n\t\treturn this.loader.file.then( file => {\n\t\t\treturn new Promise( ( resolve, reject ) => {\n\t\t\t\tthis._initRequest();\n\t\t\t\tthis._initListeners( resolve, reject, file );\n\t\t\t\tthis._sendRequest( file );\n\t\t\t} );\n\t\t} );\n\t}\n\n\t/**\n\t * Aborts the upload process.\n\t *\n\t * @see module:upload/filerepository~UploadAdapter#abort\n\t */\n\tabort() {\n\t\tif ( this.xhr ) {\n\t\t\tthis.xhr.abort();\n\t\t}\n\t}\n\n\t/**\n\t * Initializes the XMLHttpRequest object.\n\t *\n\t * @private\n\t */\n\t_initRequest() {\n\t\tconst xhr = this.xhr = new XMLHttpRequest();\n\n\t\txhr.open( 'POST', this.url, true );\n\t\txhr.responseType = 'json';\n\t}\n\n\t/**\n\t * Initializes XMLHttpRequest listeners.\n\t *\n\t * @private\n\t * @param {Function} resolve Callback function to be called when the request is successful.\n\t * @param {Function} reject Callback function to be called when the request cannot be completed.\n\t * @param {File} file File instance to be uploaded.\n\t */\n\t_initListeners( resolve, reject, file ) {\n\t\tconst xhr = this.xhr;\n\t\tconst loader = this.loader;\n\t\tconst t = this.t;\n\t\tconst genericError = t( 'Cannot upload file:' ) + ` ${ file.name }.`;\n\n\t\txhr.addEventListener( 'error', () => reject( genericError ) );\n\t\txhr.addEventListener( 'abort', () => reject() );\n\t\txhr.addEventListener( 'load', () => {\n\t\t\tconst response = xhr.response;\n\n\t\t\tif ( !response || !response.uploaded ) {\n\t\t\t\treturn reject( response && response.error && response.error.message ? response.error.message : genericError );\n\t\t\t}\n\n\t\t\tresolve( {\n\t\t\t\tdefault: response.url\n\t\t\t} );\n\t\t} );\n\n\t\t// Upload progress when it's supported.\n\t\t/* istanbul ignore else */\n\t\tif ( xhr.upload ) {\n\t\t\txhr.upload.addEventListener( 'progress', evt => {\n\t\t\t\tif ( evt.lengthComputable ) {\n\t\t\t\t\tloader.uploadTotal = evt.total;\n\t\t\t\t\tloader.uploaded = evt.loaded;\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t}\n\n\t/**\n\t * Prepares the data and sends the request.\n\t *\n\t * @private\n\t * @param {File} file File instance to be uploaded.\n\t */\n\t_sendRequest( file ) {\n\t\t// Prepare form data.\n\t\tconst data = new FormData();\n\t\tdata.append( 'upload', file );\n\t\tdata.append( 'ckCsrfToken', getCsrfToken() );\n\n\t\t// Send request.\n\t\tthis.xhr.send( data );\n\t}\n}\n","/**\n * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/* globals window, document */\n\n/**\n * @module adapter-ckfinder/utils\n */\n\nconst TOKEN_COOKIE_NAME = 'ckCsrfToken';\nconst TOKEN_LENGTH = 40;\nconst tokenCharset = 'abcdefghijklmnopqrstuvwxyz0123456789';\n\n/**\n * Returns the CSRF token value. The value is a hash stored in `document.cookie`\n * under the `ckCsrfToken` key. The CSRF token can be used to secure the communication\n * between the web browser and the CKFinder server.\n *\n * @returns {String}\n */\nexport function getCsrfToken() {\n\tlet token = getCookie( TOKEN_COOKIE_NAME );\n\n\tif ( !token || token.length != TOKEN_LENGTH ) {\n\t\ttoken = generateToken( TOKEN_LENGTH );\n\t\tsetCookie( TOKEN_COOKIE_NAME, token );\n\t}\n\n\treturn token;\n}\n\n/**\n * Returns the value of the cookie with a given name or `null` if the cookie is not found.\n *\n * @param {String} name\n * @returns {String|null}\n */\nexport function getCookie( name ) {\n\tname = name.toLowerCase();\n\tconst parts = document.cookie.split( ';' );\n\n\tfor ( const part of parts ) {\n\t\tconst pair = part.split( '=' );\n\t\tconst key = decodeURIComponent( pair[ 0 ].trim().toLowerCase() );\n\n\t\tif ( key === name ) {\n\t\t\treturn decodeURIComponent( pair[ 1 ] );\n\t\t}\n\t}\n\n\treturn null;\n}\n\n/**\n * Sets the value of the cookie with a given name.\n *\n * @param {String} name\n * @param {String} value\n */\nexport function setCookie( name, value ) {\n\tdocument.cookie = encodeURIComponent( name ) + '=' + encodeURIComponent( value ) + ';path=/';\n}\n\n// Generates the CSRF token with the given length.\n//\n// @private\n// @param {Number} length\n// @returns {string}\nfunction generateToken( length ) {\n\tlet result = '';\n\tconst randValues = new Uint8Array( length );\n\n\twindow.crypto.getRandomValues( randValues );\n\n\tfor ( let j = 0; j < randValues.length; j++ ) {\n\t\tconst character = tokenCharset.charAt( randValues[ j ] % tokenCharset.length );\n\t\tresult += Math.random() > 0.5 ? character.toUpperCase() : character;\n\t}\n\n\treturn result;\n}\n","module.exports = (__webpack_require__(/*! dll-reference CKEditor5.dll */ \"dll-reference CKEditor5.dll\"))(\"./src/core.js\");","module.exports = (__webpack_require__(/*! dll-reference CKEditor5.dll */ \"dll-reference CKEditor5.dll\"))(\"./src/upload.js\");","module.exports = CKEditor5.dll;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/**\n * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/**\n * @module adapter-ckfinder\n */\n\nexport { default as UploadAdapter } from './uploadadapter';\n"],"names":[],"sourceRoot":""}
|