@_sh/strapi-plugin-ckeditor 2.1.3 → 3.0.1

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.
Files changed (44) hide show
  1. package/README.md +376 -197
  2. package/admin/src/Input/components/Editor.js +133 -0
  3. package/admin/src/{components/Input/MediaLib/index.js → Input/components/MediaLib.js} +20 -23
  4. package/admin/src/Input/config/index.js +2 -0
  5. package/admin/src/Input/config/language.js +45 -0
  6. package/admin/src/Input/config/plugins.js +24 -0
  7. package/admin/src/Input/config/presets.js +18 -0
  8. package/admin/src/Input/config/styling.js +30 -0
  9. package/admin/src/Input/index.js +67 -0
  10. package/admin/src/{components/Input/CKEditor → Input}/plugins/StrapiMediaLib.js +8 -10
  11. package/admin/src/{components/Input/CKEditor → Input}/plugins/StrapiUploadAdapter.js +16 -34
  12. package/admin/src/{components/Input/CKEditor → Input}/plugins/index.js +1 -1
  13. package/admin/src/Input/presets/colors.js +122 -0
  14. package/admin/src/Input/presets/default.js +378 -0
  15. package/admin/src/Input/presets/index.js +7 -0
  16. package/admin/src/Input/theme/additional.js +189 -0
  17. package/admin/src/{components/Input/CKEditor → Input}/theme/common.js +18 -20
  18. package/admin/src/{components/Input/CKEditor → Input}/theme/dark.js +22 -18
  19. package/admin/src/{components/Input/CKEditor → Input}/theme/light.js +22 -17
  20. package/admin/src/index.js +76 -106
  21. package/admin/src/pluginId.js +7 -0
  22. package/admin/src/utils/exportToGlobal.js +8 -0
  23. package/admin/src/utils/{getEditorConfig.js → getPluginConfig.js} +10 -12
  24. package/admin/src/utils/getPresetsOptions.js +38 -0
  25. package/package.json +6 -83
  26. package/server/controllers/config.js +13 -11
  27. package/server/controllers/index.js +3 -3
  28. package/server/register.js +1 -1
  29. package/server/routes/index.js +7 -12
  30. package/server/services/config.js +16 -11
  31. package/server/services/index.js +3 -3
  32. package/admin/src/components/Input/CKEditor/configs/base.js +0 -639
  33. package/admin/src/components/Input/CKEditor/configs/blockBalloon.js +0 -25
  34. package/admin/src/components/Input/CKEditor/configs/index.js +0 -11
  35. package/admin/src/components/Input/CKEditor/configs/toolbar.js +0 -17
  36. package/admin/src/components/Input/CKEditor/configs/toolbarBalloon.js +0 -17
  37. package/admin/src/components/Input/CKEditor/configuration.js +0 -167
  38. package/admin/src/components/Input/CKEditor/index.js +0 -119
  39. package/admin/src/components/Input/CKEditor/styling.js +0 -24
  40. package/admin/src/components/Input/CKEditor/theme/additional.js +0 -187
  41. package/admin/src/components/Input/index.js +0 -48
  42. package/admin/src/utils/pluginId.js +0 -5
  43. /package/admin/src/{components/CKEditorIcon.js → CKEditorIcon.js} +0 -0
  44. /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,7 +23,6 @@
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
 
@@ -60,74 +60,58 @@ yarn build
60
60
 
61
61
  ## <a id="usage"></a>✍️ Usage
62
62
 
63
- 1. Go to the Content-Type Builder -> Add another field -> switch to `custom`
64
-
65
- <p align="center">
66
- <img src="https://raw.githubusercontent.com/nshenderov/strapi-plugin-ckeditor/master/assets/usage-guide1.png" width="700" />
67
- </p>
68
-
69
- 2. Click on CKEditor 5
70
-
71
63
  <p align="center">
72
- <img src="https://raw.githubusercontent.com/nshenderov/strapi-plugin-ckeditor/master/assets/usage-guide2.png" width="700" />
64
+ <img src="https://raw.githubusercontent.com/nshenderov/strapi-plugin-ckeditor/master/assets/usage-guide.gif" width="700" />
73
65
  </p>
