@_sh/strapi-plugin-ckeditor 2.1.2 → 3.0.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.
Files changed (45) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +376 -197
  3. package/admin/src/Input/components/Editor.js +133 -0
  4. package/admin/src/{components/Input/MediaLib/index.js → Input/components/MediaLib.js} +20 -23
  5. package/admin/src/Input/config/index.js +2 -0
  6. package/admin/src/Input/config/language.js +45 -0
  7. package/admin/src/Input/config/plugins.js +24 -0
  8. package/admin/src/Input/config/presets.js +18 -0
  9. package/admin/src/Input/config/styling.js +30 -0
  10. package/admin/src/Input/index.js +67 -0
  11. package/admin/src/{components/Input/CKEditor → Input}/plugins/StrapiMediaLib.js +8 -10
  12. package/admin/src/{components/Input/CKEditor → Input}/plugins/StrapiUploadAdapter.js +16 -34
  13. package/admin/src/{components/Input/CKEditor → Input}/plugins/index.js +1 -1
  14. package/admin/src/Input/presets/colors.js +122 -0
  15. package/admin/src/Input/presets/default.js +378 -0
  16. package/admin/src/Input/presets/index.js +7 -0
  17. package/admin/src/Input/theme/additional.js +189 -0
  18. package/admin/src/{components/Input/CKEditor → Input}/theme/common.js +18 -20
  19. package/admin/src/{components/Input/CKEditor → Input}/theme/dark.js +28 -21
  20. package/admin/src/{components/Input/CKEditor → Input}/theme/light.js +28 -20
  21. package/admin/src/index.js +76 -106
  22. package/admin/src/pluginId.js +7 -0
  23. package/admin/src/utils/exportToGlobal.js +8 -0
  24. package/admin/src/utils/{getEditorConfig.js → getPluginConfig.js} +10 -12
  25. package/admin/src/utils/getPresetsOptions.js +38 -0
  26. package/package.json +12 -44
  27. package/server/controllers/config.js +13 -11
  28. package/server/controllers/index.js +3 -3
  29. package/server/register.js +1 -1
  30. package/server/routes/index.js +7 -12
  31. package/server/services/config.js +16 -11
  32. package/server/services/index.js +3 -3
  33. package/admin/src/components/Input/CKEditor/configs/base.js +0 -639
  34. package/admin/src/components/Input/CKEditor/configs/blockBalloon.js +0 -25
  35. package/admin/src/components/Input/CKEditor/configs/index.js +0 -11
  36. package/admin/src/components/Input/CKEditor/configs/toolbar.js +0 -17
  37. package/admin/src/components/Input/CKEditor/configs/toolbarBalloon.js +0 -17
  38. package/admin/src/components/Input/CKEditor/configuration.js +0 -167
  39. package/admin/src/components/Input/CKEditor/index.js +0 -119
  40. package/admin/src/components/Input/CKEditor/styling.js +0 -24
  41. package/admin/src/components/Input/CKEditor/theme/additional.js +0 -187
  42. package/admin/src/components/Input/index.js +0 -48
  43. package/admin/src/utils/pluginId.js +0 -5
  44. /package/admin/src/{components/CKEditorIcon.js → CKEditorIcon.js} +0 -0
  45. /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 {
@@ -6,15 +6,12 @@ export const dark = css`
6
6
  --ck-color-focus-disabled-shadow: rgba(106, 114, 143, 0.4) !important;
7
7
  --ck-focus-ring: 1px solid #4945ff !important;
8
8
  --ck-color-button-default-hover-background: #262630 !important;
9
-
10
- --ck-powered-by-background: #212134;
11
- --ck-powered-by-border-color: #212134;
12
9
  }
13
10
 
14
11
  .ck.ck-powered-by > a > svg > path:first-child {
15
12
  fill: rgb(236, 236, 236);
16
13
  }
17
-
14
+
18
15
  .ck.ck-powered-by > a > svg > path:nth-child(3) {
19
16
  fill: rgb(172, 156, 251);
20
17
  }
@@ -43,7 +40,8 @@ export const dark = css`
43
40
  --ck-color-base-focus: #bbbaf1;
44
41
  --ck-color-base-active: #2e2e5c;
45
42
  --ck-color-base-active-focus: #28284d;
46
- /* -- Overrides generic colors. ------------------------------------------------------------- */
43
+
44
+ /* -- Overrides generic colors. ----------------------------------------- */
47
45
 
48
46
  --ck-color-base-foreground: var(--ck-custom-background);
49
47
  --ck-color-focus-border: #6765bd;
@@ -51,7 +49,7 @@ export const dark = css`
51
49
  --ck-color-shadow-drop: hsla(0, 0%, 0%, 0.2);
52
50
  --ck-color-shadow-inner: hsla(0, 0%, 0%, 0.1);
53
51
 
54
- /* -- Overrides the default .ck-button class colors. ---------------------------------------- */
52
+ /* -- Overrides the default .ck-button class colors. -------------------- */
55
53
 
56
54
  --ck-color-button-default-background: rgb(33, 33, 52);
57
55
 
@@ -77,17 +75,19 @@ export const dark = css`
77
75
  --ck-color-button-save: hsl(120, 100%, 46%);
78
76
  --ck-color-button-cancel: hsl(15, 100%, 56%);
79
77
 
80
- /* -- Overrides the default .ck-dropdown class colors. -------------------------------------- */
78
+ /* -- Overrides the default .ck-dropdown class colors. ------------------ */
81
79
 
82
80
  --ck-color-dropdown-panel-background: var(--ck-custom-background);
83
81
  --ck-color-dropdown-panel-border: var(--ck-custom-foreground);
84
82
 
85
- /* -- Overrides the default .ck-splitbutton class colors. ----------------------------------- */
83
+ /* -- Overrides the default .ck-splitbutton class colors. --------------- */
86
84
 
87
- --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
+ );
88
88
  --ck-color-split-button-hover-border: var(--ck-custom-foreground);
