magic-editor-x 2.0.0 → 2.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.
Files changed (51) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/README.md +154 -68
  3. package/dist/admin/{ConfigurationPage-DvAifELO.mjs → ConfigurationPage-CK2AbfGW.mjs} +126 -7
  4. package/dist/admin/{ConfigurationPage-B1uCIE3J.js → ConfigurationPage-CzsT_dO_.js} +125 -4
  5. package/dist/admin/{CustomBlocksPage-6-OQwpXQ.mjs → CustomBlocksPage-B2A8S5MV.mjs} +4 -4
  6. package/dist/admin/{CustomBlocksPage-6eWCOreU.js → CustomBlocksPage-CvLrsBds.js} +4 -4
  7. package/dist/admin/{EditorField-ThSoOCPm.mjs → EditorField-7YCdXx-v.mjs} +2019 -661
  8. package/dist/admin/{EditorField-DocyD2Q3.js → EditorField-BdBCW15Q.js} +2015 -657
  9. package/dist/admin/{api-B-RsxJCs.js → api-CmccMxlN.js} +2 -0
  10. package/dist/admin/{api-C4XsDZxd.mjs → api-D5CAH0nh.mjs} +2 -0
  11. package/dist/admin/{de-RAxzvrwm.mjs → de-BHPyA2S-.mjs} +10 -2
  12. package/dist/admin/{de-BMxADn2Z.mjs → de-Bt6pYIWi.mjs} +16 -1
  13. package/dist/admin/{de-Dx7vUW0Z.js → de-CVbi685U.js} +16 -1
  14. package/dist/admin/{de-DcDPRzV4.js → de-CkUYGb7U.js} +22 -1
  15. package/dist/admin/{de-B8XFFhHh.js → de-RMs-_SCK.js} +10 -2
  16. package/dist/admin/{de-n5V6c5RT.mjs → de-rRIutpYJ.mjs} +22 -1
  17. package/dist/admin/{en-sNn4z9lA.js → en-BX362fTp.js} +16 -1
  18. package/dist/admin/{en-BQ5Pxe2o.mjs → en-B_HltUxZ.mjs} +16 -1
  19. package/dist/admin/{en-BzfyifEU.mjs → en-BluCStLw.mjs} +10 -2
  20. package/dist/admin/{en-DcWUTE2J.js → en-C81faOHP.js} +10 -2
  21. package/dist/admin/{en-D-DGftl0.js → en-DulOcmXb.js} +22 -1
  22. package/dist/admin/{en-BqNm3nMQ.mjs → en-Puup8TFi.mjs} +22 -1
  23. package/dist/admin/{es-SzeTV4q8.mjs → es-257SSB7f.mjs} +22 -1
  24. package/dist/admin/{es-Di0pyQCh.js → es-BoQZC86B.js} +22 -1
  25. package/dist/admin/{es-DVsXnS0N.js → es-CHHEZi44.js} +16 -1
  26. package/dist/admin/{es-C2OJVYkV.mjs → es-CQRI2Prp.mjs} +10 -2
  27. package/dist/admin/{es-B6NYq0VH.mjs → es-CrhwOq-5.mjs} +16 -1
  28. package/dist/admin/{es-BOtVc9qv.js → es-D1QzY0JW.js} +10 -2
  29. package/dist/admin/{fr-DmG3_Cn-.mjs → fr-5djKfQ3s.mjs} +16 -1
  30. package/dist/admin/{fr-Fwxcj4SM.js → fr-B3SL0TBV.js} +16 -1
  31. package/dist/admin/{fr-DhgPYHIH.mjs → fr-C5rSdKU4.mjs} +22 -1
  32. package/dist/admin/{fr-Bpo5Uq1f.mjs → fr-Di3R6gOX.mjs} +10 -2
  33. package/dist/admin/{fr-D6F--jIB.js → fr-HxFcPpv4.js} +22 -1
  34. package/dist/admin/{fr-DfxKaOc_.js → fr-R3_MbzT5.js} +10 -2
  35. package/dist/admin/{index-D1Q5Rlt6.mjs → index-0_b1iroK.mjs} +18 -18
  36. package/dist/admin/{index-CwfaB5-e.js → index-6SZLli70.js} +18 -18
  37. package/dist/admin/index.js +1 -1
  38. package/dist/admin/index.mjs +1 -1
  39. package/dist/admin/{pt-LCvjwk0y.js → pt-BCW1u_Hp.js} +10 -2
  40. package/dist/admin/{pt-BbdwHlWF.mjs → pt-BdnY2Cth.mjs} +16 -1
  41. package/dist/admin/{pt-BPo0ex21.js → pt-Cjn2Sc9k.js} +22 -1
  42. package/dist/admin/{pt-DqCXuI4S.mjs → pt-Cr9AL408.mjs} +10 -2
  43. package/dist/admin/{pt-BvSl1btT.mjs → pt-D6UuEtPy.mjs} +22 -1
  44. package/dist/admin/{pt-C6nr71Yw.js → pt-EVwCuBUK.js} +16 -1
  45. package/dist/admin/{sanitize-9UVcXFfc.js → sanitize-DP5aeU7V.js} +46 -1
  46. package/dist/admin/{sanitize-D4kfZ_ly.mjs → sanitize-jjCot5PM.mjs} +47 -2
  47. package/dist/admin/{useT-B5M49wGH.js → useT-91ruePzq.js} +1 -1
  48. package/dist/admin/{useT-CjX6fL2m.mjs → useT-vgY88N_H.mjs} +1 -1
  49. package/dist/server/index.js +1561 -321
  50. package/dist/server/index.mjs +1561 -321
  51. package/package.json +1 -1