74
66
 
75
- 3. Choose the editor version you want
76
-
77
- <p align="center">
78
- <img src="https://raw.githubusercontent.com/nshenderov/strapi-plugin-ckeditor/master/assets/usage-guide3.png" width="700" />
79
- </p>
80
-
81
- ## Default versions:
82
-
83
67
  <details>
84
- <summary><b>Open</b></summary>
68
+ <summary><b>Default preset:</b></summary>
85
69
 
86
70
  <p align="center">
87
- <img src="https://raw.githubusercontent.com/nshenderov/strapi-plugin-ckeditor/master/assets/toolbar-version.png" width="700" />
88
- </p>
89
-
90
- <p align="center">
91
- <img src="https://raw.githubusercontent.com/nshenderov/strapi-plugin-ckeditor/master/assets/toolbarballon-version.png" width="700" />
92
- </p>
93
-
94
- <p align="center">
95
- <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" />
96
72
  </p>
97
73
 
98
74
  </details>
99
75
 
100
76
  ## <a id="configuration"></a>⚙️ Configuration
101
77
  ___
102
- 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).
103
78
 
104
- 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`
105
82
 
106
- The plugin configuration should be defined in `your-app/config/ckeditor.txt`.
83
+ By default, the plugin provides one preset, which can be modified in the config file.
107
84
 
108
- The plugin provides three editor configurations by default. Each configuration includes a set of plugins, settings, and styles.
85
+ You can also add new presets in the config file.
109
86
 
110
- You can select the configuration you need in the Content-Type Builder. Each configuration can be modified in the config file, and you can also create new ones.
87
+ The plugin exposes all CKEditor packages to the global variable SH_CKE.
111
88
 
112
- Config structure looks like this:
89
+ The config file must define a function called CKEConfig that returns the configuration object.
90
+
91
+ The structure of the configuration object is as follows:
113
92
 
114
93
  ```js
