magic-editor-x 2.3.1 → 2.4.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 +74 -0
- package/README.md +299 -142
- package/dist/admin/AuditPage-C2u6z4aN.js +381 -0
- package/dist/admin/AuditPage-guB0SiGS.mjs +381 -0
- package/dist/admin/{ConfigurationPage-CFP3lp9p.js → ConfigurationPage-D6uya-J1.js} +228 -13
- package/dist/admin/{ConfigurationPage-CYGDLjM7.mjs → ConfigurationPage-DiEpF1Rr.mjs} +222 -7
- package/dist/admin/ConfirmAction-CUhpngYU.js +71 -0
- package/dist/admin/ConfirmAction-CZjpduc3.mjs +72 -0
- package/dist/admin/{CustomBlocksPage-B5Q33N-s.mjs → CustomBlocksPage-Byt10-6c.mjs} +6 -4
- package/dist/admin/{CustomBlocksPage-DzPOSpfn.js → CustomBlocksPage-DP3h_wNd.js} +21 -19
- package/dist/admin/MentionsWidget-C2OCAmqq.js +227 -0
- package/dist/admin/MentionsWidget-sMkM9mHX.mjs +225 -0
- package/dist/admin/{TemplatesPage-BVkgafCK.js → TemplatesPage-DrSJdteI.js} +313 -17
- package/dist/admin/{TemplatesPage-4A8JNO_Z.mjs → TemplatesPage-Yp4OqFE2.mjs} +305 -9
- package/dist/admin/{ConfirmAction-DuQwvRYi.mjs → api-2ZRpHM3d.mjs} +19 -70
- package/dist/admin/{ConfirmAction-zLuIFj8t.js → api-bix9RLLI.js} +19 -70
- 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-BMY2LBaa.mjs → de-BNPIGqhs.mjs} +41 -2
- package/dist/admin/{de-2Ie5jy7j.js → de-BhhGss1l.js} +41 -2
- package/dist/admin/{de-DOiGaTNX.mjs → de-CKz6CG3V.mjs} +191 -5
- package/dist/admin/{de-C3AsGauQ.js → de-CbBDnXeT.js} +140 -1
- package/dist/admin/{de-BUS1hUw0.mjs → de-DiCZrmH8.mjs} +140 -1
- package/dist/admin/{de-B1X46JJZ.js → de-zcV8D7nt.js} +191 -5
- package/dist/admin/{en-Ah-Cw0Wd.js → en-B9ApE1y1.js} +41 -2
- package/dist/admin/{en-CDg_18Bt.js → en-BMWhILnj.js} +191 -5
- package/dist/admin/{en-BkEjpC3i.js → en-CpehF0Kv.js} +140 -1
- package/dist/admin/{en-GCzgS9Aw.mjs → en-DCPMqFIa.mjs} +140 -1
- package/dist/admin/{en-CU6UzV4g.mjs → en-cYzqbASF.mjs} +191 -5
- package/dist/admin/{en-CvFiqti2.mjs → en-gFLeK9Ng.mjs} +41 -2
- package/dist/admin/{es-DbKHZz5l.mjs → es-BmwBgEgz.mjs} +41 -2
- package/dist/admin/{es-Cr8JH85N.js → es-C0W31rl8.js} +41 -2
- package/dist/admin/{es-BCpJmUEM.js → es-CQPh8PXw.js} +191 -5
- package/dist/admin/{es-C4pEnDRv.js → es-CawpzwyC.js} +140 -1
- package/dist/admin/{es-DHBBZKl2.mjs → es-Chs37IBR.mjs} +140 -1
- package/dist/admin/{es-BmfffNM2.mjs → es-DCamt1ek.mjs} +191 -5
- package/dist/admin/{fr-DQJ_7aq5.mjs → fr-CMWBNE5D.mjs} +41 -2
- package/dist/admin/{fr-C2aLSwEu.js → fr-COOsqexl.js} +140 -1
- package/dist/admin/{fr-Dvq4xk2e.mjs → fr-Dp5-XP29.mjs} +140 -1
- package/dist/admin/{fr-ZcN0yM_2.js → fr-DpC44Ol8.js} +191 -5
- package/dist/admin/{fr-OJ4VW1kh.js → fr-iGeIfEcU.js} +41 -2
- package/dist/admin/{fr-DZd2XJP6.mjs → fr-oW0t8bT5.mjs} +191 -5
- package/dist/admin/{index-DQVE0ymw.js → index-64wc26Bl.js} +17467 -10369
- package/dist/admin/{index-k8_a5o1A.mjs → index-BVjf1gVC.mjs} +13786 -6687
- package/dist/admin/{index-DR8sHkTk.js → index-D6Z7i8ba.js} +1003 -53
- package/dist/admin/{index-My6FjjHB.mjs → index-D_Fv8Non.mjs} +1032 -82
- package/dist/admin/index.js +2 -1
- package/dist/admin/index.mjs +3 -2
- package/dist/admin/math-CIQ4Z_mY.mjs +47 -0
- package/dist/admin/math-vsK_06ZR.js +49 -0
- package/dist/admin/{pt-D0I0_JYs.js → pt-BHmXk2d9.js} +41 -2
- package/dist/admin/{pt-CImqDnLB.js → pt-Bo0Pm_Pt.js} +191 -5
- package/dist/admin/{pt-CilDggGF.mjs → pt-DALDvfBn.mjs} +140 -1
- package/dist/admin/{pt-BSLzA17U.mjs → pt-DFNgZ5_k.mjs} +41 -2
- package/dist/admin/{pt-DX0OAIoL.js → pt-DXy7G1x7.js} +140 -1
- package/dist/admin/{pt-C3UdeIpd.mjs → pt-uGpfRQLC.mjs} +191 -5
- package/dist/admin/{useT-DNphiBQR.js → useT-BXJLIPN4.js} +1 -1
- package/dist/admin/{useT-Cmg1jwwG.mjs → useT-CLPhBmBC.mjs} +1 -1
- package/dist/blocks/index.d.mts +2 -0
- package/dist/blocks/index.d.ts +2 -0
- package/dist/blocks/index.js +13 -2
- package/dist/blocks/index.mjs +13 -2
- package/dist/math/index.d.mts +27 -0
- package/dist/math/index.d.ts +27 -0
- package/dist/math/index.js +164 -0
- package/dist/math/index.mjs +134 -0
- package/dist/react/index.js +673 -91
- package/dist/react/index.mjs +673 -91
- package/dist/render/index.d.mts +26 -0
- package/dist/render/index.d.ts +26 -0
- package/dist/render/index.js +779 -106
- package/dist/render/index.mjs +779 -106
- package/dist/server/index.js +10419 -4103
- package/dist/server/index.mjs +10419 -4103
- package/dist/vue/index.js +673 -91
- package/dist/vue/index.mjs +673 -91
- package/package.json +8 -2
- package/schema/magic-editor-x.schema.json +127 -2
- package/types/blocks.d.ts +2 -0
- package/types/index.d.ts +42 -0
- package/types/math.d.ts +27 -0
- package/types/render.d.ts +26 -0
|
@@ -1,15 +1,16 @@
|
|
|
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 useT = require("./useT-
|
|
9
|
-
const ConfirmAction = require("./ConfirmAction-
|
|
8
|
+
const index = require("./index-D6Z7i8ba.js");
|
|
9
|
+
const useT = require("./useT-BXJLIPN4.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 api = require("./api-bix9RLLI.js");
|
|
13
14
|
const reactIntl = require("react-intl");
|
|
14
15
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
15
16
|
const styled__default = /* @__PURE__ */ _interopDefault(styled);
|
|
@@ -24,7 +25,7 @@ const PropertyList = ({ items }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
|
|
24
25
|
/* @__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
26
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { tag: "dd", margin: 0, minWidth: 0, flex: "1 1 auto", children: [
|
|
26
27
|
/* @__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
|
|
28
|
+
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
29
|
] })
|
|
29
30
|
]
|
|
30
31
|
},
|
|
@@ -204,7 +205,7 @@ const useConfigurationForm = () => {
|
|
|
204
205
|
};
|
|
205
206
|
}, []);
|
|
206
207
|
const fetchSettings = ReactNamespace.useCallback(
|
|
207
|
-
() => get(
|
|
208
|
+
() => get(api.API.settings).then(
|
|
208
209
|
({ data }) => {
|
|
209
210
|
if (!mounted.current) return;
|
|
210
211
|
const next = toDraft(data.data.ai, data.data.languageTool);
|
|
@@ -268,7 +269,7 @@ const useConfigurationForm = () => {
|
|
|
268
269
|
if (hasErrors) return { ok: false, invalid: true };
|
|
269
270
|
setSaving(true);
|
|
270
271
|
try {
|
|
271
|
-
const { data } = await put(
|
|
272
|
+
const { data } = await put(api.API.settings, toPayload(draft));
|
|
272
273
|
const stored = toDraft(data.data.ai, data.data.languageTool);
|
|
273
274
|
const adjusted = adjustedFields(draft, stored);
|
|
274
275
|
setDto(data.data);
|
|
@@ -278,7 +279,7 @@ const useConfigurationForm = () => {
|
|
|
278
279
|
setShowErrors(false);
|
|
279
280
|
return { ok: true, adjusted };
|
|
280
281
|
} catch (error) {
|
|
281
|
-
const info =
|
|
282
|
+
const info = api.readApiError(error);
|
|
282
283
|
setServerErrors(mapServerErrors(info.details));
|
|
283
284
|
return { ok: false, message: info.status === 400 ? null : info.message };
|
|
284
285
|
} finally {
|
|
@@ -301,10 +302,10 @@ const useConfigurationForm = () => {
|
|
|
301
302
|
try {
|
|
302
303
|
const payload = toPayload(draft);
|
|
303
304
|
if (draft.apiKeyMode === "remove") delete payload.ai.apiKey;
|
|
304
|
-
await post(
|
|
305
|
+
await post(api.API.settingsAiTest, payload);
|
|
305
306
|
return { ok: true };
|
|
306
307
|
} catch (error) {
|
|
307
|
-
const info =
|
|
308
|
+
const info = api.readApiError(error);
|
|
308
309
|
return { ok: false, code: info.code, status: info.status };
|
|
309
310
|
} finally {
|
|
310
311
|
if (mounted.current) setTesting(false);
|
|
@@ -322,10 +323,10 @@ const useConfigurationForm = () => {
|
|
|
322
323
|
try {
|
|
323
324
|
const payload = toLanguageToolPayload(lt);
|
|
324
325
|
if (lt.apiKeyMode === "remove") payload.apiKey = "";
|
|
325
|
-
await post(
|
|
326
|
+
await post(api.API.settingsLanguageToolTest, { languageTool: payload });
|
|
326
327
|
return { ok: true };
|
|
327
328
|
} catch (error) {
|
|
328
|
-
const info =
|
|
329
|
+
const info = api.readApiError(error);
|
|
329
330
|
return { ok: false, code: info.code, status: info.status };
|
|
330
331
|
} finally {
|
|
331
332
|
if (mounted.current) setTestingLanguageTool(false);
|
|
@@ -720,6 +721,7 @@ const EnvironmentSection = ({ environment }) => {
|
|
|
720
721
|
}[environment.rawHtml] || environment.rawHtml;
|
|
721
722
|
const collaboration = environment.collaboration || {};
|
|
722
723
|
const linkSchedule = environment.linkSchedule || null;
|
|
724
|
+
const privateImages = Array.isArray(environment.altTextPrivateOrigins) ? environment.altTextPrivateOrigins : [];
|
|
723
725
|
const lastRun = linkSchedule && linkSchedule.lastRun;
|
|
724
726
|
let linkScheduleHint;
|
|
725
727
|
if (linkSchedule && linkSchedule.enabled) {
|
|
@@ -797,6 +799,36 @@ const EnvironmentSection = ({ environment }) => {
|
|
|
797
799
|
value: on(Boolean(linkSchedule && linkSchedule.enabled)),
|
|
798
800
|
hint: linkScheduleHint
|
|
799
801
|
},
|
|
802
|
+
{
|
|
803
|
+
key: "privateImages",
|
|
804
|
+
label: t("settings.environment.privateImages", "Private image storage for alt text"),
|
|
805
|
+
value: privateImages.length ? t(
|
|
806
|
+
"settings.environment.privateImagesCount",
|
|
807
|
+
"{count, plural, =0 {Off} one {# origin} other {# origins}}",
|
|
808
|
+
{ count: privateImages.length }
|
|
809
|
+
) : on(false),
|
|
810
|
+
hint: privateImages.length ? t(
|
|
811
|
+
"settings.environment.privateImagesHint",
|
|
812
|
+
"Alt text suggestions may read images from {origins} (ai.altText.allowPrivateOrigins). Redirects are not followed.",
|
|
813
|
+
{ origins: privateImages.join(", ") }
|
|
814
|
+
) : t(
|
|
815
|
+
"settings.environment.privateImagesNone",
|
|
816
|
+
"Alt text suggestions read images from public addresses only. Self-hosted storage on a private network needs ai.altText.allowPrivateOrigins."
|
|
817
|
+
)
|
|
818
|
+
},
|
|
819
|
+
{
|
|
820
|
+
key: "mentionEmails",
|
|
821
|
+
label: t("settings.environment.mentionEmails", "E-mails for comment mentions"),
|
|
822
|
+
value: on(Boolean(environment.mentionEmails && environment.mentionEmails.enabled)),
|
|
823
|
+
hint: environment.mentionEmails && environment.mentionEmails.enabled ? t(
|
|
824
|
+
"settings.environment.mentionEmailsOn",
|
|
825
|
+
"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).",
|
|
826
|
+
{ count: environment.mentionEmails.perHour ?? 10 }
|
|
827
|
+
) : t(
|
|
828
|
+
"settings.environment.mentionEmailsOff",
|
|
829
|
+
"Mentions show up in the admin only. Turn on e-mails with comments.notifications.email in config/plugins."
|
|
830
|
+
)
|
|
831
|
+
},
|
|
800
832
|
{
|
|
801
833
|
key: "privateAi",
|
|
802
834
|
label: t("settings.environment.privateAi", "Private AI hosts allowed"),
|
|
@@ -1121,6 +1153,172 @@ const LanguageToolSection = ({ form, readOnly, onTest }) => {
|
|
|
1121
1153
|
}
|
|
1122
1154
|
);
|
|
1123
1155
|
};
|
|
1156
|
+
const POLL_MS = 3e3;
|
|
1157
|
+
const MAX_POLLS = 300;
|
|
1158
|
+
const LinkScheduleSection = ({ initial, canRun, onStatus }) => {
|
|
1159
|
+
const t = useT.useT();
|
|
1160
|
+
const { formatDate } = reactIntl.useIntl();
|
|
1161
|
+
const { get, post } = admin.useFetchClient();
|
|
1162
|
+
const [status, setStatus] = ReactNamespace.useState(initial);
|
|
1163
|
+
const [starting, setStarting] = ReactNamespace.useState(false);
|
|
1164
|
+
const [notice, setNotice] = ReactNamespace.useState(null);
|
|
1165
|
+
const [announcement, setAnnouncement] = ReactNamespace.useState("");
|
|
1166
|
+
const polls = ReactNamespace.useRef(0);
|
|
1167
|
+
const timer = ReactNamespace.useRef(null);
|
|
1168
|
+
const wasRunning = ReactNamespace.useRef(Boolean(initial && initial.running));
|
|
1169
|
+
const refresh = ReactNamespace.useCallback(async () => {
|
|
1170
|
+
try {
|
|
1171
|
+
const { data } = await get(api.API.linkSchedule);
|
|
1172
|
+
const next = data.data;
|
|
1173
|
+
setStatus(next);
|
|
1174
|
+
if (wasRunning.current && !next.running) {
|
|
1175
|
+
setAnnouncement(t("settings.linkRun.finished", "The link check finished."));
|
|
1176
|
+
setNotice(null);
|
|
1177
|
+
}
|
|
1178
|
+
wasRunning.current = Boolean(next.running);
|
|
1179
|
+
return next;
|
|
1180
|
+
} catch {
|
|
1181
|
+
return null;
|
|
1182
|
+
}
|
|
1183
|
+
}, [get, t]);
|
|
1184
|
+
const running = Boolean(status && status.running);
|
|
1185
|
+
ReactNamespace.useEffect(() => {
|
|
1186
|
+
if (onStatus && status && status !== initial) onStatus(status);
|
|
1187
|
+
}, [status, initial, onStatus]);
|
|
1188
|
+
ReactNamespace.useEffect(() => {
|
|
1189
|
+
if (!running) {
|
|
1190
|
+
polls.current = 0;
|
|
1191
|
+
return void 0;
|
|
1192
|
+
}
|
|
1193
|
+
timer.current = window.setTimeout(async () => {
|
|
1194
|
+
polls.current += 1;
|
|
1195
|
+
if (polls.current > MAX_POLLS) {
|
|
1196
|
+
setNotice({
|
|
1197
|
+
variant: "default",
|
|
1198
|
+
text: t(
|
|
1199
|
+
"settings.linkRun.stillRunning",
|
|
1200
|
+
"The check is still running. Reload the page later to see the result."
|
|
1201
|
+
)
|
|
1202
|
+
});
|
|
1203
|
+
return;
|
|
1204
|
+
}
|
|
1205
|
+
await refresh();
|
|
1206
|
+
}, POLL_MS);
|
|
1207
|
+
return () => window.clearTimeout(timer.current);
|
|
1208
|
+
}, [running, status, refresh, t]);
|
|
1209
|
+
if (!status || !status.enabled) return null;
|
|
1210
|
+
const runNow = async () => {
|
|
1211
|
+
setStarting(true);
|
|
1212
|
+
setNotice(null);
|
|
1213
|
+
setAnnouncement("");
|
|
1214
|
+
try {
|
|
1215
|
+
await post(api.API.linkScheduleRun, {});
|
|
1216
|
+
setAnnouncement(t("settings.linkRun.started", "The link check started."));
|
|
1217
|
+
wasRunning.current = true;
|
|
1218
|
+
setStatus((current) => ({ ...current, running: true }));
|
|
1219
|
+
} catch (error) {
|
|
1220
|
+
const info = api.readApiError(error);
|
|
1221
|
+
if (info.status === 409) {
|
|
1222
|
+
setNotice({
|
|
1223
|
+
variant: "default",
|
|
1224
|
+
text: t(
|
|
1225
|
+
"settings.linkRun.conflict",
|
|
1226
|
+
"A link check is already running. The result appears here when it finishes."
|
|
1227
|
+
)
|
|
1228
|
+
});
|
|
1229
|
+
wasRunning.current = true;
|
|
1230
|
+
setStatus((current) => ({ ...current, running: true }));
|
|
1231
|
+
} else if (info.status === 400 && info.code === "DISABLED") {
|
|
1232
|
+
setNotice({
|
|
1233
|
+
variant: "warning",
|
|
1234
|
+
text: t(
|
|
1235
|
+
"settings.linkRun.disabled",
|
|
1236
|
+
"Scheduled link checks are turned off in config/plugins.js (qualityChecks.externalLinks.schedule)."
|
|
1237
|
+
)
|
|
1238
|
+
});
|
|
1239
|
+
} else {
|
|
1240
|
+
setNotice({
|
|
1241
|
+
variant: "danger",
|
|
1242
|
+
text: t("settings.linkRun.failed", "The link check could not be started. Try again.")
|
|
1243
|
+
});
|
|
1244
|
+
}
|
|
1245
|
+
} finally {
|
|
1246
|
+
setStarting(false);
|
|
1247
|
+
}
|
|
1248
|
+
};
|
|
1249
|
+
const date = (value) => value ? formatDate(new Date(value), { dateStyle: "medium", timeStyle: "short" }) : "";
|
|
1250
|
+
const lastRun = status.lastRun;
|
|
1251
|
+
const zone = status.tz || t("settings.linkRun.serverZone", "Server time zone");
|
|
1252
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1253
|
+
useT.SectionCard,
|
|
1254
|
+
{
|
|
1255
|
+
title: t("settings.linkRun.title", "Scheduled link check"),
|
|
1256
|
+
subtitle: t(
|
|
1257
|
+
"settings.linkRun.subtitle",
|
|
1258
|
+
"Checks every external link in all editor fields on a schedule. You can also start a check now."
|
|
1259
|
+
),
|
|
1260
|
+
action: canRun ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1261
|
+
designSystem.Button,
|
|
1262
|
+
{
|
|
1263
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Play, {}),
|
|
1264
|
+
variant: "secondary",
|
|
1265
|
+
onClick: runNow,
|
|
1266
|
+
loading: starting,
|
|
1267
|
+
disabled: starting || running,
|
|
1268
|
+
children: running ? t("settings.linkRun.running", "Check running") : t("settings.linkRun.run", "Run now")
|
|
1269
|
+
}
|
|
1270
|
+
) : null,
|
|
1271
|
+
children: [
|
|
1272
|
+
!canRun ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t("settings.linkRun.noPermission", 'Starting a check needs the "Update settings" permission.') }) : null,
|
|
1273
|
+
notice ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1274
|
+
designSystem.Alert,
|
|
1275
|
+
{
|
|
1276
|
+
variant: notice.variant,
|
|
1277
|
+
closeLabel: t("settings.close", "Close"),
|
|
1278
|
+
onClose: () => setNotice(null),
|
|
1279
|
+
children: notice.text
|
|
1280
|
+
}
|
|
1281
|
+
) : null,
|
|
1282
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1283
|
+
PropertyList,
|
|
1284
|
+
{
|
|
1285
|
+
items: [
|
|
1286
|
+
{
|
|
1287
|
+
key: "state",
|
|
1288
|
+
label: t("settings.linkRun.state", "State"),
|
|
1289
|
+
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") })
|
|
1290
|
+
},
|
|
1291
|
+
{
|
|
1292
|
+
key: "rule",
|
|
1293
|
+
label: t("settings.linkRun.rule", "Schedule"),
|
|
1294
|
+
value: t("settings.linkRun.ruleValue", "{rule} ({zone})", { rule: status.rule || "", zone }),
|
|
1295
|
+
hint: status.nextRunAt ? t("settings.linkRun.next", "Next run {date}", { date: date(status.nextRunAt) }) : void 0
|
|
1296
|
+
},
|
|
1297
|
+
{
|
|
1298
|
+
key: "last",
|
|
1299
|
+
label: t("settings.linkRun.last", "Last run"),
|
|
1300
|
+
value: lastRun ? t(
|
|
1301
|
+
"settings.linkRun.lastValue",
|
|
1302
|
+
"{date}: {checked, number} links checked, {problems, number} with problems.",
|
|
1303
|
+
{
|
|
1304
|
+
date: date(lastRun.finishedAt),
|
|
1305
|
+
checked: lastRun.checked ?? 0,
|
|
1306
|
+
problems: lastRun.problems ?? 0
|
|
1307
|
+
}
|
|
1308
|
+
) : t("settings.environment.linkScheduleNever", "No run yet."),
|
|
1309
|
+
hint: lastRun && !lastRun.complete ? t(
|
|
1310
|
+
"settings.environment.linkScheduleIncomplete",
|
|
1311
|
+
"The last run did not finish; results of earlier runs were kept."
|
|
1312
|
+
) : void 0
|
|
1313
|
+
}
|
|
1314
|
+
]
|
|
1315
|
+
}
|
|
1316
|
+
),
|
|
1317
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { "aria-live": "polite", role: "status", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: announcement }) })
|
|
1318
|
+
]
|
|
1319
|
+
}
|
|
1320
|
+
);
|
|
1321
|
+
};
|
|
1124
1322
|
const RBAC = [...index.PERMISSIONS.settingsRead, ...index.PERMISSIONS.settingsUpdate];
|
|
1125
1323
|
const testErrorText = (t, code) => {
|
|
1126
1324
|
switch (code) {
|
|
@@ -1170,6 +1368,7 @@ const ConfigurationPage = () => {
|
|
|
1170
1368
|
const { allowedActions, isLoading: rbacLoading } = admin.useRBAC(RBAC);
|
|
1171
1369
|
const form = useConfigurationForm();
|
|
1172
1370
|
const title = t("settings.configuration.title", "Configuration");
|
|
1371
|
+
const [liveSchedule, setLiveSchedule] = ReactNamespace.useState(null);
|
|
1173
1372
|
if (rbacLoading || form.status === "loading") {
|
|
1174
1373
|
return /* @__PURE__ */ jsxRuntime.jsxs(admin.Page.Main, { children: [
|
|
1175
1374
|
/* @__PURE__ */ jsxRuntime.jsx(admin.Page.Title, { children: title }),
|
|
@@ -1303,7 +1502,23 @@ const ConfigurationPage = () => {
|
|
|
1303
1502
|
) : null,
|
|
1304
1503
|
/* @__PURE__ */ jsxRuntime.jsx(AiSection, { form, readOnly, onTest }),
|
|
1305
1504
|
/* @__PURE__ */ jsxRuntime.jsx(LanguageToolSection, { form, readOnly, onTest: onTestLanguageTool }),
|
|
1306
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1505
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1506
|
+
EnvironmentSection,
|
|
1507
|
+
{
|
|
1508
|
+
environment: liveSchedule && form.dto.environment ? {
|
|
1509
|
+
...form.dto.environment,
|
|
1510
|
+
linkSchedule: { ...form.dto.environment.linkSchedule, ...liveSchedule }
|
|
1511
|
+
} : form.dto.environment
|
|
1512
|
+
}
|
|
1513
|
+
),
|
|
1514
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1515
|
+
LinkScheduleSection,
|
|
1516
|
+
{
|
|
1517
|
+
initial: form.dto.environment && form.dto.environment.linkSchedule || null,
|
|
1518
|
+
canRun: !readOnly,
|
|
1519
|
+
onStatus: setLiveSchedule
|
|
1520
|
+
}
|
|
1521
|
+
),
|
|
1307
1522
|
/* @__PURE__ */ jsxRuntime.jsx(CspSection, { csp: form.dto.environment && form.dto.environment.csp }),
|
|
1308
1523
|
/* @__PURE__ */ jsxRuntime.jsxs(admin.Form, { method: "PUT", initialValues: form.saved, children: [
|
|
1309
1524
|
/* @__PURE__ */ jsxRuntime.jsx(DraftSync.DraftSync, { values: form.draft }),
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { jsx, jsxs } 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 { u as useT, S as SectionCard, P as PageShell } from "./useT-
|
|
7
|
-
import {
|
|
5
|
+
import { Duplicate, Play, Check } from "@strapi/icons";
|
|
6
|
+
import { P as PERMISSIONS } from "./index-D_Fv8Non.mjs";
|
|
7
|
+
import { u as useT, S as SectionCard, P as PageShell } from "./useT-CLPhBmBC.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 { A as API, r as readApiError } from "./api-2ZRpHM3d.mjs";
|
|
11
12
|
import { useIntl } from "react-intl";
|
|
12
13
|
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
14
|
Flex,
|
|
@@ -20,7 +21,7 @@ const PropertyList = ({ items }) => /* @__PURE__ */ jsx(Box, { tag: "dl", margin
|
|
|
20
21
|
/* @__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
22
|
/* @__PURE__ */ jsxs(Box, { tag: "dd", margin: 0, minWidth: 0, flex: "1 1 auto", children: [
|
|
22
23
|
/* @__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
|
|
24
|
+
item.hint ? /* @__PURE__ */ jsx(Box, { paddingTop: 1, children: /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { overflowWrap: "anywhere" }, children: item.hint }) }) : null
|
|
24
25
|
] })
|
|
25
26
|
]
|
|
26
27
|
},
|
|
@@ -716,6 +717,7 @@ const EnvironmentSection = ({ environment }) => {
|
|
|
716
717
|
}[environment.rawHtml] || environment.rawHtml;
|
|
717
718
|
const collaboration = environment.collaboration || {};
|
|
718
719
|
const linkSchedule = environment.linkSchedule || null;
|
|
720
|
+
const privateImages = Array.isArray(environment.altTextPrivateOrigins) ? environment.altTextPrivateOrigins : [];
|
|
719
721
|
const lastRun = linkSchedule && linkSchedule.lastRun;
|
|
720
722
|
let linkScheduleHint;
|
|
721
723
|
if (linkSchedule && linkSchedule.enabled) {
|
|
@@ -793,6 +795,36 @@ const EnvironmentSection = ({ environment }) => {
|
|
|
793
795
|
value: on(Boolean(linkSchedule && linkSchedule.enabled)),
|
|
794
796
|
hint: linkScheduleHint
|
|
795
797
|
},
|
|
798
|
+
{
|
|
799
|
+
key: "privateImages",
|
|
800
|
+
label: t("settings.environment.privateImages", "Private image storage for alt text"),
|
|
801
|
+
value: privateImages.length ? t(
|
|
802
|
+
"settings.environment.privateImagesCount",
|
|
803
|
+
"{count, plural, =0 {Off} one {# origin} other {# origins}}",
|
|
804
|
+
{ count: privateImages.length }
|
|
805
|
+
) : on(false),
|
|
806
|
+
hint: privateImages.length ? t(
|
|
807
|
+
"settings.environment.privateImagesHint",
|
|
808
|
+
"Alt text suggestions may read images from {origins} (ai.altText.allowPrivateOrigins). Redirects are not followed.",
|
|
809
|
+
{ origins: privateImages.join(", ") }
|
|
810
|
+
) : t(
|
|
811
|
+
"settings.environment.privateImagesNone",
|
|
812
|
+
"Alt text suggestions read images from public addresses only. Self-hosted storage on a private network needs ai.altText.allowPrivateOrigins."
|
|
813
|
+
)
|
|
814
|
+
},
|
|
815
|
+
{
|
|
816
|
+
key: "mentionEmails",
|
|
817
|
+
label: t("settings.environment.mentionEmails", "E-mails for comment mentions"),
|
|
818
|
+
value: on(Boolean(environment.mentionEmails && environment.mentionEmails.enabled)),
|
|
819
|
+
hint: environment.mentionEmails && environment.mentionEmails.enabled ? t(
|
|
820
|
+
"settings.environment.mentionEmailsOn",
|
|
821
|
+
"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).",
|
|
822
|
+
{ count: environment.mentionEmails.perHour ?? 10 }
|
|
823
|
+
) : t(
|
|
824
|
+
"settings.environment.mentionEmailsOff",
|
|
825
|
+
"Mentions show up in the admin only. Turn on e-mails with comments.notifications.email in config/plugins."
|
|
826
|
+
)
|
|
827
|
+
},
|
|
796
828
|
{
|
|
797
829
|
key: "privateAi",
|
|
798
830
|
label: t("settings.environment.privateAi", "Private AI hosts allowed"),
|
|
@@ -1117,6 +1149,172 @@ const LanguageToolSection = ({ form, readOnly, onTest }) => {
|
|
|
1117
1149
|
}
|
|
1118
1150
|
);
|
|
1119
1151
|
};
|
|
1152
|
+
const POLL_MS = 3e3;
|
|
1153
|
+
const MAX_POLLS = 300;
|
|
1154
|
+
const LinkScheduleSection = ({ initial, canRun, onStatus }) => {
|
|
1155
|
+
const t = useT();
|
|
1156
|
+
const { formatDate } = useIntl();
|
|
1157
|
+
const { get, post } = useFetchClient();
|
|
1158
|
+
const [status, setStatus] = useState(initial);
|
|
1159
|
+
const [starting, setStarting] = useState(false);
|
|
1160
|
+
const [notice, setNotice] = useState(null);
|
|
1161
|
+
const [announcement, setAnnouncement] = useState("");
|
|
1162
|
+
const polls = useRef(0);
|
|
1163
|
+
const timer = useRef(null);
|
|
1164
|
+
const wasRunning = useRef(Boolean(initial && initial.running));
|
|
1165
|
+
const refresh = useCallback(async () => {
|
|
1166
|
+
try {
|
|
1167
|
+
const { data } = await get(API.linkSchedule);
|
|
1168
|
+
const next = data.data;
|
|
1169
|
+
setStatus(next);
|
|
1170
|
+
if (wasRunning.current && !next.running) {
|
|
1171
|
+
setAnnouncement(t("settings.linkRun.finished", "The link check finished."));
|
|
1172
|
+
setNotice(null);
|
|
1173
|
+
}
|
|
1174
|
+
wasRunning.current = Boolean(next.running);
|
|
1175
|
+
return next;
|
|
1176
|
+
} catch {
|
|
1177
|
+
return null;
|
|
1178
|
+
}
|
|
1179
|
+
}, [get, t]);
|
|
1180
|
+
const running = Boolean(status && status.running);
|
|
1181
|
+
useEffect(() => {
|
|
1182
|
+
if (onStatus && status && status !== initial) onStatus(status);
|
|
1183
|
+
}, [status, initial, onStatus]);
|
|
1184
|
+
useEffect(() => {
|
|
1185
|
+
if (!running) {
|
|
1186
|
+
polls.current = 0;
|
|
1187
|
+
return void 0;
|
|
1188
|
+
}
|
|
1189
|
+
timer.current = window.setTimeout(async () => {
|
|
1190
|
+
polls.current += 1;
|
|
1191
|
+
if (polls.current > MAX_POLLS) {
|
|
1192
|
+
setNotice({
|
|
1193
|
+
variant: "default",
|
|
1194
|
+
text: t(
|
|
1195
|
+
"settings.linkRun.stillRunning",
|
|
1196
|
+
"The check is still running. Reload the page later to see the result."
|
|
1197
|
+
)
|
|
1198
|
+
});
|
|
1199
|
+
return;
|
|
1200
|
+
}
|
|
1201
|
+
await refresh();
|
|
1202
|
+
}, POLL_MS);
|
|
1203
|
+
return () => window.clearTimeout(timer.current);
|
|
1204
|
+
}, [running, status, refresh, t]);
|
|
1205
|
+
if (!status || !status.enabled) return null;
|
|
1206
|
+
const runNow = async () => {
|
|
1207
|
+
setStarting(true);
|
|
1208
|
+
setNotice(null);
|
|
1209
|
+
setAnnouncement("");
|
|
1210
|
+
try {
|
|
1211
|
+
await post(API.linkScheduleRun, {});
|
|
1212
|
+
setAnnouncement(t("settings.linkRun.started", "The link check started."));
|
|
1213
|
+
wasRunning.current = true;
|
|
1214
|
+
setStatus((current) => ({ ...current, running: true }));
|
|
1215
|
+
} catch (error) {
|
|
1216
|
+
const info = readApiError(error);
|
|
1217
|
+
if (info.status === 409) {
|
|
1218
|
+
setNotice({
|
|
1219
|
+
variant: "default",
|
|
1220
|
+
text: t(
|
|
1221
|
+
"settings.linkRun.conflict",
|
|
1222
|
+
"A link check is already running. The result appears here when it finishes."
|
|
1223
|
+
)
|
|
1224
|
+
});
|
|
1225
|
+
wasRunning.current = true;
|
|
1226
|
+
setStatus((current) => ({ ...current, running: true }));
|
|
1227
|
+
} else if (info.status === 400 && info.code === "DISABLED") {
|
|
1228
|
+
setNotice({
|
|
1229
|
+
variant: "warning",
|
|
1230
|
+
text: t(
|
|
1231
|
+
"settings.linkRun.disabled",
|
|
1232
|
+
"Scheduled link checks are turned off in config/plugins.js (qualityChecks.externalLinks.schedule)."
|
|
1233
|
+
)
|
|
1234
|
+
});
|
|
1235
|
+
} else {
|
|
1236
|
+
setNotice({
|
|
1237
|
+
variant: "danger",
|
|
1238
|
+
text: t("settings.linkRun.failed", "The link check could not be started. Try again.")
|
|
1239
|
+
});
|
|
1240
|
+
}
|
|
1241
|
+
} finally {
|
|
1242
|
+
setStarting(false);
|
|
1243
|
+
}
|
|
1244
|
+
};
|
|
1245
|
+
const date = (value) => value ? formatDate(new Date(value), { dateStyle: "medium", timeStyle: "short" }) : "";
|
|
1246
|
+
const lastRun = status.lastRun;
|
|
1247
|
+
const zone = status.tz || t("settings.linkRun.serverZone", "Server time zone");
|
|
1248
|
+
return /* @__PURE__ */ jsxs(
|
|
1249
|
+
SectionCard,
|
|
1250
|
+
{
|
|
1251
|
+
title: t("settings.linkRun.title", "Scheduled link check"),
|
|
1252
|
+
subtitle: t(
|
|
1253
|
+
"settings.linkRun.subtitle",
|
|
1254
|
+
"Checks every external link in all editor fields on a schedule. You can also start a check now."
|
|
1255
|
+
),
|
|
1256
|
+
action: canRun ? /* @__PURE__ */ jsx(
|
|
1257
|
+
Button,
|
|
1258
|
+
{
|
|
1259
|
+
startIcon: /* @__PURE__ */ jsx(Play, {}),
|
|
1260
|
+
variant: "secondary",
|
|
1261
|
+
onClick: runNow,
|
|
1262
|
+
loading: starting,
|
|
1263
|
+
disabled: starting || running,
|
|
1264
|
+
children: running ? t("settings.linkRun.running", "Check running") : t("settings.linkRun.run", "Run now")
|
|
1265
|
+
}
|
|
1266
|
+
) : null,
|
|
1267
|
+
children: [
|
|
1268
|
+
!canRun ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: t("settings.linkRun.noPermission", 'Starting a check needs the "Update settings" permission.') }) : null,
|
|
1269
|
+
notice ? /* @__PURE__ */ jsx(
|
|
1270
|
+
Alert,
|
|
1271
|
+
{
|
|
1272
|
+
variant: notice.variant,
|
|
1273
|
+
closeLabel: t("settings.close", "Close"),
|
|
1274
|
+
onClose: () => setNotice(null),
|
|
1275
|
+
children: notice.text
|
|
1276
|
+
}
|
|
1277
|
+
) : null,
|
|
1278
|
+
/* @__PURE__ */ jsx(
|
|
1279
|
+
PropertyList,
|
|
1280
|
+
{
|
|
1281
|
+
items: [
|
|
1282
|
+
{
|
|
1283
|
+
key: "state",
|
|
1284
|
+
label: t("settings.linkRun.state", "State"),
|
|
1285
|
+
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") })
|
|
1286
|
+
},
|
|
1287
|
+
{
|
|
1288
|
+
key: "rule",
|
|
1289
|
+
label: t("settings.linkRun.rule", "Schedule"),
|
|
1290
|
+
value: t("settings.linkRun.ruleValue", "{rule} ({zone})", { rule: status.rule || "", zone }),
|
|
1291
|
+
hint: status.nextRunAt ? t("settings.linkRun.next", "Next run {date}", { date: date(status.nextRunAt) }) : void 0
|
|
1292
|
+
},
|
|
1293
|
+
{
|
|
1294
|
+
key: "last",
|
|
1295
|
+
label: t("settings.linkRun.last", "Last run"),
|
|
1296
|
+
value: lastRun ? t(
|
|
1297
|
+
"settings.linkRun.lastValue",
|
|
1298
|
+
"{date}: {checked, number} links checked, {problems, number} with problems.",
|
|
1299
|
+
{
|
|
1300
|
+
date: date(lastRun.finishedAt),
|
|
1301
|
+
checked: lastRun.checked ?? 0,
|
|
1302
|
+
problems: lastRun.problems ?? 0
|
|
1303
|
+
}
|
|
1304
|
+
) : t("settings.environment.linkScheduleNever", "No run yet."),
|
|
1305
|
+
hint: lastRun && !lastRun.complete ? t(
|
|
1306
|
+
"settings.environment.linkScheduleIncomplete",
|
|
1307
|
+
"The last run did not finish; results of earlier runs were kept."
|
|
1308
|
+
) : void 0
|
|
1309
|
+
}
|
|
1310
|
+
]
|
|
1311
|
+
}
|
|
1312
|
+
),
|
|
1313
|
+
/* @__PURE__ */ jsx(Box, { "aria-live": "polite", role: "status", children: /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: announcement }) })
|
|
1314
|
+
]
|
|
1315
|
+
}
|
|
1316
|
+
);
|
|
1317
|
+
};
|
|
1120
1318
|
const RBAC = [...PERMISSIONS.settingsRead, ...PERMISSIONS.settingsUpdate];
|
|
1121
1319
|
const testErrorText = (t, code) => {
|
|
1122
1320
|
switch (code) {
|
|
@@ -1166,6 +1364,7 @@ const ConfigurationPage = () => {
|
|
|
1166
1364
|
const { allowedActions, isLoading: rbacLoading } = useRBAC(RBAC);
|
|
1167
1365
|
const form = useConfigurationForm();
|
|
1168
1366
|
const title = t("settings.configuration.title", "Configuration");
|
|
1367
|
+
const [liveSchedule, setLiveSchedule] = useState(null);
|
|
1169
1368
|
if (rbacLoading || form.status === "loading") {
|
|
1170
1369
|
return /* @__PURE__ */ jsxs(Page.Main, { children: [
|
|
1171
1370
|
/* @__PURE__ */ jsx(Page.Title, { children: title }),
|
|
@@ -1299,7 +1498,23 @@ const ConfigurationPage = () => {
|
|
|
1299
1498
|
) : null,
|
|
1300
1499
|
/* @__PURE__ */ jsx(AiSection, { form, readOnly, onTest }),
|
|
1301
1500
|
/* @__PURE__ */ jsx(LanguageToolSection, { form, readOnly, onTest: onTestLanguageTool }),
|
|
1302
|
-
/* @__PURE__ */ jsx(
|
|
1501
|
+
/* @__PURE__ */ jsx(
|
|
1502
|
+
EnvironmentSection,
|
|
1503
|
+
{
|
|
1504
|
+
environment: liveSchedule && form.dto.environment ? {
|
|
1505
|
+
...form.dto.environment,
|
|
1506
|
+
linkSchedule: { ...form.dto.environment.linkSchedule, ...liveSchedule }
|
|
1507
|
+
} : form.dto.environment
|
|
1508
|
+
}
|
|
1509
|
+
),
|
|
1510
|
+
/* @__PURE__ */ jsx(
|
|
1511
|
+
LinkScheduleSection,
|
|
1512
|
+
{
|
|
1513
|
+
initial: form.dto.environment && form.dto.environment.linkSchedule || null,
|
|
1514
|
+
canRun: !readOnly,
|
|
1515
|
+
onStatus: setLiveSchedule
|
|
1516
|
+
}
|
|
1517
|
+
),
|
|
1303
1518
|
/* @__PURE__ */ jsx(CspSection, { csp: form.dto.environment && form.dto.environment.csp }),
|
|
1304
1519
|
/* @__PURE__ */ jsxs(Form, { method: "PUT", initialValues: form.saved, children: [
|
|
1305
1520
|
/* @__PURE__ */ jsx(DraftSync, { values: form.draft }),
|