@_sh/strapi-plugin-ckeditor 2.1.2 → 3.0.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 +1 -1
- package/README.md +376 -197
- package/admin/src/Input/components/Editor.js +133 -0
- package/admin/src/{components/Input/MediaLib/index.js → Input/components/MediaLib.js} +20 -23
- package/admin/src/Input/config/index.js +2 -0
- package/admin/src/Input/config/language.js +45 -0
- package/admin/src/Input/config/plugins.js +24 -0
- package/admin/src/Input/config/presets.js +18 -0
- package/admin/src/Input/config/styling.js +30 -0
- package/admin/src/Input/index.js +67 -0
- package/admin/src/{components/Input/CKEditor → Input}/plugins/StrapiMediaLib.js +8 -10
- package/admin/src/{components/Input/CKEditor → Input}/plugins/StrapiUploadAdapter.js +16 -34
- package/admin/src/{components/Input/CKEditor → Input}/plugins/index.js +1 -1
- package/admin/src/Input/presets/colors.js +122 -0
- package/admin/src/Input/presets/default.js +378 -0
- package/admin/src/Input/presets/index.js +7 -0
- package/admin/src/Input/theme/additional.js +189 -0
- package/admin/src/{components/Input/CKEditor → Input}/theme/common.js +18 -20
- package/admin/src/{components/Input/CKEditor → Input}/theme/dark.js +28 -21
- package/admin/src/{components/Input/CKEditor → Input}/theme/light.js +28 -20
- package/admin/src/index.js +76 -106
- package/admin/src/pluginId.js +7 -0
- package/admin/src/utils/exportToGlobal.js +8 -0
- package/admin/src/utils/{getEditorConfig.js → getPluginConfig.js} +10 -12
- package/admin/src/utils/getPresetsOptions.js +38 -0
- package/package.json +12 -44
- package/server/controllers/config.js +13 -11
- package/server/controllers/index.js +3 -3
- package/server/register.js +1 -1
- package/server/routes/index.js +7 -12
- package/server/services/config.js +16 -11
- package/server/services/index.js +3 -3
- package/admin/src/components/Input/CKEditor/configs/base.js +0 -639
- package/admin/src/components/Input/CKEditor/configs/blockBalloon.js +0 -25
- package/admin/src/components/Input/CKEditor/configs/index.js +0 -11
- package/admin/src/components/Input/CKEditor/configs/toolbar.js +0 -17
- package/admin/src/components/Input/CKEditor/configs/toolbarBalloon.js +0 -17
- package/admin/src/components/Input/CKEditor/configuration.js +0 -167
- package/admin/src/components/Input/CKEditor/index.js +0 -119
- package/admin/src/components/Input/CKEditor/styling.js +0 -24
- package/admin/src/components/Input/CKEditor/theme/additional.js +0 -187
- package/admin/src/components/Input/index.js +0 -48
- package/admin/src/utils/pluginId.js +0 -5
- /package/admin/src/{components/CKEditorIcon.js → CKEditorIcon.js} +0 -0
- /package/admin/src/{components/Input/CKEditor → Input}/theme/index.js +0 -0
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* [Usage](#usage)
|
|
14
14
|
* [Configuration](#configuration)
|
|
15
15
|
* [Contributing](#contributing)
|
|
16
|
+
* [Migration](#migration)
|
|
16
17
|
* [Requirements](#requirements)
|
|
17
18
|
|
|
18
19
|
## <a id="features"></a>✨ Features
|
|
@@ -22,13 +23,12 @@
|
|
|
22
23
|
* **Strapi theme switching support**
|
|
23
24
|
* **Supports custom styles for the editor**
|
|
24
25
|
* **Supports i18n and different UI translations**
|
|
25
|
-
* **A few predefined, modifiable editor configurations**
|
|
26
26
|
* **Allows custom editor configrations**
|
|
27
27
|
* **Plugins extensibility**
|
|
28
28
|
|
|
29
29
|
<p align="right">
|
|
30
30
|
<a href="https://www.buymeacoffee.com/nshenderov" target="_blank">
|
|
31
|
-
<img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" >
|
|
31
|
+
<img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;max-width: 217px !important;" >
|
|
32
32
|
</a>
|
|
33
33
|
</p>
|
|
34
34
|
|
|
@@ -60,77 +60,58 @@ yarn build
|
|
|
60
60
|
|
|
61
61
|
## <a id="usage"></a>✍️ Usage
|
|
62
62
|
|
|
63
|
-
## Guide:
|
|
64
|
-
<details>
|
|
65
|
-
<summary><b>Open</b></summary>
|
|
66
|
-
|
|
67
|
-
* Go to the Content-Type Builder -> Add another field -> switch to `custom`
|
|
68
|
-
|
|
69
|
-
<p align="center">
|
|
70
|
-
<img src="https://raw.githubusercontent.com/nshenderov/strapi-plugin-ckeditor/master/assets/usage-guide1.png" width="700" />
|
|
71
|
-
</p>
|
|
72
|
-
|
|
73
|
-
* Click on CKEditor 5
|
|
74
63
|
<p align="center">
|
|
75
|
-
<img src="https://raw.githubusercontent.com/nshenderov/strapi-plugin-ckeditor/master/assets/usage-
|
|
64
|
+
<img src="https://raw.githubusercontent.com/nshenderov/strapi-plugin-ckeditor/master/assets/usage-guide.gif" width="700" />
|
|
76
65
|
</p>
|
|
77
66
|
|
|
78
|
-
* Choose the editor version you want
|
|
79
|
-
<p align="center">
|
|
80
|
-
<img src="https://raw.githubusercontent.com/nshenderov/strapi-plugin-ckeditor/master/assets/usage-guide3.png" width="700" />
|
|
81
|
-
</p>
|
|
82
|
-
|
|
83
|
-
</details>
|
|
84
|
-
|
|
85
|
-
## Editor default versions:
|
|
86
67
|
<details>
|
|
87
|
-
<summary><b>
|
|
68
|
+
<summary><b>Default preset:</b></summary>
|
|
88
69
|
|
|
89
70
|
<p align="center">
|
|
90
|
-
<img src="https://raw.githubusercontent.com/nshenderov/strapi-plugin-ckeditor/master/assets/
|
|
91
|
-
</p>
|
|
92
|
-
|
|
93
|
-
<p align="center">
|
|
94
|
-
<img src="https://raw.githubusercontent.com/nshenderov/strapi-plugin-ckeditor/master/assets/toolbarballon-version.png" width="700" />
|
|
95
|
-
</p>
|
|
96
|
-
|
|
97
|
-
<p align="center">
|
|
98
|
-
<img src="https://raw.githubusercontent.com/nshenderov/strapi-plugin-ckeditor/master/assets/blockballon-version.png" width="700" />
|
|
71
|
+
<img src="https://raw.githubusercontent.com/nshenderov/strapi-plugin-ckeditor/master/assets/default-preset.gif" width="700" />
|
|
99
72
|
</p>
|
|
100
73
|
|
|
101
74
|
</details>
|
|
102
75
|
|
|
103
76
|
## <a id="configuration"></a>⚙️ Configuration
|
|
104
77
|
___
|
|
105
|
-
The plugin is based on the [**Strapi Custom Field API**](https://docs.strapi.io/developer-docs/latest/development/custom-fields.html#registering-a-custom-field-on-the-server) and the [**CKEditor5 DLL build**](https://ckeditor.com/docs/ckeditor5/latest/installation/advanced/alternative-setups/dll-builds.html).
|
|
106
78
|
|
|
107
|
-
It is highly recommended to explore [**the official CKEditor5 documentation**](https://ckeditor.com/docs/ckeditor5/latest/features/index.html).
|
|
79
|
+
It is highly recommended to explore [**the official CKEditor5 documentation**](https://ckeditor.com/docs/ckeditor5/latest/features/index.html) and [**the Strapi Custom Field API**](https://docs.strapi.io/developer-docs/latest/development/custom-fields.html#registering-a-custom-field-on-the-server)
|
|
80
|
+
|
|
81
|
+
The plugin configuration should be defined in `your-app/config/ckeditor.js|ts`
|
|
82
|
+
|
|
83
|
+
By default, the plugin provides one preset, which can be modified in the config file.
|
|
108
84
|
|
|
109
|
-
|
|
85
|
+
You can also add new presets in the config file.
|
|
110
86
|
|
|
111
|
-
The plugin
|
|
87
|
+
The plugin exposes all CKEditor packages to the global variable SH_CKE.
|
|
112
88
|
|
|
113
|
-
|
|
89
|
+
The config file must define a function called CKEConfig that returns the configuration object.
|
|
114
90
|
|
|
115
|
-
|
|
91
|
+
The structure of the configuration object is as follows:
|
|
116
92
|
|
|
117
93
|
```js
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
94
|
+
{
|
|
95
|
+
dontMergePresets:bool,
|
|
96
|
+
dontMergeTheme:bool,
|
|
97
|
+
presets:{
|
|
98
|
+
default:{
|
|
99
|
+
field:{...},
|
|
100
|
+
styles:string,
|
|
101
|
+
editorConfig:{...},
|
|
102
|
+
},
|
|
127
103
|
...
|
|
128
104
|
}
|
|
129
|
-
theme:{
|
|
105
|
+
theme:{
|
|
106
|
+
common:string,
|
|
107
|
+
light:string,
|
|
108
|
+
dark:string,
|
|
109
|
+
additional:string,
|
|
110
|
+
}
|
|
130
111
|
}
|
|
131
112
|
```
|
|
132
113
|
|
|
133
|
-
Every
|
|
114
|
+
Every preset in the `presets` object contains three properties:
|
|
134
115
|
|
|
135
116
|
1. `field (object)` Registers this configuration version in the Admin panel.
|
|
136
117
|
2. `styles (string)` Styles applied to the editor in this version.
|
|
@@ -148,8 +129,8 @@ By default, everything defined in the user’s configuration is merged with the
|
|
|
148
129
|
default configuration object. These two properties allow you to prevent
|
|
149
130
|
this behavior:
|
|
150
131
|
|
|
151
|
-
1. `
|
|
152
|
-
2. `
|
|
132
|
+
1. `dontMergePresets (bool)`
|
|
133
|
+
2. `dontMergeTheme (bool)`
|
|
153
134
|
|
|
154
135
|
Since Strapi uses i18n for translation, the `ignorei18n` property is added to the
|
|
155
136
|
`editorConfig.language` object. This property allows you to manually set the
|
|
@@ -171,46 +152,47 @@ The language determination follows this logic:
|
|
|
171
152
|
`ignorei18n ? language.content : i18n -> language.ui`
|
|
172
153
|
|
|
173
154
|
**Example of adding a new editor configuration:**
|
|
155
|
+
|
|
174
156
|
<details>
|
|
175
|
-
<summary><b>ckeditor.
|
|
157
|
+
<summary><b>ckeditor.js</b></summary>
|
|
176
158
|
|
|
177
159
|
```js
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
160
|
+
const CKEConfig = () => {
|
|
161
|
+
presets:{
|
|
162
|
+
myCustomPreset:{
|
|
181
163
|
field: {
|
|
182
|
-
key: "
|
|
183
|
-
value: "
|
|
164
|
+
key: "myCustomPreset",
|
|
165
|
+
value: "myCustomPreset",
|
|
184
166
|
metadatas: {
|
|
185
167
|
intlLabel: {
|
|
186
|
-
id: "ckeditor5.preset.
|
|
187
|
-
defaultMessage: "My custom
|
|
168
|
+
id: "ckeditor5.preset.myCustomPreset.label",
|
|
169
|
+
defaultMessage: "My custom preset",
|
|
188
170
|
},
|
|
189
171
|
},
|
|
190
172
|
},
|
|
191
173
|
editorConfig:{
|
|
192
174
|
plugins: [
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
175
|
+
SH_CKE.Autoformat,
|
|
176
|
+
SH_CKE.Bold,
|
|
177
|
+
SH_CKE.Italic,
|
|
178
|
+
SH_CKE.Essentials,
|
|
179
|
+
SH_CKE.Heading,
|
|
180
|
+
SH_CKE.Image,
|
|
181
|
+
SH_CKE.ImageCaption,
|
|
182
|
+
SH_CKE.ImageStyle,
|
|
183
|
+
SH_CKE.ImageToolbar,
|
|
184
|
+
SH_CKE.ImageUpload,
|
|
185
|
+
SH_CKE.Indent,
|
|
186
|
+
SH_CKE.Link,
|
|
187
|
+
SH_CKE.List,
|
|
188
|
+
SH_CKE.Paragraph,
|
|
189
|
+
SH_CKE.PasteFromOffice,
|
|
190
|
+
SH_CKE.Table,
|
|
191
|
+
SH_CKE.TableToolbar,
|
|
192
|
+
SH_CKE.TableColumnResize,
|
|
193
|
+
SH_CKE.TableCaption,
|
|
194
|
+
SH_CKE.StrapiMediaLib,
|
|
195
|
+
SH_CKE.StrapiUploadAdapter,
|
|
214
196
|
],
|
|
215
197
|
toolbar: [
|
|
216
198
|
'heading',
|
|
@@ -257,14 +239,15 @@ globalThis.CKEditorConfig = {
|
|
|
257
239
|
|
|
258
240
|
</details>
|
|
259
241
|
|
|
260
|
-
**Example of changing buttons, modifying the plugin list, and adding styles in the default
|
|
242
|
+
**Example of changing buttons, modifying the plugin list, and adding styles in the default preset:**
|
|
243
|
+
|
|
261
244
|
<details>
|
|
262
|
-
<summary><b>ckeditor.
|
|
245
|
+
<summary><b>ckeditor.js</b></summary>
|
|
263
246
|
|
|
264
247
|
```js
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
248
|
+
const CKEConfig = () => {
|
|
249
|
+
presets:{
|
|
250
|
+
default:{
|
|
268
251
|
styles:`
|
|
269
252
|
--ck-focus-ring:3px dashed #5CB176;
|
|
270
253
|
|
|
@@ -284,19 +267,19 @@ globalThis.CKEditorConfig = {
|
|
|
284
267
|
`,
|
|
285
268
|
editorConfig:{
|
|
286
269
|
plugins: [
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
270
|
+
SH_CKE.Bold,
|
|
271
|
+
SH_CKE.Italic,
|
|
272
|
+
SH_CKE.Essentials,
|
|
273
|
+
SH_CKE.Heading,
|
|
274
|
+
SH_CKE.Image,
|
|
275
|
+
SH_CKE.ImageCaption,
|
|
276
|
+
SH_CKE.ImageStyle,
|
|
277
|
+
SH_CKE.ImageToolbar,
|
|
278
|
+
SH_CKE.Link,
|
|
279
|
+
SH_CKE.List,
|
|
280
|
+
SH_CKE.Paragraph,
|
|
281
|
+
SH_CKE.StrapiMediaLib,
|
|
282
|
+
SH_CKE.StrapiUploadAdapter,
|
|
300
283
|
],
|
|
301
284
|
toolbar: [
|
|
302
285
|
'heading',
|
|
@@ -315,34 +298,65 @@ globalThis.CKEditorConfig = {
|
|
|
315
298
|
|
|
316
299
|
</details>
|
|
317
300
|
|
|
318
|
-
> 📂
|
|
301
|
+
> 📂 Default preset: [**admin/src/Input/presets/default.js**](https://github.com/nshenderov/strapi-plugin-ckeditor/blob/master/admin/src/Input/presets/default.js)
|
|
319
302
|
|
|
320
|
-
> 📂
|
|
321
|
-
|
|
322
|
-
> 📂 Default editor styles: [**admin/src/components/Input/CKEditor/theme**](https://github.com/nshenderov/strapi-plugin-ckeditor/blob/master/admin/src/components/Input/CKEditor/theme)
|
|
303
|
+
> 📂 Default editor styles: [**admin/src/Input/theme**](https://github.com/nshenderov/strapi-plugin-ckeditor/blob/master/admin/src/Input/theme)
|
|
323
304
|
|
|
324
305
|
> 💡 To display content from an external source in your admin panel, you should configure your `middlewares.js`. [**Explore the documentation for more information**](https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations/required/middlewares.html)
|
|
325
306
|
|
|
326
307
|
## Adding plugins
|
|
327
308
|
|
|
328
309
|
___
|
|
329
|
-
Exmple of adding the Markdown plugin
|
|
330
310
|
|
|
331
|
-
|
|
311
|
+
Your plugin must be available in the `global`.
|
|
312
|
+
|
|
313
|
+
**Example of adding the Timestamp plugin:**
|
|
314
|
+
|
|
315
|
+
1. Create the plugin:
|
|
332
316
|
|
|
333
317
|
```js
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
318
|
+
// your-app/src/admin/timestamp.js
|
|
319
|
+
|
|
320
|
+
class Timestamp extends SH_CKE.Plugin {
|
|
321
|
+
init() {
|
|
322
|
+
const editor = this.editor;
|
|
323
|
+
// The button must be registered among the UI components of the editor
|
|
324
|
+
// to be displayed in the toolbar.
|
|
325
|
+
editor.ui.componentFactory.add( 'timestamp', () => {
|
|
326
|
+
// The button will be an instance of ButtonView.
|
|
327
|
+
const button = new SH_CKE.ButtonView();
|
|
328
|
+
|
|
329
|
+
button.set( {
|
|
330
|
+
label: 'Timestamp',
|
|
331
|
+
withText: true
|
|
332
|
+
} );
|
|
333
|
+
|
|
334
|
+
// Execute a callback function when the button is clicked.
|
|
335
|
+
button.on( 'execute', () => {
|
|
336
|
+
const now = new Date();
|
|
337
|
+
|
|
338
|
+
// Change the model using the model writer.
|
|
339
|
+
editor.model.change( writer => {
|
|
340
|
+
|
|
341
|
+
// Insert the text at the user's current position.
|
|
342
|
+
editor.model.insertContent( writer.createText( now.toString() ) );
|
|
343
|
+
} );
|
|
344
|
+
} );
|
|
345
|
+
|
|
346
|
+
return button;
|
|
347
|
+
} );
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
globalThis.Timestamp = Timestamp;
|
|
339
352
|
```
|
|
340
353
|
|
|
341
|
-
Import the plugin
|
|
354
|
+
2. Import the plugin:
|
|
342
355
|
|
|
343
356
|
```js
|
|
344
|
-
|
|
345
|
-
|
|
357
|
+
// your-app/src/admin/app.js
|
|
358
|
+
|
|
359
|
+
import './timestamp.js'
|
|
346
360
|
|
|
347
361
|
const config = {};
|
|
348
362
|
|
|
@@ -355,109 +369,74 @@ export default {
|
|
|
355
369
|
|
|
356
370
|
```
|
|
357
371
|
|
|
358
|
-
Add
|
|
372
|
+
3. Add the new plugin to your preset:
|
|
359
373
|
|
|
360
|
-
## Example of a config file with the new configuration:
|
|
361
374
|
<details>
|
|
362
|
-
<summary><b>ckeditor.
|
|
375
|
+
<summary><b>ckeditor.js</b></summary>
|
|
363
376
|
|
|
364
377
|
```js
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
378
|
+
// your-app/config/ckeditor.js
|
|
379
|
+
|
|
380
|
+
const CKEConfig = () => {
|
|
381
|
+
presets: {
|
|
382
|
+
myCustomPreset:{
|
|
368
383
|
field: {
|
|
369
|
-
key: "
|
|
370
|
-
value: "
|
|
384
|
+
key: "myCustomPreset",
|
|
385
|
+
value: "myCustomPreset",
|
|
371
386
|
metadatas: {
|
|
372
|
-
|
|
373
|
-
id: "
|
|
374
|
-
defaultMessage: "
|
|
375
|
-
|
|
387
|
+
intlLabel: {
|
|
388
|
+
id: "ckeditor5.preset.myCustomPreset.label",
|
|
389
|
+
defaultMessage: "My custom preset",
|
|
390
|
+
},
|
|
376
391
|
},
|
|
377
392
|
},
|
|
378
393
|
editorConfig:{
|
|
379
|
-
placeholder: 'Markdown editor',
|
|
380
394
|
plugins: [
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
CKEditor5.basicStyles.Code,
|
|
404
|
-
CKEditor5.codeBlock.CodeBlock,
|
|
405
|
-
CKEditor5.list.TodoList,
|
|
406
|
-
CKEditor5.basicStyles.Strikethrough,
|
|
407
|
-
CKEditor5.horizontalLine.HorizontalLine
|
|
395
|
+
Timestamp,
|
|
396
|
+
SH_CKE.Autoformat,
|
|
397
|
+
SH_CKE.Bold,
|
|
398
|
+
SH_CKE.Italic,
|
|
399
|
+
SH_CKE.Essentials,
|
|
400
|
+
SH_CKE.Heading,
|
|
401
|
+
SH_CKE.Image,
|
|
402
|
+
SH_CKE.ImageCaption,
|
|
403
|
+
SH_CKE.ImageStyle,
|
|
404
|
+
SH_CKE.ImageToolbar,
|
|
405
|
+
SH_CKE.ImageUpload,
|
|
406
|
+
SH_CKE.Indent,
|
|
407
|
+
SH_CKE.Link,
|
|
408
|
+
SH_CKE.List,
|
|
409
|
+
SH_CKE.Paragraph,
|
|
410
|
+
SH_CKE.PasteFromOffice,
|
|
411
|
+
SH_CKE.Table,
|
|
412
|
+
SH_CKE.TableToolbar,
|
|
413
|
+
SH_CKE.TableColumnResize,
|
|
414
|
+
SH_CKE.TableCaption,
|
|
415
|
+
SH_CKE.StrapiMediaLib,
|
|
416
|
+
SH_CKE.StrapiUploadAdapter,
|
|
408
417
|
],
|
|
409
|
-
toolbar:
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
'|',
|
|
422
|
-
'code',
|
|
423
|
-
'codeBlock',
|
|
424
|
-
'|',
|
|
425
|
-
'uploadImage',
|
|
426
|
-
'strapiMediaLib',
|
|
427
|
-
'blockQuote',
|
|
428
|
-
'horizontalLine',
|
|
429
|
-
'-',
|
|
430
|
-
'sourceEditing',
|
|
431
|
-
'|',
|
|
432
|
-
'outdent',
|
|
433
|
-
'indent',
|
|
434
|
-
'|',
|
|
435
|
-
'undo',
|
|
436
|
-
'redo'
|
|
437
|
-
],
|
|
438
|
-
shouldNotGroupWhenFull: true
|
|
439
|
-
},
|
|
440
|
-
image: {
|
|
441
|
-
toolbar: [ 'imageStyle:inline', 'imageStyle:block', 'imageStyle:side', '|', 'toggleImageCaption', 'imageTextAlternative' ]
|
|
442
|
-
},
|
|
443
|
-
codeBlock: {
|
|
444
|
-
languages: [
|
|
445
|
-
{ language: 'css', label: 'CSS' },
|
|
446
|
-
{ language: 'html', label: 'HTML' },
|
|
447
|
-
{ language: 'javascript', label: 'JavaScript' },
|
|
448
|
-
{ language: 'php', label: 'PHP' }
|
|
449
|
-
]
|
|
450
|
-
},
|
|
418
|
+
toolbar: [
|
|
419
|
+
'timestamp',
|
|
420
|
+
'heading',
|
|
421
|
+
'|',
|
|
422
|
+
'bold', 'italic', 'link', 'bulletedList', 'numberedList',
|
|
423
|
+
'|',
|
|
424
|
+
'strapiMediaLib', 'insertTable',
|
|
425
|
+
'|',
|
|
426
|
+
'undo', 'redo'
|
|
427
|
+
],
|
|
428
|
+
|
|
429
|
+
...
|
|
451
430
|
}
|
|
452
|
-
}
|
|
453
|
-
|
|
431
|
+
},
|
|
432
|
+
}
|
|
454
433
|
}
|
|
455
434
|
```
|
|
456
435
|
|
|
457
436
|
</details>
|
|
458
437
|
|
|
459
438
|
|
|
460
|
-
Then rebuild the application:
|
|
439
|
+
4. Then rebuild the application:
|
|
461
440
|
```bash
|
|
462
441
|
npm run build
|
|
463
442
|
```
|
|
@@ -467,6 +446,103 @@ or
|
|
|
467
446
|
yarn build
|
|
468
447
|
```
|
|
469
448
|
|
|
449
|
+
|
|
450
|
+
**Alternatively, you can define your plugin like this:**
|
|
451
|
+
|
|
452
|
+
<details>
|
|
453
|
+
<summary><b>ckeditor.js</b></summary>
|
|
454
|
+
|
|
455
|
+
```js
|
|
456
|
+
const CKEConfig = () => {
|
|
457
|
+
class Timestamp extends SH_CKE.Plugin {
|
|
458
|
+
init() {
|
|
459
|
+
const editor = this.editor;
|
|
460
|
+
// The button must be registered among the UI components of the editor
|
|
461
|
+
// to be displayed in the toolbar.
|
|
462
|
+
editor.ui.componentFactory.add("timestamp", () => {
|
|
463
|
+
// The button will be an instance of ButtonView.
|
|
464
|
+
const button = new SH_CKE.ButtonView();
|
|
465
|
+
|
|
466
|
+
button.set({
|
|
467
|
+
label: "Timestamp",
|
|
468
|
+
withText: true,
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
// Execute a callback function when the button is clicked.
|
|
472
|
+
button.on("execute", () => {
|
|
473
|
+
const now = new Date();
|
|
474
|
+
|
|
475
|
+
// Change the model using the model writer.
|
|
476
|
+
editor.model.change((writer) => {
|
|
477
|
+
// Insert the text at the user's current position.
|
|
478
|
+
editor.model.insertContent(writer.createText(now.toString()));
|
|
479
|
+
});
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
return button;
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
return {
|
|
488
|
+
presets: {
|
|
489
|
+
myCustomPreset:{
|
|
490
|
+
field: {
|
|
491
|
+
key: "myCustomPreset",
|
|
492
|
+
value: "myCustomPreset",
|
|
493
|
+
metadatas: {
|
|
494
|
+
intlLabel: {
|
|
495
|
+
id: "ckeditor5.preset.myCustomPreset.label",
|
|
496
|
+
defaultMessage: "My custom preset",
|
|
497
|
+
},
|
|
498
|
+
},
|
|
499
|
+
},
|
|
500
|
+
editorConfig:{
|
|
501
|
+
plugins: [
|
|
502
|
+
Timestamp,
|
|
503
|
+
SH_CKE.Autoformat,
|
|
504
|
+
SH_CKE.Bold,
|
|
505
|
+
SH_CKE.Italic,
|
|
506
|
+
SH_CKE.Essentials,
|
|
507
|
+
SH_CKE.Heading,
|
|
508
|
+
SH_CKE.Image,
|
|
509
|
+
SH_CKE.ImageCaption,
|
|
510
|
+
SH_CKE.ImageStyle,
|
|
511
|
+
SH_CKE.ImageToolbar,
|
|
512
|
+
SH_CKE.ImageUpload,
|
|
513
|
+
SH_CKE.Indent,
|
|
514
|
+
SH_CKE.Link,
|
|
515
|
+
SH_CKE.List,
|
|
516
|
+
SH_CKE.Paragraph,
|
|
517
|
+
SH_CKE.PasteFromOffice,
|
|
518
|
+
SH_CKE.Table,
|
|
519
|
+
SH_CKE.TableToolbar,
|
|
520
|
+
SH_CKE.TableColumnResize,
|
|
521
|
+
SH_CKE.TableCaption,
|
|
522
|
+
SH_CKE.StrapiMediaLib,
|
|
523
|
+
SH_CKE.StrapiUploadAdapter,
|
|
524
|
+
],
|
|
525
|
+
toolbar: [
|
|
526
|
+
'timestamp',
|
|
527
|
+
'heading',
|
|
528
|
+
'|',
|
|
529
|
+
'bold', 'italic', 'link', 'bulletedList', 'numberedList',
|
|
530
|
+
'|',
|
|
531
|
+
'strapiMediaLib', 'insertTable',
|
|
532
|
+
'|',
|
|
533
|
+
'undo', 'redo'
|
|
534
|
+
],
|
|
535
|
+
|
|
536
|
+
...
|
|
537
|
+
}
|
|
538
|
+
},
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
</details>
|
|
544
|
+
|
|
545
|
+
|
|
470
546
|
## <a id="contributing"></a>🛠 Contributing
|
|
471
547
|
___
|
|
472
548
|
|
|
@@ -521,6 +597,109 @@ yarn build
|
|
|
521
597
|
yarn develop
|
|
522
598
|
```
|
|
523
599
|
|
|
600
|
+
## <a id="migration"></a>✈️ Migration
|
|
601
|
+
|
|
602
|
+
### From v2 to v3
|
|
603
|
+
|
|
604
|
+
- The default editor configurations (toolbar, toolbarBalloon, blockBalloon) have been removed and now there is only one preset by default. You will need to update your fields in the Content-Type Builder
|
|
605
|
+
|
|
606
|
+
- Config file extension has changed from `.txt` to `.js` or `.ts`
|
|
607
|
+
- Configuration object properties have been renamed:
|
|
608
|
+
- `configsOverwrite` -> `dontMergePresets`
|
|
609
|
+
- `themeOverwrite` -> `dontMergeTheme`
|
|
610
|
+
- `configs` -> `presets`
|
|
611
|
+
- From v3 instead of globalThis.CKEditorConfig = {..}, the config file must define a function called CKEConfig that returns the configuration object.
|
|
612
|
+
|
|
613
|
+
Example of the new configuration file:
|
|
614
|
+
|
|
615
|
+
<details>
|
|
616
|
+
<summary><b>ckeditor.js</b></summary>
|
|
617
|
+
|
|
618
|
+
```js
|
|
619
|
+
const CKEConfig = () => {
|
|
620
|
+
presets:{
|
|
621
|
+
myCustomPreset:{
|
|
622
|
+
field: {
|
|
623
|
+
key: "myCustomPreset",
|
|
624
|
+
value: "myCustomPreset",
|
|
625
|
+
metadatas: {
|
|
626
|
+
intlLabel: {
|
|
627
|
+
id: "ckeditor5.preset.myCustomPreset.label",
|
|
628
|
+
defaultMessage: "My custom preset",
|
|
629
|
+
},
|
|
630
|
+
},
|
|
631
|
+
},
|
|
632
|
+
editorConfig:{
|
|
633
|
+
plugins: [
|
|
634
|
+
SH_CKE.Autoformat,
|
|
635
|
+
SH_CKE.Bold,
|
|
636
|
+
SH_CKE.Italic,
|
|
637
|
+
SH_CKE.Essentials,
|
|
638
|
+
SH_CKE.Heading,
|
|
639
|
+
SH_CKE.Image,
|
|
640
|
+
SH_CKE.ImageCaption,
|
|
641
|
+
SH_CKE.ImageStyle,
|
|
642
|
+
SH_CKE.ImageToolbar,
|
|
643
|
+
SH_CKE.ImageUpload,
|
|
644
|
+
SH_CKE.Indent,
|
|
645
|
+
SH_CKE.Link,
|
|
646
|
+
SH_CKE.List,
|
|
647
|
+
SH_CKE.Paragraph,
|
|
648
|
+
SH_CKE.PasteFromOffice,
|
|
649
|
+
SH_CKE.Table,
|
|
650
|
+
SH_CKE.TableToolbar,
|
|
651
|
+
SH_CKE.TableColumnResize,
|
|
652
|
+
SH_CKE.TableCaption,
|
|
653
|
+
SH_CKE.StrapiMediaLib,
|
|
654
|
+
SH_CKE.StrapiUploadAdapter,
|
|
655
|
+
],
|
|
656
|
+
toolbar: [
|
|
657
|
+
'heading',
|
|
658
|
+
'|',
|
|
659
|
+
'bold', 'italic', 'link', 'bulletedList', 'numberedList',
|
|
660
|
+
'|',
|
|
661
|
+
'strapiMediaLib', 'insertTable',
|
|
662
|
+
'|',
|
|
663
|
+
'undo', 'redo'
|
|
664
|
+
],
|
|
665
|
+
heading: {
|
|
666
|
+
options: [
|
|
667
|
+
{ model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph' },
|
|
668
|
+
{ model: 'heading1', view: 'h1', title: 'Heading 1', class: 'ck-heading_heading1' },
|
|
669
|
+
{ model: 'heading2', view: 'h2', title: 'Heading 2', class: 'ck-heading_heading2' },
|
|
670
|
+
{ model: 'heading3', view: 'h3', title: 'Heading 3', class: 'ck-heading_heading3' },
|
|
671
|
+
{ model: 'heading4', view: 'h4', title: 'Heading 4', class: 'ck-heading_heading4' },
|
|
672
|
+
]
|
|
673
|
+
},
|
|
674
|
+
image: {
|
|
675
|
+
toolbar: [
|
|
676
|
+
'imageStyle:inline',
|
|
677
|
+
'imageStyle:block',
|
|
678
|
+
'imageStyle:side',
|
|
679
|
+
'|',
|
|
680
|
+
'toggleImageCaption',
|
|
681
|
+
'imageTextAlternative'
|
|
682
|
+
]
|
|
683
|
+
},
|
|
684
|
+
table: {
|
|
685
|
+
contentToolbar: [
|
|
686
|
+
'tableColumn',
|
|
687
|
+
'tableRow',
|
|
688
|
+
'mergeTableCells',
|
|
689
|
+
'|',
|
|
690
|
+
'toggleTableCaption'
|
|
691
|
+
]
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
```
|
|
698
|
+
|
|
699
|
+
</details>
|
|
700
|
+
|
|
701
|
+
|
|
702
|
+
|
|
524
703
|
## <a id="requirements"></a>⚠️ Requirements
|
|
525
704
|
___
|
|
526
705
|
Strapi **v4.13.0+**
|