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
@@ -0,0 +1,362 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const ReactNamespace = require("react");
5
+ const designSystem = require("@strapi/design-system");
6
+ const styled = require("styled-components");
7
+ const admin = require("@strapi/strapi/admin");
8
+ const api = require("./api-4AYzwS4-.js");
9
+ const useT = require("./useT-Bpw__IXT.js");
10
+ const index = require("./index-DRyctF9s.js");
11
+ const reactIntl = require("react-intl");
12
+ const entryPanelEvents = require("./entry-panel-events-0msyPrAD.js");
13
+ const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
14
+ const styled__default = /* @__PURE__ */ _interopDefault(styled);
15
+ const useEntryPresence = ({ uid, documentId, locale }) => {
16
+ const { post } = admin.useFetchClient();
17
+ const [state, setState] = ReactNamespace.useState({
18
+ status: "loading",
19
+ enabled: false,
20
+ softLock: false,
21
+ canEdit: false,
22
+ editors: []
23
+ });
24
+ const [tabId] = ReactNamespace.useState(index.createTabId);
25
+ const postRef = ReactNamespace.useRef(post);
26
+ ReactNamespace.useEffect(() => {
27
+ postRef.current = post;
28
+ }, [post]);
29
+ ReactNamespace.useEffect(() => {
30
+ if (!uid || !documentId) return void 0;
31
+ let active = true;
32
+ let timer = null;
33
+ let failures = 0;
34
+ let lastInput = Date.now();
35
+ const body = (extra = {}) => ({
36
+ uid,
37
+ documentId,
38
+ ...locale ? { locale } : {},
39
+ tabId,
40
+ ...extra
41
+ });
42
+ const isIdle = () => document.visibilityState === "hidden" || Date.now() - lastInput > index.IDLE_AFTER_MS;
43
+ const beat = async () => {
44
+ window.clearTimeout(timer);
45
+ let delay;
46
+ try {
47
+ const { data } = await postRef.current(api.API.presence, body({ idle: isIdle() }));
48
+ if (!active) return;
49
+ failures = 0;
50
+ const value = data && data.data || {};
51
+ setState({
52
+ status: "ready",
53
+ enabled: value.enabled === true,
54
+ softLock: value.softLock === true,
55
+ canEdit: value.canEdit === true,
56
+ editors: Array.isArray(value.editors) ? value.editors : []
57
+ });
58
+ if (value.enabled !== true) return;
59
+ delay = index.nextDelay(0);
60
+ } catch (error) {
61
+ if (!active) return;
62
+ const { status } = api.readApiError(error);
63
+ if (status === 404 || status === 403) {
64
+ setState((current) => ({ ...current, status: "unavailable", editors: [] }));
65
+ return;
66
+ }
67
+ failures += 1;
68
+ setState((current) => ({ ...current, status: current.status === "ready" ? "ready" : "error" }));
69
+ delay = index.nextDelay(failures, status);
70
+ }
71
+ timer = window.setTimeout(beat, delay);
72
+ };
73
+ const onInput = () => {
74
+ const wasIdle = Date.now() - lastInput > index.IDLE_AFTER_MS;
75
+ lastInput = Date.now();
76
+ if (wasIdle && failures === 0) beat();
77
+ };
78
+ const onVisibility = () => {
79
+ if (document.visibilityState === "visible") lastInput = Date.now();
80
+ if (failures === 0) beat();
81
+ };
82
+ window.addEventListener("keydown", onInput, true);
83
+ window.addEventListener("pointerdown", onInput, true);
84
+ document.addEventListener("visibilitychange", onVisibility);
85
+ beat();
86
+ return () => {
87
+ active = false;
88
+ window.clearTimeout(timer);
89
+ window.removeEventListener("keydown", onInput, true);
90
+ window.removeEventListener("pointerdown", onInput, true);
91
+ document.removeEventListener("visibilitychange", onVisibility);
92
+ if (!index.isLoggedOut())
93
+ admin.getFetchClient().post(api.API.presence, body({ leave: true })).catch(() => {
94
+ });
95
+ };
96
+ }, [uid, documentId, locale, tabId]);
97
+ return state;
98
+ };
99
+ const List = styled__default.default.ul`
100
+ list-style: none;
101
+ margin: 0;
102
+ padding: 0;
103
+ display: flex;
104
+ flex-direction: column;
105
+ gap: ${({ theme }) => theme.spaces[2]};
106
+ min-width: 0;
107
+ `;
108
+ const Row = styled__default.default.li`
109
+ display: flex;
110
+ align-items: center;
111
+ justify-content: space-between;
112
+ gap: ${({ theme }) => theme.spaces[2]};
113
+ min-width: 0;
114
+ `;
115
+ const Dot = styled__default.default.span`
116
+ flex: 0 0 auto;
117
+ width: 0.8rem;
118
+ height: 0.8rem;
119
+ border-radius: 50%;
120
+ background: ${({ theme, $color, $idle }) => $idle ? theme.colors.neutral300 : theme.colors[`${$color}600`] || theme.colors.primary600};
121
+ `;
122
+ const Wrap = styled__default.default(designSystem.Typography)`
123
+ display: block;
124
+ min-width: 0;
125
+ overflow-wrap: anywhere;
126
+ `;
127
+ const EntryPanelSection = ({ title, children, testId }) => {
128
+ const id = ReactNamespace.useId();
129
+ return /* @__PURE__ */ jsxRuntime.jsxs(
130
+ designSystem.Flex,
131
+ {
132
+ tag: "section",
133
+ "aria-labelledby": id,
134
+ direction: "column",
135
+ alignItems: "stretch",
136
+ gap: 2,
137
+ width: "100%",
138
+ "data-testid": testId,
139
+ "data-mex-panel-section": "",
140
+ children: [
141
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { id, tag: "h3", variant: "omega", fontWeight: "bold", textColor: "neutral800", children: title }),
142
+ children
143
+ ]
144
+ }
145
+ );
146
+ };
147
+ const PresenceSection = ({ t, presence }) => {
148
+ if (presence.status === "unavailable" || presence.status === "ready" && !presence.enabled) return null;
149
+ return /* @__PURE__ */ jsxRuntime.jsx(EntryPanelSection, { title: t("entryPanel.presence.title", "Editing now"), testId: "mex-panel-presence", children: /* @__PURE__ */ jsxRuntime.jsx("div", { "aria-live": "polite", children: presence.status === "loading" ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t("entryPanel.loading", "Loading") }) : presence.editors.length ? /* @__PURE__ */ jsxRuntime.jsx(List, { children: presence.editors.map((editor) => /* @__PURE__ */ jsxRuntime.jsx(Row, { "data-testid": "mex-panel-editor", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", minWidth: 0, children: [
150
+ /* @__PURE__ */ jsxRuntime.jsx(Dot, { $color: editor.color, $idle: editor.idle, "aria-hidden": "true" }),
151
+ /* @__PURE__ */ jsxRuntime.jsx(Wrap, { variant: "omega", textColor: "neutral800", children: editor.idle ? t("entryPanel.presence.idle", "{name} has this entry open (idle)", {
152
+ name: editor.name
153
+ }) : t("entryPanel.presence.editing", "{name} is editing this entry", {
154
+ name: editor.name
155
+ }) })
156
+ ] }) }, editor.id)) }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t("entryPanel.presence.empty", "Nobody else is editing this entry right now.") }) }) });
157
+ };
158
+ const FieldRow = ({ t, field, text, action, actionLabel, panel }) => {
159
+ const [hint, setHint] = ReactNamespace.useState(false);
160
+ const group = field.label.includes(" › ") ? field.label.slice(0, field.label.lastIndexOf(" › ")) : field.label;
161
+ return /* @__PURE__ */ jsxRuntime.jsxs(Row, { children: [
162
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { minWidth: 0, children: [
163
+ /* @__PURE__ */ jsxRuntime.jsx(Wrap, { variant: "pi", fontWeight: "bold", textColor: "neutral800", children: field.label }),
164
+ /* @__PURE__ */ jsxRuntime.jsx(Wrap, { variant: "pi", textColor: "neutral600", children: text }),
165
+ /* @__PURE__ */ jsxRuntime.jsx("div", { "aria-live": "polite", children: hint ? /* @__PURE__ */ jsxRuntime.jsx(Wrap, { variant: "pi", textColor: "neutral700", "data-testid": "mex-panel-hint", children: t("entryPanel.openGroup", "Open “{group}” in the form first, then choose {action} again.", {
166
+ group,
167
+ action
168
+ }) }) : null })
169
+ ] }),
170
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { flex: "0 0 auto", children: /* @__PURE__ */ jsxRuntime.jsx(
171
+ designSystem.TextButton,
172
+ {
173
+ "aria-label": actionLabel,
174
+ onClick: () => setHint(!entryPanelEvents.requestFieldPanel({ field: field.field, path: field.path, panel })),
175
+ children: action
176
+ }
177
+ ) })
178
+ ] });
179
+ };
180
+ const CommentsSection = ({ t, summary }) => {
181
+ if (!summary.data || !summary.data.comments.enabled) return null;
182
+ const fields = index.fieldsWith(summary.data.fields, (field) => field.openThreads || 0);
183
+ return /* @__PURE__ */ jsxRuntime.jsx(EntryPanelSection, { title: t("entryPanel.comments.title", "Comments"), testId: "mex-panel-comments", children: fields.length ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
184
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t("entryPanel.comments.count", "{count, plural, one {# open thread} other {# open threads}}", {
185
+ count: summary.data.comments.open
186
+ }) }),
187
+ /* @__PURE__ */ jsxRuntime.jsx(List, { children: fields.map((field) => /* @__PURE__ */ jsxRuntime.jsx(
188
+ FieldRow,
189
+ {
190
+ t,
191
+ field,
192
+ panel: "comments",
193
+ text: t("entryPanel.comments.field", "{count, plural, one {# open} other {# open}}", {
194
+ count: field.openThreads
195
+ }),
196
+ action: t("entryPanel.comments.show", "Show"),
197
+ actionLabel: t("entryPanel.comments.showLabel", "Show comments in {field}", {
198
+ field: field.label
199
+ })
200
+ },
201
+ field.path
202
+ )) })
203
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t(
204
+ "entryPanel.comments.empty",
205
+ "No open comments. To start one, select text in a field and choose Comment."
206
+ ) }) });
207
+ };
208
+ const QualitySection = ({ t, summary }) => {
209
+ const { formatDate } = reactIntl.useIntl();
210
+ if (!summary.data) return null;
211
+ const { quality, links } = summary.data;
212
+ const fields = index.fieldsWith(summary.data.fields, index.fieldProblems);
213
+ return /* @__PURE__ */ jsxRuntime.jsxs(EntryPanelSection, { title: t("entryPanel.quality.title", "Quality"), testId: "mex-panel-quality", children: [
214
+ fields.length ? /* @__PURE__ */ jsxRuntime.jsx(List, { children: fields.map((field) => {
215
+ const issues = field.issues.errors + field.issues.warnings;
216
+ const broken = field.brokenLinks && field.brokenLinks.draft || 0;
217
+ return /* @__PURE__ */ jsxRuntime.jsx(
218
+ FieldRow,
219
+ {
220
+ t,
221
+ field,
222
+ panel: "quality",
223
+ text: [
224
+ issues ? t("entryPanel.quality.issues", "{count, plural, one {# issue} other {# issues}}", {
225
+ count: issues
226
+ }) : null,
227
+ broken ? t(
228
+ "entryPanel.quality.broken",
229
+ "{count, plural, one {# broken link} other {# broken links}}",
230
+ {
231
+ count: broken
232
+ }
233
+ ) : null
234
+ ].filter(Boolean).join(" · "),
235
+ action: t("entryPanel.quality.check", "Check"),
236
+ actionLabel: t("entryPanel.quality.checkLabel", "Check {field}", { field: field.label })
237
+ },
238
+ field.path
239
+ );
240
+ }) }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t("entryPanel.quality.empty", "No problems found in the saved draft.") }),
241
+ quality.errors + quality.warnings || links.enabled && links.draft ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t("entryPanel.quality.savedDraft", "Counts are for the saved draft. Save to update them.") }) : null,
242
+ links.enabled && links.published ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t(
243
+ "entryPanel.quality.published",
244
+ "{count, plural, one {The published version has # broken link.} other {The published version has # broken links.}}",
245
+ { count: links.published }
246
+ ) }) : null,
247
+ links.enabled ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: links.lastRun && links.lastRun.finishedAt ? t("entryPanel.quality.lastRun", "Links last checked {date}", {
248
+ date: formatDate(links.lastRun.finishedAt, { dateStyle: "medium", timeStyle: "short" })
249
+ }) : t("entryPanel.quality.noRun", "The scheduled link check has not run yet.") }) : null
250
+ ] });
251
+ };
252
+ const SummaryStatus = ({ t, summary }) => {
253
+ if (summary.status === "loading" && !summary.data)
254
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t("entryPanel.loading", "Loading") });
255
+ if (summary.status === "error" && !summary.data)
256
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 2, children: [
257
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t("entryPanel.error", "Comments and quality could not be loaded.") }),
258
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { size: "S", variant: "tertiary", onClick: summary.reload, children: t("entryPanel.retry", "Try again") })
259
+ ] });
260
+ return null;
261
+ };
262
+ const ENTRY_PANEL_SECTIONS = [
263
+ { id: "presence", Component: PresenceSection },
264
+ { id: "summary-status", Component: SummaryStatus },
265
+ { id: "comments", Component: CommentsSection },
266
+ { id: "quality", Component: QualitySection }
267
+ ];
268
+ const FOCUS_REFRESH_MS = 1e4;
269
+ const Sections = styled__default.default(designSystem.Flex)`
270
+ & > [data-mex-panel-section] ~ [data-mex-panel-section] {
271
+ border-top: 1px solid ${({ theme }) => theme.colors.neutral150};
272
+ padding-top: ${({ theme }) => theme.spaces[3]};
273
+ }
274
+ `;
275
+ const useEntrySummary = ({ uid, documentId, locale }, version) => {
276
+ const { get } = admin.useFetchClient();
277
+ const [state, setState] = ReactNamespace.useState({ status: "loading", data: null });
278
+ const requestRef = ReactNamespace.useRef(0);
279
+ const lastRef = ReactNamespace.useRef(0);
280
+ const load = ReactNamespace.useCallback(() => {
281
+ const id = requestRef.current + 1;
282
+ requestRef.current = id;
283
+ lastRef.current = Date.now();
284
+ get(api.API.entrySummary, { params: { uid, documentId, ...locale ? { locale } : {} } }).then(
285
+ ({ data }) => {
286
+ if (requestRef.current === id) setState({ status: "ready", data: data && data.data || null });
287
+ },
288
+ () => {
289
+ if (requestRef.current === id) setState((current) => ({ ...current, status: "error" }));
290
+ }
291
+ );
292
+ }, [get, uid, documentId, locale]);
293
+ ReactNamespace.useEffect(() => {
294
+ load();
295
+ }, [load, version]);
296
+ ReactNamespace.useEffect(() => {
297
+ const onFocus = () => {
298
+ if (Date.now() - lastRef.current > FOCUS_REFRESH_MS) load();
299
+ };
300
+ window.addEventListener("focus", onFocus);
301
+ return () => window.removeEventListener("focus", onFocus);
302
+ }, [load]);
303
+ const reload = ReactNamespace.useCallback(() => {
304
+ setState((current) => ({ ...current, status: "loading" }));
305
+ load();
306
+ }, [load]);
307
+ return { ...state, reload };
308
+ };
309
+ const useAcknowledged = (key) => {
310
+ const storageKey = `magic-editor-x:soft-lock:${key}`;
311
+ const read = () => {
312
+ try {
313
+ return window.sessionStorage.getItem(storageKey) === "1";
314
+ } catch {
315
+ return false;
316
+ }
317
+ };
318
+ const [acknowledged, setAcknowledged] = ReactNamespace.useState(read);
319
+ const acknowledge = ReactNamespace.useCallback(() => {
320
+ setAcknowledged(true);
321
+ try {
322
+ window.sessionStorage.setItem(storageKey, "1");
323
+ } catch {
324
+ }
325
+ }, [storageKey]);
326
+ return [acknowledged, acknowledge];
327
+ };
328
+ const EntryPanelContent = ({ uid, documentId, locale, version }) => {
329
+ const t = useT.useT();
330
+ const target = { uid, documentId, locale };
331
+ const presence = useEntryPresence(target);
332
+ const summary = useEntrySummary(target, version);
333
+ const continueRef = ReactNamespace.useRef(null);
334
+ const [acknowledged, acknowledge] = useAcknowledged(`${uid}|${documentId}|${locale || "-"}`);
335
+ const others = presence.editors.filter((editor) => !editor.idle);
336
+ const lockOpen = presence.status === "ready" && presence.softLock && presence.canEdit && !acknowledged && others.length > 0;
337
+ const names = others.map((editor) => editor.name);
338
+ return /* @__PURE__ */ jsxRuntime.jsxs(Sections, { direction: "column", alignItems: "stretch", gap: 3, width: "100%", "data-testid": "mex-entry-panel", children: [
339
+ ENTRY_PANEL_SECTIONS.map(({ id, Component }) => /* @__PURE__ */ jsxRuntime.jsx(Component, { t, target, presence, summary }, id)),
340
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: lockOpen, onOpenChange: (open) => !open ? acknowledge() : void 0, children: /* @__PURE__ */ jsxRuntime.jsxs(
341
+ designSystem.Dialog.Content,
342
+ {
343
+ "data-testid": "mex-soft-lock",
344
+ onOpenAutoFocus: (event) => {
345
+ event.preventDefault();
346
+ if (continueRef.current) continueRef.current.focus();
347
+ },
348
+ children: [
349
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: t("entryPanel.softLock.title", "Someone else is editing this entry") }),
350
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Description, { children: t(
351
+ "entryPanel.softLock.body",
352
+ "{names} {count, plural, one {is} other {are}} editing this entry right now. To avoid overwriting each other's changes, agree who changes what.",
353
+ { names: names.join(", "), count: names.length }
354
+ ) }) }),
355
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Footer, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Action, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { ref: continueRef, fullWidth: true, onClick: acknowledge, children: t("entryPanel.softLock.continue", "Continue editing") }) }) })
356
+ ]
357
+ }
358
+ ) })
359
+ ] });
360
+ };
361
+ exports.EntryPanelContent = EntryPanelContent;
362
+ exports.default = EntryPanelContent;
@@ -4,10 +4,12 @@ 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 { s as sanitizeSvg, a as sanitizeTemplate, m as mergeCodeBlocks, c as codeBlocks, P as PERMISSIONS } from "./index-My6FjjHB.mjs";
8
- import { A as API, C as ConfirmAction, r as readApiError, a as refocusIfLost } from "./ConfirmAction-DuQwvRYi.mjs";
9
- import { u as useT, S as SectionCard, P as PageShell } from "./useT-Cmg1jwwG.mjs";
7
+ import { s as sanitizeSvg, a as sanitizeTemplate, m as mergeCodeBlocks, c as codeBlocks, P as PERMISSIONS } from "./index-CMYCZWOh.mjs";
8
+ import { A as API, r as readApiError } from "./api-CcTYyckq.mjs";
9
+ import { S as SectionCard, P as PageShell } from "./SectionCard-8ZNHkvn9.mjs";
10
+ import { C as ConfirmAction, r as refocusIfLost } from "./ConfirmAction-CZjpduc3.mjs";
10
11
  import styled from "styled-components";