115
- globalThis.CKEditorConfig = {
116
- configsOverwrite:bool,
117
- themeOverwrite:bool,
118
- configs:{
119
- toolbar:{...},
120
- toolbarBalloon:{...},
121
- blockBalloon:{...},
122
- customEditorVersion1:{...},
123
- customEditorVersion2:{...}
94
+ {
95
+ dontMergePresets:bool,
96
+ dontMergeTheme:bool,
97
+ presets:{
98
+ default:{
99
+ field:{...},
100
+ styles:string,
101
+ editorConfig:{...},
102
+ },
124
103
  ...
125
104
  }
126
- theme:{...}
105
+ theme:{
106
+ common:string,
107
+ light:string,
108
+ dark:string,
109
+ additional:string,
110
+ }
127
111
  }
128
112
  ```
129
113
 
130
- Every configuration in the `configs` object contains three properties:
114
+ Every preset in the `presets` object contains three properties:
131
115
 
132
116
  1. `field (object)` Registers this configuration version in the Admin panel.
133
117
  2. `styles (string)` Styles applied to the editor in this version.
@@ -145,8 +129,8 @@ By default, everything defined in the user’s configuration is merged with the
145
129
  default configuration object. These two properties allow you to prevent
146
130
  this behavior:
147
131
 
148
- 1. `configsOverwrite (bool)`
149
- 2. `themeOverwrite (bool)`
132
+ 1. `dontMergePresets (bool)`
133
+ 2. `dontMergeTheme (bool)`
150
134
 
151
135
  Since Strapi uses i18n for translation, the `ignorei18n` property is added to the
152
136
  `editorConfig.language` object. This property allows you to manually set the
@@ -170,45 +154,45 @@ The language determination follows this logic:
170
154
  **Example of adding a new editor configuration:**
171
155
 
172
156
  <details>
173
- <summary><b>ckeditor.txt</b></summary>
157
+ <summary><b>ckeditor.js</b></summary>
174
158
 
175
159
  ```js
176
- globalThis.CKEditorConfig = {
177
- configs:{
178
- myCustomVariant:{
160
+ const CKEConfig = () => ({
161
+ presets:{
162
+ myCustomPreset:{
179
163
  field: {
180
- key: "myCustomVariant",
181
- value: "myCustomVariant",
164
+ key: "myCustomPreset",
165
+ value: "myCustomPreset",
182
166
  metadatas: {
183
167
  intlLabel: {
184
- id: "ckeditor5.preset.myCustomVariant.label",
185
- defaultMessage: "My custom variant",
168
+ id: "ckeditor5.preset.myCustomPreset.label",
169
+ defaultMessage: "My custom preset",
186
170
  },
187
171
  },
188
172
  },
189
173
  editorConfig:{
190
174
  plugins: [
191
- CKEditor5.autoformat.Autoformat,
192
- CKEditor5.basicStyles.Bold,
193
- CKEditor5.basicStyles.Italic,
194
- CKEditor5.essentials.Essentials,
195
- CKEditor5.heading.Heading,
196
- CKEditor5.image.Image,
197
- CKEditor5.image.ImageCaption,
198
- CKEditor5.image.ImageStyle,
199
- CKEditor5.image.ImageToolbar,
200
- CKEditor5.image.ImageUpload,
201
- CKEditor5.indent.Indent,
202
- CKEditor5.link.Link,
203
- CKEditor5.list.List,
204
- CKEditor5.paragraph.Paragraph,
205
- CKEditor5.pasteFromOffice.PasteFromOffice,
206
- CKEditor5.table.Table,
207
- CKEditor5.table.TableToolbar,
208
- CKEditor5.table.TableColumnResize,
209
- CKEditor5.table.TableCaption,
210
- CKEditor5.strapiPlugins.StrapiMediaLib,
211
- CKEditor5.strapiPlugins.StrapiUploadAdapter,
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,
212
196
  ],
213
197
  toolbar: [
214
198
  'heading',
@@ -250,20 +234,20 @@ globalThis.CKEditorConfig = {
250
234
  }
251
235
  }
252
236
  }
253
- }
237
+ })
254
238
  ```
255
239
 
256
240
  </details>
257
241
 
258
- **Example of changing buttons, modifying the plugin list, and adding styles in the default toolbar configuration:**
242
+ **Example of changing buttons, modifying the plugin list, and adding styles in the default preset:**
259
243
 
260
244
  <details>
261
- <summary><b>ckeditor.txt</b></summary>
245
+ <summary><b>ckeditor.js</b></summary>
262
246
 
263
247
  ```js
264
- globalThis.CKEditorConfig = {
265
- configs:{
266
- toolbar:{
248
+ const CKEConfig = () => ({
249
+ presets:{
250
+ default:{
267
251
  styles:`
268
252
  --ck-focus-ring:3px dashed #5CB176;
269
253
 
@@ -283,19 +267,19 @@ globalThis.CKEditorConfig = {
283
267
  `,
284
268
  editorConfig:{
285
269
  plugins: [
286
- CKEditor5.basicStyles.Bold,
287
- CKEditor5.basicStyles.Italic,
288
- CKEditor5.essentials.Essentials,
289
- CKEditor5.heading.Heading,
290
- CKEditor5.image.Image,
291
- CKEditor5.image.ImageCaption,
292
- CKEditor5.image.ImageStyle,
293
- CKEditor5.image.ImageToolbar,
294
- CKEditor5.link.Link,
295
- CKEditor5.list.List,
296
- CKEditor5.paragraph.Paragraph,
297
- CKEditor5.strapiPlugins.StrapiMediaLib,
298
- CKEditor5.strapiPlugins.StrapiUploadAdapter,
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,
299
283
  ],
300
284
  toolbar: [
301
285
  'heading',
@@ -309,39 +293,70 @@ globalThis.CKEditorConfig = {
309
293
  }
310
294
  }
311
295
  }
312
- }
296
+ })
313
297
  ```
314
298
 
315
299
  </details>
316
300
 
317
- > 📂 Configurations availibale by default: [**admin/src/components/Input/CKEditor/configs**](https://github.com/nshenderov/strapi-plugin-ckeditor/blob/master/admin/src/components/Input/CKEditor/configs)
318
-
319
- > 📂 Built-in plugins: [**admin/src/components/Input/CKEditor/configs/base.js**](https://github.com/nshenderov/strapi-plugin-ckeditor/blob/master/admin/src/components/Input/CKEditor/configs/base.js)
301
+ > 📂 Default preset: [**admin/src/Input/presets/default.js**](https://github.com/nshenderov/strapi-plugin-ckeditor/blob/master/admin/src/Input/presets/default.js)
320
302
 
321
- > 📂 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)
322
304
 
323
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)
324
306
 
325
307
  ## Adding plugins
326
308
 
327
309
  ___
328
- Exmple of adding the Markdown plugin
329
310
 
330
- Add the plugin to you Strapi application:
311
+ Your plugin must be available in the `global`.
312
+
313
+ **Example of adding the Timestamp plugin:**
314
+
315
+ 1. Create the plugin:
331
316
 
332
317
  ```js
333
- yarn add @ckeditor/ckeditor5-markdown-gfm
334
- ```
335
- or
336
- ```js
337
- npm install @ckeditor/ckeditor5-markdown-gfm
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;
338
352
  ```
339
353
 
340
- Import the plugin in `your-app/src/admin/app.js`:
354
+ 2. Import the plugin:
341
355
 
342
356
  ```js
343
- import ckeditor5Dll from "ckeditor5/build/ckeditor5-dll.js";
344
- import ckeditor5MrkdownDll from "@ckeditor/ckeditor5-markdown-gfm/build/markdown-gfm.js";
357
+ // your-app/src/admin/app.js
358
+
359
+ import './timestamp.js'
345
360
 
346
361
  const config = {};
347
362
 
@@ -354,110 +369,74 @@ export default {
354
369
 
355
370
  ```
356
371
 
357
- Add a new configuration option to your config file at `your-app/config/ckeditor.txt`:
358
-
359
- **Example of a config file with the new configuration:**
372
+ 3. Add the new plugin to your preset:
360
373
 
361
374
  <details>
362
- <summary><b>ckeditor.txt</b></summary>
375
+ <summary><b>ckeditor.js</b></summary>
363
376
 
364
377
  ```js
365
- globalThis.CKEditorConfig = {
366
- configs:{
367
- markdown:{
378
+ // your-app/config/ckeditor.js
379
+
380
+ const CKEConfig = () => ({
381
+ presets: {
382
+ myCustomPreset:{
368
383
  field: {
369
- key: "markdown",
370
- value: "markdown",
384
+ key: "myCustomPreset",
385
+ value: "myCustomPreset",
371
386
  metadatas: {
372
- intlLabel: {
373
- id: "ckeditor.preset.markdown.label",
374
- defaultMessage: "Markdown version",
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
- CKEditor5.essentials.Essentials,
382
- CKEditor5.autoformat.Autoformat,
383
- CKEditor5.blockQuote.BlockQuote,
384
- CKEditor5.basicStyles.Bold,
385
- CKEditor5.heading.Heading,
386
- CKEditor5.image.Image,
387
- CKEditor5.image.ImageCaption,
388
- CKEditor5.image.ImageStyle,
389
- CKEditor5.image.ImageToolbar,
390
- CKEditor5.image.ImageUpload,
391
- CKEditor5.indent.Indent,
392
- CKEditor5.basicStyles.Italic,
393
- CKEditor5.link.Link,
394
- CKEditor5.list.List,
395
- CKEditor5.mediaEmbed.MediaEmbed,
396
- CKEditor5.paragraph.Paragraph,
397
- CKEditor5.table.Table,
398
- CKEditor5.table.TableToolbar,
399
- CKEditor5.sourceEditing.SourceEditing,
400
- CKEditor5.strapiPlugins.StrapiMediaLib,
401
- CKEditor5.strapiPlugins.StrapiUploadAdapter,
402
- CKEditor5.markdownGfm.Markdown,
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
- items: [
411
- 'heading',
412
- '|',
413
- 'bold',
414
- 'italic',
415
- 'strikethrough',
416
- 'link',
417
- '|',
418
- 'bulletedList',
419
- 'numberedList',
420
- 'todoList',
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
- }
454
- }
431
+ },
432
+ }
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+**