magic-editor-x 2.4.0 → 2.5.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 (95) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/README.md +140 -62
  3. package/bin/magic-editor-x.mjs +55 -8
  4. package/dist/admin/{AuditPage-guB0SiGS.mjs → AuditPage-Be78C7EC.mjs} +4 -3
  5. package/dist/admin/{AuditPage-C2u6z4aN.js → AuditPage-iQzpjH8H.js} +7 -6
  6. package/dist/admin/{ConfigurationPage-DiEpF1Rr.mjs → ConfigurationPage-C9CPBfWy.mjs} +186 -6
  7. package/dist/admin/{ConfigurationPage-D6uya-J1.js → ConfigurationPage-DefuBeYO.js} +191 -11
  8. package/dist/admin/Content-BttG50Mc.mjs +360 -0
  9. package/dist/admin/Content-V5MRBsI3.js +362 -0
  10. package/dist/admin/{CustomBlocksPage-Byt10-6c.mjs → CustomBlocksPage-DB5nnCsn.mjs} +5 -4
  11. package/dist/admin/{CustomBlocksPage-DP3h_wNd.js → CustomBlocksPage-Dg2rM3F4.js} +8 -7
  12. package/dist/admin/EntryWidgets-B8YA0Zxy.mjs +199 -0
  13. package/dist/admin/EntryWidgets-BcXAAx3F.js +201 -0
  14. package/dist/admin/{MentionsWidget-sMkM9mHX.mjs → MentionsWidget-CJPZDk9Z.mjs} +2 -2
  15. package/dist/admin/{MentionsWidget-C2OCAmqq.js → MentionsWidget-DUz6YVIG.js} +2 -2
  16. package/dist/admin/{useT-CLPhBmBC.mjs → SectionCard-8ZNHkvn9.mjs} +2 -12
  17. package/dist/admin/{useT-BXJLIPN4.js → SectionCard-Bs-xiiH1.js} +0 -10
  18. package/dist/admin/{TemplatesPage-Yp4OqFE2.mjs → TemplatesPage-VsZ_Mc0R.mjs} +6 -5
  19. package/dist/admin/{TemplatesPage-DrSJdteI.js → TemplatesPage-dx4_yd_t.js} +13 -12
  20. package/dist/admin/{api-bix9RLLI.js → api-4AYzwS4-.js} +9 -1
  21. package/dist/admin/{api-2ZRpHM3d.mjs → api-CcTYyckq.mjs} +9 -1
  22. package/dist/admin/{de-zcV8D7nt.js → de-B6rdcOqQ.js} +103 -1
  23. package/dist/admin/{de-1cFMs-4c.mjs → de-BWfR2jTg.mjs} +8 -1
  24. package/dist/admin/{de-DiCZrmH8.mjs → de-Bip0sBRT.mjs} +19 -1
  25. package/dist/admin/{de-Dn8athM8.js → de-BrPR4sUB.js} +8 -1
  26. package/dist/admin/{de-CKz6CG3V.mjs → de-CQA8hOpl.mjs} +103 -1
  27. package/dist/admin/{de-CbBDnXeT.js → de-CnnxKXj7.js} +19 -1
  28. package/dist/admin/{de-BhhGss1l.js → de-Dss5POqk.js} +12 -1
  29. package/dist/admin/{de-BNPIGqhs.mjs → de-zgHCYTLH.mjs} +12 -1
  30. package/dist/admin/{en-CIZ5Ggod.js → en--JjAHbpP.js} +8 -1
  31. package/dist/admin/{en-cYzqbASF.mjs → en-BCKaVgBM.mjs} +103 -1
  32. package/dist/admin/{en-B9ApE1y1.js → en-CJ17Sp_e.js} +12 -1
  33. package/dist/admin/{en-BMWhILnj.js → en-CbGkcq0Q.js} +103 -1
  34. package/dist/admin/{en-DCPMqFIa.mjs → en-Cd6Jk-J0.mjs} +19 -1
  35. package/dist/admin/{en-CpehF0Kv.js → en-D69Fe9ZO.js} +19 -1
  36. package/dist/admin/{en-Dc9y-6n9.mjs → en-Dr58wBAo.mjs} +8 -1
  37. package/dist/admin/{en-gFLeK9Ng.mjs → en-Uhm7OouM.mjs} +12 -1
  38. package/dist/admin/entry-panel-events-0msyPrAD.js +18 -0
  39. package/dist/admin/entry-panel-events-XRuUoLZ9.mjs +19 -0
  40. package/dist/admin/{es-D2Kw6E4N.mjs → es-B2Hkkbw9.mjs} +8 -1
  41. package/dist/admin/{es-BmwBgEgz.mjs → es-BMkmfH88.mjs} +12 -1
  42. package/dist/admin/{es-Chs37IBR.mjs → es-Bz8d72Fa.mjs} +19 -1
  43. package/dist/admin/{es-CQPh8PXw.js → es-C8UotT8O.js} +103 -1
  44. package/dist/admin/{es-CawpzwyC.js → es-CcEDZpVQ.js} +19 -1
  45. package/dist/admin/{es-C0W31rl8.js → es-DJm3HFJt.js} +12 -1
  46. package/dist/admin/{es-C4IRHV5d.js → es-YvaTAtqY.js} +8 -1
  47. package/dist/admin/{es-DCamt1ek.mjs → es-pvPfNAld.mjs} +103 -1
  48. package/dist/admin/{fr-BOvvfEH7.mjs → fr-BvPjRiwr.mjs} +8 -1
  49. package/dist/admin/{fr-Dp5-XP29.mjs → fr-CKHZ0xxU.mjs} +19 -1
  50. package/dist/admin/{fr-iGeIfEcU.js → fr-CRM9VuAq.js} +12 -1
  51. package/dist/admin/{fr-CMWBNE5D.mjs → fr-CrIHmKYX.mjs} +12 -1
  52. package/dist/admin/{fr-COOsqexl.js → fr-Cx29jQ_g.js} +19 -1
  53. package/dist/admin/{fr-oW0t8bT5.mjs → fr-D4tL6Ag2.mjs} +103 -1
  54. package/dist/admin/{fr-Zkb8vfjN.js → fr-Di-U-rAH.js} +8 -1
  55. package/dist/admin/{fr-DpC44Ol8.js → fr-DrUYv2jh.js} +103 -1
  56. package/dist/admin/{index-BVjf1gVC.mjs → index-C4ksUkEm.mjs} +9183 -6353
  57. package/dist/admin/{index-64wc26Bl.js → index-C5D3VqLq.js} +9170 -6340
  58. package/dist/admin/{index-D_Fv8Non.mjs → index-CMYCZWOh.mjs} +1053 -190
  59. package/dist/admin/{index-D6Z7i8ba.js → index-DRyctF9s.js} +961 -98
  60. package/dist/admin/index.js +1 -1
  61. package/dist/admin/index.mjs +2 -2
  62. package/dist/admin/{math-vsK_06ZR.js → math-D6jmskGS.js} +1 -1
  63. package/dist/admin/{math-CIQ4Z_mY.mjs → math-DntdSWKX.mjs} +1 -1
  64. package/dist/admin/{pt-DALDvfBn.mjs → pt-B8x7v-Xw.mjs} +19 -1
  65. package/dist/admin/{pt-DXy7G1x7.js → pt-BYn2xx78.js} +19 -1
  66. package/dist/admin/{pt-Bo0Pm_Pt.js → pt-CojQcz-p.js} +103 -1
  67. package/dist/admin/{pt-uGpfRQLC.mjs → pt-CuoIihKx.mjs} +103 -1
  68. package/dist/admin/{pt-1IUyx6ae.js → pt-CzrN_3ui.js} +8 -1
  69. package/dist/admin/{pt-DFNgZ5_k.mjs → pt-DDlPJYtB.mjs} +12 -1
  70. package/dist/admin/{pt-BHmXk2d9.js → pt-DPVAycXJ.js} +12 -1
  71. package/dist/admin/{pt-etwsg3G4.mjs → pt-DdGagO99.mjs} +8 -1
  72. package/dist/admin/useT-Bpw__IXT.js +12 -0
  73. package/dist/admin/useT-Cb-R3kyA.mjs +13 -0
  74. package/dist/blocks/index.d.mts +124 -0
  75. package/dist/blocks/index.d.ts +124 -0
  76. package/dist/blocks/index.js +172 -3
  77. package/dist/blocks/index.mjs +172 -3
  78. package/dist/math/index.js +6 -2
  79. package/dist/math/index.mjs +6 -2
  80. package/dist/react/index.js +1376 -1067
  81. package/dist/react/index.mjs +1376 -1067
  82. package/dist/render/index.d.mts +22 -0
  83. package/dist/render/index.d.ts +22 -0
  84. package/dist/render/index.js +1376 -1067
  85. package/dist/render/index.mjs +1376 -1067
  86. package/dist/server/index.js +28894 -24197
  87. package/dist/server/index.mjs +28893 -24196
  88. package/dist/server/mcp-worker.js +11319 -0
  89. package/dist/vue/index.js +1376 -1067
  90. package/dist/vue/index.mjs +1376 -1067
  91. package/package.json +7 -7
  92. package/schema/magic-editor-x.schema.json +9 -1
  93. package/types/blocks.d.ts +124 -0
  94. package/types/index.d.ts +10 -1
  95. package/types/render.d.ts +22 -0
