@_sh/strapi-plugin-ckeditor 1.1.2 → 2.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 (122) hide show
  1. package/README.md +360 -863
  2. package/admin/src/components/CKEditorIcon.js +46 -0
  3. package/admin/src/components/Input/CKEditor/configs/base.js +628 -0
  4. package/admin/src/components/Input/CKEditor/configs/blockBaloon.js +25 -0
  5. package/admin/src/components/Input/CKEditor/configs/index.js +11 -0
  6. package/admin/src/components/Input/CKEditor/configs/toolbar.js +17 -0
  7. package/admin/src/components/Input/CKEditor/configs/toolbarBaloon.js +17 -0
  8. package/admin/src/components/Input/CKEditor/configuration.js +166 -0
  9. package/admin/src/components/Input/CKEditor/index.js +120 -0
  10. package/admin/src/components/Input/CKEditor/plugins/StrapiMediaLib.js +43 -0
  11. package/admin/src/components/Input/CKEditor/plugins/StrapiUploadAdapter.js +203 -0
  12. package/admin/src/components/Input/CKEditor/plugins/index.js +2 -0
  13. package/admin/src/components/Input/CKEditor/styling.js +16 -0
  14. package/admin/src/components/Input/CKEditor/theme/additional.js +167 -0
  15. package/admin/src/components/Input/CKEditor/theme/common.js +277 -0
  16. package/admin/src/components/Input/CKEditor/theme/dark.js +144 -0
  17. package/admin/src/components/Input/CKEditor/theme/index.js +13 -0
  18. package/admin/src/components/Input/CKEditor/theme/light.js +135 -0
  19. package/admin/src/components/Input/MediaLib/index.js +79 -0
  20. package/admin/src/components/Input/index.js +48 -0
  21. package/admin/src/index.js +110 -18
  22. package/admin/src/utils/getEditorConfig.js +37 -0
  23. package/admin/src/utils/pluginId.js +5 -0
  24. package/package.json +86 -50
  25. package/server/controllers/config.js +16 -14
  26. package/server/controllers/index.js +7 -7
  27. package/server/index.js +13 -25
  28. package/server/register.js +11 -5
  29. package/server/routes/index.js +15 -8
  30. package/server/services/config.js +11 -6
  31. package/server/services/index.js +7 -7
  32. package/strapi-admin.js +3 -3
  33. package/strapi-server.js +3 -3
  34. package/admin/src/components/CKEditor/build/ckeditor.js +0 -7
  35. package/admin/src/components/CKEditor/build/ckeditor.js.map +0 -1
  36. package/admin/src/components/CKEditor/build/translations/af.js +0 -1
  37. package/admin/src/components/CKEditor/build/translations/ar.js +0 -1
  38. package/admin/src/components/CKEditor/build/translations/ast.js +0 -1
  39. package/admin/src/components/CKEditor/build/translations/az.js +0 -1
  40. package/admin/src/components/CKEditor/build/translations/bg.js +0 -1
  41. package/admin/src/components/CKEditor/build/translations/bn.js +0 -1
  42. package/admin/src/components/CKEditor/build/translations/bs.js +0 -1
  43. package/admin/src/components/CKEditor/build/translations/ca.js +0 -1
  44. package/admin/src/components/CKEditor/build/translations/cs.js +0 -1
  45. package/admin/src/components/CKEditor/build/translations/da.js +0 -1
  46. package/admin/src/components/CKEditor/build/translations/de-ch.js +0 -1
  47. package/admin/src/components/CKEditor/build/translations/de.js +0 -1
  48. package/admin/src/components/CKEditor/build/translations/el.js +0 -1
  49. package/admin/src/components/CKEditor/build/translations/en-au.js +0 -1
  50. package/admin/src/components/CKEditor/build/translations/en-gb.js +0 -1
  51. package/admin/src/components/CKEditor/build/translations/eo.js +0 -1
  52. package/admin/src/components/CKEditor/build/translations/es.js +0 -1
  53. package/admin/src/components/CKEditor/build/translations/et.js +0 -1
  54. package/admin/src/components/CKEditor/build/translations/eu.js +0 -1
  55. package/admin/src/components/CKEditor/build/translations/fa.js +0 -1
  56. package/admin/src/components/CKEditor/build/translations/fi.js +0 -1
  57. package/admin/src/components/CKEditor/build/translations/fr.js +0 -1
  58. package/admin/src/components/CKEditor/build/translations/gl.js +0 -1
  59. package/admin/src/components/CKEditor/build/translations/gu.js +0 -1
  60. package/admin/src/components/CKEditor/build/translations/he.js +0 -1
  61. package/admin/src/components/CKEditor/build/translations/hi.js +0 -1
  62. package/admin/src/components/CKEditor/build/translations/hr.js +0 -1
  63. package/admin/src/components/CKEditor/build/translations/hu.js +0 -1
  64. package/admin/src/components/CKEditor/build/translations/id.js +0 -1
  65. package/admin/src/components/CKEditor/build/translations/it.js +0 -1
  66. package/admin/src/components/CKEditor/build/translations/ja.js +0 -1
  67. package/admin/src/components/CKEditor/build/translations/jv.js +0 -1
  68. package/admin/src/components/CKEditor/build/translations/kk.js +0 -1
  69. package/admin/src/components/CKEditor/build/translations/km.js +0 -1
  70. package/admin/src/components/CKEditor/build/translations/kn.js +0 -1
  71. package/admin/src/components/CKEditor/build/translations/ko.js +0 -1
  72. package/admin/src/components/CKEditor/build/translations/ku.js +0 -1
  73. package/admin/src/components/CKEditor/build/translations/lt.js +0 -1
  74. package/admin/src/components/CKEditor/build/translations/lv.js +0 -1
  75. package/admin/src/components/CKEditor/build/translations/ms.js +0 -1
  76. package/admin/src/components/CKEditor/build/translations/nb.js +0 -1
  77. package/admin/src/components/CKEditor/build/translations/ne.js +0 -1
  78. package/admin/src/components/CKEditor/build/translations/nl.js +0 -1
  79. package/admin/src/components/CKEditor/build/translations/no.js +0 -1
  80. package/admin/src/components/CKEditor/build/translations/oc.js +0 -1
  81. package/admin/src/components/CKEditor/build/translations/pl.js +0 -1
  82. package/admin/src/components/CKEditor/build/translations/pt-br.js +0 -1
  83. package/admin/src/components/CKEditor/build/translations/pt.js +0 -1
  84. package/admin/src/components/CKEditor/build/translations/ro.js +0 -1
  85. package/admin/src/components/CKEditor/build/translations/ru.js +0 -1
  86. package/admin/src/components/CKEditor/build/translations/si.js +0 -1
  87. package/admin/src/components/CKEditor/build/translations/sk.js +0 -1
  88. package/admin/src/components/CKEditor/build/translations/sl.js +0 -1
  89. package/admin/src/components/CKEditor/build/translations/sq.js +0 -1
  90. package/admin/src/components/CKEditor/build/translations/sr-latn.js +0 -1
  91. package/admin/src/components/CKEditor/build/translations/sr.js +0 -1
  92. package/admin/src/components/CKEditor/build/translations/sv.js +0 -1
  93. package/admin/src/components/CKEditor/build/translations/th.js +0 -1
  94. package/admin/src/components/CKEditor/build/translations/tk.js +0 -1
  95. package/admin/src/components/CKEditor/build/translations/tr.js +0 -1
  96. package/admin/src/components/CKEditor/build/translations/tt.js +0 -1
  97. package/admin/src/components/CKEditor/build/translations/ug.js +0 -1
  98. package/admin/src/components/CKEditor/build/translations/uk.js +0 -1
  99. package/admin/src/components/CKEditor/build/translations/ur.js +0 -1
  100. package/admin/src/components/CKEditor/build/translations/uz.js +0 -1
  101. package/admin/src/components/CKEditor/build/translations/vi.js +0 -1
  102. package/admin/src/components/CKEditor/build/translations/zh-cn.js +0 -1
  103. package/admin/src/components/CKEditor/build/translations/zh.js +0 -1
  104. package/admin/src/components/CKEditor/index.js +0 -194
  105. package/admin/src/components/CKEditor/styles.js +0 -511
  106. package/admin/src/components/CKEditor/theme.js +0 -313
  107. package/admin/src/components/Initializer/index.js +0 -26
  108. package/admin/src/components/MediaLib/index.js +0 -44
  109. package/admin/src/components/Wysiwyg/index.js +0 -77
  110. package/admin/src/pages/App/index.js +0 -25
  111. package/admin/src/pages/HomePage/index.js +0 -20
  112. package/admin/src/pluginId.js +0 -6
  113. package/admin/src/translations/en.json +0 -1
  114. package/admin/src/translations/fr.json +0 -1
  115. package/admin/src/utils/axiosInstance.js +0 -40
  116. package/admin/src/utils/getTrad.js +0 -5
  117. package/server/bootstrap.js +0 -5
  118. package/server/config/index.js +0 -6
  119. package/server/content-types/index.js +0 -3
  120. package/server/destroy.js +0 -5
  121. package/server/middlewares/index.js +0 -3
  122. package/server/policies/index.js +0 -3
