@_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
@@ -1,4 +1,4 @@
1
- import { css } from "styled-components";
1
+ import { css } from 'styled-components';
2
2
 
3
3
  export const common = css`
4
4
  .ck {
@@ -19,7 +19,6 @@ export const common = css`
19
19
  --ck-todo-list-checkmark-size: 16px;
20
20
  }
21
21
 
22
-
23
22
  .ck.ck-sticky-panel .ck-sticky-panel__content_sticky {
24
23
  top: 64px !important;
25
24
  }
@@ -28,9 +27,9 @@ export const common = css`
28
27
  }
29
28
 
30
29
  .ck-editor__main {
31
-
32
- --ck-font-face: "Source Sans Pro", system-ui, Roboto, "Helvetica Neue", "Helvetica", Arial, sans-serif;
33
-
30
+ --ck-font-face: 'Source Sans Pro', system-ui, Roboto, 'Helvetica Neue',
31
+ 'Helvetica', Arial, sans-serif;
32
+
34
33
  color: var(--ck-color-editor-base-text);
35
34
  font-family: var(--ck-font-face);
36
35
 
@@ -39,7 +38,6 @@ export const common = css`
39
38
  margin: revert;
40
39
  }
41
40
 
42
-
43
41
  h1 {
44
42
  font-size: 2.3em;
45
43
  }
@@ -71,8 +69,8 @@ export const common = css`
71
69
  h5,
72
70
  h6 {
73
71
  line-height: 1.2em;
74
- padding-top: .8em;
75
- margin-bottom: .4em
72
+ padding-top: 0.8em;
73
+ margin-bottom: 0.4em;
76
74
  }
77
75
 
78
76
  blockquote,
@@ -81,8 +79,8 @@ export const common = css`
81
79
  ul {
82
80
  font-size: 1em;
83
81
  line-height: 1.6em;
84
- padding-top: .2em;
85
- margin-bottom: var(--ck-spacing-large)
82
+ padding-top: 0.2em;
83
+ margin-bottom: var(--ck-spacing-large);
86
84
  }
87
85
 
