magic-editor-x 2.3.1 → 2.5.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 (106) hide show
  1. package/CHANGELOG.md +125 -0
  2. package/README.md +428 -148
  3. package/bin/magic-editor-x.mjs +55 -8
  4. package/dist/admin/AuditPage-Be78C7EC.mjs +382 -0
  5. package/dist/admin/AuditPage-iQzpjH8H.js +382 -0
  6. package/dist/admin/{ConfigurationPage-CYGDLjM7.mjs → ConfigurationPage-C9CPBfWy.mjs} +405 -10
  7. package/dist/admin/{ConfigurationPage-CFP3lp9p.js → ConfigurationPage-DefuBeYO.js} +415 -20
  8. package/dist/admin/ConfirmAction-CUhpngYU.js +71 -0
  9. package/dist/admin/ConfirmAction-CZjpduc3.mjs +72 -0
  10. package/dist/admin/Content-BttG50Mc.mjs +360 -0
  11. package/dist/admin/Content-V5MRBsI3.js +362 -0
  12. package/dist/admin/{CustomBlocksPage-B5Q33N-s.mjs → CustomBlocksPage-DB5nnCsn.mjs} +8 -5
  13. package/dist/admin/{CustomBlocksPage-DzPOSpfn.js → CustomBlocksPage-Dg2rM3F4.js} +26 -23
  14. package/dist/admin/EntryWidgets-B8YA0Zxy.mjs +199 -0
  15. package/dist/admin/EntryWidgets-BcXAAx3F.js +201 -0
  16. package/dist/admin/MentionsWidget-CJPZDk9Z.mjs +225 -0
  17. package/dist/admin/MentionsWidget-DUz6YVIG.js +227 -0
  18. package/dist/admin/{useT-Cmg1jwwG.mjs → SectionCard-8ZNHkvn9.mjs} +2 -12
  19. package/dist/admin/{useT-DNphiBQR.js → SectionCard-Bs-xiiH1.js} +0 -10
  20. package/dist/admin/{TemplatesPage-4A8JNO_Z.mjs → TemplatesPage-VsZ_Mc0R.mjs} +307 -10
  21. package/dist/admin/{TemplatesPage-BVkgafCK.js → TemplatesPage-dx4_yd_t.js} +321 -24
  22. package/dist/admin/{ConfirmAction-zLuIFj8t.js → api-4AYzwS4-.js} +28 -71
  23. package/dist/admin/{ConfirmAction-DuQwvRYi.mjs → api-CcTYyckq.mjs} +28 -71
  24. package/dist/admin/auditText-DIIYVR6k.mjs +110 -0
  25. package/dist/admin/auditText-DUhWu2Nx.js +109 -0
  26. package/dist/admin/comments-C7P41lan.js +86 -0
  27. package/dist/admin/comments-hfIbLQNO.mjs +87 -0
  28. package/dist/admin/{de-B1X46JJZ.js → de-B6rdcOqQ.js} +293 -5
  29. package/dist/admin/{de-1cFMs-4c.mjs → de-BWfR2jTg.mjs} +8 -1
  30. package/dist/admin/{de-BUS1hUw0.mjs → de-Bip0sBRT.mjs} +158 -1
  31. package/dist/admin/{de-Dn8athM8.js → de-BrPR4sUB.js} +8 -1
  32. package/dist/admin/{de-DOiGaTNX.mjs → de-CQA8hOpl.mjs} +293 -5
  33. package/dist/admin/{de-C3AsGauQ.js → de-CnnxKXj7.js} +158 -1
  34. package/dist/admin/{de-2Ie5jy7j.js → de-Dss5POqk.js} +53 -3
  35. package/dist/admin/{de-BMY2LBaa.mjs → de-zgHCYTLH.mjs} +53 -3
  36. package/dist/admin/{en-CIZ5Ggod.js → en--JjAHbpP.js} +8 -1
  37. package/dist/admin/{en-CU6UzV4g.mjs → en-BCKaVgBM.mjs} +293 -5
  38. package/dist/admin/{en-Ah-Cw0Wd.js → en-CJ17Sp_e.js} +53 -3
  39. package/dist/admin/{en-CDg_18Bt.js → en-CbGkcq0Q.js} +293 -5
  40. package/dist/admin/{en-GCzgS9Aw.mjs → en-Cd6Jk-J0.mjs} +158 -1
  41. package/dist/admin/{en-BkEjpC3i.js → en-D69Fe9ZO.js} +158 -1
  42. package/dist/admin/{en-Dc9y-6n9.mjs → en-Dr58wBAo.mjs} +8 -1
  43. package/dist/admin/{en-CvFiqti2.mjs → en-Uhm7OouM.mjs} +53 -3
  44. package/dist/admin/entry-panel-events-0msyPrAD.js +18 -0
  45. package/dist/admin/entry-panel-events-XRuUoLZ9.mjs +19 -0
  46. package/dist/admin/{es-D2Kw6E4N.mjs → es-B2Hkkbw9.mjs} +8 -1
  47. package/dist/admin/{es-DbKHZz5l.mjs → es-BMkmfH88.mjs} +53 -3
  48. package/dist/admin/{es-DHBBZKl2.mjs → es-Bz8d72Fa.mjs} +158 -1
  49. package/dist/admin/{es-BCpJmUEM.js → es-C8UotT8O.js} +293 -5
  50. package/dist/admin/{es-C4pEnDRv.js → es-CcEDZpVQ.js} +158 -1
  51. package/dist/admin/{es-Cr8JH85N.js → es-DJm3HFJt.js} +53 -3
  52. package/dist/admin/{es-C4IRHV5d.js → es-YvaTAtqY.js} +8 -1
  53. package/dist/admin/{es-BmfffNM2.mjs → es-pvPfNAld.mjs} +293 -5
  54. package/dist/admin/{fr-BOvvfEH7.mjs → fr-BvPjRiwr.mjs} +8 -1
  55. package/dist/admin/{fr-Dvq4xk2e.mjs → fr-CKHZ0xxU.mjs} +158 -1
  56. package/dist/admin/{fr-OJ4VW1kh.js → fr-CRM9VuAq.js} +53 -3
  57. package/dist/admin/{fr-DQJ_7aq5.mjs → fr-CrIHmKYX.mjs} +53 -3
  58. package/dist/admin/{fr-C2aLSwEu.js → fr-Cx29jQ_g.js} +158 -1
  59. package/dist/admin/{fr-DZd2XJP6.mjs → fr-D4tL6Ag2.mjs} +293 -5
  60. package/dist/admin/{fr-Zkb8vfjN.js → fr-Di-U-rAH.js} +8 -1
  61. package/dist/admin/{fr-ZcN0yM_2.js → fr-DrUYv2jh.js} +293 -5
  62. package/dist/admin/{index-k8_a5o1A.mjs → index-C4ksUkEm.mjs} +20059 -10130
  63. package/dist/admin/{index-DQVE0ymw.js → index-C5D3VqLq.js} +21272 -11344
  64. package/dist/admin/index-CMYCZWOh.mjs +3752 -0
  65. package/dist/admin/index-DRyctF9s.js +3753 -0
  66. package/dist/admin/index.js +2 -1
  67. package/dist/admin/index.mjs +3 -2
  68. package/dist/admin/math-D6jmskGS.js +49 -0
  69. package/dist/admin/math-DntdSWKX.mjs +47 -0
  70. package/dist/admin/{pt-CilDggGF.mjs → pt-B8x7v-Xw.mjs} +158 -1
  71. package/dist/admin/{pt-DX0OAIoL.js → pt-BYn2xx78.js} +158 -1
  72. package/dist/admin/{pt-CImqDnLB.js → pt-CojQcz-p.js} +293 -5
  73. package/dist/admin/{pt-C3UdeIpd.mjs → pt-CuoIihKx.mjs} +293 -5
  74. package/dist/admin/{pt-1IUyx6ae.js → pt-CzrN_3ui.js} +8 -1
  75. package/dist/admin/{pt-BSLzA17U.mjs → pt-DDlPJYtB.mjs} +53 -3
  76. package/dist/admin/{pt-D0I0_JYs.js → pt-DPVAycXJ.js} +53 -3
  77. package/dist/admin/{pt-etwsg3G4.mjs → pt-DdGagO99.mjs} +8 -1
  78. package/dist/admin/useT-Bpw__IXT.js +12 -0
  79. package/dist/admin/useT-Cb-R3kyA.mjs +13 -0
  80. package/dist/blocks/index.d.mts +126 -0
  81. package/dist/blocks/index.d.ts +126 -0
  82. package/dist/blocks/index.js +184 -4
  83. package/dist/blocks/index.mjs +184 -4
  84. package/dist/math/index.d.mts +27 -0
  85. package/dist/math/index.d.ts +27 -0
  86. package/dist/math/index.js +168 -0
  87. package/dist/math/index.mjs +138 -0
  88. package/dist/react/index.js +1650 -759
  89. package/dist/react/index.mjs +1650 -759
  90. package/dist/render/index.d.mts +48 -0
  91. package/dist/render/index.d.ts +48 -0
  92. package/dist/render/index.js +1755 -773
  93. package/dist/render/index.mjs +1755 -773
  94. package/dist/server/index.js +29475 -18462
  95. package/dist/server/index.mjs +29475 -18462
  96. package/dist/server/mcp-worker.js +11319 -0
  97. package/dist/vue/index.js +1650 -759
  98. package/dist/vue/index.mjs +1650 -759
  99. package/package.json +14 -8
  100. package/schema/magic-editor-x.schema.json +135 -2
  101. package/types/blocks.d.ts +126 -0
  102. package/types/index.d.ts +52 -1
  103. package/types/math.d.ts +27 -0
  104. package/types/render.d.ts +48 -0
  105. package/dist/admin/index-DR8sHkTk.js +0 -1940
  106. package/dist/admin/index-My6FjjHB.mjs +0 -1939
