magic-editor-x 2.2.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +85 -0
- package/README.md +493 -168
- package/dist/admin/{ConfigurationPage-YvnPnna6.js → ConfigurationPage-CFP3lp9p.js} +479 -50
- package/dist/admin/{ConfigurationPage-3Dir3dAf.mjs → ConfigurationPage-CYGDLjM7.mjs} +450 -21
- package/dist/admin/ConfirmAction-DuQwvRYi.mjs +125 -0
- package/dist/admin/ConfirmAction-zLuIFj8t.js +124 -0
- package/dist/admin/{CustomBlocksPage-CR2BaP9O.mjs → CustomBlocksPage-B5Q33N-s.mjs} +92 -41
- package/dist/admin/{CustomBlocksPage-BiiL2ORG.js → CustomBlocksPage-DzPOSpfn.js} +135 -84
- package/dist/admin/DraftSync-BIA8cZgA.js +11 -0
- package/dist/admin/DraftSync-CUxOMG-E.mjs +12 -0
- package/dist/admin/TemplatesPage-4A8JNO_Z.mjs +993 -0
- package/dist/admin/TemplatesPage-BVkgafCK.js +993 -0
- package/dist/admin/{de-BmmLBJli.mjs → de-1cFMs-4c.mjs} +2 -0
- package/dist/admin/{de-BteRx2iA.js → de-2Ie5jy7j.js} +79 -1
- package/dist/admin/{de-62Vxb2iw.js → de-B1X46JJZ.js} +205 -2
- package/dist/admin/{de-CFX5atOk.mjs → de-BMY2LBaa.mjs} +79 -1
- package/dist/admin/{de-Bt6pYIWi.mjs → de-BUS1hUw0.mjs} +145 -0
- package/dist/admin/{de-CVbi685U.js → de-C3AsGauQ.js} +145 -0
- package/dist/admin/{de-BVvwSYYO.mjs → de-DOiGaTNX.mjs} +205 -2
- package/dist/admin/{de-DaJwN6nk.js → de-Dn8athM8.js} +2 -0
- package/dist/admin/{en-CyjAcccB.js → en-Ah-Cw0Wd.js} +79 -1
- package/dist/admin/{en-BX362fTp.js → en-BkEjpC3i.js} +145 -0
- package/dist/admin/{en-VlkaIzrM.js → en-CDg_18Bt.js} +205 -2
- package/dist/admin/{en-Cn78RZs-.js → en-CIZ5Ggod.js} +2 -0
- package/dist/admin/{en-Cg2Ak5Cr.mjs → en-CU6UzV4g.mjs} +205 -2
- package/dist/admin/{en-ea0tfA5i.mjs → en-CvFiqti2.mjs} +79 -1
- package/dist/admin/{en-D7mZWLGp.mjs → en-Dc9y-6n9.mjs} +2 -0
- package/dist/admin/{en-B_HltUxZ.mjs → en-GCzgS9Aw.mjs} +145 -0
- package/dist/admin/{es-BT9oAcHf.js → es-BCpJmUEM.js} +205 -2
- package/dist/admin/{es-C9-cXdb6.mjs → es-BmfffNM2.mjs} +205 -2
- package/dist/admin/{es-BmGtLkJD.js → es-C4IRHV5d.js} +2 -0
- package/dist/admin/{es-CHHEZi44.js → es-C4pEnDRv.js} +145 -0
- package/dist/admin/{es-C8GZFGjv.js → es-Cr8JH85N.js} +79 -1
- package/dist/admin/{es-joykG5I9.mjs → es-D2Kw6E4N.mjs} +2 -0
- package/dist/admin/{es-CrhwOq-5.mjs → es-DHBBZKl2.mjs} +145 -0
- package/dist/admin/{es-CEi_ycX8.mjs → es-DbKHZz5l.mjs} +79 -1
- package/dist/admin/{fr-CrzxGe5e.mjs → fr-BOvvfEH7.mjs} +2 -0
- package/dist/admin/{fr-B3SL0TBV.js → fr-C2aLSwEu.js} +145 -0
- package/dist/admin/{fr-BAMSvQbR.mjs → fr-DQJ_7aq5.mjs} +79 -1
- package/dist/admin/{fr-DpU_qiXR.mjs → fr-DZd2XJP6.mjs} +205 -2
- package/dist/admin/{fr-5djKfQ3s.mjs → fr-Dvq4xk2e.mjs} +145 -0
- package/dist/admin/{fr-oRCJNdeJ.js → fr-OJ4VW1kh.js} +79 -1
- package/dist/admin/{fr-D6KJqPWi.js → fr-ZcN0yM_2.js} +205 -2
- package/dist/admin/{fr-Ct_uPqxV.js → fr-Zkb8vfjN.js} +2 -0
- package/dist/admin/{EditorField-Diq1j8kc.js → index-DQVE0ymw.js} +13712 -6767
- package/dist/admin/index-DR8sHkTk.js +1940 -0
- package/dist/admin/index-My6FjjHB.mjs +1939 -0
- package/dist/admin/{EditorField-B8pyAxPE.mjs → index-k8_a5o1A.mjs} +10223 -3278
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +2 -2
- package/dist/admin/{pt-chN2jrXl.js → pt-1IUyx6ae.js} +2 -0
- package/dist/admin/{pt-CQrfqsCN.mjs → pt-BSLzA17U.mjs} +79 -1
- package/dist/admin/{pt-jUqOR7Xh.mjs → pt-C3UdeIpd.mjs} +205 -2
- package/dist/admin/{pt-BOrl6x-r.js → pt-CImqDnLB.js} +205 -2
- package/dist/admin/{pt-BdnY2Cth.mjs → pt-CilDggGF.mjs} +145 -0
- package/dist/admin/{pt-tUeJ2Ywd.js → pt-D0I0_JYs.js} +79 -1
- package/dist/admin/{pt-EVwCuBUK.js → pt-DX0OAIoL.js} +145 -0
- package/dist/admin/{pt-Ga-4Hsv0.mjs → pt-etwsg3G4.mjs} +2 -0
- package/dist/admin/useBreakpoint-D30eNTkF.js +37 -0
- package/dist/admin/useBreakpoint-DCfn6pDG.mjs +38 -0
- package/dist/admin/useT-Cmg1jwwG.mjs +65 -0
- package/dist/admin/{useT-BWZ_-Hel.js → useT-DNphiBQR.js} +4 -70
- package/dist/blocks/index.d.mts +167 -0
- package/dist/blocks/index.d.ts +167 -0
- package/dist/blocks/index.js +631 -0
- package/dist/blocks/index.mjs +609 -0
- package/dist/react/index.d.mts +39 -0
- package/dist/react/index.d.ts +39 -0
- package/dist/react/index.js +2687 -0
- package/dist/react/index.mjs +2657 -0
- package/dist/render/index.d.mts +131 -5
- package/dist/render/index.d.ts +131 -5
- package/dist/render/index.js +1679 -181
- package/dist/render/index.mjs +1679 -181
- package/dist/server/index.js +10645 -3716
- package/dist/server/index.mjs +10645 -3716
- package/dist/vue/index.d.mts +41 -0
- package/dist/vue/index.d.ts +41 -0
- package/dist/vue/index.js +2630 -0
- package/dist/vue/index.mjs +2610 -0
- package/package.json +30 -6
- package/schema/magic-editor-x.schema.json +540 -1
- package/types/blocks.d.ts +167 -0
- package/types/index.d.ts +127 -0
- package/types/react.d.ts +39 -0
- package/types/render.d.ts +131 -5
- package/types/vue.d.ts +41 -0
- package/dist/admin/api-Dsq53giv.js +0 -37
- package/dist/admin/api-RZ0Fz0BD.mjs +0 -38
- package/dist/admin/index-C-lyON1B.mjs +0 -303
- package/dist/admin/index-iA0lued_.js +0 -302
- package/dist/admin/sanitize-Cb4jvBhj.js +0 -628
- package/dist/admin/sanitize-ClkX823p.mjs +0 -627
- package/dist/admin/useT-pvHmgBFj.mjs +0 -131
|
@@ -0,0 +1,125 @@
|
|
|
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
|
+
const API = {
|
|
6
|
+
config: "/magic-editor-x/config",
|
|
7
|
+
link: "/magic-editor-x/link",
|
|
8
|
+
imageByFile: "/magic-editor-x/image/byFile",
|
|
9
|
+
imageByUrl: "/magic-editor-x/image/byUrl",
|
|
10
|
+
fileUpload: "/magic-editor-x/file/upload",
|
|
11
|
+
contentTypes: "/magic-editor-x/content-types",
|
|
12
|
+
linkTypes: "/magic-editor-x/links/types",
|
|
13
|
+
linkSearch: "/magic-editor-x/links/search",
|
|
14
|
+
qualityLinks: "/magic-editor-x/quality/links",
|
|
15
|
+
qualityLinkReport: "/magic-editor-x/quality/link-report",
|
|
16
|
+
customBlocks: "/magic-editor-x/custom-blocks",
|
|
17
|
+
customBlocksExport: "/magic-editor-x/custom-blocks/export",
|
|
18
|
+
customBlocksImport: "/magic-editor-x/custom-blocks/import",
|
|
19
|
+
customBlocksOrder: "/magic-editor-x/custom-blocks/order",
|
|
20
|
+
customBlock: (id) => `/magic-editor-x/custom-blocks/${encodeURIComponent(id)}`,
|
|
21
|
+
customBlockDuplicate: (id) => `/magic-editor-x/custom-blocks/${encodeURIComponent(id)}/duplicate`,
|
|
22
|
+
collaborationSession: "/magic-editor-x/collaboration/session",
|
|
23
|
+
history: "/magic-editor-x/history",
|
|
24
|
+
historyItem: (id) => `/magic-editor-x/history/${encodeURIComponent(id)}`,
|
|
25
|
+
ai: (action) => `/magic-editor-x/ai/${encodeURIComponent(action)}`,
|
|
26
|
+
aiAltText: "/magic-editor-x/ai/image/alt-text",
|
|
27
|
+
aiField: (action) => `/magic-editor-x/ai/field/${encodeURIComponent(action)}`,
|
|
28
|
+
grammarCheck: "/magic-editor-x/grammar/check",
|
|
29
|
+
comments: "/magic-editor-x/comments",
|
|
30
|
+
comment: (id) => `/magic-editor-x/comments/${encodeURIComponent(id)}`,
|
|
31
|
+
commentReplies: (id) => `/magic-editor-x/comments/${encodeURIComponent(id)}/replies`,
|
|
32
|
+
commentResolve: (id) => `/magic-editor-x/comments/${encodeURIComponent(id)}/resolve`,
|
|
33
|
+
commentReopen: (id) => `/magic-editor-x/comments/${encodeURIComponent(id)}/reopen`,
|
|
34
|
+
templates: "/magic-editor-x/templates",
|
|
35
|
+
templateTargets: "/magic-editor-x/templates/targets",
|
|
36
|
+
templatesOrder: "/magic-editor-x/templates/order",
|
|
37
|
+
template: (id) => `/magic-editor-x/templates/${encodeURIComponent(id)}`,
|
|
38
|
+
templateDuplicate: (id) => `/magic-editor-x/templates/${encodeURIComponent(id)}/duplicate`,
|
|
39
|
+
templateUsage: (id) => `/magic-editor-x/templates/${encodeURIComponent(id)}/usage`,
|
|
40
|
+
settings: "/magic-editor-x/settings",
|
|
41
|
+
settingsAiTest: "/magic-editor-x/settings/ai/test",
|
|
42
|
+
settingsLanguageToolTest: "/magic-editor-x/settings/language-tool/test"
|
|
43
|
+
};
|
|
44
|
+
const readApiError = (error) => {
|
|
45
|
+
const response = error && error.response;
|
|
46
|
+
const body = response && response.data;
|
|
47
|
+
const apiError = body && body.error;
|
|
48
|
+
const status = response && response.status || (error && typeof error.status === "number" ? error.status : null) || (apiError && typeof apiError.status === "number" ? apiError.status : null);
|
|
49
|
+
return {
|
|
50
|
+
status: status || null,
|
|
51
|
+
message: apiError && apiError.message || body && body.message || null,
|
|
52
|
+
code: apiError && apiError.details && apiError.details.code || null,
|
|
53
|
+
details: apiError && apiError.details || null
|
|
54
|
+
};
|
|
55
|
+
};
|
|
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
|
+
export {
|
|
121
|
+
API as A,
|
|
122
|
+
ConfirmAction as C,
|
|
123
|
+
refocusIfLost as a,
|
|
124
|
+
readApiError as r
|
|
125
|
+
};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
+
const ReactNamespace = require("react");
|
|
4
|
+
const designSystem = require("@strapi/design-system");
|
|
5
|
+
const admin = require("@strapi/strapi/admin");
|
|
6
|
+
const API = {
|
|
7
|
+
config: "/magic-editor-x/config",
|
|
8
|
+
link: "/magic-editor-x/link",
|
|
9
|
+
imageByFile: "/magic-editor-x/image/byFile",
|
|
10
|
+
imageByUrl: "/magic-editor-x/image/byUrl",
|
|
11
|
+
fileUpload: "/magic-editor-x/file/upload",
|
|
12
|
+
contentTypes: "/magic-editor-x/content-types",
|
|
13
|
+
linkTypes: "/magic-editor-x/links/types",
|
|
14
|
+
linkSearch: "/magic-editor-x/links/search",
|
|
15
|
+
qualityLinks: "/magic-editor-x/quality/links",
|
|
16
|
+
qualityLinkReport: "/magic-editor-x/quality/link-report",
|
|
17
|
+
customBlocks: "/magic-editor-x/custom-blocks",
|
|
18
|
+
customBlocksExport: "/magic-editor-x/custom-blocks/export",
|
|
19
|
+
customBlocksImport: "/magic-editor-x/custom-blocks/import",
|
|
20
|
+
customBlocksOrder: "/magic-editor-x/custom-blocks/order",
|
|
21
|
+
customBlock: (id) => `/magic-editor-x/custom-blocks/${encodeURIComponent(id)}`,
|
|
22
|
+
customBlockDuplicate: (id) => `/magic-editor-x/custom-blocks/${encodeURIComponent(id)}/duplicate`,
|
|
23
|
+
collaborationSession: "/magic-editor-x/collaboration/session",
|
|
24
|
+
history: "/magic-editor-x/history",
|
|
25
|
+
historyItem: (id) => `/magic-editor-x/history/${encodeURIComponent(id)}`,
|
|
26
|
+
ai: (action) => `/magic-editor-x/ai/${encodeURIComponent(action)}`,
|
|
27
|
+
aiAltText: "/magic-editor-x/ai/image/alt-text",
|
|
28
|
+
aiField: (action) => `/magic-editor-x/ai/field/${encodeURIComponent(action)}`,
|
|
29
|
+
grammarCheck: "/magic-editor-x/grammar/check",
|
|
30
|
+
comments: "/magic-editor-x/comments",
|
|
31
|
+
comment: (id) => `/magic-editor-x/comments/${encodeURIComponent(id)}`,
|
|
32
|
+
commentReplies: (id) => `/magic-editor-x/comments/${encodeURIComponent(id)}/replies`,
|
|
33
|
+
commentResolve: (id) => `/magic-editor-x/comments/${encodeURIComponent(id)}/resolve`,
|
|
34
|
+
commentReopen: (id) => `/magic-editor-x/comments/${encodeURIComponent(id)}/reopen`,
|
|
35
|
+
templates: "/magic-editor-x/templates",
|
|
36
|
+
templateTargets: "/magic-editor-x/templates/targets",
|
|
37
|
+
templatesOrder: "/magic-editor-x/templates/order",
|
|
38
|
+
template: (id) => `/magic-editor-x/templates/${encodeURIComponent(id)}`,
|
|
39
|
+
templateDuplicate: (id) => `/magic-editor-x/templates/${encodeURIComponent(id)}/duplicate`,
|
|
40
|
+
templateUsage: (id) => `/magic-editor-x/templates/${encodeURIComponent(id)}/usage`,
|
|
41
|
+
settings: "/magic-editor-x/settings",
|
|
42
|
+
settingsAiTest: "/magic-editor-x/settings/ai/test",
|
|
43
|
+
settingsLanguageToolTest: "/magic-editor-x/settings/language-tool/test"
|
|
44
|
+
};
|
|
45
|
+
const readApiError = (error) => {
|
|
46
|
+
const response = error && error.response;
|
|
47
|
+
const body = response && response.data;
|
|
48
|
+
const apiError = body && body.error;
|
|
49
|
+
const status = response && response.status || (error && typeof error.status === "number" ? error.status : null) || (apiError && typeof apiError.status === "number" ? apiError.status : null);
|
|
50
|
+
return {
|
|
51
|
+
status: status || null,
|
|
52
|
+
message: apiError && apiError.message || body && body.message || null,
|
|
53
|
+
code: apiError && apiError.details && apiError.details.code || null,
|
|
54
|
+
details: apiError && apiError.details || null
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
const canTakeFocus = (el) => Boolean(
|
|
58
|
+
el && el.isConnected && typeof el.focus === "function" && !el.disabled && (typeof el.getAttribute !== "function" || el.getAttribute("aria-disabled") !== "true")
|
|
59
|
+
);
|
|
60
|
+
const pickFocusTarget = (opener, fallback) => {
|
|
61
|
+
if (canTakeFocus(opener)) return opener;
|
|
62
|
+
if (canTakeFocus(fallback)) return fallback;
|
|
63
|
+
return null;
|
|
64
|
+
};
|
|
65
|
+
const refocusIfLost = (opener, fallback, doc = globalThis.document) => {
|
|
66
|
+
if (!doc) return;
|
|
67
|
+
const active = doc.activeElement;
|
|
68
|
+
if (active && active !== doc.body) return;
|
|
69
|
+
const target = pickFocusTarget(opener, fallback);
|
|
70
|
+
if (target) target.focus();
|
|
71
|
+
};
|
|
72
|
+
const ConfirmAction = ({
|
|
73
|
+
trigger,
|
|
74
|
+
title,
|
|
75
|
+
body,
|
|
76
|
+
confirmLabel,
|
|
77
|
+
onConfirm,
|
|
78
|
+
variant = "danger",
|
|
79
|
+
disabled = false,
|
|
80
|
+
fallbackFocusRef
|
|
81
|
+
}) => {
|
|
82
|
+
const [open, setOpen] = ReactNamespace.useState(false);
|
|
83
|
+
const [busy, setBusy] = ReactNamespace.useState(false);
|
|
84
|
+
const triggerRef = ReactNamespace.useRef(null);
|
|
85
|
+
const restoreFocus = () => requestAnimationFrame(() => {
|
|
86
|
+
const active = document.activeElement;
|
|
87
|
+
if (active && active !== document.body) return;
|
|
88
|
+
const target = pickFocusTarget(triggerRef.current, fallbackFocusRef && fallbackFocusRef.current);
|
|
89
|
+
if (target) target.focus();
|
|
90
|
+
});
|
|
91
|
+
const onOpenChange = (next) => {
|
|
92
|
+
if (busy) return;
|
|
93
|
+
setOpen(next);
|
|
94
|
+
if (!next) restoreFocus();
|
|
95
|
+
};
|
|
96
|
+
const confirm = async (event) => {
|
|
97
|
+
if (event && typeof event.preventDefault === "function") event.preventDefault();
|
|
98
|
+
setBusy(true);
|
|
99
|
+
try {
|
|
100
|
+
await onConfirm();
|
|
101
|
+
setOpen(false);
|
|
102
|
+
restoreFocus();
|
|
103
|
+
} catch {
|
|
104
|
+
} finally {
|
|
105
|
+
setBusy(false);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Root, { open, onOpenChange, children: [
|
|
109
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Trigger, { ref: triggerRef, disabled, children: trigger }),
|
|
110
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
111
|
+
admin.ConfirmDialog,
|
|
112
|
+
{
|
|
113
|
+
title,
|
|
114
|
+
variant,
|
|
115
|
+
endAction: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { fullWidth: true, variant, onClick: confirm, loading: busy, disabled: busy, children: confirmLabel }),
|
|
116
|
+
children: body
|
|
117
|
+
}
|
|
118
|
+
)
|
|
119
|
+
] });
|
|
120
|
+
};
|
|
121
|
+
exports.API = API;
|
|
122
|
+
exports.ConfirmAction = ConfirmAction;
|
|
123
|
+
exports.readApiError = readApiError;
|
|
124
|
+
exports.refocusIfLost = refocusIfLost;
|
|
@@ -1,47 +1,15 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useState, useRef, useEffect, useCallback, useMemo } from "react";
|
|
3
3
|
import { Box, Typography, Flex, Badge, Table, Thead, Tr, Th, VisuallyHidden, Tbody, Td, Switch, IconButton, Grid, Field, TextInput, SingleSelect, SingleSelectOption, Textarea, Checkbox, Button, Modal, Alert, Divider, MultiSelect, MultiSelectOption, EmptyStateLayout } from "@strapi/design-system";
|
|
4
4
|
import { Pencil, Duplicate, ArrowUp, ArrowDown, Trash, Plus, Upload, Download } from "@strapi/icons";
|
|
5
5
|
import { EmptyDocuments } from "@strapi/icons/symbols";
|
|
6
6
|
import { useFetchClient, useNotification, useRBAC, Page } from "@strapi/strapi/admin";
|
|
7
|
-
import { P as PERMISSIONS } from "./index-
|
|
8
|
-
import { A as API, r as readApiError } from "./
|
|
9
|
-
import { u as useT,
|
|
10
|
-
import styled
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
const useBreakpoint = () => {
|
|
14
|
-
const theme = useTheme();
|
|
15
|
-
const queries = useMemo(
|
|
16
|
-
() => ({
|
|
17
|
-
small: toQuery(theme && theme.breakpoints && theme.breakpoints.small) || "(min-width: 520px)",
|
|
18
|
-
medium: toQuery(theme && theme.breakpoints && theme.breakpoints.medium) || "(min-width: 768px)",
|
|
19
|
-
large: toQuery(theme && theme.breakpoints && theme.breakpoints.large) || "(min-width: 1080px)"
|
|
20
|
-
}),
|
|
21
|
-
[theme]
|
|
22
|
-
);
|
|
23
|
-
const read = useMemo(
|
|
24
|
-
() => () => {
|
|
25
|
-
if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
|
|
26
|
-
return { small: true, medium: true, large: true };
|
|
27
|
-
}
|
|
28
|
-
return Object.fromEntries(
|
|
29
|
-
Object.entries(queries).map(([key, query]) => [key, window.matchMedia(query).matches])
|
|
30
|
-
);
|
|
31
|
-
},
|
|
32
|
-
[queries]
|
|
33
|
-
);
|
|
34
|
-
const [matches, setMatches] = useState(read);
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
if (typeof window === "undefined" || typeof window.matchMedia !== "function") return void 0;
|
|
37
|
-
const lists = Object.values(queries).map((query) => window.matchMedia(query));
|
|
38
|
-
const update = () => setMatches(read());
|
|
39
|
-
update();
|
|
40
|
-
lists.forEach((list) => list.addEventListener("change", update));
|
|
41
|
-
return () => lists.forEach((list) => list.removeEventListener("change", update));
|
|
42
|
-
}, [queries, read]);
|
|
43
|
-
return { isBelowSmall: !matches.small, isBelowMedium: !matches.medium, isBelowLarge: !matches.large };
|
|
44
|
-
};
|
|
7
|
+
import { s as sanitizeSvg, a as sanitizeTemplate, m as mergeCodeBlocks, c as codeBlocks, P as PERMISSIONS } from "./index-My6FjjHB.mjs";
|
|
8
|
+
import { A as API, C as ConfirmAction, r as readApiError, a as refocusIfLost } from "./ConfirmAction-DuQwvRYi.mjs";
|
|
9
|
+
import { u as useT, S as SectionCard, P as PageShell } from "./useT-Cmg1jwwG.mjs";
|
|
10
|
+
import styled from "styled-components";
|
|
11
|
+
import { u as useBreakpoint } from "./useBreakpoint-DCfn6pDG.mjs";
|
|
12
|
+
import { useIntl } from "react-intl";
|
|
45
13
|
const FIELD_TYPES = Object.freeze([
|
|
46
14
|
"text",
|
|
47
15
|
"textarea",
|
|
@@ -54,6 +22,7 @@ const FIELD_TYPES = Object.freeze([
|
|
|
54
22
|
]);
|
|
55
23
|
const TUNES = Object.freeze(["alignmentTune", "textVariant", "indentTune"]);
|
|
56
24
|
const BLOCK_TYPES = Object.freeze(["simple", "embedded-entry"]);
|
|
25
|
+
const LEGACY_NAMES = Object.freeze(["toc", "gallery", "video", "audio", "synced", "mention"]);
|
|
57
26
|
const RESERVED_NAMES = Object.freeze(
|
|
58
27
|
[
|
|
59
28
|
"paragraph",
|
|
@@ -65,11 +34,16 @@ const RESERVED_NAMES = Object.freeze(
|
|
|
65
34
|
"code",
|
|
66
35
|
"codeFlask",
|
|
67
36
|
"delimiter",
|
|
37
|
+
"toc",
|
|
68
38
|
"table",
|
|
69
39
|
"embed",
|
|
70
40
|
"raw",
|
|
71
41
|
"image",
|
|
72
42
|
"simpleImage",
|
|
43
|
+
"gallery",
|
|
44
|
+
"video",
|
|
45
|
+
"audio",
|
|
46
|
+
"synced",
|
|
73
47
|
"linkTool",
|
|
74
48
|
"attaches",
|
|
75
49
|
"personality",
|
|
@@ -85,6 +59,7 @@ const RESERVED_NAMES = Object.freeze(
|
|
|
85
59
|
"strikethrough",
|
|
86
60
|
"tooltip",
|
|
87
61
|
"hyperlink",
|
|
62
|
+
"mention",
|
|
88
63
|
"aiAssistant",
|
|
89
64
|
"textVariant",
|
|
90
65
|
"alignmentTune",
|
|
@@ -228,7 +203,8 @@ const validateBlock = (values, context = {}) => {
|
|
|
228
203
|
const name = String(values.name || "").trim();
|
|
229
204
|
if (!name) errors.name = "required";
|
|
230
205
|
else if (!NAME_PATTERN.test(name)) errors.name = "namePattern";
|
|
231
|
-
else if (RESERVED_NAMES.includes(name.toLowerCase())
|
|
206
|
+
else if (RESERVED_NAMES.includes(name.toLowerCase()) && !(LEGACY_NAMES.includes(name.toLowerCase()) && context.originalName === name))
|
|
207
|
+
errors.name = "reserved";
|
|
232
208
|
else if ((context.existingNames || []).some((other) => other.toLowerCase() === name.toLowerCase()))
|
|
233
209
|
errors.name = "taken";
|
|
234
210
|
const label = String(values.label || "").trim();
|
|
@@ -914,7 +890,11 @@ const BlockFormModal = ({
|
|
|
914
890
|
const [serverErrors, setServerErrors] = useState({});
|
|
915
891
|
const [showErrors, setShowErrors] = useState(false);
|
|
916
892
|
const [saving, setSaving] = useState(false);
|
|
917
|
-
const
|
|
893
|
+
const originalName = block ? block.name : null;
|
|
894
|
+
const errors = useMemo(
|
|
895
|
+
() => validateBlock(values, { existingNames: otherNames, originalName }),
|
|
896
|
+
[values, otherNames, originalName]
|
|
897
|
+
);
|
|
918
898
|
const visible = useMemo(
|
|
919
899
|
() => ({ ...showErrors ? errors : {}, ...serverErrors }),
|
|
920
900
|
[errors, serverErrors, showErrors]
|
|
@@ -1388,6 +1368,76 @@ const BlockFormModal = ({
|
|
|
1388
1368
|
}
|
|
1389
1369
|
);
|
|
1390
1370
|
};
|
|
1371
|
+
const CodeBlocksSection = () => {
|
|
1372
|
+
const t = useT();
|
|
1373
|
+
const { locale } = useIntl();
|
|
1374
|
+
const { get } = useFetchClient();
|
|
1375
|
+
const [server, setServer] = useState([]);
|
|
1376
|
+
useEffect(() => {
|
|
1377
|
+
let active = true;
|
|
1378
|
+
get(API.config).then(
|
|
1379
|
+
({ data }) => {
|
|
1380
|
+
if (active && data && data.data && Array.isArray(data.data.codeBlocks))
|
|
1381
|
+
setServer(data.data.codeBlocks);
|
|
1382
|
+
},
|
|
1383
|
+
() => {
|
|
1384
|
+
}
|
|
1385
|
+
);
|
|
1386
|
+
return () => {
|
|
1387
|
+
active = false;
|
|
1388
|
+
};
|
|
1389
|
+
}, [get]);
|
|
1390
|
+
const rows = useMemo(() => mergeCodeBlocks(server, codeBlocks(), locale), [server, locale]);
|
|
1391
|
+
if (!rows.length) return null;
|
|
1392
|
+
return /* @__PURE__ */ jsx(
|
|
1393
|
+
SectionCard,
|
|
1394
|
+
{
|
|
1395
|
+
title: t("settings.blocks.code.title", "Defined in code"),
|
|
1396
|
+
subtitle: t(
|
|
1397
|
+
"settings.blocks.code.subtitle",
|
|
1398
|
+
"Blocks your app registers in code with the custom block SDK. They are changed in the code and cannot be edited here."
|
|
1399
|
+
),
|
|
1400
|
+
children: /* @__PURE__ */ jsx(Box, { tag: "ul", margin: 0, padding: 0, children: /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 3, children: rows.map((row) => /* @__PURE__ */ jsx(
|
|
1401
|
+
Box,
|
|
1402
|
+
{
|
|
1403
|
+
tag: "li",
|
|
1404
|
+
padding: 4,
|
|
1405
|
+
hasRadius: true,
|
|
1406
|
+
borderColor: "neutral200",
|
|
1407
|
+
background: "neutral100",
|
|
1408
|
+
minWidth: 0,
|
|
1409
|
+
children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 2, minWidth: 0, children: [
|
|
1410
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", alignItems: "center", children: [
|
|
1411
|
+
/* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "bold", textColor: "neutral800", tag: "h3", children: row.title }),
|
|
1412
|
+
/* @__PURE__ */ jsx(Badge, { children: t("settings.blocks.code.badge", "Defined in code") })
|
|
1413
|
+
] }),
|
|
1414
|
+
/* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral600", style: { overflowWrap: "anywhere" }, children: [
|
|
1415
|
+
row.name,
|
|
1416
|
+
" ·",
|
|
1417
|
+
" ",
|
|
1418
|
+
t("settings.blocks.code.version", "Version {version}", { version: row.version })
|
|
1419
|
+
] }),
|
|
1420
|
+
row.fields.length ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { overflowWrap: "anywhere" }, children: t("settings.blocks.code.fields", "Fields: {fields}", {
|
|
1421
|
+
fields: row.fields.map((field) => `${field.key} (${field.type})`).join(", ")
|
|
1422
|
+
}) }) : null,
|
|
1423
|
+
row.presets.length ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: t("settings.blocks.code.presets", "Also in the presets: {presets}", {
|
|
1424
|
+
presets: row.presets.join(", ")
|
|
1425
|
+
}) }) : null,
|
|
1426
|
+
!row.inAdmin ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "warning600", children: t(
|
|
1427
|
+
"settings.blocks.code.noTool",
|
|
1428
|
+
"No editor tool is registered in the admin, so editors cannot insert this block."
|
|
1429
|
+
) }) : null,
|
|
1430
|
+
!row.onServer ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "warning600", children: t(
|
|
1431
|
+
"settings.blocks.code.noServer",
|
|
1432
|
+
"Not registered on the server: saved content of this block is cleaned with the generic policy."
|
|
1433
|
+
) }) : null
|
|
1434
|
+
] })
|
|
1435
|
+
},
|
|
1436
|
+
row.name
|
|
1437
|
+
)) }) })
|
|
1438
|
+
}
|
|
1439
|
+
);
|
|
1440
|
+
};
|
|
1391
1441
|
const CustomBlocksPage = () => {
|
|
1392
1442
|
const t = useT();
|
|
1393
1443
|
const { post, put, del, get } = useFetchClient();
|
|
@@ -1718,6 +1768,7 @@ const CustomBlocksPage = () => {
|
|
|
1718
1768
|
fallbackFocusRef: createRef
|
|
1719
1769
|
}
|
|
1720
1770
|
),
|
|
1771
|
+
/* @__PURE__ */ jsx(CodeBlocksSection, {}),
|
|
1721
1772
|
/* @__PURE__ */ jsx(
|
|
1722
1773
|
BlockFormModal,
|
|
1723
1774
|
{
|