@_sh/strapi-plugin-ckeditor 6.0.3 → 7.1.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.
package/README.md CHANGED
@@ -28,7 +28,7 @@
28
28
  - **Self-Hosted**
29
29
 
30
30
  <p align="right">
31
- <a href="https://www.buymeacoffee.com/nshenderov" target="_blank">
31
+ <a href="https://boosty.to/nkshenderov/donate" target="_blank">
32
32
  <img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px; width: 217px;" >
33
33
  </a>
34
34
  </p>
@@ -469,7 +469,7 @@ export default {
469
469
  <summary>Setting a new set of presets [TS]</summary>
470
470
 
471
471
  ```ts
472
- // src/admin/app.tsx
472
+ // src/admin/app.ts
473
473
 
474
474
  import {
475
475
  Bold,
@@ -553,7 +553,7 @@ export default {
553
553
  <summary>Default presets modification using setPluginConfig [TS]</summary>
554
554
 
555
555
  ```ts
556
- // src/admin/app.tsx
556
+ // src/admin/app.ts
557
557
 
558
558
  import { css } from 'styled-components';
559
559
 
@@ -627,7 +627,7 @@ export default {
627
627
  <summary>Default presets modification using getPluginPresets [TS]</summary>
628
628
 
629
629
  ```ts
630
- // src/admin/app.tsx
630
+ // src/admin/app.ts
631
631
 
632
632
  import { css } from 'styled-components';
633
633
  import { getPluginPresets } from '@_sh/strapi-plugin-ckeditor';
@@ -687,7 +687,7 @@ export default {
687
687
  <summary>Modifying theme using setPluginConfig [TS]</summary>
688
688
 
689
689
  ```ts
690
- // src/admin/app.tsx
690
+ // src/admin/app.ts
691
691
 
692
692
  import { css } from 'styled-components';
693
693
 
@@ -723,7 +723,7 @@ export default {
723
723
  <summary>Modifying theme using getPluginTheme [TS]</summary>
724
724
 
725
725
  ```ts
726
- // src/admin/app.tsx
726
+ // src/admin/app.ts
727
727
 
728
728
  import { css } from 'styled-components';
729
729
  import { getPluginTheme } from '@_sh/strapi-plugin-ckeditor';
@@ -849,7 +849,7 @@ for detailed instructions.
849
849
 
850
850
  Strapi **>= 5.0.0**
851
851
 
852
- Node **>= 18.0.0 <= 22.x.x**
852
+ Node **>= 20.0.0 <= 24.x.x**
853
853
 
854
854
  ---
855
855
 
@@ -1,12 +1,12 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import React, { createContext, useContext, useState, useEffect, useMemo, useRef, useCallback, useImperativeHandle, useReducer } from "react";
2
+ import React, { createContext, useContext, useState, useEffect, useMemo, useRef, useCallback, useImperativeHandle } from "react";
3
3
  import { Flex, IconButton, Modal, Field as Field$1, Loader, Box } from "@strapi/design-system";
4
4
  import { styled, css, createGlobalStyle } from "styled-components";
5
5
  import { useStrapiApp, useField } from "@strapi/strapi/admin";
6
6
  import { ClassicEditor } from "ckeditor5";
7
7
  import { CKEditor } from "@ckeditor/ckeditor5-react";
8
8
  import "ckeditor5/ckeditor5.css";
9
- import { g as getPluginConfig, p as prefixFileUrlWithBackendUrl, i as isImageResponsive } from "./index-CwLpvdFD.mjs";
9
+ import { g as getPluginConfig, p as prefixFileUrlWithBackendUrl, i as isImageResponsive } from "./index-Be7yVVtW.mjs";
10
10
  import "sanitize-html";
11
11
  import { Collapse, Expand } from "@strapi/icons";
12
12
  const STORAGE_KEYS = {
@@ -323,7 +323,9 @@ const CKEReact = React.forwardRef((_, forwardedRef) => {
323
323
  const ckWrapper = document.querySelector(".ck-body-wrapper");
324
324
  const listener = ckWrapper?.addEventListener("pointerdown", (e) => e.stopPropagation(), true);
325
325
  return () => {
326
- listener && ckWrapper?.removeEventListener("pointerdown", listener);
326
+ if (listener) {
327
+ ckWrapper?.removeEventListener("pointerdown", listener);
328
+ }
327
329
  };
328
330
  }, [editorInstance]);
329
331
  useImperativeHandle(
@@ -431,24 +433,44 @@ const WordCounter = styled(Flex)`
431
433
  `;
432
434
  function EditorLayout({ children }) {
433
435
  const { error, preset } = useEditorContext();
434
- const [isExpandedMode, handleToggleExpand] = useReducer((prev) => !prev, false);
435
- useEffect(() => {
436
- if (isExpandedMode) {
437
- document.body.classList.add("lock-body-scroll");
436
+ const [isExpandedMode, setIsExpandedMode] = useState(false);
437
+ const handleToggleExpand = (open) => {
438
+ if (open) {
438
439
  setTimeout(() => {
440
+ const ckPopupsWrapper = document.querySelector(".ck-body-wrapper");
441
+ const ckEditorModal = document.getElementById("ck-editor-modal");
442
+ if (ckPopupsWrapper && ckEditorModal) {
443
+ ckEditorModal.appendChild(ckPopupsWrapper);
444
+ }
439
445
  document.querySelector(".ck-editor__expanded .ck-editor__editable")?.focus();
440
446
  }, 0);
447
+ } else {
448
+ const ckPopupsWrapper = document.querySelector(".ck-body-wrapper");
449
+ if (ckPopupsWrapper) {
450
+ document.body.appendChild(ckPopupsWrapper);
451
+ }
452
+ }
453
+ setIsExpandedMode(open);
454
+ };
455
+ useEffect(() => {
456
+ if (isExpandedMode) {
457
+ document.body.classList.add("lock-body-scroll");
441
458
  }
442
459
  return () => {
443
460
  document.body.classList.remove("lock-body-scroll");
444
461
  };
445
462
  }, [isExpandedMode]);
446
463
  if (isExpandedMode) {
447
- return /* @__PURE__ */ jsx(Modal.Root, { open: isExpandedMode, onOpenChange: handleToggleExpand, children: /* @__PURE__ */ jsx(
448
- Modal.Content,
464
+ return /* @__PURE__ */ jsx(Modal.Root, { open: isExpandedMode, onOpenChange: handleToggleExpand, children: /* @__PURE__ */ jsx(Content, { id: "ck-editor-modal", children: /* @__PURE__ */ jsx(
465
+ Flex,
449
466
  {
450
- style: { maxWidth: "var(--ck-editor-full-screen-box-max-width)", width: "unset" },
451
- children: /* @__PURE__ */ jsx(Flex, { height: "90dvh", width: "90dvw", alignItems: "flex-start", direction: "column", children: /* @__PURE__ */ jsxs(
467
+ height: "90dvh",
468
+ width: "90dvw",
469
+ maxWidth: "100%",
470
+ direction: "column",
471
+ alignItems: "flex-start",
472
+ background: "neutral100",
473
+ children: /* @__PURE__ */ jsxs(
452
474
  EditorWrapper,
453
475
  {
454
476
  $presetStyles: preset?.styles,
@@ -457,12 +479,20 @@ function EditorLayout({ children }) {
457
479
  className: "ck-editor__expanded",
458
480
  children: [
459
481
  children,
460
- /* @__PURE__ */ jsx(CollapseButton, { tabindex: "-1", label: "Collapse", onClick: handleToggleExpand, children: /* @__PURE__ */ jsx(Collapse, {}) })
482
+ /* @__PURE__ */ jsx(
483
+ CollapseButton,
484
+ {
485
+ tabIndex: "-1",
486
+ label: "Collapse",
487
+ onClick: () => handleToggleExpand(false),
488
+ children: /* @__PURE__ */ jsx(Collapse, {})
489
+ }
490
+ )
461
491
  ]
462
492
  }
463
- ) })
493
+ )
464
494
  }
465
- ) });
495
+ ) }) });
466
496
  }
467
497
  return /* @__PURE__ */ jsxs(
468
498
  EditorWrapper,
@@ -472,7 +502,7 @@ function EditorLayout({ children }) {
472
502
  $hasError: Boolean(error),
473
503
  children: [
474
504
  children,
475
- /* @__PURE__ */ jsx(ExpandButton, { label: "Expand", onClick: handleToggleExpand, children: /* @__PURE__ */ jsx(Expand, {}) })
505
+ /* @__PURE__ */ jsx(ExpandButton, { label: "Expand", onClick: () => handleToggleExpand(true), children: /* @__PURE__ */ jsx(Expand, {}) })
476
506
  ]
477
507
  }
478
508
  );
@@ -514,6 +544,11 @@ const CollapseButton = styled(IconButton)`
514
544
  z-index: 2;
515
545
  box-shadow: ${({ theme }) => theme.shadows.filterShadow};
516
546
  `;
547
+ const Content = styled(Modal.Content)`
548
+ max-width: var(--ck-editor-full-screen-box-max-width);
549
+ width: unset;
550
+ overflow: visible;
551
+ `;
517
552
  const GlobalStyle = createGlobalStyle`
518
553
  ${({ $editortTheme, $variant }) => $editortTheme && css`
519
554
  ${$editortTheme.common}
@@ -30,7 +30,7 @@ const admin = require("@strapi/strapi/admin");
30
30
  const ckeditor5 = require("ckeditor5");
31
31
  const ckeditor5React = require("@ckeditor/ckeditor5-react");
32
32
  require("ckeditor5/ckeditor5.css");
33
- const index = require("./index-D48ig74s.js");
33
+ const index = require("./index-BmYyqc_l.js");
34
34
  require("sanitize-html");
35
35
  const icons = require("@strapi/icons");
36
36
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
@@ -349,7 +349,9 @@ const CKEReact = React__default.default.forwardRef((_, forwardedRef) => {
349
349
  const ckWrapper = document.querySelector(".ck-body-wrapper");
350
350
  const listener = ckWrapper?.addEventListener("pointerdown", (e) => e.stopPropagation(), true);
351
351
  return () => {
352
- listener && ckWrapper?.removeEventListener("pointerdown", listener);
352
+ if (listener) {
353
+ ckWrapper?.removeEventListener("pointerdown", listener);
354
+ }
353
355
  };
354
356
  }, [editorInstance]);
355
357
  React.useImperativeHandle(
@@ -457,24 +459,44 @@ const WordCounter = styledComponents.styled(designSystem.Flex)`
457
459
  `;
458
460
  function EditorLayout({ children }) {
459
461
  const { error, preset } = useEditorContext();
460
- const [isExpandedMode, handleToggleExpand] = React.useReducer((prev) => !prev, false);
461
- React.useEffect(() => {
462
- if (isExpandedMode) {
463
- document.body.classList.add("lock-body-scroll");
462
+ const [isExpandedMode, setIsExpandedMode] = React.useState(false);
463
+ const handleToggleExpand = (open) => {
464
+ if (open) {
464
465
  setTimeout(() => {
466
+ const ckPopupsWrapper = document.querySelector(".ck-body-wrapper");
467
+ const ckEditorModal = document.getElementById("ck-editor-modal");
468
+ if (ckPopupsWrapper && ckEditorModal) {
469
+ ckEditorModal.appendChild(ckPopupsWrapper);
470
+ }
465
471
  document.querySelector(".ck-editor__expanded .ck-editor__editable")?.focus();
466
472
  }, 0);
473
+ } else {
474
+ const ckPopupsWrapper = document.querySelector(".ck-body-wrapper");
475
+ if (ckPopupsWrapper) {
476
+ document.body.appendChild(ckPopupsWrapper);
477
+ }
478
+ }
479
+ setIsExpandedMode(open);
480
+ };
481
+ React.useEffect(() => {
482
+ if (isExpandedMode) {
483
+ document.body.classList.add("lock-body-scroll");
467
484
  }
468
485
  return () => {
469
486
  document.body.classList.remove("lock-body-scroll");
470
487
  };
471
488
  }, [isExpandedMode]);
472
489
  if (isExpandedMode) {
473
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Root, { open: isExpandedMode, onOpenChange: handleToggleExpand, children: /* @__PURE__ */ jsxRuntime.jsx(
474
- designSystem.Modal.Content,
490
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Root, { open: isExpandedMode, onOpenChange: handleToggleExpand, children: /* @__PURE__ */ jsxRuntime.jsx(Content, { id: "ck-editor-modal", children: /* @__PURE__ */ jsxRuntime.jsx(
491
+ designSystem.Flex,
475
492
  {
476
- style: { maxWidth: "var(--ck-editor-full-screen-box-max-width)", width: "unset" },
477
- children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { height: "90dvh", width: "90dvw", alignItems: "flex-start", direction: "column", children: /* @__PURE__ */ jsxRuntime.jsxs(
493
+ height: "90dvh",
494
+ width: "90dvw",
495
+ maxWidth: "100%",
496
+ direction: "column",
497
+ alignItems: "flex-start",
498
+ background: "neutral100",
499
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
478
500
  EditorWrapper,
479
501
  {
480
502
  $presetStyles: preset?.styles,
@@ -483,12 +505,20 @@ function EditorLayout({ children }) {
483
505
  className: "ck-editor__expanded",
484
506
  children: [
485
507
  children,
486
- /* @__PURE__ */ jsxRuntime.jsx(CollapseButton, { tabindex: "-1", label: "Collapse", onClick: handleToggleExpand, children: /* @__PURE__ */ jsxRuntime.jsx(icons.Collapse, {}) })
508
+ /* @__PURE__ */ jsxRuntime.jsx(
509
+ CollapseButton,
510
+ {
511
+ tabIndex: "-1",
512
+ label: "Collapse",
513
+ onClick: () => handleToggleExpand(false),
514
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.Collapse, {})
515
+ }
516
+ )
487
517
  ]
488
518
  }
489
- ) })
519
+ )
490
520
  }
491
- ) });
521
+ ) }) });
492
522
  }
493
523
  return /* @__PURE__ */ jsxRuntime.jsxs(
494
524
  EditorWrapper,
@@ -498,7 +528,7 @@ function EditorLayout({ children }) {
498
528
  $hasError: Boolean(error),
499
529
  children: [
500
530
  children,
501
- /* @__PURE__ */ jsxRuntime.jsx(ExpandButton, { label: "Expand", onClick: handleToggleExpand, children: /* @__PURE__ */ jsxRuntime.jsx(icons.Expand, {}) })
531
+ /* @__PURE__ */ jsxRuntime.jsx(ExpandButton, { label: "Expand", onClick: () => handleToggleExpand(true), children: /* @__PURE__ */ jsxRuntime.jsx(icons.Expand, {}) })
502
532
  ]
503
533
  }
504
534
  );
@@ -540,6 +570,11 @@ const CollapseButton = styledComponents.styled(designSystem.IconButton)`
540
570
  z-index: 2;
541
571
  box-shadow: ${({ theme }) => theme.shadows.filterShadow};
542
572
  `;
573
+ const Content = styledComponents.styled(designSystem.Modal.Content)`
574
+ max-width: var(--ck-editor-full-screen-box-max-width);
575
+ width: unset;
576
+ overflow: visible;
577
+ `;
543
578
  const GlobalStyle = styledComponents.createGlobalStyle`
544
579
  ${({ $editortTheme, $variant }) => $editortTheme && styledComponents.css`
545
580
  ${$editortTheme.common}