@_sh/strapi-plugin-ckeditor 4.0.10 → 5.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 (78) hide show
  1. package/README.md +586 -575
  2. package/dist/_chunks/Field-8Nh0dMSc.mjs +574 -0
  3. package/dist/_chunks/Field-BKtrDFjh.js +598 -0
  4. package/dist/_chunks/index-CNalXcwy.mjs +1330 -0
  5. package/dist/_chunks/index-DO2vqIdx.js +1350 -0
  6. package/dist/admin/index.js +11 -4
  7. package/dist/admin/index.mjs +10 -4
  8. package/dist/admin/src/components/CKEReact.d.ts +6 -0
  9. package/dist/admin/src/components/CKEditorIcon.d.ts +1 -0
  10. package/dist/admin/src/components/Editor.d.ts +1 -0
  11. package/dist/admin/src/components/EditorLayout.d.ts +4 -0
  12. package/dist/admin/src/components/EditorProvider.d.ts +20 -0
  13. package/dist/admin/src/components/Field.d.ts +20 -0
  14. package/dist/admin/src/components/GlobalStyling.d.ts +4 -0
  15. package/dist/admin/src/components/MediaLib.d.ts +9 -0
  16. package/dist/admin/src/config/htmlPreset.d.ts +2 -0
  17. package/dist/admin/src/config/index.d.ts +5 -0
  18. package/dist/admin/src/config/language.d.ts +15 -0
  19. package/dist/admin/src/config/markdownPreset.d.ts +2 -0
  20. package/dist/admin/src/config/pluginConfig.d.ts +23 -0
  21. package/dist/admin/src/config/types.d.ts +123 -0
  22. package/dist/admin/src/exports.d.ts +9 -0
  23. package/dist/admin/src/index.d.ts +6 -0
  24. package/dist/admin/src/plugins/StrapiMediaLib.d.ts +15 -0
  25. package/dist/admin/src/plugins/StrapiUploadAdapter.d.ts +12 -0
  26. package/dist/admin/src/plugins/index.d.ts +2 -0
  27. package/dist/admin/src/theme/additional.d.ts +1 -0
  28. package/dist/admin/src/theme/colors.d.ts +1 -0
  29. package/dist/admin/src/theme/common.d.ts +1 -0
  30. package/dist/admin/src/theme/dark.d.ts +1 -0
  31. package/dist/admin/src/theme/index.d.ts +2 -0
  32. package/dist/admin/src/theme/light.d.ts +1 -0
  33. package/dist/admin/src/utils/index.d.ts +4 -0
  34. package/dist/admin/src/utils/isImageResponsive.d.ts +3 -0
  35. package/dist/admin/src/utils/localStorage.d.ts +3 -0
  36. package/dist/admin/src/utils/pluginId.d.ts +1 -0
  37. package/dist/admin/src/utils/prefixWithBackendUrl.d.ts +1 -0
  38. package/dist/server/index.js +61 -119
  39. package/dist/server/index.mjs +61 -117
  40. package/dist/server/src/index.d.ts +7 -0
  41. package/package.json +50 -22
  42. package/dist/_chunks/index-0XricxMA.js +0 -3548
  43. package/dist/_chunks/index-0XricxMA.js.map +0 -1
  44. package/dist/_chunks/index-28M_cjfZ.js +0 -1150
  45. package/dist/_chunks/index-28M_cjfZ.js.map +0 -1
  46. package/dist/_chunks/index-B3VZXRRM.mjs +0 -1124
  47. package/dist/_chunks/index-B3VZXRRM.mjs.map +0 -1
  48. package/dist/_chunks/index-BEYONTI5.js +0 -1150
  49. package/dist/_chunks/index-BEYONTI5.js.map +0 -1
  50. package/dist/_chunks/index-B_BYkSZj.js +0 -1150
  51. package/dist/_chunks/index-B_BYkSZj.js.map +0 -1
  52. package/dist/_chunks/index-BeoZd6fh.mjs +0 -3530
  53. package/dist/_chunks/index-BeoZd6fh.mjs.map +0 -1
  54. package/dist/_chunks/index-BiwTLCLk.mjs +0 -1124
  55. package/dist/_chunks/index-BiwTLCLk.mjs.map +0 -1
  56. package/dist/_chunks/index-BliHiZJM.js +0 -3548
  57. package/dist/_chunks/index-BliHiZJM.js.map +0 -1
  58. package/dist/_chunks/index-BnZp4Mbc.mjs +0 -3530
  59. package/dist/_chunks/index-BnZp4Mbc.mjs.map +0 -1
  60. package/dist/_chunks/index-BsSnWl8P.js +0 -990
  61. package/dist/_chunks/index-BsSnWl8P.js.map +0 -1
  62. package/dist/_chunks/index-CpmwvDcE.mjs +0 -3530
  63. package/dist/_chunks/index-CpmwvDcE.mjs.map +0 -1
  64. package/dist/_chunks/index-DOdOcVer.mjs +0 -986
  65. package/dist/_chunks/index-DOdOcVer.mjs.map +0 -1
  66. package/dist/_chunks/index-DXRXMzTP.js +0 -3548
  67. package/dist/_chunks/index-DXRXMzTP.js.map +0 -1
  68. package/dist/_chunks/index-TbPGn87z.js +0 -3548
  69. package/dist/_chunks/index-TbPGn87z.js.map +0 -1
  70. package/dist/_chunks/index-Z38y6cY4.mjs +0 -1124
  71. package/dist/_chunks/index-Z38y6cY4.mjs.map +0 -1
  72. package/dist/_chunks/index-eczlqHt8.mjs +0 -3530
  73. package/dist/_chunks/index-eczlqHt8.mjs.map +0 -1
  74. package/dist/admin/index.js.map +0 -1
  75. package/dist/admin/index.mjs.map +0 -1
  76. package/dist/server/index.js.map +0 -1
  77. package/dist/server/index.mjs.map +0 -1
  78. package/strapi-server.js +0 -3
