@_sh/strapi-plugin-ckeditor 1.0.8 → 1.1.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 (60) hide show
  1. package/README.md +173 -39
  2. package/admin/src/components/CKEditor/build/ckeditor.js +2 -2
  3. package/admin/src/components/CKEditor/build/ckeditor.js.map +1 -1
  4. package/admin/src/components/CKEditor/build/translations/ar.js +1 -1
  5. package/admin/src/components/CKEditor/build/translations/az.js +1 -1
  6. package/admin/src/components/CKEditor/build/translations/bs.js +1 -1
  7. package/admin/src/components/CKEditor/build/translations/ca.js +1 -1
  8. package/admin/src/components/CKEditor/build/translations/cs.js +1 -1
  9. package/admin/src/components/CKEditor/build/translations/da.js +1 -1
  10. package/admin/src/components/CKEditor/build/translations/de-ch.js +1 -1
  11. package/admin/src/components/CKEditor/build/translations/de.js +1 -1
  12. package/admin/src/components/CKEditor/build/translations/el.js +1 -1
  13. package/admin/src/components/CKEditor/build/translations/en-au.js +1 -1
  14. package/admin/src/components/CKEditor/build/translations/en-gb.js +1 -1
  15. package/admin/src/components/CKEditor/build/translations/es.js +1 -1
  16. package/admin/src/components/CKEditor/build/translations/et.js +1 -1
  17. package/admin/src/components/CKEditor/build/translations/fa.js +1 -1
  18. package/admin/src/components/CKEditor/build/translations/fi.js +1 -1
  19. package/admin/src/components/CKEditor/build/translations/fr.js +1 -1
  20. package/admin/src/components/CKEditor/build/translations/gl.js +1 -1
  21. package/admin/src/components/CKEditor/build/translations/he.js +1 -1
  22. package/admin/src/components/CKEditor/build/translations/hi.js +1 -1
  23. package/admin/src/components/CKEditor/build/translations/hr.js +1 -1
  24. package/admin/src/components/CKEditor/build/translations/hu.js +1 -1
  25. package/admin/src/components/CKEditor/build/translations/id.js +1 -1
  26. package/admin/src/components/CKEditor/build/translations/it.js +1 -1
  27. package/admin/src/components/CKEditor/build/translations/ja.js +1 -1
  28. package/admin/src/components/CKEditor/build/translations/jv.js +1 -1
  29. package/admin/src/components/CKEditor/build/translations/ko.js +1 -1
  30. package/admin/src/components/CKEditor/build/translations/ku.js +1 -1
  31. package/admin/src/components/CKEditor/build/translations/lt.js +1 -1
  32. package/admin/src/components/CKEditor/build/translations/lv.js +1 -1
  33. package/admin/src/components/CKEditor/build/translations/nb.js +1 -1
  34. package/admin/src/components/CKEditor/build/translations/ne.js +1 -1
  35. package/admin/src/components/CKEditor/build/translations/nl.js +1 -1
  36. package/admin/src/components/CKEditor/build/translations/no.js +1 -1
  37. package/admin/src/components/CKEditor/build/translations/pl.js +1 -1
  38. package/admin/src/components/CKEditor/build/translations/pt-br.js +1 -1
  39. package/admin/src/components/CKEditor/build/translations/pt.js +1 -1
  40. package/admin/src/components/CKEditor/build/translations/ro.js +1 -1
  41. package/admin/src/components/CKEditor/build/translations/ru.js +1 -1
  42. package/admin/src/components/CKEditor/build/translations/sk.js +1 -1
  43. package/admin/src/components/CKEditor/build/translations/sl.js +1 -1
  44. package/admin/src/components/CKEditor/build/translations/sq.js +1 -1
  45. package/admin/src/components/CKEditor/build/translations/sr-latn.js +1 -1
  46. package/admin/src/components/CKEditor/build/translations/sr.js +1 -1
  47. package/admin/src/components/CKEditor/build/translations/sv.js +1 -1
  48. package/admin/src/components/CKEditor/build/translations/th.js +1 -1
  49. package/admin/src/components/CKEditor/build/translations/tk.js +1 -1
  50. package/admin/src/components/CKEditor/build/translations/tr.js +1 -1
  51. package/admin/src/components/CKEditor/build/translations/ug.js +1 -1
  52. package/admin/src/components/CKEditor/build/translations/uk.js +1 -1
  53. package/admin/src/components/CKEditor/build/translations/uz.js +1 -1
  54. package/admin/src/components/CKEditor/build/translations/vi.js +1 -1
  55. package/admin/src/components/CKEditor/build/translations/zh-cn.js +1 -1
  56. package/admin/src/components/CKEditor/build/translations/zh.js +1 -1
  57. package/admin/src/components/CKEditor/index.js +159 -123
  58. package/admin/src/components/CKEditor/styles.js +12 -19
  59. package/admin/src/components/CKEditor/theme.js +282 -0
  60. package/package.json +1 -1
