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,13 +1,15 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useRef, useEffect, useCallback, useMemo } from "react";
|
|
2
3
|
import { Box, Flex, Typography, Switch, Grid, Field, SingleSelect, SingleSelectOption, TextInput, TextButton, NumberInput, Button, Badge, Alert, IconButton } from "@strapi/design-system";
|
|
3
4
|
import { useFetchClient, useClipboard, useNotification, useRBAC, Page, Form, Blocker } from "@strapi/strapi/admin";
|
|
4
|
-
import { Duplicate, Check } from "@strapi/icons";
|
|
5
|
-
import { P as PERMISSIONS } from "./index-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { Duplicate, Play, Check } from "@strapi/icons";
|
|
6
|
+
import { t as tokenLabel, i as isHexColor, P as PERMISSIONS } from "./index-CMYCZWOh.mjs";
|
|
7
|
+
import { S as SectionCard, P as PageShell } from "./SectionCard-8ZNHkvn9.mjs";
|
|
8
|
+
import { C as ConfirmAction } from "./ConfirmAction-CZjpduc3.mjs";
|
|
8
9
|
import { D as DraftSync } from "./DraftSync-CUxOMG-E.mjs";
|
|
9
|
-
import { useState, useRef, useEffect, useCallback, useMemo } from "react";
|
|
10
10
|
import styled from "styled-components";
|
|
11
|
+
import { u as useT } from "./useT-Cb-R3kyA.mjs";
|
|
12
|
+
import { A as API, r as readApiError } from "./api-CcTYyckq.mjs";
|
|
11
13
|
import { useIntl } from "react-intl";
|
|
12
14
|
const PropertyList = ({ items }) => /* @__PURE__ */ jsx(Box, { tag: "dl", margin: 0, children: /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 3, children: items.map((item) => /* @__PURE__ */ jsxs(
|
|
13
15
|
Flex,
|
|
@@ -20,7 +22,7 @@ const PropertyList = ({ items }) => /* @__PURE__ */ jsx(Box, { tag: "dl", margin
|
|
|
20
22
|
/* @__PURE__ */ jsx(Box, { tag: "dt", minWidth: 0, flex: { initial: "0 0 auto", medium: "0 0 26rem" }, children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", children: item.label }) }),
|
|
21
23
|
/* @__PURE__ */ jsxs(Box, { tag: "dd", margin: 0, minWidth: 0, flex: "1 1 auto", children: [
|
|
22
24
|
/* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral800", children: item.value }),
|
|
23
|
-
item.hint ? /* @__PURE__ */ jsx(Box, { paddingTop: 1, children: /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: item.hint }) }) : null
|
|
25
|
+
item.hint ? /* @__PURE__ */ jsx(Box, { paddingTop: 1, children: /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { overflowWrap: "anywhere" }, children: item.hint }) }) : null
|
|
24
26
|
] })
|
|
25
27
|
]
|
|
26
28
|
},
|
|
@@ -716,6 +718,25 @@ const EnvironmentSection = ({ environment }) => {
|
|
|
716
718
|
}[environment.rawHtml] || environment.rawHtml;
|
|
717
719
|
const collaboration = environment.collaboration || {};
|
|
718
720
|
const linkSchedule = environment.linkSchedule || null;
|
|
721
|
+
const privateImages = Array.isArray(environment.altTextPrivateOrigins) ? environment.altTextPrivateOrigins : [];
|
|
722
|
+
const mcp = environment.mcp || {};
|
|
723
|
+
let mcpHint;
|
|
724
|
+
if (mcp.active)
|
|
725
|
+
mcpHint = t(
|
|
726
|
+
"settings.environment.mcpOn",
|
|
727
|
+
'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.',
|
|
728
|
+
{ path: mcp.path || "/mcp" }
|
|
729
|
+
);
|
|
730
|
+
else if (mcp.enabled)
|
|
731
|
+
mcpHint = t(
|
|
732
|
+
"settings.environment.mcpServerOff",
|
|
733
|
+
"Turned on (mcp.enabled), but Strapi's MCP server is off. Set server.mcp.enabled to true in config/server and restart."
|
|
734
|
+
);
|
|
735
|
+
else
|
|
736
|
+
mcpHint = t(
|
|
737
|
+
"settings.environment.mcpOff",
|
|
738
|
+
"Turn on with mcp.enabled in config/plugins and server.mcp.enabled in config/server, then restart."
|
|
739
|
+
);
|
|
719
740
|
const lastRun = linkSchedule && linkSchedule.lastRun;
|
|
720
741
|
let linkScheduleHint;
|
|
721
742
|
if (linkSchedule && linkSchedule.enabled) {
|
|
@@ -793,6 +814,36 @@ const EnvironmentSection = ({ environment }) => {
|
|
|
793
814
|
value: on(Boolean(linkSchedule && linkSchedule.enabled)),
|
|
794
815
|
hint: linkScheduleHint
|
|
795
816
|
},
|
|
817
|
+
{
|
|
818
|
+
key: "privateImages",
|
|
819
|
+
label: t("settings.environment.privateImages", "Private image storage for alt text"),
|
|
820
|
+
value: privateImages.length ? t(
|
|
821
|
+
"settings.environment.privateImagesCount",
|
|
822
|
+
"{count, plural, =0 {Off} one {# origin} other {# origins}}",
|
|
823
|
+
{ count: privateImages.length }
|
|
824
|
+
) : on(false),
|
|
825
|
+
hint: privateImages.length ? t(
|
|
826
|
+
"settings.environment.privateImagesHint",
|
|
827
|
+
"Alt text suggestions may read images from {origins} (ai.altText.allowPrivateOrigins). Redirects are not followed.",
|
|
828
|
+
{ origins: privateImages.join(", ") }
|
|
829
|
+
) : t(
|
|
830
|
+
"settings.environment.privateImagesNone",
|
|
831
|
+
"Alt text suggestions read images from public addresses only. Self-hosted storage on a private network needs ai.altText.allowPrivateOrigins."
|
|
832
|
+
)
|
|
833
|
+
},
|
|
834
|
+
{
|
|
835
|
+
key: "mentionEmails",
|
|
836
|
+
label: t("settings.environment.mentionEmails", "E-mails for comment mentions"),
|
|
837
|
+
value: on(Boolean(environment.mentionEmails && environment.mentionEmails.enabled)),
|
|
838
|
+
hint: environment.mentionEmails && environment.mentionEmails.enabled ? t(
|
|
839
|
+
"settings.environment.mentionEmailsOn",
|
|
840
|
+
"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).",
|
|
841
|
+
{ count: environment.mentionEmails.perHour ?? 10 }
|
|
842
|
+
) : t(
|
|
843
|
+
"settings.environment.mentionEmailsOff",
|
|
844
|
+
"Mentions show up in the admin only. Turn on e-mails with comments.notifications.email in config/plugins."
|
|
845
|
+
)
|
|
846
|
+
},
|
|
796
847
|
{
|
|
797
848
|
key: "privateAi",
|
|
798
849
|
label: t("settings.environment.privateAi", "Private AI hosts allowed"),
|
|
@@ -801,6 +852,13 @@ const EnvironmentSection = ({ environment }) => {
|
|
|
801
852
|
"settings.environment.privateAiHint",
|
|
802
853
|
"Needed for local models on localhost or a private network (ai.allowPrivateBaseUrl)."
|
|
803
854
|
)
|
|
855
|
+
},
|
|
856
|
+
// 2.5: MCP tools for AI clients (config only).
|
|
857
|
+
{
|
|
858
|
+
key: "mcp",
|
|
859
|
+
label: t("settings.environment.mcp", "Tools for AI clients (MCP)"),
|
|
860
|
+
value: on(Boolean(mcp.active)),
|
|
861
|
+
hint: mcpHint
|
|
804
862
|
}
|
|
805
863
|
]
|
|
806
864
|
}
|
|
@@ -808,7 +866,7 @@ const EnvironmentSection = ({ environment }) => {
|
|
|
808
866
|
}
|
|
809
867
|
);
|
|
810
868
|
};
|
|
811
|
-
const CodeBlock = styled.pre`
|
|
869
|
+
const CodeBlock$1 = styled.pre`
|
|
812
870
|
margin: 0;
|
|
813
871
|
max-width: 100%;
|
|
814
872
|
overflow-x: auto;
|
|
@@ -916,7 +974,7 @@ const CspSection = ({ csp }) => {
|
|
|
916
974
|
/* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", id: "mex-csp-snippet-label", children: codeLabel }),
|
|
917
975
|
/* @__PURE__ */ jsx(IconButton, { label: t("settings.csp.copy", "Copy the snippet"), variant: "tertiary", onClick: onCopy, children: /* @__PURE__ */ jsx(Duplicate, {}) })
|
|
918
976
|
] }),
|
|
919
|
-
/* @__PURE__ */ jsx(Box, { minWidth: 0, children: /* @__PURE__ */ jsx(CodeBlock, { ref: codeRef, tabIndex: 0, "aria-labelledby": "mex-csp-snippet-label", children: /* @__PURE__ */ jsx("code", { children: csp.snippet }) }) }),
|
|
977
|
+
/* @__PURE__ */ jsx(Box, { minWidth: 0, children: /* @__PURE__ */ jsx(CodeBlock$1, { ref: codeRef, tabIndex: 0, "aria-labelledby": "mex-csp-snippet-label", children: /* @__PURE__ */ jsx("code", { children: csp.snippet }) }) }),
|
|
920
978
|
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: t(
|
|
921
979
|
"settings.csp.mergeHint",
|
|
922
980
|
"Keep your other directives (for example the hosts of your upload provider) and restart Strapi after the change."
|
|
@@ -926,6 +984,159 @@ const CspSection = ({ csp }) => {
|
|
|
926
984
|
}
|
|
927
985
|
);
|
|
928
986
|
};
|
|
987
|
+
const Swatch = styled.span`
|
|
988
|
+
display: inline-block;
|
|
989
|
+
flex: 0 0 auto;
|
|
990
|
+
width: 2.4rem;
|
|
991
|
+
height: 2.4rem;
|
|
992
|
+
border-radius: ${({ theme }) => theme.borderRadius};
|
|
993
|
+
border: 1px solid ${({ theme }) => theme.colors.neutral300};
|
|
994
|
+
background: ${({ $color }) => isHexColor($color) ? $color : "transparent"};
|
|
995
|
+
`;
|
|
996
|
+
const CodeBlock = styled.pre`
|
|
997
|
+
margin: 0;
|
|
998
|
+
max-width: 100%;
|
|
999
|
+
max-height: 24rem;
|
|
1000
|
+
overflow: auto;
|
|
1001
|
+
padding: ${({ theme }) => theme.spaces[4]};
|
|
1002
|
+
border: 1px solid ${({ theme }) => theme.colors.neutral200};
|
|
1003
|
+
border-radius: ${({ theme }) => theme.borderRadius};
|
|
1004
|
+
background: ${({ theme }) => theme.colors.neutral100};
|
|
1005
|
+
color: ${({ theme }) => theme.colors.neutral800};
|
|
1006
|
+
font-family: 'SF Mono', SFMono-Regular, ui-monospace, Menlo, Consolas, monospace;
|
|
1007
|
+
font-size: ${({ theme }) => theme.fontSizes[1]};
|
|
1008
|
+
line-height: 1.6;
|
|
1009
|
+
white-space: pre;
|
|
1010
|
+
|
|
1011
|
+
&:focus-visible {
|
|
1012
|
+
outline: 2px solid ${({ theme }) => theme.colors.primary600};
|
|
1013
|
+
outline-offset: 2px;
|
|
1014
|
+
}
|
|
1015
|
+
`;
|
|
1016
|
+
const TokenList = styled.ul`
|
|
1017
|
+
margin: 0;
|
|
1018
|
+
padding: 0;
|
|
1019
|
+
list-style: none;
|
|
1020
|
+
display: grid;
|
|
1021
|
+
grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr));
|
|
1022
|
+
gap: ${({ theme }) => theme.spaces[3]};
|
|
1023
|
+
`;
|
|
1024
|
+
const TokenItem = ({ token, locale, t }) => /* @__PURE__ */ jsx(Box, { tag: "li", minWidth: 0, children: /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", minWidth: 0, children: [
|
|
1025
|
+
/* @__PURE__ */ jsx(Swatch, { $color: token.light, title: t("settings.palette.light", "Light theme"), "aria-hidden": "true" }),
|
|
1026
|
+
/* @__PURE__ */ jsx(Swatch, { $color: token.dark, title: t("settings.palette.dark", "Dark theme"), "aria-hidden": "true" }),
|
|
1027
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", minWidth: 0, children: [
|
|
1028
|
+
/* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "semiBold", textColor: "neutral800", children: tokenLabel(token, locale) }),
|
|
1029
|
+
/* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral600", style: { overflowWrap: "anywhere" }, children: [
|
|
1030
|
+
token.name,
|
|
1031
|
+
" · ",
|
|
1032
|
+
token.light,
|
|
1033
|
+
" / ",
|
|
1034
|
+
token.dark
|
|
1035
|
+
] })
|
|
1036
|
+
] })
|
|
1037
|
+
] }) });
|
|
1038
|
+
const PaletteSection = ({ palette }) => {
|
|
1039
|
+
const t = useT();
|
|
1040
|
+
const { locale } = useIntl();
|
|
1041
|
+
const { copy } = useClipboard();
|
|
1042
|
+
const codeRef = useRef(null);
|
|
1043
|
+
const [alertOpen, setAlertOpen] = useState(true);
|
|
1044
|
+
if (!palette) return null;
|
|
1045
|
+
const colors = Array.isArray(palette.colors) ? palette.colors : [];
|
|
1046
|
+
const highlights = Array.isArray(palette.highlights) ? palette.highlights : [];
|
|
1047
|
+
const issues = Array.isArray(palette.issues) ? palette.issues : [];
|
|
1048
|
+
const annotations = Array.isArray(palette.annotations) ? palette.annotations : [];
|
|
1049
|
+
const empty = !colors.length && !highlights.length;
|
|
1050
|
+
const pairText = (issue) => t(
|
|
1051
|
+
"settings.palette.issue",
|
|
1052
|
+
"{mode, select, dark {Dark theme} other {Light theme}}: {pair} has contrast {ratio}:1 (needs 4.5:1)",
|
|
1053
|
+
{
|
|
1054
|
+
mode: issue.mode,
|
|
1055
|
+
pair: `${issue.color || t("settings.palette.defaultText", "default text")} / ${issue.highlight || t("settings.palette.page", "page background")}`,
|
|
1056
|
+
ratio: issue.ratio
|
|
1057
|
+
}
|
|
1058
|
+
);
|
|
1059
|
+
const onCopy = async () => {
|
|
1060
|
+
if (!await copy(palette.css) && codeRef.current) {
|
|
1061
|
+
const range = document.createRange();
|
|
1062
|
+
range.selectNodeContents(codeRef.current);
|
|
1063
|
+
const selection = window.getSelection();
|
|
1064
|
+
selection.removeAllRanges();
|
|
1065
|
+
selection.addRange(range);
|
|
1066
|
+
codeRef.current.focus();
|
|
1067
|
+
}
|
|
1068
|
+
};
|
|
1069
|
+
return /* @__PURE__ */ jsxs(
|
|
1070
|
+
SectionCard,
|
|
1071
|
+
{
|
|
1072
|
+
title: t("settings.palette.title", "Text colours and highlights"),
|
|
1073
|
+
subtitle: t(
|
|
1074
|
+
"settings.palette.subtitle",
|
|
1075
|
+
'Defined in the plugin configuration (config/plugins.js, key palette). Fields offer them when the field option "Text colour and highlight" is on.'
|
|
1076
|
+
),
|
|
1077
|
+
children: [
|
|
1078
|
+
empty ? /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", children: t(
|
|
1079
|
+
"settings.palette.empty",
|
|
1080
|
+
"No palette is configured, so editors see no colour tool. Ask your developer to add colour tokens to the plugin configuration."
|
|
1081
|
+
) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1082
|
+
issues.length && alertOpen ? (
|
|
1083
|
+
// The Alert renders its children inside a paragraph: the list follows it (no <ul> in <p>).
|
|
1084
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
|
1085
|
+
/* @__PURE__ */ jsx(
|
|
1086
|
+
Alert,
|
|
1087
|
+
{
|
|
1088
|
+
variant: "warning",
|
|
1089
|
+
closeLabel: t("settings.close", "Close"),
|
|
1090
|
+
onClose: () => setAlertOpen(false),
|
|
1091
|
+
children: t(
|
|
1092
|
+
"settings.palette.issuesTitle",
|
|
1093
|
+
"{count, plural, one {# combination is} other {# combinations are}} hard to read",
|
|
1094
|
+
{ count: issues.length }
|
|
1095
|
+
)
|
|
1096
|
+
}
|
|
1097
|
+
),
|
|
1098
|
+
/* @__PURE__ */ jsx(Box, { tag: "ul", paddingLeft: 4, margin: 0, children: issues.slice(0, 20).map((issue) => /* @__PURE__ */ jsx(
|
|
1099
|
+
Typography,
|
|
1100
|
+
{
|
|
1101
|
+
tag: "li",
|
|
1102
|
+
variant: "omega",
|
|
1103
|
+
children: pairText(issue)
|
|
1104
|
+
},
|
|
1105
|
+
`${issue.mode}|${issue.color}|${issue.highlight}`
|
|
1106
|
+
)) })
|
|
1107
|
+
] })
|
|
1108
|
+
) : null,
|
|
1109
|
+
colors.length ? /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
|
1110
|
+
/* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", tag: "h3", children: t("settings.palette.colors", "Text colours") }),
|
|
1111
|
+
/* @__PURE__ */ jsx(TokenList, { children: colors.map((token) => /* @__PURE__ */ jsx(TokenItem, { token, locale, t }, token.name)) })
|
|
1112
|
+
] }) : null,
|
|
1113
|
+
highlights.length ? /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
|
1114
|
+
/* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", tag: "h3", children: t("settings.palette.highlights", "Highlights") }),
|
|
1115
|
+
/* @__PURE__ */ jsx(TokenList, { children: highlights.map((token) => /* @__PURE__ */ jsx(TokenItem, { token, locale, t }, token.name)) })
|
|
1116
|
+
] }) : null,
|
|
1117
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, minWidth: 0, children: [
|
|
1118
|
+
/* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", gap: 2, wrap: "wrap", children: [
|
|
1119
|
+
/* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", id: "mex-palette-css-label", tag: "h3", children: t("settings.palette.css", "CSS for your site") }),
|
|
1120
|
+
/* @__PURE__ */ jsx(
|
|
1121
|
+
IconButton,
|
|
1122
|
+
{
|
|
1123
|
+
label: t("settings.palette.copy", "Copy the CSS"),
|
|
1124
|
+
variant: "tertiary",
|
|
1125
|
+
onClick: onCopy,
|
|
1126
|
+
children: /* @__PURE__ */ jsx(Duplicate, {})
|
|
1127
|
+
}
|
|
1128
|
+
)
|
|
1129
|
+
] }),
|
|
1130
|
+
/* @__PURE__ */ jsx(Box, { minWidth: 0, children: /* @__PURE__ */ jsx(CodeBlock, { ref: codeRef, tabIndex: 0, "aria-labelledby": "mex-palette-css-label", children: /* @__PURE__ */ jsx("code", { children: palette.css }) }) })
|
|
1131
|
+
] })
|
|
1132
|
+
] }),
|
|
1133
|
+
annotations.length ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: t("settings.palette.annotations", 'Annotations for the field option "Annotations": {names}', {
|
|
1134
|
+
names: annotations.map((item) => item.name).join(", ")
|
|
1135
|
+
}) }) : null
|
|
1136
|
+
]
|
|
1137
|
+
}
|
|
1138
|
+
);
|
|
1139
|
+
};
|
|
929
1140
|
const hostOf = (t, baseUrl) => {
|
|
930
1141
|
try {
|
|
931
1142
|
return new URL(baseUrl).host || t("settings.languageTool.server", "the LanguageTool server");
|
|
@@ -1117,6 +1328,172 @@ const LanguageToolSection = ({ form, readOnly, onTest }) => {
|
|
|
1117
1328
|
}
|
|
1118
1329
|
);
|
|
1119
1330
|
};
|
|
1331
|
+
const POLL_MS = 3e3;
|
|
1332
|
+
const MAX_POLLS = 300;
|
|
1333
|
+
const LinkScheduleSection = ({ initial, canRun, onStatus }) => {
|
|
1334
|
+
const t = useT();
|
|
1335
|
+
const { formatDate } = useIntl();
|
|
1336
|
+
const { get, post } = useFetchClient();
|
|
1337
|
+
const [status, setStatus] = useState(initial);
|
|
1338
|
+
const [starting, setStarting] = useState(false);
|
|
1339
|
+
const [notice, setNotice] = useState(null);
|
|
1340
|
+
const [announcement, setAnnouncement] = useState("");
|
|
1341
|
+
const polls = useRef(0);
|
|
1342
|
+
const timer = useRef(null);
|
|
1343
|
+
const wasRunning = useRef(Boolean(initial && initial.running));
|
|
1344
|
+
const refresh = useCallback(async () => {
|
|
1345
|
+
try {
|
|
1346
|
+
const { data } = await get(API.linkSchedule);
|
|
1347
|
+
const next = data.data;
|
|
1348
|
+
setStatus(next);
|
|
1349
|
+
if (wasRunning.current && !next.running) {
|
|
1350
|
+
setAnnouncement(t("settings.linkRun.finished", "The link check finished."));
|
|
1351
|
+
setNotice(null);
|
|
1352
|
+
}
|
|
1353
|
+
wasRunning.current = Boolean(next.running);
|
|
1354
|
+
return next;
|
|
1355
|
+
} catch {
|
|
1356
|
+
return null;
|
|
1357
|
+
}
|
|
1358
|
+
}, [get, t]);
|
|
1359
|
+
const running = Boolean(status && status.running);
|
|
1360
|
+
useEffect(() => {
|
|
1361
|
+
if (onStatus && status && status !== initial) onStatus(status);
|
|
1362
|
+
}, [status, initial, onStatus]);
|
|
1363
|
+
useEffect(() => {
|
|
1364
|
+
if (!running) {
|
|
1365
|
+
polls.current = 0;
|
|
1366
|
+
return void 0;
|
|
1367
|
+
}
|
|
1368
|
+
timer.current = window.setTimeout(async () => {
|
|
1369
|
+
polls.current += 1;
|
|
1370
|
+
if (polls.current > MAX_POLLS) {
|
|
1371
|
+
setNotice({
|
|
1372
|
+
variant: "default",
|
|
1373
|
+
text: t(
|
|
1374
|
+
"settings.linkRun.stillRunning",
|
|
1375
|
+
"The check is still running. Reload the page later to see the result."
|
|
1376
|
+
)
|
|
1377
|
+
});
|
|
1378
|
+
return;
|
|
1379
|
+
}
|
|
1380
|
+
await refresh();
|
|
1381
|
+
}, POLL_MS);
|
|
1382
|
+
return () => window.clearTimeout(timer.current);
|
|
1383
|
+
}, [running, status, refresh, t]);
|
|
1384
|
+
if (!status || !status.enabled) return null;
|
|
1385
|
+
const runNow = async () => {
|
|
1386
|
+
setStarting(true);
|
|
1387
|
+
setNotice(null);
|
|
1388
|
+
setAnnouncement("");
|
|
1389
|
+
try {
|
|
1390
|
+
await post(API.linkScheduleRun, {});
|
|
1391
|
+
setAnnouncement(t("settings.linkRun.started", "The link check started."));
|
|
1392
|
+
wasRunning.current = true;
|
|
1393
|
+
setStatus((current) => ({ ...current, running: true }));
|
|
1394
|
+
} catch (error) {
|
|
1395
|
+
const info = readApiError(error);
|
|
1396
|
+
if (info.status === 409) {
|
|
1397
|
+
setNotice({
|
|
1398
|
+
variant: "default",
|
|
1399
|
+
text: t(
|
|
1400
|
+
"settings.linkRun.conflict",
|
|
1401
|
+
"A link check is already running. The result appears here when it finishes."
|
|
1402
|
+
)
|
|
1403
|
+
});
|
|
1404
|
+
wasRunning.current = true;
|
|
1405
|
+
setStatus((current) => ({ ...current, running: true }));
|
|
1406
|
+
} else if (info.status === 400 && info.code === "DISABLED") {
|
|
1407
|
+
setNotice({
|
|
1408
|
+
variant: "warning",
|
|
1409
|
+
text: t(
|
|
1410
|
+
"settings.linkRun.disabled",
|
|
1411
|
+
"Scheduled link checks are turned off in config/plugins.js (qualityChecks.externalLinks.schedule)."
|
|
1412
|
+
)
|
|
1413
|
+
});
|
|
1414
|
+
} else {
|
|
1415
|
+
setNotice({
|
|
1416
|
+
variant: "danger",
|
|
1417
|
+
text: t("settings.linkRun.failed", "The link check could not be started. Try again.")
|
|
1418
|
+
});
|
|
1419
|
+
}
|
|
1420
|
+
} finally {
|
|
1421
|
+
setStarting(false);
|
|
1422
|
+
}
|
|
1423
|
+
};
|
|
1424
|
+
const date = (value) => value ? formatDate(new Date(value), { dateStyle: "medium", timeStyle: "short" }) : "";
|
|
1425
|
+
const lastRun = status.lastRun;
|
|
1426
|
+
const zone = status.tz || t("settings.linkRun.serverZone", "Server time zone");
|
|
1427
|
+
return /* @__PURE__ */ jsxs(
|
|
1428
|
+
SectionCard,
|
|
1429
|
+
{
|
|
1430
|
+
title: t("settings.linkRun.title", "Scheduled link check"),
|
|
1431
|
+
subtitle: t(
|
|
1432
|
+
"settings.linkRun.subtitle",
|
|
1433
|
+
"Checks every external link in all editor fields on a schedule. You can also start a check now."
|
|
1434
|
+
),
|
|
1435
|
+
action: canRun ? /* @__PURE__ */ jsx(
|
|
1436
|
+
Button,
|
|
1437
|
+
{
|
|
1438
|
+
startIcon: /* @__PURE__ */ jsx(Play, {}),
|
|
1439
|
+
variant: "secondary",
|
|
1440
|
+
onClick: runNow,
|
|
1441
|
+
loading: starting,
|
|
1442
|
+
disabled: starting || running,
|
|
1443
|
+
children: running ? t("settings.linkRun.running", "Check running") : t("settings.linkRun.run", "Run now")
|
|
1444
|
+
}
|
|
1445
|
+
) : null,
|
|
1446
|
+
children: [
|
|
1447
|
+
!canRun ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: t("settings.linkRun.noPermission", 'Starting a check needs the "Update settings" permission.') }) : null,
|
|
1448
|
+
notice ? /* @__PURE__ */ jsx(
|
|
1449
|
+
Alert,
|
|
1450
|
+
{
|
|
1451
|
+
variant: notice.variant,
|
|
1452
|
+
closeLabel: t("settings.close", "Close"),
|
|
1453
|
+
onClose: () => setNotice(null),
|
|
1454
|
+
children: notice.text
|
|
1455
|
+
}
|
|
1456
|
+
) : null,
|
|
1457
|
+
/* @__PURE__ */ jsx(
|
|
1458
|
+
PropertyList,
|
|
1459
|
+
{
|
|
1460
|
+
items: [
|
|
1461
|
+
{
|
|
1462
|
+
key: "state",
|
|
1463
|
+
label: t("settings.linkRun.state", "State"),
|
|
1464
|
+
value: running ? /* @__PURE__ */ jsx(Badge, { backgroundColor: "primary100", textColor: "primary700", children: t("settings.linkRun.running", "Check running") }) : /* @__PURE__ */ jsx(Badge, { backgroundColor: "neutral150", textColor: "neutral700", children: t("settings.linkRun.idle", "Idle") })
|
|
1465
|
+
},
|
|
1466
|
+
{
|
|
1467
|
+
key: "rule",
|
|
1468
|
+
label: t("settings.linkRun.rule", "Schedule"),
|
|
1469
|
+
value: t("settings.linkRun.ruleValue", "{rule} ({zone})", { rule: status.rule || "", zone }),
|
|
1470
|
+
hint: status.nextRunAt ? t("settings.linkRun.next", "Next run {date}", { date: date(status.nextRunAt) }) : void 0
|
|
1471
|
+
},
|
|
1472
|
+
{
|
|
1473
|
+
key: "last",
|
|
1474
|
+
label: t("settings.linkRun.last", "Last run"),
|
|
1475
|
+
value: lastRun ? t(
|
|
1476
|
+
"settings.linkRun.lastValue",
|
|
1477
|
+
"{date}: {checked, number} links checked, {problems, number} with problems.",
|
|
1478
|
+
{
|
|
1479
|
+
date: date(lastRun.finishedAt),
|
|
1480
|
+
checked: lastRun.checked ?? 0,
|
|
1481
|
+
problems: lastRun.problems ?? 0
|
|
1482
|
+
}
|
|
1483
|
+
) : t("settings.environment.linkScheduleNever", "No run yet."),
|
|
1484
|
+
hint: lastRun && !lastRun.complete ? t(
|
|
1485
|
+
"settings.environment.linkScheduleIncomplete",
|
|
1486
|
+
"The last run did not finish; results of earlier runs were kept."
|
|
1487
|
+
) : void 0
|
|
1488
|
+
}
|
|
1489
|
+
]
|
|
1490
|
+
}
|
|
1491
|
+
),
|
|
1492
|
+
/* @__PURE__ */ jsx(Box, { "aria-live": "polite", role: "status", children: /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: announcement }) })
|
|
1493
|
+
]
|
|
1494
|
+
}
|
|
1495
|
+
);
|
|
1496
|
+
};
|
|
1120
1497
|
const RBAC = [...PERMISSIONS.settingsRead, ...PERMISSIONS.settingsUpdate];
|
|
1121
1498
|
const testErrorText = (t, code) => {
|
|
1122
1499
|
switch (code) {
|
|
@@ -1166,6 +1543,7 @@ const ConfigurationPage = () => {
|
|
|
1166
1543
|
const { allowedActions, isLoading: rbacLoading } = useRBAC(RBAC);
|
|
1167
1544
|
const form = useConfigurationForm();
|
|
1168
1545
|
const title = t("settings.configuration.title", "Configuration");
|
|
1546
|
+
const [liveSchedule, setLiveSchedule] = useState(null);
|
|
1169
1547
|
if (rbacLoading || form.status === "loading") {
|
|
1170
1548
|
return /* @__PURE__ */ jsxs(Page.Main, { children: [
|
|
1171
1549
|
/* @__PURE__ */ jsx(Page.Title, { children: title }),
|
|
@@ -1299,8 +1677,25 @@ const ConfigurationPage = () => {
|
|
|
1299
1677
|
) : null,
|
|
1300
1678
|
/* @__PURE__ */ jsx(AiSection, { form, readOnly, onTest }),
|
|
1301
1679
|
/* @__PURE__ */ jsx(LanguageToolSection, { form, readOnly, onTest: onTestLanguageTool }),
|
|
1302
|
-
/* @__PURE__ */ jsx(
|
|
1680
|
+
/* @__PURE__ */ jsx(
|
|
1681
|
+
EnvironmentSection,
|
|
1682
|
+
{
|
|
1683
|
+
environment: liveSchedule && form.dto.environment ? {
|
|
1684
|
+
...form.dto.environment,
|
|
1685
|
+
linkSchedule: { ...form.dto.environment.linkSchedule, ...liveSchedule }
|
|
1686
|
+
} : form.dto.environment
|
|
1687
|
+
}
|
|
1688
|
+
),
|
|
1689
|
+
/* @__PURE__ */ jsx(
|
|
1690
|
+
LinkScheduleSection,
|
|
1691
|
+
{
|
|
1692
|
+
initial: form.dto.environment && form.dto.environment.linkSchedule || null,
|
|
1693
|
+
canRun: !readOnly,
|
|
1694
|
+
onStatus: setLiveSchedule
|
|
1695
|
+
}
|
|
1696
|
+
),
|
|
1303
1697
|
/* @__PURE__ */ jsx(CspSection, { csp: form.dto.environment && form.dto.environment.csp }),
|
|
1698
|
+
/* @__PURE__ */ jsx(PaletteSection, { palette: form.dto.environment && form.dto.environment.palette }),
|
|
1304
1699
|
/* @__PURE__ */ jsxs(Form, { method: "PUT", initialValues: form.saved, children: [
|
|
1305
1700
|
/* @__PURE__ */ jsx(DraftSync, { values: form.draft }),
|
|
1306
1701
|
/* @__PURE__ */ jsx(Blocker, {})
|