89
89
 
90
- /* -- Overrides the default .ck-input class colors. ----------------------------------------- */
90
+ /* -- Overrides the default .ck-input class colors. --------------------- */
91
91
 
92
92
  --ck-color-input-background: var(--ck-custom-background);
93
93
  --ck-color-input-border: hsl(257, 3%, 43%);
@@ -96,47 +96,54 @@ export const dark = css`
96
96
  --ck-color-input-disabled-border: hsl(250, 3%, 38%);
97
97
  --ck-color-input-disabled-text: hsl(0, 0%, 78%);
98
98
 
99
- /* -- Overrides the default .ck-labeled-field-view class colors. ---------------------------- */
99
+ /* -- Overrides the default .ck-labeled-field-view class colors. ---------*/
100
100
 
101
101
  --ck-color-labeled-field-label-background: var(--ck-custom-background);
102
102
 
103
- /* -- Overrides the default .ck-list class colors. ------------------------------------------ */
103
+ /* -- Overrides the default .ck-list class colors. ---------------------- */
104
104
 
105
105
  --ck-color-list-background: var(--ck-custom-background);
106
106
  --ck-color-list-button-hover-background: #121221;
107
107
  --ck-color-list-button-on-background: var(--ck-color-base-active);
108
- --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
+ );
109
111
  --ck-color-list-button-on-text: #ffffff;
110
112
 
111
- /* -- Overrides the default .ck-balloon-panel class colors. --------------------------------- */
113
+ /* -- Overrides the default .ck-balloon-panel class colors. ------------- */
112
114
 
113
115
  --ck-color-panel-background: var(--ck-custom-background);
114
116
  --ck-color-panel-border: var(--ck-custom-border);
115
117
 
116
- /* -- Overrides the default .ck-toolbar class colors. --------------------------------------- */
118
+ /* -- Overrides the default .ck-toolbar class colors. ------------------- */
117
119
 
118
120
  --ck-color-toolbar-background: var(--ck-custom-background);
119
121
  --ck-color-toolbar-border: var(--ck-custom-border);
120
122
 
121
- /* -- Overrides the default .ck-tooltip class colors. --------------------------------------- */
123
+ /* -- Overrides the default .ck-tooltip class colors. ------------------- */
122
124
 
123
125
  --ck-color-tooltip-background: #3a3955;
124
126
  --ck-color-tooltip-text: hsl(0, 0%, 93%);
125
127
 
126
- /* -- Overrides the default colors used by the ckeditor5-image package. --------------------- */
128
+ /* -- Overrides the default colors used by the ckeditor5-image package. - */
127
129
 
128
130
  --ck-color-image-caption-background: hsl(0, 0%, 97%);
129
131
  --ck-color-image-caption-text: hsl(0, 0%, 20%);
130
132
 
131
- /* -- Overrides the default colors used by the ckeditor5-widget package. -------------------- */
133
+ /* -- Overrides the default colors used by the ckeditor5-widget package. */
132
134
 
133
135
  --ck-color-widget-blurred-border: #7c7c96;
134
136
  --ck-color-widget-hover-border: #666687;
135
137
  --ck-color-widget-editable-focus-background: var(--ck-custom-white);
136
138
 
137
- /* -- Overrides the default colors used by the ckeditor5-link package. ---------------------- */
139
+ /* -- Overrides the default colors used by the ckeditor5-link package. -- */
138
140
 
139
141
  --ck-color-link-default: hsl(216, 100%, 75%);
140
- }
141
142
 
143
+ --ck-powered-by-background: transparrent;
144
+ --ck-powered-by-border-color: var(--ck-color-base-background);
145
+
146
+ --ck-color-dialog-background: var(--ck-custom-background);
147
+ --ck-color-dialog-form-header-border: var(--ck-color-base-border);
148
+ }
142
149
  `;
