@_sh/strapi-plugin-ckeditor 1.0.0 → 1.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.
@@ -23,7 +23,8 @@ const Editor = ({ onChange, name, value, disabled }) => {
23
23
 
24
24
  //####### strapi media lib connector #############################################################################################
25
25
  const [mediaLibVisible, setMediaLibVisible] = useState(false);
26
- const [editor, setEditor] = useState(null);
26
+ const [editor, setEditor] = useState();
27
+ const [uploadCfg, setUploadCfg] = useState();
27
28
  const toggleMediaLib = (editor) => {
28
29
  if (editor) {
29
30
  setEditor(editor);
@@ -34,15 +35,20 @@ const Editor = ({ onChange, name, value, disabled }) => {
34
35
  let newValue = value ? value : "";
35
36
  assets.map((asset) => {
36
37
  if (asset.mime.includes("image")) {
37
- let set =''
38
- let keys = Object.keys(asset.formats)
39
- console.log(asset)
40
- keys?.map(k=>{
41
- let str = prefixFileUrlWithBackendUrl(asset.formats[k].url) + ` ${asset.formats[k].width}w,`
42
- set = set + str
43
- })
44
- const imgTag = `<figure><img src="${asset.url}" alt="${asset.alt}" srcset="${set}"></img></figure>`;
45
- newValue = `${newValue}${imgTag}`;
38
+ if(uploadCfg?.responsiveDimensions){
39
+ let set =''
40
+ let keys = Object.keys(asset.formats)
41
+ console.log(asset)
42
+ keys?.map(k=>{
43
+ let str = prefixFileUrlWithBackendUrl(asset.formats[k].url) + ` ${asset.formats[k].width}w,`
44
+ set = set + str
45
+ })
46
+ const imgTag = `<figure><img src="${asset.url}" alt="${asset.alt}" srcset="${set}"></img></figure>`;
47
+ newValue = `${newValue}${imgTag}`;
48
+ }else{
49
+ const imgTag = `<figure><img src="${asset.url}" alt="${asset.alt}"></img></figure>`;
50
+ newValue = `${newValue}${imgTag}`;
51
+ }
46
52
  }
47
53
  // Handle videos and other type of files by adding some code
48
54
  });
@@ -60,6 +66,7 @@ const Editor = ({ onChange, name, value, disabled }) => {
60
66
  (async () => {
61
67
  const editor = await request(`/${pluginId}/config/editor`, { method: 'GET' });
62
68
  const plugin = await request(`/${pluginId}/config/plugin`, { method: 'GET' });
69
+ const upload = await request(`/${pluginId}/config/uploadcfg`, { method: 'GET' });
63
70
 
64
71
  if(editor){
65
72
  setConfig({
@@ -83,6 +90,12 @@ const Editor = ({ onChange, name, value, disabled }) => {
83
90
  ...plugin,
84
91
  })
85
92
  }
93
+ if(upload){
94
+ setUploadCfg({
95
+ ...uploadCfg,
96
+ ...upload,
97
+ })
98
+ }
86
99
  })();
87
100
 
88
101
  return () => {
@@ -91,8 +104,8 @@ const Editor = ({ onChange, name, value, disabled }) => {
91
104
 
92
105
 
93
106
  //####### theme #############################################################################################
94
- const strapiTheme = localStorage.getItem('STRAPI_THEME');
95
- useEffect(() => {
107
+ useEffect(() => {
108
+ const strapiTheme = localStorage.getItem('STRAPI_THEME');
96
109
  if (strapiTheme)
97
110
  document.documentElement.setAttribute('data-theme', strapiTheme)
98
111
  return () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@_sh/strapi-plugin-ckeditor",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Replaces the default Strapi WYSIWYG editor with a customized buil of CKEditor 5 packed with useful plugins.",
5
5
  "private": false,
6
6
  "keywords": [
@@ -3,7 +3,13 @@
3
3
  module.exports = {
4
4
  getConfig: async (ctx) => {
5
5
  const { configKey } = ctx.params;
6
- const config = await strapi.plugin('ckeditor').service('config').getConfig(configKey);
7
- ctx.send(config);
6
+ if(configKey === 'uploadcfg'){
7
+ const uploadConfig = await strapi.plugin('ckeditor').service('config').getUploadConfig('upload').getSettings();
8
+ ctx.send(uploadConfig);
9
+ }else{
10
+ const config = await strapi.plugin('ckeditor').service('config').getConfig(configKey);
11
+ ctx.send(config);
12
+ }
13
+
8
14
  },
9
- };
15
+ };
@@ -9,5 +9,8 @@ module.exports = ({ strapi }) => {
9
9
  getConfig(key = 'editor') {
10
10
  return strapi.plugin('ckeditor').config(key) ?? {};
11
11
  },
12
+ getUploadConfig(name) {
13
+ return strapi.plugin('upload').service(name) ?? {};
14
+ },
12
15
  };
13
16
  };