@@ -4,12 +4,14 @@ const jsxRuntime = require("react/jsx-runtime");
4
4
  const designSystem = require("@strapi/design-system");
5
5
  const admin = require("@strapi/strapi/admin");
6
6
  const icons = require("@strapi/icons");
7
- const index = require("./index-CwfaB5-e.js");
8
- const useT = require("./useT-B5M49wGH.js");
7
+ const index = require("./index-6SZLli70.js");
8
+ const useT = require("./useT-91ruePzq.js");
9
9
  const react = require("react");
10
- require("styled-components");
11
- const api = require("./api-B-RsxJCs.js");
10
+ const styled = require("styled-components");
11
+ const api = require("./api-CmccMxlN.js");
12
12
  const reactIntl = require("react-intl");
13
+ const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
14
+ const styled__default = /* @__PURE__ */ _interopDefault(styled);
13
15
  const DraftSync = ({ values }) => {
14
16
  const setValues = admin.useForm("MagicEditorXDraftSync", (state) => state.setValues);
15
17
  react.useEffect(() => {
@@ -613,6 +615,124 @@ const EnvironmentSection = ({ environment }) => {
613
615
  }
614
616
  );
615
617
  };
618
+ const CodeBlock = styled__default.default.pre`
619
+ margin: 0;
620
+ max-width: 100%;
621
+ overflow-x: auto;
622
+ padding: ${({ theme }) => theme.spaces[4]};
623
+ border: 1px solid ${({ theme }) => theme.colors.neutral200};
624
+ border-radius: ${({ theme }) => theme.borderRadius};
625
+ background: ${({ theme }) => theme.colors.neutral100};
626
+ color: ${({ theme }) => theme.colors.neutral800};
627
+ font-family: 'SF Mono', SFMono-Regular, ui-monospace, Menlo, Consolas, monospace;
628
+ font-size: ${({ theme }) => theme.fontSizes[1]};
629
+ line-height: 1.6;
630
+ white-space: pre;
631
+
632
+ &:focus-visible {
633
+ outline: 2px solid ${({ theme }) => theme.colors.primary600};
634
+ outline-offset: 2px;
635
+ }
636
+ `;
637
+ const selectText = (node) => {
638
+ if (!node || typeof window.getSelection !== "function") return;
639
+ const range = document.createRange();
640
+ range.selectNodeContents(node);
641
+ const selection = window.getSelection();
642
+ selection.removeAllRanges();
643
+ selection.addRange(range);
644
+ node.focus();
645
+ };
646
+ const CspSection = ({ csp }) => {
647
+ const t = useT.useT();
648
+ const { copy } = admin.useClipboard();
649
+ const { toggleNotification } = admin.useNotification();
650
+ const codeRef = react.useRef(null);
651
+ const [alertOpen, setAlertOpen] = react.useState(true);
652
+ const frameMissing = csp && Array.isArray(csp.frameSrcMissing) && csp.frameSrcMissing || [];
653
+ const imgMissing = Boolean(csp && csp.imgSrcMissing);
654
+ if (!csp || !csp.active || !csp.snippet || !frameMissing.length && !imgMissing) return null;
655
+ const onCopy = async () => {
656
+ const ok = await copy(csp.snippet);
657
+ if (ok) {
658
+ toggleNotification({
659
+ type: "success",
660
+ message: t("settings.csp.copied", "Snippet copied to the clipboard.")
661
+ });
662
+ } else {
663
+ selectText(codeRef.current);
664
+ toggleNotification({
665
+ type: "warning",
666
+ message: t(
667
+ "settings.csp.copyFailed",
668
+ "The browser did not allow copying. The snippet is selected; copy it with Ctrl+C or Cmd+C."
669
+ )
670
+ });
671
+ }
672
+ };
673
+ const allowed = t("settings.csp.allowed", "Allowed");
674
+ const codeLabel = t("settings.csp.codeLabel", "Snippet for config/middlewares.js");
675
+ return /* @__PURE__ */ jsxRuntime.jsxs(
676
+ useT.SectionCard,
677
+ {
678
+ title: t("settings.csp.title", "Content Security Policy"),
679
+ subtitle: t(
680
+ "settings.csp.subtitle",
681
+ "The admin Content Security Policy is set in config/middlewares.js. The plugin never changes it."
682
+ ),
683
+ children: [
684
+ alertOpen ? /* @__PURE__ */ jsxRuntime.jsx(
685
+ designSystem.Alert,
686
+ {
687
+ variant: "warning",
688
+ closeLabel: t("settings.close", "Close"),
689
+ onClose: () => setAlertOpen(false),
690
+ title: t("settings.csp.alertTitle", "Some editor previews are blocked"),
691
+ children: t(
692
+ "settings.csp.alertBody",
693
+ "Your Content Security Policy blocks content the editor shows. Stored content is not affected; editors see a placeholder instead. To allow it, add the sources below to the strapi::security middleware and restart Strapi."
694
+ )
695
+ }
696
+ ) : null,
697
+ /* @__PURE__ */ jsxRuntime.jsx(
698
+ PropertyList,
699
+ {
700
+ items: [
701
+ {
702
+ key: "frame",
703
+ label: t("settings.csp.frames", "Embeds (frame-src)"),
704
+ value: frameMissing.length ? t("settings.csp.framesBlocked", "Blocked: {sources}", { sources: frameMissing.join(", ") }) : allowed
705
+ },
706
+ {
707
+ key: "img",
708
+ label: t("settings.csp.images", "External images (img-src)"),
709
+ value: imgMissing ? t(
710
+ "settings.csp.imagesBlocked",
711
+ "Blocked: images from other hosts (for example link previews)"
712
+ ) : allowed,
713
+ hint: imgMissing ? t(
714
+ "settings.csp.imagesHint",
715
+ "The snippet adds https:. You can list your image hosts instead."
716
+ ) : void 0
717
+ }
718
+ ]
719
+ }
720
+ ),
721
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, minWidth: 0, children: [
722
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", gap: 2, wrap: "wrap", children: [
723
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", id: "mex-csp-snippet-label", children: codeLabel }),
724
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.IconButton, { label: t("settings.csp.copy", "Copy the snippet"), variant: "tertiary", onClick: onCopy, children: /* @__PURE__ */ jsxRuntime.jsx(icons.Duplicate, {}) })
725
+ ] }),
726
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { minWidth: 0, children: /* @__PURE__ */ jsxRuntime.jsx(CodeBlock, { ref: codeRef, tabIndex: 0, "aria-labelledby": "mex-csp-snippet-label", children: /* @__PURE__ */ jsxRuntime.jsx("code", { children: csp.snippet }) }) }),
727
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t(
728
+ "settings.csp.mergeHint",
729
+ "Keep your other directives (for example the hosts of your upload provider) and restart Strapi after the change."
730
+ ) })
731
+ ] })
732
+ ]
733
+ }
734
+ );
735
+ };
616
736
  const RBAC = [...index.PERMISSIONS.settingsRead, ...index.PERMISSIONS.settingsUpdate];
