@_sh/strapi-plugin-ckeditor 2.0.3 → 2.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/LICENSE +20 -20
- package/README.md +437 -448
- package/admin/src/components/CKEditorIcon.js +46 -46
- package/admin/src/components/Input/CKEditor/configs/base.js +636 -627
- package/admin/src/components/Input/CKEditor/configs/blockBalloon.js +25 -0
- 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/toolbarBalloon.js +17 -0
- package/admin/src/components/Input/CKEditor/configuration.js +166 -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 +186 -212
- package/admin/src/components/Input/CKEditor/theme/common.js +232 -232
- 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 +70 -79
- package/admin/src/components/Input/index.js +48 -48
- package/admin/src/index.js +110 -110
- package/admin/src/utils/getEditorConfig.js +37 -37
- package/admin/src/utils/pluginId.js +4 -4
- package/package.json +90 -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/admin/src/components/Input/CKEditor/configs/blockBaloon.js +0 -25
- package/admin/src/components/Input/CKEditor/configs/toolbarBaloon.js +0 -17
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { blockBalloonEditorConfig } from "./base";
|
|
2
|
+
|
|
3
|
+
export const blockBalloonEditor = {
|
|
4
|
+
blockBalloon: {
|
|
5
|
+
styles: `
|
|
6
|
+
.ck-content{
|
|
7
|
+
border-radius:4px !important;
|
|
8
|
+
}
|
|
9
|
+
.ck-sticky-panel{
|
|
10
|
+
display:none !important;
|
|
11
|
+
}
|
|
12
|
+
`,
|
|
13
|
+
field: {
|
|
14
|
+
key: "blockBalloon",
|
|
15
|
+
value: "blockBalloon",
|
|
16
|
+
metadatas: {
|
|
17
|
+
intlLabel: {
|
|
18
|
+
id: "ckeditor.preset.blockBalloon.label",
|
|
19
|
+
defaultMessage: "Block balloon version",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
editorConfig: blockBalloonEditorConfig,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { toolbarEditor } from './toolbar';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
const baseConfigs = {
|
|
6
|
-
...toolbarEditor,
|
|
7
|
-
...
|
|
8
|
-
...
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export default baseConfigs;
|
|
1
|
+
import { toolbarEditor } from './toolbar';
|
|
2
|
+
import { toolbarBalloonEditor } from './toolbarBalloon';
|
|
3
|
+
import { blockBalloonEditor } from './blockBalloon';
|
|
4
|
+
|
|
5
|
+
const baseConfigs = {
|
|
6
|
+
...toolbarEditor,
|
|
7
|
+
...toolbarBalloonEditor,
|
|
8
|
+
...blockBalloonEditor
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default baseConfigs;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { toolbarEditorConfig } from "./base";
|
|
2
|
-
|
|
3
|
-
export const toolbarEditor = {
|
|
4
|
-
toolbar: {
|
|
5
|
-
field: {
|
|
6
|
-
key: "toolbar",
|
|
7
|
-
value: "toolbar",
|
|
8
|
-
metadatas: {
|
|
9
|
-
intlLabel: {
|
|
10
|
-
id: "ckeditor.preset.toolbar.label",
|
|
11
|
-
defaultMessage: "Toolbar version",
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
editorConfig: toolbarEditorConfig,
|
|
16
|
-
},
|
|
17
|
-
};
|
|
1
|
+
import { toolbarEditorConfig } from "./base";
|
|
2
|
+
|
|
3
|
+
export const toolbarEditor = {
|
|
4
|
+
toolbar: {
|
|
5
|
+
field: {
|
|
6
|
+
key: "toolbar",
|
|
7
|
+
value: "toolbar",
|
|
8
|
+
metadatas: {
|
|
9
|
+
intlLabel: {
|
|
10
|
+
id: "ckeditor.preset.toolbar.label",
|
|
11
|
+
defaultMessage: "Toolbar version",
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
editorConfig: toolbarEditorConfig,
|
|
16
|
+
},
|
|
17
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { toolbarBalloonEditorConfig } from "./base";
|
|
2
|
+
|
|
3
|
+
export const toolbarBalloonEditor = {
|
|
4
|
+
toolbarBalloon: {
|
|
5
|
+
field: {
|
|
6
|
+
key: "toolbarBalloon",
|
|
7
|
+
value: "toolbarBalloon",
|
|
8
|
+
metadatas: {
|
|
9
|
+
intlLabel: {
|
|
10
|
+
id: "ckeditor.preset.toolbarBalloon.label",
|
|
11
|
+
defaultMessage: "Toolbar balloon version",
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
editorConfig: toolbarBalloonEditorConfig,
|
|
16
|
+
},
|
|
17
|
+
};
|
|
@@ -1,166 +1,167 @@
|
|
|
1
|
-
import { auth, request } from "@strapi/helper-plugin";
|
|
2
|
-
import cloneDeep from 'lodash/cloneDeep';
|
|
3
|
-
|
|
4
|
-
import baseConfigs from "./configs";
|
|
5
|
-
import pluginId from "../../../utils/pluginId";
|
|
6
|
-
|
|
7
|
-
const importLang = async (config, language) => {
|
|
8
|
-
|
|
9
|
-
if (!language) return;
|
|
10
|
-
|
|
11
|
-
const { plugins: configPlugins = [] } = config;
|
|
12
|
-
|
|
13
|
-
const configPluginNames = [...configPlugins.map((p) => p.pluginName)];
|
|
14
|
-
|
|
15
|
-
const plugins = [
|
|
16
|
-
{ name: "DocumentList", module: "ckeditor5-list" },
|
|
17
|
-
{ name: "TextPartLanguage", module: "ckeditor5-language" },
|
|
18
|
-
{ name: "Alignment", module: "ckeditor5-alignment" },
|
|
19
|
-
{ name: "Autosave", module: "ckeditor5-autosave" },
|
|
20
|
-
{ name: "BlockQuote", module: "ckeditor5-block-quote" },
|
|
21
|
-
{ name: "CodeBlock", module: "ckeditor5-code-block" },
|
|
22
|
-
{ name: "Heading", module: "ckeditor5-heading" },
|
|
23
|
-
{ name: "HtmlEmbed", module: "ckeditor5-html-embed" },
|
|
24
|
-
{ name: "GeneralHtmlSupport", module: "ckeditor5-html-support" },
|
|
25
|
-
{ name: "HorizontalLine", module: "ckeditor5-horizontal-line" },
|
|
26
|
-
{ name: "MediaEmbed", module: "ckeditor5-media-embed" },
|
|
27
|
-
{ name: "Image", module: "ckeditor5-image" },
|
|
28
|
-
{ name: "Indent", module: "ckeditor5-indent" },
|
|
29
|
-
{ name: "Link", module: "ckeditor5-link" },
|
|
30
|
-
{ name: "RemoveFormat", module: "ckeditor5-remove-format" },
|
|
31
|
-
{ name: "Table", module: "ckeditor5-table" },
|
|
32
|
-
{ name: "WordCount", module: "ckeditor5-word-count" },
|
|
33
|
-
{ name: "FindAndReplace", module: "ckeditor5-find-and-replace" },
|
|
34
|
-
{ name: "SpecialCharacters", module: "ckeditor5-special-characters" },
|
|
35
|
-
{ name: "PageBreak", module: "ckeditor5-page-break" },
|
|
36
|
-
{ name: "SourceEditing", module: "ckeditor5-source-editing" },
|
|
37
|
-
{ name: "Highlight", module: "ckeditor5-highlight" },
|
|
38
|
-
{ name: "Style", module: "ckeditor5-style" },
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
await importLang(config, config.language.
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
await importLang(config, config.language.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
configs[cfgName].
|
|
125
|
-
configs[cfgName].
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
1
|
+
import { auth, request } from "@strapi/helper-plugin";
|
|
2
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
3
|
+
|
|
4
|
+
import baseConfigs from "./configs";
|
|
5
|
+
import pluginId from "../../../utils/pluginId";
|
|
6
|
+
|
|
7
|
+
const importLang = async (config, language) => {
|
|
8
|
+
|
|
9
|
+
if (!language) return;
|
|
10
|
+
|
|
11
|
+
const { plugins: configPlugins = [] } = config;
|
|
12
|
+
|
|
13
|
+
const configPluginNames = [...configPlugins.map((p) => p.pluginName)];
|
|
14
|
+
|
|
15
|
+
const plugins = [
|
|
16
|
+
{ name: "DocumentList", module: "ckeditor5-list" },
|
|
17
|
+
{ name: "TextPartLanguage", module: "ckeditor5-language" },
|
|
18
|
+
{ name: "Alignment", module: "ckeditor5-alignment" },
|
|
19
|
+
{ name: "Autosave", module: "ckeditor5-autosave" },
|
|
20
|
+
{ name: "BlockQuote", module: "ckeditor5-block-quote" },
|
|
21
|
+
{ name: "CodeBlock", module: "ckeditor5-code-block" },
|
|
22
|
+
{ name: "Heading", module: "ckeditor5-heading" },
|
|
23
|
+
{ name: "HtmlEmbed", module: "ckeditor5-html-embed" },
|
|
24
|
+
{ name: "GeneralHtmlSupport", module: "ckeditor5-html-support" },
|
|
25
|
+
{ name: "HorizontalLine", module: "ckeditor5-horizontal-line" },
|
|
26
|
+
{ name: "MediaEmbed", module: "ckeditor5-media-embed" },
|
|
27
|
+
{ name: "Image", module: "ckeditor5-image" },
|
|
28
|
+
{ name: "Indent", module: "ckeditor5-indent" },
|
|
29
|
+
{ name: "Link", module: "ckeditor5-link" },
|
|
30
|
+
{ name: "RemoveFormat", module: "ckeditor5-remove-format" },
|
|
31
|
+
{ name: "Table", module: "ckeditor5-table" },
|
|
32
|
+
{ name: "WordCount", module: "ckeditor5-word-count" },
|
|
33
|
+
{ name: "FindAndReplace", module: "ckeditor5-find-and-replace" },
|
|
34
|
+
{ name: "SpecialCharacters", module: "ckeditor5-special-characters" },
|
|
35
|
+
{ name: "PageBreak", module: "ckeditor5-page-break" },
|
|
36
|
+
{ name: "SourceEditing", module: "ckeditor5-source-editing" },
|
|
37
|
+
{ name: "Highlight", module: "ckeditor5-highlight" },
|
|
38
|
+
{ name: "Style", module: "ckeditor5-style" },
|
|
39
|
+
{ name: "ShowBlocks", module: "ckeditor5-show-blocks" }
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
const basicStylesPlugin = [
|
|
43
|
+
"Bold",
|
|
44
|
+
"Code",
|
|
45
|
+
"Italic",
|
|
46
|
+
"Strikethrough",
|
|
47
|
+
"Subscript",
|
|
48
|
+
"Superscript",
|
|
49
|
+
"Underline",
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
const fontPlugin = ["FontBackgroundColor", "FontColor", "FontFamily", "FontSize"];
|
|
53
|
+
|
|
54
|
+
const listPlugin = ["List", "DocumentList"];
|
|
55
|
+
|
|
56
|
+
await Promise.all(
|
|
57
|
+
plugins
|
|
58
|
+
.filter(({ name }) => configPluginNames.includes(name))
|
|
59
|
+
.map(
|
|
60
|
+
async ({ module }) =>
|
|
61
|
+
await import(
|
|
62
|
+
/* webpackMode: "lazy-once" */ `@ckeditor/${module}/build/translations/${language}.js`
|
|
63
|
+
).catch(() => null)
|
|
64
|
+
)
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
if (configPluginNames.some((p) => basicStylesPlugin.includes(p)))
|
|
68
|
+
await import(
|
|
69
|
+
/* webpackMode: "lazy-once" */ `@ckeditor/ckeditor5-basic-styles/build/translations/${language}.js`
|
|
70
|
+
).catch(() => null);
|
|
71
|
+
if (configPluginNames.some((p) => listPlugin.includes(p)))
|
|
72
|
+
await import(
|
|
73
|
+
/* webpackMode: "lazy-once" */ `@ckeditor/ckeditor5-list/build/translations/${language}.js`
|
|
74
|
+
).catch(() => null);
|
|
75
|
+
if (configPluginNames.some((p) => fontPlugin.includes(p)))
|
|
76
|
+
await import(
|
|
77
|
+
/* webpackMode: "lazy-once" */ `@ckeditor/ckeditor5-font/build/translations/${language}.js`
|
|
78
|
+
).catch(() => null);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const setLanguage = async (config) => {
|
|
82
|
+
const urlSearchParams = new URLSearchParams(window.location.search);
|
|
83
|
+
const params = Object.fromEntries(urlSearchParams.entries());
|
|
84
|
+
const languageContent = params["plugins[i18n][locale]"];
|
|
85
|
+
|
|
86
|
+
const preferedLanguage = auth.getUserInfo().preferedLanguage;
|
|
87
|
+
|
|
88
|
+
const { ui = preferedLanguage || 'en', content, textPartLanguage, ignorei18n } = config.language || {};
|
|
89
|
+
|
|
90
|
+
if (languageContent) {
|
|
91
|
+
const locale = languageContent.split("-")[0];
|
|
92
|
+
|
|
93
|
+
config.language = {
|
|
94
|
+
ui: typeof config.language === "string" ? config.language : ui,
|
|
95
|
+
content: ignorei18n ? content : locale,
|
|
96
|
+
textPartLanguage: textPartLanguage,
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
await importLang(config, config.language.ui);
|
|
100
|
+
await importLang(config, config.language.content);
|
|
101
|
+
} else if (typeof config.language === "object") {
|
|
102
|
+
await importLang(config, config.language.ui);
|
|
103
|
+
await importLang(config, config.language.content);
|
|
104
|
+
} else if (typeof config.language === "string") {
|
|
105
|
+
await importLang(config, config.language);
|
|
106
|
+
} else {
|
|
107
|
+
config.language = preferedLanguage;
|
|
108
|
+
await importLang(config, preferedLanguage);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const getCurrentConfig = (presetName) => {
|
|
113
|
+
const { configs: userConfigs, configsOverwrite: overwrite } = globalThis.CKEditorConfig || {};
|
|
114
|
+
|
|
115
|
+
let configs;
|
|
116
|
+
|
|
117
|
+
if (overwrite) {
|
|
118
|
+
configs = userConfigs;
|
|
119
|
+
} else {
|
|
120
|
+
configs = baseConfigs;
|
|
121
|
+
if (userConfigs) {
|
|
122
|
+
Object.keys(userConfigs).map(cfgName=>{
|
|
123
|
+
if(baseConfigs.hasOwnProperty(cfgName)){
|
|
124
|
+
configs[cfgName].fields = { ...baseConfigs[cfgName].field, ...userConfigs[cfgName].field };
|
|
125
|
+
configs[cfgName].styles = userConfigs[cfgName].styles || baseConfigs[cfgName].styles;
|
|
126
|
+
configs[cfgName].editorConfig = { ...baseConfigs[cfgName].editorConfig, ...userConfigs[cfgName].editorConfig };
|
|
127
|
+
} else { configs[cfgName] = userConfigs[cfgName] }
|
|
128
|
+
})
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const clonedConfig = cloneDeep(configs[presetName]);
|
|
133
|
+
|
|
134
|
+
return clonedConfig;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const setPlugins = (config, { responsiveDimensions }, toggleMediaLib) => {
|
|
138
|
+
const configPluginNames = config.editorConfig?.plugins ? [ ...config.editorConfig.plugins.map((p) => p.pluginName)] : [];
|
|
139
|
+
|
|
140
|
+
if (configPluginNames.includes("StrapiMediaLib")) {
|
|
141
|
+
config.editorConfig.strapiMediaLib = { toggle: toggleMediaLib };
|
|
142
|
+
}
|
|
143
|
+
if (configPluginNames.includes("StrapiUploadAdapter")) {
|
|
144
|
+
config.editorConfig.strapiUploadAdapter = {
|
|
145
|
+
uploadUrl: `${strapi.backendURL}/upload`,
|
|
146
|
+
headers: { Authorization: "Bearer " + auth.getToken() },
|
|
147
|
+
backendUrl: strapi.backendURL,
|
|
148
|
+
responsive: responsiveDimensions,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
if (configPluginNames.includes("WordCount")) {
|
|
152
|
+
config.editorConfig.WordCountPlugin = true;
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
const requestConfig = (key) => request(`/${pluginId}/config/${key}`, { method: "GET" });
|
|
156
|
+
|
|
157
|
+
export const getConfiguration = async (presetName, toggleMediaLib) => {
|
|
158
|
+
const currentConfig = getCurrentConfig(presetName);
|
|
159
|
+
|
|
160
|
+
const uploadPluginConfig = await requestConfig("upload");
|
|
161
|
+
|
|
162
|
+
setPlugins(currentConfig, uploadPluginConfig, toggleMediaLib);
|
|
163
|
+
|
|
164
|
+
await setLanguage(currentConfig.editorConfig);
|
|
165
|
+
|
|
166
|
+
return { currentConfig, uploadPluginConfig };
|
|
166
167
|
};
|