@@ -7,13 +7,16 @@ const designSystem = require("@strapi/design-system");
7
7
  const icons = require("@strapi/icons");
8
8
  const symbols = require("@strapi/icons/symbols");
9
9
  const admin = require("@strapi/strapi/admin");
10
- const index$1 = require("./index-DR8sHkTk.js");
11
- const ConfirmAction = require("./ConfirmAction-zLuIFj8t.js");
12
- const useT = require("./useT-DNphiBQR.js");
10
+ const index$1 = require("./index-DRyctF9s.js");
11
+ const api = require("./api-4AYzwS4-.js");
12
+ const SectionCard = require("./SectionCard-Bs-xiiH1.js");
13
+ const ConfirmAction = require("./ConfirmAction-CUhpngYU.js");
13
14
  require("styled-components");
14
- const index = require("./index-DQVE0ymw.js");
15
+ const useT = require("./useT-Bpw__IXT.js");
16
+ const index = require("./index-C5D3VqLq.js");
15
17
  const useBreakpoint = require("./useBreakpoint-D30eNTkF.js");
16
18
  const DraftSync = require("./DraftSync-BIA8cZgA.js");
19
+ const reactIntl = require("react-intl");
17
20
  const fieldKey = (entry) => `${entry.uid}|${entry.field}`;
