@_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
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { blockBaloonEditorConfig } from "./base";
|
|
2
|
-
|
|
3
|
-
export const blockBaloonEditor = {
|
|
4
|
-
blockBaloon: {
|
|
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: "blockBaloon",
|
|
15
|
-
value: "blockBaloon",
|
|
16
|
-
metadatas: {
|
|
17
|
-
intlLabel: {
|
|
18
|
-
id: "ckeditor.preset.blockBaloon.label",
|
|
19
|
-
defaultMessage: "Block baloon version",
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
editorConfig: blockBaloonEditorConfig,
|
|
24
|
-
},
|
|
25
|
-
};
|
|
1
|
+
import { blockBaloonEditorConfig } from "./base";
|
|
2
|
+
|
|
3
|
+
export const blockBaloonEditor = {
|
|
4
|
+
blockBaloon: {
|
|
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: "blockBaloon",
|
|
15
|
+
value: "blockBaloon",
|
|
16
|
+
metadatas: {
|
|
17
|
+
intlLabel: {
|
|
18
|
+
id: "ckeditor.preset.blockBaloon.label",
|
|
19
|
+
defaultMessage: "Block baloon version",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
editorConfig: blockBaloonEditorConfig,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { toolbarEditor } from './toolbar';
|
|
2
|
-
import { toolbarBaloonEditor } from './toolbarBaloon';
|
|
3
|
-
import { blockBaloonEditor } from './blockBaloon';
|
|
4
|
-
|
|
5
|
-
const baseConfigs = {
|
|
6
|
-
...toolbarEditor,
|
|
7
|
-
...toolbarBaloonEditor,
|
|
8
|
-
...blockBaloonEditor
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export default baseConfigs;
|
|
1
|
+
import { toolbarEditor } from './toolbar';
|
|
2
|
+
import { toolbarBaloonEditor } from './toolbarBaloon';
|
|
3
|
+
import { blockBaloonEditor } from './blockBaloon';
|
|
4
|
+
|
|
5
|
+
const baseConfigs = {
|
|
6
|
+
...toolbarEditor,
|
|
7
|
+
...toolbarBaloonEditor,
|
|
8
|
+
...blockBaloonEditor
|
|
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
|
+
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { toolbarBaloonEditorConfig } from "./base";
|
|
2
|
-
|
|
3
|
-
export const toolbarBaloonEditor = {
|
|
4
|
-
toolbarBaloon: {
|
|
5
|
-
field: {
|
|
6
|
-
key: "toolbarBaloon",
|
|
7
|
-
value: "toolbarBaloon",
|
|
8
|
-
metadatas: {
|
|
9
|
-
intlLabel: {
|
|
10
|
-
id: "ckeditor.preset.toolbarBaloon.label",
|
|
11
|
-
defaultMessage: "Toolbar baloon version",
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
editorConfig: toolbarBaloonEditorConfig,
|
|
16
|
-
},
|
|
17
|
-
};
|
|
1
|
+
import { toolbarBaloonEditorConfig } from "./base";
|
|
2
|
+
|
|
3
|
+
export const toolbarBaloonEditor = {
|
|
4
|
+
toolbarBaloon: {
|
|
5
|
+
field: {
|
|
6
|
+
key: "toolbarBaloon",
|
|
7
|
+
value: "toolbarBaloon",
|
|
8
|
+
metadatas: {
|
|
9
|
+
intlLabel: {
|
|
10
|
+
id: "ckeditor.preset.toolbarBaloon.label",
|
|
11
|
+
defaultMessage: "Toolbar baloon version",
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
editorConfig: toolbarBaloonEditorConfig,
|
|
16
|
+
},
|
|
17
|
+
};
|
|
@@ -1,166 +1,166 @@
|
|
|
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
|
-
const basicStylesPlugin = [
|
|
42
|
-
"Bold",
|
|
43
|
-
"Code",
|
|
44
|
-
"Italic",
|
|
45
|
-
"Strikethrough",
|
|
46
|
-
"Subscript",
|
|
47
|
-
"Superscript",
|
|
48
|
-
"Underline",
|
|
49
|
-
];
|
|
50
|
-
|
|
51
|
-
const fontPlugin = ["FontBackgroundColor", "FontColor", "FontFamily", "FontSize"];
|
|
52
|
-
|
|
53
|
-
const listPlugin = ["List", "DocumentList"];
|
|
54
|
-
|
|
55
|
-
await Promise.all(
|
|
56
|
-
plugins
|
|
57
|
-
.filter(({ name }) => configPluginNames.includes(name))
|
|
58
|
-
.map(
|
|
59
|
-
async ({ module }) =>
|
|
60
|
-
await import(
|
|
61
|
-
/* webpackMode: "lazy-once" */ `@ckeditor/${module}/build/translations/${language}.js`
|
|
62
|
-
).catch(() => null)
|
|
63
|
-
)
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
if (configPluginNames.some((p) => basicStylesPlugin.includes(p)))
|
|
67
|
-
await import(
|
|
68
|
-
/* webpackMode: "lazy-once" */ `@ckeditor/ckeditor5-basic-styles/build/translations/${language}.js`
|
|
69
|
-
).catch(() => null);
|
|
70
|
-
if (configPluginNames.some((p) => listPlugin.includes(p)))
|
|
71
|
-
await import(
|
|
72
|
-
/* webpackMode: "lazy-once" */ `@ckeditor/ckeditor5-list/build/translations/${language}.js`
|
|
73
|
-
).catch(() => null);
|
|
74
|
-
if (configPluginNames.some((p) => fontPlugin.includes(p)))
|
|
75
|
-
await import(
|
|
76
|
-
/* webpackMode: "lazy-once" */ `@_sh/ckeditor5-font-with-picker/build/translations/${language}.js`
|
|
77
|
-
).catch(() => null);
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
const setLanguage = async (config) => {
|
|
81
|
-
const urlSearchParams = new URLSearchParams(window.location.search);
|
|
82
|
-
const params = Object.fromEntries(urlSearchParams.entries());
|
|
83
|
-
const languageContent = params["plugins[i18n][locale]"];
|
|
84
|
-
|
|
85
|
-
const preferedLanguage = auth.getUserInfo().preferedLanguage;
|
|
86
|
-
|
|
87
|
-
const { ui = preferedLanguage || 'en', content, textPartLanguage, ignorei18n } = config.language || {};
|
|
88
|
-
|
|
89
|
-
if (languageContent) {
|
|
90
|
-
const locale = languageContent.split("-")[0];
|
|
91
|
-
|
|
92
|
-
config.language = {
|
|
93
|
-
ui: typeof config.language === "string" ? config.language : ui,
|
|
94
|
-
content: ignorei18n ? content : locale,
|
|
95
|
-
textPartLanguage: textPartLanguage,
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
await importLang(config, config.language.ui);
|
|
99
|
-
await importLang(config, config.language.content);
|
|
100
|
-
} else if (typeof config.language === "object") {
|
|
101
|
-
await importLang(config, config.language.ui);
|
|
102
|
-
await importLang(config, config.language.content);
|
|
103
|
-
} else if (typeof config.language === "string") {
|
|
104
|
-
await importLang(config, config.language);
|
|
105
|
-
} else {
|
|
106
|
-
config.language = preferedLanguage;
|
|
107
|
-
await importLang(config, preferedLanguage);
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
const getCurrentConfig = (presetName) => {
|
|
112
|
-
const { configs: userConfigs, configsOverwrite: overwrite } = globalThis.CKEditorConfig || {};
|
|
113
|
-
|
|
114
|
-
let configs;
|
|
115
|
-
|
|
116
|
-
if (overwrite) {
|
|
117
|
-
configs = userConfigs;
|
|
118
|
-
} else {
|
|
119
|
-
configs = baseConfigs;
|
|
120
|
-
if (userConfigs) {
|
|
121
|
-
Object.keys(userConfigs).map(cfgName=>{
|
|
122
|
-
if(baseConfigs.hasOwnProperty(cfgName)){
|
|
123
|
-
configs[cfgName].fields = { ...baseConfigs[cfgName].field, ...userConfigs[cfgName].field };
|
|
124
|
-
configs[cfgName].styles = userConfigs[cfgName].styles || baseConfigs[cfgName].styles;
|
|
125
|
-
configs[cfgName].editorConfig = { ...baseConfigs[cfgName].editorConfig, ...userConfigs[cfgName].editorConfig };
|
|
126
|
-
} else { configs[cfgName] = userConfigs[cfgName] }
|
|
127
|
-
})
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const clonedConfig = cloneDeep(configs[presetName]);
|
|
132
|
-
|
|
133
|
-
return clonedConfig;
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
const setPlugins = (config, { responsiveDimensions }, toggleMediaLib) => {
|
|
137
|
-
const configPluginNames = config.editorConfig?.plugins ? [ ...config.editorConfig.plugins.map((p) => p.pluginName)] : [];
|
|
138
|
-
|
|
139
|
-
if (configPluginNames.includes("StrapiMediaLib")) {
|
|
140
|
-
config.editorConfig.strapiMediaLib = { toggle: toggleMediaLib };
|
|
141
|
-
}
|
|
142
|
-
if (configPluginNames.includes("StrapiUploadAdapter")) {
|
|
143
|
-
config.editorConfig.strapiUploadAdapter = {
|
|
144
|
-
uploadUrl: `${strapi.backendURL}/upload`,
|
|
145
|
-
headers: { Authorization: "Bearer " + auth.getToken() },
|
|
146
|
-
backendUrl: strapi.backendURL,
|
|
147
|
-
responsive: responsiveDimensions,
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
if (configPluginNames.includes("WordCount")) {
|
|
151
|
-
config.editorConfig.WordCountPlugin = true;
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
const requestConfig = (key) => request(`/${pluginId}/config/${key}`, { method: "GET" });
|
|
155
|
-
|
|
156
|
-
export const getConfiguration = async (presetName, toggleMediaLib) => {
|
|
157
|
-
const currentConfig = getCurrentConfig(presetName);
|
|
158
|
-
|
|
159
|
-
const uploadPluginConfig = await requestConfig("upload");
|
|
160
|
-
|
|
161
|
-
setPlugins(currentConfig, uploadPluginConfig, toggleMediaLib);
|
|
162
|
-
|
|
163
|
-
await setLanguage(currentConfig.editorConfig);
|
|
164
|
-
|
|
165
|
-
return { currentConfig, uploadPluginConfig };
|
|
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
|
+
const basicStylesPlugin = [
|
|
42
|
+
"Bold",
|
|
43
|
+
"Code",
|
|
44
|
+
"Italic",
|
|
45
|
+
"Strikethrough",
|
|
46
|
+
"Subscript",
|
|
47
|
+
"Superscript",
|
|
48
|
+
"Underline",
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
const fontPlugin = ["FontBackgroundColor", "FontColor", "FontFamily", "FontSize"];
|
|
52
|
+
|
|
53
|
+
const listPlugin = ["List", "DocumentList"];
|
|
54
|
+
|
|
55
|
+
await Promise.all(
|
|
56
|
+
plugins
|
|
57
|
+
.filter(({ name }) => configPluginNames.includes(name))
|
|
58
|
+
.map(
|
|
59
|
+
async ({ module }) =>
|
|
60
|
+
await import(
|
|
61
|
+
/* webpackMode: "lazy-once" */ `@ckeditor/${module}/build/translations/${language}.js`
|
|
62
|
+
).catch(() => null)
|
|
63
|
+
)
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
if (configPluginNames.some((p) => basicStylesPlugin.includes(p)))
|
|
67
|
+
await import(
|
|
68
|
+
/* webpackMode: "lazy-once" */ `@ckeditor/ckeditor5-basic-styles/build/translations/${language}.js`
|
|
69
|
+
).catch(() => null);
|
|
70
|
+
if (configPluginNames.some((p) => listPlugin.includes(p)))
|
|
71
|
+
await import(
|
|
72
|
+
/* webpackMode: "lazy-once" */ `@ckeditor/ckeditor5-list/build/translations/${language}.js`
|
|
73
|
+
).catch(() => null);
|
|
74
|
+
if (configPluginNames.some((p) => fontPlugin.includes(p)))
|
|
75
|
+
await import(
|
|
76
|
+
/* webpackMode: "lazy-once" */ `@_sh/ckeditor5-font-with-picker/build/translations/${language}.js`
|
|
77
|
+
).catch(() => null);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const setLanguage = async (config) => {
|
|
81
|
+
const urlSearchParams = new URLSearchParams(window.location.search);
|
|
82
|
+
const params = Object.fromEntries(urlSearchParams.entries());
|
|
83
|
+
const languageContent = params["plugins[i18n][locale]"];
|
|
84
|
+
|
|
85
|
+
const preferedLanguage = auth.getUserInfo().preferedLanguage;
|
|
86
|
+
|
|
87
|
+
const { ui = preferedLanguage || 'en', content, textPartLanguage, ignorei18n } = config.language || {};
|
|
88
|
+
|
|
89
|
+
if (languageContent) {
|
|
90
|
+
const locale = languageContent.split("-")[0];
|
|
91
|
+
|
|
92
|
+
config.language = {
|
|
93
|
+
ui: typeof config.language === "string" ? config.language : ui,
|
|
94
|
+
content: ignorei18n ? content : locale,
|
|
95
|
+
textPartLanguage: textPartLanguage,
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
await importLang(config, config.language.ui);
|
|
99
|
+
await importLang(config, config.language.content);
|
|
100
|
+
} else if (typeof config.language === "object") {
|
|
101
|
+
await importLang(config, config.language.ui);
|
|
102
|
+
await importLang(config, config.language.content);
|
|
103
|
+
} else if (typeof config.language === "string") {
|
|
104
|
+
await importLang(config, config.language);
|
|
105
|
+
} else {
|
|
106
|
+
config.language = preferedLanguage;
|
|
107
|
+
await importLang(config, preferedLanguage);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const getCurrentConfig = (presetName) => {
|
|
112
|
+
const { configs: userConfigs, configsOverwrite: overwrite } = globalThis.CKEditorConfig || {};
|
|
113
|
+
|
|
114
|
+
let configs;
|
|
115
|
+
|
|
116
|
+
if (overwrite) {
|
|
117
|
+
configs = userConfigs;
|
|
118
|
+
} else {
|
|
119
|
+
configs = baseConfigs;
|
|
120
|
+
if (userConfigs) {
|
|
121
|
+
Object.keys(userConfigs).map(cfgName=>{
|
|
122
|
+
if(baseConfigs.hasOwnProperty(cfgName)){
|
|
123
|
+
configs[cfgName].fields = { ...baseConfigs[cfgName].field, ...userConfigs[cfgName].field };
|
|
124
|
+
configs[cfgName].styles = userConfigs[cfgName].styles || baseConfigs[cfgName].styles;
|
|
125
|
+
configs[cfgName].editorConfig = { ...baseConfigs[cfgName].editorConfig, ...userConfigs[cfgName].editorConfig };
|
|
126
|
+
} else { configs[cfgName] = userConfigs[cfgName] }
|
|
127
|
+
})
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const clonedConfig = cloneDeep(configs[presetName]);
|
|
132
|
+
|
|
133
|
+
return clonedConfig;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const setPlugins = (config, { responsiveDimensions }, toggleMediaLib) => {
|
|
137
|
+
const configPluginNames = config.editorConfig?.plugins ? [ ...config.editorConfig.plugins.map((p) => p.pluginName)] : [];
|
|
138
|
+
|
|
139
|
+
if (configPluginNames.includes("StrapiMediaLib")) {
|
|
140
|
+
config.editorConfig.strapiMediaLib = { toggle: toggleMediaLib };
|
|
141
|
+
}
|
|
142
|
+
if (configPluginNames.includes("StrapiUploadAdapter")) {
|
|
143
|
+
config.editorConfig.strapiUploadAdapter = {
|
|
144
|
+
uploadUrl: `${strapi.backendURL}/upload`,
|
|
145
|
+
headers: { Authorization: "Bearer " + auth.getToken() },
|
|
146
|
+
backendUrl: strapi.backendURL,
|
|
147
|
+
responsive: responsiveDimensions,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
if (configPluginNames.includes("WordCount")) {
|
|
151
|
+
config.editorConfig.WordCountPlugin = true;
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
const requestConfig = (key) => request(`/${pluginId}/config/${key}`, { method: "GET" });
|
|
155
|
+
|
|
156
|
+
export const getConfiguration = async (presetName, toggleMediaLib) => {
|
|
157
|
+
const currentConfig = getCurrentConfig(presetName);
|
|
158
|
+
|
|
159
|
+
const uploadPluginConfig = await requestConfig("upload");
|
|
160
|
+
|
|
161
|
+
setPlugins(currentConfig, uploadPluginConfig, toggleMediaLib);
|
|
162
|
+
|
|
163
|
+
await setLanguage(currentConfig.editorConfig);
|
|
164
|
+
|
|
165
|
+
return { currentConfig, uploadPluginConfig };
|
|
166
166
|
};
|