@@ -1,14 +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;
9
-
10
- --ck-powered-by-background: #ffffff;
11
- --ck-powered-by-border-color: #ffffff;
8
+ --ck-color-button-default-hover-background: #f0f0ff !important;
12
9
  }
13
10
 
14
11
  .ck.ck-powered-by > a > svg > path:first-child {
@@ -37,7 +34,8 @@ export const light = css`
37
34
  --ck-color-base-focus: #bbbaf1;
38
35
  --ck-color-base-active: #f0f0ff;
39
36
  --ck-color-base-active-focus: #e2e2fd;
40
- /* -- Overrides generic colors. ------------------------------------------------------------- */
37
+
38
+ /* -- Overrides generic colors. ----------------------------------------- */
41
39
 
42
40
  --ck-color-base-foreground: var(--ck-custom-background);
43
41
 
@@ -47,7 +45,7 @@ export const light = css`
47
45
  --ck-color-shadow-drop: hsla(250, 31%, 80%, 0.1);
48
46
  --ck-color-shadow-inner: hsla(250, 31%, 80%, 0.1);
49
47
 
50
- /* -- Overrides the default .ck-button class colors. ---------------------------------------- */
48
+ /* -- Overrides the default .ck-button class colors. -------------------- */
51
49
 
52
50
  --ck-color-button-default-background: var(--ck-custom-background);
53
51
  --ck-color-button-default-hover-background: #f0f0ff;
@@ -72,17 +70,19 @@ export const light = css`
72
70
  --ck-color-button-save: hsl(120, 100%, 46%);
73
71
  --ck-color-button-cancel: hsl(15, 100%, 56%);
74
72
 
75
- /* -- Overrides the default .ck-dropdown class colors. -------------------------------------- */
73
+ /* -- Overrides the default .ck-dropdown class colors. ------------------ */
76
74
 
77
75
  --ck-color-dropdown-panel-background: var(--ck-custom-background);
78
76
  --ck-color-dropdown-panel-border: var(--ck-custom-foreground);
79
77
 
80
- /* -- Overrides the default .ck-splitbutton class colors. ----------------------------------- */
78
+ /* -- Overrides the default .ck-splitbutton class colors. --------------- */
81
79
 
82
- --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
+ );
83
83
  --ck-color-split-button-hover-border: var(--ck-custom-foreground);
84
84
 
85
- /* -- Overrides the default .ck-input class colors. ----------------------------------------- */
85
+ /* -- Overrides the default .ck-input class colors. --------------------- */
86
86
 
87
87
  --ck-color-input-background: var(--ck-custom-background);
88
88
  --ck-color-input-border: hsl(257, 3%, 43%);
@@ -91,46 +91,54 @@ export const light = css`
91
91
  --ck-color-input-disabled-border: rgb(214, 214, 214);
92
92
  --ck-color-input-disabled-text: hsl(0, 0%, 78%);
93
93
 
94
- /* -- Overrides the default .ck-labeled-field-view class colors. ---------------------------- */
94
+ /* -- Overrides the default .ck-labeled-field-view class colors. -------- */
95
95
 
96
96
  --ck-color-labeled-field-label-background: var(--ck-custom-background);
97
97
 
98
- /* -- Overrides the default .ck-list class colors. ------------------------------------------ */
98
+ /* -- Overrides the default .ck-list class colors. ---------------------- */
99
99
 
100
100
  --ck-color-list-background: var(--ck-custom-background);
101
101
  --ck-color-list-button-hover-background: #f4f4fb;
102
102
  --ck-color-list-button-on-background: var(--ck-color-base-active);
103
- --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
+ );
104
106
  --ck-color-list-button-on-text: #271fe2;
