magic-editor-x 2.2.0 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/README.md +493 -168
  3. package/dist/admin/{ConfigurationPage-YvnPnna6.js → ConfigurationPage-CFP3lp9p.js} +479 -50
  4. package/dist/admin/{ConfigurationPage-3Dir3dAf.mjs → ConfigurationPage-CYGDLjM7.mjs} +450 -21
  5. package/dist/admin/ConfirmAction-DuQwvRYi.mjs +125 -0
  6. package/dist/admin/ConfirmAction-zLuIFj8t.js +124 -0
  7. package/dist/admin/{CustomBlocksPage-CR2BaP9O.mjs → CustomBlocksPage-B5Q33N-s.mjs} +92 -41
  8. package/dist/admin/{CustomBlocksPage-BiiL2ORG.js → CustomBlocksPage-DzPOSpfn.js} +135 -84
  9. package/dist/admin/DraftSync-BIA8cZgA.js +11 -0
  10. package/dist/admin/DraftSync-CUxOMG-E.mjs +12 -0
  11. package/dist/admin/TemplatesPage-4A8JNO_Z.mjs +993 -0
  12. package/dist/admin/TemplatesPage-BVkgafCK.js +993 -0
  13. package/dist/admin/{de-BmmLBJli.mjs → de-1cFMs-4c.mjs} +2 -0
  14. package/dist/admin/{de-BteRx2iA.js → de-2Ie5jy7j.js} +79 -1
  15. package/dist/admin/{de-62Vxb2iw.js → de-B1X46JJZ.js} +205 -2
  16. package/dist/admin/{de-CFX5atOk.mjs → de-BMY2LBaa.mjs} +79 -1
  17. package/dist/admin/{de-Bt6pYIWi.mjs → de-BUS1hUw0.mjs} +145 -0
  18. package/dist/admin/{de-CVbi685U.js → de-C3AsGauQ.js} +145 -0
  19. package/dist/admin/{de-BVvwSYYO.mjs → de-DOiGaTNX.mjs} +205 -2
  20. package/dist/admin/{de-DaJwN6nk.js → de-Dn8athM8.js} +2 -0
  21. package/dist/admin/{en-CyjAcccB.js → en-Ah-Cw0Wd.js} +79 -1
  22. package/dist/admin/{en-BX362fTp.js → en-BkEjpC3i.js} +145 -0
  23. package/dist/admin/{en-VlkaIzrM.js → en-CDg_18Bt.js} +205 -2
  24. package/dist/admin/{en-Cn78RZs-.js → en-CIZ5Ggod.js} +2 -0
  25. package/dist/admin/{en-Cg2Ak5Cr.mjs → en-CU6UzV4g.mjs} +205 -2
  26. package/dist/admin/{en-ea0tfA5i.mjs → en-CvFiqti2.mjs} +79 -1
  27. package/dist/admin/{en-D7mZWLGp.mjs → en-Dc9y-6n9.mjs} +2 -0
  28. package/dist/admin/{en-B_HltUxZ.mjs → en-GCzgS9Aw.mjs} +145 -0
  29. package/dist/admin/{es-BT9oAcHf.js → es-BCpJmUEM.js} +205 -2
  30. package/dist/admin/{es-C9-cXdb6.mjs → es-BmfffNM2.mjs} +205 -2
  31. package/dist/admin/{es-BmGtLkJD.js → es-C4IRHV5d.js} +2 -0
  32. package/dist/admin/{es-CHHEZi44.js → es-C4pEnDRv.js} +145 -0
  33. package/dist/admin/{es-C8GZFGjv.js → es-Cr8JH85N.js} +79 -1
  34. package/dist/admin/{es-joykG5I9.mjs → es-D2Kw6E4N.mjs} +2 -0
  35. package/dist/admin/{es-CrhwOq-5.mjs → es-DHBBZKl2.mjs} +145 -0
  36. package/dist/admin/{es-CEi_ycX8.mjs → es-DbKHZz5l.mjs} +79 -1
  37. package/dist/admin/{fr-CrzxGe5e.mjs → fr-BOvvfEH7.mjs} +2 -0
  38. package/dist/admin/{fr-B3SL0TBV.js → fr-C2aLSwEu.js} +145 -0
  39. package/dist/admin/{fr-BAMSvQbR.mjs → fr-DQJ_7aq5.mjs} +79 -1
  40. package/dist/admin/{fr-DpU_qiXR.mjs → fr-DZd2XJP6.mjs} +205 -2
  41. package/dist/admin/{fr-5djKfQ3s.mjs → fr-Dvq4xk2e.mjs} +145 -0
  42. package/dist/admin/{fr-oRCJNdeJ.js → fr-OJ4VW1kh.js} +79 -1
  43. package/dist/admin/{fr-D6KJqPWi.js → fr-ZcN0yM_2.js} +205 -2
  44. package/dist/admin/{fr-Ct_uPqxV.js → fr-Zkb8vfjN.js} +2 -0
  45. package/dist/admin/{EditorField-Diq1j8kc.js → index-DQVE0ymw.js} +13712 -6767
  46. package/dist/admin/index-DR8sHkTk.js +1940 -0
  47. package/dist/admin/index-My6FjjHB.mjs +1939 -0
  48. package/dist/admin/{EditorField-B8pyAxPE.mjs → index-k8_a5o1A.mjs} +10223 -3278
  49. package/dist/admin/index.js +1 -1
  50. package/dist/admin/index.mjs +2 -2
  51. package/dist/admin/{pt-chN2jrXl.js → pt-1IUyx6ae.js} +2 -0
  52. package/dist/admin/{pt-CQrfqsCN.mjs → pt-BSLzA17U.mjs} +79 -1
  53. package/dist/admin/{pt-jUqOR7Xh.mjs → pt-C3UdeIpd.mjs} +205 -2
  54. package/dist/admin/{pt-BOrl6x-r.js → pt-CImqDnLB.js} +205 -2
  55. package/dist/admin/{pt-BdnY2Cth.mjs → pt-CilDggGF.mjs} +145 -0
  56. package/dist/admin/{pt-tUeJ2Ywd.js → pt-D0I0_JYs.js} +79 -1
  57. package/dist/admin/{pt-EVwCuBUK.js → pt-DX0OAIoL.js} +145 -0
  58. package/dist/admin/{pt-Ga-4Hsv0.mjs → pt-etwsg3G4.mjs} +2 -0
  59. package/dist/admin/useBreakpoint-D30eNTkF.js +37 -0
  60. package/dist/admin/useBreakpoint-DCfn6pDG.mjs +38 -0
  61. package/dist/admin/useT-Cmg1jwwG.mjs +65 -0
  62. package/dist/admin/{useT-BWZ_-Hel.js → useT-DNphiBQR.js} +4 -70
  63. package/dist/blocks/index.d.mts +167 -0
  64. package/dist/blocks/index.d.ts +167 -0
  65. package/dist/blocks/index.js +631 -0
  66. package/dist/blocks/index.mjs +609 -0
  67. package/dist/react/index.d.mts +39 -0
  68. package/dist/react/index.d.ts +39 -0
  69. package/dist/react/index.js +2687 -0
  70. package/dist/react/index.mjs +2657 -0
  71. package/dist/render/index.d.mts +131 -5
  72. package/dist/render/index.d.ts +131 -5
  73. package/dist/render/index.js +1679 -181
  74. package/dist/render/index.mjs +1679 -181
  75. package/dist/server/index.js +10645 -3716
  76. package/dist/server/index.mjs +10645 -3716
  77. package/dist/vue/index.d.mts +41 -0
  78. package/dist/vue/index.d.ts +41 -0
  79. package/dist/vue/index.js +2630 -0
  80. package/dist/vue/index.mjs +2610 -0
  81. package/package.json +30 -6
  82. package/schema/magic-editor-x.schema.json +540 -1
  83. package/types/blocks.d.ts +167 -0
  84. package/types/index.d.ts +127 -0
  85. package/types/react.d.ts +39 -0
  86. package/types/render.d.ts +131 -5
  87. package/types/vue.d.ts +41 -0
  88. package/dist/admin/api-Dsq53giv.js +0 -37
  89. package/dist/admin/api-RZ0Fz0BD.mjs +0 -38
  90. package/dist/admin/index-C-lyON1B.mjs +0 -303
  91. package/dist/admin/index-iA0lued_.js +0 -302
  92. package/dist/admin/sanitize-Cb4jvBhj.js +0 -628
  93. package/dist/admin/sanitize-ClkX823p.mjs +0 -627
  94. package/dist/admin/useT-pvHmgBFj.mjs +0 -131
