@_sh/strapi-plugin-ckeditor 1.0.9 → 1.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/README.md +78 -105
- package/admin/src/components/CKEditor/build/ckeditor.js +1 -1
- package/admin/src/components/CKEditor/build/ckeditor.js.map +1 -1
- package/admin/src/components/CKEditor/index.js +140 -134
- package/admin/src/components/CKEditor/styles.js +12 -62
- package/admin/src/components/CKEditor/theme.js +282 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
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.
|
|
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).
|
|
28
28
|
|
|
29
29
|
## <a id="installation"></a>🔧 Installation
|
|
30
30
|
|
|
@@ -63,6 +63,10 @@ or
|
|
|
63
63
|
yarn build
|
|
64
64
|
```
|
|
65
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
|
+
|
|
66
70
|
## <a id="configuration"></a>⚙️ Configuration
|
|
67
71
|
CKEditor config should be defined in `config.editor` field.
|
|
68
72
|
|
|
@@ -81,7 +85,6 @@ AutoLink,
|
|
|
81
85
|
Autosave,
|
|
82
86
|
BlockQuote,
|
|
83
87
|
Bold,
|
|
84
|
-
CloudServices,
|
|
85
88
|
Code,
|
|
86
89
|
CodeBlock,
|
|
87
90
|
DataFilter,
|
|
@@ -156,17 +159,32 @@ FullScreen
|
|
|
156
159
|
```js
|
|
157
160
|
// plugins.js
|
|
158
161
|
module.exports = () => {
|
|
159
|
-
|
|
162
|
+
return {
|
|
160
163
|
ckeditor: {
|
|
161
164
|
enabled: true,
|
|
162
165
|
config:{
|
|
163
166
|
plugin:{
|
|
164
|
-
|
|
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
|
+
// `
|
|
165
180
|
},
|
|
166
181
|
editor:{ // editor default config
|
|
182
|
+
|
|
167
183
|
// https://ckeditor.com/docs/ckeditor5/latest/features/markdown.html
|
|
168
|
-
// if you need markdown support and output set
|
|
169
|
-
// default is
|
|
184
|
+
// if you need markdown support and output set: removePlugins: [''],
|
|
185
|
+
// default is
|
|
186
|
+
removePlugins: ['Markdown'],
|
|
187
|
+
|
|
170
188
|
// https://ckeditor.com/docs/ckeditor5/latest/features/toolbar/toolbar.html
|
|
171
189
|
toolbar: {
|
|
172
190
|
items: [
|
|
@@ -227,10 +245,6 @@ module.exports = () => {
|
|
|
227
245
|
21,
|
|
228
246
|
27,
|
|
229
247
|
35,
|
|
230
|
-
"tiny",
|
|
231
|
-
"small",
|
|
232
|
-
"big",
|
|
233
|
-
"huge"
|
|
234
248
|
],
|
|
235
249
|
supportAllValues: false
|
|
236
250
|
},
|
|
@@ -311,111 +325,45 @@ module.exports = () => {
|
|
|
311
325
|
{ model: 'heading2', view: 'h2', title: 'Heading 2', class: 'ck-heading_heading2' },
|
|
312
326
|
{ model: 'heading3', view: 'h3', title: 'Heading 3', class: 'ck-heading_heading3' },
|
|
313
327
|
{ model: 'heading4', view: 'h4', title: 'Heading 4', class: 'ck-heading_heading4' },
|
|
314
|
-
{ model: 'heading5', view: 'h5', title: 'Heading 5', class: 'ck-heading_heading5' },
|
|
315
|
-
{ model: 'heading6', view: 'h6', title: 'Heading 6', class: 'ck-heading_heading6' },
|
|
316
|
-
{
|
|
317
|
-
model: 'h1b',
|
|
318
|
-
view: {name: 'h1', classes: 'ck-heading_h1_b'},
|
|
319
|
-
title: 'H1 (border)',
|
|
320
|
-
class: 'ck-heading_heading1',
|
|
321
|
-
converterPriority: 'high'
|
|
322
|
-
},
|
|
323
|
-
{
|
|
324
|
-
model: 'h2b',
|
|
325
|
-
view: {name: 'h2', classes: 'ck-heading_h2_b'},
|
|
326
|
-
title: 'H2 (border)',
|
|
327
|
-
class: 'ck-heading_heading2',
|
|
328
|
-
converterPriority: 'high'
|
|
329
|
-
},
|
|
330
|
-
{
|
|
331
|
-
model: 'h3b',
|
|
332
|
-
view: {name: 'h3', classes: 'ck-heading_h3_b'},
|
|
333
|
-
title: 'H3 (border)',
|
|
334
|
-
class: 'ck-heading_heading3',
|
|
335
|
-
converterPriority: 'high'
|
|
336
|
-
},
|
|
337
|
-
{ model: 'custom',
|
|
338
|
-
view: {name: 'custom', classes: 'Heading 1'},
|
|
339
|
-
title: 'custom',
|
|
340
|
-
class: 'ck-heading_heading3',
|
|
341
|
-
converterPriority: 'high'
|
|
342
|
-
}
|
|
343
328
|
]
|
|
344
329
|
},
|
|
345
330
|
// https://ckeditor.com/docs/ckeditor5/latest/features/general-html-support.html
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
// },
|
|
358
|
-
|
|
359
|
-
// // Enables <div>s with all inline styles (but no other attributes).
|
|
360
|
-
// {
|
|
361
|
-
// name: 'div',
|
|
362
|
-
// styles: true
|
|
363
|
-
// },
|
|
364
|
-
|
|
365
|
-
// // Enables <div>s with foo and bar classes.
|
|
366
|
-
// {
|
|
367
|
-
// name: 'div',
|
|
368
|
-
// classes: [ 'foo', 'bar' ]
|
|
369
|
-
// },
|
|
370
|
-
|
|
371
|
-
// // Adds support for `foo` and `bar` classes to the already supported
|
|
372
|
-
// // <p> elements (those are enabled by the dedicated paragraph feature).
|
|
373
|
-
// {
|
|
374
|
-
// name: 'p',
|
|
375
|
-
// classes: [ 'foo', 'bar' ]
|
|
376
|
-
// },
|
|
377
|
-
|
|
378
|
-
// // Enables <div>s with foo="true" attribute and bar attribute that
|
|
379
|
-
// // can accept any value (boolean `true` value works as an asterisk).
|
|
380
|
-
// {
|
|
381
|
-
// name: 'div',
|
|
382
|
-
// attributes: {
|
|
383
|
-
// foo: 'true',
|
|
384
|
-
// bar: true
|
|
385
|
-
// }
|
|
386
|
-
// },
|
|
387
|
-
|
|
388
|
-
// // Adds support for style="color: *" to the already supported
|
|
389
|
-
// // <p> and <h2-h4> elements.
|
|
390
|
-
// {
|
|
391
|
-
// name: `/^(p|h[2-4])$/'`,
|
|
392
|
-
// styles: { 'color': true }
|
|
393
|
-
// },
|
|
394
|
-
// ]
|
|
395
|
-
// },
|
|
331
|
+
htmlSupport: {
|
|
332
|
+
allow: [
|
|
333
|
+
{
|
|
334
|
+
name: 'img',
|
|
335
|
+
attributes: {
|
|
336
|
+
sizes:true,
|
|
337
|
+
loading:true,
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
]
|
|
341
|
+
},
|
|
396
342
|
}
|
|
397
343
|
}
|
|
398
344
|
}
|
|
399
|
-
|
|
345
|
+
}
|
|
400
346
|
}
|
|
401
347
|
```
|
|
402
348
|
## <a id="themecustomization"></a>💅 Theme customization
|
|
403
|
-
If you want to customize editor styles you should define styles in `config.plugin.styles` field
|
|
349
|
+
If you want to customize editor styles you should define styles in `config.plugin.styles` field.
|
|
404
350
|
|
|
405
351
|
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).
|
|
406
352
|
|
|
407
|
-
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']`
|
|
353
|
+
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`
|
|
408
354
|
|
|
409
|
-
|
|
355
|
+
If you want default ckeditor theme you can set `strapiTheme:false`
|
|
410
356
|
|
|
411
|
-
[
|
|
357
|
+
More [info about ckeditor theming](https://ckeditor.com/docs/ckeditor5/latest/framework/guides/deep-dive/ui/theme-customization.html)
|
|
412
358
|
|
|
413
|
-
[
|
|
359
|
+
[**👔 Default styles**](https://github.com/nshenderov/strapi-plugin-ckeditor/blob/master/admin/src/components/CKEditor/styles.js)
|
|
360
|
+
|
|
361
|
+
[**🎨 Default theme**](https://github.com/nshenderov/strapi-plugin-ckeditor/blob/master/admin/src/components/CKEditor/theme.js)
|
|
414
362
|
|
|
415
363
|
**Example of customization:**
|
|
416
364
|
```js
|
|
417
365
|
// plugins.js
|
|
418
|
-
const
|
|
366
|
+
const styles = require('./styles.js')
|
|
419
367
|
|
|
420
368
|
module.exports = () => {
|
|
421
369
|
return {
|
|
@@ -423,10 +371,31 @@ module.exports = () => {
|
|
|
423
371
|
enabled: true,
|
|
424
372
|
config:{
|
|
425
373
|
plugin:{
|
|
426
|
-
//
|
|
374
|
+
// disable data-theme tag setting //
|
|
375
|
+
// setAttribute:false,
|
|
376
|
+
|
|
377
|
+
// disable strapi theme, will use default ckeditor theme //
|
|
378
|
+
// strapiTheme:false,
|
|
379
|
+
|
|
380
|
+
// styles applied to editor container, e.g:
|
|
427
381
|
styles:`
|
|
428
|
-
${
|
|
429
|
-
|
|
382
|
+
${styles()}
|
|
383
|
+
.ck-editor__styled__container{
|
|
384
|
+
background:red;
|
|
385
|
+
}
|
|
386
|
+
html[data-theme='light'] {
|
|
387
|
+
--ck-scroll-track-background:red;
|
|
388
|
+
--ck-scroll-thumb-background:red;
|
|
389
|
+
--ck-scroll-thumb-border-color:red;
|
|
390
|
+
--ck-scroll-thumb-hover-background:red;
|
|
391
|
+
--ck-scroll-thumb-active-background:red;
|
|
392
|
+
--ck-color-base-border: red;
|
|
393
|
+
--ck-color-base-background:red;
|
|
394
|
+
--ck-custom-background: red;
|
|
395
|
+
--ck-custom-foreground: red;
|
|
396
|
+
--ck-custom-border: red;
|
|
397
|
+
--ck-custom-white: red;
|
|
398
|
+
}
|
|
430
399
|
`
|
|
431
400
|
},
|
|
432
401
|
// editor default config
|
|
@@ -439,17 +408,21 @@ module.exports = () => {
|
|
|
439
408
|
}
|
|
440
409
|
|
|
441
410
|
// styles.js
|
|
442
|
-
const
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
411
|
+
const styles = () =>`
|
|
412
|
+
.ck.ck-editor__main .ck-blurred{
|
|
413
|
+
max-height: 200px;
|
|
414
|
+
}
|
|
415
|
+
.ck.ck-editor__main .ck-focused{
|
|
416
|
+
max-height: 500px;
|
|
417
|
+
}
|
|
418
|
+
`
|
|
419
|
+
module.exports = styles;
|
|
447
420
|
```
|
|
448
421
|
|
|
449
422
|
## <a id="requirements"></a>⚠️ Requirements
|
|
450
423
|
Strapi **v4**
|
|
451
424
|
|
|
452
|
-
Tested on **v4.18 - 4.
|
|
425
|
+
Tested on **v4.18 - 4.1.11**
|
|
453
426
|
|
|
454
427
|
## <a id="thanks"></a>👍 This build includes some useful plugins based on these repos so thanks to them:
|
|
455
428
|
https://github.com/Roslovets-Inc/strapi-plugin-ckeditor5
|