@@ -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,11 +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-D_Fv8Non.mjs";
8
- import { A as API, r as readApiError } from "./api-2ZRpHM3d.mjs";
9
- import { u as useT, S as SectionCard, P as PageShell } from "./useT-CLPhBmBC.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
10
  import { C as ConfirmAction, r as refocusIfLost } from "./ConfirmAction-CZjpduc3.mjs";
11
11
  import styled from "styled-components";
12
+ import { u as useT } from "./useT-Cb-R3kyA.mjs";
12
13
  import { u as useBreakpoint } from "./useBreakpoint-DCfn6pDG.mjs";
13
14
  import { useIntl } from "react-intl";
14
15
  const FIELD_TYPES = Object.freeze([
@@ -936,7 +937,7 @@ const BlockFormModal = ({
936
937
  onOpenChange: (next) => {
937
938
  if (!next && !saving) onClose();
938
939
  },
939
- children: /* @__PURE__ */ jsxs(Modal.Content, { children: [
940
+ children: /* @__PURE__ */ jsxs(Modal.Content, { "aria-describedby": void 0, children: [
940
941
  /* @__PURE__ */ jsx(Modal.Header, { closeLabel: t("settings.close", "Close"), children: /* @__PURE__ */ jsx(Modal.Title, { children: title }) }),
941
942
  /* @__PURE__ */ jsx(Modal.Body, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
942
943
  visible._form ? /* @__PURE__ */ jsx(
@@ -6,11 +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-D6Z7i8ba.js");
10
- const api = require("./api-bix9RLLI.js");
11
- const useT = require("./useT-BXJLIPN4.js");
9
+ const index = require("./index-DRyctF9s.js");
10
+ const api = require("./api-4AYzwS4-.js");
11
+ const SectionCard = require("./SectionCard-Bs-xiiH1.js");
12
12
  const ConfirmAction = require("./ConfirmAction-CUhpngYU.js");
13
13
  const styled = require("styled-components");
14
+ const useT = require("./useT-Bpw__IXT.js");
14
15
  const useBreakpoint = require("./useBreakpoint-D30eNTkF.js");
15
16
  const reactIntl = require("react-intl");
16
17
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
@@ -940,7 +941,7 @@ const BlockFormModal = ({
940
941
  onOpenChange: (next) => {
941
942
  if (!next && !saving) onClose();
942
943
  },
943
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Content, { children: [
944
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Content, { "aria-describedby": void 0, children: [
944
945
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { closeLabel: t("settings.close", "Close"), children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: title }) }),
945
946
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
946
947
  visible._form ? /* @__PURE__ */ jsxRuntime.jsx(
@@ -1396,7 +1397,7 @@ const CodeBlocksSection = () => {
1396
1397
  const rows = ReactNamespace.useMemo(() => index.mergeCodeBlocks(server, index.codeBlocks(), locale), [server, locale]);
1397
1398
  if (!rows.length) return null;
1398
1399
  return /* @__PURE__ */ jsxRuntime.jsx(
1399
- useT.SectionCard,
1400
+ SectionCard.SectionCard,
1400
1401
  {
1401
1402
  title: t("settings.blocks.code.title", "Defined in code"),
1402
1403
  subtitle: t(
@@ -1671,7 +1672,7 @@ const CustomBlocksPage = () => {
1671
1672
  }
1672
1673
  );
1673
1674
  return /* @__PURE__ */ jsxRuntime.jsxs(
1674
- useT.PageShell,
1675
+ SectionCard.PageShell,
1675
1676
  {
1676
1677
  title,
1677
1678
  subtitle: t(
@@ -1743,7 +1744,7 @@ const CustomBlocksPage = () => {
1743
1744
  }) }, `${entry.name}-${index2}`)) })
1744
1745
  }
1745
1746
  ) : null,
1746
- 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(
1747
1748
  designSystem.EmptyStateLayout,
1748
1749
  {
1749
1750
  icon: /* @__PURE__ */ jsxRuntime.jsx(symbols.EmptyDocuments, { width: "16rem", height: "8.8rem" }),
@@ -0,0 +1,199 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useState, useRef, useCallback, useEffect } from "react";
3
+ import { useIntl } from "react-intl";
4
+ import { Link } from "react-router-dom";
5
+ import { Flex, Typography, Button } from "@strapi/design-system";
6
+ import { Widget, useFetchClient } from "@strapi/strapi/admin";
7
+ import styled from "styled-components";
8
+ import { A as API } from "./api-CcTYyckq.mjs";
9
+ import { u as useT } from "./useT-Cb-R3kyA.mjs";
10
+ import { r as relativeTimeParts } from "./comments-hfIbLQNO.mjs";
11
+ import { e as entryPath } from "./index-CMYCZWOh.mjs";
12
+ const POLL_MS = 6e4;
13
+ const PAGE_SIZE = 5;
14
+ const List = styled.ul`
15
+ list-style: none;
16
+ margin: 0;
17
+ padding: 0;
18
+ display: flex;
19
+ flex-direction: column;
20
+ gap: ${({ theme }) => theme.spaces[1]};
21
+ min-width: 0;
22
+ `;
23
+ const ItemLink = styled(Link)`
24
+ display: block;
25
+ min-width: 0;
26
+ padding: ${({ theme }) => theme.spaces[2]};
27
+ border-radius: ${({ theme }) => theme.borderRadius};
28
+ color: inherit;
29
+ text-decoration: none;
30
+ &:hover {
31
+ background: ${({ theme }) => theme.colors.neutral100};
32
+ }
33
+ &:hover span:first-child {
34
+ text-decoration: underline;
35
+ }
36
+ &:focus-visible {
37
+ outline: 2px solid ${({ theme }) => theme.colors.primary600};
38
+ outline-offset: 2px;
39
+ }
40
+ `;
41
+ const Wrap = styled(Typography)`
42
+ display: block;
43
+ overflow-wrap: anywhere;
44
+ min-width: 0;
45
+ `;
46
+ const useWidgetData = (path) => {
47
+ const { get } = useFetchClient();
48
+ const [state, setState] = useState({ loading: true, error: false, items: [], meta: {} });
49
+ const requestRef = useRef(0);
50
+ const load = useCallback(() => {
51
+ const id = requestRef.current + 1;
52
+ requestRef.current = id;
53
+ return get(path, { params: { pageSize: PAGE_SIZE } }).then(
54
+ ({ data }) => {
55
+ if (requestRef.current !== id) return;
56
+ setState({
57
+ loading: false,
58
+ error: false,
59
+ items: Array.isArray(data.data) ? data.data : [],
60
+ meta: data.meta || {}
61
+ });
62
+ },
63
+ () => {
64
+ if (requestRef.current !== id) return;
65
+ setState((current) => ({ ...current, loading: false, error: true }));
66
+ }
67
+ );
68
+ }, [get, path]);
69
+ useEffect(() => {
70
+ let timer = null;
71
+ const schedule = () => {
72
+ window.clearTimeout(timer);
73
+ if (document.visibilityState === "hidden") return;
74
+ timer = window.setTimeout(async () => {
75
+ await load();
76
+ schedule();
77
+ }, POLL_MS);
78
+ };
79
+ const onWake = () => {
80
+ if (document.visibilityState === "hidden") {
81
+ window.clearTimeout(timer);
82
+ return;
83
+ }
84
+ load();
85
+ schedule();
86
+ };
87
+ load();
88
+ schedule();
89
+ window.addEventListener("focus", onWake);
90
+ document.addEventListener("visibilitychange", onWake);
91
+ return () => {
92
+ window.clearTimeout(timer);
93
+ window.removeEventListener("focus", onWake);
94
+ document.removeEventListener("visibilitychange", onWake);
95
+ };
96
+ }, [load]);
97
+ return { ...state, reload: load };
98
+ };
99
+ const ErrorState = ({ text, retry, onRetry }) => /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, alignItems: "center", children: [
100
+ /* @__PURE__ */ jsx(Widget.Error, { children: text }),
101
+ /* @__PURE__ */ jsx(Button, { size: "S", variant: "tertiary", onClick: onRetry, children: retry })
102
+ ] });
103
+ const entryName = (t, target) => target.title ? t("widget.openThreads.where", "{title} ({type})", { title: target.title, type: target.typeName }) : target.typeName;
104
+ const OpenThreadsWidget = () => {
105
+ const t = useT();
106
+ const { formatRelativeTime } = useIntl();
107
+ const state = useWidgetData(API.widgetOpenThreads);
108
+ if (state.loading && !state.items.length)
109
+ return /* @__PURE__ */ jsx(Widget.Loading, { children: t("widget.openThreads.loading", "Loading threads") });
110
+ if (state.error && !state.items.length)
111
+ return /* @__PURE__ */ jsx(
112
+ ErrorState,
113
+ {
114
+ text: t("widget.openThreads.error", "Threads could not be loaded."),
115
+ retry: t("widget.retry", "Try again"),
116
+ onRetry: state.reload
117
+ }
118
+ );
119
+ if (!state.items.length)
120
+ return /* @__PURE__ */ jsx(Widget.NoData, { children: t(
121
+ "widget.openThreads.empty",
122
+ "No open threads. Threads you start or are mentioned in stay here until they are resolved."
123
+ ) });
124
+ return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, "data-testid": "mex-open-threads-widget", children: [
125
+ /* @__PURE__ */ jsx(List, { children: state.items.map((item) => {
126
+ const { value, unit } = relativeTimeParts(item.updatedAt);
127
+ const why = item.started ? t("widget.openThreads.started", "You started this thread") : t("widget.openThreads.mentioned", "You were mentioned");
128
+ return /* @__PURE__ */ jsx("li", { "data-testid": "mex-open-thread", children: /* @__PURE__ */ jsxs(ItemLink, { to: entryPath(item.target, { mexThread: item.threadId }), children: [
129
+ /* @__PURE__ */ jsx(Wrap, { variant: "omega", fontWeight: "bold", textColor: "neutral800", children: item.excerpt || item.snippet || entryName(t, item.target) }),
130
+ /* @__PURE__ */ jsxs(Wrap, { variant: "pi", textColor: "neutral600", children: [
131
+ entryName(t, item.target),
132
+ " · ",
133
+ why,
134
+ " · ",
135
+ formatRelativeTime(value, unit, { numeric: "auto" })
136
+ ] })
137
+ ] }) }, item.threadId);
138
+ }) }),
139
+ state.meta.more ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: t("widget.openThreads.more", "More open threads are not shown. Resolve threads to see the rest.") }) : null
140
+ ] });
141
+ };
142
+ const BrokenLinksWidget = () => {
143
+ const t = useT();
144
+ const { formatDate } = useIntl();
145
+ const state = useWidgetData(API.widgetBrokenLinks);
146
+ if (state.loading && !state.items.length && !state.meta.lastRun)
147
+ return /* @__PURE__ */ jsx(Widget.Loading, { children: t("widget.brokenLinks.loading", "Loading links") });
148
+ if (state.error && !state.items.length)
149
+ return /* @__PURE__ */ jsx(
150
+ ErrorState,
151
+ {
152
+ text: t("widget.brokenLinks.error", "Broken links could not be loaded."),
153
+ retry: t("widget.retry", "Try again"),
154
+ onRetry: state.reload
155
+ }
156
+ );
157
+ if (state.meta.enabled === false)
158
+ return /* @__PURE__ */ jsx(Widget.NoData, { children: t("widget.brokenLinks.off", "The scheduled link check is turned off in the server configuration.") });
159
+ if (!state.meta.lastRun)
160
+ return /* @__PURE__ */ jsx(Widget.NoData, { children: t(
161
+ "widget.brokenLinks.noRun",
162
+ "The scheduled link check has not run yet. Results show up here after it runs."
163
+ ) });
164
+ const checked = t("widget.brokenLinks.lastRun", "Last check {date}", {
165
+ date: formatDate(state.meta.lastRun.finishedAt, { dateStyle: "medium", timeStyle: "short" })
166
+ });
167
+ if (!state.items.length)
168
+ return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, alignItems: "center", children: [
169
+ /* @__PURE__ */ jsx(Widget.NoData, { children: t("widget.brokenLinks.empty", "No broken links in the entries you can read.") }),
170
+ /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: checked })
171
+ ] });
172
+ return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, "data-testid": "mex-broken-links-widget", children: [
173
+ /* @__PURE__ */ jsx(List, { children: state.items.map((item) => /* @__PURE__ */ jsx(
174
+ "li",
175
+ {
176
+ "data-testid": "mex-broken-entry",
177
+ children: /* @__PURE__ */ jsxs(ItemLink, { to: entryPath(item.target), children: [
178
+ /* @__PURE__ */ jsx(Wrap, { variant: "omega", fontWeight: "bold", textColor: "neutral800", children: entryName(t, item.target) }),
179
+ /* @__PURE__ */ jsxs(Wrap, { variant: "pi", textColor: "neutral600", children: [
180
+ t(
181
+ "widget.brokenLinks.count",
182
+ "{count, plural, one {# broken link} other {# broken links}}",
183
+ {
184
+ count: item.problems
185
+ }
186
+ ),
187
+ item.target.locale ? ` · ${item.target.locale}` : ""
188
+ ] })
189
+ ] })
190
+ },
191
+ `${item.target.uid}|${item.target.documentId}|${item.target.locale || ""}`
192
+ )) }),
193
+ /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: state.meta.more ? t("widget.brokenLinks.more", "More entries have broken links. {date}", { date: checked }) : checked })
194
+ ] });
195
+ };
196
+ export {
197
+ BrokenLinksWidget,
198
+ OpenThreadsWidget
199
+ };