18
21
  const fieldFromKey = (key) => {
19
22
  const [uid, field] = String(key).split("|");
@@ -110,7 +113,7 @@ const useTemplateList = () => {
110
113
  };
111
114
  }, []);
112
115
  const fetchTemplates = ReactNamespace.useCallback(
113
- () => get(ConfirmAction.API.templates, { params: { all: "true" } }).then(
116
+ () => get(api.API.templates, { params: { all: "true" } }).then(
114
117
  ({ data }) => {
115
118
  if (!mounted.current) return;
116
119
  setTemplates(Array.isArray(data.data) ? data.data : []);
@@ -127,7 +130,7 @@ const useTemplateList = () => {
127
130
  [get]
128
131
  );
129
132
  const fetchTargets = ReactNamespace.useCallback(
130
- () => get(ConfirmAction.API.templateTargets).then(
133
+ () => get(api.API.templateTargets).then(
131
134
  ({ data }) => {
132
135
  if (mounted.current)
133
136
  setTargets({ status: "ready", items: Array.isArray(data.data) ? data.data : [] });
@@ -163,7 +166,7 @@ const SyncedUsage = ({ template }) => {
163
166
  const [state, setState] = ReactNamespace.useState({ status: "loading", usage: null });
164
167
  ReactNamespace.useEffect(() => {
165
168
  const controller = new AbortController();
166
- get(ConfirmAction.API.templateUsage(template.id), { signal: controller.signal }).then(
169
+ get(api.API.templateUsage(template.id), { signal: controller.signal }).then(
167
170
  ({ data }) => {
168
171
  if (!controller.signal.aborted) setState({ status: "ready", usage: data.data });
169
172
  },
@@ -399,6 +402,293 @@ const TemplateList = ({ templates, busyId, onToggle, ...actions }) => {
399
402
  ] }, template.id)) })
400
403
  ] });
401
404
  };
405
+ const MAX_LABEL_LENGTH = 120;
406
+ const TRIGGERS = {
407
+ manual: { key: "settings.syncedVersions.trigger.manual", text: "Saved" },
408
+ restore: { key: "settings.syncedVersions.trigger.restore", text: "Restored" }
409
+ };
410
+ const SyncedVersions = ({ template, current, dirty, onRestored }) => {
411
+ const t = useT.useT();
412
+ const { formatDate } = reactIntl.useIntl();
413
+ const { get, put, post } = admin.useFetchClient();
414
+ const { toggleNotification } = admin.useNotification();
415
+ const [state, setState] = ReactNamespace.useState({ loading: true, error: false, items: [] });
416
+ const [preview, setPreview] = ReactNamespace.useState(null);
417
+ const [tab, setTab] = ReactNamespace.useState("preview");
418
+ const [renaming, setRenaming] = ReactNamespace.useState(null);
419
+ const [renameBusy, setRenameBusy] = ReactNamespace.useState(false);
420
+ const [confirm, setConfirm] = ReactNamespace.useState(null);
421
+ const [restoring, setRestoring] = ReactNamespace.useState(false);
422
+ const renameButtons = ReactNamespace.useRef(/* @__PURE__ */ new Map());
423
+ const fetchList = ReactNamespace.useCallback(
424
+ () => get(api.API.templateVersions(template.id)).then(
425
+ ({ data }) => setState({ loading: false, error: false, items: data.data || [] }),
426
+ () => setState((value) => ({ ...value, loading: false, error: true }))
427
+ ),
428
+ [get, template.id]
429
+ );
430
+ ReactNamespace.useEffect(() => {
431
+ fetchList();
432
+ }, [fetchList, template.updatedAt]);
433
+ const reload = () => {
434
+ setState((value) => ({ ...value, loading: true, error: false }));
435
+ return fetchList();
436
+ };
437
+ const showPreview = async (item) => {
438
+ if (preview && preview.item.id === item.id) {
439
+ setPreview(null);
440
+ return;
441
+ }
442
+ setTab("preview");
443
+ setPreview({ item, loading: true });
444
+ try {
445
+ const { data } = await get(api.API.templateVersion(template.id, item.id));
446
+ setPreview({
447
+ item,
448
+ loading: false,
449
+ content: data.data.content,
450
+ lines: index.previewLines(data.data.content)
451
+ });
452
+ } catch {
453
+ setPreview({ item, loading: false, error: true });
454
+ }
455
+ };
456
+ const endRename = (id) => {
457
+ setRenaming(null);
458
+ window.requestAnimationFrame(() => {
459
+ const button = renameButtons.current.get(id);
460
+ if (button) button.focus();
461
+ });
462
+ };
463
+ const saveRename = async (event) => {
464
+ if (event) event.preventDefault();
465
+ if (!renaming || renameBusy || renaming.value.trim().length > MAX_LABEL_LENGTH) return;
466
+ setRenameBusy(true);
467
+ try {
468
+ await put(api.API.templateVersion(template.id, renaming.id), { label: renaming.value.trim() || null });
469
+ toggleNotification({
470
+ type: "success",
471
+ message: t("settings.syncedVersions.renamed", "Version name saved.")
472
+ });
473
+ const id = renaming.id;
474
+ await reload();
475
+ endRename(id);
476
+ } catch (error) {
477
+ toggleNotification({
478
+ type: "danger",
479
+ message: api.readApiError(error).message || t("settings.syncedVersions.renameFailed", "The name could not be saved.")
480
+ });
481
+ } finally {
482
+ setRenameBusy(false);
483
+ }
484
+ };
485
+ const restore = async () => {
486
+ const item = confirm;
487
+ setRestoring(true);
488
+ try {
489
+ const { data } = await post(api.API.templateVersionRestore(template.id, item.id), {});
490
+ toggleNotification({
491
+ type: "success",
492
+ message: t(
493
+ "settings.syncedVersions.restored",
494
+ "Version {version} restored. Every field that uses this synced block shows it now.",
495
+ { version: item.version }
496
+ )
497
+ });
498
+ setConfirm(null);
499
+ onRestored(data.data);
500
+ } catch (error) {
501
+ const info = api.readApiError(error);
502
+ toggleNotification({
503
+ type: "danger",
504
+ message: info.status === 400 ? t(
505
+ "settings.syncedVersions.restoreInvalid",
506
+ 'This version cannot be restored with the current settings (for example a field in "Where it is offered" no longer exists).'
507
+ ) : t("settings.syncedVersions.restoreFailed", "This version could not be restored.")
508
+ });
509
+ } finally {
510
+ setRestoring(false);
511
+ }
512
+ };
513
+ return /* @__PURE__ */ jsxRuntime.jsxs(
514
+ SectionCard.SectionCard,
515
+ {
516
+ title: t("settings.syncedVersions.title", "Versions"),
517
+ subtitle: t(
518
+ "settings.syncedVersions.subtitle",
519
+ "Every save of this synced block is kept as a version. Restoring a version saves it again as the newest one."
520
+ ),
521
+ children: [
522
+ state.loading ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { small: true, children: t("settings.syncedVersions.loading", "Loading versions") }) }) : null,
523
+ state.error ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 2, children: [
524
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger600", children: t("settings.syncedVersions.error", "Versions could not be loaded.") }),
525
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "secondary", startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowClockwise, {}), onClick: reload, children: t("settings.retry", "Try again") })
526
+ ] }) : null,
527
+ !state.loading && !state.error && state.items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: t("settings.syncedVersions.empty", "No versions yet. They are created when you save.") }) : null,
528
+ !state.error && state.items.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
529
+ designSystem.Flex,
530
+ {
531
+ tag: "ul",
532
+ direction: "column",
533
+ alignItems: "stretch",
534
+ gap: 2,
535
+ "aria-label": t("settings.syncedVersions.listLabel", "Versions of this synced block"),
536
+ children: state.items.map((item, index$12) => {
537
+ const trigger = TRIGGERS[item.trigger] || TRIGGERS.manual;
538
+ const when = item.createdAt ? formatDate(new Date(item.createdAt), { dateStyle: "medium", timeStyle: "short" }) : "";
539
+ const versionText = t("settings.syncedVersions.version", "Version {version}", {
540
+ version: item.version
541
+ });
542
+ return /* @__PURE__ */ jsxRuntime.jsxs(
543
+ designSystem.Box,
544
+ {
545
+ tag: "li",
546
+ padding: 3,
547
+ hasRadius: true,
548
+ borderColor: "neutral200",
549
+ background: "neutral0",
550
+ children: [
551
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 3, justifyContent: "space-between", wrap: "wrap", children: [
552
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 1, minWidth: 0, flex: "1 1 20rem", children: [
553
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", minWidth: 0, children: [
554
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "bold", style: { overflowWrap: "anywhere" }, children: item.label || versionText }),
555
+ item.label ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: versionText }) : null,
556
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { children: t(trigger.key, trigger.text) }),
557
+ index$12 === 0 ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "success100", textColor: "success700", children: t("settings.syncedVersions.current", "Current") }) : null
558
+ ] }),
559
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", style: { overflowWrap: "anywhere" }, children: item.createdBy ? t("settings.syncedVersions.byline", "{date} by {name}", {
560
+ date: when,
561
+ name: item.createdBy.name
562
+ }) : when }),
563
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", style: { overflowWrap: "anywhere" }, children: t(
564
+ "settings.syncedVersions.details",
565
+ "{name} · {blocks, plural, one {# block} other {# blocks}}",
566
+ { name: item.name, blocks: item.blockCount }
567
+ ) })
568
+ ] }),
569
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", children: [
570
+ /* @__PURE__ */ jsxRuntime.jsx(
571
+ designSystem.IconButton,
572
+ {
573
+ label: t("settings.syncedVersions.preview", "Preview version {version}", {
574
+ version: item.version
575
+ }),
576
+ variant: "tertiary",
577
+ "aria-expanded": Boolean(preview && preview.item.id === item.id),
578
+ onClick: () => showPreview(item),
579
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.Eye, {})
580
+ }
581
+ ),
582
+ /* @__PURE__ */ jsxRuntime.jsx(
583
+ designSystem.IconButton,
584
+ {
585
+ ref: (node) => {
586
+ if (node) renameButtons.current.set(item.id, node);
587
+ else renameButtons.current.delete(item.id);
588
+ },
589
+ label: t("settings.syncedVersions.rename", "Rename version {version}", {
590
+ version: item.version
591
+ }),
592
+ variant: "tertiary",
593
+ onClick: () => setRenaming({ id: item.id, value: item.label || "" }),
594
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.Pencil, {})
595
+ }
596
+ ),
597
+ index$12 > 0 ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "secondary", onClick: () => setConfirm(item), children: t("settings.syncedVersions.restore", "Restore") }) : null
598
+ ] })
599
+ ] }),
600
+ renaming && renaming.id === item.id ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { tag: "form", marginTop: 3, onSubmit: saveRename, noValidate: true, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
601
+ /* @__PURE__ */ jsxRuntime.jsxs(
602
+ designSystem.Field.Root,
603
+ {
604
+ name: `mex-synced-version-label-${item.id}`,
605
+ hint: t("settings.syncedVersions.renameHint", "Leave empty to remove the name."),
606
+ error: renaming.value.trim().length > MAX_LABEL_LENGTH ? t("settings.syncedVersions.labelTooLong", "Use 120 characters or fewer.") : void 0,
607
+ children: [
608
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: t("settings.syncedVersions.renameLabel", "Version name") }),
609
+ /* @__PURE__ */ jsxRuntime.jsx(
610
+ designSystem.TextInput,
611
+ {
612
+ autoFocus: true,
613
+ value: renaming.value,
614
+ onChange: (event) => setRenaming({ ...renaming, value: event.target.value }),
615
+ onKeyDown: (event) => {
616
+ if (event.key === "Escape") {
617
+ event.preventDefault();
618
+ event.stopPropagation();
619
+ endRename(item.id);
620
+ }
621
+ }
622
+ }
623
+ ),
624
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {}),
625
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
626
+ ]
627
+ }
628
+ ),
629
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", children: [
630
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { type: "submit", size: "S", loading: renameBusy, children: t("settings.syncedVersions.renameSave", "Save name") }),
631
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { type: "button", size: "S", variant: "tertiary", onClick: () => endRename(item.id), children: t("settings.syncedVersions.renameCancel", "Cancel") })
632
+ ] })
633
+ ] }) }) : null,
634
+ preview && preview.item.id === item.id ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { marginTop: 3, padding: 3, background: "neutral100", hasRadius: true, minWidth: 0, children: [
635
+ preview.loading ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { small: true, children: t("settings.syncedVersions.previewLoading", "Loading preview") }) : null,
636
+ preview.error ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger600", children: t("settings.syncedVersions.previewError", "The preview could not be loaded.") }) : null,
637
+ preview.content ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tabs.Root, { value: tab, onValueChange: setTab, children: [
638
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tabs.List, { "aria-label": t("settings.syncedVersions.tabs", "Version views"), children: [
639
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Trigger, { value: "preview", children: t("settings.syncedVersions.tab.preview", "Preview") }),
640
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Trigger, { value: "changes", children: t("settings.syncedVersions.tab.changes", "Changes") })
641
+ ] }),
642
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Content, { value: "preview", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 3, children: preview.lines.map((line, lineIndex) => /* @__PURE__ */ jsxRuntime.jsx(
643
+ designSystem.Typography,
644
+ {
645
+ tag: "p",
646
+ variant: "pi",
647
+ textColor: "neutral800",
648
+ style: { overflowWrap: "anywhere" },
649
+ children: line
650
+ },
651
+ lineIndex
652
+ )) }) }),
653
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Content, { value: "changes", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 3, children: tab === "changes" ? /* @__PURE__ */ jsxRuntime.jsx(
654
+ index.VersionDiff,
655
+ {
656
+ t,
657
+ version: preview.content,
658
+ current: current || { blocks: [] },
659
+ versionNumber: item.version,
660
+ canRestore: false
661
+ }
662
+ ) : null }) })
663
+ ] }) : null
664
+ ] }) : null
665
+ ]
666
+ },
667
+ item.id
668
+ );
669
+ })
670
+ }
671
+ ) : null,
672
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: Boolean(confirm), onOpenChange: (open) => !open && !restoring && setConfirm(null), children: confirm ? /* @__PURE__ */ jsxRuntime.jsx(
673
+ admin.ConfirmDialog,
674
+ {
675
+ title: t("settings.syncedVersions.confirmTitle", "Restore version {version}?", {
676
+ version: confirm.version
677
+ }),
678
+ endAction: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "danger-light", loading: restoring, onClick: restore, children: t("settings.syncedVersions.restore", "Restore") }),
679
+ children: dirty ? t(
680
+ "settings.syncedVersions.confirmBodyDirty",
681
+ "The synced block is saved with the content of this version, and every field that uses it shows it at once. Your unsaved changes in this form are lost."
682
+ ) : t(
683
+ "settings.syncedVersions.confirmBody",
684
+ "The synced block is saved with the content of this version, and every field that uses it shows it at once."
685
+ )
686
+ }
687
+ ) : null })
688
+ ]
689
+ }
690
+ );
691
+ };
402
692
  const EDITOR_TARGET = Object.freeze({
403
693
  uid: null,
404
694
  documentId: null,
@@ -430,7 +720,7 @@ const errorText = (t, code) => {
430
720
  });
431
721
  return code;
432
722
  };