88
86
  figcaption {
@@ -180,7 +178,7 @@ export const common = css`
180
178
  }
181
179
  }
182
180
 
183
- .ck .ck-source-editing-area textarea{
181
+ .ck .ck-source-editing-area textarea {
184
182
  color: var(--ck-color-text);
185
183
  background-color: var(--ck-color-base-background);
186
184
  border: 1px solid var(--ck-color-base-border) !important;
@@ -193,7 +191,7 @@ export const common = css`
193
191
  width: 20px !important;
194
192
  height: 25px !important;
195
193
  margin-left: -2px !important ;
196
-
194
+
197
195
  & svg {
198
196
  color: var(--ck-color-text) !important;
199
197
  position: absolute;
@@ -213,19 +211,19 @@ export const common = css`
213
211
  /* color: #b3b3c4; */
214
212
  }
215
213
 
216
- .ck[dir=rtl]{
214
+ .ck[dir='rtl'] {
217
215
  .ck-block-toolbar-button {
218
216
  margin-left: 2px !important ;
219
217
  }
220
- & + div{
218
+ & + div {
221
219
  justify-content: flex-start;
222
220
  & > .ck-word-count {
223
- & > div:first-child{
224
- order: 2;
225
- }
226
- & > div:last-child{
227
- order: 1;
228
- }
221
+ & > div:first-child {
222
+ order: 2;
223
+ }
224
+ & > div:last-child {
225
+ order: 1;
226
+ }
229
227
  }
230
228
  }
231
229
  }
@@ -1,4 +1,4 @@
1
- import { css } from "styled-components";
1
+ import { css } from 'styled-components';
2
2
 
3
3
  export const dark = css`
4
4
  :root {
@@ -11,7 +11,7 @@ export const dark = css`
11
11
  .ck.ck-powered-by > a > svg > path:first-child {
12
12
  fill: rgb(236, 236, 236);
13
13
  }
14
-
14
+
15
15
  .ck.ck-powered-by > a > svg > path:nth-child(3) {
16
16
  fill: rgb(172, 156, 251);
17
17
  }
@@ -40,7 +40,8 @@ export const dark = css`
40
40
  --ck-color-base-focus: #bbbaf1;
41
41
  --ck-color-base-active: #2e2e5c;
42
42
  --ck-color-base-active-focus: #28284d;
43
- /* -- Overrides generic colors. ------------------------------------------------------------- */
43
+
44
+ /* -- Overrides generic colors. ----------------------------------------- */
44
45
 
45
46
  --ck-color-base-foreground: var(--ck-custom-background);
46
47
  --ck-color-focus-border: #6765bd;
@@ -48,7 +49,7 @@ export const dark = css`
48
49
  --ck-color-shadow-drop: hsla(0, 0%, 0%, 0.2);
49
50
  --ck-color-shadow-inner: hsla(0, 0%, 0%, 0.1);
50
51
 
51
- /* -- Overrides the default .ck-button class colors. ---------------------------------------- */
52
+ /* -- Overrides the default .ck-button class colors. -------------------- */
52
53
 
53
54
  --ck-color-button-default-background: rgb(33, 33, 52);
54
55
 
@@ -74,17 +75,19 @@ export const dark = css`
74
75
  --ck-color-button-save: hsl(120, 100%, 46%);
75
76
  --ck-color-button-cancel: hsl(15, 100%, 56%);
76
77
 
77
- /* -- Overrides the default .ck-dropdown class colors. -------------------------------------- */
78
+ /* -- Overrides the default .ck-dropdown class colors. ------------------ */
78
79
 
79
80
  --ck-color-dropdown-panel-background: var(--ck-custom-background);
80
81
  --ck-color-dropdown-panel-border: var(--ck-custom-foreground);
81
82
 
82
- /* -- Overrides the default .ck-splitbutton class colors. ----------------------------------- */
83
+ /* -- Overrides the default .ck-splitbutton class colors. --------------- */
83
84
 
84
- --ck-color-split-button-hover-background: var(--ck-color-button-default-hover-background);
85
+ --ck-color-split-button-hover-background: var(
86
+ --ck-color-button-default-hover-background
87
+ );
85
88
  --ck-color-split-button-hover-border: var(--ck-custom-foreground);
86
89
 
87
- /* -- Overrides the default .ck-input class colors. ----------------------------------------- */
90
+ /* -- Overrides the default .ck-input class colors. --------------------- */
88
91
 
89
92
  --ck-color-input-background: var(--ck-custom-background);
90
93
  --ck-color-input-border: hsl(257, 3%, 43%);
@@ -93,45 +96,47 @@ export const dark = css`
93
96
  --ck-color-input-disabled-border: hsl(250, 3%, 38%);
94
97
  --ck-color-input-disabled-text: hsl(0, 0%, 78%);
95
98
 
96
- /* -- Overrides the default .ck-labeled-field-view class colors. ---------------------------- */
99
+ /* -- Overrides the default .ck-labeled-field-view class colors. ---------*/
97
100
 
98
101
  --ck-color-labeled-field-label-background: var(--ck-custom-background);
99
102
 
100
- /* -- Overrides the default .ck-list class colors. ------------------------------------------ */
103
+ /* -- Overrides the default .ck-list class colors. ---------------------- */
101
104
 
102
105
  --ck-color-list-background: var(--ck-custom-background);
103
106
  --ck-color-list-button-hover-background: #121221;
104
107
  --ck-color-list-button-on-background: var(--ck-color-base-active);
105
- --ck-color-list-button-on-background-focus: var(--ck-color-base-active-focus);
108
+ --ck-color-list-button-on-background-focus: var(
109
+ --ck-color-base-active-focus
110
+ );
106
111
  --ck-color-list-button-on-text: #ffffff;
107
112
 
108
- /* -- Overrides the default .ck-balloon-panel class colors. --------------------------------- */
113
+ /* -- Overrides the default .ck-balloon-panel class colors. ------------- */
109
114
 
110
115
  --ck-color-panel-background: var(--ck-custom-background);
111
116
  --ck-color-panel-border: var(--ck-custom-border);
112
117
 
113
- /* -- Overrides the default .ck-toolbar class colors. --------------------------------------- */
118
+ /* -- Overrides the default .ck-toolbar class colors. ------------------- */
114
119
 
115
120
  --ck-color-toolbar-background: var(--ck-custom-background);
116
121
  --ck-color-toolbar-border: var(--ck-custom-border);
117
122
 
118
- /* -- Overrides the default .ck-tooltip class colors. --------------------------------------- */
123
+ /* -- Overrides the default .ck-tooltip class colors. ------------------- */
119
124
 
120
125
  --ck-color-tooltip-background: #3a3955;
121
126
  --ck-color-tooltip-text: hsl(0, 0%, 93%);
122
127
 
123
- /* -- Overrides the default colors used by the ckeditor5-image package. --------------------- */
128
+ /* -- Overrides the default colors used by the ckeditor5-image package. - */
124
129
 
125
130
  --ck-color-image-caption-background: hsl(0, 0%, 97%);
126
131
  --ck-color-image-caption-text: hsl(0, 0%, 20%);
127
132
 
128
- /* -- Overrides the default colors used by the ckeditor5-widget package. -------------------- */
133
+ /* -- Overrides the default colors used by the ckeditor5-widget package. */
129
134
 
130
135
  --ck-color-widget-blurred-border: #7c7c96;
131
136
  --ck-color-widget-hover-border: #666687;
132
137
  --ck-color-widget-editable-focus-background: var(--ck-custom-white);
133
138
 
134
- /* -- Overrides the default colors used by the ckeditor5-link package. ---------------------- */
139
+ /* -- Overrides the default colors used by the ckeditor5-link package. -- */
135
140
 
136
141
  --ck-color-link-default: hsl(216, 100%, 75%);
137
142
 
@@ -141,5 +146,4 @@ export const dark = css`
141
146
  --ck-color-dialog-background: var(--ck-custom-background);
142
147
  --ck-color-dialog-form-header-border: var(--ck-color-base-border);
143
148
  }
144
-
145
149
  `;
@@ -1,11 +1,11 @@
1
- import { css } from "styled-components";
1
+ import { css } from 'styled-components';
2
2
 
3
3
  export const light = css`
4
4
  :root {
5
5
  --ck-color-focus-outer-shadow: rgba(77, 115, 255, 0.2) !important;
6
6
  --ck-color-focus-disabled-shadow: #e4e3ff !important;
7
7
  --ck-focus-ring: 1px solid rgb(73, 69, 255) !important;
8
- --ck-color-button-default-hover-background: #F0F0FF !important;
8
+ --ck-color-button-default-hover-background: #f0f0ff !important;
9
9
  }
10
10
 
11
11
  .ck.ck-powered-by > a > svg > path:first-child {
@@ -34,7 +34,8 @@ export const light = css`
34
34
  --ck-color-base-focus: #bbbaf1;
35
35
  --ck-color-base-active: #f0f0ff;
36
36
  --ck-color-base-active-focus: #e2e2fd;
37
- /* -- Overrides generic colors. ------------------------------------------------------------- */
37
+
38
+ /* -- Overrides generic colors. ----------------------------------------- */
38
39
 
39
40
  --ck-color-base-foreground: var(--ck-custom-background);
40
41
 
@@ -44,7 +45,7 @@ export const light = css`
44
45
  --ck-color-shadow-drop: hsla(250, 31%, 80%, 0.1);
45
46
  --ck-color-shadow-inner: hsla(250, 31%, 80%, 0.1);
46
47
 
47
- /* -- Overrides the default .ck-button class colors. ---------------------------------------- */
48
+ /* -- Overrides the default .ck-button class colors. -------------------- */
48
49
 
49
50
  --ck-color-button-default-background: var(--ck-custom-background);
50
51
  --ck-color-button-default-hover-background: #f0f0ff;
@@ -69,17 +70,19 @@ export const light = css`
69
70
  --ck-color-button-save: hsl(120, 100%, 46%);
70
71
  --ck-color-button-cancel: hsl(15, 100%, 56%);
71
72
 
72
- /* -- Overrides the default .ck-dropdown class colors. -------------------------------------- */
73
+ /* -- Overrides the default .ck-dropdown class colors. ------------------ */
73
74
 
74
75
  --ck-color-dropdown-panel-background: var(--ck-custom-background);
75
76
  --ck-color-dropdown-panel-border: var(--ck-custom-foreground);
76
77
 
77
- /* -- Overrides the default .ck-splitbutton class colors. ----------------------------------- */
78
+ /* -- Overrides the default .ck-splitbutton class colors. --------------- */
78
79
 
79
- --ck-color-split-button-hover-background: var(--ck-color-button-default-hover-background);
80
+ --ck-color-split-button-hover-background: var(
81
+ --ck-color-button-default-hover-background
82
+ );
80
83
  --ck-color-split-button-hover-border: var(--ck-custom-foreground);
81
84
 
82
- /* -- Overrides the default .ck-input class colors. ----------------------------------------- */
85
+ /* -- Overrides the default .ck-input class colors. --------------------- */
83
86
 
84
87
  --ck-color-input-background: var(--ck-custom-background);
85
88
  --ck-color-input-border: hsl(257, 3%, 43%);
@@ -88,45 +91,47 @@ export const light = css`
88
91
  --ck-color-input-disabled-border: rgb(214, 214, 214);
89
92
  --ck-color-input-disabled-text: hsl(0, 0%, 78%);
90
93
 
91
- /* -- Overrides the default .ck-labeled-field-view class colors. ---------------------------- */
94
+ /* -- Overrides the default .ck-labeled-field-view class colors. -------- */
92
95
 
93
96
  --ck-color-labeled-field-label-background: var(--ck-custom-background);
94
97
 
95
- /* -- Overrides the default .ck-list class colors. ------------------------------------------ */
98
+ /* -- Overrides the default .ck-list class colors. ---------------------- */
96
99
 
97
100
  --ck-color-list-background: var(--ck-custom-background);
98
101
  --ck-color-list-button-hover-background: #f4f4fb;
99
102
  --ck-color-list-button-on-background: var(--ck-color-base-active);
100
- --ck-color-list-button-on-background-focus: var(--ck-color-base-active-focus);
103
+ --ck-color-list-button-on-background-focus: var(
104
+ --ck-color-base-active-focus
105
+ );
101
106
  --ck-color-list-button-on-text: #271fe2;
102
107
 
103
- /* -- Overrides the default .ck-balloon-panel class colors. --------------------------------- */
108
+ /* -- Overrides the default .ck-balloon-panel class colors. ------------- */
104
109
 
105
110
  --ck-color-panel-background: var(--ck-custom-background);
106
111
  --ck-color-panel-border: var(--ck-custom-border);
107
112
 
108
- /* -- Overrides the default .ck-toolbar class colors. --------------------------------------- */
113
+ /* -- Overrides the default .ck-toolbar class colors. ------------------- */
109
114
 
110
115
  --ck-color-toolbar-background: var(--ck-custom-background);
111
116
  --ck-color-toolbar-border: var(--ck-custom-border);
112
117
 
113
- /* -- Overrides the default .ck-tooltip class colors. --------------------------------------- */
118
+ /* -- Overrides the default .ck-tooltip class colors. ------------------- */
114
119
 
115
120
  --ck-color-tooltip-background: #3a3955;
116
121
  --ck-color-tooltip-text: hsl(0, 0%, 93%);
117
122
 
118
- /* -- Overrides the default colors used by the ckeditor5-image package. --------------------- */
123
+ /* -- Overrides the default colors used by the ckeditor5-image package. - */
119
124
 
120
125
  --ck-color-image-caption-background: hsl(0, 0%, 97%);
121
126
  --ck-color-image-caption-text: hsl(0, 0%, 20%);
122
127
 
123
- /* -- Overrides the default colors used by the ckeditor5-widget package. -------------------- */
128
+ /* -- Overrides the default colors used by the ckeditor5-widget package. */
124
129
 
125
130
  --ck-color-widget-blurred-border: #cfcffa;
126
131
  --ck-color-widget-hover-border: #c9c9e4;
127
132
  --ck-color-widget-editable-focus-background: var(--ck-custom-white);
128
133
 
129
- /* -- Overrides the default colors used by the ckeditor5-link package. ---------------------- */
134
+ /* -- Overrides the default colors used by the ckeditor5-link package. -- */
130
135
 
131
136
  --ck-color-link-default: hsl(209, 89%, 33%);
132
137
 
@@ -1,110 +1,80 @@
1
- import React from "react";
2
- import * as yup from "yup";
1
+ import React from 'react';
2
+ import * as yup from 'yup';
3
3
 
4
- import baseConfigs from "./components/Input/CKEditor/configs";
5
- import getEditorConfig from "./utils/getEditorConfig";
6
- import CKEditorIcon from "./components/CKEditorIcon";
7
- import pluginId from "./utils/pluginId";
4
+ import './utils/exportToGlobal';
5
+ import { getPresetsOptions } from './utils/getPresetsOptions';
6
+ import pluginId from './pluginId';
7
+ import CKEditorIcon from './CKEditorIcon';
8
8
 
9
9
  export default {
10
10
  async register(app) {
11
-
12
- const {
13
- configs: userConfigs = baseConfigs,
14
- configsOverwrite: overwrite
15
- } = await getEditorConfig() || {};
16
-
17
- const setOptions = () => {
18
-
19
- let configs = {};
20
-
21
- if (overwrite) {
22
- configs = userConfigs;
23
- } else {
24
- configs = baseConfigs;
25
- if (userConfigs) {
26
- Object.keys(userConfigs).map(cfgName=>{
27
- if(baseConfigs.hasOwnProperty(cfgName))
28
- configs[cfgName].field = { ...baseConfigs[cfgName].field, ...userConfigs[cfgName].field };
29
- else configs[cfgName] = userConfigs[cfgName];
30
- })
31
- }
32
- }
33
-
34
- const options = [...Object.keys(configs).map(configName=>configs[configName].field)];
35
-
36
- return options;
37
- }
38
-
39
- app.customFields.register({
40
- name: "CKEditor",
41
- type: "richtext",
42
- pluginId: pluginId,
43
- icon: CKEditorIcon,
44
- intlLabel: {
45
- id: pluginId + ".label",
46
- defaultMessage: "CKEditor 5",
47
- },
48
- intlDescription: {
49
- id: pluginId + ".description",
50
- defaultMessage: "The rich text editor for every use case",
51
- },
52
- components: {
53
- Input: async () => import("./components/Input"),
54
- },
55
- options: {
56
- base: [
57
- {
58
- intlLabel: {
59
- id: pluginId + ".preset.label",
60
- defaultMessage: "Choose editor version",
61
- },
62
- description: {
63
- id: pluginId + ".preset.description",
64
- defaultMessage: " ",
65
- },
66
- name: "options.preset",
67
- type: "select",
68
- options: setOptions(),
69
- },
70
- ],
71
- advanced: [
72
- {
73
- sectionTitle: null,
74
- items: [
75
- {
76
- name: "required",
77
- type: "checkbox",
78
- intlLabel: {
79
- id: pluginId + ".required.label",
80
- defaultMessage: "Required field",
81
- },
82
- description: {
83
- id: pluginId + "required.description",
84
- defaultMessage:
85
- "You won't be able to create an entry if this field is empty",
86
- },
87
- },
88
- {
89
- name: "options.maxLengthCharacters",
90
- type: "checkbox-with-number-field",
91
- intlLabel: {
92
- id: pluginId + ".maxLength.label",
93
- defaultMessage: "Maximum length (characters)",
94
- },
95
- }
96
-
97
- ],
98
- },
99
- ],
100
- validator: (args) => ({
101
- preset: yup.string().required({
102
- id: pluginId + ".preset.error.required",
103
- defaultMessage: "Editor preset is required",
104
- }),
105
- }),
106
- },
107
- });
108
- }
109
- };
110
-
11
+ app.customFields.register({
12
+ name: 'CKEditor',
13
+ type: 'richtext',
14
+ pluginId: pluginId,
15
+ icon: CKEditorIcon,
16
+ intlLabel: {
17
+ id: pluginId + '.label',
18
+ defaultMessage: 'CKEditor 5',
19
+ },
20
+ intlDescription: {
21
+ id: pluginId + '.description',
22
+ defaultMessage: 'The rich text editor for every use case',
23
+ },
24
+ components: {
25
+ Input: async () => import('./Input'),
26
+ },
27
+ options: {
28
+ base: [
29
+ {
30
+ intlLabel: {
31
+ id: pluginId + '.preset.label',
32
+ defaultMessage: 'Preset',
33
+ },
34
+ description: {
35
+ id: pluginId + '.preset.description',
36
+ defaultMessage: ' ',
37
+ },
38
+ name: 'options.preset',
39
+ type: 'select',
40
+ options: await getPresetsOptions(),
41
+ },
42
+ ],
43
+ advanced: [
44
+ {
45
+ sectionTitle: null,
46
+ items: [
47
+ {
48
+ name: 'required',
49
+ type: 'checkbox',
50
+ intlLabel: {
51
+ id: pluginId + '.required.label',
52
+ defaultMessage: 'Required field',
53
+ },
54
+ description: {
55
+ id: pluginId + 'required.description',
56
+ defaultMessage:
57
+ "You won't be able to create an entry if this field is empty",
58
+ },
59
+ },
60
+ {
61
+ name: 'options.maxLengthCharacters',
62
+ type: 'checkbox-with-number-field',
63
+ intlLabel: {
64
+ id: pluginId + '.maxLength.label',
65
+ defaultMessage: 'Maximum length (characters)',
66
+ },
67
+ },
68
+ ],
69
+ },
70
+ ],
71
+ validator: (args) => ({
72
+ preset: yup.string().required({
73
+ id: pluginId + '.preset.error.required',
74
+ defaultMessage: 'Editor preset is required',
75
+ }),
76
+ }),
77
+ },
78
+ });
79
+ },
80
+ };
@@ -0,0 +1,7 @@
1
+ const pluginPkg = require('../../package.json');
2
+
3
+ const pluginId =
4
+ pluginPkg.strapi.name ||
5
+ pluginPkg.name.replace(/^(@_sh\/strapi-)plugin-/i, '');
6
+
7
+ module.exports = pluginId;
@@ -0,0 +1,8 @@
1
+ import * as cke from 'ckeditor5';
2
+ import { StrapiMediaLib, StrapiUploadAdapter } from '../Input/plugins';
3
+ import { materialColors } from '../Input/presets/colors';
4
+
5
+ globalThis.SH_CKE = cke;
6
+ globalThis.SH_CKE.StrapiMediaLib = StrapiMediaLib;
7
+ globalThis.SH_CKE.StrapiUploadAdapter = StrapiUploadAdapter;
8
+ globalThis.SH_CKE.MaterialColors = materialColors;
@@ -1,13 +1,13 @@
1
- import pluginId from "./pluginId";
1
+ import pluginId from '../pluginId';
2
2
 
3
3
  const insertConfigScript = () => {
4
4
  const url =
5
- strapi.backendURL !== "/"
6
- ? `${strapi.backendURL}/${pluginId}/ckeditor-config`
7
- : `/${pluginId}/ckeditor-config`;
5
+ strapi.backendURL !== '/'
6
+ ? `${strapi.backendURL}/${pluginId}/config/ckeditor`
7
+ : `/${pluginId}/config/ckeditor`;
8
8
 
9
- var script = document.createElement("script");
10
- script.id = "ckeditor-config";
9
+ var script = document.createElement('script');
10
+ script.id = 'ckeditor-config';
11
11
  script.src = url;
12
12
  document.body.appendChild(script);
13
13
  };
@@ -15,14 +15,14 @@ const insertConfigScript = () => {
15
15
  const waitForConfigToInitialize = async () => {
16
16
  return new Promise((resolve) => {
17
17
  (function checkConfigLoaded() {
18
- if (typeof globalThis.CKEditorConfig !== "undefined") {
19
- resolve(globalThis.CKEditorConfig);
18
+ if (typeof globalThis.SH_CKE_CONFIG !== 'undefined') {
19
+ resolve(globalThis.SH_CKE_CONFIG);
20
20
  } else setTimeout(checkConfigLoaded, 5);
21
21
  })();
22
22
  });
23
23
  };
24
24
 
25
- const getEditorConfig = async () => {
25
+ export const getPluginConfig = async () => {
26
26
  // raw config/ckeditor.[js|ts] file
27
27
  // Can be used with non-JSON serializable properties
28
28
  insertConfigScript();
@@ -31,7 +31,5 @@ const getEditorConfig = async () => {
31
31
  return configFromScript;
32
32
  }
33
33
 
34
- return null;
34
+ return null;
35
35
  };
36
-
37
- export default getEditorConfig;
@@ -0,0 +1,38 @@
1
+ import basePresets from '../Input/presets';
2
+ import { getPluginConfig } from './getPluginConfig';
3
+
4
+ const mergePresetsTo = (userPresets, basePresets) => {
5
+ Object.keys(userPresets).map((presetName) => {
6
+ if (basePresets.hasOwnProperty(presetName)) {
7
+ basePresets[presetName].field = {
8
+ ...basePresets[presetName].field,
9
+ ...userPresets[presetName].field,
10
+ };
11
+ basePresets[presetName].styles =
12
+ userPresets[presetName].styles || basePresets[presetName].styles;
13
+ basePresets[presetName].editorConfig = {
14
+ ...basePresets[presetName].editorConfig,
15
+ ...userPresets[presetName].editorConfig,
16
+ };
17
+ } else {
18
+ basePresets[presetName] = userPresets[presetName];
19
+ }
20
+ });
21
+ };
22
+
23
+ export const getPresetsOptions = async () => {
24
+ const { presets: userPresets, dontMergePresets } =
25
+ (await getPluginConfig()) || {};
26
+
27
+ if (!dontMergePresets && userPresets) {
28
+ mergePresetsTo(userPresets, basePresets);
29
+ }
30
+
31
+ const options = [
32
+ ...Object.keys(basePresets).map(
33
+ (presetName) => basePresets[presetName].field
34
+ ),
35
+ ];
36
+
37
+ return options;
38
+ };