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.
- package/CHANGELOG.md +125 -0
- package/README.md +428 -148
- package/bin/magic-editor-x.mjs +55 -8
- package/dist/admin/AuditPage-Be78C7EC.mjs +382 -0
- package/dist/admin/AuditPage-iQzpjH8H.js +382 -0
- package/dist/admin/{ConfigurationPage-CYGDLjM7.mjs → ConfigurationPage-C9CPBfWy.mjs} +405 -10
- package/dist/admin/{ConfigurationPage-CFP3lp9p.js → ConfigurationPage-DefuBeYO.js} +415 -20
- package/dist/admin/ConfirmAction-CUhpngYU.js +71 -0
- package/dist/admin/ConfirmAction-CZjpduc3.mjs +72 -0
- package/dist/admin/Content-BttG50Mc.mjs +360 -0
- package/dist/admin/Content-V5MRBsI3.js +362 -0
- package/dist/admin/{CustomBlocksPage-B5Q33N-s.mjs → CustomBlocksPage-DB5nnCsn.mjs} +8 -5
- package/dist/admin/{CustomBlocksPage-DzPOSpfn.js → CustomBlocksPage-Dg2rM3F4.js} +26 -23
- package/dist/admin/EntryWidgets-B8YA0Zxy.mjs +199 -0
- package/dist/admin/EntryWidgets-BcXAAx3F.js +201 -0
- package/dist/admin/MentionsWidget-CJPZDk9Z.mjs +225 -0
- package/dist/admin/MentionsWidget-DUz6YVIG.js +227 -0
- package/dist/admin/{useT-Cmg1jwwG.mjs → SectionCard-8ZNHkvn9.mjs} +2 -12
- package/dist/admin/{useT-DNphiBQR.js → SectionCard-Bs-xiiH1.js} +0 -10
- package/dist/admin/{TemplatesPage-4A8JNO_Z.mjs → TemplatesPage-VsZ_Mc0R.mjs} +307 -10
- package/dist/admin/{TemplatesPage-BVkgafCK.js → TemplatesPage-dx4_yd_t.js} +321 -24
- package/dist/admin/{ConfirmAction-zLuIFj8t.js → api-4AYzwS4-.js} +28 -71
- package/dist/admin/{ConfirmAction-DuQwvRYi.mjs → api-CcTYyckq.mjs} +28 -71
- package/dist/admin/auditText-DIIYVR6k.mjs +110 -0
- package/dist/admin/auditText-DUhWu2Nx.js +109 -0
- package/dist/admin/comments-C7P41lan.js +86 -0
- package/dist/admin/comments-hfIbLQNO.mjs +87 -0
- package/dist/admin/{de-B1X46JJZ.js → de-B6rdcOqQ.js} +293 -5
- package/dist/admin/{de-1cFMs-4c.mjs → de-BWfR2jTg.mjs} +8 -1
- package/dist/admin/{de-BUS1hUw0.mjs → de-Bip0sBRT.mjs} +158 -1
- package/dist/admin/{de-Dn8athM8.js → de-BrPR4sUB.js} +8 -1
- package/dist/admin/{de-DOiGaTNX.mjs → de-CQA8hOpl.mjs} +293 -5
- package/dist/admin/{de-C3AsGauQ.js → de-CnnxKXj7.js} +158 -1
- package/dist/admin/{de-2Ie5jy7j.js → de-Dss5POqk.js} +53 -3
- package/dist/admin/{de-BMY2LBaa.mjs → de-zgHCYTLH.mjs} +53 -3
- package/dist/admin/{en-CIZ5Ggod.js → en--JjAHbpP.js} +8 -1
- package/dist/admin/{en-CU6UzV4g.mjs → en-BCKaVgBM.mjs} +293 -5
- package/dist/admin/{en-Ah-Cw0Wd.js → en-CJ17Sp_e.js} +53 -3
- package/dist/admin/{en-CDg_18Bt.js → en-CbGkcq0Q.js} +293 -5
- package/dist/admin/{en-GCzgS9Aw.mjs → en-Cd6Jk-J0.mjs} +158 -1
- package/dist/admin/{en-BkEjpC3i.js → en-D69Fe9ZO.js} +158 -1
- package/dist/admin/{en-Dc9y-6n9.mjs → en-Dr58wBAo.mjs} +8 -1
- package/dist/admin/{en-CvFiqti2.mjs → en-Uhm7OouM.mjs} +53 -3
- package/dist/admin/entry-panel-events-0msyPrAD.js +18 -0
- package/dist/admin/entry-panel-events-XRuUoLZ9.mjs +19 -0
- package/dist/admin/{es-D2Kw6E4N.mjs → es-B2Hkkbw9.mjs} +8 -1
- package/dist/admin/{es-DbKHZz5l.mjs → es-BMkmfH88.mjs} +53 -3
- package/dist/admin/{es-DHBBZKl2.mjs → es-Bz8d72Fa.mjs} +158 -1
- package/dist/admin/{es-BCpJmUEM.js → es-C8UotT8O.js} +293 -5
- package/dist/admin/{es-C4pEnDRv.js → es-CcEDZpVQ.js} +158 -1
- package/dist/admin/{es-Cr8JH85N.js → es-DJm3HFJt.js} +53 -3
- package/dist/admin/{es-C4IRHV5d.js → es-YvaTAtqY.js} +8 -1
- package/dist/admin/{es-BmfffNM2.mjs → es-pvPfNAld.mjs} +293 -5
- package/dist/admin/{fr-BOvvfEH7.mjs → fr-BvPjRiwr.mjs} +8 -1
- package/dist/admin/{fr-Dvq4xk2e.mjs → fr-CKHZ0xxU.mjs} +158 -1
- package/dist/admin/{fr-OJ4VW1kh.js → fr-CRM9VuAq.js} +53 -3
- package/dist/admin/{fr-DQJ_7aq5.mjs → fr-CrIHmKYX.mjs} +53 -3
- package/dist/admin/{fr-C2aLSwEu.js → fr-Cx29jQ_g.js} +158 -1
- package/dist/admin/{fr-DZd2XJP6.mjs → fr-D4tL6Ag2.mjs} +293 -5
- package/dist/admin/{fr-Zkb8vfjN.js → fr-Di-U-rAH.js} +8 -1
- package/dist/admin/{fr-ZcN0yM_2.js → fr-DrUYv2jh.js} +293 -5
- package/dist/admin/{index-k8_a5o1A.mjs → index-C4ksUkEm.mjs} +20059 -10130
- package/dist/admin/{index-DQVE0ymw.js → index-C5D3VqLq.js} +21272 -11344
- package/dist/admin/index-CMYCZWOh.mjs +3752 -0
- package/dist/admin/index-DRyctF9s.js +3753 -0
- package/dist/admin/index.js +2 -1
- package/dist/admin/index.mjs +3 -2
- package/dist/admin/math-D6jmskGS.js +49 -0
- package/dist/admin/math-DntdSWKX.mjs +47 -0
- package/dist/admin/{pt-CilDggGF.mjs → pt-B8x7v-Xw.mjs} +158 -1
- package/dist/admin/{pt-DX0OAIoL.js → pt-BYn2xx78.js} +158 -1
- package/dist/admin/{pt-CImqDnLB.js → pt-CojQcz-p.js} +293 -5
- package/dist/admin/{pt-C3UdeIpd.mjs → pt-CuoIihKx.mjs} +293 -5
- package/dist/admin/{pt-1IUyx6ae.js → pt-CzrN_3ui.js} +8 -1
- package/dist/admin/{pt-BSLzA17U.mjs → pt-DDlPJYtB.mjs} +53 -3
- package/dist/admin/{pt-D0I0_JYs.js → pt-DPVAycXJ.js} +53 -3
- package/dist/admin/{pt-etwsg3G4.mjs → pt-DdGagO99.mjs} +8 -1
- package/dist/admin/useT-Bpw__IXT.js +12 -0
- package/dist/admin/useT-Cb-R3kyA.mjs +13 -0
- package/dist/blocks/index.d.mts +126 -0
- package/dist/blocks/index.d.ts +126 -0
- package/dist/blocks/index.js +184 -4
- package/dist/blocks/index.mjs +184 -4
- package/dist/math/index.d.mts +27 -0
- package/dist/math/index.d.ts +27 -0
- package/dist/math/index.js +168 -0
- package/dist/math/index.mjs +138 -0
- package/dist/react/index.js +1650 -759
- package/dist/react/index.mjs +1650 -759
- package/dist/render/index.d.mts +48 -0
- package/dist/render/index.d.ts +48 -0
- package/dist/render/index.js +1755 -773
- package/dist/render/index.mjs +1755 -773
- package/dist/server/index.js +29475 -18462
- package/dist/server/index.mjs +29475 -18462
- package/dist/server/mcp-worker.js +11319 -0
- package/dist/vue/index.js +1650 -759
- package/dist/vue/index.mjs +1650 -759
- package/package.json +14 -8
- package/schema/magic-editor-x.schema.json +135 -2
- package/types/blocks.d.ts +126 -0
- package/types/index.d.ts +52 -1
- package/types/math.d.ts +27 -0
- package/types/render.d.ts +48 -0
- package/dist/admin/index-DR8sHkTk.js +0 -1940
- package/dist/admin/index-My6FjjHB.mjs +0 -1939
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const ReactNamespace = require("react");
|
|
4
5
|
const designSystem = require("@strapi/design-system");
|
|
5
6
|
const admin = require("@strapi/strapi/admin");
|
|
6
7
|
const icons = require("@strapi/icons");
|
|
7
|
-
const index = require("./index-
|
|
8
|
-
const
|
|
9
|
-
const ConfirmAction = require("./ConfirmAction-
|
|
8
|
+
const index = require("./index-DRyctF9s.js");
|
|
9
|
+
const SectionCard = require("./SectionCard-Bs-xiiH1.js");
|
|
10
|
+
const ConfirmAction = require("./ConfirmAction-CUhpngYU.js");
|
|
10
11
|
const DraftSync = require("./DraftSync-BIA8cZgA.js");
|
|
11
|
-
const ReactNamespace = require("react");
|
|
12
12
|
const styled = require("styled-components");
|
|
13
|
+
const useT = require("./useT-Bpw__IXT.js");
|
|
14
|
+
const api = require("./api-4AYzwS4-.js");
|
|
13
15
|
const reactIntl = require("react-intl");
|
|
14
16
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
15
17
|
const styled__default = /* @__PURE__ */ _interopDefault(styled);
|
|
@@ -24,7 +26,7 @@ const PropertyList = ({ items }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
|
|
24
26
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { tag: "dt", minWidth: 0, flex: { initial: "0 0 auto", medium: "0 0 26rem" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: item.label }) }),
|
|
25
27
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { tag: "dd", margin: 0, minWidth: 0, flex: "1 1 auto", children: [
|
|
26
28
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", children: item.value }),
|
|
27
|
-
item.hint ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 1, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: item.hint }) }) : null
|
|
29
|
+
item.hint ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 1, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", style: { overflowWrap: "anywhere" }, children: item.hint }) }) : null
|
|
28
30
|
] })
|
|
29
31
|
]
|
|
30
32
|
},
|
|
@@ -204,7 +206,7 @@ const useConfigurationForm = () => {
|
|
|
204
206
|
};
|
|
205
207
|
}, []);
|
|
206
208
|
const fetchSettings = ReactNamespace.useCallback(
|
|
207
|
-
() => get(
|
|
209
|
+
() => get(api.API.settings).then(
|
|
208
210
|
({ data }) => {
|
|
209
211
|
if (!mounted.current) return;
|
|
210
212
|
const next = toDraft(data.data.ai, data.data.languageTool);
|
|
@@ -268,7 +270,7 @@ const useConfigurationForm = () => {
|
|
|
268
270
|
if (hasErrors) return { ok: false, invalid: true };
|
|
269
271
|
setSaving(true);
|
|
270
272
|
try {
|
|
271
|
-
const { data } = await put(
|
|
273
|
+
const { data } = await put(api.API.settings, toPayload(draft));
|
|
272
274
|
const stored = toDraft(data.data.ai, data.data.languageTool);
|
|
273
275
|
const adjusted = adjustedFields(draft, stored);
|
|
274
276
|
setDto(data.data);
|
|
@@ -278,7 +280,7 @@ const useConfigurationForm = () => {
|
|
|
278
280
|
setShowErrors(false);
|
|
279
281
|
return { ok: true, adjusted };
|
|
280
282
|
} catch (error) {
|
|
281
|
-
const info =
|
|
283
|
+
const info = api.readApiError(error);
|
|
282
284
|
setServerErrors(mapServerErrors(info.details));
|
|
283
285
|
return { ok: false, message: info.status === 400 ? null : info.message };
|
|
284
286
|
} finally {
|
|
@@ -301,10 +303,10 @@ const useConfigurationForm = () => {
|
|
|
301
303
|
try {
|
|
302
304
|
const payload = toPayload(draft);
|
|
303
305
|
if (draft.apiKeyMode === "remove") delete payload.ai.apiKey;
|
|
304
|
-
await post(
|
|
306
|
+
await post(api.API.settingsAiTest, payload);
|
|
305
307
|
return { ok: true };
|
|
306
308
|
} catch (error) {
|
|
307
|
-
const info =
|
|
309
|
+
const info = api.readApiError(error);
|
|
308
310
|
return { ok: false, code: info.code, status: info.status };
|
|
309
311
|
} finally {
|
|
310
312
|
if (mounted.current) setTesting(false);
|
|
@@ -322,10 +324,10 @@ const useConfigurationForm = () => {
|
|
|
322
324
|
try {
|
|
323
325
|
const payload = toLanguageToolPayload(lt);
|
|
324
326
|
if (lt.apiKeyMode === "remove") payload.apiKey = "";
|
|
325
|
-
await post(
|
|
327
|
+
await post(api.API.settingsLanguageToolTest, { languageTool: payload });
|
|
326
328
|
return { ok: true };
|
|
327
329
|
} catch (error) {
|
|
328
|
-
const info =
|
|
330
|
+
const info = api.readApiError(error);
|
|
329
331
|
return { ok: false, code: info.code, status: info.status };
|
|
330
332
|
} finally {
|
|
331
333
|
if (mounted.current) setTestingLanguageTool(false);
|
|
@@ -469,7 +471,7 @@ const AiSection = ({ form, readOnly, onTest }) => {
|
|
|
469
471
|
const defaults = dto.environment.defaults || { models: {}, baseUrls: {} };
|
|
470
472
|
const keyDisabled = readOnly || ai.apiKeyFromEnvironment || !ai.canStoreApiKey;
|
|
471
473
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
472
|
-
|
|
474
|
+
SectionCard.SectionCard,
|
|
473
475
|
{
|
|
474
476
|
title: t("settings.ai.title", "AI assistant"),
|
|
475
477
|
subtitle: t(
|
|
@@ -720,6 +722,25 @@ const EnvironmentSection = ({ environment }) => {
|
|
|
720
722
|
}[environment.rawHtml] || environment.rawHtml;
|
|
721
723
|
const collaboration = environment.collaboration || {};
|
|
722
724
|
const linkSchedule = environment.linkSchedule || null;
|
|
725
|
+
const privateImages = Array.isArray(environment.altTextPrivateOrigins) ? environment.altTextPrivateOrigins : [];
|
|
726
|
+
const mcp = environment.mcp || {};
|
|
727
|
+
let mcpHint;
|
|
728
|
+
if (mcp.active)
|
|
729
|
+
mcpHint = t(
|
|
730
|
+
"settings.environment.mcpOn",
|
|
731
|
+
'AI clients connect to {path} with an admin token. Give the token the permission "Use the MCP tools" under Plugins > Magic Editor X. The tools convert, check and render content; they never read or save entries.',
|
|
732
|
+
{ path: mcp.path || "/mcp" }
|
|
733
|
+
);
|
|
734
|
+
else if (mcp.enabled)
|
|
735
|
+
mcpHint = t(
|
|
736
|
+
"settings.environment.mcpServerOff",
|
|
737
|
+
"Turned on (mcp.enabled), but Strapi's MCP server is off. Set server.mcp.enabled to true in config/server and restart."
|
|
738
|
+
);
|
|
739
|
+
else
|
|
740
|
+
mcpHint = t(
|
|
741
|
+
"settings.environment.mcpOff",
|
|
742
|
+
"Turn on with mcp.enabled in config/plugins and server.mcp.enabled in config/server, then restart."
|
|
743
|
+
);
|
|
723
744
|
const lastRun = linkSchedule && linkSchedule.lastRun;
|
|
724
745
|
let linkScheduleHint;
|
|
725
746
|
if (linkSchedule && linkSchedule.enabled) {
|
|
@@ -749,7 +770,7 @@ const EnvironmentSection = ({ environment }) => {
|
|
|
749
770
|
linkScheduleHint = parts.join(" ");
|
|
750
771
|
}
|
|
751
772
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
752
|
-
|
|
773
|
+
SectionCard.SectionCard,
|
|
753
774
|
{
|
|
754
775
|
title: t("settings.environment.title", "Server configuration"),
|
|
755
776
|
subtitle: t(
|
|
@@ -797,6 +818,36 @@ const EnvironmentSection = ({ environment }) => {
|
|
|
797
818
|
value: on(Boolean(linkSchedule && linkSchedule.enabled)),
|
|
798
819
|
hint: linkScheduleHint
|
|
799
820
|
},
|
|
821
|
+
{
|
|
822
|
+
key: "privateImages",
|
|
823
|
+
label: t("settings.environment.privateImages", "Private image storage for alt text"),
|
|
824
|
+
value: privateImages.length ? t(
|
|
825
|
+
"settings.environment.privateImagesCount",
|
|
826
|
+
"{count, plural, =0 {Off} one {# origin} other {# origins}}",
|
|
827
|
+
{ count: privateImages.length }
|
|
828
|
+
) : on(false),
|
|
829
|
+
hint: privateImages.length ? t(
|
|
830
|
+
"settings.environment.privateImagesHint",
|
|
831
|
+
"Alt text suggestions may read images from {origins} (ai.altText.allowPrivateOrigins). Redirects are not followed.",
|
|
832
|
+
{ origins: privateImages.join(", ") }
|
|
833
|
+
) : t(
|
|
834
|
+
"settings.environment.privateImagesNone",
|
|
835
|
+
"Alt text suggestions read images from public addresses only. Self-hosted storage on a private network needs ai.altText.allowPrivateOrigins."
|
|
836
|
+
)
|
|
837
|
+
},
|
|
838
|
+
{
|
|
839
|
+
key: "mentionEmails",
|
|
840
|
+
label: t("settings.environment.mentionEmails", "E-mails for comment mentions"),
|
|
841
|
+
value: on(Boolean(environment.mentionEmails && environment.mentionEmails.enabled)),
|
|
842
|
+
hint: environment.mentionEmails && environment.mentionEmails.enabled ? t(
|
|
843
|
+
"settings.environment.mentionEmailsOn",
|
|
844
|
+
"People mentioned in a comment get an e-mail through the Strapi email plugin, at most {count} per hour. It names who mentioned them and links to the entry, never the comment text (comments.notifications.email).",
|
|
845
|
+
{ count: environment.mentionEmails.perHour ?? 10 }
|
|
846
|
+
) : t(
|
|
847
|
+
"settings.environment.mentionEmailsOff",
|
|
848
|
+
"Mentions show up in the admin only. Turn on e-mails with comments.notifications.email in config/plugins."
|
|
849
|
+
)
|
|
850
|
+
},
|
|
800
851
|
{
|
|
801
852
|
key: "privateAi",
|
|
802
853
|
label: t("settings.environment.privateAi", "Private AI hosts allowed"),
|
|
@@ -805,6 +856,13 @@ const EnvironmentSection = ({ environment }) => {
|
|
|
805
856
|
"settings.environment.privateAiHint",
|
|
806
857
|
"Needed for local models on localhost or a private network (ai.allowPrivateBaseUrl)."
|
|
807
858
|
)
|
|
859
|
+
},
|
|
860
|
+
// 2.5: MCP tools for AI clients (config only).
|
|
861
|
+
{
|
|
862
|
+
key: "mcp",
|
|
863
|
+
label: t("settings.environment.mcp", "Tools for AI clients (MCP)"),
|
|
864
|
+
value: on(Boolean(mcp.active)),
|
|
865
|
+
hint: mcpHint
|
|
808
866
|
}
|
|
809
867
|
]
|
|
810
868
|
}
|
|
@@ -812,7 +870,7 @@ const EnvironmentSection = ({ environment }) => {
|
|
|
812
870
|
}
|
|
813
871
|
);
|
|
814
872
|
};
|
|
815
|
-
const CodeBlock = styled__default.default.pre`
|
|
873
|
+
const CodeBlock$1 = styled__default.default.pre`
|
|
816
874
|
margin: 0;
|
|
817
875
|
max-width: 100%;
|
|
818
876
|
overflow-x: auto;
|
|
@@ -870,7 +928,7 @@ const CspSection = ({ csp }) => {
|
|
|
870
928
|
const allowed = t("settings.csp.allowed", "Allowed");
|
|
871
929
|
const codeLabel = t("settings.csp.codeLabel", "Snippet for config/middlewares.js");
|
|
872
930
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
873
|
-
|
|
931
|
+
SectionCard.SectionCard,
|
|
874
932
|
{
|
|
875
933
|
title: t("settings.csp.title", "Content Security Policy"),
|
|
876
934
|
subtitle: t(
|
|
@@ -920,7 +978,7 @@ const CspSection = ({ csp }) => {
|
|
|
920
978
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", id: "mex-csp-snippet-label", children: codeLabel }),
|
|
921
979
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.IconButton, { label: t("settings.csp.copy", "Copy the snippet"), variant: "tertiary", onClick: onCopy, children: /* @__PURE__ */ jsxRuntime.jsx(icons.Duplicate, {}) })
|
|
922
980
|
] }),
|
|
923
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { minWidth: 0, children: /* @__PURE__ */ jsxRuntime.jsx(CodeBlock, { ref: codeRef, tabIndex: 0, "aria-labelledby": "mex-csp-snippet-label", children: /* @__PURE__ */ jsxRuntime.jsx("code", { children: csp.snippet }) }) }),
|
|
981
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { minWidth: 0, children: /* @__PURE__ */ jsxRuntime.jsx(CodeBlock$1, { ref: codeRef, tabIndex: 0, "aria-labelledby": "mex-csp-snippet-label", children: /* @__PURE__ */ jsxRuntime.jsx("code", { children: csp.snippet }) }) }),
|
|
924
982
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t(
|
|
925
983
|
"settings.csp.mergeHint",
|
|
926
984
|
"Keep your other directives (for example the hosts of your upload provider) and restart Strapi after the change."
|
|
@@ -930,6 +988,159 @@ const CspSection = ({ csp }) => {
|
|
|
930
988
|
}
|
|
931
989
|
);
|
|
932
990
|
};
|
|
991
|
+
const Swatch = styled__default.default.span`
|
|
992
|
+
display: inline-block;
|
|
993
|
+
flex: 0 0 auto;
|
|
994
|
+
width: 2.4rem;
|
|
995
|
+
height: 2.4rem;
|
|
996
|
+
border-radius: ${({ theme }) => theme.borderRadius};
|
|
997
|
+
border: 1px solid ${({ theme }) => theme.colors.neutral300};
|
|
998
|
+
background: ${({ $color }) => index.isHexColor($color) ? $color : "transparent"};
|
|
999
|
+
`;
|
|
1000
|
+
const CodeBlock = styled__default.default.pre`
|
|
1001
|
+
margin: 0;
|
|
1002
|
+
max-width: 100%;
|
|
1003
|
+
max-height: 24rem;
|
|
1004
|
+
overflow: auto;
|
|
1005
|
+
padding: ${({ theme }) => theme.spaces[4]};
|
|
1006
|
+
border: 1px solid ${({ theme }) => theme.colors.neutral200};
|
|
1007
|
+
border-radius: ${({ theme }) => theme.borderRadius};
|
|
1008
|
+
background: ${({ theme }) => theme.colors.neutral100};
|
|
1009
|
+
color: ${({ theme }) => theme.colors.neutral800};
|
|
1010
|
+
font-family: 'SF Mono', SFMono-Regular, ui-monospace, Menlo, Consolas, monospace;
|
|
1011
|
+
font-size: ${({ theme }) => theme.fontSizes[1]};
|
|
1012
|
+
line-height: 1.6;
|
|
1013
|
+
white-space: pre;
|
|
1014
|
+
|
|
1015
|
+
&:focus-visible {
|
|
1016
|
+
outline: 2px solid ${({ theme }) => theme.colors.primary600};
|
|
1017
|
+
outline-offset: 2px;
|
|
1018
|
+
}
|
|
1019
|
+
`;
|
|
1020
|
+
const TokenList = styled__default.default.ul`
|
|
1021
|
+
margin: 0;
|
|
1022
|
+
padding: 0;
|
|
1023
|
+
list-style: none;
|
|
1024
|
+
display: grid;
|
|
1025
|
+
grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr));
|
|
1026
|
+
gap: ${({ theme }) => theme.spaces[3]};
|
|
1027
|
+
`;
|
|
1028
|
+
const TokenItem = ({ token, locale, t }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { tag: "li", minWidth: 0, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", minWidth: 0, children: [
|
|
1029
|
+
/* @__PURE__ */ jsxRuntime.jsx(Swatch, { $color: token.light, title: t("settings.palette.light", "Light theme"), "aria-hidden": "true" }),
|
|
1030
|
+
/* @__PURE__ */ jsxRuntime.jsx(Swatch, { $color: token.dark, title: t("settings.palette.dark", "Dark theme"), "aria-hidden": "true" }),
|
|
1031
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", minWidth: 0, children: [
|
|
1032
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "semiBold", textColor: "neutral800", children: index.tokenLabel(token, locale) }),
|
|
1033
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", style: { overflowWrap: "anywhere" }, children: [
|
|
1034
|
+
token.name,
|
|
1035
|
+
" · ",
|
|
1036
|
+
token.light,
|
|
1037
|
+
" / ",
|
|
1038
|
+
token.dark
|
|
1039
|
+
] })
|
|
1040
|
+
] })
|
|
1041
|
+
] }) });
|
|
1042
|
+
const PaletteSection = ({ palette }) => {
|
|
1043
|
+
const t = useT.useT();
|
|
1044
|
+
const { locale } = reactIntl.useIntl();
|
|
1045
|
+
const { copy } = admin.useClipboard();
|
|
1046
|
+
const codeRef = ReactNamespace.useRef(null);
|
|
1047
|
+
const [alertOpen, setAlertOpen] = ReactNamespace.useState(true);
|
|
1048
|
+
if (!palette) return null;
|
|
1049
|
+
const colors = Array.isArray(palette.colors) ? palette.colors : [];
|
|
1050
|
+
const highlights = Array.isArray(palette.highlights) ? palette.highlights : [];
|
|
1051
|
+
const issues = Array.isArray(palette.issues) ? palette.issues : [];
|
|
1052
|
+
const annotations = Array.isArray(palette.annotations) ? palette.annotations : [];
|
|
1053
|
+
const empty = !colors.length && !highlights.length;
|
|
1054
|
+
const pairText = (issue) => t(
|
|
1055
|
+
"settings.palette.issue",
|
|
1056
|
+
"{mode, select, dark {Dark theme} other {Light theme}}: {pair} has contrast {ratio}:1 (needs 4.5:1)",
|
|
1057
|
+
{
|
|
1058
|
+
mode: issue.mode,
|
|
1059
|
+
pair: `${issue.color || t("settings.palette.defaultText", "default text")} / ${issue.highlight || t("settings.palette.page", "page background")}`,
|
|
1060
|
+
ratio: issue.ratio
|
|
1061
|
+
}
|
|
1062
|
+
);
|
|
1063
|
+
const onCopy = async () => {
|
|
1064
|
+
if (!await copy(palette.css) && codeRef.current) {
|
|
1065
|
+
const range = document.createRange();
|
|
1066
|
+
range.selectNodeContents(codeRef.current);
|
|
1067
|
+
const selection = window.getSelection();
|
|
1068
|
+
selection.removeAllRanges();
|
|
1069
|
+
selection.addRange(range);
|
|
1070
|
+
codeRef.current.focus();
|
|
1071
|
+
}
|
|
1072
|
+
};
|
|
1073
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1074
|
+
SectionCard.SectionCard,
|
|
1075
|
+
{
|
|
1076
|
+
title: t("settings.palette.title", "Text colours and highlights"),
|
|
1077
|
+
subtitle: t(
|
|
1078
|
+
"settings.palette.subtitle",
|
|
1079
|
+
'Defined in the plugin configuration (config/plugins.js, key palette). Fields offer them when the field option "Text colour and highlight" is on.'
|
|
1080
|
+
),
|
|
1081
|
+
children: [
|
|
1082
|
+
empty ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral600", children: t(
|
|
1083
|
+
"settings.palette.empty",
|
|
1084
|
+
"No palette is configured, so editors see no colour tool. Ask your developer to add colour tokens to the plugin configuration."
|
|
1085
|
+
) }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1086
|
+
issues.length && alertOpen ? (
|
|
1087
|
+
// The Alert renders its children inside a paragraph: the list follows it (no <ul> in <p>).
|
|
1088
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
|
1089
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1090
|
+
designSystem.Alert,
|
|
1091
|
+
{
|
|
1092
|
+
variant: "warning",
|
|
1093
|
+
closeLabel: t("settings.close", "Close"),
|
|
1094
|
+
onClose: () => setAlertOpen(false),
|
|
1095
|
+
children: t(
|
|
1096
|
+
"settings.palette.issuesTitle",
|
|
1097
|
+
"{count, plural, one {# combination is} other {# combinations are}} hard to read",
|
|
1098
|
+
{ count: issues.length }
|
|
1099
|
+
)
|
|
1100
|
+
}
|
|
1101
|
+
),
|
|
1102
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { tag: "ul", paddingLeft: 4, margin: 0, children: issues.slice(0, 20).map((issue) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1103
|
+
designSystem.Typography,
|
|
1104
|
+
{
|
|
1105
|
+
tag: "li",
|
|
1106
|
+
variant: "omega",
|
|
1107
|
+
children: pairText(issue)
|
|
1108
|
+
},
|
|
1109
|
+
`${issue.mode}|${issue.color}|${issue.highlight}`
|
|
1110
|
+
)) })
|
|
1111
|
+
] })
|
|
1112
|
+
) : null,
|
|
1113
|
+
colors.length ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
|
1114
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", tag: "h3", children: t("settings.palette.colors", "Text colours") }),
|
|
1115
|
+
/* @__PURE__ */ jsxRuntime.jsx(TokenList, { children: colors.map((token) => /* @__PURE__ */ jsxRuntime.jsx(TokenItem, { token, locale, t }, token.name)) })
|
|
1116
|
+
] }) : null,
|
|
1117
|
+
highlights.length ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
|
1118
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", tag: "h3", children: t("settings.palette.highlights", "Highlights") }),
|
|
1119
|
+
/* @__PURE__ */ jsxRuntime.jsx(TokenList, { children: highlights.map((token) => /* @__PURE__ */ jsxRuntime.jsx(TokenItem, { token, locale, t }, token.name)) })
|
|
1120
|
+
] }) : null,
|
|
1121
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, minWidth: 0, children: [
|
|
1122
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", gap: 2, wrap: "wrap", children: [
|
|
1123
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", id: "mex-palette-css-label", tag: "h3", children: t("settings.palette.css", "CSS for your site") }),
|
|
1124
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1125
|
+
designSystem.IconButton,
|
|
1126
|
+
{
|
|
1127
|
+
label: t("settings.palette.copy", "Copy the CSS"),
|
|
1128
|
+
variant: "tertiary",
|
|
1129
|
+
onClick: onCopy,
|
|
1130
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Duplicate, {})
|
|
1131
|
+
}
|
|
1132
|
+
)
|
|
1133
|
+
] }),
|
|
1134
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { minWidth: 0, children: /* @__PURE__ */ jsxRuntime.jsx(CodeBlock, { ref: codeRef, tabIndex: 0, "aria-labelledby": "mex-palette-css-label", children: /* @__PURE__ */ jsxRuntime.jsx("code", { children: palette.css }) }) })
|
|
1135
|
+
] })
|
|
1136
|
+
] }),
|
|
1137
|
+
annotations.length ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t("settings.palette.annotations", 'Annotations for the field option "Annotations": {names}', {
|
|
1138
|
+
names: annotations.map((item) => item.name).join(", ")
|
|
1139
|
+
}) }) : null
|
|
1140
|
+
]
|
|
1141
|
+
}
|
|
1142
|
+
);
|
|
1143
|
+
};
|
|
933
1144
|
const hostOf = (t, baseUrl) => {
|
|
934
1145
|
try {
|
|
935
1146
|
return new URL(baseUrl).host || t("settings.languageTool.server", "the LanguageTool server");
|
|
@@ -959,7 +1170,7 @@ const LanguageToolSection = ({ form, readOnly, onTest }) => {
|
|
|
959
1170
|
keyLabel = t("settings.ai.key.status.stored", "Stored, encrypted");
|
|
960
1171
|
}
|
|
961
1172
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
962
|
-
|
|
1173
|
+
SectionCard.SectionCard,
|
|
963
1174
|
{
|
|
964
1175
|
title: t("settings.languageTool.title", "Grammar check (LanguageTool)"),
|
|
965
1176
|
subtitle: t(
|
|
@@ -1121,6 +1332,172 @@ const LanguageToolSection = ({ form, readOnly, onTest }) => {
|
|
|
1121
1332
|
}
|
|
1122
1333
|
);
|
|
1123
1334
|
};
|
|
1335
|
+
const POLL_MS = 3e3;
|
|
1336
|
+
const MAX_POLLS = 300;
|
|
1337
|
+
const LinkScheduleSection = ({ initial, canRun, onStatus }) => {
|
|
1338
|
+
const t = useT.useT();
|
|
1339
|
+
const { formatDate } = reactIntl.useIntl();
|
|
1340
|
+
const { get, post } = admin.useFetchClient();
|
|
1341
|
+
const [status, setStatus] = ReactNamespace.useState(initial);
|
|
1342
|
+
const [starting, setStarting] = ReactNamespace.useState(false);
|
|
1343
|
+
const [notice, setNotice] = ReactNamespace.useState(null);
|
|
1344
|
+
const [announcement, setAnnouncement] = ReactNamespace.useState("");
|
|
1345
|
+
const polls = ReactNamespace.useRef(0);
|
|
1346
|
+
const timer = ReactNamespace.useRef(null);
|
|
1347
|
+
const wasRunning = ReactNamespace.useRef(Boolean(initial && initial.running));
|
|
1348
|
+
const refresh = ReactNamespace.useCallback(async () => {
|
|
1349
|
+
try {
|
|
1350
|
+
const { data } = await get(api.API.linkSchedule);
|
|
1351
|
+
const next = data.data;
|
|
1352
|
+
setStatus(next);
|
|
1353
|
+
if (wasRunning.current && !next.running) {
|
|
1354
|
+
setAnnouncement(t("settings.linkRun.finished", "The link check finished."));
|
|
1355
|
+
setNotice(null);
|
|
1356
|
+
}
|
|
1357
|
+
wasRunning.current = Boolean(next.running);
|
|
1358
|
+
return next;
|
|
1359
|
+
} catch {
|
|
1360
|
+
return null;
|
|
1361
|
+
}
|
|
1362
|
+
}, [get, t]);
|
|
1363
|
+
const running = Boolean(status && status.running);
|
|
1364
|
+
ReactNamespace.useEffect(() => {
|
|
1365
|
+
if (onStatus && status && status !== initial) onStatus(status);
|
|
1366
|
+
}, [status, initial, onStatus]);
|
|
1367
|
+
ReactNamespace.useEffect(() => {
|
|
1368
|
+
if (!running) {
|
|
1369
|
+
polls.current = 0;
|
|
1370
|
+
return void 0;
|
|
1371
|
+
}
|
|
1372
|
+
timer.current = window.setTimeout(async () => {
|
|
1373
|
+
polls.current += 1;
|
|
1374
|
+
if (polls.current > MAX_POLLS) {
|
|
1375
|
+
setNotice({
|
|
1376
|
+
variant: "default",
|
|
1377
|
+
text: t(
|
|
1378
|
+
"settings.linkRun.stillRunning",
|
|
1379
|
+
"The check is still running. Reload the page later to see the result."
|
|
1380
|
+
)
|
|
1381
|
+
});
|
|
1382
|
+
return;
|
|
1383
|
+
}
|
|
1384
|
+
await refresh();
|
|
1385
|
+
}, POLL_MS);
|
|
1386
|
+
return () => window.clearTimeout(timer.current);
|
|
1387
|
+
}, [running, status, refresh, t]);
|
|
1388
|
+
if (!status || !status.enabled) return null;
|
|
1389
|
+
const runNow = async () => {
|
|
1390
|
+
setStarting(true);
|
|
1391
|
+
setNotice(null);
|
|
1392
|
+
setAnnouncement("");
|
|
1393
|
+
try {
|
|
1394
|
+
await post(api.API.linkScheduleRun, {});
|
|
1395
|
+
setAnnouncement(t("settings.linkRun.started", "The link check started."));
|
|
1396
|
+
wasRunning.current = true;
|
|
1397
|
+
setStatus((current) => ({ ...current, running: true }));
|
|
1398
|
+
} catch (error) {
|
|
1399
|
+
const info = api.readApiError(error);
|
|
1400
|
+
if (info.status === 409) {
|
|
1401
|
+
setNotice({
|
|
1402
|
+
variant: "default",
|
|
1403
|
+
text: t(
|
|
1404
|
+
"settings.linkRun.conflict",
|
|
1405
|
+
"A link check is already running. The result appears here when it finishes."
|
|
1406
|
+
)
|
|
1407
|
+
});
|
|
1408
|
+
wasRunning.current = true;
|
|
1409
|
+
setStatus((current) => ({ ...current, running: true }));
|
|
1410
|
+
} else if (info.status === 400 && info.code === "DISABLED") {
|
|
1411
|
+
setNotice({
|
|
1412
|
+
variant: "warning",
|
|
1413
|
+
text: t(
|
|
1414
|
+
"settings.linkRun.disabled",
|
|
1415
|
+
"Scheduled link checks are turned off in config/plugins.js (qualityChecks.externalLinks.schedule)."
|
|
1416
|
+
)
|
|
1417
|
+
});
|
|
1418
|
+
} else {
|
|
1419
|
+
setNotice({
|
|
1420
|
+
variant: "danger",
|
|
1421
|
+
text: t("settings.linkRun.failed", "The link check could not be started. Try again.")
|
|
1422
|
+
});
|
|
1423
|
+
}
|
|
1424
|
+
} finally {
|
|
1425
|
+
setStarting(false);
|
|
1426
|
+
}
|
|
1427
|
+
};
|
|
1428
|
+
const date = (value) => value ? formatDate(new Date(value), { dateStyle: "medium", timeStyle: "short" }) : "";
|
|
1429
|
+
const lastRun = status.lastRun;
|
|
1430
|
+
const zone = status.tz || t("settings.linkRun.serverZone", "Server time zone");
|
|
1431
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1432
|
+
SectionCard.SectionCard,
|
|
1433
|
+
{
|
|
1434
|
+
title: t("settings.linkRun.title", "Scheduled link check"),
|
|
1435
|
+
subtitle: t(
|
|
1436
|
+
"settings.linkRun.subtitle",
|
|
1437
|
+
"Checks every external link in all editor fields on a schedule. You can also start a check now."
|
|
1438
|
+
),
|
|
1439
|
+
action: canRun ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1440
|
+
designSystem.Button,
|
|
1441
|
+
{
|
|
1442
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Play, {}),
|
|
1443
|
+
variant: "secondary",
|
|
1444
|
+
onClick: runNow,
|
|
1445
|
+
loading: starting,
|
|
1446
|
+
disabled: starting || running,
|
|
1447
|
+
children: running ? t("settings.linkRun.running", "Check running") : t("settings.linkRun.run", "Run now")
|
|
1448
|
+
}
|
|
1449
|
+
) : null,
|
|
1450
|
+
children: [
|
|
1451
|
+
!canRun ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t("settings.linkRun.noPermission", 'Starting a check needs the "Update settings" permission.') }) : null,
|
|
1452
|
+
notice ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1453
|
+
designSystem.Alert,
|
|
1454
|
+
{
|
|
1455
|
+
variant: notice.variant,
|
|
1456
|
+
closeLabel: t("settings.close", "Close"),
|
|
1457
|
+
onClose: () => setNotice(null),
|
|
1458
|
+
children: notice.text
|
|
1459
|
+
}
|
|
1460
|
+
) : null,
|
|
1461
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1462
|
+
PropertyList,
|
|
1463
|
+
{
|
|
1464
|
+
items: [
|
|
1465
|
+
{
|
|
1466
|
+
key: "state",
|
|
1467
|
+
label: t("settings.linkRun.state", "State"),
|
|
1468
|
+
value: running ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "primary100", textColor: "primary700", children: t("settings.linkRun.running", "Check running") }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "neutral150", textColor: "neutral700", children: t("settings.linkRun.idle", "Idle") })
|
|
1469
|
+
},
|
|
1470
|
+
{
|
|
1471
|
+
key: "rule",
|
|
1472
|
+
label: t("settings.linkRun.rule", "Schedule"),
|
|
1473
|
+
value: t("settings.linkRun.ruleValue", "{rule} ({zone})", { rule: status.rule || "", zone }),
|
|
1474
|
+
hint: status.nextRunAt ? t("settings.linkRun.next", "Next run {date}", { date: date(status.nextRunAt) }) : void 0
|
|
1475
|
+
},
|
|
1476
|
+
{
|
|
1477
|
+
key: "last",
|
|
1478
|
+
label: t("settings.linkRun.last", "Last run"),
|
|
1479
|
+
value: lastRun ? t(
|
|
1480
|
+
"settings.linkRun.lastValue",
|
|
1481
|
+
"{date}: {checked, number} links checked, {problems, number} with problems.",
|
|
1482
|
+
{
|
|
1483
|
+
date: date(lastRun.finishedAt),
|
|
1484
|
+
checked: lastRun.checked ?? 0,
|
|
1485
|
+
problems: lastRun.problems ?? 0
|
|
1486
|
+
}
|
|
1487
|
+
) : t("settings.environment.linkScheduleNever", "No run yet."),
|
|
1488
|
+
hint: lastRun && !lastRun.complete ? t(
|
|
1489
|
+
"settings.environment.linkScheduleIncomplete",
|
|
1490
|
+
"The last run did not finish; results of earlier runs were kept."
|
|
1491
|
+
) : void 0
|
|
1492
|
+
}
|
|
1493
|
+
]
|
|
1494
|
+
}
|
|
1495
|
+
),
|
|
1496
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { "aria-live": "polite", role: "status", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: announcement }) })
|
|
1497
|
+
]
|
|
1498
|
+
}
|
|
1499
|
+
);
|
|
1500
|
+
};
|
|
1124
1501
|
const RBAC = [...index.PERMISSIONS.settingsRead, ...index.PERMISSIONS.settingsUpdate];
|
|
1125
1502
|
const testErrorText = (t, code) => {
|
|
1126
1503
|
switch (code) {
|
|
@@ -1170,6 +1547,7 @@ const ConfigurationPage = () => {
|
|
|
1170
1547
|
const { allowedActions, isLoading: rbacLoading } = admin.useRBAC(RBAC);
|
|
1171
1548
|
const form = useConfigurationForm();
|
|
1172
1549
|
const title = t("settings.configuration.title", "Configuration");
|
|
1550
|
+
const [liveSchedule, setLiveSchedule] = ReactNamespace.useState(null);
|
|
1173
1551
|
if (rbacLoading || form.status === "loading") {
|
|
1174
1552
|
return /* @__PURE__ */ jsxRuntime.jsxs(admin.Page.Main, { children: [
|
|
1175
1553
|
/* @__PURE__ */ jsxRuntime.jsx(admin.Page.Title, { children: title }),
|
|
@@ -1255,7 +1633,7 @@ const ConfigurationPage = () => {
|
|
|
1255
1633
|
}
|
|
1256
1634
|
};
|
|
1257
1635
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1258
|
-
|
|
1636
|
+
SectionCard.PageShell,
|
|
1259
1637
|
{
|
|
1260
1638
|
title,
|
|
1261
1639
|
subtitle: readOnly ? t(
|
|
@@ -1303,8 +1681,25 @@ const ConfigurationPage = () => {
|
|
|
1303
1681
|
) : null,
|
|
1304
1682
|
/* @__PURE__ */ jsxRuntime.jsx(AiSection, { form, readOnly, onTest }),
|
|
1305
1683
|
/* @__PURE__ */ jsxRuntime.jsx(LanguageToolSection, { form, readOnly, onTest: onTestLanguageTool }),
|
|
1306
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1684
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1685
|
+
EnvironmentSection,
|
|
1686
|
+
{
|
|
1687
|
+
environment: liveSchedule && form.dto.environment ? {
|
|
1688
|
+
...form.dto.environment,
|
|
1689
|
+
linkSchedule: { ...form.dto.environment.linkSchedule, ...liveSchedule }
|
|
1690
|
+
} : form.dto.environment
|
|
1691
|
+
}
|
|
1692
|
+
),
|
|
1693
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1694
|
+
LinkScheduleSection,
|
|
1695
|
+
{
|
|
1696
|
+
initial: form.dto.environment && form.dto.environment.linkSchedule || null,
|
|
1697
|
+
canRun: !readOnly,
|
|
1698
|
+
onStatus: setLiveSchedule
|
|
1699
|
+
}
|
|
1700
|
+
),
|
|
1307
1701
|
/* @__PURE__ */ jsxRuntime.jsx(CspSection, { csp: form.dto.environment && form.dto.environment.csp }),
|
|
1702
|
+
/* @__PURE__ */ jsxRuntime.jsx(PaletteSection, { palette: form.dto.environment && form.dto.environment.palette }),
|
|
1308
1703
|
/* @__PURE__ */ jsxRuntime.jsxs(admin.Form, { method: "PUT", initialValues: form.saved, children: [
|
|
1309
1704
|
/* @__PURE__ */ jsxRuntime.jsx(DraftSync.DraftSync, { values: form.draft }),
|
|
1310
1705
|
/* @__PURE__ */ jsxRuntime.jsx(admin.Blocker, {})
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
const canTakeFocus = (el) => Boolean(
|
|
7
|
+
el && el.isConnected && typeof el.focus === "function" && !el.disabled && (typeof el.getAttribute !== "function" || el.getAttribute("aria-disabled") !== "true")
|
|
8
|
+
);
|
|
9
|
+
const pickFocusTarget = (opener, fallback) => {
|
|
10
|
+
if (canTakeFocus(opener)) return opener;
|
|
11
|
+
if (canTakeFocus(fallback)) return fallback;
|
|
12
|
+
return null;
|
|
13
|
+
};
|
|
14
|
+
const refocusIfLost = (opener, fallback, doc = globalThis.document) => {
|
|
15
|
+
if (!doc) return;
|
|
16
|
+
const active = doc.activeElement;
|
|
17
|
+
if (active && active !== doc.body) return;
|
|
18
|
+
const target = pickFocusTarget(opener, fallback);
|
|
19
|
+
if (target) target.focus();
|
|
20
|
+
};
|
|
21
|
+
const ConfirmAction = ({
|
|
22
|
+
trigger,
|
|
23
|
+
title,
|
|
24
|
+
body,
|
|
25
|
+
confirmLabel,
|
|
26
|
+
onConfirm,
|
|
27
|
+
variant = "danger",
|
|
28
|
+
disabled = false,
|
|
29
|
+
fallbackFocusRef
|
|
30
|
+
}) => {
|
|
31
|
+
const [open, setOpen] = ReactNamespace.useState(false);
|
|
32
|
+
const [busy, setBusy] = ReactNamespace.useState(false);
|
|
33
|
+
const triggerRef = ReactNamespace.useRef(null);
|
|
34
|
+
const restoreFocus = () => requestAnimationFrame(() => {
|
|
35
|
+
const active = document.activeElement;
|
|
36
|
+
if (active && active !== document.body) return;
|
|
37
|
+
const target = pickFocusTarget(triggerRef.current, fallbackFocusRef && fallbackFocusRef.current);
|
|
38
|
+
if (target) target.focus();
|
|
39
|
+
});
|
|
40
|
+
const onOpenChange = (next) => {
|
|
41
|
+
if (busy) return;
|
|
42
|
+
setOpen(next);
|
|
43
|
+
if (!next) restoreFocus();
|
|
44
|
+
};
|
|
45
|
+
const confirm = async (event) => {
|
|
46
|
+
if (event && typeof event.preventDefault === "function") event.preventDefault();
|
|
47
|
+
setBusy(true);
|
|
48
|
+
try {
|
|
49
|
+
await onConfirm();
|
|
50
|
+
setOpen(false);
|
|
51
|
+
restoreFocus();
|
|
52
|
+
} catch {
|
|
53
|
+
} finally {
|
|
54
|
+
setBusy(false);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Root, { open, onOpenChange, children: [
|
|
58
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Trigger, { ref: triggerRef, disabled, children: trigger }),
|
|
59
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
60
|
+
admin.ConfirmDialog,
|
|
61
|
+
{
|
|
62
|
+
title,
|
|
63
|
+
variant,
|
|
64
|
+
endAction: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { fullWidth: true, variant, onClick: confirm, loading: busy, disabled: busy, children: confirmLabel }),
|
|
65
|
+
children: body
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
] });
|
|
69
|
+
};
|
|
70
|
+
exports.ConfirmAction = ConfirmAction;
|
|
71
|
+
exports.refocusIfLost = refocusIfLost;
|