@@ -0,0 +1,135 @@
1
+ import { css } from "styled-components";
2
+
3
+ export const light = css`
4
+ :root {
5
+ --ck-color-focus-outer-shadow: rgba(77, 115, 255, 0.2) !important;
6
+ --ck-color-focus-disabled-shadow: #e4e3ff !important;
7
+ --ck-focus-ring: 1px solid rgb(73, 69, 255) !important;
8
+ --ck-color-button-default-hover-background: #F0F0FF !important;
9
+
10
+ .ck .ck-color-picker-save {
11
+ & > svg {
12
+ stroke: #7b79ff !important;
13
+ }
14
+ }
15
+ }
16
+
17
+ .ck {
18
+ --ck-scroll-track-background: rgb(242, 242, 242);
19
+ --ck-scroll-thumb-background: rgb(236, 236, 236);
20
+ --ck-scroll-thumb-border-color: #cdcdf8;
21
+ --ck-scroll-thumb-hover-background: #f0f0ff;
22
+ --ck-scroll-thumb-active-background: #d9d8ff;
23
+
24
+ --ck-color-editor-base-text: #001234;
25
+ /* Overrides the border radius setting in the theme. */
26
+ --ck-border-radius: 4px;
27
+
28
+ /* Helper variables to avoid duplication in the colors. */
29
+ --ck-color-base-border: #dcdce4;
30
+ --ck-color-base-background: #ffffff;
31
+ --ck-custom-background: #ffffff;
32
+ --ck-custom-foreground: #dedede;
33
+ --ck-custom-border: #dcdce4;
34
+ --ck-custom-white: hsl(0, 0%, 100%);
35
+
36
+ --ck-color-base-focus: #bbbaf1;
37
+ --ck-color-base-active: #f0f0ff;
38
+ --ck-color-base-active-focus: #e2e2fd;
39
+ /* -- Overrides generic colors. ------------------------------------------------------------- */
40
+
41
+ --ck-color-base-foreground: var(--ck-custom-background);
42
+
43
+ --ck-color-focus-border: rgb(73, 69, 255);
44
+
45
+ --ck-color-text: #32324d;
46
+ --ck-color-shadow-drop: hsla(250, 31%, 80%, 0.1);
47
+ --ck-color-shadow-inner: hsla(250, 31%, 80%, 0.1);
48
+
49
+ /* -- Overrides the default .ck-button class colors. ---------------------------------------- */
50
+
51
+ --ck-color-button-default-background: var(--ck-custom-background);
52
+ --ck-color-button-default-hover-background: #f0f0ff;
53
+ --ck-color-button-default-active-background: #f6f6f9;
54
+ --ck-color-button-default-active-shadow: #dedefb;
55
+ --ck-color-button-default-disabled-background: var(--ck-custom-background);
56
+
57
+ --ck-color-button-on-color: rgb(73, 69, 255);
58
+ --ck-color-button-on-background: #f0f0ff;
59
+ --ck-color-button-on-hover-background: #e6e9fc;
60
+ --ck-color-button-on-active-background: #f6f6f9;
61
+ --ck-color-button-on-active-shadow: #cdcdf8;
62
+ --ck-color-button-on-disabled-background: var(--ck-custom-foreground);
63
+
64
+ --ck-color-button-action-background: hsl(168, 76%, 42%);
65
+ --ck-color-button-action-hover-background: hsl(168, 76%, 38%);
66
+ --ck-color-button-action-active-background: hsl(168, 76%, 36%);
67
+ --ck-color-button-action-active-shadow: hsl(168, 75%, 34%);
68
+ --ck-color-button-action-disabled-background: hsl(168, 76%, 42%);
69
+ --ck-color-button-action-text: var(--ck-custom-white);
70
+
71
+ --ck-color-button-save: hsl(120, 100%, 46%);
72
+ --ck-color-button-cancel: hsl(15, 100%, 56%);
73
+
74
+ /* -- Overrides the default .ck-dropdown class colors. -------------------------------------- */
75
+
76
+ --ck-color-dropdown-panel-background: var(--ck-custom-background);
77
+ --ck-color-dropdown-panel-border: var(--ck-custom-foreground);
78
+
79
+ /* -- Overrides the default .ck-splitbutton class colors. ----------------------------------- */
80
+
81
+ --ck-color-split-button-hover-background: var(--ck-color-button-default-hover-background);
82
+ --ck-color-split-button-hover-border: var(--ck-custom-foreground);
83
+
84
+ /* -- Overrides the default .ck-input class colors. ----------------------------------------- */
85
+
86
+ --ck-color-input-background: var(--ck-custom-background);
87
+ --ck-color-input-border: hsl(257, 3%, 43%);
88
+ --ck-color-input-text: hsl(0, 0%, 98%);
89
+ --ck-color-input-disabled-background: hsl(0, 0%, 97%);
90
+ --ck-color-input-disabled-border: rgb(214, 214, 214);
91
+ --ck-color-input-disabled-text: hsl(0, 0%, 78%);
92
+
93
+ /* -- Overrides the default .ck-labeled-field-view class colors. ---------------------------- */
94
+
95
+ --ck-color-labeled-field-label-background: var(--ck-custom-background);
96
+
97
+ /* -- Overrides the default .ck-list class colors. ------------------------------------------ */
98
+
99
+ --ck-color-list-background: var(--ck-custom-background);
100
+ --ck-color-list-button-hover-background: #f4f4fb;
101
+ --ck-color-list-button-on-background: var(--ck-color-base-active);
102
+ --ck-color-list-button-on-background-focus: var(--ck-color-base-active-focus);
103
+ --ck-color-list-button-on-text: #271fe2;
104
+
105
+ /* -- Overrides the default .ck-balloon-panel class colors. --------------------------------- */
106
+
107
+ --ck-color-panel-background: var(--ck-custom-background);
108
+ --ck-color-panel-border: var(--ck-custom-border);
109
+
110
+ /* -- Overrides the default .ck-toolbar class colors. --------------------------------------- */
111
+
112
+ --ck-color-toolbar-background: var(--ck-custom-background);
113
+ --ck-color-toolbar-border: var(--ck-custom-border);
114
+
115
+ /* -- Overrides the default .ck-tooltip class colors. --------------------------------------- */
116
+
117
+ --ck-color-tooltip-background: #3a3955;
118
+ --ck-color-tooltip-text: hsl(0, 0%, 93%);
119
+
120
+ /* -- Overrides the default colors used by the ckeditor5-image package. --------------------- */
121
+
122
+ --ck-color-image-caption-background: hsl(0, 0%, 97%);
123
+ --ck-color-image-caption-text: hsl(0, 0%, 20%);
124
+
125
+ /* -- Overrides the default colors used by the ckeditor5-widget package. -------------------- */
126
+
127
+ --ck-color-widget-blurred-border: #cfcffa;
128
+ --ck-color-widget-hover-border: #c9c9e4;
129
+ --ck-color-widget-editable-focus-background: var(--ck-custom-white);
130
+
131
+ /* -- Overrides the default colors used by the ckeditor5-link package. ---------------------- */
132
+
133
+ --ck-color-link-default: hsl(209, 89%, 33%);
134
+ }
135
+ `;
@@ -0,0 +1,79 @@
1
+ import React from "react";
2
+ import { prefixFileUrlWithBackendUrl, useLibrary } from "@strapi/helper-plugin";
3
+ import PropTypes from "prop-types";
4
+
5
+ const MediaLib = ({ isOpen, onChange, onToggle, editor, uploadConfig: { responsiveDimensions } }) => {
6
+ const { components } = useLibrary();
7
+ const MediaLibraryDialog = components["media-library"];
8
+
9
+ const handleChangeAssets = (assets) => {
10
+ let newValue = "";
11
+
12
+ assets.map(({name, url, alt, formats, mime}) => {
13
+
14
+ if (mime.includes("image")) {
15
+
16
+ if (formats && responsiveDimensions) {
17
+ let set = "";
18
+ let keys = Object.keys(formats).sort((a, b) => formats[a].width - formats[b].width );
19
+ keys.map((k) => set += prefixFileUrlWithBackendUrl(formats[k].url) + ` ${formats[k].width}w,`);
20
+ newValue += `<img src="${url}" alt="${alt}" width="${formats[keys[keys.length-1]].width}px" srcset="${set}" />`;
21
+ } else {
22
+ newValue += `<img src="${url}" alt="${alt}" />`;
23
+ }
24
+
25
+ } else if (mime.includes("application/pdf")) {
26
+
27
+ newValue = `<a href="${prefixFileUrlWithBackendUrl(url)}" download="${name}">${name || 'Download PDF'}</a>`;
28
+
29
+ }
30
+ // Handle videos and other type of files by adding some code
31
+ });
32
+
33
+ const viewFragment = editor.data.processor.toView( newValue );
34
+ const modelFragment = editor.data.toModel( viewFragment );
35
+ editor.model.insertContent( modelFragment );
36
+
37
+ onToggle();
38
+ };
39
+
40
+ const handleSelectAssets = (files) => {
41
+ const formattedFiles = files.map((f) => ({
42
+ name: f.name,
43
+ alt: f.alternativeText || f.name,
44
+ url: prefixFileUrlWithBackendUrl(f.url),
45
+ mime: f.mime,
46
+ formats: f.formats
47
+ }));
48
+
49
+ handleChangeAssets(formattedFiles);
50
+ };
51
+
52
+
53
+
54
+
55
+ if (!isOpen) {
56
+ return null;
57
+ }
58
+
59
+ return (
60
+ <MediaLibraryDialog
61
+ onClose={onToggle}
62
+ onSelectAssets={handleSelectAssets}
63
+ />
64
+ );
65
+ };
66
+
67
+ MediaLib.defaultProps = {
68
+ isOpen: false,
69
+ onChange: () => {},
70
+ onToggle: () => {},
71
+ };
72
+
73
+ MediaLib.propTypes = {
74
+ isOpen: PropTypes.bool,
75
+ onChange: PropTypes.func,
76
+ onToggle: PropTypes.func,
77
+ };
78
+
79
+ export default MediaLib;
@@ -0,0 +1,48 @@
1
+ import React from "react";
2
+ import PropTypes from "prop-types";
3
+ import {default as CKEditor} from "./CKEditor";
4
+ import { useIntl } from "react-intl";
5
+ import { Field, FieldHint, FieldError, FieldLabel } from "@strapi/design-system/Field";
6
+ import { Stack } from "@strapi/design-system/Stack";
7
+
8
+ const Wysiwyg = ({ name, attribute, onChange, value, intlLabel, labelAction, disabled, error, description, required }) => {
9
+ const { formatMessage } = useIntl();
10
+ const { preset, maxLengthCharacters, ...options } = attribute.options;
11
+
12
+ return (
13
+ <Field name={name} id={name} error={error} hint={description && formatMessage(description)}>
14
+ <Stack spacing={1}>
15
+ <FieldLabel action={labelAction} required={required}>
16
+ {formatMessage(intlLabel)}
17
+ </FieldLabel>
18
+ <CKEditor disabled={disabled} name={name} onChange={onChange} value={value} preset={preset} maxLength={maxLengthCharacters}/>
19
+ <FieldHint />
20
+ <FieldError />
21
+ </Stack>
22
+ </Field>
23
+ );
24
+ };
25
+
26
+
27
+ Wysiwyg.defaultProps = {
28
+ description: null,
29
+ disabled: false,
30
+ error: null,
31
+ labelAction: null,
32
+ required: false,
33
+ value: "",
34
+ };
35
+
36
+ Wysiwyg.propTypes = {
37
+ intlLabel: PropTypes.object.isRequired,
38
+ onChange: PropTypes.func.isRequired,
39
+ attribute: PropTypes.object.isRequired,
40
+ name: PropTypes.string.isRequired,
41
+ description: PropTypes.object,
42
+ disabled: PropTypes.bool,
43
+ error: PropTypes.string,
44
+ labelAction: PropTypes.object,
45
+ required: PropTypes.bool,
46
+ value: PropTypes.string,
47
+ };
48
+ export default Wysiwyg;
@@ -1,18 +1,110 @@
1
- import pluginPkg from "../../package.json";
2
- import Wysiwyg from "./components/Wysiwyg";
3
- import pluginId from "./pluginId";
4
-
5
- const name = pluginPkg.strapi.name;
6
-
7
- export default {
8
- register(app) {
9
- app.addFields({ type: "wysiwyg", Component: Wysiwyg });
10
- app.registerPlugin({
11
- id: pluginId,
12
- isReady: true,
13
- name,
14
- });
15
- },
16
- bootstrap(app) {
17
- },
18
- };
1
+ import React from "react";
2
+ import * as yup from "yup";
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";
8
+
9
+ export default {
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
+
@@ -0,0 +1,37 @@
1
+ import pluginId from "./pluginId";
2
+
3
+ const insertConfigScript = () => {
4
+ const url =
5
+ strapi.backendURL !== "/"
6
+ ? `${strapi.backendURL}/${pluginId}/ckeditor-config`
7
+ : `/${pluginId}/ckeditor-config`;
8
+
9
+ var script = document.createElement("script");
10
+ script.id = "ckeditor-config";
11
+ script.src = url;
12
+ document.body.appendChild(script);
13
+ };
14
+
15
+ const waitForConfigToInitialize = async () => {
16
+ return new Promise((resolve) => {
17
+ (function checkConfigLoaded() {
18
+ if (typeof globalThis.CKEditorConfig !== "undefined") {
19
+ resolve(globalThis.CKEditorConfig);
20
+ } else setTimeout(checkConfigLoaded, 5);
21
+ })();
22
+ });
23
+ };
24
+
25
+ const getEditorConfig = async () => {
26
+ // raw config/ckeditor.[js|ts] file
27
+ // Can be used with non-JSON serializable properties
28
+ insertConfigScript();
29
+ const configFromScript = await waitForConfigToInitialize();
30
+ if (configFromScript) {
31
+ return configFromScript;
32
+ }
33
+
34
+ return null;
35
+ };
36
+
37
+ export default getEditorConfig;
@@ -0,0 +1,5 @@
1
+ const pluginPkg = require('../../../package.json');
2
+
3
+ const pluginId = pluginPkg.strapi.name || pluginPkg.name.replace(/^(@_sh\/strapi-)plugin-/i, '');
4
+
5
+ module.exports = pluginId;
package/package.json CHANGED
@@ -1,50 +1,86 @@
1
- {
2
- "name": "@_sh/strapi-plugin-ckeditor",
3
- "version": "1.1.2",
4
- "description": "Replaces the default Strapi WYSIWYG editor with a customized buil of CKEditor 5 packed with useful plugins.",
5
- "private": false,
6
- "keywords": [
7
- "strapi",
8
- "ckeditor",
9
- "ckeditor5",
10
- "ckeditor 5",
11
- "wysiwyg",
12
- "rich text",
13
- "editor"
14
- ],
15
- "strapi": {
16
- "icon": "edit",
17
- "name": "ckeditor",
18
- "displayName": "CKEditor 5",
19
- "description": "Replaces the default Strapi WYSIWYG editor with a customized buil of CKEditor 5 packed with useful plugins.",
20
- "kind": "plugin"
21
- },
22
- "files": [
23
- "admin",
24
- "server",
25
- "strapi-admin.js",
26
- "strapi-server.js"
27
- ],
28
- "dependencies": {
29
- "@ckeditor/ckeditor5-react": "5.0.2"
30
- },
31
- "peerDependencies": {
32
- "@strapi/strapi": "^4.0.0"
33
- },
34
- "author": {
35
- "name": "nshenderov"
36
- },
37
- "homepage": "https://market.strapi.io/plugins/@_sh-strapi-plugin-ckeditor",
38
- "repository": {
39
- "type": "git",
40
- "url": "https://github.com/nshenderov/strapi-plugin-ckeditor.git"
41
- },
42
- "scripts": {
43
- "test": "echo \"Error: no tests specified\" && exit 1"
44
- },
45
- "engines": {
46
- "node": ">=14.x.x <=16.x.x",
47
- "npm": ">=6.0.0"
48
- },
49
- "license": "MIT"
50
- }
1
+ {
2
+ "name": "@_sh/strapi-plugin-ckeditor",
3
+ "version": "2.0.0",
4
+ "description": "Integrates CKEditor 5 into your Strapi project as a fully customizable custom field. (Unofficial integration)",
5
+ "private": false,
6
+ "keywords": [
7
+ "strapi",
8
+ "ckeditor",
9
+ "ckeditor5",
10
+ "ckeditor 5",
11
+ "wysiwyg",
12
+ "rich text",
13
+ "editor"
14
+ ],
15
+ "strapi": {
16
+ "name": "ckeditor5",
17
+ "displayName": "CKEditor 5",
18
+ "description": "Integrates CKEditor 5 into your Strapi project as a fully customizable custom field. (Unofficial integration)",
19
+ "kind": "plugin"
20
+ },
21
+ "files": [
22
+ "admin",
23
+ "server",
24
+ "strapi-admin.js",
25
+ "strapi-server.js"
26
+ ],
27
+ "dependencies": {
28
+ "ckeditor5": "^36.0.0",
29
+ "@ckeditor/ckeditor5-react": "^5.0.6",
30
+ "@ckeditor/ckeditor5-alignment": "^36.0.0",
31
+ "@ckeditor/ckeditor5-autoformat": "^36.0.0",
32
+ "@ckeditor/ckeditor5-autosave": "^36.0.0",
33
+ "@ckeditor/ckeditor5-basic-styles": "^36.0.0",
34
+ "@ckeditor/ckeditor5-block-quote": "^36.0.0",
35
+ "@ckeditor/ckeditor5-style": "^36.0.0",
36
+ "@ckeditor/ckeditor5-code-block": "^36.0.0",
37
+ "@ckeditor/ckeditor5-easy-image": "^36.0.0",
38
+ "@ckeditor/ckeditor5-editor-classic": "^36.0.0",
39
+ "@ckeditor/ckeditor5-essentials": "^36.0.0",
40
+ "@ckeditor/ckeditor5-find-and-replace": "^36.0.0",
41
+ "@ckeditor/ckeditor5-heading": "^36.0.0",
42
+ "@ckeditor/ckeditor5-highlight": "^36.0.0",
43
+ "@ckeditor/ckeditor5-horizontal-line": "^36.0.0",
44
+ "@ckeditor/ckeditor5-html-embed": "^36.0.0",
45
+ "@ckeditor/ckeditor5-html-support": "^36.0.0",
46
+ "@ckeditor/ckeditor5-image": "^36.0.0",
47
+ "@ckeditor/ckeditor5-indent": "^36.0.0",
48
+ "@ckeditor/ckeditor5-language": "^36.0.0",
49
+ "@ckeditor/ckeditor5-link": "^36.0.0",
50
+ "@ckeditor/ckeditor5-list": "^36.0.0",
51
+ "@ckeditor/ckeditor5-mention": "^36.0.0",
52
+ "@ckeditor/ckeditor5-media-embed": "^36.0.0",
53
+ "@ckeditor/ckeditor5-page-break": "^36.0.0",
54
+ "@ckeditor/ckeditor5-paragraph": "^36.0.0",
55
+ "@ckeditor/ckeditor5-paste-from-office": "^36.0.0",
56
+ "@ckeditor/ckeditor5-remove-format": "^36.0.0",
57
+ "@ckeditor/ckeditor5-special-characters": "^36.0.0",
58
+ "@ckeditor/ckeditor5-source-editing": "^36.0.0",
59
+ "@ckeditor/ckeditor5-table": "^36.0.0",
60
+ "@ckeditor/ckeditor5-theme-lark": "^36.0.0",
61
+ "@ckeditor/ckeditor5-typing": "^36.0.0",
62
+ "@ckeditor/ckeditor5-upload": "^36.0.0",
63
+ "@ckeditor/ckeditor5-word-count": "^36.0.0",
64
+ "sanitize-html": "^2.8.1",
65
+ "@_sh/ckeditor5-font-with-picker": "^0.0.1"
66
+ },
67
+ "peerDependencies": {
68
+ "@strapi/strapi": "^4.4.0"
69
+ },
70
+ "author": {
71
+ "name": "nshenderov"
72
+ },
73
+ "homepage": "https://market.strapi.io/plugins/@_sh-strapi-plugin-ckeditor",
74
+ "repository": {
75
+ "type": "git",
76
+ "url": "https://github.com/nshenderov/strapi-plugin-ckeditor.git"
77
+ },
78
+ "scripts": {
79
+ "test": "echo \"Error: no tests specified\" && exit 1"
80
+ },
81
+ "engines": {
82
+ "node": ">=14.19.1 <=18.x.x",
83
+ "npm": ">=6.0.0"
84
+ },
85
+ "license": "MIT"
86
+ }
@@ -1,15 +1,17 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- getConfig: async (ctx) => {
5
- const { configKey } = ctx.params;
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
-
14
- },
1
+ 'use strict';
2
+
3
+ const pluginId = require("../../admin/src/utils/pluginId");
4
+
5
+ module.exports = {
6
+
7
+ getUploadConfig: async (ctx) => {
8
+ const uploadConfig = await strapi.plugin(pluginId).service('config').getUploadConfig('upload').getSettings();
9
+ ctx.send(uploadConfig);
10
+ },
11
+
12
+ getCKEditorConfig: async (ctx) => {
13
+ const config = await strapi.plugin(pluginId).service('config').getCKEditorConfig();
14
+ ctx.type = 'text/javascript';
15
+ ctx.send(config);
16
+ }
15
17
  };
@@ -1,7 +1,7 @@
1
- 'use strict';
2
-
3
- const config = require('./config');
4
-
5
- module.exports = {
6
- config
7
- };
1
+ 'use strict';
2
+
3
+ const config = require('./config');
4
+
5
+ module.exports = {
6
+ config
7
+ };
package/server/index.js CHANGED
@@ -1,25 +1,13 @@
1
- 'use strict';
2
-
3
- const register = require('./register');
4
- const bootstrap = require('./bootstrap');
5
- const destroy = require('./destroy');
6
- const config = require('./config');
7
- const contentTypes = require('./content-types');
8
- const controllers = require('./controllers');
9
- const routes = require('./routes');
10
- const middlewares = require('./middlewares');
11
- const policies = require('./policies');
12
- const services = require('./services');
13
-
14
- module.exports = {
15
- register,
16
- bootstrap,
17
- destroy,
18
- config,
19
- controllers,
20
- routes,
21
- services,
22
- contentTypes,
23
- policies,
24
- middlewares,
25
- };
1
+ 'use strict';
2
+
3
+ const register = require('./register');
4
+ const controllers = require('./controllers');
5
+ const routes = require('./routes');
6
+ const services = require('./services');
7
+
8
+ module.exports = {
9
+ register,
10
+ controllers,
11
+ routes,
12
+ services
13
+ };