@strapi/content-manager 0.0.0-experimental.d954d57341a6623992a0d211daaec8e245c3517d → 0.0.0-experimental.dad3c50630ca4fd9eccdcbe549ee632fc572e23d
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/LICENSE +18 -3
- package/dist/_chunks/CardDragPreview-C0QyJgRA.js.map +1 -1
- package/dist/_chunks/CardDragPreview-DOxamsuj.mjs.map +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-WRPUXGd6.js → ComponentConfigurationPage-BLWQy8ru.js} +5 -6
- package/dist/_chunks/{ComponentConfigurationPage-WRPUXGd6.js.map → ComponentConfigurationPage-BLWQy8ru.js.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-gdUj_t-O.mjs → ComponentConfigurationPage-CtIa3aa2.mjs} +4 -4
- package/dist/_chunks/{ComponentConfigurationPage-gdUj_t-O.mjs.map → ComponentConfigurationPage-CtIa3aa2.mjs.map} +1 -1
- package/dist/_chunks/{ComponentIcon-BXdiCGQp.js → ComponentIcon-CRbtQEUV.js} +2 -3
- package/dist/_chunks/{ComponentIcon-BXdiCGQp.js.map → ComponentIcon-CRbtQEUV.js.map} +1 -1
- package/dist/_chunks/ComponentIcon-u4bIXTFY.mjs.map +1 -1
- package/dist/_chunks/{EditConfigurationPage-BwuIPOJG.mjs → EditConfigurationPage-DsPR2DVk.mjs} +4 -4
- package/dist/_chunks/{EditConfigurationPage-BwuIPOJG.mjs.map → EditConfigurationPage-DsPR2DVk.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-C1vjMBgy.js → EditConfigurationPage-RQkymxCy.js} +5 -6
- package/dist/_chunks/{EditConfigurationPage-C1vjMBgy.js.map → EditConfigurationPage-RQkymxCy.js.map} +1 -1
- package/dist/_chunks/{EditViewPage-DbcGfyqK.js → EditViewPage-B-kExt8C.js} +63 -13
- package/dist/_chunks/EditViewPage-B-kExt8C.js.map +1 -0
- package/dist/_chunks/{EditViewPage-0MiFkXa8.mjs → EditViewPage-BPyVuPfM.mjs} +63 -12
- package/dist/_chunks/EditViewPage-BPyVuPfM.mjs.map +1 -0
- package/dist/_chunks/{Field-BG1xu38N.js → Field-DPIsQRre.js} +680 -261
- package/dist/_chunks/Field-DPIsQRre.js.map +1 -0
- package/dist/_chunks/{Field-BDMSCcy5.mjs → Field-Dltnt1km.mjs} +676 -257
- package/dist/_chunks/Field-Dltnt1km.mjs.map +1 -0
- package/dist/_chunks/FieldTypeIcon-CMlNO8PE.mjs.map +1 -1
- package/dist/_chunks/FieldTypeIcon-Dnwq_IRF.js.map +1 -1
- package/dist/_chunks/{Form-9BnFyUjy.js → Form-BFi4MXMT.js} +43 -22
- package/dist/_chunks/Form-BFi4MXMT.js.map +1 -0
- package/dist/_chunks/{Form-CPVWavB8.mjs → Form-C1IcWm1u.mjs} +41 -19
- package/dist/_chunks/Form-C1IcWm1u.mjs.map +1 -0
- package/dist/_chunks/{History-BVpd8LP3.mjs → History-04ChQ4pl.mjs} +108 -116
- package/dist/_chunks/History-04ChQ4pl.mjs.map +1 -0
- package/dist/_chunks/{History-BWWxLt2Z.js → History-wjcK4L0C.js} +107 -116
- package/dist/_chunks/History-wjcK4L0C.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-DozVMKcR.mjs → ListConfigurationPage-BYqPYLSU.mjs} +25 -12
- package/dist/_chunks/ListConfigurationPage-BYqPYLSU.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-6swzjdAZ.js → ListConfigurationPage-CRbxIC3J.js} +25 -13
- package/dist/_chunks/ListConfigurationPage-CRbxIC3J.js.map +1 -0
- package/dist/_chunks/{ListViewPage-BlzfjS2Q.js → ListViewPage-D5NY9183.js} +121 -81
- package/dist/_chunks/ListViewPage-D5NY9183.js.map +1 -0
- package/dist/_chunks/{ListViewPage-Ds0ulgfG.mjs → ListViewPage-FU2LBuhl.mjs} +118 -77
- package/dist/_chunks/ListViewPage-FU2LBuhl.mjs.map +1 -0
- package/dist/_chunks/{NoContentTypePage-D2nCCWEl.js → NoContentTypePage-BgQVE_Qb.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-D2nCCWEl.js.map → NoContentTypePage-BgQVE_Qb.js.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-BH11kaKt.mjs → NoContentTypePage-DCKUkwb8.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-BH11kaKt.mjs.map → NoContentTypePage-DCKUkwb8.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-DN_JlsU2.js → NoPermissionsPage-C5jwn70o.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-DN_JlsU2.js.map → NoPermissionsPage-C5jwn70o.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-BT2Tn0D_.mjs → NoPermissionsPage-jqve7C8l.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-BT2Tn0D_.mjs.map → NoPermissionsPage-jqve7C8l.mjs.map} +1 -1
- package/dist/_chunks/Preview-BMYN548c.mjs +294 -0
- package/dist/_chunks/Preview-BMYN548c.mjs.map +1 -0
- package/dist/_chunks/Preview-DaOihysv.js +312 -0
- package/dist/_chunks/Preview-DaOihysv.js.map +1 -0
- package/dist/_chunks/{Relations-CcgFTcWo.js → Relations-CTGM7Hv5.js} +76 -43
- package/dist/_chunks/Relations-CTGM7Hv5.js.map +1 -0
- package/dist/_chunks/{Relations-Dnag3fhV.mjs → Relations-gscPkxjF.mjs} +76 -42
- package/dist/_chunks/Relations-gscPkxjF.mjs.map +1 -0
- package/dist/_chunks/{en-fbKQxLGn.js → en-BzQmavmK.js} +37 -18
- package/dist/_chunks/{en-fbKQxLGn.js.map → en-BzQmavmK.js.map} +1 -1
- package/dist/_chunks/{en-Ux26r5pl.mjs → en-CSxLmrh1.mjs} +37 -18
- package/dist/_chunks/{en-Ux26r5pl.mjs.map → en-CSxLmrh1.mjs.map} +1 -1
- package/dist/_chunks/{es-EUonQTon.js → es-9K52xZIr.js} +2 -2
- package/dist/_chunks/{ja-CcFe8diO.js.map → es-9K52xZIr.js.map} +1 -1
- package/dist/_chunks/{es-CeXiYflN.mjs → es-D34tqjMw.mjs} +2 -2
- package/dist/_chunks/{es-CeXiYflN.mjs.map → es-D34tqjMw.mjs.map} +1 -1
- package/dist/_chunks/{fr-CD9VFbPM.mjs → fr--pg5jUbt.mjs} +13 -3
- package/dist/_chunks/{fr-CD9VFbPM.mjs.map → fr--pg5jUbt.mjs.map} +1 -1
- package/dist/_chunks/{fr-B7kGGg3E.js → fr-B2Kyv8Z9.js} +13 -3
- package/dist/_chunks/{fr-B7kGGg3E.js.map → fr-B2Kyv8Z9.js.map} +1 -1
- package/dist/_chunks/hooks-BAaaKPS_.js.map +1 -1
- package/dist/_chunks/{index-CWpLBSt0.js → index-Ca7YWlAA.js} +1271 -746
- package/dist/_chunks/index-Ca7YWlAA.js.map +1 -0
- package/dist/_chunks/{index-JNNNKUHs.mjs → index-DqasUQ6Q.mjs} +1288 -763
- package/dist/_chunks/index-DqasUQ6Q.mjs.map +1 -0
- package/dist/_chunks/{ja-CcFe8diO.js → ja-7sfIbjxE.js} +2 -2
- package/dist/_chunks/{es-EUonQTon.js.map → ja-7sfIbjxE.js.map} +1 -1
- package/dist/_chunks/{ja-CtsUxOvk.mjs → ja-BHqhDq4V.mjs} +2 -2
- package/dist/_chunks/{ja-CtsUxOvk.mjs.map → ja-BHqhDq4V.mjs.map} +1 -1
- package/dist/_chunks/{layout--iHdZzRk.js → layout-BW80JSCd.js} +27 -15
- package/dist/_chunks/layout-BW80JSCd.js.map +1 -0
- package/dist/_chunks/{layout-DC503LnF.mjs → layout-W3clJSCy.mjs} +28 -15
- package/dist/_chunks/layout-W3clJSCy.mjs.map +1 -0
- package/dist/_chunks/{objects-gigeqt7s.js → objects-BcXOv6_9.js} +2 -4
- package/dist/_chunks/{objects-gigeqt7s.js.map → objects-BcXOv6_9.js.map} +1 -1
- package/dist/_chunks/{objects-mKMAmfec.mjs → objects-D6yBsdmx.mjs} +2 -4
- package/dist/_chunks/{objects-mKMAmfec.mjs.map → objects-D6yBsdmx.mjs.map} +1 -1
- package/dist/_chunks/{relations-CTje5t-a.mjs → relations-BlDkoeWh.mjs} +6 -7
- package/dist/_chunks/relations-BlDkoeWh.mjs.map +1 -0
- package/dist/_chunks/{relations-BbHizA5K.js → relations-C9Usz9k5.js} +6 -7
- package/dist/_chunks/relations-C9Usz9k5.js.map +1 -0
- package/dist/_chunks/{usePrev-B9w_-eYc.js → useDebounce-CtcjDB3L.js} +14 -1
- package/dist/_chunks/useDebounce-CtcjDB3L.js.map +1 -0
- package/dist/_chunks/useDebounce-DmuSJIF3.mjs +29 -0
- package/dist/_chunks/useDebounce-DmuSJIF3.mjs.map +1 -0
- package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js → useDragAndDrop-BMtgCYzL.js} +5 -9
- package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js.map → useDragAndDrop-BMtgCYzL.js.map} +1 -1
- package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs → useDragAndDrop-DJ6jqvZN.mjs} +4 -7
- package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs.map → useDragAndDrop-DJ6jqvZN.mjs.map} +1 -1
- package/dist/admin/index.js +3 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +5 -3
- package/dist/admin/src/content-manager.d.ts +3 -2
- package/dist/admin/src/exports.d.ts +2 -1
- package/dist/admin/src/history/index.d.ts +3 -0
- package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
- package/dist/admin/src/hooks/useDocument.d.ts +32 -1
- package/dist/admin/src/index.d.ts +1 -0
- package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
- package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +2 -1
- package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +3 -3
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.d.ts +7 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/utils/prismLanguages.d.ts +49 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +5 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.d.ts +4 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/Field.d.ts +4 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/Relations.d.ts +20 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygFooter.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +4 -48
- package/dist/admin/src/pages/EditView/components/Header.d.ts +11 -11
- package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
- package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
- package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
- package/dist/admin/src/preview/index.d.ts +4 -0
- package/dist/admin/src/preview/pages/Preview.d.ts +11 -0
- package/dist/admin/src/preview/routes.d.ts +3 -0
- package/dist/admin/src/preview/services/preview.d.ts +3 -0
- package/dist/admin/src/router.d.ts +1 -1
- package/dist/admin/src/services/api.d.ts +1 -1
- package/dist/admin/src/services/components.d.ts +2 -2
- package/dist/admin/src/services/contentTypes.d.ts +3 -3
- package/dist/admin/src/services/documents.d.ts +19 -20
- package/dist/admin/src/services/init.d.ts +1 -1
- package/dist/admin/src/services/relations.d.ts +2 -2
- package/dist/admin/src/services/uid.d.ts +3 -3
- package/dist/admin/src/utils/validation.d.ts +4 -1
- package/dist/server/index.js +765 -437
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +766 -437
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/bootstrap.d.ts.map +1 -1
- package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
- package/dist/server/src/controllers/index.d.ts.map +1 -1
- package/dist/server/src/controllers/relations.d.ts.map +1 -1
- package/dist/server/src/controllers/uid.d.ts.map +1 -1
- package/dist/server/src/controllers/utils/metadata.d.ts +16 -1
- package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
- package/dist/server/src/controllers/validation/dimensions.d.ts +4 -2
- package/dist/server/src/controllers/validation/dimensions.d.ts.map +1 -1
- package/dist/server/src/history/controllers/history-version.d.ts +1 -1
- package/dist/server/src/history/controllers/history-version.d.ts.map +1 -1
- package/dist/server/src/history/services/history.d.ts +3 -3
- package/dist/server/src/history/services/history.d.ts.map +1 -1
- package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
- package/dist/server/src/history/services/utils.d.ts +8 -12
- package/dist/server/src/history/services/utils.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +7 -6
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/policies/hasPermissions.d.ts.map +1 -1
- package/dist/server/src/preview/controllers/index.d.ts +2 -0
- package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
- package/dist/server/src/preview/controllers/preview.d.ts +13 -0
- package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
- package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
- package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
- package/dist/server/src/preview/index.d.ts +4 -0
- package/dist/server/src/preview/index.d.ts.map +1 -0
- package/dist/server/src/preview/routes/index.d.ts +8 -0
- package/dist/server/src/preview/routes/index.d.ts.map +1 -0
- package/dist/server/src/preview/routes/preview.d.ts +4 -0
- package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
- package/dist/server/src/preview/services/index.d.ts +16 -0
- package/dist/server/src/preview/services/index.d.ts.map +1 -0
- package/dist/server/src/preview/services/preview-config.d.ts +32 -0
- package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
- package/dist/server/src/preview/services/preview.d.ts +12 -0
- package/dist/server/src/preview/services/preview.d.ts.map +1 -0
- package/dist/server/src/preview/utils.d.ts +19 -0
- package/dist/server/src/preview/utils.d.ts.map +1 -0
- package/dist/server/src/register.d.ts.map +1 -1
- package/dist/server/src/routes/index.d.ts.map +1 -1
- package/dist/server/src/services/document-manager.d.ts.map +1 -1
- package/dist/server/src/services/document-metadata.d.ts +12 -10
- package/dist/server/src/services/document-metadata.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +7 -6
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/permission-checker.d.ts.map +1 -1
- package/dist/server/src/services/utils/populate.d.ts +2 -2
- package/dist/server/src/services/utils/populate.d.ts.map +1 -1
- package/dist/server/src/utils/index.d.ts +2 -0
- package/dist/server/src/utils/index.d.ts.map +1 -1
- package/dist/shared/contracts/collection-types.d.ts +3 -1
- package/dist/shared/contracts/collection-types.d.ts.map +1 -1
- package/dist/shared/contracts/index.d.ts +1 -0
- package/dist/shared/contracts/index.d.ts.map +1 -1
- package/dist/shared/contracts/preview.d.ts +27 -0
- package/dist/shared/contracts/preview.d.ts.map +1 -0
- package/dist/shared/index.js +4 -0
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/index.mjs +4 -0
- package/dist/shared/index.mjs.map +1 -1
- package/package.json +17 -15
- package/dist/_chunks/EditViewPage-0MiFkXa8.mjs.map +0 -1
- package/dist/_chunks/EditViewPage-DbcGfyqK.js.map +0 -1
- package/dist/_chunks/Field-BDMSCcy5.mjs.map +0 -1
- package/dist/_chunks/Field-BG1xu38N.js.map +0 -1
- package/dist/_chunks/Form-9BnFyUjy.js.map +0 -1
- package/dist/_chunks/Form-CPVWavB8.mjs.map +0 -1
- package/dist/_chunks/History-BVpd8LP3.mjs.map +0 -1
- package/dist/_chunks/History-BWWxLt2Z.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-6swzjdAZ.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-DozVMKcR.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-BlzfjS2Q.js.map +0 -1
- package/dist/_chunks/ListViewPage-Ds0ulgfG.mjs.map +0 -1
- package/dist/_chunks/Relations-CcgFTcWo.js.map +0 -1
- package/dist/_chunks/Relations-Dnag3fhV.mjs.map +0 -1
- package/dist/_chunks/index-CWpLBSt0.js.map +0 -1
- package/dist/_chunks/index-JNNNKUHs.mjs.map +0 -1
- package/dist/_chunks/layout--iHdZzRk.js.map +0 -1
- package/dist/_chunks/layout-DC503LnF.mjs.map +0 -1
- package/dist/_chunks/relations-BbHizA5K.js.map +0 -1
- package/dist/_chunks/relations-CTje5t-a.mjs.map +0 -1
- package/dist/_chunks/usePrev-B9w_-eYc.js.map +0 -1
- package/dist/_chunks/usePrev-DH6iah0A.mjs +0 -16
- package/dist/_chunks/usePrev-DH6iah0A.mjs.map +0 -1
- package/strapi-server.js +0 -3
@@ -0,0 +1,312 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
4
|
+
const React = require("react");
|
5
|
+
const strapiAdmin = require("@strapi/admin/strapi-admin");
|
6
|
+
const designSystem = require("@strapi/design-system");
|
7
|
+
const reactIntl = require("react-intl");
|
8
|
+
const reactRouterDom = require("react-router-dom");
|
9
|
+
const index = require("./index-Ca7YWlAA.js");
|
10
|
+
const Icons = require("@strapi/icons");
|
11
|
+
const qs = require("qs");
|
12
|
+
const styledComponents = require("styled-components");
|
13
|
+
const EditViewPage = require("./EditViewPage-B-kExt8C.js");
|
14
|
+
function _interopNamespace(e) {
|
15
|
+
if (e && e.__esModule) return e;
|
16
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
17
|
+
if (e) {
|
18
|
+
for (const k in e) {
|
19
|
+
if (k !== "default") {
|
20
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
21
|
+
Object.defineProperty(n, k, d.get ? d : {
|
22
|
+
enumerable: true,
|
23
|
+
get: () => e[k]
|
24
|
+
});
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
n.default = e;
|
29
|
+
return Object.freeze(n);
|
30
|
+
}
|
31
|
+
const React__namespace = /* @__PURE__ */ _interopNamespace(React);
|
32
|
+
const PreviewContent = () => {
|
33
|
+
const previewUrl = usePreviewContext("PreviewContent", (state) => state.url);
|
34
|
+
const { formatMessage } = reactIntl.useIntl();
|
35
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
36
|
+
designSystem.Box,
|
37
|
+
{
|
38
|
+
src: previewUrl,
|
39
|
+
title: formatMessage({
|
40
|
+
id: "content-manager.preview.panel.title",
|
41
|
+
defaultMessage: "Preview"
|
42
|
+
}),
|
43
|
+
width: "100%",
|
44
|
+
height: "100%",
|
45
|
+
borderWidth: 0,
|
46
|
+
tag: "iframe"
|
47
|
+
},
|
48
|
+
previewUrl
|
49
|
+
);
|
50
|
+
};
|
51
|
+
const ClosePreviewButton = () => {
|
52
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
53
|
+
const { formatMessage } = reactIntl.useIntl();
|
54
|
+
const canGoBack = strapiAdmin.useHistory("BackButton", (state) => state.canGoBack);
|
55
|
+
const goBack = strapiAdmin.useHistory("BackButton", (state) => state.goBack);
|
56
|
+
const history = strapiAdmin.useHistory("BackButton", (state) => state.history);
|
57
|
+
const locationIndex = strapiAdmin.useHistory("BackButton", (state) => state.currentLocationIndex);
|
58
|
+
const historyTo = canGoBack ? history.at(locationIndex - 2) : void 0;
|
59
|
+
const fallback = {
|
60
|
+
pathname: "..",
|
61
|
+
search: qs.stringify(query, { encode: false })
|
62
|
+
};
|
63
|
+
const toWithFallback = historyTo ?? fallback;
|
64
|
+
const handleClick = (e) => {
|
65
|
+
if (canGoBack) {
|
66
|
+
e.preventDefault();
|
67
|
+
goBack();
|
68
|
+
return;
|
69
|
+
}
|
70
|
+
};
|
71
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
72
|
+
designSystem.IconButton,
|
73
|
+
{
|
74
|
+
tag: reactRouterDom.Link,
|
75
|
+
relative: "path",
|
76
|
+
to: toWithFallback,
|
77
|
+
onClick: handleClick,
|
78
|
+
label: formatMessage({
|
79
|
+
id: "content-manager.preview.header.close",
|
80
|
+
defaultMessage: "Close preview"
|
81
|
+
}),
|
82
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {})
|
83
|
+
}
|
84
|
+
);
|
85
|
+
};
|
86
|
+
const Status = () => {
|
87
|
+
const document = usePreviewContext("PreviewHeader", (state) => state.document);
|
88
|
+
const schema = usePreviewContext("PreviewHeader", (state) => state.schema);
|
89
|
+
const meta = usePreviewContext("PreviewHeader", (state) => state.meta);
|
90
|
+
const hasDraftAndPublished = schema?.options?.draftAndPublish ?? false;
|
91
|
+
if (!hasDraftAndPublished) {
|
92
|
+
return null;
|
93
|
+
}
|
94
|
+
const status = EditViewPage.getDocumentStatus(document, meta);
|
95
|
+
return /* @__PURE__ */ jsxRuntime.jsx(index.DocumentStatus, { status, size: "XS" });
|
96
|
+
};
|
97
|
+
const PreviewTabs = () => {
|
98
|
+
const { formatMessage } = reactIntl.useIntl();
|
99
|
+
const [{ query }, setQuery] = strapiAdmin.useQueryParams();
|
100
|
+
const document = usePreviewContext("PreviewHeader", (state) => state.document);
|
101
|
+
const schema = usePreviewContext("PreviewHeader", (state) => state.schema);
|
102
|
+
const meta = usePreviewContext("PreviewHeader", (state) => state.meta);
|
103
|
+
const hasDraftAndPublish = schema?.options?.draftAndPublish ?? false;
|
104
|
+
const documentStatus = EditViewPage.getDocumentStatus(document, meta);
|
105
|
+
const handleTabChange = (status) => {
|
106
|
+
if (status === "published" || status === "draft") {
|
107
|
+
setQuery({ status }, "push", true);
|
108
|
+
}
|
109
|
+
};
|
110
|
+
if (!hasDraftAndPublish) {
|
111
|
+
return null;
|
112
|
+
}
|
113
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Root, { variant: "simple", value: query.status || "draft", onValueChange: handleTabChange, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
114
|
+
designSystem.Tabs.List,
|
115
|
+
{
|
116
|
+
"aria-label": formatMessage({
|
117
|
+
id: "preview.tabs.label",
|
118
|
+
defaultMessage: "Document status"
|
119
|
+
}),
|
120
|
+
children: [
|
121
|
+
/* @__PURE__ */ jsxRuntime.jsx(StatusTab, { value: "draft", children: formatMessage({
|
122
|
+
id: "content-manager.containers.List.draft",
|
123
|
+
defaultMessage: "draft"
|
124
|
+
}) }),
|
125
|
+
/* @__PURE__ */ jsxRuntime.jsx(StatusTab, { value: "published", disabled: documentStatus === "draft", children: formatMessage({
|
126
|
+
id: "content-manager.containers.List.published",
|
127
|
+
defaultMessage: "published"
|
128
|
+
}) })
|
129
|
+
]
|
130
|
+
}
|
131
|
+
) }) });
|
132
|
+
};
|
133
|
+
const PreviewHeader = () => {
|
134
|
+
const mainField = usePreviewContext("PreviewHeader", (state) => state.mainField);
|
135
|
+
const document = usePreviewContext("PreviewHeader", (state) => state.document);
|
136
|
+
const schema = usePreviewContext("PreviewHeader", (state) => state.schema);
|
137
|
+
let documentTitle = "Untitled";
|
138
|
+
if (mainField !== "id" && document?.[mainField]) {
|
139
|
+
documentTitle = document[mainField];
|
140
|
+
} else if (schema.kind === "singleType" && schema?.info.displayName) {
|
141
|
+
documentTitle = schema.info.displayName;
|
142
|
+
}
|
143
|
+
const { formatMessage } = reactIntl.useIntl();
|
144
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
145
|
+
const { copy } = strapiAdmin.useClipboard();
|
146
|
+
const handleCopyLink = () => {
|
147
|
+
copy(window.location.href);
|
148
|
+
toggleNotification({
|
149
|
+
message: formatMessage({
|
150
|
+
id: "content-manager.preview.copy.success",
|
151
|
+
defaultMessage: "Copied preview link"
|
152
|
+
}),
|
153
|
+
type: "success"
|
154
|
+
});
|
155
|
+
};
|
156
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
157
|
+
designSystem.Grid.Root,
|
158
|
+
{
|
159
|
+
gap: 3,
|
160
|
+
gridCols: 3,
|
161
|
+
paddingLeft: 2,
|
162
|
+
paddingRight: 2,
|
163
|
+
background: "neutral0",
|
164
|
+
borderColor: "neutral150",
|
165
|
+
tag: "header",
|
166
|
+
children: [
|
167
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Item, { xs: 1, paddingTop: 2, paddingBottom: 2, gap: 3, children: [
|
168
|
+
/* @__PURE__ */ jsxRuntime.jsx(ClosePreviewButton, {}),
|
169
|
+
/* @__PURE__ */ jsxRuntime.jsx(PreviewTitle, { tag: "h1", fontWeight: 600, fontSize: 2, maxWidth: "200px", title: documentTitle, children: documentTitle }),
|
170
|
+
/* @__PURE__ */ jsxRuntime.jsx(Status, {})
|
171
|
+
] }),
|
172
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 1, marginBottom: "-1px", alignItems: "end", margin: "auto", children: /* @__PURE__ */ jsxRuntime.jsx(PreviewTabs, {}) }),
|
173
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 1, justifyContent: "end", paddingTop: 2, paddingBottom: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
|
174
|
+
designSystem.IconButton,
|
175
|
+
{
|
176
|
+
type: "button",
|
177
|
+
label: formatMessage({
|
178
|
+
id: "preview.copy.label",
|
179
|
+
defaultMessage: "Copy preview link"
|
180
|
+
}),
|
181
|
+
onClick: handleCopyLink,
|
182
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Link, {})
|
183
|
+
}
|
184
|
+
) })
|
185
|
+
]
|
186
|
+
}
|
187
|
+
);
|
188
|
+
};
|
189
|
+
const PreviewTitle = styledComponents.styled(designSystem.Typography)`
|
190
|
+
overflow: hidden;
|
191
|
+
text-overflow: ellipsis;
|
192
|
+
white-space: nowrap;
|
193
|
+
`;
|
194
|
+
const StatusTab = styledComponents.styled(designSystem.Tabs.Trigger)`
|
195
|
+
text-transform: uppercase;
|
196
|
+
`;
|
197
|
+
const [PreviewProvider, usePreviewContext] = strapiAdmin.createContext("PreviewPage");
|
198
|
+
const PreviewPage = () => {
|
199
|
+
const { formatMessage } = reactIntl.useIntl();
|
200
|
+
const {
|
201
|
+
slug: model,
|
202
|
+
id: documentId,
|
203
|
+
collectionType
|
204
|
+
} = reactRouterDom.useParams();
|
205
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
206
|
+
const params = React__namespace.useMemo(() => index.buildValidParams(query), [query]);
|
207
|
+
if (!collectionType) {
|
208
|
+
throw new Error("Could not find collectionType in url params");
|
209
|
+
}
|
210
|
+
if (!model) {
|
211
|
+
throw new Error("Could not find model in url params");
|
212
|
+
}
|
213
|
+
if (collectionType === index.COLLECTION_TYPES && !documentId) {
|
214
|
+
throw new Error("Could not find documentId in url params");
|
215
|
+
}
|
216
|
+
const previewUrlResponse = index.useGetPreviewUrlQuery({
|
217
|
+
params: {
|
218
|
+
contentType: model
|
219
|
+
},
|
220
|
+
query: {
|
221
|
+
documentId,
|
222
|
+
locale: params.locale,
|
223
|
+
status: params.status
|
224
|
+
}
|
225
|
+
});
|
226
|
+
const documentResponse = index.useDocument({
|
227
|
+
model,
|
228
|
+
collectionType,
|
229
|
+
documentId,
|
230
|
+
params
|
231
|
+
});
|
232
|
+
const documentLayoutResponse = index.useDocumentLayout(model);
|
233
|
+
if (documentResponse.isLoading || previewUrlResponse.isLoading || documentLayoutResponse.isLoading) {
|
234
|
+
return /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Loading, {});
|
235
|
+
}
|
236
|
+
if (previewUrlResponse.error || documentLayoutResponse.error || !documentResponse.document || !documentResponse.meta || !documentResponse.schema) {
|
237
|
+
return /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Error, {});
|
238
|
+
}
|
239
|
+
if (!previewUrlResponse.data?.data?.url) {
|
240
|
+
return /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.NoData, {});
|
241
|
+
}
|
242
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
243
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Title, { children: formatMessage(
|
244
|
+
{
|
245
|
+
id: "content-manager.preview.page-title",
|
246
|
+
defaultMessage: "{contentType} preview"
|
247
|
+
},
|
248
|
+
{
|
249
|
+
contentType: documentLayoutResponse.edit.settings.displayName
|
250
|
+
}
|
251
|
+
) }),
|
252
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
253
|
+
PreviewProvider,
|
254
|
+
{
|
255
|
+
url: previewUrlResponse.data.data.url,
|
256
|
+
mainField: documentLayoutResponse.edit.settings.mainField,
|
257
|
+
document: documentResponse.document,
|
258
|
+
meta: documentResponse.meta,
|
259
|
+
schema: documentResponse.schema,
|
260
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", height: "100%", alignItems: "stretch", children: [
|
261
|
+
/* @__PURE__ */ jsxRuntime.jsx(PreviewHeader, {}),
|
262
|
+
/* @__PURE__ */ jsxRuntime.jsx(PreviewContent, {})
|
263
|
+
] })
|
264
|
+
}
|
265
|
+
)
|
266
|
+
] });
|
267
|
+
};
|
268
|
+
const ProtectedPreviewPageImpl = () => {
|
269
|
+
const { slug: model } = reactRouterDom.useParams();
|
270
|
+
const {
|
271
|
+
permissions = [],
|
272
|
+
isLoading,
|
273
|
+
error
|
274
|
+
} = strapiAdmin.useRBAC([{ action: "plugin::content-manager.explorer.read", subject: model }]);
|
275
|
+
if (isLoading) {
|
276
|
+
return /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Loading, {});
|
277
|
+
}
|
278
|
+
if (error || !model) {
|
279
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
280
|
+
designSystem.Box,
|
281
|
+
{
|
282
|
+
height: "100vh",
|
283
|
+
width: "100vw",
|
284
|
+
position: "fixed",
|
285
|
+
top: 0,
|
286
|
+
left: 0,
|
287
|
+
zIndex: 2,
|
288
|
+
background: "neutral0",
|
289
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Error, {})
|
290
|
+
}
|
291
|
+
);
|
292
|
+
}
|
293
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
294
|
+
designSystem.Box,
|
295
|
+
{
|
296
|
+
height: "100vh",
|
297
|
+
width: "100vw",
|
298
|
+
position: "fixed",
|
299
|
+
top: 0,
|
300
|
+
left: 0,
|
301
|
+
zIndex: 2,
|
302
|
+
background: "neutral0",
|
303
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Protect, { permissions, children: ({ permissions: permissions2 }) => /* @__PURE__ */ jsxRuntime.jsx(index.DocumentRBAC, { permissions: permissions2, children: /* @__PURE__ */ jsxRuntime.jsx(PreviewPage, {}) }) })
|
304
|
+
}
|
305
|
+
);
|
306
|
+
};
|
307
|
+
const ProtectedPreviewPage = () => {
|
308
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.FocusTrap, { children: /* @__PURE__ */ jsxRuntime.jsx(ProtectedPreviewPageImpl, {}) }) });
|
309
|
+
};
|
310
|
+
exports.ProtectedPreviewPage = ProtectedPreviewPage;
|
311
|
+
exports.usePreviewContext = usePreviewContext;
|
312
|
+
//# sourceMappingURL=Preview-DaOihysv.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Preview-DaOihysv.js","sources":["../../admin/src/preview/components/PreviewContent.tsx","../../admin/src/preview/components/PreviewHeader.tsx","../../admin/src/preview/pages/Preview.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Box } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\n\nimport { usePreviewContext } from '../pages/Preview';\n\nconst PreviewContent = () => {\n const previewUrl = usePreviewContext('PreviewContent', (state) => state.url);\n\n const { formatMessage } = useIntl();\n\n return (\n <Box\n src={previewUrl}\n /**\n * For some reason, changing an iframe's src tag causes the browser to add a new item in the\n * history stack. This is an issue for us as it means clicking the back button will not let us\n * go back to the edit view. To fix it, we need to trick the browser into thinking this is a\n * different iframe when the preview URL changes. So we set a key prop to force React\n * to mount a different node when the src changes.\n */\n key={previewUrl}\n title={formatMessage({\n id: 'content-manager.preview.panel.title',\n defaultMessage: 'Preview',\n })}\n width=\"100%\"\n height=\"100%\"\n borderWidth={0}\n tag=\"iframe\"\n />\n );\n};\n\nexport { PreviewContent };\n","import * as React from 'react';\n\nimport {\n useClipboard,\n useHistory,\n useNotification,\n useQueryParams,\n} from '@strapi/admin/strapi-admin';\nimport { IconButton, Tabs, Typography, Grid } from '@strapi/design-system';\nimport { Cross, Link as LinkIcon } from '@strapi/icons';\nimport { stringify } from 'qs';\nimport { useIntl } from 'react-intl';\nimport { Link, type To } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { DocumentStatus } from '../../pages/EditView/components/DocumentStatus';\nimport { getDocumentStatus } from '../../pages/EditView/EditViewPage';\nimport { usePreviewContext } from '../pages/Preview';\n\n/* -------------------------------------------------------------------------------------------------\n * ClosePreviewButton\n * -----------------------------------------------------------------------------------------------*/\n\nconst ClosePreviewButton = () => {\n const [{ query }] = useQueryParams<{\n plugins?: Record<string, unknown>;\n }>();\n const { formatMessage } = useIntl();\n\n const canGoBack = useHistory('BackButton', (state) => state.canGoBack);\n const goBack = useHistory('BackButton', (state) => state.goBack);\n const history = useHistory('BackButton', (state) => state.history);\n const locationIndex = useHistory('BackButton', (state) => state.currentLocationIndex);\n\n /**\n * Get the link destination from the history.\n * Rely on a fallback (the parent edit view page) if there's no page to go back .\n */\n const historyTo = canGoBack ? history.at(locationIndex - 2) : undefined;\n const fallback = {\n pathname: '..',\n search: stringify(query, { encode: false }),\n } satisfies To;\n const toWithFallback = historyTo ?? fallback;\n\n const handleClick = (e: React.MouseEvent) => {\n if (canGoBack) {\n // Prevent normal link behavior, go back in the history stack instead\n e.preventDefault();\n goBack();\n return;\n }\n\n // Otherwise rely on native link behavior to go back to the edit view. We don't use navigate()\n // here in order to get the relative=\"path\" functionality from the Link component.\n };\n\n return (\n <IconButton\n tag={Link}\n relative=\"path\"\n to={toWithFallback}\n onClick={handleClick}\n label={formatMessage({\n id: 'content-manager.preview.header.close',\n defaultMessage: 'Close preview',\n })}\n >\n <Cross />\n </IconButton>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Status\n * -----------------------------------------------------------------------------------------------*/\n\nconst Status = () => {\n // Get status\n const document = usePreviewContext('PreviewHeader', (state) => state.document);\n const schema = usePreviewContext('PreviewHeader', (state) => state.schema);\n const meta = usePreviewContext('PreviewHeader', (state) => state.meta);\n const hasDraftAndPublished = schema?.options?.draftAndPublish ?? false;\n\n if (!hasDraftAndPublished) {\n return null;\n }\n\n const status = getDocumentStatus(document, meta);\n\n return <DocumentStatus status={status} size=\"XS\" />;\n};\n\nconst PreviewTabs = () => {\n const { formatMessage } = useIntl();\n\n // URL query params\n const [{ query }, setQuery] = useQueryParams<{ status: 'draft' | 'published' }>();\n\n // Get status\n const document = usePreviewContext('PreviewHeader', (state) => state.document);\n const schema = usePreviewContext('PreviewHeader', (state) => state.schema);\n const meta = usePreviewContext('PreviewHeader', (state) => state.meta);\n const hasDraftAndPublish = schema?.options?.draftAndPublish ?? false;\n const documentStatus = getDocumentStatus(document, meta);\n\n const handleTabChange = (status: string) => {\n if (status === 'published' || status === 'draft') {\n setQuery({ status }, 'push', true);\n }\n };\n\n if (!hasDraftAndPublish) {\n return null;\n }\n\n return (\n <>\n <Tabs.Root variant=\"simple\" value={query.status || 'draft'} onValueChange={handleTabChange}>\n <Tabs.List\n aria-label={formatMessage({\n id: 'preview.tabs.label',\n defaultMessage: 'Document status',\n })}\n >\n <StatusTab value=\"draft\">\n {formatMessage({\n id: 'content-manager.containers.List.draft',\n defaultMessage: 'draft',\n })}\n </StatusTab>\n <StatusTab value=\"published\" disabled={documentStatus === 'draft'}>\n {formatMessage({\n id: 'content-manager.containers.List.published',\n defaultMessage: 'published',\n })}\n </StatusTab>\n </Tabs.List>\n </Tabs.Root>\n </>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * PreviewHeader\n * -----------------------------------------------------------------------------------------------*/\n\nconst PreviewHeader = () => {\n // Get main field\n const mainField = usePreviewContext('PreviewHeader', (state) => state.mainField);\n const document = usePreviewContext('PreviewHeader', (state) => state.document);\n const schema = usePreviewContext('PreviewHeader', (state) => state.schema);\n\n /**\n * We look to see what the mainField is from the configuration, if it's an id\n * we don't use it because it's a uuid format and not very user friendly.\n * Instead, we display the schema name for single-type documents\n * or \"Untitled\".\n */\n let documentTitle = 'Untitled';\n if (mainField !== 'id' && document?.[mainField]) {\n documentTitle = document[mainField];\n } else if (schema.kind === 'singleType' && schema?.info.displayName) {\n documentTitle = schema.info.displayName;\n }\n\n const { formatMessage } = useIntl();\n const { toggleNotification } = useNotification();\n const { copy } = useClipboard();\n\n const handleCopyLink = () => {\n copy(window.location.href);\n toggleNotification({\n message: formatMessage({\n id: 'content-manager.preview.copy.success',\n defaultMessage: 'Copied preview link',\n }),\n type: 'success',\n });\n };\n\n return (\n <Grid.Root\n gap={3}\n gridCols={3}\n paddingLeft={2}\n paddingRight={2}\n background=\"neutral0\"\n borderColor=\"neutral150\"\n tag=\"header\"\n >\n {/* Title and status */}\n <Grid.Item xs={1} paddingTop={2} paddingBottom={2} gap={3}>\n <ClosePreviewButton />\n <PreviewTitle tag=\"h1\" fontWeight={600} fontSize={2} maxWidth=\"200px\" title={documentTitle}>\n {documentTitle}\n </PreviewTitle>\n <Status />\n </Grid.Item>\n {/* Tabs */}\n <Grid.Item xs={1} marginBottom=\"-1px\" alignItems=\"end\" margin=\"auto\">\n <PreviewTabs />\n </Grid.Item>\n {/* Copy link */}\n <Grid.Item xs={1} justifyContent=\"end\" paddingTop={2} paddingBottom={2}>\n <IconButton\n type=\"button\"\n label={formatMessage({\n id: 'preview.copy.label',\n defaultMessage: 'Copy preview link',\n })}\n onClick={handleCopyLink}\n >\n <LinkIcon />\n </IconButton>\n </Grid.Item>\n </Grid.Root>\n );\n};\n\nconst PreviewTitle = styled(Typography)`\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n`;\n\nconst StatusTab = styled(Tabs.Trigger)`\n text-transform: uppercase;\n`;\n\nexport { PreviewHeader };\n","import * as React from 'react';\n\nimport { Page, useQueryParams, useRBAC, createContext } from '@strapi/admin/strapi-admin';\nimport { Box, Flex, FocusTrap, Portal } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\nimport { useParams } from 'react-router-dom';\n\nimport { GetPreviewUrl } from '../../../../shared/contracts/preview';\nimport { COLLECTION_TYPES } from '../../constants/collections';\nimport { DocumentRBAC } from '../../features/DocumentRBAC';\nimport { type UseDocument, useDocument } from '../../hooks/useDocument';\nimport { useDocumentLayout } from '../../hooks/useDocumentLayout';\nimport { buildValidParams } from '../../utils/api';\nimport { PreviewContent } from '../components/PreviewContent';\nimport { PreviewHeader } from '../components/PreviewHeader';\nimport { useGetPreviewUrlQuery } from '../services/preview';\n\nimport type { UID } from '@strapi/types';\n\n/* -------------------------------------------------------------------------------------------------\n * PreviewProvider\n * -----------------------------------------------------------------------------------------------*/\n\ninterface PreviewContextValue {\n url: string;\n mainField: string;\n document: NonNullable<ReturnType<UseDocument>['document']>;\n meta: NonNullable<ReturnType<UseDocument>['meta']>;\n schema: NonNullable<ReturnType<UseDocument>['schema']>;\n}\n\nconst [PreviewProvider, usePreviewContext] = createContext<PreviewContextValue>('PreviewPage');\n\n/* -------------------------------------------------------------------------------------------------\n * PreviewPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst PreviewPage = () => {\n const { formatMessage } = useIntl();\n\n // Read all the necessary data from the URL to find the right preview URL\n const {\n slug: model,\n id: documentId,\n collectionType,\n } = useParams<{\n slug: UID.ContentType;\n id: string;\n collectionType: string;\n }>();\n const [{ query }] = useQueryParams<{\n plugins?: Record<string, unknown>;\n }>();\n\n const params = React.useMemo(() => buildValidParams(query), [query]);\n\n if (!collectionType) {\n throw new Error('Could not find collectionType in url params');\n }\n\n if (!model) {\n throw new Error('Could not find model in url params');\n }\n\n // Only collection types must have a documentId\n if (collectionType === COLLECTION_TYPES && !documentId) {\n throw new Error('Could not find documentId in url params');\n }\n\n const previewUrlResponse = useGetPreviewUrlQuery({\n params: {\n contentType: model,\n },\n query: {\n documentId,\n locale: params.locale,\n status: params.status as GetPreviewUrl.Request['query']['status'],\n },\n });\n\n const documentResponse = useDocument({\n model,\n collectionType,\n documentId,\n params,\n });\n\n const documentLayoutResponse = useDocumentLayout(model);\n\n if (\n documentResponse.isLoading ||\n previewUrlResponse.isLoading ||\n documentLayoutResponse.isLoading\n ) {\n return <Page.Loading />;\n }\n\n if (\n previewUrlResponse.error ||\n documentLayoutResponse.error ||\n !documentResponse.document ||\n !documentResponse.meta ||\n !documentResponse.schema\n ) {\n return <Page.Error />;\n }\n\n if (!previewUrlResponse.data?.data?.url) {\n return <Page.NoData />;\n }\n\n return (\n <>\n <Page.Title>\n {formatMessage(\n {\n id: 'content-manager.preview.page-title',\n defaultMessage: '{contentType} preview',\n },\n {\n contentType: documentLayoutResponse.edit.settings.displayName,\n }\n )}\n </Page.Title>\n <PreviewProvider\n url={previewUrlResponse.data.data.url}\n mainField={documentLayoutResponse.edit.settings.mainField}\n document={documentResponse.document}\n meta={documentResponse.meta}\n schema={documentResponse.schema}\n >\n <Flex direction=\"column\" height=\"100%\" alignItems={'stretch'}>\n <PreviewHeader />\n <PreviewContent />\n </Flex>\n </PreviewProvider>\n </>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * ProtectedPreviewPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst ProtectedPreviewPageImpl = () => {\n const { slug: model } = useParams<{\n slug: string;\n }>();\n const {\n permissions = [],\n isLoading,\n error,\n } = useRBAC([{ action: 'plugin::content-manager.explorer.read', subject: model }]);\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n if (error || !model) {\n return (\n <Box\n height=\"100vh\"\n width=\"100vw\"\n position=\"fixed\"\n top={0}\n left={0}\n zIndex={2}\n background=\"neutral0\"\n >\n <Page.Error />\n </Box>\n );\n }\n\n return (\n <Box\n height=\"100vh\"\n width=\"100vw\"\n position=\"fixed\"\n top={0}\n left={0}\n zIndex={2}\n background=\"neutral0\"\n >\n <Page.Protect permissions={permissions}>\n {({ permissions }) => (\n <DocumentRBAC permissions={permissions}>\n <PreviewPage />\n </DocumentRBAC>\n )}\n </Page.Protect>\n </Box>\n );\n};\n\nconst ProtectedPreviewPage = () => {\n return (\n <Portal>\n <FocusTrap>\n <ProtectedPreviewPageImpl />\n </FocusTrap>\n </Portal>\n );\n};\n\nexport { ProtectedPreviewPage, usePreviewContext };\n"],"names":["useIntl","jsx","Box","useQueryParams","useHistory","stringify","IconButton","Link","Cross","getDocumentStatus","DocumentStatus","Fragment","Tabs","jsxs","useNotification","useClipboard","Grid","LinkIcon","styled","Typography","createContext","useParams","React","buildValidParams","COLLECTION_TYPES","useGetPreviewUrlQuery","useDocument","useDocumentLayout","Page","Flex","useRBAC","permissions","DocumentRBAC","Portal","FocusTrap"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM,iBAAiB,MAAM;AAC3B,QAAM,aAAa,kBAAkB,kBAAkB,CAAC,UAAU,MAAM,GAAG;AAErE,QAAA,EAAE,cAAc,IAAIA,kBAAQ;AAGhC,SAAAC,2BAAA;AAAA,IAACC,aAAA;AAAA,IAAA;AAAA,MACC,KAAK;AAAA,MASL,OAAO,cAAc;AAAA,QACnB,IAAI;AAAA,QACJ,gBAAgB;AAAA,MAAA,CACjB;AAAA,MACD,OAAM;AAAA,MACN,QAAO;AAAA,MACP,aAAa;AAAA,MACb,KAAI;AAAA,IAAA;AAAA,IARC;AAAA,EASP;AAEJ;ACVA,MAAM,qBAAqB,MAAM;AAC/B,QAAM,CAAC,EAAE,OAAO,IAAIC,2BAEjB;AACG,QAAA,EAAE,cAAc,IAAIH,kBAAQ;AAElC,QAAM,YAAYI,YAAA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
11
|
const reactRouterDom = require("react-router-dom");
|
12
12
|
const reactWindow = require("react-window");
|
13
13
|
const styledComponents = require("styled-components");
|
14
|
-
const index = require("./index-
|
15
|
-
const useDragAndDrop = require("./useDragAndDrop-
|
16
|
-
const relations = require("./relations-
|
14
|
+
const index = require("./index-Ca7YWlAA.js");
|
15
|
+
const useDragAndDrop = require("./useDragAndDrop-BMtgCYzL.js");
|
16
|
+
const relations = require("./relations-C9Usz9k5.js");
|
17
17
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
18
18
|
function _interopNamespace(e) {
|
19
|
-
if (e && e.__esModule)
|
20
|
-
return e;
|
19
|
+
if (e && e.__esModule) return e;
|
21
20
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
22
21
|
if (e) {
|
23
22
|
for (const k in e) {
|
@@ -41,6 +40,31 @@ const [ComponentProvider, useComponent] = strapiAdmin.createContext("ComponentCo
|
|
41
40
|
uid: void 0,
|
42
41
|
type: void 0
|
43
42
|
});
|
43
|
+
function useHandleDisconnect(fieldName, consumerName) {
|
44
|
+
const field = strapiAdmin.useField(fieldName);
|
45
|
+
const removeFieldRow = strapiAdmin.useForm(consumerName, (state) => state.removeFieldRow);
|
46
|
+
const addFieldRow = strapiAdmin.useForm(consumerName, (state) => state.addFieldRow);
|
47
|
+
const handleDisconnect = (relation) => {
|
48
|
+
if (field.value && field.value.connect) {
|
49
|
+
const indexOfRelationInConnectArray = field.value.connect.findIndex(
|
50
|
+
(rel) => rel.id === relation.id
|
51
|
+
);
|
52
|
+
if (indexOfRelationInConnectArray >= 0) {
|
53
|
+
removeFieldRow(`${fieldName}.connect`, indexOfRelationInConnectArray);
|
54
|
+
return;
|
55
|
+
}
|
56
|
+
}
|
57
|
+
addFieldRow(`${fieldName}.disconnect`, {
|
58
|
+
id: relation.id,
|
59
|
+
apiData: {
|
60
|
+
id: relation.id,
|
61
|
+
documentId: relation.documentId,
|
62
|
+
locale: relation.locale
|
63
|
+
}
|
64
|
+
});
|
65
|
+
};
|
66
|
+
return handleDisconnect;
|
67
|
+
}
|
44
68
|
const RELATIONS_TO_DISPLAY = 5;
|
45
69
|
const ONE_WAY_RELATIONS = ["oneWay", "oneToOne", "manyToOne", "oneToManyMorph", "oneToOneMorph"];
|
46
70
|
const RelationsField = React__namespace.forwardRef(
|
@@ -53,9 +77,16 @@ const RelationsField = React__namespace.forwardRef(
|
|
53
77
|
const params = index.buildValidParams(query);
|
54
78
|
const isMorph = props.attribute.relation.toLowerCase().includes("morph");
|
55
79
|
const isDisabled = isMorph || disabled;
|
56
|
-
const {
|
80
|
+
const { componentId, componentUID } = useComponent("RelationsField", ({ uid, id: id2 }) => ({
|
81
|
+
componentId: id2,
|
82
|
+
componentUID: uid
|
83
|
+
}));
|
84
|
+
const isSubmitting = strapiAdmin.useForm("RelationsList", (state) => state.isSubmitting);
|
85
|
+
React__namespace.useEffect(() => {
|
86
|
+
setCurrentPage(1);
|
87
|
+
}, [isSubmitting]);
|
57
88
|
const id = componentId ? componentId.toString() : documentId;
|
58
|
-
const model =
|
89
|
+
const model = componentUID ?? documentModel;
|
59
90
|
const [targetField] = props.name.split(".").slice(-1);
|
60
91
|
const { data, isLoading, isFetching } = relations.useGetRelationsQuery(
|
61
92
|
{
|
@@ -108,10 +139,8 @@ const RelationsField = React__namespace.forwardRef(
|
|
108
139
|
);
|
109
140
|
const transformedRels = transformations([...data.results]);
|
110
141
|
return [...transformedRels, ...field.value?.connect ?? []].sort((a, b) => {
|
111
|
-
if (a.__temp_key__ < b.__temp_key__)
|
112
|
-
|
113
|
-
if (a.__temp_key__ > b.__temp_key__)
|
114
|
-
return 1;
|
142
|
+
if (a.__temp_key__ < b.__temp_key__) return -1;
|
143
|
+
if (a.__temp_key__ > b.__temp_key__) return 1;
|
115
144
|
return 0;
|
116
145
|
});
|
117
146
|
}, [
|
@@ -121,10 +150,16 @@ const RelationsField = React__namespace.forwardRef(
|
|
121
150
|
props.attribute.targetModel,
|
122
151
|
props.mainField
|
123
152
|
]);
|
153
|
+
const handleDisconnect = useHandleDisconnect(props.name, "RelationsField");
|
124
154
|
const handleConnect = (relation) => {
|
125
155
|
const [lastItemInList] = relations$1.slice(-1);
|
126
156
|
const item = {
|
127
157
|
id: relation.id,
|
158
|
+
apiData: {
|
159
|
+
id: relation.id,
|
160
|
+
documentId: relation.documentId,
|
161
|
+
locale: relation.locale
|
162
|
+
},
|
128
163
|
status: relation.status,
|
129
164
|
/**
|
130
165
|
* If there's a last item, that's the first key we use to generate out next one.
|
@@ -134,9 +169,11 @@ const RelationsField = React__namespace.forwardRef(
|
|
134
169
|
[props.mainField?.name ?? "documentId"]: relation[props.mainField?.name ?? "documentId"],
|
135
170
|
label: relations.getRelationLabel(relation, props.mainField),
|
136
171
|
// @ts-expect-error – targetModel does exist on the attribute, but it's not typed.
|
137
|
-
href: `../${index.COLLECTION_TYPES}/${props.attribute.targetModel}/${relation.documentId}`
|
172
|
+
href: `../${index.COLLECTION_TYPES}/${props.attribute.targetModel}/${relation.documentId}?${relation.locale ? `plugins[i18n][locale]=${relation.locale}` : ""}`
|
138
173
|
};
|
139
174
|
if (ONE_WAY_RELATIONS.includes(props.attribute.relation)) {
|
175
|
+
field.value?.connect?.forEach(handleDisconnect);
|
176
|
+
relations$1.forEach(handleDisconnect);
|
140
177
|
field.onChange(`${props.name}.connect`, [item]);
|
141
178
|
} else {
|
142
179
|
field.onChange(`${props.name}.connect`, [...field.value?.connect ?? [], item]);
|
@@ -157,7 +194,7 @@ const RelationsField = React__namespace.forwardRef(
|
|
157
194
|
RelationsInput,
|
158
195
|
{
|
159
196
|
disabled: isDisabled,
|
160
|
-
id,
|
197
|
+
id: componentUID ? componentId ? `${componentId}` : "" : documentId,
|
161
198
|
label: `${label} ${relationsCount > 0 ? `(${relationsCount})` : ""}`,
|
162
199
|
model,
|
163
200
|
onChange: handleConnect,
|
@@ -216,7 +253,7 @@ const addLabelAndHref = ({ mainField, href }) => (relations$1) => relations$1.ma
|
|
216
253
|
// Fallback to `id` if there is no `mainField` value, which will overwrite the above `documentId` property with the exact same data.
|
217
254
|
[mainField?.name ?? "documentId"]: relation[mainField?.name ?? "documentId"],
|
218
255
|
label: relations.getRelationLabel(relation, mainField),
|
219
|
-
href: `${href}/${relation.documentId}`
|
256
|
+
href: `${href}/${relation.documentId}?${relation.locale ? `plugins[i18n][locale]=${relation.locale}` : ""}`
|
220
257
|
};
|
221
258
|
});
|
222
259
|
const RelationsInput = ({
|
@@ -311,7 +348,7 @@ const RelationsInput = ({
|
|
311
348
|
{
|
312
349
|
ref: fieldRef,
|
313
350
|
name,
|
314
|
-
autocomplete: "
|
351
|
+
autocomplete: "list",
|
315
352
|
placeholder: placeholder || formatMessage({
|
316
353
|
id: index.getTranslation("relation.add"),
|
317
354
|
defaultMessage: "Add relation"
|
@@ -369,8 +406,6 @@ const RelationsList = ({
|
|
369
406
|
const [overflow, setOverflow] = React__namespace.useState();
|
370
407
|
const [liveText, setLiveText] = React__namespace.useState("");
|
371
408
|
const field = strapiAdmin.useField(name);
|
372
|
-
const removeFieldRow = strapiAdmin.useForm("RelationsList", (state) => state.removeFieldRow);
|
373
|
-
const addFieldRow = strapiAdmin.useForm("RelationsList", (state) => state.addFieldRow);
|
374
409
|
React__namespace.useEffect(() => {
|
375
410
|
if (data.length <= RELATIONS_TO_DISPLAY) {
|
376
411
|
return setOverflow(void 0);
|
@@ -420,17 +455,25 @@ const RelationsList = ({
|
|
420
455
|
newData.splice(oldIndex, 1);
|
421
456
|
newData.splice(newIndex, 0, { ...currentRow, __temp_key__: newKey });
|
422
457
|
const connectedRelations = newData.reduce((acc, relation, currentIndex, array) => {
|
423
|
-
const relationOnServer = serverData.find(
|
424
|
-
(oldRelation) => oldRelation.documentId === relation.documentId
|
425
|
-
);
|
458
|
+
const relationOnServer = serverData.find((oldRelation) => oldRelation.id === relation.id);
|
426
459
|
const relationInFront = array[currentIndex + 1];
|
427
460
|
if (!relationOnServer || relationOnServer.__temp_key__ !== relation.__temp_key__) {
|
428
461
|
const position = relationInFront ? {
|
429
462
|
before: relationInFront.documentId,
|
430
463
|
locale: relationInFront.locale,
|
431
|
-
status: relationInFront.
|
464
|
+
status: "publishedAt" in relationInFront && relationInFront.publishedAt ? "published" : "draft"
|
432
465
|
} : { end: true };
|
433
|
-
const relationWithPosition = {
|
466
|
+
const relationWithPosition = {
|
467
|
+
...relation,
|
468
|
+
...{
|
469
|
+
apiData: {
|
470
|
+
id: relation.id,
|
471
|
+
documentId: relation.documentId,
|
472
|
+
locale: relation.locale,
|
473
|
+
position
|
474
|
+
}
|
475
|
+
}
|
476
|
+
};
|
434
477
|
return [...acc, relationWithPosition];
|
435
478
|
}
|
436
479
|
return acc;
|
@@ -481,18 +524,7 @@ const RelationsList = ({
|
|
481
524
|
)
|
482
525
|
);
|
483
526
|
};
|
484
|
-
const handleDisconnect = (
|
485
|
-
if (field.value && field.value.connect) {
|
486
|
-
const indexOfRelationInConnectArray = field.value.connect.findIndex(
|
487
|
-
(rel) => rel.id === relation.id
|
488
|
-
);
|
489
|
-
if (indexOfRelationInConnectArray >= 0) {
|
490
|
-
removeFieldRow(`${name}.connect`, indexOfRelationInConnectArray);
|
491
|
-
return;
|
492
|
-
}
|
493
|
-
}
|
494
|
-
addFieldRow(`${name}.disconnect`, { id: relation.id });
|
495
|
-
};
|
527
|
+
const handleDisconnect = useHandleDisconnect(name, "RelationsList");
|
496
528
|
const canReorder = !ONE_WAY_RELATIONS.includes(relationType);
|
497
529
|
const dynamicListHeight = data.length > RELATIONS_TO_DISPLAY ? Math.min(data.length, RELATIONS_TO_DISPLAY) * (RELATION_ITEM_HEIGHT + RELATION_GUTTER) + RELATION_ITEM_HEIGHT / 2 : Math.min(data.length, RELATIONS_TO_DISPLAY) * (RELATION_ITEM_HEIGHT + RELATION_GUTTER);
|
498
530
|
return /* @__PURE__ */ jsxRuntime.jsxs(ShadowBox, { $overflowDirection: overflow, children: [
|
@@ -573,7 +605,7 @@ const ListItem = ({ data, index: index$1, style }) => {
|
|
573
605
|
relations: relations2
|
574
606
|
} = data;
|
575
607
|
const { formatMessage } = reactIntl.useIntl();
|
576
|
-
const { href,
|
608
|
+
const { href, id, label, status } = relations2[index$1];
|
577
609
|
const [{ handlerId, isDragging, handleKeyDown }, relationRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop.useDragAndDrop(
|
578
610
|
canDrag && !disabled,
|
579
611
|
{
|
@@ -582,7 +614,7 @@ const ListItem = ({ data, index: index$1, style }) => {
|
|
582
614
|
item: {
|
583
615
|
displayedValue: label,
|
584
616
|
status,
|
585
|
-
id
|
617
|
+
id,
|
586
618
|
index: index$1
|
587
619
|
},
|
588
620
|
onMoveItem: handleMoveItem,
|
@@ -630,7 +662,7 @@ const ListItem = ({ data, index: index$1, style }) => {
|
|
630
662
|
id: index.getTranslation("components.RelationInput.icon-button-aria-label"),
|
631
663
|
defaultMessage: "Drag"
|
632
664
|
}),
|
633
|
-
|
665
|
+
variant: "ghost",
|
634
666
|
onKeyDown: handleKeyDown,
|
635
667
|
disabled,
|
636
668
|
children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Drag, {})
|
@@ -642,16 +674,17 @@ const ListItem = ({ data, index: index$1, style }) => {
|
|
642
674
|
] })
|
643
675
|
] }),
|
644
676
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingLeft: 4, children: /* @__PURE__ */ jsxRuntime.jsx(
|
645
|
-
|
677
|
+
designSystem.IconButton,
|
646
678
|
{
|
647
|
-
disabled,
|
648
|
-
type: "button",
|
649
679
|
onClick: () => handleDisconnect(relations2[index$1]),
|
650
|
-
|
680
|
+
disabled,
|
681
|
+
label: formatMessage({
|
651
682
|
id: index.getTranslation("relation.disconnect"),
|
652
683
|
defaultMessage: "Remove"
|
653
684
|
}),
|
654
|
-
|
685
|
+
variant: "ghost",
|
686
|
+
size: "S",
|
687
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {})
|
655
688
|
}
|
656
689
|
) })
|
657
690
|
]
|
@@ -711,4 +744,4 @@ exports.FlexWrapper = FlexWrapper;
|
|
711
744
|
exports.LinkEllipsis = LinkEllipsis;
|
712
745
|
exports.MemoizedRelationsField = MemoizedRelationsField;
|
713
746
|
exports.useComponent = useComponent;
|
714
|
-
//# sourceMappingURL=Relations-
|
747
|
+
//# sourceMappingURL=Relations-CTGM7Hv5.js.map
|