105
107
 
106
- /* -- Overrides the default .ck-balloon-panel class colors. --------------------------------- */
108
+ /* -- Overrides the default .ck-balloon-panel class colors. ------------- */
107
109
 
108
110
  --ck-color-panel-background: var(--ck-custom-background);
109
111
  --ck-color-panel-border: var(--ck-custom-border);
110
112
 
111
- /* -- Overrides the default .ck-toolbar class colors. --------------------------------------- */
113
+ /* -- Overrides the default .ck-toolbar class colors. ------------------- */
112
114
 
113
115
  --ck-color-toolbar-background: var(--ck-custom-background);
114
116
  --ck-color-toolbar-border: var(--ck-custom-border);
115
117
 
116
- /* -- Overrides the default .ck-tooltip class colors. --------------------------------------- */
118
+ /* -- Overrides the default .ck-tooltip class colors. ------------------- */
117
119
 
118
120
  --ck-color-tooltip-background: #3a3955;
119
121
  --ck-color-tooltip-text: hsl(0, 0%, 93%);
120
122
 
121
- /* -- Overrides the default colors used by the ckeditor5-image package. --------------------- */
123
+ /* -- Overrides the default colors used by the ckeditor5-image package. - */
122
124
 
123
125
  --ck-color-image-caption-background: hsl(0, 0%, 97%);
124
126
  --ck-color-image-caption-text: hsl(0, 0%, 20%);
125
127
 
126
- /* -- Overrides the default colors used by the ckeditor5-widget package. -------------------- */
128
+ /* -- Overrides the default colors used by the ckeditor5-widget package. */
127
129
 
128
130
  --ck-color-widget-blurred-border: #cfcffa;
129
131
  --ck-color-widget-hover-border: #c9c9e4;
130
132
  --ck-color-widget-editable-focus-background: var(--ck-custom-white);
131
133
 
132
- /* -- Overrides the default colors used by the ckeditor5-link package. ---------------------- */
134
+ /* -- Overrides the default colors used by the ckeditor5-link package. -- */
133
135
 
134
136
  --ck-color-link-default: hsl(209, 89%, 33%);
137
+
138
+ --ck-powered-by-background: transparrent;
139
+ --ck-powered-by-border-color: var(--ck-color-base-background);
140
+
141
+ --ck-color-dialog-background: var(--ck-custom-background);
142
+ --ck-color-dialog-form-header-border: var(--ck-color-base-border);
135
143
  }
136
144
  `;
@@ -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
+ };