@_sh/strapi-plugin-ckeditor 2.0.3 → 2.1.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/LICENSE +20 -20
- package/README.md +437 -448
- package/admin/src/components/CKEditorIcon.js +46 -46
- package/admin/src/components/Input/CKEditor/configs/base.js +636 -627
- package/admin/src/components/Input/CKEditor/configs/blockBalloon.js +25 -0
- package/admin/src/components/Input/CKEditor/configs/index.js +11 -11
- package/admin/src/components/Input/CKEditor/configs/toolbar.js +17 -17
- package/admin/src/components/Input/CKEditor/configs/toolbarBalloon.js +17 -0
- package/admin/src/components/Input/CKEditor/configuration.js +166 -165
- package/admin/src/components/Input/CKEditor/index.js +119 -119
- package/admin/src/components/Input/CKEditor/plugins/StrapiMediaLib.js +43 -43
- package/admin/src/components/Input/CKEditor/plugins/StrapiUploadAdapter.js +204 -203
- package/admin/src/components/Input/CKEditor/plugins/index.js +1 -1
- package/admin/src/components/Input/CKEditor/styling.js +16 -16
- package/admin/src/components/Input/CKEditor/theme/additional.js +186 -212
- package/admin/src/components/Input/CKEditor/theme/common.js +232 -232
- package/admin/src/components/Input/CKEditor/theme/dark.js +144 -144
- package/admin/src/components/Input/CKEditor/theme/index.js +12 -12
- package/admin/src/components/Input/CKEditor/theme/light.js +135 -135
- package/admin/src/components/Input/MediaLib/index.js +70 -79
- package/admin/src/components/Input/index.js +48 -48
- package/admin/src/index.js +110 -110
- package/admin/src/utils/getEditorConfig.js +37 -37
- package/admin/src/utils/pluginId.js +4 -4
- package/package.json +90 -86
- package/server/controllers/config.js +16 -16
- package/server/controllers/index.js +7 -7
- package/server/index.js +13 -13
- package/server/register.js +11 -11
- package/server/routes/index.js +15 -15
- package/server/services/config.js +19 -19
- package/server/services/index.js +7 -7
- package/strapi-admin.js +3 -3
- package/strapi-server.js +3 -3
- package/admin/src/components/Input/CKEditor/configs/blockBaloon.js +0 -25
- package/admin/src/components/Input/CKEditor/configs/toolbarBaloon.js +0 -17
|
@@ -1,203 +1,204 @@
|
|
|
1
|
-
const Plugin = window.CKEditor5.core.Plugin;
|
|
2
|
-
const FileRepository = window.CKEditor5.upload.FileRepository;
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Similar to Simple upload adapter but customized for Strapi.
|
|
6
|
-
* Inspired by https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-upload/src/adapters/simpleuploadadapter.js
|
|
7
|
-
*/
|
|
8
|
-
export default class StrapiUploadAdapter extends Plugin {
|
|
9
|
-
/**
|
|
10
|
-
* @inheritDoc
|
|
11
|
-
*/
|
|
12
|
-
static get requires() {
|
|
13
|
-
return [FileRepository];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @inheritDoc
|
|
18
|
-
*/
|
|
19
|
-
static get pluginName() {
|
|
20
|
-
return "StrapiUploadAdapter";
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @inheritDoc
|
|
25
|
-
*/
|
|
26
|
-
init() {
|
|
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
|
-
this.
|
|
86
|
-
this.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
xhr.
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
* @
|
|
121
|
-
* @param {Function}
|
|
122
|
-
* @param {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
xhr.addEventListener("
|
|
131
|
-
xhr.addEventListener("
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
if (
|
|
147
|
-
|
|
148
|
-
let
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
loader.
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
* @
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
1
|
+
const Plugin = window.CKEditor5.core.Plugin;
|
|
2
|
+
const FileRepository = window.CKEditor5.upload.FileRepository;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Similar to Simple upload adapter but customized for Strapi.
|
|
6
|
+
* Inspired by https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-upload/src/adapters/simpleuploadadapter.js
|
|
7
|
+
*/
|
|
8
|
+
export default class StrapiUploadAdapter extends Plugin {
|
|
9
|
+
/**
|
|
10
|
+
* @inheritDoc
|
|
11
|
+
*/
|
|
12
|
+
static get requires() {
|
|
13
|
+
return [FileRepository];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @inheritDoc
|
|
18
|
+
*/
|
|
19
|
+
static get pluginName() {
|
|
20
|
+
return "StrapiUploadAdapter";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @inheritDoc
|
|
25
|
+
*/
|
|
26
|
+
init() {
|
|
27
|
+
// backendUrl
|
|
28
|
+
// uploadUrl
|
|
29
|
+
// headers
|
|
30
|
+
// responsive
|
|
31
|
+
|
|
32
|
+
const options = this.editor.config.get("strapiUploadAdapter");
|
|
33
|
+
|
|
34
|
+
if (!options) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (!options.uploadUrl) {
|
|
39
|
+
console.warn(
|
|
40
|
+
'strapi-upload-adapter-missing-uploadUrl: Missing the "uploadUrl" property in the "strapiUploadAdapter" editor configuration.'
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
this.editor.plugins.get(FileRepository).createUploadAdapter = (loader) => {
|
|
47
|
+
return new Adapter(loader, options);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Upload adapter.
|
|
54
|
+
*
|
|
55
|
+
* @private
|
|
56
|
+
*/
|
|
57
|
+
class Adapter {
|
|
58
|
+
/**
|
|
59
|
+
* Creates a new adapter instance.
|
|
60
|
+
*/
|
|
61
|
+
constructor(loader, options) {
|
|
62
|
+
/**
|
|
63
|
+
* FileLoader instance to use during the upload.
|
|
64
|
+
*
|
|
65
|
+
*/
|
|
66
|
+
this.loader = loader;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The configuration of the adapter.
|
|
70
|
+
*
|
|
71
|
+
*/
|
|
72
|
+
this.options = options;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Starts the upload process.
|
|
77
|
+
*
|
|
78
|
+
* @returns {Promise}
|
|
79
|
+
*/
|
|
80
|
+
upload() {
|
|
81
|
+
return this.loader.file.then(
|
|
82
|
+
(file) =>
|
|
83
|
+
new Promise((resolve, reject) => {
|
|
84
|
+
this._initRequest();
|
|
85
|
+
this._initListeners(resolve, reject, file);
|
|
86
|
+
this._sendRequest(file);
|
|
87
|
+
})
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Aborts the upload process.
|
|
93
|
+
*
|
|
94
|
+
* @returns {Promise}
|
|
95
|
+
*/
|
|
96
|
+
abort() {
|
|
97
|
+
if (this.xhr) {
|
|
98
|
+
this.xhr.abort();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Initializes the `XMLHttpRequest` object using the URL specified as
|
|
104
|
+
* `strapiUpload.uploadUrl` in the editor's
|
|
105
|
+
* configuration.
|
|
106
|
+
*
|
|
107
|
+
* @private
|
|
108
|
+
*/
|
|
109
|
+
_initRequest() {
|
|
110
|
+
const xhr = (this.xhr = new XMLHttpRequest());
|
|
111
|
+
|
|
112
|
+
xhr.open("POST", this.options.uploadUrl, true);
|
|
113
|
+
xhr.responseType = "json";
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Initializes XMLHttpRequest listeners
|
|
118
|
+
*
|
|
119
|
+
* @private
|
|
120
|
+
* @param {Function} resolve Callback function to be called when the request is successful.
|
|
121
|
+
* @param {Function} reject Callback function to be called when the request cannot be completed.
|
|
122
|
+
* @param {File} file Native File object.
|
|
123
|
+
*/
|
|
124
|
+
_initListeners(resolve, reject, file) {
|
|
125
|
+
const xhr = this.xhr;
|
|
126
|
+
const loader = this.loader;
|
|
127
|
+
const genericErrorText = `Couldn't upload file: ${file.name}.`;
|
|
128
|
+
|
|
129
|
+
xhr.addEventListener("error", () => reject(genericErrorText));
|
|
130
|
+
xhr.addEventListener("abort", () => reject());
|
|
131
|
+
xhr.addEventListener("load", () => {
|
|
132
|
+
const response = xhr.response;
|
|
133
|
+
|
|
134
|
+
if (!Array.isArray(response) || response.error || response.length !== 1) {
|
|
135
|
+
return reject(
|
|
136
|
+
response && response.error && response.error.message
|
|
137
|
+
? response.error.message
|
|
138
|
+
: genericErrorText
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const { backendUrl, responsive } = this.options || {};
|
|
143
|
+
const { name, url, alternativeText, formats, provider } = response[0];
|
|
144
|
+
const defaultUrl = provider !== "local" ? url : backendUrl + url;
|
|
145
|
+
|
|
146
|
+
if (formats && responsive) {
|
|
147
|
+
let urls = { default: defaultUrl };
|
|
148
|
+
let keys = Object.keys(formats).sort(
|
|
149
|
+
(a, b) => formats[a].width - formats[b].width
|
|
150
|
+
);
|
|
151
|
+
keys.map((k) => (urls[formats[k].width] = provider !== 'local' ? url : backendUrl + formats[k].url));
|
|
152
|
+
resolve({ alt: alternativeText || name, urls: urls });
|
|
153
|
+
} else {
|
|
154
|
+
resolve(
|
|
155
|
+
url
|
|
156
|
+
? {
|
|
157
|
+
alt: alternativeText || name,
|
|
158
|
+
urls: { default: defaultUrl },
|
|
159
|
+
}
|
|
160
|
+
: null
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
// Upload progress when it is supported.
|
|
166
|
+
/* istanbul ignore else */
|
|
167
|
+
if (xhr.upload) {
|
|
168
|
+
xhr.upload.addEventListener("progress", (evt) => {
|
|
169
|
+
if (evt.lengthComputable) {
|
|
170
|
+
loader.uploadTotal = evt.total;
|
|
171
|
+
loader.uploaded = evt.loaded;
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Prepares the data and sends the request.
|
|
179
|
+
*
|
|
180
|
+
* @private
|
|
181
|
+
* @param {File} file File instance to be uploaded.
|
|
182
|
+
*/
|
|
183
|
+
_sendRequest(file) {
|
|
184
|
+
// Set headers if specified.
|
|
185
|
+
const headers = this.options.headers || {};
|
|
186
|
+
|
|
187
|
+
// Use the withCredentials flag if specified.
|
|
188
|
+
const withCredentials = this.options.withCredentials || false;
|
|
189
|
+
|
|
190
|
+
for (const headerName of Object.keys(headers)) {
|
|
191
|
+
this.xhr.setRequestHeader(headerName, headers[headerName]);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
this.xhr.withCredentials = withCredentials;
|
|
195
|
+
|
|
196
|
+
// Prepare the form data.
|
|
197
|
+
const data = new FormData();
|
|
198
|
+
|
|
199
|
+
data.append("files", file);
|
|
200
|
+
|
|
201
|
+
// Send the request.
|
|
202
|
+
this.xhr.send(data);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as StrapiMediaLib } from './StrapiMediaLib';
|
|
1
|
+
export { default as StrapiMediaLib } from './StrapiMediaLib';
|
|
2
2
|
export { default as StrapiUploadAdapter } from './StrapiUploadAdapter';
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import baseTheme from "./theme";
|
|
2
|
-
import { createGlobalStyle } from "styled-components";
|
|
3
|
-
|
|
4
|
-
export const getGlobalStyling = () => {
|
|
5
|
-
|
|
6
|
-
const variant = localStorage.getItem("STRAPI_THEME") || "light";
|
|
7
|
-
const { theme: userTheme, themeOverwrite: overwrite } = globalThis.CKEditorConfig || {};
|
|
8
|
-
|
|
9
|
-
const theme = overwrite ? userTheme : { ...baseTheme, ...userTheme};
|
|
10
|
-
|
|
11
|
-
return createGlobalStyle`
|
|
12
|
-
${theme.common}
|
|
13
|
-
${theme[variant]}
|
|
14
|
-
${theme.additional}
|
|
15
|
-
`;
|
|
16
|
-
}
|
|
1
|
+
import baseTheme from "./theme";
|
|
2
|
+
import { createGlobalStyle } from "styled-components";
|
|
3
|
+
|
|
4
|
+
export const getGlobalStyling = () => {
|
|
5
|
+
|
|
6
|
+
const variant = localStorage.getItem("STRAPI_THEME") || "light";
|
|
7
|
+
const { theme: userTheme, themeOverwrite: overwrite } = globalThis.CKEditorConfig || {};
|
|
8
|
+
|
|
9
|
+
const theme = overwrite ? userTheme : { ...baseTheme, ...userTheme};
|
|
10
|
+
|
|
11
|
+
return createGlobalStyle`
|
|
12
|
+
${theme.common}
|
|
13
|
+
${theme[variant]}
|
|
14
|
+
${theme.additional}
|
|
15
|
+
`;
|
|
16
|
+
}
|