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,10 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useState, useRef } from "react";
|
|
3
|
-
import { Dialog, Button } from "@strapi/design-system";
|
|
4
|
-
import { ConfirmDialog } from "@strapi/strapi/admin";
|
|
5
1
|
const API = {
|
|
6
2
|
config: "/magic-editor-x/config",
|
|
7
3
|
link: "/magic-editor-x/link",
|
|
8
4
|
imageByFile: "/magic-editor-x/image/byFile",
|
|
9
5
|
imageByUrl: "/magic-editor-x/image/byUrl",
|
|
10
6
|
fileUpload: "/magic-editor-x/file/upload",
|
|
7
|
+
mediaByUrl: "/magic-editor-x/media/byUrl",
|
|
11
8
|
contentTypes: "/magic-editor-x/content-types",
|
|
12
9
|
linkTypes: "/magic-editor-x/links/types",
|
|
13
10
|
linkSearch: "/magic-editor-x/links/search",
|
|
@@ -25,21 +22,47 @@ const API = {
|
|
|
25
22
|
ai: (action) => `/magic-editor-x/ai/${encodeURIComponent(action)}`,
|
|
26
23
|
aiAltText: "/magic-editor-x/ai/image/alt-text",
|
|
27
24
|
aiField: (action) => `/magic-editor-x/ai/field/${encodeURIComponent(action)}`,
|
|
25
|
+
aiBlocks: (action) => `/magic-editor-x/ai/blocks/${encodeURIComponent(action)}`,
|
|
28
26
|
grammarCheck: "/magic-editor-x/grammar/check",
|
|
29
27
|
comments: "/magic-editor-x/comments",
|
|
30
28
|
comment: (id) => `/magic-editor-x/comments/${encodeURIComponent(id)}`,
|
|
31
29
|
commentReplies: (id) => `/magic-editor-x/comments/${encodeURIComponent(id)}/replies`,
|
|
32
30
|
commentResolve: (id) => `/magic-editor-x/comments/${encodeURIComponent(id)}/resolve`,
|
|
33
31
|
commentReopen: (id) => `/magic-editor-x/comments/${encodeURIComponent(id)}/reopen`,
|
|
32
|
+
// 2.4: @mentions and notifications.
|
|
33
|
+
commentMentionable: "/magic-editor-x/comments/mentionable",
|
|
34
|
+
notifications: "/magic-editor-x/notifications",
|
|
35
|
+
notificationsReadAll: "/magic-editor-x/notifications/read-all",
|
|
36
|
+
notificationRead: (id) => `/magic-editor-x/notifications/${encodeURIComponent(id)}/read`,
|
|
37
|
+
notificationUnread: (id) => `/magic-editor-x/notifications/${encodeURIComponent(id)}/unread`,
|
|
38
|
+
suggestions: "/magic-editor-x/suggestions",
|
|
39
|
+
suggestion: (id) => `/magic-editor-x/suggestions/${encodeURIComponent(id)}`,
|
|
40
|
+
suggestionAccept: (id) => `/magic-editor-x/suggestions/${encodeURIComponent(id)}/accept`,
|
|
41
|
+
suggestionReject: (id) => `/magic-editor-x/suggestions/${encodeURIComponent(id)}/reject`,
|
|
34
42
|
templates: "/magic-editor-x/templates",
|
|
35
43
|
templateTargets: "/magic-editor-x/templates/targets",
|
|
36
44
|
templatesOrder: "/magic-editor-x/templates/order",
|
|
37
45
|
template: (id) => `/magic-editor-x/templates/${encodeURIComponent(id)}`,
|
|
38
46
|
templateDuplicate: (id) => `/magic-editor-x/templates/${encodeURIComponent(id)}/duplicate`,
|
|
39
47
|
templateUsage: (id) => `/magic-editor-x/templates/${encodeURIComponent(id)}/usage`,
|
|
48
|
+
templateVersions: (id) => `/magic-editor-x/templates/${encodeURIComponent(id)}/versions`,
|
|
49
|
+
templateVersion: (id, versionId) => `/magic-editor-x/templates/${encodeURIComponent(id)}/versions/${encodeURIComponent(versionId)}`,
|
|
50
|
+
templateVersionRestore: (id, versionId) => `/magic-editor-x/templates/${encodeURIComponent(id)}/versions/${encodeURIComponent(versionId)}/restore`,
|
|
51
|
+
audit: "/magic-editor-x/audit",
|
|
52
|
+
auditActors: "/magic-editor-x/audit/actors",
|
|
53
|
+
linkSchedule: "/magic-editor-x/quality/link-schedule",
|
|
54
|
+
linkScheduleRun: "/magic-editor-x/quality/link-schedule/run",
|
|
40
55
|
settings: "/magic-editor-x/settings",
|
|
41
56
|
settingsAiTest: "/magic-editor-x/settings/ai/test",
|
|
42
|
-
settingsLanguageToolTest: "/magic-editor-x/settings/language-tool/test"
|
|
57
|
+
settingsLanguageToolTest: "/magic-editor-x/settings/language-tool/test",
|
|
58
|
+
// 2.5: entry side panel and homepage widgets.
|
|
59
|
+
presence: "/magic-editor-x/presence",
|
|
60
|
+
entrySummary: "/magic-editor-x/entry-summary",
|
|
61
|
+
widgetOpenThreads: "/magic-editor-x/widgets/open-threads",
|
|
62
|
+
widgetBrokenLinks: "/magic-editor-x/widgets/broken-links",
|
|
63
|
+
// 2.5 "Use existing content".
|
|
64
|
+
reuseTypes: "/magic-editor-x/reuse/types",
|
|
65
|
+
reuseSource: "/magic-editor-x/reuse/source"
|
|
43
66
|
};
|
|
44
67
|
const readApiError = (error) => {
|
|
45
68
|
const response = error && error.response;
|
|
@@ -53,73 +76,7 @@ const readApiError = (error) => {
|
|
|
53
76
|
details: apiError && apiError.details || null
|
|
54
77
|
};
|
|
55
78
|
};
|
|
56
|
-
const canTakeFocus = (el) => Boolean(
|
|
57
|
-
el && el.isConnected && typeof el.focus === "function" && !el.disabled && (typeof el.getAttribute !== "function" || el.getAttribute("aria-disabled") !== "true")
|
|
58
|
-
);
|
|
59
|
-
const pickFocusTarget = (opener, fallback) => {
|
|
60
|
-
if (canTakeFocus(opener)) return opener;
|
|
61
|
-
if (canTakeFocus(fallback)) return fallback;
|
|
62
|
-
return null;
|
|
63
|
-
};
|
|
64
|
-
const refocusIfLost = (opener, fallback, doc = globalThis.document) => {
|
|
65
|
-
if (!doc) return;
|
|
66
|
-
const active = doc.activeElement;
|
|
67
|
-
if (active && active !== doc.body) return;
|
|
68
|
-
const target = pickFocusTarget(opener, fallback);
|
|
69
|
-
if (target) target.focus();
|
|
70
|
-
};
|
|
71
|
-
const ConfirmAction = ({
|
|
72
|
-
trigger,
|
|
73
|
-
title,
|
|
74
|
-
body,
|
|
75
|
-
confirmLabel,
|
|
76
|
-
onConfirm,
|
|
77
|
-
variant = "danger",
|
|
78
|
-
disabled = false,
|
|
79
|
-
fallbackFocusRef
|
|
80
|
-
}) => {
|
|
81
|
-
const [open, setOpen] = useState(false);
|
|
82
|
-
const [busy, setBusy] = useState(false);
|
|
83
|
-
const triggerRef = useRef(null);
|
|
84
|
-
const restoreFocus = () => requestAnimationFrame(() => {
|
|
85
|
-
const active = document.activeElement;
|
|
86
|
-
if (active && active !== document.body) return;
|
|
87
|
-
const target = pickFocusTarget(triggerRef.current, fallbackFocusRef && fallbackFocusRef.current);
|
|
88
|
-
if (target) target.focus();
|
|
89
|
-
});
|
|
90
|
-
const onOpenChange = (next) => {
|
|
91
|
-
if (busy) return;
|
|
92
|
-
setOpen(next);
|
|
93
|
-
if (!next) restoreFocus();
|
|
94
|
-
};
|
|
95
|
-
const confirm = async (event) => {
|
|
96
|
-
if (event && typeof event.preventDefault === "function") event.preventDefault();
|
|
97
|
-
setBusy(true);
|
|
98
|
-
try {
|
|
99
|
-
await onConfirm();
|
|
100
|
-
setOpen(false);
|
|
101
|
-
restoreFocus();
|
|
102
|
-
} catch {
|
|
103
|
-
} finally {
|
|
104
|
-
setBusy(false);
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
return /* @__PURE__ */ jsxs(Dialog.Root, { open, onOpenChange, children: [
|
|
108
|
-
/* @__PURE__ */ jsx(Dialog.Trigger, { ref: triggerRef, disabled, children: trigger }),
|
|
109
|
-
/* @__PURE__ */ jsx(
|
|
110
|
-
ConfirmDialog,
|
|
111
|
-
{
|
|
112
|
-
title,
|
|
113
|
-
variant,
|
|
114
|
-
endAction: /* @__PURE__ */ jsx(Button, { fullWidth: true, variant, onClick: confirm, loading: busy, disabled: busy, children: confirmLabel }),
|
|
115
|
-
children: body
|
|
116
|
-
}
|
|
117
|
-
)
|
|
118
|
-
] });
|
|
119
|
-
};
|
|
120
79
|
export {
|
|
121
80
|
API as A,
|
|
122
|
-
ConfirmAction as C,
|
|
123
|
-
refocusIfLost as a,
|
|
124
81
|
readApiError as r
|
|
125
82
|
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
const EVENT_LABELS = {
|
|
2
|
+
"entry.create": { key: "settings.audit.event.entryCreate", text: "Entry created" },
|
|
3
|
+
"entry.update": { key: "settings.audit.event.entryUpdate", text: "Entry saved" },
|
|
4
|
+
"entry.publish": { key: "settings.audit.event.entryPublish", text: "Published" },
|
|
5
|
+
"entry.unpublish": { key: "settings.audit.event.entryUnpublish", text: "Unpublished" },
|
|
6
|
+
"entry.discard": { key: "settings.audit.event.entryDiscard", text: "Draft discarded" },
|
|
7
|
+
"entry.delete": { key: "settings.audit.event.entryDelete", text: "Entry deleted" },
|
|
8
|
+
"version.create": { key: "settings.audit.event.versionCreate", text: "Version saved" },
|
|
9
|
+
"version.restore": { key: "settings.audit.event.versionRestore", text: "Version restored" },
|
|
10
|
+
"version.rename": { key: "settings.audit.event.versionRename", text: "Version renamed" },
|
|
11
|
+
"ai.action": { key: "settings.audit.event.aiAction", text: "AI assistant used" },
|
|
12
|
+
"comment.create": { key: "settings.audit.event.commentCreate", text: "Comment added" },
|
|
13
|
+
"comment.reply": { key: "settings.audit.event.commentReply", text: "Reply added" },
|
|
14
|
+
"comment.resolve": { key: "settings.audit.event.commentResolve", text: "Thread resolved" },
|
|
15
|
+
"comment.reopen": { key: "settings.audit.event.commentReopen", text: "Thread reopened" },
|
|
16
|
+
"comment.delete": { key: "settings.audit.event.commentDelete", text: "Comment deleted" },
|
|
17
|
+
"comment.moderate": { key: "settings.audit.event.commentModerate", text: "Comment removed by a moderator" },
|
|
18
|
+
"template.create": { key: "settings.audit.event.templateCreate", text: "Template created" },
|
|
19
|
+
"template.update": { key: "settings.audit.event.templateUpdate", text: "Template changed" },
|
|
20
|
+
"template.delete": { key: "settings.audit.event.templateDelete", text: "Template deleted" },
|
|
21
|
+
"synced.create": { key: "settings.audit.event.syncedCreate", text: "Synced block created" },
|
|
22
|
+
"synced.update": { key: "settings.audit.event.syncedUpdate", text: "Synced block changed" },
|
|
23
|
+
"synced.delete": { key: "settings.audit.event.syncedDelete", text: "Synced block deleted" },
|
|
24
|
+
"synced.restore": { key: "settings.audit.event.syncedRestore", text: "Synced block version restored" },
|
|
25
|
+
"settings.update": { key: "settings.audit.event.settingsUpdate", text: "Settings changed" },
|
|
26
|
+
"linkcheck.run": { key: "settings.audit.event.linkcheckRun", text: "Link check run" },
|
|
27
|
+
"ai.localize": { key: "settings.audit.event.aiLocalize", text: "Strapi AI translation checked" },
|
|
28
|
+
// 2.4 block suggestions
|
|
29
|
+
"suggestion.create": { key: "settings.audit.event.suggestionCreate", text: "Changes suggested" },
|
|
30
|
+
"suggestion.accept": { key: "settings.audit.event.suggestionAccept", text: "Suggestion accepted" },
|
|
31
|
+
"suggestion.reject": { key: "settings.audit.event.suggestionReject", text: "Suggestion rejected" },
|
|
32
|
+
"suggestion.withdraw": { key: "settings.audit.event.suggestionWithdraw", text: "Suggestion withdrawn" }
|
|
33
|
+
};
|
|
34
|
+
const eventLabel = (t, event) => {
|
|
35
|
+
const entry = EVENT_LABELS[event];
|
|
36
|
+
return entry ? t(entry.key, entry.text) : event;
|
|
37
|
+
};
|
|
38
|
+
const actorLabel = (t, actor) => {
|
|
39
|
+
if (!actor) return t("settings.audit.actor.system", "System");
|
|
40
|
+
if (actor.kind === "deleted") return t("settings.audit.actor.deleted", "Deleted user");
|
|
41
|
+
if (actor.kind === "api") return t("settings.audit.actor.api", "Content API");
|
|
42
|
+
if (actor.kind === "system") return t("settings.audit.actor.system", "System");
|
|
43
|
+
const name = actor.name || t("settings.audit.actor.unnamed", "Admin without a name");
|
|
44
|
+
return actor.own ? t("settings.audit.actor.you", "{name} (you)", { name }) : name;
|
|
45
|
+
};
|
|
46
|
+
const changeSummary = (t, item) => {
|
|
47
|
+
const counts = item.counts || {};
|
|
48
|
+
const meta = item.meta || {};
|
|
49
|
+
const parts = [];
|
|
50
|
+
if (item.event && item.event.startsWith("entry.")) {
|
|
51
|
+
if (counts.added)
|
|
52
|
+
parts.push(t("settings.audit.counts.added", "{count, number} added", { count: counts.added }));
|
|
53
|
+
if (counts.changed)
|
|
54
|
+
parts.push(t("settings.audit.counts.changed", "{count, number} changed", { count: counts.changed }));
|
|
55
|
+
if (counts.removed)
|
|
56
|
+
parts.push(t("settings.audit.counts.removed", "{count, number} removed", { count: counts.removed }));
|
|
57
|
+
if (counts.moved)
|
|
58
|
+
parts.push(t("settings.audit.counts.moved", "{count, number} moved", { count: counts.moved }));
|
|
59
|
+
}
|
|
60
|
+
if (item.event && item.event.startsWith("version.") && counts.version)
|
|
61
|
+
parts.push(t("settings.audit.counts.version", "Version {version}", { version: counts.version }));
|
|
62
|
+
if (item.event === "ai.action" && typeof meta.action === "string") {
|
|
63
|
+
parts.push(t("settings.audit.meta.action", "Action: {action}", { action: meta.action }));
|
|
64
|
+
if (counts.segments)
|
|
65
|
+
parts.push(
|
|
66
|
+
t("settings.audit.counts.segments", "{count, plural, one {# text} other {# texts}}", {
|
|
67
|
+
count: counts.segments
|
|
68
|
+
})
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
if (item.event === "settings.update" && Array.isArray(meta.keys) && meta.keys.length)
|
|
72
|
+
parts.push(t("settings.audit.meta.keys", "Sections: {keys}", { keys: meta.keys.join(", ") }));
|
|
73
|
+
if (item.event === "linkcheck.run")
|
|
74
|
+
parts.push(
|
|
75
|
+
t(
|
|
76
|
+
"settings.audit.counts.linkcheck",
|
|
77
|
+
"{checked, number} links checked, {problems, number} with problems",
|
|
78
|
+
{ checked: counts.checked || 0, problems: counts.problems || 0 }
|
|
79
|
+
)
|
|
80
|
+
);
|
|
81
|
+
if (item.event === "ai.localize")
|
|
82
|
+
parts.push(
|
|
83
|
+
t(
|
|
84
|
+
"settings.audit.counts.aiLocalize",
|
|
85
|
+
"{translated, number} of {segments, number} texts translated, {kept, number} kept from the source locale",
|
|
86
|
+
{ translated: counts.translated || 0, segments: counts.segments || 0, kept: counts.kept || 0 }
|
|
87
|
+
)
|
|
88
|
+
);
|
|
89
|
+
if ((item.event || "").match(/^(template|synced)\./) && Number.isInteger(counts.blocks))
|
|
90
|
+
parts.push(
|
|
91
|
+
t("settings.audit.counts.blocks", "{count, plural, one {# block} other {# blocks}}", {
|
|
92
|
+
count: counts.blocks
|
|
93
|
+
})
|
|
94
|
+
);
|
|
95
|
+
if (item.event === "suggestion.create" && Number.isInteger(counts.suggestions))
|
|
96
|
+
parts.push(
|
|
97
|
+
t("settings.audit.counts.blocks", "{count, plural, one {# block} other {# blocks}}", {
|
|
98
|
+
count: counts.suggestions
|
|
99
|
+
})
|
|
100
|
+
);
|
|
101
|
+
if (item.event === "suggestion.accept" && counts.outdated)
|
|
102
|
+
parts.push(t("settings.audit.counts.outdated", "Replaced a newer version of the block"));
|
|
103
|
+
return parts.join(" · ");
|
|
104
|
+
};
|
|
105
|
+
export {
|
|
106
|
+
EVENT_LABELS as E,
|
|
107
|
+
actorLabel as a,
|
|
108
|
+
changeSummary as c,
|
|
109
|
+
eventLabel as e
|
|
110
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const EVENT_LABELS = {
|
|
3
|
+
"entry.create": { key: "settings.audit.event.entryCreate", text: "Entry created" },
|
|
4
|
+
"entry.update": { key: "settings.audit.event.entryUpdate", text: "Entry saved" },
|
|
5
|
+
"entry.publish": { key: "settings.audit.event.entryPublish", text: "Published" },
|
|
6
|
+
"entry.unpublish": { key: "settings.audit.event.entryUnpublish", text: "Unpublished" },
|
|
7
|
+
"entry.discard": { key: "settings.audit.event.entryDiscard", text: "Draft discarded" },
|
|
8
|
+
"entry.delete": { key: "settings.audit.event.entryDelete", text: "Entry deleted" },
|
|
9
|
+
"version.create": { key: "settings.audit.event.versionCreate", text: "Version saved" },
|
|
10
|
+
"version.restore": { key: "settings.audit.event.versionRestore", text: "Version restored" },
|
|
11
|
+
"version.rename": { key: "settings.audit.event.versionRename", text: "Version renamed" },
|
|
12
|
+
"ai.action": { key: "settings.audit.event.aiAction", text: "AI assistant used" },
|
|
13
|
+
"comment.create": { key: "settings.audit.event.commentCreate", text: "Comment added" },
|
|
14
|
+
"comment.reply": { key: "settings.audit.event.commentReply", text: "Reply added" },
|
|
15
|
+
"comment.resolve": { key: "settings.audit.event.commentResolve", text: "Thread resolved" },
|
|
16
|
+
"comment.reopen": { key: "settings.audit.event.commentReopen", text: "Thread reopened" },
|
|
17
|
+
"comment.delete": { key: "settings.audit.event.commentDelete", text: "Comment deleted" },
|
|
18
|
+
"comment.moderate": { key: "settings.audit.event.commentModerate", text: "Comment removed by a moderator" },
|
|
19
|
+
"template.create": { key: "settings.audit.event.templateCreate", text: "Template created" },
|
|
20
|
+
"template.update": { key: "settings.audit.event.templateUpdate", text: "Template changed" },
|
|
21
|
+
"template.delete": { key: "settings.audit.event.templateDelete", text: "Template deleted" },
|
|
22
|
+
"synced.create": { key: "settings.audit.event.syncedCreate", text: "Synced block created" },
|
|
23
|
+
"synced.update": { key: "settings.audit.event.syncedUpdate", text: "Synced block changed" },
|
|
24
|
+
"synced.delete": { key: "settings.audit.event.syncedDelete", text: "Synced block deleted" },
|
|
25
|
+
"synced.restore": { key: "settings.audit.event.syncedRestore", text: "Synced block version restored" },
|
|
26
|
+
"settings.update": { key: "settings.audit.event.settingsUpdate", text: "Settings changed" },
|
|
27
|
+
"linkcheck.run": { key: "settings.audit.event.linkcheckRun", text: "Link check run" },
|
|
28
|
+
"ai.localize": { key: "settings.audit.event.aiLocalize", text: "Strapi AI translation checked" },
|
|
29
|
+
// 2.4 block suggestions
|
|
30
|
+
"suggestion.create": { key: "settings.audit.event.suggestionCreate", text: "Changes suggested" },
|
|
31
|
+
"suggestion.accept": { key: "settings.audit.event.suggestionAccept", text: "Suggestion accepted" },
|
|
32
|
+
"suggestion.reject": { key: "settings.audit.event.suggestionReject", text: "Suggestion rejected" },
|
|
33
|
+
"suggestion.withdraw": { key: "settings.audit.event.suggestionWithdraw", text: "Suggestion withdrawn" }
|
|
34
|
+
};
|
|
35
|
+
const eventLabel = (t, event) => {
|
|
36
|
+
const entry = EVENT_LABELS[event];
|
|
37
|
+
return entry ? t(entry.key, entry.text) : event;
|
|
38
|
+
};
|
|
39
|
+
const actorLabel = (t, actor) => {
|
|
40
|
+
if (!actor) return t("settings.audit.actor.system", "System");
|
|
41
|
+
if (actor.kind === "deleted") return t("settings.audit.actor.deleted", "Deleted user");
|
|
42
|
+
if (actor.kind === "api") return t("settings.audit.actor.api", "Content API");
|
|
43
|
+
if (actor.kind === "system") return t("settings.audit.actor.system", "System");
|
|
44
|
+
const name = actor.name || t("settings.audit.actor.unnamed", "Admin without a name");
|
|
45
|
+
return actor.own ? t("settings.audit.actor.you", "{name} (you)", { name }) : name;
|
|
46
|
+
};
|
|
47
|
+
const changeSummary = (t, item) => {
|
|
48
|
+
const counts = item.counts || {};
|
|
49
|
+
const meta = item.meta || {};
|
|
50
|
+
const parts = [];
|
|
51
|
+
if (item.event && item.event.startsWith("entry.")) {
|
|
52
|
+
if (counts.added)
|
|
53
|
+
parts.push(t("settings.audit.counts.added", "{count, number} added", { count: counts.added }));
|
|
54
|
+
if (counts.changed)
|
|
55
|
+
parts.push(t("settings.audit.counts.changed", "{count, number} changed", { count: counts.changed }));
|
|
56
|
+
if (counts.removed)
|
|
57
|
+
parts.push(t("settings.audit.counts.removed", "{count, number} removed", { count: counts.removed }));
|
|
58
|
+
if (counts.moved)
|
|
59
|
+
parts.push(t("settings.audit.counts.moved", "{count, number} moved", { count: counts.moved }));
|
|
60
|
+
}
|
|
61
|
+
if (item.event && item.event.startsWith("version.") && counts.version)
|
|
62
|
+
parts.push(t("settings.audit.counts.version", "Version {version}", { version: counts.version }));
|
|
63
|
+
if (item.event === "ai.action" && typeof meta.action === "string") {
|
|
64
|
+
parts.push(t("settings.audit.meta.action", "Action: {action}", { action: meta.action }));
|
|
65
|
+
if (counts.segments)
|
|
66
|
+
parts.push(
|
|
67
|
+
t("settings.audit.counts.segments", "{count, plural, one {# text} other {# texts}}", {
|
|
68
|
+
count: counts.segments
|
|
69
|
+
})
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
if (item.event === "settings.update" && Array.isArray(meta.keys) && meta.keys.length)
|
|
73
|
+
parts.push(t("settings.audit.meta.keys", "Sections: {keys}", { keys: meta.keys.join(", ") }));
|
|
74
|
+
if (item.event === "linkcheck.run")
|
|
75
|
+
parts.push(
|
|
76
|
+
t(
|
|
77
|
+
"settings.audit.counts.linkcheck",
|
|
78
|
+
"{checked, number} links checked, {problems, number} with problems",
|
|
79
|
+
{ checked: counts.checked || 0, problems: counts.problems || 0 }
|
|
80
|
+
)
|
|
81
|
+
);
|
|
82
|
+
if (item.event === "ai.localize")
|
|
83
|
+
parts.push(
|
|
84
|
+
t(
|
|
85
|
+
"settings.audit.counts.aiLocalize",
|
|
86
|
+
"{translated, number} of {segments, number} texts translated, {kept, number} kept from the source locale",
|
|
87
|
+
{ translated: counts.translated || 0, segments: counts.segments || 0, kept: counts.kept || 0 }
|
|
88
|
+
)
|
|
89
|
+
);
|
|
90
|
+
if ((item.event || "").match(/^(template|synced)\./) && Number.isInteger(counts.blocks))
|
|
91
|
+
parts.push(
|
|
92
|
+
t("settings.audit.counts.blocks", "{count, plural, one {# block} other {# blocks}}", {
|
|
93
|
+
count: counts.blocks
|
|
94
|
+
})
|
|
95
|
+
);
|
|
96
|
+
if (item.event === "suggestion.create" && Number.isInteger(counts.suggestions))
|
|
97
|
+
parts.push(
|
|
98
|
+
t("settings.audit.counts.blocks", "{count, plural, one {# block} other {# blocks}}", {
|
|
99
|
+
count: counts.suggestions
|
|
100
|
+
})
|
|
101
|
+
);
|
|
102
|
+
if (item.event === "suggestion.accept" && counts.outdated)
|
|
103
|
+
parts.push(t("settings.audit.counts.outdated", "Replaced a newer version of the block"));
|
|
104
|
+
return parts.join(" · ");
|
|
105
|
+
};
|
|
106
|
+
exports.EVENT_LABELS = EVENT_LABELS;
|
|
107
|
+
exports.actorLabel = actorLabel;
|
|
108
|
+
exports.changeSummary = changeSummary;
|
|
109
|
+
exports.eventLabel = eventLabel;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const MAX_COMMENT_LENGTH = 4e3;
|
|
3
|
+
const MAX_EXCERPT_LENGTH = 200;
|
|
4
|
+
const CONTROL = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/g;
|
|
5
|
+
const BIDI = /[\u061c\u200b-\u200f\u202a-\u202e\u2060\u2066-\u2069\ufeff]/g;
|
|
6
|
+
const normalizeExcerpt = (value) => {
|
|
7
|
+
if (typeof value !== "string") return null;
|
|
8
|
+
const text = value.slice(0, MAX_EXCERPT_LENGTH * 4).replace(CONTROL, " ").replace(BIDI, "").replace(/\s+/g, " ").trim();
|
|
9
|
+
if (!text) return null;
|
|
10
|
+
return text.length > MAX_EXCERPT_LENGTH ? `${text.slice(0, MAX_EXCERPT_LENGTH - 1).trimEnd()}…` : text;
|
|
11
|
+
};
|
|
12
|
+
const blockExcerpt = (block) => {
|
|
13
|
+
if (!block || typeof block !== "object" || !block.data || typeof block.data !== "object") return null;
|
|
14
|
+
const parts = [];
|
|
15
|
+
const visit = (value, depth) => {
|
|
16
|
+
if (parts.join(" ").length > MAX_EXCERPT_LENGTH * 2 || depth > 6) return;
|
|
17
|
+
if (typeof value === "string") parts.push(value.slice(0, MAX_EXCERPT_LENGTH * 4));
|
|
18
|
+
else if (Array.isArray(value)) value.forEach((item) => visit(item, depth + 1));
|
|
19
|
+
else if (value && typeof value === "object") {
|
|
20
|
+
for (const [key, item] of Object.entries(value)) {
|
|
21
|
+
if (["url", "href", "link", "src", "file", "id", "documentId", "mime", "style", "level"].includes(key))
|
|
22
|
+
continue;
|
|
23
|
+
visit(item, depth + 1);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
visit(block.data, 0);
|
|
28
|
+
const text = parts.join(" ").replace(/<[^>]{0,500}>/g, " ").replace(/ /g, " ").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, "&");
|
|
29
|
+
return normalizeExcerpt(text);
|
|
30
|
+
};
|
|
31
|
+
const openThreadsByBlock = (threads) => {
|
|
32
|
+
const counts = /* @__PURE__ */ new Map();
|
|
33
|
+
for (const thread of Array.isArray(threads) ? threads : []) {
|
|
34
|
+
if (!thread || thread.status !== "open" || typeof thread.blockId !== "string") continue;
|
|
35
|
+
counts.set(thread.blockId, (counts.get(thread.blockId) || 0) + 1);
|
|
36
|
+
}
|
|
37
|
+
return counts;
|
|
38
|
+
};
|
|
39
|
+
const countThreads = (threads) => {
|
|
40
|
+
const counts = { open: 0, resolved: 0, comments: 0 };
|
|
41
|
+
for (const thread of Array.isArray(threads) ? threads : []) {
|
|
42
|
+
if (!thread) continue;
|
|
43
|
+
if (thread.status === "resolved") counts.resolved += 1;
|
|
44
|
+
else counts.open += 1;
|
|
45
|
+
counts.comments += Array.isArray(thread.comments) ? thread.comments.length : 0;
|
|
46
|
+
}
|
|
47
|
+
return counts;
|
|
48
|
+
};
|
|
49
|
+
const arrangeThreads = (threads, blockIds) => {
|
|
50
|
+
const index = new Map((blockIds || []).map((id, position) => [id, position]));
|
|
51
|
+
return (Array.isArray(threads) ? threads : []).map((thread) => {
|
|
52
|
+
const position = index.has(thread.blockId) ? index.get(thread.blockId) : null;
|
|
53
|
+
return { ...thread, detached: Boolean(blockIds) && position === null, position };
|
|
54
|
+
}).sort((a, b) => {
|
|
55
|
+
if (a.status === "resolved" !== (b.status === "resolved")) return a.status === "resolved" ? 1 : -1;
|
|
56
|
+
if (a.detached !== b.detached) return a.detached ? 1 : -1;
|
|
57
|
+
if (a.position !== null && b.position !== null && a.position !== b.position)
|
|
58
|
+
return a.position - b.position;
|
|
59
|
+
return String(b.updatedAt || "").localeCompare(String(a.updatedAt || ""));
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
const UNITS = [
|
|
63
|
+
["year", 365 * 24 * 3600],
|
|
64
|
+
["month", 30 * 24 * 3600],
|
|
65
|
+
["week", 7 * 24 * 3600],
|
|
66
|
+
["day", 24 * 3600],
|
|
67
|
+
["hour", 3600],
|
|
68
|
+
["minute", 60]
|
|
69
|
+
];
|
|
70
|
+
const relativeTimeParts = (when, now = Date.now()) => {
|
|
71
|
+
const time = new Date(when).getTime();
|
|
72
|
+
if (!Number.isFinite(time)) return { value: 0, unit: "second" };
|
|
73
|
+
const seconds = Math.round((time - now) / 1e3);
|
|
74
|
+
const abs = Math.abs(seconds);
|
|
75
|
+
for (const [unit, size] of UNITS) {
|
|
76
|
+
if (abs >= size) return { value: Math.trunc(seconds / size), unit };
|
|
77
|
+
}
|
|
78
|
+
return { value: 0, unit: "second" };
|
|
79
|
+
};
|
|
80
|
+
exports.MAX_COMMENT_LENGTH = MAX_COMMENT_LENGTH;
|
|
81
|
+
exports.arrangeThreads = arrangeThreads;
|
|
82
|
+
exports.blockExcerpt = blockExcerpt;
|
|
83
|
+
exports.countThreads = countThreads;
|
|
84
|
+
exports.normalizeExcerpt = normalizeExcerpt;
|
|
85
|
+
exports.openThreadsByBlock = openThreadsByBlock;
|
|
86
|
+
exports.relativeTimeParts = relativeTimeParts;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
const MAX_COMMENT_LENGTH = 4e3;
|
|
2
|
+
const MAX_EXCERPT_LENGTH = 200;
|
|
3
|
+
const CONTROL = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/g;
|
|
4
|
+
const BIDI = /[\u061c\u200b-\u200f\u202a-\u202e\u2060\u2066-\u2069\ufeff]/g;
|
|
5
|
+
const normalizeExcerpt = (value) => {
|
|
6
|
+
if (typeof value !== "string") return null;
|
|
7
|
+
const text = value.slice(0, MAX_EXCERPT_LENGTH * 4).replace(CONTROL, " ").replace(BIDI, "").replace(/\s+/g, " ").trim();
|
|
8
|
+
if (!text) return null;
|
|
9
|
+
return text.length > MAX_EXCERPT_LENGTH ? `${text.slice(0, MAX_EXCERPT_LENGTH - 1).trimEnd()}…` : text;
|
|
10
|
+
};
|
|
11
|
+
const blockExcerpt = (block) => {
|
|
12
|
+
if (!block || typeof block !== "object" || !block.data || typeof block.data !== "object") return null;
|
|
13
|
+
const parts = [];
|
|
14
|
+
const visit = (value, depth) => {
|
|
15
|
+
if (parts.join(" ").length > MAX_EXCERPT_LENGTH * 2 || depth > 6) return;
|
|
16
|
+
if (typeof value === "string") parts.push(value.slice(0, MAX_EXCERPT_LENGTH * 4));
|
|
17
|
+
else if (Array.isArray(value)) value.forEach((item) => visit(item, depth + 1));
|
|
18
|
+
else if (value && typeof value === "object") {
|
|
19
|
+
for (const [key, item] of Object.entries(value)) {
|
|
20
|
+
if (["url", "href", "link", "src", "file", "id", "documentId", "mime", "style", "level"].includes(key))
|
|
21
|
+
continue;
|
|
22
|
+
visit(item, depth + 1);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
visit(block.data, 0);
|
|
27
|
+
const text = parts.join(" ").replace(/<[^>]{0,500}>/g, " ").replace(/ /g, " ").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, "&");
|
|
28
|
+
return normalizeExcerpt(text);
|
|
29
|
+
};
|
|
30
|
+
const openThreadsByBlock = (threads) => {
|
|
31
|
+
const counts = /* @__PURE__ */ new Map();
|
|
32
|
+
for (const thread of Array.isArray(threads) ? threads : []) {
|
|
33
|
+
if (!thread || thread.status !== "open" || typeof thread.blockId !== "string") continue;
|
|
34
|
+
counts.set(thread.blockId, (counts.get(thread.blockId) || 0) + 1);
|
|
35
|
+
}
|
|
36
|
+
return counts;
|
|
37
|
+
};
|
|
38
|
+
const countThreads = (threads) => {
|
|
39
|
+
const counts = { open: 0, resolved: 0, comments: 0 };
|
|
40
|
+
for (const thread of Array.isArray(threads) ? threads : []) {
|
|
41
|
+
if (!thread) continue;
|
|
42
|
+
if (thread.status === "resolved") counts.resolved += 1;
|
|
43
|
+
else counts.open += 1;
|
|
44
|
+
counts.comments += Array.isArray(thread.comments) ? thread.comments.length : 0;
|
|
45
|
+
}
|
|
46
|
+
return counts;
|
|
47
|
+
};
|
|
48
|
+
const arrangeThreads = (threads, blockIds) => {
|
|
49
|
+
const index = new Map((blockIds || []).map((id, position) => [id, position]));
|
|
50
|
+
return (Array.isArray(threads) ? threads : []).map((thread) => {
|
|
51
|
+
const position = index.has(thread.blockId) ? index.get(thread.blockId) : null;
|
|
52
|
+
return { ...thread, detached: Boolean(blockIds) && position === null, position };
|
|
53
|
+
}).sort((a, b) => {
|
|
54
|
+
if (a.status === "resolved" !== (b.status === "resolved")) return a.status === "resolved" ? 1 : -1;
|
|
55
|
+
if (a.detached !== b.detached) return a.detached ? 1 : -1;
|
|
56
|
+
if (a.position !== null && b.position !== null && a.position !== b.position)
|
|
57
|
+
return a.position - b.position;
|
|
58
|
+
return String(b.updatedAt || "").localeCompare(String(a.updatedAt || ""));
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
const UNITS = [
|
|
62
|
+
["year", 365 * 24 * 3600],
|
|
63
|
+
["month", 30 * 24 * 3600],
|
|
64
|
+
["week", 7 * 24 * 3600],
|
|
65
|
+
["day", 24 * 3600],
|
|
66
|
+
["hour", 3600],
|
|
67
|
+
["minute", 60]
|
|
68
|
+
];
|
|
69
|
+
const relativeTimeParts = (when, now = Date.now()) => {
|
|
70
|
+
const time = new Date(when).getTime();
|
|
71
|
+
if (!Number.isFinite(time)) return { value: 0, unit: "second" };
|
|
72
|
+
const seconds = Math.round((time - now) / 1e3);
|
|
73
|
+
const abs = Math.abs(seconds);
|
|
74
|
+
for (const [unit, size] of UNITS) {
|
|
75
|
+
if (abs >= size) return { value: Math.trunc(seconds / size), unit };
|
|
76
|
+
}
|
|
77
|
+
return { value: 0, unit: "second" };
|
|
78
|
+
};
|
|
79
|
+
export {
|
|
80
|
+
MAX_COMMENT_LENGTH as M,
|
|
81
|
+
arrangeThreads as a,
|
|
82
|
+
blockExcerpt as b,
|
|
83
|
+
countThreads as c,
|
|
84
|
+
normalizeExcerpt as n,
|
|
85
|
+
openThreadsByBlock as o,
|
|
86
|
+
relativeTimeParts as r
|
|
87
|
+
};
|