617
737
  const testErrorText = (t, code) => {
618
738
  switch (code) {
@@ -755,6 +875,7 @@ const ConfigurationPage = () => {
755
875
  ) : null,
756
876
  /* @__PURE__ */ jsxRuntime.jsx(AiSection, { form, readOnly, onTest }),
757
877
  /* @__PURE__ */ jsxRuntime.jsx(EnvironmentSection, { environment: form.dto.environment }),
878
+ /* @__PURE__ */ jsxRuntime.jsx(CspSection, { csp: form.dto.environment && form.dto.environment.csp }),
758
879
  /* @__PURE__ */ jsxRuntime.jsxs(admin.Form, { method: "PUT", initialValues: form.saved, children: [
759
880
  /* @__PURE__ */ jsxRuntime.jsx(DraftSync, { values: form.draft }),
760
881
  /* @__PURE__ */ jsxRuntime.jsx(admin.Blocker, {})
@@ -4,11 +4,11 @@ import { Box, Typography, Flex, Badge, Table, Thead, Tr, Th, VisuallyHidden, Tbo
4
4
  import { Pencil, Duplicate, ArrowUp, ArrowDown, Trash, Plus, Upload, Download } from "@strapi/icons";
5
5
  import { EmptyDocuments } from "@strapi/icons/symbols";
6
6
  import { useFetchClient, useNotification, useRBAC, Page } from "@strapi/strapi/admin";
7
- import { P as PERMISSIONS } from "./index-D1Q5Rlt6.mjs";
8
- import { A as API, r as readApiError } from "./api-C4XsDZxd.mjs";
9
- import { u as useT, C as ConfirmAction, P as PageShell, S as SectionCard, r as refocusIfLost } from "./useT-CjX6fL2m.mjs";
7
+ import { P as PERMISSIONS } from "./index-0_b1iroK.mjs";
8
+ import { A as API, r as readApiError } from "./api-D5CAH0nh.mjs";
9
+ import { u as useT, C as ConfirmAction, P as PageShell, S as SectionCard, r as refocusIfLost } from "./useT-vgY88N_H.mjs";
10
10
  import styled, { useTheme } from "styled-components";
11
- import { b as sanitizeSvg, c as sanitizeTemplate } from "./sanitize-D4kfZ_ly.mjs";
11
+ import { b as sanitizeSvg, c as sanitizeTemplate } from "./sanitize-jjCot5PM.mjs";
12
12
  const toQuery = (breakpoint) => typeof breakpoint === "string" ? breakpoint.replace(/^\s*@media\s*/i, "").trim() : "";
13
13
  const useBreakpoint = () => {
14
14
  const theme = useTheme();
@@ -6,11 +6,11 @@ const designSystem = require("@strapi/design-system");
6
6
  const icons = require("@strapi/icons");
7
7
  const symbols = require("@strapi/icons/symbols");
8
8
  const admin = require("@strapi/strapi/admin");
9
- const index = require("./index-CwfaB5-e.js");
10
- const api = require("./api-B-RsxJCs.js");
11
- const useT = require("./useT-B5M49wGH.js");
9
+ const index = require("./index-6SZLli70.js");
10
+ const api = require("./api-CmccMxlN.js");
11
+ const useT = require("./useT-91ruePzq.js");
12
12
  const styled = require("styled-components");
13
- const sanitize = require("./sanitize-9UVcXFfc.js");
13
+ const sanitize = require("./sanitize-DP5aeU7V.js");
14
14
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
15
15
  const styled__default = /* @__PURE__ */ _interopDefault(styled);
16
16
  const toQuery = (breakpoint) => typeof breakpoint === "string" ? breakpoint.replace(/^\s*@media\s*/i, "").trim() : "";