@@ -1,51 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
- const react = require("react");
4
+ const ReactNamespace = require("react");
5
5
  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-iA0lued_.js");
10
- const api = require("./api-Dsq53giv.js");
11
- const useT = require("./useT-BWZ_-Hel.js");
9
+ const index = require("./index-DR8sHkTk.js");
10
+ const ConfirmAction = require("./ConfirmAction-zLuIFj8t.js");
11
+ const useT = require("./useT-DNphiBQR.js");
12
12
  const styled = require("styled-components");
13
- const sanitize = require("./sanitize-Cb4jvBhj.js");
13
+ const useBreakpoint = require("./useBreakpoint-D30eNTkF.js");
14
+ const reactIntl = require("react-intl");
14
15
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
15
16
  const styled__default = /* @__PURE__ */ _interopDefault(styled);
16
- const toQuery = (breakpoint) => typeof breakpoint === "string" ? breakpoint.replace(/^\s*@media\s*/i, "").trim() : "";
17
- const useBreakpoint = () => {
18
- const theme = styled.useTheme();
19
- const queries = react.useMemo(
20
- () => ({
21
- small: toQuery(theme && theme.breakpoints && theme.breakpoints.small) || "(min-width: 520px)",
22
- medium: toQuery(theme && theme.breakpoints && theme.breakpoints.medium) || "(min-width: 768px)",
23
- large: toQuery(theme && theme.breakpoints && theme.breakpoints.large) || "(min-width: 1080px)"
24
- }),
25
- [theme]
26
- );
27
- const read = react.useMemo(
28
- () => () => {
29
- if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
30
- return { small: true, medium: true, large: true };
31
- }
32
- return Object.fromEntries(
33
- Object.entries(queries).map(([key, query]) => [key, window.matchMedia(query).matches])
34
- );
35
- },
36
- [queries]
37
- );
38
- const [matches, setMatches] = react.useState(read);
39
- react.useEffect(() => {
40
- if (typeof window === "undefined" || typeof window.matchMedia !== "function") return void 0;
41
- const lists = Object.values(queries).map((query) => window.matchMedia(query));
42
- const update = () => setMatches(read());
43
- update();
44
- lists.forEach((list) => list.addEventListener("change", update));
45
- return () => lists.forEach((list) => list.removeEventListener("change", update));
46
- }, [queries, read]);
47
- return { isBelowSmall: !matches.small, isBelowMedium: !matches.medium, isBelowLarge: !matches.large };
48
- };
49
17
  const FIELD_TYPES = Object.freeze([
50
18
  "text",
51
19
  "textarea",
@@ -58,6 +26,7 @@ const FIELD_TYPES = Object.freeze([
58
26
  ]);
59
27
  const TUNES = Object.freeze(["alignmentTune", "textVariant", "indentTune"]);
60
28
  const BLOCK_TYPES = Object.freeze(["simple", "embedded-entry"]);
29
+ const LEGACY_NAMES = Object.freeze(["toc", "gallery", "video", "audio", "synced", "mention"]);
61
30
  const RESERVED_NAMES = Object.freeze(
62
31
  [
63
32
  "paragraph",
@@ -69,11 +38,16 @@ const RESERVED_NAMES = Object.freeze(
69
38
  "code",
70
39
  "codeFlask",
71
40
  "delimiter",
41
+ "toc",
72
42
  "table",
73
43
  "embed",
74
44
  "raw",
75
45
  "image",
76
46
  "simpleImage",
47
+ "gallery",
48
+ "video",
49
+ "audio",
50
+ "synced",
77
51
  "linkTool",
78
52
  "attaches",
79
53
  "personality",
@@ -89,6 +63,7 @@ const RESERVED_NAMES = Object.freeze(
89
63
  "strikethrough",
90
64
  "tooltip",
91
65
  "hyperlink",
66
+ "mention",
92
67
  "aiAssistant",
93
68
  "textVariant",
94
69
  "alignmentTune",
@@ -232,7 +207,8 @@ const validateBlock = (values, context = {}) => {
232
207
  const name = String(values.name || "").trim();
233
208
  if (!name) errors.name = "required";
234
209
  else if (!NAME_PATTERN.test(name)) errors.name = "namePattern";
235
- else if (RESERVED_NAMES.includes(name.toLowerCase())) errors.name = "reserved";
210
+ else if (RESERVED_NAMES.includes(name.toLowerCase()) && !(LEGACY_NAMES.includes(name.toLowerCase()) && context.originalName === name))
211
+ errors.name = "reserved";
236
212
  else if ((context.existingNames || []).some((other) => other.toLowerCase() === name.toLowerCase()))
237
213
  errors.name = "taken";
238
214
  const label = String(values.label || "").trim();
@@ -316,20 +292,20 @@ const fillTemplate = (template, fields) => {
316
292
  };
317
293
  const useCustomBlocks = () => {
318
294
  const { get } = admin.useFetchClient();
319
- const [status, setStatus] = react.useState("loading");
320
- const [blocks, setBlocks] = react.useState([]);
321
- const [refreshError, setRefreshError] = react.useState(false);
322
- const [contentTypes, setContentTypes] = react.useState({ status: "loading", items: [] });
323
- const mounted = react.useRef(true);
324
- const loaded = react.useRef(false);
325
- react.useEffect(() => {
295
+ const [status, setStatus] = ReactNamespace.useState("loading");
296
+ const [blocks, setBlocks] = ReactNamespace.useState([]);
297
+ const [refreshError, setRefreshError] = ReactNamespace.useState(false);
298
+ const [contentTypes, setContentTypes] = ReactNamespace.useState({ status: "loading", items: [] });
299
+ const mounted = ReactNamespace.useRef(true);
300
+ const loaded = ReactNamespace.useRef(false);
301
+ ReactNamespace.useEffect(() => {
326
302
  mounted.current = true;
327
303
  return () => {
328
304
  mounted.current = false;
329
305
  };
330
306
  }, []);
331
- const fetchBlocks = react.useCallback(
332
- () => get(api.API.customBlocks, { params: { all: "true" } }).then(
307
+ const fetchBlocks = ReactNamespace.useCallback(
308
+ () => get(ConfirmAction.API.customBlocks, { params: { all: "true" } }).then(
333
309
  ({ data }) => {
334
310
  if (!mounted.current) return;
335
311
  setBlocks(Array.isArray(data.data) ? data.data : []);
@@ -345,8 +321,8 @@ const useCustomBlocks = () => {
345
321
  ),
346
322
  [get]
347
323
  );
348
- const fetchContentTypes = react.useCallback(
349
- () => get(api.API.contentTypes).then(
324
+ const fetchContentTypes = ReactNamespace.useCallback(
325
+ () => get(ConfirmAction.API.contentTypes).then(
350
326
  ({ data }) => {
351
327
  if (mounted.current)
352
328
  setContentTypes({ status: "ready", items: Array.isArray(data.data) ? data.data : [] });
@@ -357,15 +333,15 @@ const useCustomBlocks = () => {
357
333
  ),
358
334
  [get]
359
335
  );
360
- react.useEffect(() => {
336
+ ReactNamespace.useEffect(() => {
361
337
  fetchBlocks();
362
338
  fetchContentTypes();
363
339
  }, [fetchBlocks, fetchContentTypes]);
364
- const load = react.useCallback(() => {
340
+ const load = ReactNamespace.useCallback(() => {
365
341
  if (!loaded.current) setStatus("loading");
366
342
  return fetchBlocks();
367
343
  }, [fetchBlocks]);
368
- const loadContentTypes = react.useCallback(() => {
344
+ const loadContentTypes = ReactNamespace.useCallback(() => {
369
345
  setContentTypes((current) => ({ ...current, status: "loading" }));
370
346
  return fetchContentTypes();
371
347
  }, [fetchContentTypes]);
@@ -456,11 +432,11 @@ const TemplateFrame = styled__default.default(designSystem.Box)`
456
432
  }
457
433
  `;
458
434
  const IconPreview = ({ svg, label }) => {
459
- const clean = react.useMemo(() => sanitize.sanitizeSvg(svg), [svg]);
435
+ const clean = ReactNamespace.useMemo(() => index.sanitizeSvg(svg), [svg]);
460
436
  return /* @__PURE__ */ jsxRuntime.jsx(IconFrame, { role: "img", "aria-label": label, dangerouslySetInnerHTML: { __html: clean } });
461
437
  };
462
438
  const TemplatePreview = ({ template, fields, label, empty }) => {
463
- const clean = react.useMemo(() => sanitize.sanitizeTemplate(fillTemplate(template, fields)), [template, fields]);
439
+ const clean = ReactNamespace.useMemo(() => index.sanitizeTemplate(fillTemplate(template, fields)), [template, fields]);
464
440
  return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
465
441
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", tag: "p", children: label }),
466
442
  /* @__PURE__ */ jsxRuntime.jsx(TemplateFrame, { marginTop: 2, padding: 4, hasRadius: true, borderColor: "neutral200", background: "neutral100", children: clean ? (
@@ -523,7 +499,7 @@ const RowActions = ({
523
499
  }
524
500
  ),
525
501
  /* @__PURE__ */ jsxRuntime.jsx(
526
- useT.ConfirmAction,
502
+ ConfirmAction.ConfirmAction,
527
503
  {
528
504
  fallbackFocusRef,
529
505
  trigger: /* @__PURE__ */ jsxRuntime.jsx(
@@ -600,7 +576,7 @@ const BlockList = ({
600
576
  fallbackFocusRef
601
577
  }) => {
602
578
  const t = useT.useT();
603
- const { isBelowLarge } = useBreakpoint();
579
+ const { isBelowLarge } = useBreakpoint.useBreakpoint();
604
580
  const actions = { onEdit, onDuplicate, onMove, onDelete, fallbackFocusRef };
605
581
  if (isBelowLarge) {
606
582
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -914,12 +890,16 @@ const BlockFormModal = ({
914
890
  onClose
915
891
  }) => {
916
892
  const t = useT.useT();
917
- const [values, setValues] = react.useState(() => block ? fromDto(block) : emptyValues());
918
- const [serverErrors, setServerErrors] = react.useState({});
919
- const [showErrors, setShowErrors] = react.useState(false);
920
- const [saving, setSaving] = react.useState(false);
921
- const errors = react.useMemo(() => validateBlock(values, { existingNames: otherNames }), [values, otherNames]);
922
- const visible = react.useMemo(
893
+ const [values, setValues] = ReactNamespace.useState(() => block ? fromDto(block) : emptyValues());
894
+ const [serverErrors, setServerErrors] = ReactNamespace.useState({});
895
+ const [showErrors, setShowErrors] = ReactNamespace.useState(false);
896
+ const [saving, setSaving] = ReactNamespace.useState(false);
897
+ const originalName = block ? block.name : null;
898
+ const errors = ReactNamespace.useMemo(
899
+ () => validateBlock(values, { existingNames: otherNames, originalName }),
900
+ [values, otherNames, originalName]
901
+ );
902
+ const visible = ReactNamespace.useMemo(
923
903
  () => ({ ...showErrors ? errors : {}, ...serverErrors }),
924
904
  [errors, serverErrors, showErrors]
925
905
  );
@@ -1392,21 +1372,91 @@ const BlockFormModal = ({
1392
1372
  }
1393
1373
  );
1394
1374
  };
1375
+ const CodeBlocksSection = () => {
1376
+ const t = useT.useT();
1377
+ const { locale } = reactIntl.useIntl();
1378
+ const { get } = admin.useFetchClient();
1379
+ const [server, setServer] = ReactNamespace.useState([]);
1380
+ ReactNamespace.useEffect(() => {
1381
+ let active = true;
1382
+ get(ConfirmAction.API.config).then(
1383
+ ({ data }) => {
1384
+ if (active && data && data.data && Array.isArray(data.data.codeBlocks))
1385
+ setServer(data.data.codeBlocks);
1386
+ },
1387
+ () => {
1388
+ }
1389
+ );
1390
+ return () => {
1391
+ active = false;
1392
+ };
1393
+ }, [get]);
1394
+ const rows = ReactNamespace.useMemo(() => index.mergeCodeBlocks(server, index.codeBlocks(), locale), [server, locale]);
1395
+ if (!rows.length) return null;
1396
+ return /* @__PURE__ */ jsxRuntime.jsx(
1397
+ useT.SectionCard,
1398
+ {
1399
+ title: t("settings.blocks.code.title", "Defined in code"),
1400
+ subtitle: t(
1401
+ "settings.blocks.code.subtitle",
1402
+ "Blocks your app registers in code with the custom block SDK. They are changed in the code and cannot be edited here."
1403
+ ),
1404
+ children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { tag: "ul", margin: 0, padding: 0, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 3, children: rows.map((row) => /* @__PURE__ */ jsxRuntime.jsx(
1405
+ designSystem.Box,
1406
+ {
1407
+ tag: "li",
1408
+ padding: 4,
1409
+ hasRadius: true,
1410
+ borderColor: "neutral200",
1411
+ background: "neutral100",
1412
+ minWidth: 0,
1413
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 2, minWidth: 0, children: [
1414
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", alignItems: "center", children: [
1415
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "bold", textColor: "neutral800", tag: "h3", children: row.title }),
1416
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { children: t("settings.blocks.code.badge", "Defined in code") })
1417
+ ] }),
1418
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", style: { overflowWrap: "anywhere" }, children: [
1419
+ row.name,
1420
+ " ·",
1421
+ " ",
1422
+ t("settings.blocks.code.version", "Version {version}", { version: row.version })
1423
+ ] }),
1424
+ row.fields.length ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", style: { overflowWrap: "anywhere" }, children: t("settings.blocks.code.fields", "Fields: {fields}", {
1425
+ fields: row.fields.map((field) => `${field.key} (${field.type})`).join(", ")
1426
+ }) }) : null,
1427
+ row.presets.length ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t("settings.blocks.code.presets", "Also in the presets: {presets}", {
1428
+ presets: row.presets.join(", ")
1429
+ }) }) : null,
1430
+ !row.inAdmin ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "warning600", children: t(
1431
+ "settings.blocks.code.noTool",
1432
+ "No editor tool is registered in the admin, so editors cannot insert this block."
1433
+ ) }) : null,
1434
+ !row.onServer ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "warning600", children: t(
1435
+ "settings.blocks.code.noServer",
1436
+ "Not registered on the server: saved content of this block is cleaned with the generic policy."
1437
+ ) }) : null
1438
+ ] })
1439
+ },
1440
+ row.name
1441
+ )) }) })
1442
+ }
1443
+ );
1444
+ };
1395
1445
  const CustomBlocksPage = () => {
1396
1446
  const t = useT.useT();
1397
1447
  const { post, put, del, get } = admin.useFetchClient();
1398
1448
  const { toggleNotification } = admin.useNotification();
1399
1449
  const { allowedActions, isLoading: rbacLoading } = admin.useRBAC(index.PERMISSIONS.customBlocksManage);
1400
1450
  const data = useCustomBlocks();
1401
- const [modal, setModal] = react.useState({ open: false, block: null, key: 0 });
1402
- const [busyId, setBusyId] = react.useState(null);
1403
- const [exporting, setExporting] = react.useState(false);
1404
- const [importing, setImporting] = react.useState(false);
1405
- const [importReport, setImportReport] = react.useState(null);
1406
- const createRef = react.useRef(null);
1407
- const fileRef = react.useRef(null);
1451
+ const [modal, setModal] = ReactNamespace.useState({ open: false, block: null, key: 0 });
1452
+ const [busyId, setBusyId] = ReactNamespace.useState(null);
1453
+ const [exporting, setExporting] = ReactNamespace.useState(false);
1454
+ const [importing, setImporting] = ReactNamespace.useState(false);
1455
+ const [importReport, setImportReport] = ReactNamespace.useState(null);
1456
+ const createRef = ReactNamespace.useRef(null);
1457
+ const fileRef = ReactNamespace.useRef(null);
1408
1458
  const title = t("settings.blocks.title", "Custom blocks");
1409
- const otherNames = react.useMemo(
1459
+ const otherNames = ReactNamespace.useMemo(
1410
1460
  () => data.blocks.filter((block) => !modal.block || block.id !== modal.block.id).map((block) => block.name),
1411
1461
  [data.blocks, modal.block]
1412
1462
  );
@@ -1435,7 +1485,7 @@ const CustomBlocksPage = () => {
1435
1485
  ] });
1436
1486
  }
1437
1487
  const failed = (error, fallback) => {
1438
- const info = api.readApiError(error);
1488
+ const info = ConfirmAction.readApiError(error);
1439
1489
  toggleNotification({
1440
1490
  type: "danger",
1441
1491
  message: info.status === 404 ? t("settings.blocks.notFound", "This block no longer exists.") : fallback
@@ -1444,8 +1494,8 @@ const CustomBlocksPage = () => {
1444
1494
  const onSubmit = async (values) => {
1445
1495
  const payload = toPayload(values);
1446
1496
  try {
1447
- if (modal.block) await put(api.API.customBlock(modal.block.id), payload);
1448
- else await post(api.API.customBlocks, payload);
1497
+ if (modal.block) await put(ConfirmAction.API.customBlock(modal.block.id), payload);
1498
+ else await post(ConfirmAction.API.customBlocks, payload);
1449
1499
  toggleNotification({
1450
1500
  type: "success",
1451
1501
  message: modal.block ? t("settings.blocks.saved", "Block {label} saved.", { label: payload.label }) : t("settings.blocks.created", "Block {label} created.", { label: payload.label })
@@ -1454,7 +1504,7 @@ const CustomBlocksPage = () => {
1454
1504
  await data.reload();
1455
1505
  return { ok: true };
1456
1506
  } catch (error) {
1457
- const info = api.readApiError(error);
1507
+ const info = ConfirmAction.readApiError(error);
1458
1508
  if (info.status === 400) {
1459
1509
  toggleNotification({
1460
1510
  type: "warning",
@@ -1475,7 +1525,7 @@ const CustomBlocksPage = () => {
1475
1525
  const onToggle = async (block, enabled) => {
1476
1526
  setBusyId(block.id);
1477
1527
  try {
1478
- const { data: response } = await put(api.API.customBlock(block.id), withEnabled(block, enabled));
1528
+ const { data: response } = await put(ConfirmAction.API.customBlock(block.id), withEnabled(block, enabled));
1479
1529
  data.setBlocks((current) => current.map((item) => item.id === block.id ? response.data : item));
1480
1530
  toggleNotification({
1481
1531
  type: "success",
@@ -1484,7 +1534,7 @@ const CustomBlocksPage = () => {
1484
1534
  })
1485
1535
  });
1486
1536
  } catch (error) {
1487
- const info = api.readApiError(error);
1537
+ const info = ConfirmAction.readApiError(error);
1488
1538
  if (info.status === 400) {
1489
1539
  toggleNotification({
1490
1540
  type: "warning",
@@ -1502,7 +1552,7 @@ const CustomBlocksPage = () => {
1502
1552
  const onDuplicate = async (block) => {
1503
1553
  setBusyId(block.id);
1504
1554
  try {
1505
- const { data: response } = await post(api.API.customBlockDuplicate(block.id), {});
1555
+ const { data: response } = await post(ConfirmAction.API.customBlockDuplicate(block.id), {});
1506
1556
  toggleNotification({
1507
1557
  type: "success",
1508
1558
  message: t("settings.blocks.duplicated", "Copy {label} created.", { label: response.data.label })
@@ -1524,18 +1574,18 @@ const CustomBlocksPage = () => {
1524
1574
  const opener = typeof document !== "undefined" ? document.activeElement : null;
1525
1575
  setBusyId(block.id);
1526
1576
  try {
1527
- const { data: response } = await put(api.API.customBlocksOrder, { ids });
1577
+ const { data: response } = await put(ConfirmAction.API.customBlocksOrder, { ids });
1528
1578
  data.setBlocks(response.data);
1529
1579
  } catch (error) {
1530
1580
  failed(error, t("settings.blocks.moveError", "The order could not be saved."));
1531
1581
  } finally {
1532
1582
  setBusyId(null);
1533
- requestAnimationFrame(() => useT.refocusIfLost(opener, createRef.current));
1583
+ requestAnimationFrame(() => ConfirmAction.refocusIfLost(opener, createRef.current));
1534
1584
  }
1535
1585
  };
1536
1586
  const onDelete = async (block) => {
1537
1587
  try {
1538
- await del(api.API.customBlock(block.id));
1588
+ await del(ConfirmAction.API.customBlock(block.id));
1539
1589
  toggleNotification({
1540
1590
  type: "success",
1541
1591
  message: t("settings.blocks.deleted", "Block {label} deleted.", { label: block.label })
@@ -1549,7 +1599,7 @@ const CustomBlocksPage = () => {
1549
1599
  const onExport = async () => {
1550
1600
  setExporting(true);
1551
1601
  try {
1552
- const { data: response } = await get(api.API.customBlocksExport);
1602
+ const { data: response } = await get(ConfirmAction.API.customBlocksExport);
1553
1603
  const blob = new Blob([JSON.stringify(response.data, null, 2)], { type: "application/json" });
1554
1604
  const url = URL.createObjectURL(blob);
1555
1605
  const link = document.createElement("a");
@@ -1588,7 +1638,7 @@ const CustomBlocksPage = () => {
1588
1638
  });
1589
1639
  return;
1590
1640
  }
1591
- const { data: response } = await post(api.API.customBlocksImport, parsed);
1641
+ const { data: response } = await post(ConfirmAction.API.customBlocksImport, parsed);
1592
1642
  const { created, skipped } = response.data;
1593
1643
  setImportReport({ created, skipped });
1594
1644
  toggleNotification({
@@ -1600,7 +1650,7 @@ const CustomBlocksPage = () => {
1600
1650
  });
1601
1651
  await data.reload();
1602
1652
  } catch (error) {
1603
- const info = api.readApiError(error);
1653
+ const info = ConfirmAction.readApiError(error);
1604
1654
  toggleNotification({
1605
1655
  type: "danger",
1606
1656
  message: info.status === 400 ? t("settings.blocks.importRejected", "The file is not a Magic Editor X custom block export.") : t("settings.blocks.importError", "The import failed. Nothing was imported.")
@@ -1722,6 +1772,7 @@ const CustomBlocksPage = () => {
1722
1772
  fallbackFocusRef: createRef
1723
1773
  }
1724
1774
  ),
1775
+ /* @__PURE__ */ jsxRuntime.jsx(CodeBlocksSection, {}),
1725
1776
  /* @__PURE__ */ jsxRuntime.jsx(
1726
1777
  BlockFormModal,
1727
1778
  {
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ const ReactNamespace = require("react");
3
+ const admin = require("@strapi/strapi/admin");
4
+ const DraftSync = ({ values }) => {
5
+ const setValues = admin.useForm("MagicEditorXDraftSync", (state) => state.setValues);
6
+ ReactNamespace.useEffect(() => {
7
+ setValues(values);
8
+ }, [values, setValues]);
9
+ return null;
10
+ };
11
+ exports.DraftSync = DraftSync;
@@ -0,0 +1,12 @@
1
+ import { useEffect } from "react";
2
+ import { useForm } from "@strapi/strapi/admin";
3
+ const DraftSync = ({ values }) => {
4
+ const setValues = useForm("MagicEditorXDraftSync", (state) => state.setValues);
5
+ useEffect(() => {
6
+ setValues(values);
7
+ }, [values, setValues]);
8
+ return null;
9
+ };
10
+ export {
11
+ DraftSync as D
12
+ };