@_sh/strapi-plugin-ckeditor 1.1.0 → 1.1.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.
- package/README.md +2 -1
- package/admin/src/components/CKEditor/index.js +43 -30
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -328,6 +328,7 @@ module.exports = () => {
|
|
|
328
328
|
]
|
|
329
329
|
},
|
|
330
330
|
// https://ckeditor.com/docs/ckeditor5/latest/features/general-html-support.html
|
|
331
|
+
// Regular expressions (/.*/ /^(p|h[2-4])$/' etc) for htmlSupport does not allowed in this config
|
|
331
332
|
htmlSupport: {
|
|
332
333
|
allow: [
|
|
333
334
|
{
|
|
@@ -422,7 +423,7 @@ module.exports = styles;
|
|
|
422
423
|
## <a id="requirements"></a>⚠️ Requirements
|
|
423
424
|
Strapi **v4**
|
|
424
425
|
|
|
425
|
-
Tested on **v4.18 - 4.
|
|
426
|
+
Tested on **v4.18 - 4.2.3**
|
|
426
427
|
|
|
427
428
|
## <a id="thanks"></a>👍 This build includes some useful plugins based on these repos so thanks to them:
|
|
428
429
|
https://github.com/Roslovets-Inc/strapi-plugin-ckeditor5
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import React, { useEffect, useState } from "react";
|
|
2
|
-
import
|
|
2
|
+
import { auth, prefixFileUrlWithBackendUrl, request } from "@strapi/helper-plugin";
|
|
3
3
|
import styled, { createGlobalStyle } from "styled-components";
|
|
4
|
+
|
|
5
|
+
import { Box } from "@strapi/design-system/Box";
|
|
4
6
|
import { CKEditor } from "@ckeditor/ckeditor5-react";
|
|
5
7
|
import { Editor as CustomClassicEditor } from "./build/ckeditor";
|
|
6
|
-
import { Box } from "@strapi/design-system/Box";
|
|
7
|
-
import { prefixFileUrlWithBackendUrl, request, auth } from "@strapi/helper-plugin";
|
|
8
8
|
import MediaLib from "../MediaLib";
|
|
9
|
+
import PropTypes from "prop-types";
|
|
9
10
|
import pluginId from "../../pluginId";
|
|
10
11
|
import styles from "./styles";
|
|
11
12
|
import theme from "./theme";
|
|
12
13
|
|
|
13
14
|
const EditorStyle = createGlobalStyle`
|
|
15
|
+
#fullscreeneditor {z-index: 4!important;}
|
|
14
16
|
${styles}
|
|
15
17
|
${({ strapiTheme }) => strapiTheme}
|
|
16
18
|
${({ custom }) => custom}
|
|
@@ -33,18 +35,19 @@ const Editor = ({ onChange, name, value, disabled }) => {
|
|
|
33
35
|
}
|
|
34
36
|
setMediaLibVisible((prev) => !prev);
|
|
35
37
|
};
|
|
38
|
+
|
|
36
39
|
const handleChangeAssets = (assets) => {
|
|
37
|
-
let newValue =
|
|
40
|
+
let newValue = "";
|
|
41
|
+
|
|
38
42
|
assets.map((asset) => {
|
|
39
43
|
if (asset.mime.includes("image")) {
|
|
40
|
-
if (uploadCfg?.responsiveDimensions) {
|
|
44
|
+
if (asset.formats && uploadCfg?.responsiveDimensions) {
|
|
41
45
|
let set = "";
|
|
42
46
|
let keys = Object.keys(asset.formats).sort((a, b) => {
|
|
43
47
|
return asset.formats[a].width - asset.formats[b].width;
|
|
44
48
|
});
|
|
45
|
-
keys
|
|
46
|
-
let str =
|
|
47
|
-
prefixFileUrlWithBackendUrl(asset.formats[k].url) + ` ${asset.formats[k].width}w,`;
|
|
49
|
+
keys.map((k) => {
|
|
50
|
+
let str = prefixFileUrlWithBackendUrl(asset.formats[k].url) + ` ${asset.formats[k].width}w,`;
|
|
48
51
|
set = set + str;
|
|
49
52
|
});
|
|
50
53
|
const imgTag = `<img src="${asset.url}" alt="${asset.alt}" srcset="${set}"></img>`;
|
|
@@ -56,7 +59,11 @@ const Editor = ({ onChange, name, value, disabled }) => {
|
|
|
56
59
|
}
|
|
57
60
|
// Handle videos and other type of files by adding some code
|
|
58
61
|
});
|
|
59
|
-
|
|
62
|
+
|
|
63
|
+
const viewFragment = editor.data.processor.toView(newValue);
|
|
64
|
+
const modelFragment = editor.data.toModel(viewFragment);
|
|
65
|
+
editor.model.insertContent(modelFragment);
|
|
66
|
+
|
|
60
67
|
toggleMediaLib();
|
|
61
68
|
};
|
|
62
69
|
|
|
@@ -73,12 +80,28 @@ const Editor = ({ onChange, name, value, disabled }) => {
|
|
|
73
80
|
const plugin = await request(`/${pluginId}/config/plugin`, { method: "GET" });
|
|
74
81
|
const upload = await request(`/${pluginId}/config/uploadcfg`, { method: "GET" });
|
|
75
82
|
|
|
83
|
+
//read i18n locale
|
|
84
|
+
const urlSearchParams = new URLSearchParams(window.location.search);
|
|
85
|
+
const params = Object.fromEntries(urlSearchParams.entries());
|
|
86
|
+
const languageContent = params["plugins[i18n][locale]"];
|
|
87
|
+
|
|
76
88
|
if (editor) {
|
|
89
|
+
//set locale language code to content
|
|
90
|
+
let language = editor.language;
|
|
91
|
+
if (languageContent) {
|
|
92
|
+
const countryCode = languageContent.split("-")[0]
|
|
93
|
+
if (countryCode && language)
|
|
94
|
+
language = {
|
|
95
|
+
content: language.content || countryCode,
|
|
96
|
+
ui: typeof language === "string" && language || language.ui || auth.getUserInfo().preferedLanguage,
|
|
97
|
+
textPartLanguage: language.textPartLanguage
|
|
98
|
+
}
|
|
99
|
+
}
|
|
77
100
|
setConfig({
|
|
78
101
|
...config,
|
|
79
102
|
editor: {
|
|
80
103
|
...editor,
|
|
81
|
-
language:
|
|
104
|
+
language: language ? language : auth.getUserInfo().preferedLanguage,
|
|
82
105
|
strapiMediaLib: {
|
|
83
106
|
onToggle: toggleMediaLib,
|
|
84
107
|
label: "Media library",
|
|
@@ -92,27 +115,17 @@ const Editor = ({ onChange, name, value, disabled }) => {
|
|
|
92
115
|
|
|
93
116
|
if (editor.language) {
|
|
94
117
|
if (editor.language.ui) {
|
|
95
|
-
import(
|
|
96
|
-
/* webpackMode: "eager" */ `./build/translations/${editor.language.ui}.js`
|
|
97
|
-
).catch(() => null);
|
|
118
|
+
import(/* webpackMode: "eager" */ `./build/translations/${editor.language.ui}.js`).catch(() => null);
|
|
98
119
|
}
|
|
99
120
|
if (editor.language.content) {
|
|
100
|
-
import(
|
|
101
|
-
/* webpackMode: "eager" */ `./build/translations/${editor.language.content}.js`
|
|
102
|
-
).catch(() => null);
|
|
121
|
+
import(/* webpackMode: "eager" */ `./build/translations/${editor.language.content}.js`).catch(() => null);
|
|
103
122
|
}
|
|
104
123
|
if (typeof editor.language !== "object") {
|
|
105
|
-
import(/* webpackMode: "eager" */ `./build/translations/${editor.language}.js`).catch(
|
|
106
|
-
() => null
|
|
107
|
-
);
|
|
124
|
+
import(/* webpackMode: "eager" */ `./build/translations/${editor.language}.js`).catch(() => null);
|
|
108
125
|
}
|
|
109
126
|
}
|
|
110
127
|
if (!editor.language) {
|
|
111
|
-
import(
|
|
112
|
-
/* webpackMode: "eager" */ `./build/translations/${
|
|
113
|
-
auth.getUserInfo().preferedLanguage
|
|
114
|
-
}.js`
|
|
115
|
-
).catch(() => null);
|
|
128
|
+
import(/* webpackMode: "eager" */ `./build/translations/${auth.getUserInfo().preferedLanguage}.js`).catch(() => null);
|
|
116
129
|
}
|
|
117
130
|
}
|
|
118
131
|
if (plugin) {
|
|
@@ -132,16 +145,14 @@ const Editor = ({ onChange, name, value, disabled }) => {
|
|
|
132
145
|
}
|
|
133
146
|
})();
|
|
134
147
|
|
|
135
|
-
return () => {};
|
|
148
|
+
return () => { };
|
|
136
149
|
}, []);
|
|
137
150
|
|
|
138
151
|
//###########################################################################################################
|
|
152
|
+
|
|
139
153
|
return (
|
|
140
154
|
<Wrapper className="ck-editor__styled__container">
|
|
141
|
-
<EditorStyle
|
|
142
|
-
custom={pluginCfg.styles}
|
|
143
|
-
strapiTheme={pluginCfg.strapiTheme !== false ? theme : ""}
|
|
144
|
-
/>
|
|
155
|
+
<EditorStyle custom={pluginCfg.styles} strapiTheme={pluginCfg.strapiTheme !== false ? theme : ""} />
|
|
145
156
|
{config && (
|
|
146
157
|
<CKEditor
|
|
147
158
|
editor={CustomClassicEditor}
|
|
@@ -155,7 +166,9 @@ const Editor = ({ onChange, name, value, disabled }) => {
|
|
|
155
166
|
config={config?.editor}
|
|
156
167
|
/>
|
|
157
168
|
)}
|
|
158
|
-
<
|
|
169
|
+
<div style={{zIndex:5}}>
|
|
170
|
+
<MediaLib isOpen={mediaLibVisible} onChange={handleChangeAssets} onToggle={toggleMediaLib} />
|
|
171
|
+
</div>
|
|
159
172
|
</Wrapper>
|
|
160
173
|
);
|
|
161
174
|
};
|
package/package.json
CHANGED