@_sh/strapi-plugin-ckeditor 2.0.2 → 2.0.4
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 +448 -448
- package/admin/src/components/CKEditorIcon.js +45 -45
- package/admin/src/components/Input/CKEditor/configs/base.js +627 -627
- package/admin/src/components/Input/CKEditor/configs/blockBaloon.js +25 -25
- 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/toolbarBaloon.js +17 -17
- package/admin/src/components/Input/CKEditor/configuration.js +165 -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 +212 -166
- package/admin/src/components/Input/CKEditor/theme/common.js +232 -277
- 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 +78 -78
- package/admin/src/components/Input/index.js +47 -47
- package/admin/src/index.js +109 -109
- package/admin/src/utils/getEditorConfig.js +37 -37
- package/admin/src/utils/pluginId.js +4 -4
- package/package.json +86 -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/README.md
CHANGED
|
@@ -1,448 +1,448 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<img src="https://raw.githubusercontent.com/nshenderov/strapi-plugin-ckeditor/master/assets/ckeditor5_2_0.png" width="700" />
|
|
3
|
-
</p>
|
|
4
|
-
|
|
5
|
-
<h1 align="center">CKEditor 5 for Strapi</h1>
|
|
6
|
-
|
|
7
|
-
<p align="center">Integrates CKEditor 5 into your Strapi project as a fully customizable custom field. (Unofficial integration)</p>
|
|
8
|
-
|
|
9
|
-
## 👋 Get Started
|
|
10
|
-
|
|
11
|
-
* [Features](#features)
|
|
12
|
-
* [Installation](#installation)
|
|
13
|
-
* [Configuration](#configuration)
|
|
14
|
-
* [Contributing](#contributing)
|
|
15
|
-
* [Requirements](#requirements)
|
|
16
|
-
|
|
17
|
-
## <a id="features"></a>✨ Features
|
|
18
|
-
|
|
19
|
-
* **Media library integration**
|
|
20
|
-
* **Supports responsive images**
|
|
21
|
-
* **Supports Strapi's theme switching with the possibility to define your own theme**
|
|
22
|
-
* **Supports i18n for content and user's preferred language for UI**
|
|
23
|
-
* **Few predefined editor configs with the possibility to add your owns**
|
|
24
|
-
* **Possible to add new plugins**
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
## <a id="installation"></a>🔧 Installation
|
|
28
|
-
___
|
|
29
|
-
|
|
30
|
-
* Inside your Strapi app, add the package:
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
npm install @_sh/strapi-plugin-ckeditor
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
or
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
yarn add @_sh/strapi-plugin-ckeditor
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
* Then run build:
|
|
43
|
-
```bash
|
|
44
|
-
npm run build
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
or
|
|
48
|
-
```bash
|
|
49
|
-
yarn build
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
## <a id="configuration"></a>⚙️ Configuration
|
|
55
|
-
___
|
|
56
|
-
The plugin is based on [**Strapi's custom fields**](https://docs.strapi.io/developer-docs/latest/development/custom-fields.html#registering-a-custom-field-on-the-server) and [**CKEditor dll build**](https://ckeditor.com/docs/ckeditor5/latest/installation/advanced/alternative-setups/dll-builds.html)
|
|
57
|
-
|
|
58
|
-
Plugin configuration should be defined in the `/config/ckeditor.txt` file.
|
|
59
|
-
|
|
60
|
-
It's highly recommended to explore [**the official ckeditor documentation**](https://ckeditor.com/docs/ckeditor5/latest/features/index.html)
|
|
61
|
-
|
|
62
|
-
Content from ckeditor.txt will be passed into a script tag through the initialization process.
|
|
63
|
-
|
|
64
|
-
> 📂 Default configs: [**admin/src/components/Input/CKEditor/configs**](https://github.com/nshenderov/strapi-plugin-ckeditor/blob/master/admin/src/components/Input/CKEditor/configs)
|
|
65
|
-
|
|
66
|
-
> 📂 Default theme: [**admin/src/components/Input/CKEditor/theme**](https://github.com/nshenderov/strapi-plugin-ckeditor/blob/master/admin/src/components/Input/CKEditor/theme)
|
|
67
|
-
|
|
68
|
-
**ckeditor.txt example:**
|
|
69
|
-
|
|
70
|
-
```js
|
|
71
|
-
globalThis.CKEditorConfig = {
|
|
72
|
-
|
|
73
|
-
/* By default configs and theme
|
|
74
|
-
objects will be spread with
|
|
75
|
-
default configs and theme
|
|
76
|
-
these two properties specified below
|
|
77
|
-
allow you to redefine
|
|
78
|
-
default objects completely: */
|
|
79
|
-
|
|
80
|
-
//configsOverwrite:true,
|
|
81
|
-
//themeOverwrite:true,
|
|
82
|
-
|
|
83
|
-
/* Here you can redefine default configs
|
|
84
|
-
or add completely new ones.
|
|
85
|
-
Each config includes:
|
|
86
|
-
"styles", "field" and "editorConfig" properties.
|
|
87
|
-
Property "field" is required. */
|
|
88
|
-
|
|
89
|
-
configs:{
|
|
90
|
-
toolbar:{
|
|
91
|
-
// styles:``,
|
|
92
|
-
// field:{},
|
|
93
|
-
// editorConfig:{}
|
|
94
|
-
},
|
|
95
|
-
custom:{
|
|
96
|
-
|
|
97
|
-
/* Styles for this specific editor.
|
|
98
|
-
This will be passed into the editor's parent container. */
|
|
99
|
-
|
|
100
|
-
styles:`
|
|
101
|
-
// --ck-focus-ring:3px dashed #5CB176;
|
|
102
|
-
|
|
103
|
-
// .ck.ck-content.ck-editor__editable {
|
|
104
|
-
// &.ck-focused:not(.ck-editor__nested-editable) {
|
|
105
|
-
// border: var(--ck-focus-ring) !important;
|
|
106
|
-
// }
|
|
107
|
-
// }
|
|
108
|
-
// .ck.ck-content.ck-editor__editable.ck-rounded-corners.ck-editor__editable_inline.ck-blurred{
|
|
109
|
-
// min-height: 400px;
|
|
110
|
-
// max-height: 400px;
|
|
111
|
-
// }
|
|
112
|
-
// .ck.ck-content.ck-editor__editable.ck-rounded-corners.ck-editor__editable_inline.ck-focused{
|
|
113
|
-
// min-height: 400px;
|
|
114
|
-
// max-height: 1700px;
|
|
115
|
-
// }
|
|
116
|
-
`,
|
|
117
|
-
|
|
118
|
-
/* Custom field option */
|
|
119
|
-
field: {
|
|
120
|
-
key: "custom",
|
|
121
|
-
value: "custom",
|
|
122
|
-
metadatas: {
|
|
123
|
-
intlLabel: {
|
|
124
|
-
id: "ckeditor5.preset.custom.label",
|
|
125
|
-
defaultMessage: "Custom version",
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
},
|
|
129
|
-
/* CKEditor configuration */
|
|
130
|
-
editorConfig:{
|
|
131
|
-
/* All available built-in plugins
|
|
132
|
-
you can find in admin/src/components/Input/CKEditor/configs/base.js */
|
|
133
|
-
plugins: [
|
|
134
|
-
CKEditor5.autoformat.Autoformat,
|
|
135
|
-
CKEditor5.basicStyles.Bold,
|
|
136
|
-
CKEditor5.basicStyles.Italic,
|
|
137
|
-
CKEditor5.essentials.Essentials,
|
|
138
|
-
CKEditor5.heading.Heading,
|
|
139
|
-
CKEditor5.image.Image,
|
|
140
|
-
CKEditor5.image.ImageCaption,
|
|
141
|
-
CKEditor5.image.ImageStyle,
|
|
142
|
-
CKEditor5.image.ImageToolbar,
|
|
143
|
-
CKEditor5.image.ImageUpload,
|
|
144
|
-
CKEditor5.indent.Indent,
|
|
145
|
-
CKEditor5.link.Link,
|
|
146
|
-
CKEditor5.list.List,
|
|
147
|
-
CKEditor5.paragraph.Paragraph,
|
|
148
|
-
CKEditor5.pasteFromOffice.PasteFromOffice,
|
|
149
|
-
CKEditor5.table.Table,
|
|
150
|
-
CKEditor5.table.TableToolbar,
|
|
151
|
-
CKEditor5.table.TableColumnResize,
|
|
152
|
-
CKEditor5.table.TableCaption,
|
|
153
|
-
CKEditor5.strapiPlugins.StrapiMediaLib,
|
|
154
|
-
CKEditor5.strapiPlugins.StrapiUploadAdapter,
|
|
155
|
-
],
|
|
156
|
-
|
|
157
|
-
/* By default, for plugin's UI will use
|
|
158
|
-
the language defined in this file
|
|
159
|
-
or the preferred language from strapi's user config
|
|
160
|
-
and 'en' as a fallback.
|
|
161
|
-
language.ui -> preferred language -> 'en' */
|
|
162
|
-
|
|
163
|
-
/* For content it will use language based on i18n (if! ignorei18n)
|
|
164
|
-
or language.content defined here
|
|
165
|
-
and it will use UI language as a fallback.
|
|
166
|
-
ignorei18n ? language.content : i18n; -> language.ui */
|
|
167
|
-
|
|
168
|
-
language:{
|
|
169
|
-
// ignorei18n: true,
|
|
170
|
-
ui:'he',
|
|
171
|
-
content:'he'
|
|
172
|
-
},
|
|
173
|
-
toolbar: [
|
|
174
|
-
'heading',
|
|
175
|
-
'|',
|
|
176
|
-
'bold', 'italic', 'link', 'bulletedList', 'numberedList',
|
|
177
|
-
'|',
|
|
178
|
-
'strapiMediaLib', 'insertTable',
|
|
179
|
-
'|',
|
|
180
|
-
'undo', 'redo'
|
|
181
|
-
],
|
|
182
|
-
heading: {
|
|
183
|
-
options: [
|
|
184
|
-
{ model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph' },
|
|
185
|
-
{ model: 'heading1', view: 'h1', title: 'Heading 1', class: 'ck-heading_heading1' },
|
|
186
|
-
{ model: 'heading2', view: 'h2', title: 'Heading 2', class: 'ck-heading_heading2' },
|
|
187
|
-
{ model: 'heading3', view: 'h3', title: 'Heading 3', class: 'ck-heading_heading3' },
|
|
188
|
-
{ model: 'heading4', view: 'h4', title: 'Heading 4', class: 'ck-heading_heading4' },
|
|
189
|
-
]
|
|
190
|
-
},
|
|
191
|
-
image: {
|
|
192
|
-
toolbar: [
|
|
193
|
-
'imageStyle:inline',
|
|
194
|
-
'imageStyle:block',
|
|
195
|
-
'imageStyle:side',
|
|
196
|
-
'|',
|
|
197
|
-
'toggleImageCaption',
|
|
198
|
-
'imageTextAlternative'
|
|
199
|
-
]
|
|
200
|
-
},
|
|
201
|
-
table: {
|
|
202
|
-
contentToolbar: [
|
|
203
|
-
'tableColumn',
|
|
204
|
-
'tableRow',
|
|
205
|
-
'mergeTableCells',
|
|
206
|
-
'|',
|
|
207
|
-
'toggleTableCaption'
|
|
208
|
-
]
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
},
|
|
213
|
-
|
|
214
|
-
/* Here you can customize the plugin's theme.
|
|
215
|
-
This will be passed as "createGlobalStyle". */
|
|
216
|
-
theme:{
|
|
217
|
-
// common:``,
|
|
218
|
-
// light:``,
|
|
219
|
-
// dark:``,
|
|
220
|
-
// additional:``
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
}
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
> If you use the default (local) upload provider you should specify a `url` property in the `config/server.js` in order to get the full URL on uploaded files eg:
|
|
227
|
-
```js
|
|
228
|
-
module.exports = ({ env }) => ({
|
|
229
|
-
url: env("PUBLIC_URL", "http://localhost:1337"),
|
|
230
|
-
host: env('HOST', '0.0.0.0'),
|
|
231
|
-
port: env.int('PORT', 1337),
|
|
232
|
-
app: {
|
|
233
|
-
keys: env.array('APP_KEYS'),
|
|
234
|
-
},
|
|
235
|
-
});
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
> In order to display some content from an external source on your `admin` side you should configure your middlewares.js [**check the docs about this**](https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations/required/middlewares.html)
|
|
239
|
-
|
|
240
|
-
## How to add plugins
|
|
241
|
-
|
|
242
|
-
___
|
|
243
|
-
Markdown plugin example
|
|
244
|
-
|
|
245
|
-
* Inside your app:
|
|
246
|
-
|
|
247
|
-
```js
|
|
248
|
-
yarn add @ckeditor/ckeditor5-markdown-gfm
|
|
249
|
-
```
|
|
250
|
-
or
|
|
251
|
-
```js
|
|
252
|
-
npm install @ckeditor/ckeditor5-markdown-gfm
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
* your-app/src/
|
|
256
|
-
|
|
257
|
-
```js
|
|
258
|
-
import ckeditor5Dll from "ckeditor5/build/ckeditor5-dll.js";
|
|
259
|
-
import ckeditor5MrkdownDll from "@ckeditor/ckeditor5-markdown-gfm/build/markdown-gfm.js";
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
const config = {};
|
|
263
|
-
|
|
264
|
-
const bootstrap = (app) => {};
|
|
265
|
-
|
|
266
|
-
export default {
|
|
267
|
-
config,
|
|
268
|
-
bootstrap,
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
* your-app/config/**ckeditor.txt**
|
|
274
|
-
|
|
275
|
-
```js
|
|
276
|
-
globalThis.CKEditorConfig = {
|
|
277
|
-
configs:{
|
|
278
|
-
markdown:{
|
|
279
|
-
field: {
|
|
280
|
-
key: "markdown",
|
|
281
|
-
value: "markdown",
|
|
282
|
-
metadatas: {
|
|
283
|
-
intlLabel: {
|
|
284
|
-
id: "ckeditor.preset.markdown.label",
|
|
285
|
-
defaultMessage: "Markdown version",
|
|
286
|
-
},
|
|
287
|
-
},
|
|
288
|
-
},
|
|
289
|
-
editorConfig:{
|
|
290
|
-
placeholder: 'Markdown editor',
|
|
291
|
-
plugins: [
|
|
292
|
-
CKEditor5.essentials.Essentials,
|
|
293
|
-
CKEditor5.autoformat.Autoformat,
|
|
294
|
-
CKEditor5.blockQuote.BlockQuote,
|
|
295
|
-
CKEditor5.basicStyles.Bold,
|
|
296
|
-
CKEditor5.heading.Heading,
|
|
297
|
-
CKEditor5.image.Image,
|
|
298
|
-
CKEditor5.image.ImageCaption,
|
|
299
|
-
CKEditor5.image.ImageStyle,
|
|
300
|
-
CKEditor5.image.ImageToolbar,
|
|
301
|
-
CKEditor5.image.ImageUpload,
|
|
302
|
-
CKEditor5.indent.Indent,
|
|
303
|
-
CKEditor5.basicStyles.Italic,
|
|
304
|
-
CKEditor5.link.Link,
|
|
305
|
-
CKEditor5.list.List,
|
|
306
|
-
CKEditor5.mediaEmbed.MediaEmbed,
|
|
307
|
-
CKEditor5.paragraph.Paragraph,
|
|
308
|
-
CKEditor5.table.Table,
|
|
309
|
-
CKEditor5.table.TableToolbar,
|
|
310
|
-
CKEditor5.sourceEditing.SourceEditing,
|
|
311
|
-
CKEditor5.strapiPlugins.StrapiMediaLib,
|
|
312
|
-
CKEditor5.strapiPlugins.StrapiUploadAdapter,
|
|
313
|
-
CKEditor5.markdownGfm.Markdown,
|
|
314
|
-
CKEditor5.basicStyles.Code,
|
|
315
|
-
CKEditor5.codeBlock.CodeBlock,
|
|
316
|
-
CKEditor5.list.TodoList,
|
|
317
|
-
CKEditor5.basicStyles.Strikethrough,
|
|
318
|
-
CKEditor5.horizontalLine.HorizontalLine
|
|
319
|
-
],
|
|
320
|
-
toolbar: {
|
|
321
|
-
items: [
|
|
322
|
-
'heading',
|
|
323
|
-
'|',
|
|
324
|
-
'bold',
|
|
325
|
-
'italic',
|
|
326
|
-
'strikethrough',
|
|
327
|
-
'link',
|
|
328
|
-
'|',
|
|
329
|
-
'bulletedList',
|
|
330
|
-
'numberedList',
|
|
331
|
-
'todoList',
|
|
332
|
-
'|',
|
|
333
|
-
'code',
|
|
334
|
-
'codeBlock',
|
|
335
|
-
'|',
|
|
336
|
-
'uploadImage',
|
|
337
|
-
'strapiMediaLib',
|
|
338
|
-
'blockQuote',
|
|
339
|
-
'horizontalLine',
|
|
340
|
-
'-',
|
|
341
|
-
'sourceEditing',
|
|
342
|
-
'|',
|
|
343
|
-
'outdent',
|
|
344
|
-
'indent',
|
|
345
|
-
'|',
|
|
346
|
-
'undo',
|
|
347
|
-
'redo'
|
|
348
|
-
],
|
|
349
|
-
shouldNotGroupWhenFull: true
|
|
350
|
-
},
|
|
351
|
-
image: {
|
|
352
|
-
toolbar: [ 'imageStyle:inline', 'imageStyle:block', 'imageStyle:side', '|', 'toggleImageCaption', 'imageTextAlternative' ]
|
|
353
|
-
},
|
|
354
|
-
codeBlock: {
|
|
355
|
-
languages: [
|
|
356
|
-
{ language: 'css', label: 'CSS' },
|
|
357
|
-
{ language: 'html', label: 'HTML' },
|
|
358
|
-
{ language: 'javascript', label: 'JavaScript' },
|
|
359
|
-
{ language: 'php', label: 'PHP' }
|
|
360
|
-
]
|
|
361
|
-
},
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
```
|
|
367
|
-
|
|
368
|
-
* Then rebuild your app:
|
|
369
|
-
```bash
|
|
370
|
-
npm run build
|
|
371
|
-
```
|
|
372
|
-
|
|
373
|
-
or
|
|
374
|
-
```bash
|
|
375
|
-
yarn build
|
|
376
|
-
```
|
|
377
|
-
|
|
378
|
-
## <a id="contributing"></a>🛠 Contributing
|
|
379
|
-
___
|
|
380
|
-
|
|
381
|
-
This section covers the way how to configure your environment if you want to contribute to this package.
|
|
382
|
-
|
|
383
|
-
### Setting up the environment
|
|
384
|
-
|
|
385
|
-
In order to start making changes in the plugin you first need to install Strapi infrastructure on top of the plugin repository.
|
|
386
|
-
|
|
387
|
-
```
|
|
388
|
-
npx create-strapi-app --quickstart strapi
|
|
389
|
-
cd strapi
|
|
390
|
-
```
|
|
391
|
-
|
|
392
|
-
By default Strapi does not create plugins folder so we need to create it.
|
|
393
|
-
|
|
394
|
-
```
|
|
395
|
-
mkdir -p src/plugins
|
|
396
|
-
```
|
|
397
|
-
|
|
398
|
-
Now we should clone this repository so we can work on it.
|
|
399
|
-
|
|
400
|
-
```
|
|
401
|
-
git clone git@github.com:nshenderov/strapi-plugin-ckeditor.git src/plugins/strapi-plugin-ckeditor
|
|
402
|
-
```
|
|
403
|
-
|
|
404
|
-
Let's add an entry inside `./package.json` file so, we won't need to use `yarn` inside plugin itself.
|
|
405
|
-
|
|
406
|
-
```
|
|
407
|
-
"workspaces": ["./src/plugins/strapi-plugin-ckeditor"]
|
|
408
|
-
```
|
|
409
|
-
|
|
410
|
-
Install dependencies:
|
|
411
|
-
|
|
412
|
-
```
|
|
413
|
-
yarn install
|
|
414
|
-
```
|
|
415
|
-
|
|
416
|
-
Now we need to register plugin so strapi can use it. In order to do that we need
|
|
417
|
-
to create (if not already created) `./config/plugins.js` file and add entry to it.
|
|
418
|
-
|
|
419
|
-
```
|
|
420
|
-
module.exports = ({ env }) => ({
|
|
421
|
-
ckeditor5: {
|
|
422
|
-
enabled: true,
|
|
423
|
-
resolve: "./src/plugins/strapi-plugin-ckeditor"
|
|
424
|
-
},
|
|
425
|
-
});
|
|
426
|
-
```
|
|
427
|
-
|
|
428
|
-
Rebuild the project and start the server:
|
|
429
|
-
|
|
430
|
-
```
|
|
431
|
-
yarn build
|
|
432
|
-
yarn develop
|
|
433
|
-
```
|
|
434
|
-
|
|
435
|
-
## <a id="requirements"></a>⚠️ Requirements
|
|
436
|
-
___
|
|
437
|
-
Strapi **v4.4.0+**
|
|
438
|
-
|
|
439
|
-
Node **>=14.19.1 <=18.x.x**
|
|
440
|
-
|
|
441
|
-
### 👍 This build includes some useful plugins based on these repos so thanks to them:
|
|
442
|
-
https://github.com/Roslovets-Inc/strapi-plugin-ckeditor5
|
|
443
|
-
|
|
444
|
-
https://github.com/leknoppix/ckeditor5-fullscreen
|
|
445
|
-
|
|
446
|
-
https://github.com/gtomato/ckeditor5-strapi-upload-plugin
|
|
447
|
-
|
|
448
|
-
https://github.com/pshurygin/ckeditor5-font-color
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/nshenderov/strapi-plugin-ckeditor/master/assets/ckeditor5_2_0.png" width="700" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">CKEditor 5 for Strapi</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">Integrates CKEditor 5 into your Strapi project as a fully customizable custom field. (Unofficial integration)</p>
|
|
8
|
+
|
|
9
|
+
## 👋 Get Started
|
|
10
|
+
|
|
11
|
+
* [Features](#features)
|
|
12
|
+
* [Installation](#installation)
|
|
13
|
+
* [Configuration](#configuration)
|
|
14
|
+
* [Contributing](#contributing)
|
|
15
|
+
* [Requirements](#requirements)
|
|
16
|
+
|
|
17
|
+
## <a id="features"></a>✨ Features
|
|
18
|
+
|
|
19
|
+
* **Media library integration**
|
|
20
|
+
* **Supports responsive images**
|
|
21
|
+
* **Supports Strapi's theme switching with the possibility to define your own theme**
|
|
22
|
+
* **Supports i18n for content and user's preferred language for UI**
|
|
23
|
+
* **Few predefined editor configs with the possibility to add your owns**
|
|
24
|
+
* **Possible to add new plugins**
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
## <a id="installation"></a>🔧 Installation
|
|
28
|
+
___
|
|
29
|
+
|
|
30
|
+
* Inside your Strapi app, add the package:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install @_sh/strapi-plugin-ckeditor
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
or
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
yarn add @_sh/strapi-plugin-ckeditor
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
* Then run build:
|
|
43
|
+
```bash
|
|
44
|
+
npm run build
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
or
|
|
48
|
+
```bash
|
|
49
|
+
yarn build
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
## <a id="configuration"></a>⚙️ Configuration
|
|
55
|
+
___
|
|
56
|
+
The plugin is based on [**Strapi's custom fields**](https://docs.strapi.io/developer-docs/latest/development/custom-fields.html#registering-a-custom-field-on-the-server) and [**CKEditor dll build**](https://ckeditor.com/docs/ckeditor5/latest/installation/advanced/alternative-setups/dll-builds.html)
|
|
57
|
+
|
|
58
|
+
Plugin configuration should be defined in the `/config/ckeditor.txt` file.
|
|
59
|
+
|
|
60
|
+
It's highly recommended to explore [**the official ckeditor documentation**](https://ckeditor.com/docs/ckeditor5/latest/features/index.html)
|
|
61
|
+
|
|
62
|
+
Content from ckeditor.txt will be passed into a script tag through the initialization process.
|
|
63
|
+
|
|
64
|
+
> 📂 Default configs: [**admin/src/components/Input/CKEditor/configs**](https://github.com/nshenderov/strapi-plugin-ckeditor/blob/master/admin/src/components/Input/CKEditor/configs)
|
|
65
|
+
|
|
66
|
+
> 📂 Default theme: [**admin/src/components/Input/CKEditor/theme**](https://github.com/nshenderov/strapi-plugin-ckeditor/blob/master/admin/src/components/Input/CKEditor/theme)
|
|
67
|
+
|
|
68
|
+
**ckeditor.txt example:**
|
|
69
|
+
|
|
70
|
+
```js
|
|
71
|
+
globalThis.CKEditorConfig = {
|
|
72
|
+
|
|
73
|
+
/* By default configs and theme
|
|
74
|
+
objects will be spread with
|
|
75
|
+
default configs and theme
|
|
76
|
+
these two properties specified below
|
|
77
|
+
allow you to redefine
|
|
78
|
+
default objects completely: */
|
|
79
|
+
|
|
80
|
+
//configsOverwrite:true,
|
|
81
|
+
//themeOverwrite:true,
|
|
82
|
+
|
|
83
|
+
/* Here you can redefine default configs
|
|
84
|
+
or add completely new ones.
|
|
85
|
+
Each config includes:
|
|
86
|
+
"styles", "field" and "editorConfig" properties.
|
|
87
|
+
Property "field" is required. */
|
|
88
|
+
|
|
89
|
+
configs:{
|
|
90
|
+
toolbar:{
|
|
91
|
+
// styles:``,
|
|
92
|
+
// field:{},
|
|
93
|
+
// editorConfig:{}
|
|
94
|
+
},
|
|
95
|
+
custom:{
|
|
96
|
+
|
|
97
|
+
/* Styles for this specific editor.
|
|
98
|
+
This will be passed into the editor's parent container. */
|
|
99
|
+
|
|
100
|
+
styles:`
|
|
101
|
+
// --ck-focus-ring:3px dashed #5CB176;
|
|
102
|
+
|
|
103
|
+
// .ck.ck-content.ck-editor__editable {
|
|
104
|
+
// &.ck-focused:not(.ck-editor__nested-editable) {
|
|
105
|
+
// border: var(--ck-focus-ring) !important;
|
|
106
|
+
// }
|
|
107
|
+
// }
|
|
108
|
+
// .ck.ck-content.ck-editor__editable.ck-rounded-corners.ck-editor__editable_inline.ck-blurred{
|
|
109
|
+
// min-height: 400px;
|
|
110
|
+
// max-height: 400px;
|
|
111
|
+
// }
|
|
112
|
+
// .ck.ck-content.ck-editor__editable.ck-rounded-corners.ck-editor__editable_inline.ck-focused{
|
|
113
|
+
// min-height: 400px;
|
|
114
|
+
// max-height: 1700px;
|
|
115
|
+
// }
|
|
116
|
+
`,
|
|
117
|
+
|
|
118
|
+
/* Custom field option */
|
|
119
|
+
field: {
|
|
120
|
+
key: "custom",
|
|
121
|
+
value: "custom",
|
|
122
|
+
metadatas: {
|
|
123
|
+
intlLabel: {
|
|
124
|
+
id: "ckeditor5.preset.custom.label",
|
|
125
|
+
defaultMessage: "Custom version",
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
/* CKEditor configuration */
|
|
130
|
+
editorConfig:{
|
|
131
|
+
/* All available built-in plugins
|
|
132
|
+
you can find in admin/src/components/Input/CKEditor/configs/base.js */
|
|
133
|
+
plugins: [
|
|
134
|
+
CKEditor5.autoformat.Autoformat,
|
|
135
|
+
CKEditor5.basicStyles.Bold,
|
|
136
|
+
CKEditor5.basicStyles.Italic,
|
|
137
|
+
CKEditor5.essentials.Essentials,
|
|
138
|
+
CKEditor5.heading.Heading,
|
|
139
|
+
CKEditor5.image.Image,
|
|
140
|
+
CKEditor5.image.ImageCaption,
|
|
141
|
+
CKEditor5.image.ImageStyle,
|
|
142
|
+
CKEditor5.image.ImageToolbar,
|
|
143
|
+
CKEditor5.image.ImageUpload,
|
|
144
|
+
CKEditor5.indent.Indent,
|
|
145
|
+
CKEditor5.link.Link,
|
|
146
|
+
CKEditor5.list.List,
|
|
147
|
+
CKEditor5.paragraph.Paragraph,
|
|
148
|
+
CKEditor5.pasteFromOffice.PasteFromOffice,
|
|
149
|
+
CKEditor5.table.Table,
|
|
150
|
+
CKEditor5.table.TableToolbar,
|
|
151
|
+
CKEditor5.table.TableColumnResize,
|
|
152
|
+
CKEditor5.table.TableCaption,
|
|
153
|
+
CKEditor5.strapiPlugins.StrapiMediaLib,
|
|
154
|
+
CKEditor5.strapiPlugins.StrapiUploadAdapter,
|
|
155
|
+
],
|
|
156
|
+
|
|
157
|
+
/* By default, for plugin's UI will use
|
|
158
|
+
the language defined in this file
|
|
159
|
+
or the preferred language from strapi's user config
|
|
160
|
+
and 'en' as a fallback.
|
|
161
|
+
language.ui -> preferred language -> 'en' */
|
|
162
|
+
|
|
163
|
+
/* For content it will use language based on i18n (if! ignorei18n)
|
|
164
|
+
or language.content defined here
|
|
165
|
+
and it will use UI language as a fallback.
|
|
166
|
+
ignorei18n ? language.content : i18n; -> language.ui */
|
|
167
|
+
|
|
168
|
+
language:{
|
|
169
|
+
// ignorei18n: true,
|
|
170
|
+
// ui:'he',
|
|
171
|
+
// content:'he'
|
|
172
|
+
},
|
|
173
|
+
toolbar: [
|
|
174
|
+
'heading',
|
|
175
|
+
'|',
|
|
176
|
+
'bold', 'italic', 'link', 'bulletedList', 'numberedList',
|
|
177
|
+
'|',
|
|
178
|
+
'strapiMediaLib', 'insertTable',
|
|
179
|
+
'|',
|
|
180
|
+
'undo', 'redo'
|
|
181
|
+
],
|
|
182
|
+
heading: {
|
|
183
|
+
options: [
|
|
184
|
+
{ model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph' },
|
|
185
|
+
{ model: 'heading1', view: 'h1', title: 'Heading 1', class: 'ck-heading_heading1' },
|
|
186
|
+
{ model: 'heading2', view: 'h2', title: 'Heading 2', class: 'ck-heading_heading2' },
|
|
187
|
+
{ model: 'heading3', view: 'h3', title: 'Heading 3', class: 'ck-heading_heading3' },
|
|
188
|
+
{ model: 'heading4', view: 'h4', title: 'Heading 4', class: 'ck-heading_heading4' },
|
|
189
|
+
]
|
|
190
|
+
},
|
|
191
|
+
image: {
|
|
192
|
+
toolbar: [
|
|
193
|
+
'imageStyle:inline',
|
|
194
|
+
'imageStyle:block',
|
|
195
|
+
'imageStyle:side',
|
|
196
|
+
'|',
|
|
197
|
+
'toggleImageCaption',
|
|
198
|
+
'imageTextAlternative'
|
|
199
|
+
]
|
|
200
|
+
},
|
|
201
|
+
table: {
|
|
202
|
+
contentToolbar: [
|
|
203
|
+
'tableColumn',
|
|
204
|
+
'tableRow',
|
|
205
|
+
'mergeTableCells',
|
|
206
|
+
'|',
|
|
207
|
+
'toggleTableCaption'
|
|
208
|
+
]
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
|
|
214
|
+
/* Here you can customize the plugin's theme.
|
|
215
|
+
This will be passed as "createGlobalStyle". */
|
|
216
|
+
theme:{
|
|
217
|
+
// common:``,
|
|
218
|
+
// light:``,
|
|
219
|
+
// dark:``,
|
|
220
|
+
// additional:``
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
> If you use the default (local) upload provider you should specify a `url` property in the `config/server.js` in order to get the full URL on uploaded files eg:
|
|
227
|
+
```js
|
|
228
|
+
module.exports = ({ env }) => ({
|
|
229
|
+
url: env("PUBLIC_URL", "http://localhost:1337"),
|
|
230
|
+
host: env('HOST', '0.0.0.0'),
|
|
231
|
+
port: env.int('PORT', 1337),
|
|
232
|
+
app: {
|
|
233
|
+
keys: env.array('APP_KEYS'),
|
|
234
|
+
},
|
|
235
|
+
});
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
> In order to display some content from an external source on your `admin` side you should configure your middlewares.js [**check the docs about this**](https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations/required/middlewares.html)
|
|
239
|
+
|
|
240
|
+
## How to add plugins
|
|
241
|
+
|
|
242
|
+
___
|
|
243
|
+
Markdown plugin example
|
|
244
|
+
|
|
245
|
+
* Inside your app:
|
|
246
|
+
|
|
247
|
+
```js
|
|
248
|
+
yarn add @ckeditor/ckeditor5-markdown-gfm
|
|
249
|
+
```
|
|
250
|
+
or
|
|
251
|
+
```js
|
|
252
|
+
npm install @ckeditor/ckeditor5-markdown-gfm
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
* your-app/src/admin/**app.js**
|
|
256
|
+
|
|
257
|
+
```js
|
|
258
|
+
import ckeditor5Dll from "ckeditor5/build/ckeditor5-dll.js";
|
|
259
|
+
import ckeditor5MrkdownDll from "@ckeditor/ckeditor5-markdown-gfm/build/markdown-gfm.js";
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
const config = {};
|
|
263
|
+
|
|
264
|
+
const bootstrap = (app) => {};
|
|
265
|
+
|
|
266
|
+
export default {
|
|
267
|
+
config,
|
|
268
|
+
bootstrap,
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
* your-app/config/**ckeditor.txt**
|
|
274
|
+
|
|
275
|
+
```js
|
|
276
|
+
globalThis.CKEditorConfig = {
|
|
277
|
+
configs:{
|
|
278
|
+
markdown:{
|
|
279
|
+
field: {
|
|
280
|
+
key: "markdown",
|
|
281
|
+
value: "markdown",
|
|
282
|
+
metadatas: {
|
|
283
|
+
intlLabel: {
|
|
284
|
+
id: "ckeditor.preset.markdown.label",
|
|
285
|
+
defaultMessage: "Markdown version",
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
editorConfig:{
|
|
290
|
+
placeholder: 'Markdown editor',
|
|
291
|
+
plugins: [
|
|
292
|
+
CKEditor5.essentials.Essentials,
|
|
293
|
+
CKEditor5.autoformat.Autoformat,
|
|
294
|
+
CKEditor5.blockQuote.BlockQuote,
|
|
295
|
+
CKEditor5.basicStyles.Bold,
|
|
296
|
+
CKEditor5.heading.Heading,
|
|
297
|
+
CKEditor5.image.Image,
|
|
298
|
+
CKEditor5.image.ImageCaption,
|
|
299
|
+
CKEditor5.image.ImageStyle,
|
|
300
|
+
CKEditor5.image.ImageToolbar,
|
|
301
|
+
CKEditor5.image.ImageUpload,
|
|
302
|
+
CKEditor5.indent.Indent,
|
|
303
|
+
CKEditor5.basicStyles.Italic,
|
|
304
|
+
CKEditor5.link.Link,
|
|
305
|
+
CKEditor5.list.List,
|
|
306
|
+
CKEditor5.mediaEmbed.MediaEmbed,
|
|
307
|
+
CKEditor5.paragraph.Paragraph,
|
|
308
|
+
CKEditor5.table.Table,
|
|
309
|
+
CKEditor5.table.TableToolbar,
|
|
310
|
+
CKEditor5.sourceEditing.SourceEditing,
|
|
311
|
+
CKEditor5.strapiPlugins.StrapiMediaLib,
|
|
312
|
+
CKEditor5.strapiPlugins.StrapiUploadAdapter,
|
|
313
|
+
CKEditor5.markdownGfm.Markdown,
|
|
314
|
+
CKEditor5.basicStyles.Code,
|
|
315
|
+
CKEditor5.codeBlock.CodeBlock,
|
|
316
|
+
CKEditor5.list.TodoList,
|
|
317
|
+
CKEditor5.basicStyles.Strikethrough,
|
|
318
|
+
CKEditor5.horizontalLine.HorizontalLine
|
|
319
|
+
],
|
|
320
|
+
toolbar: {
|
|
321
|
+
items: [
|
|
322
|
+
'heading',
|
|
323
|
+
'|',
|
|
324
|
+
'bold',
|
|
325
|
+
'italic',
|
|
326
|
+
'strikethrough',
|
|
327
|
+
'link',
|
|
328
|
+
'|',
|
|
329
|
+
'bulletedList',
|
|
330
|
+
'numberedList',
|
|
331
|
+
'todoList',
|
|
332
|
+
'|',
|
|
333
|
+
'code',
|
|
334
|
+
'codeBlock',
|
|
335
|
+
'|',
|
|
336
|
+
'uploadImage',
|
|
337
|
+
'strapiMediaLib',
|
|
338
|
+
'blockQuote',
|
|
339
|
+
'horizontalLine',
|
|
340
|
+
'-',
|
|
341
|
+
'sourceEditing',
|
|
342
|
+
'|',
|
|
343
|
+
'outdent',
|
|
344
|
+
'indent',
|
|
345
|
+
'|',
|
|
346
|
+
'undo',
|
|
347
|
+
'redo'
|
|
348
|
+
],
|
|
349
|
+
shouldNotGroupWhenFull: true
|
|
350
|
+
},
|
|
351
|
+
image: {
|
|
352
|
+
toolbar: [ 'imageStyle:inline', 'imageStyle:block', 'imageStyle:side', '|', 'toggleImageCaption', 'imageTextAlternative' ]
|
|
353
|
+
},
|
|
354
|
+
codeBlock: {
|
|
355
|
+
languages: [
|
|
356
|
+
{ language: 'css', label: 'CSS' },
|
|
357
|
+
{ language: 'html', label: 'HTML' },
|
|
358
|
+
{ language: 'javascript', label: 'JavaScript' },
|
|
359
|
+
{ language: 'php', label: 'PHP' }
|
|
360
|
+
]
|
|
361
|
+
},
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
* Then rebuild your app:
|
|
369
|
+
```bash
|
|
370
|
+
npm run build
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
or
|
|
374
|
+
```bash
|
|
375
|
+
yarn build
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
## <a id="contributing"></a>🛠 Contributing
|
|
379
|
+
___
|
|
380
|
+
|
|
381
|
+
This section covers the way how to configure your environment if you want to contribute to this package.
|
|
382
|
+
|
|
383
|
+
### Setting up the environment
|
|
384
|
+
|
|
385
|
+
In order to start making changes in the plugin you first need to install Strapi infrastructure on top of the plugin repository.
|
|
386
|
+
|
|
387
|
+
```
|
|
388
|
+
npx create-strapi-app --quickstart strapi
|
|
389
|
+
cd strapi
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
By default Strapi does not create plugins folder so we need to create it.
|
|
393
|
+
|
|
394
|
+
```
|
|
395
|
+
mkdir -p src/plugins
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
Now we should clone this repository so we can work on it.
|
|
399
|
+
|
|
400
|
+
```
|
|
401
|
+
git clone git@github.com:nshenderov/strapi-plugin-ckeditor.git src/plugins/strapi-plugin-ckeditor
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
Let's add an entry inside `./package.json` file so, we won't need to use `yarn` inside plugin itself.
|
|
405
|
+
|
|
406
|
+
```
|
|
407
|
+
"workspaces": ["./src/plugins/strapi-plugin-ckeditor"]
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
Install dependencies:
|
|
411
|
+
|
|
412
|
+
```
|
|
413
|
+
yarn install
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
Now we need to register plugin so strapi can use it. In order to do that we need
|
|
417
|
+
to create (if not already created) `./config/plugins.js` file and add entry to it.
|
|
418
|
+
|
|
419
|
+
```
|
|
420
|
+
module.exports = ({ env }) => ({
|
|
421
|
+
ckeditor5: {
|
|
422
|
+
enabled: true,
|
|
423
|
+
resolve: "./src/plugins/strapi-plugin-ckeditor"
|
|
424
|
+
},
|
|
425
|
+
});
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
Rebuild the project and start the server:
|
|
429
|
+
|
|
430
|
+
```
|
|
431
|
+
yarn build
|
|
432
|
+
yarn develop
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
## <a id="requirements"></a>⚠️ Requirements
|
|
436
|
+
___
|
|
437
|
+
Strapi **v4.4.0+**
|
|
438
|
+
|
|
439
|
+
Node **>=14.19.1 <=18.x.x**
|
|
440
|
+
|
|
441
|
+
### 👍 This build includes some useful plugins based on these repos so thanks to them:
|
|
442
|
+
https://github.com/Roslovets-Inc/strapi-plugin-ckeditor5
|
|
443
|
+
|
|
444
|
+
https://github.com/leknoppix/ckeditor5-fullscreen
|
|
445
|
+
|
|
446
|
+
https://github.com/gtomato/ckeditor5-strapi-upload-plugin
|
|
447
|
+
|
|
448
|
+
https://github.com/pshurygin/ckeditor5-font-color
|