12
+ import { u as useT } from "./useT-Cb-R3kyA.mjs";
11
13
  import { u as useBreakpoint } from "./useBreakpoint-DCfn6pDG.mjs";
12
14
  import { useIntl } from "react-intl";
13
15
  const FIELD_TYPES = Object.freeze([
@@ -22,7 +24,7 @@ const FIELD_TYPES = Object.freeze([
22
24
  ]);
23
25
  const TUNES = Object.freeze(["alignmentTune", "textVariant", "indentTune"]);
24
26
  const BLOCK_TYPES = Object.freeze(["simple", "embedded-entry"]);
25
- const LEGACY_NAMES = Object.freeze(["toc", "gallery", "video", "audio", "synced", "mention"]);
27
+ const LEGACY_NAMES = Object.freeze(["toc", "gallery", "video", "audio", "synced", "mention", "math"]);
26
28
  const RESERVED_NAMES = Object.freeze(
27
29
  [
28
30
  "paragraph",
@@ -44,6 +46,7 @@ const RESERVED_NAMES = Object.freeze(
44
46
  "video",
45
47
  "audio",
46
48
  "synced",
49
+ "math",
47
50
  "linkTool",
48
51
  "attaches",
49
52
  "personality",
@@ -934,7 +937,7 @@ const BlockFormModal = ({
934
937
  onOpenChange: (next) => {
935
938
  if (!next && !saving) onClose();
936
939
  },
937
- children: /* @__PURE__ */ jsxs(Modal.Content, { children: [
940
+ children: /* @__PURE__ */ jsxs(Modal.Content, { "aria-describedby": void 0, children: [
938
941
  /* @__PURE__ */ jsx(Modal.Header, { closeLabel: t("settings.close", "Close"), children: /* @__PURE__ */ jsx(Modal.Title, { children: title }) }),
939
942
  /* @__PURE__ */ jsx(Modal.Body, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
940
943
  visible._form ? /* @__PURE__ */ jsx(
@@ -6,10 +6,12 @@ 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-DR8sHkTk.js");
10
- const ConfirmAction = require("./ConfirmAction-zLuIFj8t.js");
11
- const useT = require("./useT-DNphiBQR.js");
9
+ const index = require("./index-DRyctF9s.js");
10
+ const api = require("./api-4AYzwS4-.js");
11
+ const SectionCard = require("./SectionCard-Bs-xiiH1.js");
12
+ const ConfirmAction = require("./ConfirmAction-CUhpngYU.js");
12
13
  const styled = require("styled-components");
14
+ const useT = require("./useT-Bpw__IXT.js");
13
15
  const useBreakpoint = require("./useBreakpoint-D30eNTkF.js");
14
16
  const reactIntl = require("react-intl");
15
17
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
@@ -26,7 +28,7 @@ const FIELD_TYPES = Object.freeze([
26
28
  ]);
27
29
  const TUNES = Object.freeze(["alignmentTune", "textVariant", "indentTune"]);
28
30
  const BLOCK_TYPES = Object.freeze(["simple", "embedded-entry"]);
29
- const LEGACY_NAMES = Object.freeze(["toc", "gallery", "video", "audio", "synced", "mention"]);
31
+ const LEGACY_NAMES = Object.freeze(["toc", "gallery", "video", "audio", "synced", "mention", "math"]);
30
32
  const RESERVED_NAMES = Object.freeze(
31
33
  [
32
34
  "paragraph",
@@ -48,6 +50,7 @@ const RESERVED_NAMES = Object.freeze(
48
50
  "video",
49
51
  "audio",
50
52
  "synced",
53
+ "math",
51
54
  "linkTool",
52
55
  "attaches",
53
56
  "personality",
@@ -305,7 +308,7 @@ const useCustomBlocks = () => {
305
308
  };
306
309
  }, []);
307
310
  const fetchBlocks = ReactNamespace.useCallback(
308
- () => get(ConfirmAction.API.customBlocks, { params: { all: "true" } }).then(
311
+ () => get(api.API.customBlocks, { params: { all: "true" } }).then(
309
312
  ({ data }) => {
310
313
  if (!mounted.current) return;
311
314
  setBlocks(Array.isArray(data.data) ? data.data : []);
@@ -322,7 +325,7 @@ const useCustomBlocks = () => {
322
325
  [get]
323
326
  );
324
327
  const fetchContentTypes = ReactNamespace.useCallback(
325
- () => get(ConfirmAction.API.contentTypes).then(
328
+ () => get(api.API.contentTypes).then(
326
329
  ({ data }) => {
327
330
  if (mounted.current)
328
331
  setContentTypes({ status: "ready", items: Array.isArray(data.data) ? data.data : [] });
@@ -938,7 +941,7 @@ const BlockFormModal = ({
938
941
  onOpenChange: (next) => {
939
942
  if (!next && !saving) onClose();
940
943
  },
941
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Content, { children: [
944
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Content, { "aria-describedby": void 0, children: [
942
945
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { closeLabel: t("settings.close", "Close"), children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: title }) }),
943
946
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
944
947
  visible._form ? /* @__PURE__ */ jsxRuntime.jsx(
@@ -1379,7 +1382,7 @@ const CodeBlocksSection = () => {
1379
1382
  const [server, setServer] = ReactNamespace.useState([]);
1380
1383
  ReactNamespace.useEffect(() => {
1381
1384
  let active = true;
1382
- get(ConfirmAction.API.config).then(
1385
+ get(api.API.config).then(
1383
1386
  ({ data }) => {
1384
1387
  if (active && data && data.data && Array.isArray(data.data.codeBlocks))
1385
1388
  setServer(data.data.codeBlocks);
@@ -1394,7 +1397,7 @@ const CodeBlocksSection = () => {
1394
1397
  const rows = ReactNamespace.useMemo(() => index.mergeCodeBlocks(server, index.codeBlocks(), locale), [server, locale]);
1395
1398
  if (!rows.length) return null;
1396
1399
  return /* @__PURE__ */ jsxRuntime.jsx(
1397
- useT.SectionCard,
1400
+ SectionCard.SectionCard,
1398
1401
  {
1399
1402
  title: t("settings.blocks.code.title", "Defined in code"),
1400
1403
  subtitle: t(
@@ -1485,7 +1488,7 @@ const CustomBlocksPage = () => {
1485
1488
  ] });
1486
1489
  }
1487
1490
  const failed = (error, fallback) => {
1488
- const info = ConfirmAction.readApiError(error);
1491
+ const info = api.readApiError(error);
1489
1492
  toggleNotification({
1490
1493
  type: "danger",
1491
1494
  message: info.status === 404 ? t("settings.blocks.notFound", "This block no longer exists.") : fallback
@@ -1494,8 +1497,8 @@ const CustomBlocksPage = () => {
1494
1497
  const onSubmit = async (values) => {
1495
1498
  const payload = toPayload(values);
1496
1499
  try {
1497
- if (modal.block) await put(ConfirmAction.API.customBlock(modal.block.id), payload);
1498
- else await post(ConfirmAction.API.customBlocks, payload);
1500
+ if (modal.block) await put(api.API.customBlock(modal.block.id), payload);
1501
+ else await post(api.API.customBlocks, payload);
1499
1502
  toggleNotification({
1500
1503
  type: "success",
1501
1504
  message: modal.block ? t("settings.blocks.saved", "Block {label} saved.", { label: payload.label }) : t("settings.blocks.created", "Block {label} created.", { label: payload.label })
@@ -1504,7 +1507,7 @@ const CustomBlocksPage = () => {
1504
1507
  await data.reload();
1505
1508
  return { ok: true };
1506
1509
  } catch (error) {
1507
- const info = ConfirmAction.readApiError(error);
1510
+ const info = api.readApiError(error);
1508
1511
  if (info.status === 400) {
1509
1512
  toggleNotification({
1510
1513
  type: "warning",
@@ -1525,7 +1528,7 @@ const CustomBlocksPage = () => {
1525
1528
  const onToggle = async (block, enabled) => {
1526
1529
  setBusyId(block.id);
1527
1530
  try {
1528
- const { data: response } = await put(ConfirmAction.API.customBlock(block.id), withEnabled(block, enabled));
1531
+ const { data: response } = await put(api.API.customBlock(block.id), withEnabled(block, enabled));
1529
1532
  data.setBlocks((current) => current.map((item) => item.id === block.id ? response.data : item));
1530
1533
  toggleNotification({
1531
1534
  type: "success",
@@ -1534,7 +1537,7 @@ const CustomBlocksPage = () => {
1534
1537
  })
1535
1538
  });
1536
1539
  } catch (error) {
1537
- const info = ConfirmAction.readApiError(error);
1540
+ const info = api.readApiError(error);
1538
1541
  if (info.status === 400) {
1539
1542
  toggleNotification({
1540
1543
  type: "warning",
@@ -1552,7 +1555,7 @@ const CustomBlocksPage = () => {
1552
1555
  const onDuplicate = async (block) => {
1553
1556
  setBusyId(block.id);
1554
1557
  try {
1555
- const { data: response } = await post(ConfirmAction.API.customBlockDuplicate(block.id), {});
1558
+ const { data: response } = await post(api.API.customBlockDuplicate(block.id), {});
1556
1559
  toggleNotification({
1557
1560
  type: "success",
1558
1561
  message: t("settings.blocks.duplicated", "Copy {label} created.", { label: response.data.label })
@@ -1574,7 +1577,7 @@ const CustomBlocksPage = () => {
1574
1577
  const opener = typeof document !== "undefined" ? document.activeElement : null;
1575
1578
  setBusyId(block.id);
1576
1579
  try {
1577
- const { data: response } = await put(ConfirmAction.API.customBlocksOrder, { ids });
1580
+ const { data: response } = await put(api.API.customBlocksOrder, { ids });
1578
1581
  data.setBlocks(response.data);
1579
1582
  } catch (error) {
1580
1583
  failed(error, t("settings.blocks.moveError", "The order could not be saved."));
@@ -1585,7 +1588,7 @@ const CustomBlocksPage = () => {
1585
1588
  };
1586
1589
  const onDelete = async (block) => {
1587
1590
  try {
1588
- await del(ConfirmAction.API.customBlock(block.id));
1591
+ await del(api.API.customBlock(block.id));
1589
1592
  toggleNotification({
1590
1593
  type: "success",
1591
1594
  message: t("settings.blocks.deleted", "Block {label} deleted.", { label: block.label })
@@ -1599,7 +1602,7 @@ const CustomBlocksPage = () => {
1599
1602
  const onExport = async () => {
1600
1603
  setExporting(true);
1601
1604
  try {
1602
- const { data: response } = await get(ConfirmAction.API.customBlocksExport);
1605
+ const { data: response } = await get(api.API.customBlocksExport);
1603
1606
  const blob = new Blob([JSON.stringify(response.data, null, 2)], { type: "application/json" });
1604
1607
  const url = URL.createObjectURL(blob);
1605
1608
  const link = document.createElement("a");
@@ -1638,7 +1641,7 @@ const CustomBlocksPage = () => {
1638
1641
  });
1639
1642
  return;
1640
1643
  }
1641
- const { data: response } = await post(ConfirmAction.API.customBlocksImport, parsed);
1644
+ const { data: response } = await post(api.API.customBlocksImport, parsed);
1642
1645
  const { created, skipped } = response.data;
1643
1646
  setImportReport({ created, skipped });
1644
1647
  toggleNotification({
@@ -1650,7 +1653,7 @@ const CustomBlocksPage = () => {
1650
1653
  });
1651
1654
  await data.reload();
1652
1655
  } catch (error) {
1653
- const info = ConfirmAction.readApiError(error);
1656
+ const info = api.readApiError(error);
1654
1657
  toggleNotification({
1655
1658
  type: "danger",
1656
1659
  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.")
@@ -1669,7 +1672,7 @@ const CustomBlocksPage = () => {
1669
1672
  }
1670
1673
  );
1671
1674
  return /* @__PURE__ */ jsxRuntime.jsxs(
1672
- useT.PageShell,
1675
+ SectionCard.PageShell,
1673
1676
  {
1674
1677
  title,
1675
1678
  subtitle: t(
@@ -1741,7 +1744,7 @@ const CustomBlocksPage = () => {
1741
1744
  }) }, `${entry.name}-${index2}`)) })
1742
1745
  }
1743
1746
  ) : null,
1744
- data.blocks.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(useT.SectionCard, { children: /* @__PURE__ */ jsxRuntime.jsx(
1747
+ data.blocks.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(SectionCard.SectionCard, { children: /* @__PURE__ */ jsxRuntime.jsx(
1745
1748
  designSystem.EmptyStateLayout,
1746
1749
  {
1747
1750
  icon: /* @__PURE__ */ jsxRuntime.jsx(symbols.EmptyDocuments, { width: "16rem", height: "8.8rem" }),