433
- const TemplateEditor = ({ template, targets, onRetryTargets, onSubmit, onBack }) => {
723
+ const TemplateEditor = ({ template, targets, onRetryTargets, onSubmit, onBack, onRestored }) => {
434
724
  const t = useT.useT();
435
725
  const saved = ReactNamespace.useMemo(() => template ? fromDto(template) : emptyValues(), [template]);
436
726
  const [values, setValues] = ReactNamespace.useState(saved);
@@ -488,7 +778,7 @@ const TemplateEditor = ({ template, targets, onRetryTargets, onSubmit, onBack })
488
778
  if (!fieldOptions.some((option) => option.key === key)) fieldOptions.push({ key, label: key });
489
779
  }
490
780
  return /* @__PURE__ */ jsxRuntime.jsxs(
491
- useT.PageShell,
781
+ SectionCard.PageShell,
492
782
  {
493
783
  title,
494
784
  subtitle: t(
@@ -524,7 +814,7 @@ const TemplateEditor = ({ template, targets, onRetryTargets, onSubmit, onBack })
524
814
  children: [
525
815
  showErrors && Object.keys(errors).length ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "danger600", role: "status", children: t("settings.templates.form.invalid", "Some values need attention. They are marked below.") }) : null,
526
816
  visible._form ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Alert, { variant: "danger", closeLabel: t("settings.close", "Close"), onClose: () => setServerErrors({}), children: visible._form }) : null,
527
- /* @__PURE__ */ jsxRuntime.jsx(useT.SectionCard, { title: t("settings.templates.form.details", "Details"), children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { gap: { initial: 4, medium: 6 }, children: [
817
+ /* @__PURE__ */ jsxRuntime.jsx(SectionCard.SectionCard, { title: t("settings.templates.form.details", "Details"), children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { gap: { initial: 4, medium: 6 }, children: [
528
818
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 6, xs: 12, s: 12, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxRuntime.jsxs(
529
819
  designSystem.Field.Root,
530
820
  {
@@ -631,7 +921,7 @@ const TemplateEditor = ({ template, targets, onRetryTargets, onSubmit, onBack })
631
921
  ] }) })
632
922
  ] }) }),
633
923
  /* @__PURE__ */ jsxRuntime.jsxs(
634
- useT.SectionCard,
924
+ SectionCard.SectionCard,
635
925
  {
636
926
  title: t("settings.templates.form.scope", "Where it is offered"),
637
927
  subtitle: t(
@@ -692,7 +982,7 @@ const TemplateEditor = ({ template, targets, onRetryTargets, onSubmit, onBack })
692
982
  }
693
983
  ),
694
984
  /* @__PURE__ */ jsxRuntime.jsx(
695
- useT.SectionCard,
985
+ SectionCard.SectionCard,
696
986
  {
697
987
  title: t("settings.templates.form.content", "Content"),
698
988
  subtitle: t(
@@ -714,6 +1004,7 @@ const TemplateEditor = ({ template, targets, onRetryTargets, onSubmit, onBack })
714
1004
  )
715
1005
  }
716
1006
  ),
1007
+ savedSynced && onRestored ? /* @__PURE__ */ jsxRuntime.jsx(SyncedVersions, { template, current: values.blocks, dirty, onRestored }) : null,
717
1008
  /* @__PURE__ */ jsxRuntime.jsxs(admin.Form, { method: "PUT", initialValues: savedKey, children: [
718
1009
  /* @__PURE__ */ jsxRuntime.jsx(DraftSync.DraftSync, { values: draftKey }),
719
1010
  /* @__PURE__ */ jsxRuntime.jsx(admin.Blocker, {})
@@ -774,7 +1065,7 @@ const TemplatesPage = () => {
774
1065
  ] });
775
1066
  }
776
1067
  const failed = (error, fallback) => {
777
- const info = ConfirmAction.readApiError(error);
1068
+ const info = api.readApiError(error);
778
1069
  toggleNotification({
779
1070
  type: "danger",
780
1071
  message: info.status === 404 ? t("settings.templates.notFound", "This template no longer exists.") : fallback
@@ -787,8 +1078,8 @@ const TemplatesPage = () => {
787
1078
  const onSubmit = async (values) => {
788
1079
  const payload = toPayload(values);
789
1080
  try {
790
- if (editing.template) await put(ConfirmAction.API.template(editing.template.id), payload);
791
- else await post(ConfirmAction.API.templates, payload);
1081
+ if (editing.template) await put(api.API.template(editing.template.id), payload);
1082
+ else await post(api.API.templates, payload);
792
1083
  toggleNotification({
793
1084
  type: "success",
794
1085
  message: editing.template ? t("settings.templates.saved", "Template {name} saved.", { name: payload.name }) : t("settings.templates.created", "Template {name} created.", { name: payload.name })
@@ -798,7 +1089,7 @@ const TemplatesPage = () => {
798
1089
  backToList();
799
1090
  return { ok: true };
800
1091
  } catch (error) {
801
- const info = ConfirmAction.readApiError(error);
1092
+ const info = api.readApiError(error);
802
1093
  if (info.status === 400) {
803
1094
  toggleNotification({
804
1095
  type: "warning",
@@ -819,6 +1110,11 @@ const TemplatesPage = () => {
819
1110
  return { ok: false };
820
1111
  }
821
1112
  };
1113
+ const onRestored = async (template) => {
1114
+ index.resetEditorConfigCache();
1115
+ await data.reload();
1116
+ setEditing({ template, key: `${template.id}:${template.updatedAt || Date.now()}` });
1117
+ };
822
1118
  if (editing) {
823
1119
  return /* @__PURE__ */ jsxRuntime.jsx(
824
1120
  TemplateEditor,
@@ -827,7 +1123,8 @@ const TemplatesPage = () => {
827
1123
  targets: data.targets,
828
1124
  onRetryTargets: data.reloadTargets,
829
1125
  onSubmit,
830
- onBack: backToList
1126
+ onBack: backToList,
1127
+ onRestored
831
1128
  },
832
1129
  editing.key
833
1130
  );
@@ -835,7 +1132,7 @@ const TemplatesPage = () => {
835
1132
  const onToggle = async (template, enabled) => {
836
1133
  setBusyId(template.id);
837
1134
  try {
838
- const { data: response } = await put(ConfirmAction.API.template(template.id), withEnabled(template, enabled));
1135
+ const { data: response } = await put(api.API.template(template.id), withEnabled(template, enabled));
839
1136
  data.setTemplates((current) => current.map((item) => item.id === template.id ? response.data : item));
840
1137
  toggleNotification({
841
1138
  type: "success",
@@ -852,7 +1149,7 @@ const TemplatesPage = () => {
852
1149
  const onDuplicate = async (template) => {
853
1150
  setBusyId(template.id);
854
1151
  try {
855
- const { data: response } = await post(ConfirmAction.API.templateDuplicate(template.id), {});
1152
+ const { data: response } = await post(api.API.templateDuplicate(template.id), {});
856
1153
  toggleNotification({
857
1154
  type: "success",
858
1155
  message: t("settings.templates.duplicated", "Copy {name} created. It is off until you turn it on.", {
@@ -878,7 +1175,7 @@ const TemplatesPage = () => {
878
1175
  const opener = typeof document !== "undefined" ? document.activeElement : null;
879
1176
  setBusyId(template.id);
880
1177
  try {
881
- const { data: response } = await put(ConfirmAction.API.templatesOrder, { ids });
1178
+ const { data: response } = await put(api.API.templatesOrder, { ids });
882
1179
  data.setTemplates(response.data);
883
1180
  } catch (error) {
884
1181
  failed(error, t("settings.templates.moveError", "The order could not be saved."));
@@ -889,7 +1186,7 @@ const TemplatesPage = () => {
889
1186
  };
890
1187
  const onDelete = async (template) => {
891
1188
  try {
892
- await del(ConfirmAction.API.template(template.id));
1189
+ await del(api.API.template(template.id));
893
1190
  toggleNotification({
894
1191
  type: "success",
895
1192
  message: t("settings.templates.deleted", "Template {name} deleted.", { name: template.name })
@@ -902,7 +1199,7 @@ const TemplatesPage = () => {
902
1199
  };
903
1200
  const openCreate = () => setEditing({ template: null, key: Date.now() });
904
1201
  return /* @__PURE__ */ jsxRuntime.jsxs(
905
- useT.PageShell,
1202
+ SectionCard.PageShell,
906
1203
  {
907
1204
  title,
908
1205
  subtitle: t(
@@ -923,7 +1220,7 @@ const TemplatesPage = () => {
923
1220
  )
924
1221
  }
925
1222
  ) : null,
926
- data.templates.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(useT.SectionCard, { children: /* @__PURE__ */ jsxRuntime.jsx(
1223
+ data.templates.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(SectionCard.SectionCard, { children: /* @__PURE__ */ jsxRuntime.jsx(
927
1224
  designSystem.EmptyStateLayout,
928
1225
  {
929
1226
  icon: /* @__PURE__ */ jsxRuntime.jsx(symbols.EmptyDocuments, { width: "16rem", height: "8.8rem" }),
@@ -978,7 +1275,7 @@ const TemplatesPage = () => {
978
1275
  setPreview(null);
979
1276
  requestAnimationFrame(() => ConfirmAction.refocusIfLost(previewOpenerRef.current, createRef.current));
980
1277
  },
981
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Content, { children: [
1278
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Content, { "aria-describedby": void 0, children: [
982
1279
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { closeLabel: t("settings.close", "Close"), children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: t("settings.templates.preview.title", "Preview of {name}", { name: preview.name }) }) }),
983
1280
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { "data-testid": "mex-settings-template-preview", children: /* @__PURE__ */ jsxRuntime.jsx(index.RenderedContent, { value: preview.blocks, t }) }) }),
984
1281
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Close, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: t("settings.close", "Close") }) }) })
@@ -1,14 +1,11 @@
1
1
  "use strict";
2
- const jsxRuntime = require("react/jsx-runtime");
3
- const ReactNamespace = require("react");
4
- const designSystem = require("@strapi/design-system");
5
- const admin = require("@strapi/strapi/admin");
6
2
  const API = {
7
3
  config: "/magic-editor-x/config",
8
4
  link: "/magic-editor-x/link",
9
5
  imageByFile: "/magic-editor-x/image/byFile",
10
6
  imageByUrl: "/magic-editor-x/image/byUrl",
11
7
  fileUpload: "/magic-editor-x/file/upload",
8
+ mediaByUrl: "/magic-editor-x/media/byUrl",
12
9
  contentTypes: "/magic-editor-x/content-types",
13
10
  linkTypes: "/magic-editor-x/links/types",
14
11
  linkSearch: "/magic-editor-x/links/search",
@@ -26,21 +23,47 @@ const API = {
26
23
  ai: (action) => `/magic-editor-x/ai/${encodeURIComponent(action)}`,
27
24
  aiAltText: "/magic-editor-x/ai/image/alt-text",
28
25
  aiField: (action) => `/magic-editor-x/ai/field/${encodeURIComponent(action)}`,
26
+ aiBlocks: (action) => `/magic-editor-x/ai/blocks/${encodeURIComponent(action)}`,
29
27
  grammarCheck: "/magic-editor-x/grammar/check",
30
28
  comments: "/magic-editor-x/comments",
31
29
  comment: (id) => `/magic-editor-x/comments/${encodeURIComponent(id)}`,
32
30
  commentReplies: (id) => `/magic-editor-x/comments/${encodeURIComponent(id)}/replies`,
33
31
  commentResolve: (id) => `/magic-editor-x/comments/${encodeURIComponent(id)}/resolve`,
34
32
  commentReopen: (id) => `/magic-editor-x/comments/${encodeURIComponent(id)}/reopen`,
33
+ // 2.4: @mentions and notifications.
34
+ commentMentionable: "/magic-editor-x/comments/mentionable",
35
+ notifications: "/magic-editor-x/notifications",
36
+ notificationsReadAll: "/magic-editor-x/notifications/read-all",
37
+ notificationRead: (id) => `/magic-editor-x/notifications/${encodeURIComponent(id)}/read`,
38
+ notificationUnread: (id) => `/magic-editor-x/notifications/${encodeURIComponent(id)}/unread`,
39
+ suggestions: "/magic-editor-x/suggestions",
40
+ suggestion: (id) => `/magic-editor-x/suggestions/${encodeURIComponent(id)}`,
41
+ suggestionAccept: (id) => `/magic-editor-x/suggestions/${encodeURIComponent(id)}/accept`,
42
+ suggestionReject: (id) => `/magic-editor-x/suggestions/${encodeURIComponent(id)}/reject`,
35
43
  templates: "/magic-editor-x/templates",
36
44
  templateTargets: "/magic-editor-x/templates/targets",
37
45
  templatesOrder: "/magic-editor-x/templates/order",
38
46
  template: (id) => `/magic-editor-x/templates/${encodeURIComponent(id)}`,
39
47
  templateDuplicate: (id) => `/magic-editor-x/templates/${encodeURIComponent(id)}/duplicate`,
40
48
  templateUsage: (id) => `/magic-editor-x/templates/${encodeURIComponent(id)}/usage`,
49
+ templateVersions: (id) => `/magic-editor-x/templates/${encodeURIComponent(id)}/versions`,
50
+ templateVersion: (id, versionId) => `/magic-editor-x/templates/${encodeURIComponent(id)}/versions/${encodeURIComponent(versionId)}`,
51
+ templateVersionRestore: (id, versionId) => `/magic-editor-x/templates/${encodeURIComponent(id)}/versions/${encodeURIComponent(versionId)}/restore`,
52
+ audit: "/magic-editor-x/audit",
53
+ auditActors: "/magic-editor-x/audit/actors",
54
+ linkSchedule: "/magic-editor-x/quality/link-schedule",
55
+ linkScheduleRun: "/magic-editor-x/quality/link-schedule/run",
41
56
  settings: "/magic-editor-x/settings",
42
57
  settingsAiTest: "/magic-editor-x/settings/ai/test",
43
- settingsLanguageToolTest: "/magic-editor-x/settings/language-tool/test"
58
+ settingsLanguageToolTest: "/magic-editor-x/settings/language-tool/test",
59
+ // 2.5: entry side panel and homepage widgets.
60
+ presence: "/magic-editor-x/presence",
61
+ entrySummary: "/magic-editor-x/entry-summary",
62
+ widgetOpenThreads: "/magic-editor-x/widgets/open-threads",
63
+ widgetBrokenLinks: "/magic-editor-x/widgets/broken-links",
64
+ // 2.5 "Use existing content".
65
+ reuseTypes: "/magic-editor-x/reuse/types",
66
+ reuseSource: "/magic-editor-x/reuse/source"
44
67
  };
45
68
  const readApiError = (error) => {
46
69
  const response = error && error.response;
@@ -54,71 +77,5 @@ const readApiError = (error) => {
54
77
  details: apiError && apiError.details || null
55
78
  };
56
79
  };
57
- const canTakeFocus = (el) => Boolean(
58
- el && el.isConnected && typeof el.focus === "function" && !el.disabled && (typeof el.getAttribute !== "function" || el.getAttribute("aria-disabled") !== "true")
59
- );
60
- const pickFocusTarget = (opener, fallback) => {
61
- if (canTakeFocus(opener)) return opener;
62
- if (canTakeFocus(fallback)) return fallback;
63
- return null;
64
- };
65
- const refocusIfLost = (opener, fallback, doc = globalThis.document) => {
66
- if (!doc) return;
67
- const active = doc.activeElement;
68
- if (active && active !== doc.body) return;
69
- const target = pickFocusTarget(opener, fallback);
70
- if (target) target.focus();
71
- };
72
- const ConfirmAction = ({
73
- trigger,
74
- title,
75
- body,
76
- confirmLabel,
77
- onConfirm,
78
- variant = "danger",
79
- disabled = false,
80
- fallbackFocusRef
81
- }) => {
82
- const [open, setOpen] = ReactNamespace.useState(false);
83
- const [busy, setBusy] = ReactNamespace.useState(false);
84
- const triggerRef = ReactNamespace.useRef(null);
85
- const restoreFocus = () => requestAnimationFrame(() => {
86
- const active = document.activeElement;
87
- if (active && active !== document.body) return;
88
- const target = pickFocusTarget(triggerRef.current, fallbackFocusRef && fallbackFocusRef.current);
89
- if (target) target.focus();
90
- });
91
- const onOpenChange = (next) => {
92
- if (busy) return;
93
- setOpen(next);
94
- if (!next) restoreFocus();
95
- };
96
- const confirm = async (event) => {
97
- if (event && typeof event.preventDefault === "function") event.preventDefault();
98
- setBusy(true);
99
- try {
100
- await onConfirm();
101
- setOpen(false);
102
- restoreFocus();
103
- } catch {
104
- } finally {
105
- setBusy(false);
106
- }
107
- };
108
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Root, { open, onOpenChange, children: [
109
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Trigger, { ref: triggerRef, disabled, children: trigger }),
110
- /* @__PURE__ */ jsxRuntime.jsx(
111
- admin.ConfirmDialog,
112
- {
113
- title,
114
- variant,
115
- endAction: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { fullWidth: true, variant, onClick: confirm, loading: busy, disabled: busy, children: confirmLabel }),
116
- children: body
117
- }
118
- )
119
- ] });
120
- };
121
80
  exports.API = API;
122
- exports.ConfirmAction = ConfirmAction;
123
81
  exports.readApiError = readApiError;
124
- exports.refocusIfLost = refocusIfLost;