@@ -0,0 +1,1330 @@
1
+ import * as yup from "yup";
2
+ import { css, styled } from "styled-components";
3
+ import { Plugin, ButtonView, FileRepository, logWarning, Alignment, Autoformat, AutoImage, BalloonToolbar, BlockQuote, Bold, Code, CodeBlock, Essentials, FontBackgroundColor, FontColor, FontFamily, FontSize, GeneralHtmlSupport, Heading, HorizontalLine, HtmlEmbed, Image, ImageCaption, ImageInsert, ImageResize, ImageStyle, ImageToolbar, ImageUpload, Indent, IndentBlock, Italic, List, ListProperties, Link, LinkImage, MediaEmbed, Paragraph, PageBreak, PasteFromOffice, PictureEditing, RemoveFormat, SourceEditing, SpecialCharacters, SpecialCharactersEssentials, Strikethrough, Style, Subscript, Superscript, ShowBlocks, Table, TableCaption, TableCellProperties, TableColumnResize, TableProperties, TableToolbar, TodoList, Underline, WordCount, icons, Markdown, TextTransformation } from "ckeditor5";
4
+ import * as sanitizeHtml from "sanitize-html";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { Flex, lightTheme } from "@strapi/design-system";
7
+ import cloneDeep from "lodash/cloneDeep";
8
+ const name = "@_sh/strapi-plugin-ckeditor";
9
+ const version = "5.0.0";
10
+ const description = "Integrates CKEditor 5 into your Strapi project as a fully customizable custom field. (Community Edition)";
11
+ const keywords = [
12
+ "strapi",
13
+ "ckeditor",
14
+ "ckeditor5",
15
+ "ckeditor 5",
16
+ "wysiwyg",
17
+ "rich text",
18
+ "editor"
19
+ ];
20
+ const author = {
21
+ name: "nshenderov"
22
+ };
23
+ const homepage = "https://market.strapi.io/plugins/@_sh-strapi-plugin-ckeditor";
24
+ const repository = {
25
+ type: "git",
26
+ url: "https://github.com/nshenderov/strapi-plugin-ckeditor.git"
27
+ };
28
+ const strapi = {
29
+ name: "ckeditor5",
30
+ displayName: "CKEditor 5",
31
+ description: "Integrates CKEditor 5 into your Strapi project as a fully customizable custom field. (Community Edition)",
32
+ kind: "plugin"
33
+ };
34
+ const type = "commonjs";
35
+ const exports = {
36
+ "./package.json": "./package.json",
37
+ ".": {
38
+ types: "./dist/admin/src/index.d.ts",
39
+ source: "./admin/src/index.ts",
40
+ "import": "./dist/admin/index.mjs",
41
+ require: "./dist/admin/index.js",
42
+ "default": "./dist/admin/index.js"
43
+ },
44
+ "./strapi-admin": {
45
+ types: "./dist/admin/src/index.d.ts",
46
+ source: "./admin/src/index.ts",
47
+ "import": "./dist/admin/index.mjs",
48
+ require: "./dist/admin/index.js",
49
+ "default": "./dist/admin/index.js"
50
+ },
51
+ "./strapi-server": {
52
+ types: "./dist/server/src/index.d.ts",
53
+ source: "./server/src/index.ts",
54
+ "import": "./dist/server/index.mjs",
55
+ require: "./dist/server/index.js",
56
+ "default": "./dist/server/index.js"
57
+ }
58
+ };
59
+ const files = [
60
+ "dist"
61
+ ];
62
+ const scripts = {
63
+ build: "strapi-plugin build",
64
+ watch: "strapi-plugin watch",
65
+ "watch:link": "strapi-plugin watch:link",
66
+ verify: "strapi-plugin verify",
67
+ "test:ts:front": "run -T tsc -p admin/tsconfig.json",
68
+ "test:ts:back": "run -T tsc -p server/tsconfig.json",
69
+ release: "release-it",
70
+ "release:info": "release-it --changelog"
71
+ };
72
+ const dependencies = {
73
+ "@ckeditor/ckeditor5-react": "^9.4.0",
74
+ "@strapi/design-system": "^2.0.0-rc.13",
75
+ "@strapi/icons": "^2.0.0-rc.13",
76
+ lodash: "^4.17.21",
77
+ ckeditor5: "^44.0.0",
78
+ "prop-types": "^15.8.1",
79
+ "sanitize-html": "^2.13.1",
80
+ yup: "0.32.9"
81
+ };
82
+ const devDependencies = {
83
+ "@release-it/conventional-changelog": "^8.0.1",
84
+ "@strapi/sdk-plugin": "^5.2.7",
85
+ "@strapi/strapi": "^5.0.0",
86
+ "@strapi/typescript-utils": "^5.4.0",
87
+ "@types/react": "^18.3.12",
88
+ "@types/react-dom": "^18.3.1",
89
+ "@types/sanitize-html": "^2.13.0",
90
+ "@typescript-eslint/eslint-plugin": "^7.0.0",
91
+ "@typescript-eslint/parser": "^7.0.0",
92
+ eslint: "^8.2.0",
93
+ "eslint-config-airbnb": "^19.0.4",
94
+ "eslint-config-airbnb-typescript": "^18.0.0",
95
+ "eslint-config-prettier": "^9.1.0",
96
+ "eslint-plugin-import": "^2.25.3",
97
+ "eslint-plugin-jsx-a11y": "^6.10.2",
98
+ "eslint-plugin-prettier": "^5.2.1",
99
+ "eslint-plugin-react": "^7.28.0",
100
+ "eslint-plugin-react-hooks": "^4.3.0",
101
+ prettier: "3.4.0",
102
+ react: "^18.3.1",
103
+ "react-dom": "^18.3.1",
104
+ "react-router-dom": "^6.26.2",
105
+ "release-it": "^17.6.0",
106
+ "styled-components": "^6.1.13",
107
+ typescript: "^5.6.3"
108
+ };
109
+ const peerDependencies = {
110
+ "@strapi/strapi": "^5.0.0",
111
+ react: "^18.0.0",
112
+ "react-dom": "^18.0.0",
113
+ "react-router-dom": "^6.0.0",
114
+ "styled-components": "^6.0.0"
115
+ };
116
+ const engines = {
117
+ node: ">=18.0.0 <=22.x.x",
118
+ npm: ">=6.0.0"
119
+ };
120
+ const license = "MIT";
121
+ const pluginPkg = {
122
+ name,
123
+ version,
124
+ description,
125
+ keywords,
126
+ author,
127
+ homepage,
128
+ repository,
129
+ strapi,
130
+ type,
131
+ exports,
132
+ files,
133
+ scripts,
134
+ dependencies,
135
+ devDependencies,
136
+ peerDependencies,
137
+ engines,
138
+ license
139
+ };
140
+ const PLUGIN_ID = pluginPkg.strapi.name;
141
+ function isImageResponsive(imgFormats) {
142
+ const formats = Object.keys(imgFormats);
143
+ const isResponsive = !(formats.length === 1 && formats[0] === "thumbnail");
144
+ return isResponsive;
145
+ }
146
+ function prefixFileUrlWithBackendUrl(fileURL) {
147
+ return !!fileURL && fileURL.startsWith("/") ? `${window.strapi.backendURL}${fileURL}` : fileURL;
148
+ }
149
+ const colors = css`
150
+ ${({ theme }) => css`
151
+ :root {
152
+ /* -- Generic colors ---------------------------------------------------------------------- */
153
+
154
+ --ck-color-focus-outer-shadow: ${theme.colors.primary600}1F !important;
155
+ --ck-color-focus-disabled-shadow: ${theme.colors.primary200} !important;
156
+ --ck-focus-ring: 1px solid ${theme.colors.primary600}9F !important;
157
+ --ck-color-button-default-hover-background: ${theme.colors.primary100} !important;
158
+ }
159
+
160
+ .ck {
161
+ /* -- Generic colors ---------------------------------------------------------------------- */
162
+
163
+ --ck-color-base-focus: ${theme.colors.primary200};
164
+ --ck-color-base-active: ${theme.colors.primary500}8F;
165
+ --ck-color-base-active-focus: ${theme.colors.primary600};
166
+ --ck-color-editor-base-text: ${theme.colors.neutral800};
167
+ --ck-color-base-border: ${theme.colors.neutral200};
168
+ --ck-color-base-background: ${theme.colors.neutral0};
169
+ --ck-custom-foreground: ${theme.colors.neutral200};
170
+ --ck-color-base-foreground: var(--ck-color-base-background);
171
+ --ck-color-focus-border: ${theme.colors.primary500};
172
+ --ck-color-text: ${theme.colors.neutral800};
173
+ --ck-custom-white: hsl(0, 0%, 100%);
174
+
175
+ /* -- Buttons ----------------------------------------------------------------------------- */
176
+
177
+ --ck-color-button-default-background: var(--ck-color-base-background);
178
+ --ck-color-button-default-hover-background: ${theme.colors.primary100};
179
+ --ck-color-button-default-active-background: ${theme.colors.primary100};
180
+ --ck-color-button-default-active-shadow: ${theme.colors.primary100};
181
+ --ck-color-button-default-disabled-background: var(--ck-color-base-background);
182
+
183
+ --ck-color-button-on-color: ${theme.colors.primary600};
184
+ --ck-color-button-on-background: ${theme.colors.primary100};
185
+ --ck-color-button-on-hover-background: ${theme.colors.primary200};
186
+ --ck-color-button-on-active-background: ${theme.colors.primary100};
187
+ --ck-color-button-on-disabled-background: var(--ck-custom-foreground);
188
+ --ck-color-button-on-active-shadow: ${theme.colors.primary200};
189
+
190
+ --ck-color-button-action-background: ${theme.colors.success500}E5;
191
+ --ck-color-button-action-hover-background: ${theme.colors.success500}F5;
192
+ --ck-color-button-action-active-background: ${theme.colors.success500};
193
+ --ck-color-button-action-disabled-background: ${theme.colors.success500}99;
194
+ --ck-color-button-action-text: var(--ck-custom-white);
195
+
196
+ --ck-color-switch-button-off-background: ${theme.colors.neutral400};
197
+ --ck-color-switch-button-off-hover-background: ${theme.colors.neutral500};
198
+ --ck-color-switch-button-on-background: var(--ck-color-button-action-background);
199
+ --ck-color-switch-button-on-hover-background: var(--ck-color-button-action-hover-background);
200
+
201
+ --ck-color-button-save: ${theme.colors.success500};
202
+ --ck-color-button-cancel: ${theme.colors.danger500};
203
+
204
+ --ck-color-split-button-hover-background: var(--ck-color-button-default-hover-background);
205
+ --ck-color-split-button-hover-border: var(--ck-custom-foreground);
206
+
207
+ /* -- Dropdown ---------------------------------------------------------------------------- */
208
+
209
+ --ck-color-dropdown-panel-background: var(--ck-color-base-background);
210
+ --ck-color-dropdown-panel-border: var(--ck-custom-foreground);
211
+
212
+ /* -- Input ------------------------------------------------------------------------------- */
213
+
214
+ --ck-color-input-background: var(--ck-color-base-background);
215
+ --ck-color-input-border: var(--ck-color-base-border);
216
+ --ck-color-input-text: var(--ck-color-editor-base-text);
217
+
218
+ --ck-color-input-disabled-background: ${theme.colors.neutral100};
219
+ --ck-color-input-disabled-border: ${theme.colors.neutral150};
220
+ --ck-color-input-disabled-text: ${theme.colors.neutral400};
221
+
222
+ --ck-color-labeled-field-label-background: var(--ck-color-base-background);
223
+
224
+ /* -- List -------------------------------------------------------------------------------- */
225
+
226
+ --ck-color-list-background: var(--ck-color-base-background);
227
+ --ck-color-list-button-hover-background: ${theme.colors.primary100};
228
+ --ck-color-list-button-on-background: var(--ck-color-base-active);
229
+ --ck-color-list-button-on-background-focus: var(--ck-color-base-active-focus);
230
+
231
+ /* -- Panel ------------------------------------------------------------------------------- */
232
+
233
+ --ck-color-panel-background: var(--ck-color-base-background);
234
+ --ck-color-panel-border: var(--ck-color-base-border);
235
+
236
+ --ck-style-panel-button-label-background: ${theme.colors.neutral100};
237
+ --ck-style-panel-button-hover-label-background: ${theme.colors.neutral150};
238
+ --ck-style-panel-button-hover-border-color: var(--ck-color-base-border);
239
+
240
+ /* -- Toolbar ----------------------------------------------------------------------------- */
241
+
242
+ --ck-color-toolbar-background: var(--ck-color-base-background);
243
+ --ck-color-toolbar-border: var(--ck-color-base-border);
244
+
245
+ /* -- Tooltip ----------------------------------------------------------------------------- */
246
+
247
+ --ck-color-tooltip-background: ${theme.colors.neutral800};
248
+ --ck-color-tooltip-text: ${theme.colors.neutral100};
249
+
250
+ /* -- Image ------------------------------------------------------------------------------- */
251
+
252
+ --ck-color-image-caption-background: ${theme.colors.neutral100};
253
+ --ck-color-image-caption-text: ${theme.colors.neutral800};
254
+
255
+ /* -- Widget ------------------------------------------------------------------------------ */
256
+
257
+ --ck-color-widget-blurred-border: ${theme.colors.neutral400};
258
+ --ck-color-widget-hover-border: ${theme.colors.neutral300};
259
+ --ck-color-widget-editable-focus-background: ${theme.colors.neutral150};
260
+ --ck-color-widget-type-around-button-active: var(--ck-color-focus-border);
261
+ --ck-color-widget-type-around-button-hover: ${theme.colors.neutral300};
262
+
263
+ /* -- Link -------------------------------------------------------------------------------- */
264
+
265
+ --ck-color-link-fake-selection: ${theme.colors.primary200};
266
+ --ck-color-link-selected-background: ${theme.colors.primary200};
267
+
268
+ /* -- Dialog ------------------------------------------------------------------------------ */
269
+
270
+ --ck-color-dialog-background: var(--ck-color-base-background);
271
+ --ck-color-dialog-form-header-border: var(--ck-color-base-border);
272
+
273
+ /* -- PoweredBy --------------------------------------------------------------------------- */
274
+
275
+ --ck-powered-by-background: transparrent;
276
+ }
277
+ `}
278
+ `;
279
+ const light = css`
280
+ ${colors}
281
+ `;
282
+ const dark = css`
283
+ ${colors}
284
+
285
+ .ck.ck-powered-by > a > svg > path:nth-child(3) {
286
+ fill: rgb(172, 156, 251);
287
+ }
288
+ `;
289
+ const reset = css`
290
+ ${({ theme }) => css`
291
+ .ck {
292
+ --ck-color-image-caption-background: hsl(0, 0%, 97%);
293
+ --ck-color-image-caption-text: hsl(0, 0%, 20%);
294
+ --ck-color-mention-background: hsla(341, 100%, 30%, 0.1);
295
+ --ck-color-mention-text: hsl(341, 100%, 30%);
296
+ --ck-color-table-caption-background: hsl(0, 0%, 97%);
297
+ --ck-color-table-caption-text: hsl(0, 0%, 20%);
298
+ --ck-highlight-marker-blue: hsl(201, 97%, 72%);
299
+ --ck-highlight-marker-green: hsl(120, 93%, 68%);
300
+ --ck-highlight-marker-pink: hsl(345, 96%, 73%);
301
+ --ck-highlight-marker-yellow: hsl(60, 97%, 73%);
302
+ --ck-highlight-pen-green: hsl(112, 100%, 27%);
303
+ --ck-highlight-pen-red: hsl(0, 85%, 49%);
304
+ --ck-image-style-spacing: 1.5em;
305
+ --ck-inline-image-style-spacing: calc(var(--ck-image-style-spacing) / 2);
306
+ --ck-todo-list-checkmark-size: 16px;
307
+ --ck-border-radius: ${theme.borderRadius};
308
+
309
+ font-size: ${theme.fontSizes[2]};
310
+ }
311
+
312
+ .ck.ck-reset.ck-dropdown__panel.ck-dropdown__panel_sw.ck-dropdown__panel-visible {
313
+ border-radius: var(--ck-border-radius);
314
+ }
315
+
316
+ .ck-editor__main {
317
+ --ck-font-face: 'Source Sans Pro', system-ui, Roboto, 'Helvetica Neue', 'Helvetica', Arial,
318
+ sans-serif;
319
+
320
+ color: var(--ck-color-editor-base-text);
321
+ font-family: var(--ck-font-face);
322
+
323
+ * {
324
+ font: revert;
325
+ margin: revert;
326
+ }
327
+
328
+ h1 {
329
+ font-size: 2.3em;
330
+ }
331
+
332
+ h2 {
333
+ font-size: 1.84em;
334
+ }
335
+
336
+ h3 {
337
+ font-size: 1.48em;
338
+ }
339
+
340
+ h4 {
341
+ font-size: 1.22em;
342
+ }
343
+
344
+ h5 {
345
+ font-size: 1.06em;
346
+ }
347
+
348
+ h6 {
349
+ font-size: 1em;
350
+ }
351
+
352
+ h1,
353
+ h2,
354
+ h3,
355
+ h4,
356
+ h5,
357
+ h6 {
358
+ line-height: 1.2em;
359
+ padding-top: 0.8em;
360
+ margin-bottom: 0.4em;
361
+ }
362
+
363
+ blockquote,
364
+ ol,
365
+ p,
366
+ ul {
367
+ font-size: 1em;
368
+ line-height: 1.6em;
369
+ padding-top: 0.2em;
370
+ margin-bottom: var(--ck-spacing-large);
371
+ }
372
+
373
+ figcaption {
374
+ background-color: var(--ck-color-image-caption-background);
375
+ caption-side: bottom;
376
+ color: var(--ck-color-image-caption-text);
377
+ display: table-caption;
378
+ font-size: 0.75em;
379
+ outline-offset: -1px;
380
+ padding: 0.6em;
381
+ word-break: break-word;
382
+ }
383
+
384
+ a {
385
+ text-decoration: none;
386
+ color: #1b3af2;
387
+ }
388
+
389
+ a:hover {
390
+ text-decoration: underline;
391
+ }
392
+
393
+ .table {
394
+ margin: 0;
395
+ }
396
+
397
+ ul.todo-list {
398
+ list-style: none;
399
+ margin: revert;
400
+ color: revert;
401
+ font-family: revert;
402
+ margin-left: 2rem;
403
+ }
404
+
405
+ ul,
406
+ ol {
407
+ list-style: initial;
408
+ margin-left: 2rem;
409
+ }
410
+
411
+ ol {
412
+ list-style: decimal;
413
+ }
414
+
415
+ sub {
416
+ vertical-align: sub;
417
+ }
418
+
419
+ sup {
420
+ vertical-align: super;
421
+ }
422
+ }
423
+ `}
424
+ `;
425
+ const plugin = css`
426
+ ${({ theme }) => css`
427
+ .ck {
428
+ scrollbar-width: thin;
429
+ scrollbar-color: ${`${theme.colors.neutral300} ${theme.colors.neutral150}`};
430
+
431
+ @-moz-document url-prefix() {
432
+ scrollbar-width: auto;
433
+ }
434
+ }
435
+
436
+ .ck.ck-content.ck-editor__editable {
437
+ line-height: initial;
438
+ height: auto;
439
+ min-height: var(--ck-editor-min-height);
440
+ border: none !important;
441
+ max-width: var(--ck-editor-max-width) !important;
442
+ margin: 0 auto;
443
+ &.ck-focused:not(.ck-editor__nested-editable) {
444
+ box-shadow: none;
445
+ }
446
+ }
447
+
448
+ .ck.ck-editor__top .ck-sticky-panel .ck-sticky-panel__content {
449
+ border: none !important;
450
+ }
451
+
452
+ .ck.ck-editor__main {
453
+ min-height: var(--ck-editor-min-height) !important;
454
+ max-height: var(--ck-editor-max-height) !important;
455
+ overflow-y: auto;
456
+ overflow-x: hidden;
457
+ border-top: 1px solid var(--ck-color-base-border);
458
+ border-bottom-left-radius: var(--ck-border-radius);
459
+ border-bottom-right-radius: var(--ck-border-radius);
460
+ }
461
+
462
+ .ck .ck-source-editing-area,
463
+ .ck .ck-source-editing-area textarea {
464
+ color: var(--ck-color-text);
465
+ background-color: var(--ck-color-base-background);
466
+ border: none !important;
467
+ box-shadow: none !important;
468
+ min-height: var(--ck-editor-min-height);
469
+ max-width: var(--ck-editor-max-width);
470
+ margin: 0 auto;
471
+ }
472
+
473
+ .ck .ck-block-toolbar-button {
474
+ min-width: 0 !important;
475
+ min-height: 0 !important;
476
+ width: 20px !important;
477
+ height: 25px !important;
478
+ margin-left: -2px !important ;
479
+
480
+ & svg {
481
+ color: var(--ck-color-text) !important;
482
+ position: absolute;
483
+ width: 20px;
484
+ height: 20px;
485
+ }
486
+ }
487
+
488
+ .ck-word-count {
489
+ display: flex;
490
+ position: absolute;
491
+ justify-content: end;
492
+ gap: 0.3rem;
493
+ font-size: 1rem;
494
+ font-weight: 500;
495
+ text-transform: lowercase;
496
+ z-index: 2;
497
+ bottom: -2rem;
498
+ right: 0;
499
+ }
500
+
501
+ .ck[dir='rtl'] {
502
+ .ck-block-toolbar-button {
503
+ margin-left: 2px !important ;
504
+ }
505
+ & + div {
506
+ justify-content: flex-start;
507
+ & > .ck-word-count {
508
+ & > div:first-child {
509
+ order: 2;
510
+ }
511
+ & > div:last-child {
512
+ order: 1;
513
+ }
514
+ }
515
+ }
516
+ }
517
+
518
+ .ck.ck-editor__editable > .ck-placeholder::before {
519
+ color: var(--ck-color-editor-base-text);
520
+ opacity: 0.65;
521
+ }
522
+
523
+ .ck.ck-powered-by > a > svg > path:first-child {
524
+ fill: ${theme.colors.neutral800};
525
+ }
526
+ `}
527
+ `;
528
+ const expanded = css`
529
+ .ck-editor__expanded {
530
+ .ck.ck-content.ck-editor__editable,
531
+ .ck-source-editing-area {
532
+ min-height: 100% !important;
533
+ height: auto !important;
534
+ max-height: none !important;
535
+ border-radius: var(--ck-border-radius) !important;
536
+ border: 1px solid var(--ck-color-base-border) !important;
537
+ overflow: auto !important;
538
+ box-sizing: border-box;
539
+ }
540
+
541
+ .ck.ck-editor__top {
542
+ box-shadow: 0 0 5px hsla(0, 0%, 0%, 0.2);
543
+ z-index: var(--ck-z-panel);
544
+ }
545
+
546
+ .ck.ck-editor {
547
+ display: flex;
548
+ flex-direction: column;
549
+ }
550
+
551
+ .ck.ck-editor,
552
+ .ck.ck-content,
553
+ .ck.ck-editor__main {
554
+ height: calc(100% - 0px) !important;
555
+ }
556
+
557
+ .ck.ck-editor__main {
558
+ min-height: none !important;
559
+ max-height: none !important;
560
+ overflow-y: scroll !important;
561
+ padding: calc(2 * var(--ck-spacing-large));
562
+ }
563
+
564
+ .ck-word-count {
565
+ bottom: 0.3rem;
566
+ right: 1.2rem;
567
+ }
568
+ }
569
+ `;
570
+ const common = css`
571
+ ${reset}
572
+ ${plugin}
573
+ ${expanded}
574
+ `;
575
+ const editorSizes = css`
576
+ :root {
577
+ --ck-editor-full-screen-box-max-width: 1700px;
578
+ }
579
+
580
+ .ck {
581
+ --ck-editor-max-width: 1366px;
582
+ --ck-editor-min-height: 200px;
583
+ --ck-editor-max-height: 500px;
584
+ }
585
+ `;
586
+ const additional = css`
587
+ ${editorSizes}
588
+ `;
589
+ const defaultTheme = {
590
+ light,
591
+ dark,
592
+ common,
593
+ additional
594
+ };
595
+ const mediaLibIcon = '<svg width="1em" height="1em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M4.3.6a.9.9 0 100 1.8h15.311a.9.9 0 100-1.8H4.301zm17.1 3.7A1.6 1.6 0 0123 5.9v15.5a1.6 1.6 0 01-1.6 1.6H2.6A1.601 1.601 0 011 21.4V8 5.915C1 5.03 1.716 4.3 2.6 4.3h18.8zM5.032 19.18h14.336l-3.136-3.205-1.792 1.831-4.032-4.12-5.376 5.494zm13.44-8.697c0 1.282-.985 2.289-2.24 2.289-1.254 0-2.24-1.007-2.24-2.29 0-1.281.986-2.288 2.24-2.288 1.255 0 2.24 1.007 2.24 2.289z"></path></svg>';
596
+ class StrapiMediaLib extends Plugin {
597
+ /**
598
+ * Strapi function used to show media library modal.
599
+ * Should be provided via connect method before using toggle method.
600
+ */
601
+ strapiToggle = null;
602
+ static get pluginName() {
603
+ return "StrapiMediaLib";
604
+ }
605
+ init() {
606
+ this.editor.ui.componentFactory.add("strapiMediaLib", () => {
607
+ const button = new ButtonView();
608
+ button.set({
609
+ label: "Media Library",
610
+ icon: mediaLibIcon,
611
+ tooltip: true
612
+ });
613
+ button.on("execute", this.toggle.bind(this));
614
+ return button;
615
+ });
616
+ }
617
+ connect(strapiToggle) {
618
+ if (typeof strapiToggle !== "function") {
619
+ throw new Error("Input parameter for toogle should be a function");
620
+ }
621
+ this.strapiToggle = strapiToggle;
622
+ }
623
+ toggle() {
624
+ if (typeof this.strapiToggle !== "function") {
625
+ throw new Error(
626
+ "Strapi media library toggle function not connected. Use connect function first"
627
+ );
628
+ }
629
+ this.strapiToggle();
630
+ }
631
+ }
632
+ class StrapiUploadAdapter extends Plugin {
633
+ static get requires() {
634
+ return [FileRepository];
635
+ }
636
+ static get pluginName() {
637
+ return "StrapiUploadAdapter";
638
+ }
639
+ init() {
640
+ }
641
+ initAdapter(config) {
642
+ if (!config.uploadUrl) {
643
+ logWarning("strapi-upload-adapter-missing-uploadurl");
644
+ return;
645
+ }
646
+ this.editor.plugins.get(FileRepository).createUploadAdapter = (loader) => new Adapter(loader, config);
647
+ }
648
+ }
649
+ class Adapter {
650
+ /**
651
+ * FileLoader instance to use during the upload.
652
+ */
653
+ loader;
654
+ /**
655
+ * The configuration of the adapter.
656
+ */
657
+ config;
658
+ xhr;
659
+ /**
660
+ * Creates a new adapter instance.
661
+ */
662
+ constructor(loader, config) {
663
+ this.loader = loader;
664
+ this.config = config;
665
+ }
666
+ /**
667
+ * Starts the upload process.
668
+ */
669
+ upload() {
670
+ return this.loader.file.then(
671
+ (file) => new Promise((resolve, reject) => {
672
+ this.initRequest();
673
+ this.initListeners(resolve, reject, file);
674
+ this.sendRequest(file);
675
+ })
676
+ );
677
+ }
678
+ /**
679
+ * Aborts the upload process.
680
+ */
681
+ abort() {
682
+ if (this.xhr) {
683
+ this.xhr.abort();
684
+ }
685
+ }
686
+ /**
687
+ * Initializes the `XMLHttpRequest` object using the URL specified as
688
+ * `strapiUpload.uploadUrl` in the editor's
689
+ * configuration.
690
+ */
691
+ initRequest() {
692
+ const xhr = new XMLHttpRequest();
693
+ this.xhr = xhr;
694
+ xhr.open("POST", this.config.uploadUrl, true);
695
+ xhr.responseType = "json";
696
+ }
697
+ /**
698
+ * Initializes XMLHttpRequest listeners
699
+ *
700
+ * resolve - Callback function to be called when the request is successful.
701
+ * reject - Callback function to be called when the request cannot be completed.
702
+ * file - Native File object.
703
+ */
704
+ initListeners(resolve, reject, file) {
705
+ const xhr = this.xhr;
706
+ const { loader } = this;
707
+ const genericErrorText = `Couldn't upload file: ${file.name}.`;
708
+ xhr.addEventListener("error", () => reject(genericErrorText));
709
+ xhr.addEventListener("abort", () => reject());
710
+ xhr.addEventListener("load", () => {
711
+ const { response } = xhr;
712
+ if (!Array.isArray(response) || typeof response === "object" && "error" in response || response.length !== 1) {
713
+ return reject(
714
+ response && response.error && response.error.message ? response.error.message : genericErrorText
715
+ );
716
+ }
717
+ const { name: name2, url, alternativeText, formats } = response[0];
718
+ const urls = { default: prefixFileUrlWithBackendUrl(url) };
719
+ const alt = alternativeText || name2;
720
+ if (formats && isImageResponsive(formats)) {
721
+ const sortedFormatsKeys = Object.keys(formats).sort(
722
+ (a, b) => formats[a].width - formats[b].width
723
+ );
724
+ sortedFormatsKeys.forEach((k) => {
725
+ urls[formats[k].width] = prefixFileUrlWithBackendUrl(formats[k].url);
726
+ });
727
+ }
728
+ resolve(url ? { alt, urls } : {});
729
+ return void 0;
730
+ });
731
+ if (xhr.upload) {
732
+ xhr.upload.addEventListener("progress", (evt) => {
733
+ if (evt.lengthComputable) {
734
+ loader.uploadTotal = evt.total;
735
+ loader.uploaded = evt.loaded;
736
+ }
737
+ });
738
+ }
739
+ }
740
+ /**
741
+ * Prepares the data and sends the request.
742
+ *
743
+ * File - instance to be uploaded.
744
+ */
745
+ sendRequest(file) {
746
+ const headers = this.config.headers || {};
747
+ const withCredentials = this.config.withCredentials || false;
748
+ Object.keys(headers).forEach((headerName) => {
749
+ this.xhr.setRequestHeader(headerName, headers[headerName]);
750
+ });
751
+ this.xhr.withCredentials = withCredentials;
752
+ const data = new FormData();
753
+ data.append("files", file);
754
+ this.xhr.send(data);
755
+ }
756
+ }
757
+ const editorConfig$1 = {
758
+ licenseKey: "GPL",
759
+ plugins: [
760
+ Alignment,
761
+ Autoformat,
762
+ AutoImage,
763
+ BalloonToolbar,
764
+ BlockQuote,
765
+ Bold,
766
+ Code,
767
+ CodeBlock,
768
+ Essentials,
769
+ FontBackgroundColor,
770
+ FontColor,
771
+ FontFamily,
772
+ FontSize,
773
+ GeneralHtmlSupport,
774
+ Heading,
775
+ HorizontalLine,
776
+ HtmlEmbed,
777
+ Image,
778
+ ImageCaption,
779
+ ImageInsert,
780
+ ImageResize,
781
+ ImageStyle,
782
+ ImageToolbar,
783
+ ImageUpload,
784
+ Indent,
785
+ IndentBlock,
786
+ Italic,
787
+ List,
788
+ ListProperties,
789
+ Link,
790
+ LinkImage,
791
+ MediaEmbed,
792
+ Paragraph,
793
+ PageBreak,
794
+ PasteFromOffice,
795
+ PictureEditing,
796
+ RemoveFormat,
797
+ SourceEditing,
798
+ SpecialCharacters,
799
+ SpecialCharactersEssentials,
800
+ Strikethrough,
801
+ Style,
802
+ Subscript,
803
+ Superscript,
804
+ ShowBlocks,
805
+ Table,
806
+ TableCaption,
807
+ TableCellProperties,
808
+ TableColumnResize,
809
+ TableProperties,
810
+ TableToolbar,
811
+ TodoList,
812
+ Underline,
813
+ WordCount,
814
+ StrapiMediaLib,
815
+ StrapiUploadAdapter
816
+ ],
817
+ toolbar: [
818
+ "showBlocks",
819
+ "|",
820
+ "heading",
821
+ "|",
822
+ "fontSize",
823
+ "fontFamily",
824
+ "alignment",
825
+ {
826
+ label: "Indentation",
827
+ icon: icons.indent,
828
+ items: ["outdent", "indent"]
829
+ },
830
+ "bulletedList",
831
+ "numberedList",
832
+ "todoList",
833
+ "link",
834
+ "mediaEmbed",
835
+ "insertImage",
836
+ "strapiMediaLib",
837
+ "blockquote",
838
+ "insertTable",
839
+ "codeBlock",
840
+ "htmlEmbed",
841
+ "SourceEditing",
842
+ "specialCharacters",
843
+ "horizontalLine",
844
+ "pageBreak",
845
+ "|",
846
+ "undo",
847
+ "redo"
848
+ ],
849
+ balloonToolbar: [
850
+ "bold",
851
+ "italic",
852
+ "fontColor",
853
+ "fontBackgroundColor",
854
+ {
855
+ label: "Other formatting options",
856
+ icon: `
857
+ <svg width="800px" height="800px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
858
+ <rect x="0" fill="none" width="24" height="24"/>
859
+ <g>
860
+ <path d="M14.348 12H21v2h-4.613c.24.515.368 1.094.368 1.748 0 1.317-.474 2.355-1.423 3.114-.947.76-2.266 1.138-3.956 1.138-1.557 0-2.934-.293-4.132-.878v-2.874c.985.44 1.818.75 2.5.928.682.18 1.306.27 1.872.27.68 0 1.2-.13 1.562-.39.363-.26.545-.644.545-1.158 0-.285-.08-.54-.24-.763-.16-.222-.394-.437-.704-.643-.18-.12-.483-.287-.88-.49H3v-2H14.347zm-3.528-2c-.073-.077-.143-.155-.193-.235-.126-.202-.19-.44-.19-.713 0-.44.157-.795.47-1.068.313-.273.762-.41 1.348-.41.492 0 .993.064 1.502.19.51.127 1.153.35 1.93.67l1-2.405c-.753-.327-1.473-.58-2.16-.76-.69-.18-1.414-.27-2.173-.27-1.544 0-2.753.37-3.628 1.108-.874.738-1.312 1.753-1.312 3.044 0 .302.036.58.088.848h3.318z"/>
861
+ </g>
862
+ </svg>`,
863
+ items: ["underline", "strikethrough", "superscript", "subscript"]
864
+ },
865
+ "|",
866
+ "removeFormat"
867
+ ],
868
+ fontFamily: {
869
+ supportAllValues: true
870
+ },
871
+ fontSize: {
872
+ options: [10, 12, 14, "default", 18, 20, 22],
873
+ supportAllValues: true
874
+ },
875
+ heading: {
876
+ options: [
877
+ { model: "paragraph", title: "Paragraph", class: "ck-heading_paragraph" },
878
+ {
879
+ model: "heading1",
880
+ view: "h1",
881
+ title: "Heading 1",
882
+ class: "ck-heading_heading1"
883
+ },
884
+ {
885
+ model: "heading2",
886
+ view: "h2",
887
+ title: "Heading 2",
888
+ class: "ck-heading_heading2"
889
+ },
890
+ {
891
+ model: "heading3",
892
+ view: "h3",
893
+ title: "Heading 3",
894
+ class: "ck-heading_heading3"
895
+ },
896
+ {
897
+ model: "heading4",
898
+ view: "h4",
899
+ title: "Heading 4",
900
+ class: "ck-heading_heading4"
901
+ },
902
+ {
903
+ model: "heading5",
904
+ view: "h5",
905
+ title: "Heading 5",
906
+ class: "ck-heading_heading5"
907
+ },
908
+ {
909
+ model: "heading6",
910
+ view: "h6",
911
+ title: "Heading 6",
912
+ class: "ck-heading_heading6"
913
+ }
914
+ ]
915
+ },
916
+ htmlSupport: {
917
+ allow: [
918
+ {
919
+ name: /.*/,
920
+ attributes: true,
921
+ classes: true,
922
+ styles: true
923
+ }
924
+ ],
925
+ disallow: [
926
+ {
927
+ attributes: [
928
+ { key: /^on(.*)/i, value: true },
929
+ {
930
+ key: /.*/,
931
+ value: /(\b)(on\S+)(\s*)=|javascript:|(<\s*)(\/*)script/i
932
+ },
933
+ { key: /.*/, value: /data:(?!image\/(png|jpeg|gif|webp))/i }
934
+ ]
935
+ },
936
+ { name: "script" }
937
+ ]
938
+ },
939
+ htmlEmbed: {
940
+ showPreviews: true,
941
+ sanitizeHtml: (inputHtml) => {
942
+ const outputHtml = sanitizeHtml.default(inputHtml);
943
+ return {
944
+ html: outputHtml,
945
+ hasChanged: true
946
+ };
947
+ }
948
+ },
949
+ list: {
950
+ properties: {
951
+ styles: true,
952
+ startIndex: true,
953
+ reversed: true
954
+ }
955
+ },
956
+ table: {
957
+ contentToolbar: [
958
+ "tableColumn",
959
+ "tableRow",
960
+ "mergeTableCells",
961
+ "tableProperties",
962
+ "tableCellProperties",
963
+ "toggleTableCaption"
964
+ ]
965
+ },
966
+ image: {
967
+ styles: {
968
+ options: [
969
+ "inline",
970
+ "alignLeft",
971
+ "alignRight",
972
+ "alignCenter",
973
+ "alignBlockLeft",
974
+ "alignBlockRight",
975
+ "block",
976
+ "side"
977
+ ]
978
+ },
979
+ resizeOptions: [
980
+ {
981
+ name: "resizeImage:original",
982
+ label: "Default image width",
983
+ value: null
984
+ },
985
+ {
986
+ name: "resizeImage:50",
987
+ label: "50% page width",
988
+ value: "50"
989
+ },
990
+ {
991
+ name: "resizeImage:75",
992
+ label: "75% page width",
993
+ value: "75"
994
+ }
995
+ ],
996
+ toolbar: [
997
+ "imageTextAlternative",
998
+ "toggleImageCaption",
999
+ "linkImage",
1000
+ "|",
1001
+ "imageStyle:inline",
1002
+ "imageStyle:wrapText",
1003
+ "imageStyle:breakText",
1004
+ "imageStyle:side",
1005
+ "|",
1006
+ "resizeImage"
1007
+ ]
1008
+ },
1009
+ link: {
1010
+ decorators: {
1011
+ toggleDownloadable: {
1012
+ mode: "manual",
1013
+ label: "Downloadable",
1014
+ attributes: {
1015
+ download: "file"
1016
+ }
1017
+ }
1018
+ },
1019
+ addTargetToExternalLinks: true,
1020
+ defaultProtocol: "https://"
1021
+ },
1022
+ ui: {
1023
+ poweredBy: {
1024
+ position: "inside",
1025
+ side: "left",
1026
+ label: "",
1027
+ verticalOffset: 0,
1028
+ horizontalOffset: 0
1029
+ }
1030
+ }
1031
+ };
1032
+ const defaultHtmlPreset = {
1033
+ name: "defaultHtml",
1034
+ description: "Default HTML editor",
1035
+ editorConfig: editorConfig$1
1036
+ };
1037
+ const editorConfig = {
1038
+ licenseKey: "GPL",
1039
+ plugins: [
1040
+ Autoformat,
1041
+ BlockQuote,
1042
+ Bold,
1043
+ Code,
1044
+ CodeBlock,
1045
+ Essentials,
1046
+ Heading,
1047
+ HorizontalLine,
1048
+ Image,
1049
+ ImageToolbar,
1050
+ ImageUpload,
1051
+ ImageInsert,
1052
+ Italic,
1053
+ List,
1054
+ Link,
1055
+ Markdown,
1056
+ Paragraph,
1057
+ SourceEditing,
1058
+ SpecialCharacters,
1059
+ SpecialCharactersEssentials,
1060
+ Strikethrough,
1061
+ Table,
1062
+ TableToolbar,
1063
+ TextTransformation,
1064
+ TodoList,
1065
+ WordCount,
1066
+ StrapiMediaLib,
1067
+ StrapiUploadAdapter
1068
+ ],
1069
+ toolbar: [
1070
+ "sourceEditing",
1071
+ "|",
1072
+ "heading",
1073
+ "|",
1074
+ "bold",
1075
+ "italic",
1076
+ "fontColor",
1077
+ "strikethrough",
1078
+ "code",
1079
+ "bulletedList",
1080
+ "numberedList",
1081
+ "todoList",
1082
+ "link",
1083
+ "insertImage",
1084
+ "strapiMediaLib",
1085
+ "blockQuote",
1086
+ "insertTable",
1087
+ "codeBlock",
1088
+ "specialCharacters",
1089
+ "horizontalLine",
1090
+ "undo",
1091
+ "redo"
1092
+ ],
1093
+ heading: {
1094
+ options: [
1095
+ { model: "paragraph", title: "Paragraph", class: "ck-heading_paragraph" },
1096
+ {
1097
+ model: "heading1",
1098
+ view: "h1",
1099
+ title: "Heading 1",
1100
+ class: "ck-heading_heading1"
1101
+ },
1102
+ {
1103
+ model: "heading2",
1104
+ view: "h2",
1105
+ title: "Heading 2",
1106
+ class: "ck-heading_heading2"
1107
+ },
1108
+ {
1109
+ model: "heading3",
1110
+ view: "h3",
1111
+ title: "Heading 3",
1112
+ class: "ck-heading_heading3"
1113
+ },
1114
+ {
1115
+ model: "heading4",
1116
+ view: "h4",
1117
+ title: "Heading 4",
1118
+ class: "ck-heading_heading4"
1119
+ },
1120
+ {
1121
+ model: "heading5",
1122
+ view: "h5",
1123
+ title: "Heading 5",
1124
+ class: "ck-heading_heading5"
1125
+ },
1126
+ {
1127
+ model: "heading6",
1128
+ view: "h6",
1129
+ title: "Heading 6",
1130
+ class: "ck-heading_heading6"
1131
+ }
1132
+ ]
1133
+ },
1134
+ image: {
1135
+ toolbar: ["imageTextAlternative"]
1136
+ },
1137
+ table: {
1138
+ contentToolbar: ["tableColumn", "tableRow", "mergeTableCells"]
1139
+ },
1140
+ ui: {
1141
+ poweredBy: {
1142
+ position: "inside",
1143
+ side: "left",
1144
+ label: "",
1145
+ verticalOffset: 0,
1146
+ horizontalOffset: 0
1147
+ }
1148
+ }
1149
+ };
1150
+ const defaultMarkdownPreset = {
1151
+ name: "defaultMarkdown",
1152
+ description: "Default Markdown editor",
1153
+ editorConfig
1154
+ };
1155
+ const PLUGIN_CONFIG = {
1156
+ presets: {
1157
+ defaultHtml: defaultHtmlPreset,
1158
+ defaultMarkdown: defaultMarkdownPreset
1159
+ },
1160
+ theme: defaultTheme
1161
+ };
1162
+ function setPluginConfig(userPluginConfig) {
1163
+ const { presets: userPresets, theme: userTheme } = userPluginConfig || {};
1164
+ if (userPresets) {
1165
+ PLUGIN_CONFIG.presets = {};
1166
+ userPresets.forEach((preset) => {
1167
+ PLUGIN_CONFIG.presets[preset.name] = preset;
1168
+ });
1169
+ }
1170
+ if (userTheme) {
1171
+ PLUGIN_CONFIG.theme = userTheme;
1172
+ }
1173
+ deepFreeze(PLUGIN_CONFIG);
1174
+ }
1175
+ function getPluginConfig() {
1176
+ if (!Object.isFrozen(PLUGIN_CONFIG)) deepFreeze(PLUGIN_CONFIG);
1177
+ return PLUGIN_CONFIG;
1178
+ }
1179
+ function deepFreeze(obj) {
1180
+ Object.keys(obj).forEach((p) => {
1181
+ if (typeof obj[p] === "object" && obj[p] !== null && !Object.isFrozen(obj[p])) {
1182
+ deepFreeze(obj[p]);
1183
+ }
1184
+ });
1185
+ return Object.freeze(obj);
1186
+ }
1187
+ function CKEditorIcon() {
1188
+ return /* @__PURE__ */ jsx(IconBox, { justifyContent: "center", alignItems: "center", width: 7, height: 6, hasRadius: true, "aria-hidden": true, children: /* @__PURE__ */ jsx(SvgIcon, {}) });
1189
+ }
1190
+ function SvgIcon() {
1191
+ return /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "-8 -7 37 37", children: [
1192
+ /* @__PURE__ */ jsx(
1193
+ "path",
1194
+ {
1195
+ d: "M15.04 16.726a3.98 3.98 0 0 0-1.535.524 3.96 3.96 0 0 0-1.402 1.364c-.108.18-.716 1.347-.716 1.347l-2.09 3.82.022.016c.097.063.2.116.308.159.317.113.65.175.987.18 1.264.058 2.529-.016 3.793-.007.725.023 1.45.005 2.172-.053.348-.017.687-.117.99-.29.31-.178.576-.423.78-.717.138-.205.283-.407.409-.62.6-1.02 1.199-2.043 1.794-3.065.187-.321.37-.644.555-.966l.281-.481c.236-.392.367-.838.381-1.294l-3.258.057s-3.147-.012-3.472.026Zm2.764.903Z",
1196
+ fill: lightTheme.colors.secondary700
1197
+ }
1198
+ ),
1199
+ /* @__PURE__ */ jsx(
1200
+ "path",
1201
+ {
1202
+ d: "m7.12 22.61 1.901-3.477.46-.877c-.31-.168-.614-.35-.918-.528-.866-.508-1.766-.957-2.613-1.498a2.459 2.459 0 0 1-.609-.517c-.27-.336-.341-.736-.362-1.15-.052-1.022-.003-2.045-.02-3.068-.01-.487 0-.975.005-1.462.01-.806.384-1.382 1.069-1.783L8.115 7.03c.55-.322 1.102-.642 1.654-.961.127-.073.263-.13.395-.192.68-.321 1.298-.119 1.9.213.039.02.075.045.112.068.306.149.605.313.895.491.794.445 1.587.893 2.378 1.343.239.139.469.292.688.458.485.36.636.875.666 1.445.039.71.017 1.422.013 2.134-.002.698.01 1.396.003 2.094 1.478-.006 3.146 0 3.146 0l1.807-.032c-.006-.73-.016-1.46-.017-2.19 0-1.31.037-2.62-.039-3.928-.061-1.05-.34-2-1.232-2.666a12.549 12.549 0 0 0-1.264-.848c-1.454-.834-2.91-1.664-4.37-2.49-.545-.308-1.067-.659-1.644-.91-.069-.043-.135-.089-.205-.128-1.106-.613-2.24-.992-3.485-.405-.242.115-.49.218-.723.352-1.011.58-2.02 1.166-3.026 1.757-1.271.744-2.54 1.488-3.81 2.234C.705 5.602.025 6.66.012 8.144c-.008.897-.02 1.794 0 2.691.039 1.884-.045 3.77.058 5.652.042.761.174 1.499.672 2.12.32.377.698.7 1.121.956 1.556 1.001 3.209 1.835 4.8 2.775l.457.271Z",
1203
+ fill: lightTheme.colors.secondary600
1204
+ }
1205
+ )
1206
+ ] });
1207
+ }
1208
+ const IconBox = styled(Flex)`
1209
+ background-color: ${lightTheme.colors.secondary100};
1210
+ border: 1px solid ${lightTheme.colors.secondary200};
1211
+ `;
1212
+ const clonedDefaultTheme = cloneDeep(defaultTheme);
1213
+ const clonedDefaultHtmlPreset = cloneDeep(defaultHtmlPreset);
1214
+ const clonedDefaultMarkdownPreset = cloneDeep(defaultMarkdownPreset);
1215
+ const AVAILABLE_OPTIONS = [];
1216
+ function fillAvailableOptions() {
1217
+ const { presets } = getPluginConfig();
1218
+ Object.values(presets).forEach(({ name: name2, description: description2 }) => {
1219
+ const option = {
1220
+ key: name2,
1221
+ value: name2,
1222
+ metadatas: {
1223
+ intlLabel: {
1224
+ id: `${PLUGIN_ID}.preset.${name2}.label`,
1225
+ defaultMessage: description2
1226
+ }
1227
+ }
1228
+ };
1229
+ AVAILABLE_OPTIONS.push(option);
1230
+ });
1231
+ }
1232
+ const index = {
1233
+ bootstrap() {
1234
+ fillAvailableOptions();
1235
+ },
1236
+ async register(app) {
1237
+ app.customFields.register({
1238
+ name: "CKEditor",
1239
+ type: "richtext",
1240
+ pluginId: PLUGIN_ID,
1241
+ icon: CKEditorIcon,
1242
+ intlLabel: {
1243
+ id: `${PLUGIN_ID}.label`,
1244
+ defaultMessage: "CKEditor 5"
1245
+ },
1246
+ intlDescription: {
1247
+ id: `${PLUGIN_ID}.description`,
1248
+ defaultMessage: "The advanced rich text editor. (Community Edition)"
1249
+ },
1250
+ components: {
1251
+ Input: async () => import("./Field-8Nh0dMSc.mjs").then((module) => ({
1252
+ default: module.Field
1253
+ }))
1254
+ },
1255
+ options: {
1256
+ base: [
1257
+ {
1258
+ intlLabel: {
1259
+ id: `${PLUGIN_ID}.preset.label`,
1260
+ defaultMessage: "Preset"
1261
+ },
1262
+ description: {
1263
+ id: `${PLUGIN_ID}.preset.description`,
1264
+ defaultMessage: " "
1265
+ },
1266
+ name: "options.preset",
1267
+ type: "select",
1268
+ options: AVAILABLE_OPTIONS
1269
+ }
1270
+ ],
1271
+ advanced: [
1272
+ {
1273
+ name: "required",
1274
+ type: "checkbox",
1275
+ intlLabel: {
1276
+ id: `${PLUGIN_ID}.required.label`,
1277
+ defaultMessage: "Required field"
1278
+ },
1279
+ description: {
1280
+ id: `${PLUGIN_ID}.required.description`,
1281
+ defaultMessage: "You won't be able to create an entry if this field is empty"
1282
+ }
1283
+ },
1284
+ {
1285
+ sectionTitle: {
1286
+ id: `${PLUGIN_ID}.options.advanced.limiters`,
1287
+ defaultMessage: "Input limiters"
1288
+ },
1289
+ items: [
1290
+ {
1291
+ name: "options.maxLengthWords",
1292
+ type: "checkbox-with-number-field",
1293
+ intlLabel: {
1294
+ id: `${PLUGIN_ID}.maxLengthWords.label`,
1295
+ defaultMessage: "Words limit"
1296
+ }
1297
+ },
1298
+ {
1299
+ name: "options.maxLengthCharacters",
1300
+ type: "checkbox-with-number-field",
1301
+ intlLabel: {
1302
+ id: `${PLUGIN_ID}.maxLengthCharacters.label`,
1303
+ defaultMessage: "Characters limit"
1304
+ }
1305
+ }
1306
+ ]
1307
+ }
1308
+ ],
1309
+ validator: () => ({
1310
+ preset: yup.string().required({
1311
+ id: `${PLUGIN_ID}.preset.error.required`,
1312
+ defaultMessage: "Editor preset is required"
1313
+ })
1314
+ })
1315
+ }
1316
+ });
1317
+ }
1318
+ };
1319
+ export {
1320
+ StrapiMediaLib as S,
1321
+ index as a,
1322
+ clonedDefaultHtmlPreset as b,
1323
+ clonedDefaultTheme as c,
1324
+ clonedDefaultMarkdownPreset as d,
1325
+ StrapiUploadAdapter as e,
1326
+ getPluginConfig as g,
1327
+ isImageResponsive as i,
1328
+ prefixFileUrlWithBackendUrl as p,
1329
+ setPluginConfig as s
1330
+ };