package/README.md CHANGED
@@ -18,12 +18,13 @@
18
18
  ## <a id="features"></a>✨ Features
19
19
 
20
20
  * **Lots of default plugins:** for styling text, images, tables and so on.
21
- * **Font color picker:** choose colors for font styling that's not defined in config from the color palette.
21
+ * **Font color picker:** choose color for font styling that's not defined in default palette.
22
22
  * **Upload adapter for Strapi:** for upload images to your library when you drop an image into the editor.
23
23
  * **Fullscreen mode button.**
24
24
  * **Strapi media library button.**
25
25
  * **Supports strapi theme swithing.**
26
26
  * **Supports responsive images:** plugin adds srcset attribute to images based on their `formats` if responsive enable in strapi settings.
27
+ * **Language support:** you can set the preferred language for the UI or the content in the configuration, by default it will use the language defined in the user profile if that language [is supported](https://github.com/nshenderov/strapi-plugin-ckeditor/tree/master/admin/src/components/CKEditor/build/translations).
27
28
 
28
29
  ## <a id="installation"></a>🔧 Installation
29
30
 
@@ -62,23 +63,129 @@ or
62
63
  yarn build
63
64
  ```
64
65
 
66
+ > 💡 `sizes` and `loading` attributes for image can be set in source mode.
67
+ > If you use default upload provider and you want prefix img url with api path you need to add `baseURL` in `api.js` file `(config/api.js)`
68
+
69
+
65
70
  ## <a id="configuration"></a>⚙️ Configuration
66
71
  CKEditor config should be defined in `config.editor` field.
67
72
 
68
73
  Learn more about configuration from [official documentation](https://ckeditor.com/docs/ckeditor5/latest/installation/getting-started/configuration.html).
69
74
 
75
+ <details>
76
+ <summary>(spoiler) <b>Built in plugins:</b> </summary>
77
+
78
+ ```js
79
+ plugins: [
80
+ StrapiUploadAdapter,
81
+ Alignment,
82
+ Autoformat,
83
+ AutoImage,
84
+ AutoLink,
85
+ Autosave,
86
+ BlockQuote,
87
+ Bold,
88
+ Code,
89
+ CodeBlock,
90
+ DataFilter,
91
+ DataSchema,
92
+ Essentials,
93
+ FindAndReplace,
94
+ FontBackgroundColor,
95
+ FontColor,
96
+ FontFamily,
97
+ FontSize,
98
+ GeneralHtmlSupport,
99
+ Heading,
100
+ HeadingButtonsUI,
101
+ ParagraphButtonUI,
102
+ Highlight,
103
+ HorizontalLine,
104
+ HtmlComment,
105
+ HtmlEmbed,
106
+ Image,
107
+ ImageCaption,
108
+ ImageInsert,
109
+ ImageResize,
110
+ ImageStyle,
111
+ ImageToolbar,
112
+ ImageUpload,
113
+ Indent,
114
+ IndentBlock,
115
+ Italic,
116
+ Link,
117
+ LinkImage,
118
+ List,
119
+ ListProperties,
120
+ MediaEmbed,
121
+ MediaEmbedToolbar,
122
+ Mention,
123
+ PageBreak,
124
+ Paragraph,
125
+ PasteFromOffice,
126
+ RemoveFormat,
127
+ SourceEditing,
128
+ SpecialCharacters,
129
+ SpecialCharactersArrows,
130
+ SpecialCharactersCurrency,
131
+ SpecialCharactersEssentials,
132
+ SpecialCharactersLatin,
133
+ SpecialCharactersMathematical,
134
+ SpecialCharactersText,
135
+ StandardEditingMode,
136
+ Strikethrough,
137
+ Subscript,
138
+ Superscript,
139
+ Table,
140
+ TableCaption,
141
+ TableCellProperties,
142
+ TableProperties,
143
+ TableToolbar,
144
+ TextPartLanguage,
145
+ TextTransformation,
146
+ TodoList,
147
+ Underline,
148
+ WordCount,
149
+ Markdown,
150
+ StrapiMediaLib,
151
+ FullScreen
152
+ ]
153
+
154
+ ```
155
+
156
+ </details>
157
+
70
158
  **Default configuration:**
71
159
  ```js
72
160
  // plugins.js
73
161
  module.exports = () => {
74
- return {
162
+ return {
75
163
  ckeditor: {
76
164
  enabled: true,
77
165
  config:{
78
166
  plugin:{
79
- styles:` // styles applied to editor container `
167
+ // disable data-theme tag setting //
168
+ // setAttribute:false,
169
+
170
+ // disable strapi theme, will use default ckeditor theme //
171
+ // strapiTheme:false,
172
+
173
+ // styles applied to editor container (global scope) //
174
+ // styles:`
175
+ // :root{
176
+ // --ck-color-focus-border:red;
177
+ // --ck-color-text:red;
178
+ // }
179
+ // `
80
180
  },
81
181
  editor:{ // editor default config
182
+
183
+ // https://ckeditor.com/docs/ckeditor5/latest/features/markdown.html
184
+ // if you need markdown support and output set: removePlugins: [''],
185
+ // default is
186
+ removePlugins: ['Markdown'],
187
+
188
+ // https://ckeditor.com/docs/ckeditor5/latest/features/toolbar/toolbar.html
82
189
  toolbar: {
83
190
  items: [
84
191
  'paragraph',
@@ -126,6 +233,7 @@ module.exports = () => {
126
233
  'redo'
127
234
  ]
128
235
  },
236
+ // https://ckeditor.com/docs/ckeditor5/latest/features/font.html
129
237
  fontSize: {
130
238
  options: [
131
239
  9,
@@ -137,10 +245,6 @@ module.exports = () => {
137
245
  21,
138
246
  27,
139
247
  35,
140
- "tiny",
141
- "small",
142
- "big",
143
- "huge"
144
248
  ],
145
249
  supportAllValues: false
146
250
  },
@@ -167,7 +271,9 @@ module.exports = () => {
167
271
  columns: 5,
168
272
  documentColors: 10,
169
273
  },
170
- language: 'en',
274
+ // https://ckeditor.com/docs/ckeditor5/latest/features/ui-language.html
275
+ // default language: 'en',
276
+ // https://ckeditor.com/docs/ckeditor5/latest/features/images/images-overview.html
171
277
  image: {
172
278
  resizeUnit: "%",
173
279
  resizeOptions: [ {
@@ -200,6 +306,7 @@ module.exports = () => {
200
306
  'resizeImage:25', 'resizeImage:50', 'resizeImage:75', 'resizeImage:original'
201
307
  ]
202
308
  },
309
+ // https://ckeditor.com/docs/ckeditor5/latest/features/table.html
203
310
  table: {
204
311
  contentToolbar: [
205
312
  'tableColumn',
@@ -210,6 +317,7 @@ module.exports = () => {
210
317
  'toggleTableCaption'
211
318
  ]
212
319
  },
320
+ // https://ckeditor.com/docs/ckeditor5/latest/features/headings.html
213
321
  heading: {
214
322
  options: [
215
323
  { model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph' },
@@ -217,45 +325,46 @@ module.exports = () => {
217
325
  { model: 'heading2', view: 'h2', title: 'Heading 2', class: 'ck-heading_heading2' },
218
326
  { model: 'heading3', view: 'h3', title: 'Heading 3', class: 'ck-heading_heading3' },
219
327
  { model: 'heading4', view: 'h4', title: 'Heading 4', class: 'ck-heading_heading4' },
220
- { model: 'heading5', view: 'h5', title: 'Heading 5', class: 'ck-heading_heading5' },
221
- { model: 'heading6', view: 'h6', title: 'Heading 6', class: 'ck-heading_heading6' },
222
- {
223
- model: 'h1b',
224
- view: {name: 'h1', classes: 'ck-heading_h1_b'}, title: 'H1 (border)', class: 'ck-heading_heading1', converterPriority: 'high'
225
- },
226
- {
227
- model: 'h2b',
228
- view: {name: 'h2', classes: 'ck-heading_h2_b'}, title: 'H2 (border)', class: 'ck-heading_heading2', converterPriority: 'high'
229
- },
230
- {
231
- model: 'h3b',
232
- view: {name: 'h3', classes: 'ck-heading_h3_b'}, title: 'H3 (border)', class: 'ck-heading_heading3', converterPriority: 'high'
233
- }
234
328
  ]
235
- }
329
+ },
330
+ // https://ckeditor.com/docs/ckeditor5/latest/features/general-html-support.html
331
+ // Regular expressions (/.*/ /^(p|h[2-4])$/' etc) for htmlSupport does not allowed in this config
332
+ htmlSupport: {
333
+ allow: [
334
+ {
335
+ name: 'img',
336
+ attributes: {
337
+ sizes:true,
338
+ loading:true,
339
+ }
340
+ },
341
+ ]
342
+ },
236
343
  }
237
344
  }
238
345
  }
239
- }
346
+ }
240
347
  }
241
348
  ```
242
349
  ## <a id="themecustomization"></a>💅 Theme customization
243
- If you want to customize editor styles you should define styles in `config.plugin.styles` field it will replace default styles applied to the editor.
350
+ If you want to customize editor styles you should define styles in `config.plugin.styles` field.
244
351
 
245
352
  Since Strapi resets css styles, it needs some styles to revert back, these styles defined below, also check [official documentation](https://ckeditor.com/docs/ckeditor5/latest/installation/advanced/content-styles.html).
246
353
 
247
- For theme colors switching this plugin uses css variables depending on html data-theme attribute, e.g. `html[data-theme='light']` or `html[data-theme='dark']`
354
+ For theme colors switching this plugin uses css variables depending on html data-theme attribute, e.g. `html[data-theme='light']` or `html[data-theme='dark']` you cand disable it by `setAttribute:false`
355
+
356
+ If you want default ckeditor theme you can set `strapiTheme:false`
248
357
 
249
- [More info about theming](https://ckeditor.com/docs/ckeditor5/latest/framework/guides/deep-dive/ui/theme-customization.html)
358
+ More [info about ckeditor theming](https://ckeditor.com/docs/ckeditor5/latest/framework/guides/deep-dive/ui/theme-customization.html)
250
359
 
251
- [**👔 Default styles**](https://github.com/nshenderov/strapi-plugin-ckeditor/blob/master/admin/src/components/CKEditor/styles.js#L3-L517)
360
+ [**👔 Default styles**](https://github.com/nshenderov/strapi-plugin-ckeditor/blob/master/admin/src/components/CKEditor/styles.js)
252
361
 
253
- [**🎨 Default colour variables**](https://github.com/nshenderov/strapi-plugin-ckeditor/blob/master/assets/theme-colors.css#L105-L333)
362
+ [**🎨 Default theme**](https://github.com/nshenderov/strapi-plugin-ckeditor/blob/master/admin/src/components/CKEditor/theme.js)
254
363
 
255
364
  **Example of customization:**
256
365
  ```js
257
366
  // plugins.js
258
- const defStyles = require('./styles.js')
367
+ const styles = require('./styles.js')
259
368
 
260
369
  module.exports = () => {
261
370
  return {
@@ -263,10 +372,31 @@ module.exports = () => {
263
372
  enabled: true,
264
373
  config:{
265
374
  plugin:{
266
- // styles applied to editor container
375
+ // disable data-theme tag setting //
376
+ // setAttribute:false,
377
+
378
+ // disable strapi theme, will use default ckeditor theme //
379
+ // strapiTheme:false,
380
+
381
+ // styles applied to editor container, e.g:
267
382
  styles:`
268
- ${defStyles()}
269
- --ck-color-editor-base-text:red;
383
+ ${styles()}
384
+ .ck-editor__styled__container{
385
+ background:red;
386
+ }
387
+ html[data-theme='light'] {
388
+ --ck-scroll-track-background:red;
389
+ --ck-scroll-thumb-background:red;
390
+ --ck-scroll-thumb-border-color:red;
391
+ --ck-scroll-thumb-hover-background:red;
392
+ --ck-scroll-thumb-active-background:red;
393
+ --ck-color-base-border: red;
394
+ --ck-color-base-background:red;
395
+ --ck-custom-background: red;
396
+ --ck-custom-foreground: red;
397
+ --ck-custom-border: red;
398
+ --ck-custom-white: red;
399
+ }
270
400
  `
271
401
  },
272
402
  // editor default config
@@ -279,17 +409,21 @@ module.exports = () => {
279
409
  }
280
410
 
281
411
  // styles.js
282
- const defStyles = () =>`
283
-
284
- ### All default styles ###
285
- `
286
- module.exports = defStyles;
412
+ const styles = () =>`
413
+ .ck.ck-editor__main .ck-blurred{
414
+ max-height: 200px;
415
+ }
416
+ .ck.ck-editor__main .ck-focused{
417
+ max-height: 500px;
418
+ }
419
+ `
420
+ module.exports = styles;
287
421
  ```
288
422
 
289
423
  ## <a id="requirements"></a>⚠️ Requirements
290
424
  Strapi **v4**
291
425
 
292
- Tested on **v4.18 - 4.19**
426
+ Tested on **v4.18 - 4.2.3**
293
427
 
294
428
  ## <a id="thanks"></a>👍 This build includes some useful plugins based on these repos so thanks to them:
295
429
  https://github.com/Roslovets-Inc/strapi-plugin-ckeditor5