@strapi/content-manager 0.0.0-experimental.e60ec1829240dae21c1e1d29076681c322288813 → 0.0.0-experimental.e8d8fc824d0f6a695b2a9ebaa4680ed21c3645ca
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-DSVYodBX.js → CardDragPreview-C0QyJgRA.js} +10 -14
- package/dist/_chunks/CardDragPreview-C0QyJgRA.js.map +1 -0
- package/dist/_chunks/{CardDragPreview-ikSG4M46.mjs → CardDragPreview-DOxamsuj.mjs} +7 -9
- package/dist/_chunks/CardDragPreview-DOxamsuj.mjs.map +1 -0
- package/dist/_chunks/{ComponentConfigurationPage-DjWJdz6Y.js → ComponentConfigurationPage-BlzvDpbX.js} +5 -6
- package/dist/_chunks/{ComponentConfigurationPage-DjWJdz6Y.js.map → ComponentConfigurationPage-BlzvDpbX.js.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-BPvzFjM7.mjs → ComponentConfigurationPage-DaPOlQaD.mjs} +4 -4
- package/dist/_chunks/{ComponentConfigurationPage-BPvzFjM7.mjs.map → ComponentConfigurationPage-DaPOlQaD.mjs.map} +1 -1
- package/dist/_chunks/{ComponentIcon-BBQsYCVn.js → ComponentIcon-CRbtQEUV.js} +9 -4
- package/dist/_chunks/ComponentIcon-CRbtQEUV.js.map +1 -0
- package/dist/_chunks/{ComponentIcon-BOFnK76n.mjs → ComponentIcon-u4bIXTFY.mjs} +9 -3
- package/dist/_chunks/ComponentIcon-u4bIXTFY.mjs.map +1 -0
- package/dist/_chunks/{EditConfigurationPage-DacbqQ_f.mjs → EditConfigurationPage-BZPXItXo.mjs} +4 -4
- package/dist/_chunks/{EditConfigurationPage-DacbqQ_f.mjs.map → EditConfigurationPage-BZPXItXo.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-Dmv83RlS.js → EditConfigurationPage-uy-v43AR.js} +5 -6
- package/dist/_chunks/{EditConfigurationPage-Dmv83RlS.js.map → EditConfigurationPage-uy-v43AR.js.map} +1 -1
- package/dist/_chunks/{EditViewPage-DvNpQkam.js → EditViewPage-DT6A4ayX.js} +102 -54
- package/dist/_chunks/EditViewPage-DT6A4ayX.js.map +1 -0
- package/dist/_chunks/EditViewPage-oOLeTySr.mjs +254 -0
- package/dist/_chunks/EditViewPage-oOLeTySr.mjs.map +1 -0
- package/dist/_chunks/{Field-6gvGdPBV.mjs → Field-D7dv2aUX.mjs} +1192 -896
- package/dist/_chunks/Field-D7dv2aUX.mjs.map +1 -0
- package/dist/_chunks/{Field-DmVKIAOo.js → Field-kYFVIGiP.js} +1238 -943
- package/dist/_chunks/Field-kYFVIGiP.js.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-DW6K1IH-.mjs → Form-BxR6sc29.mjs} +67 -46
- package/dist/_chunks/Form-BxR6sc29.mjs.map +1 -0
- package/dist/_chunks/{Form-CPZC9vWa.js → Form-CCijSg3V.js} +68 -49
- package/dist/_chunks/Form-CCijSg3V.js.map +1 -0
- package/dist/_chunks/{History-DeAPlvtv.js → History-BMndx49M.js} +182 -147
- package/dist/_chunks/History-BMndx49M.js.map +1 -0
- package/dist/_chunks/{History-Dmr9fmUA.mjs → History-D8F7aYQU.mjs} +181 -144
- package/dist/_chunks/History-D8F7aYQU.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-DPCwW5Vr.js → ListConfigurationPage-DouY1EWM.js} +72 -63
- package/dist/_chunks/ListConfigurationPage-DouY1EWM.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-DhwvYcNv.mjs → ListConfigurationPage-DqAdSPwC.mjs} +68 -57
- package/dist/_chunks/ListConfigurationPage-DqAdSPwC.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-5ySZ-VUs.js → ListViewPage-BPVmh9pq.js} +179 -164
- package/dist/_chunks/ListViewPage-BPVmh9pq.js.map +1 -0
- package/dist/_chunks/{ListViewPage-BtAwuYLE.mjs → ListViewPage-C73F0jPh.mjs} +175 -159
- package/dist/_chunks/ListViewPage-C73F0jPh.mjs.map +1 -0
- package/dist/_chunks/{NoContentTypePage-DSPxnxxp.mjs → NoContentTypePage-B5w7iJOF.mjs} +3 -3
- package/dist/_chunks/NoContentTypePage-B5w7iJOF.mjs.map +1 -0
- package/dist/_chunks/{NoContentTypePage-DOC_yWOf.js → NoContentTypePage-BwcL--4H.js} +3 -3
- package/dist/_chunks/NoContentTypePage-BwcL--4H.js.map +1 -0
- package/dist/_chunks/{NoPermissionsPage-Dwu8rRJu.js → NoPermissionsPage-BMFKVcwJ.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-Dwu8rRJu.js.map → NoPermissionsPage-BMFKVcwJ.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-UWDC-1Tw.mjs → NoPermissionsPage-UnEgMGK4.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-UWDC-1Tw.mjs.map → NoPermissionsPage-UnEgMGK4.mjs.map} +1 -1
- package/dist/_chunks/Preview-B7PR3Ok_.js +312 -0
- package/dist/_chunks/Preview-B7PR3Ok_.js.map +1 -0
- package/dist/_chunks/Preview-DECOhK0D.mjs +294 -0
- package/dist/_chunks/Preview-DECOhK0D.mjs.map +1 -0
- package/dist/_chunks/{Relations-J8cscLlR.mjs → Relations-DinMQJ4B.mjs} +138 -94
- package/dist/_chunks/Relations-DinMQJ4B.mjs.map +1 -0
- package/dist/_chunks/{Relations-CgWtgnPe.js → Relations-lndx3aQk.js} +142 -100
- package/dist/_chunks/Relations-lndx3aQk.js.map +1 -0
- package/dist/_chunks/{en-C-V1_90f.js → en-BK8Xyl5I.js} +38 -18
- package/dist/_chunks/{en-C-V1_90f.js.map → en-BK8Xyl5I.js.map} +1 -1
- package/dist/_chunks/{en-MBPul9Su.mjs → en-Dtk_ot79.mjs} +38 -18
- package/dist/_chunks/{en-MBPul9Su.mjs.map → en-Dtk_ot79.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-CwRRo1V9.mjs → index-C2SagWVW.mjs} +2070 -988
- package/dist/_chunks/index-C2SagWVW.mjs.map +1 -0
- package/dist/_chunks/{index-C6AH2hEl.js → index-Cnw4gqee.js} +2047 -966
- package/dist/_chunks/index-Cnw4gqee.js.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-jIDzX0Fp.mjs → layout-DY_D9MGA.mjs} +46 -28
- package/dist/_chunks/layout-DY_D9MGA.mjs.map +1 -0
- package/dist/_chunks/{layout-B_SXLhqf.js → layout-ivwIVPnV.js} +47 -32
- package/dist/_chunks/layout-ivwIVPnV.js.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-iBMa_OFG.js → relations-B7C7O_Pv.js} +6 -7
- package/dist/_chunks/relations-B7C7O_Pv.js.map +1 -0
- package/dist/_chunks/{relations-CuvIgCqI.mjs → relations-Boc5Y9kX.mjs} +6 -7
- package/dist/_chunks/relations-Boc5Y9kX.mjs.map +1 -0
- package/dist/_chunks/useDebounce-CtcjDB3L.js +28 -0
- 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-BMtgCYzL.js.map +1 -0
- package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs → useDragAndDrop-DJ6jqvZN.mjs} +4 -7
- package/dist/_chunks/useDragAndDrop-DJ6jqvZN.mjs.map +1 -0
- package/dist/admin/index.js +3 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +9 -7
- package/dist/admin/src/components/ComponentIcon.d.ts +6 -3
- package/dist/admin/src/content-manager.d.ts +6 -5
- package/dist/admin/src/exports.d.ts +2 -1
- package/dist/admin/src/history/components/VersionInputRenderer.d.ts +1 -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 +37 -9
- package/dist/admin/src/hooks/useDocumentActions.d.ts +24 -3
- package/dist/admin/src/hooks/useDocumentLayout.d.ts +2 -2
- package/dist/admin/src/hooks/useDragAndDrop.d.ts +4 -4
- package/dist/admin/src/hooks/useKeyboardDragAndDrop.d.ts +1 -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 +12 -5
- package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +2 -2
- 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/BlocksInput.d.ts +3 -3
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +5 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/Component/Input.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.d.ts +3 -5
- package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/Field.d.ts +1 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/Relations.d.ts +30 -18
- package/dist/admin/src/pages/EditView/components/FormInputs/UID.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +3 -49
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/Field.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 +16 -53
- package/dist/admin/src/pages/EditView/components/Header.d.ts +11 -11
- package/dist/admin/src/pages/EditView/components/InputRenderer.d.ts +2 -10
- package/dist/admin/src/pages/ListView/components/BulkActions/Actions.d.ts +3 -30
- package/dist/admin/src/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.d.ts +2 -2
- package/dist/admin/src/pages/ListView/components/BulkActions/PublishAction.d.ts +9 -26
- 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 +2 -3
- package/dist/admin/src/services/components.d.ts +2 -2
- package/dist/admin/src/services/contentTypes.d.ts +5 -5
- package/dist/admin/src/services/documents.d.ts +31 -20
- package/dist/admin/src/services/init.d.ts +2 -2
- package/dist/admin/src/services/relations.d.ts +3 -3
- package/dist/admin/src/services/uid.d.ts +3 -3
- package/dist/admin/src/utils/api.d.ts +4 -18
- package/dist/admin/src/utils/validation.d.ts +5 -7
- package/dist/server/index.js +886 -480
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +892 -485
- 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/single-types.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 +23 -0
- package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -0
- package/dist/server/src/controllers/validation/dimensions.d.ts +11 -0
- package/dist/server/src/controllers/validation/dimensions.d.ts.map +1 -0
- package/dist/server/src/controllers/validation/index.d.ts +1 -1
- 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 +4 -4
- package/dist/server/src/history/services/utils.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +22 -42
- 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 +13 -12
- package/dist/server/src/services/document-manager.d.ts.map +1 -1
- package/dist/server/src/services/document-metadata.d.ts +16 -35
- package/dist/server/src/services/document-metadata.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +22 -42
- 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 +8 -1
- 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 +17 -7
- 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/contracts/relations.d.ts +2 -2
- package/dist/shared/contracts/relations.d.ts.map +1 -1
- 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 +22 -21
- package/dist/_chunks/CardDragPreview-DSVYodBX.js.map +0 -1
- package/dist/_chunks/CardDragPreview-ikSG4M46.mjs.map +0 -1
- package/dist/_chunks/ComponentIcon-BBQsYCVn.js.map +0 -1
- package/dist/_chunks/ComponentIcon-BOFnK76n.mjs.map +0 -1
- package/dist/_chunks/EditViewPage-DDS6H9HO.mjs +0 -203
- package/dist/_chunks/EditViewPage-DDS6H9HO.mjs.map +0 -1
- package/dist/_chunks/EditViewPage-DvNpQkam.js.map +0 -1
- package/dist/_chunks/Field-6gvGdPBV.mjs.map +0 -1
- package/dist/_chunks/Field-DmVKIAOo.js.map +0 -1
- package/dist/_chunks/Form-CPZC9vWa.js.map +0 -1
- package/dist/_chunks/Form-DW6K1IH-.mjs.map +0 -1
- package/dist/_chunks/History-DeAPlvtv.js.map +0 -1
- package/dist/_chunks/History-Dmr9fmUA.mjs.map +0 -1
- package/dist/_chunks/ListConfigurationPage-DPCwW5Vr.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-DhwvYcNv.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-5ySZ-VUs.js.map +0 -1
- package/dist/_chunks/ListViewPage-BtAwuYLE.mjs.map +0 -1
- package/dist/_chunks/NoContentTypePage-DOC_yWOf.js.map +0 -1
- package/dist/_chunks/NoContentTypePage-DSPxnxxp.mjs.map +0 -1
- package/dist/_chunks/Relations-CgWtgnPe.js.map +0 -1
- package/dist/_chunks/Relations-J8cscLlR.mjs.map +0 -1
- package/dist/_chunks/index-C6AH2hEl.js.map +0 -1
- package/dist/_chunks/index-CwRRo1V9.mjs.map +0 -1
- package/dist/_chunks/layout-B_SXLhqf.js.map +0 -1
- package/dist/_chunks/layout-jIDzX0Fp.mjs.map +0 -1
- package/dist/_chunks/relations-CuvIgCqI.mjs.map +0 -1
- package/dist/_chunks/relations-iBMa_OFG.js.map +0 -1
- package/dist/_chunks/urls-CbOsUOoW.mjs +0 -7
- package/dist/_chunks/urls-CbOsUOoW.mjs.map +0 -1
- package/dist/_chunks/urls-DzZya_gm.js +0 -6
- package/dist/_chunks/urls-DzZya_gm.js.map +0 -1
- package/dist/_chunks/useDragAndDrop-DdHgKsqq.mjs.map +0 -1
- package/dist/_chunks/useDragAndDrop-J0TUUbR6.js.map +0 -1
- package/dist/server/src/controllers/utils/dimensions.d.ts +0 -5
- package/dist/server/src/controllers/utils/dimensions.d.ts.map +0 -1
- package/strapi-server.js +0 -3
@@ -1,25 +1,76 @@
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
2
2
|
import * as React from "react";
|
3
|
-
import { useState, useEffect, useCallback } from "react";
|
3
|
+
import { useState, useEffect, useCallback, memo } from "react";
|
4
4
|
import { useStrapiApp, createContext, useField, useNotification, useForm, useAPIErrorHandler, useQueryParams, useFocusInputField, InputRenderer as InputRenderer$1 } from "@strapi/admin/strapi-admin";
|
5
|
-
import { Typography, Flex,
|
5
|
+
import { Box, SingleSelect, SingleSelectOption, Typography, Flex, BaseLink, Button, Popover, Field, Tooltip, IconButton, useComposedRefs, Portal, FocusTrap, Divider, VisuallyHidden, Grid as Grid$1, Accordion, TextButton, TextInput, IconButtonGroup, Menu, MenuItem } from "@strapi/design-system";
|
6
6
|
import pipe$1 from "lodash/fp/pipe";
|
7
7
|
import { useIntl } from "react-intl";
|
8
|
-
import {
|
8
|
+
import { m as DOCUMENT_META_FIELDS, g as getTranslation, c as useDoc, e as contentManagerApi, n as CLONE_PATH, d as buildValidParams, f as useDocumentRBAC, S as SINGLE_TYPES, o as useDocLayout } from "./index-C2SagWVW.mjs";
|
9
9
|
import { generateNKeysBetween } from "fractional-indexing";
|
10
|
-
import { u as useComponent, C as ComponentProvider,
|
11
|
-
import {
|
12
|
-
import styled,
|
13
|
-
import { C as ComponentIcon } from "./ComponentIcon-
|
10
|
+
import { u as useComponent, C as ComponentProvider, M as MemoizedRelationsField } from "./Relations-DinMQJ4B.mjs";
|
11
|
+
import { CodeBlock as CodeBlock$1, HeadingOne, HeadingTwo, HeadingThree, HeadingFour, HeadingFive, HeadingSix, Image as Image$1, NumberList, BulletList, Paragraph, Quotes, Link as Link$1, Drag, Collapse, Bold, Italic, Underline, StrikeThrough, Code, Expand, PlusCircle, Plus, Trash, EyeStriked, CheckCircle, WarningCircle, Loader, ArrowClockwise, More } from "@strapi/icons";
|
12
|
+
import { styled, css, keyframes } from "styled-components";
|
13
|
+
import { C as ComponentIcon, a as COMPONENT_ICONS } from "./ComponentIcon-u4bIXTFY.mjs";
|
14
14
|
import { getEmptyImage } from "react-dnd-html5-backend";
|
15
|
-
import { a as DIRECTIONS, u as useDragAndDrop, I as ItemTypes } from "./useDragAndDrop-
|
16
|
-
import { g as getIn } from "./objects-
|
15
|
+
import { a as DIRECTIONS, u as useDragAndDrop, I as ItemTypes } from "./useDragAndDrop-DJ6jqvZN.mjs";
|
16
|
+
import { g as getIn } from "./objects-D6yBsdmx.mjs";
|
17
17
|
import { Editor as Editor$1, Transforms, Node, Element, Range, Path, Point, createEditor } from "slate";
|
18
18
|
import { withHistory } from "slate-history";
|
19
19
|
import { useFocused, useSelected, ReactEditor, Editable, useSlate, Slate, withReact } from "slate-react";
|
20
|
-
import
|
20
|
+
import * as Prism from "prismjs";
|
21
|
+
import "prismjs/themes/prism-solarizedlight.css";
|
22
|
+
import "prismjs/components/prism-asmatmel";
|
23
|
+
import "prismjs/components/prism-bash";
|
24
|
+
import "prismjs/components/prism-basic";
|
25
|
+
import "prismjs/components/prism-c";
|
26
|
+
import "prismjs/components/prism-clojure";
|
27
|
+
import "prismjs/components/prism-cobol";
|
28
|
+
import "prismjs/components/prism-cpp";
|
29
|
+
import "prismjs/components/prism-csharp";
|
30
|
+
import "prismjs/components/prism-dart";
|
31
|
+
import "prismjs/components/prism-docker";
|
32
|
+
import "prismjs/components/prism-elixir";
|
33
|
+
import "prismjs/components/prism-erlang";
|
34
|
+
import "prismjs/components/prism-fortran";
|
35
|
+
import "prismjs/components/prism-fsharp";
|
36
|
+
import "prismjs/components/prism-go";
|
37
|
+
import "prismjs/components/prism-graphql";
|
38
|
+
import "prismjs/components/prism-groovy";
|
39
|
+
import "prismjs/components/prism-haskell";
|
40
|
+
import "prismjs/components/prism-haxe";
|
41
|
+
import "prismjs/components/prism-ini";
|
42
|
+
import "prismjs/components/prism-java";
|
43
|
+
import "prismjs/components/prism-javascript";
|
44
|
+
import "prismjs/components/prism-jsx";
|
45
|
+
import "prismjs/components/prism-json";
|
46
|
+
import "prismjs/components/prism-julia";
|
47
|
+
import "prismjs/components/prism-kotlin";
|
48
|
+
import "prismjs/components/prism-latex";
|
49
|
+
import "prismjs/components/prism-lua";
|
50
|
+
import "prismjs/components/prism-markdown";
|
51
|
+
import "prismjs/components/prism-matlab";
|
52
|
+
import "prismjs/components/prism-makefile";
|
53
|
+
import "prismjs/components/prism-objectivec";
|
54
|
+
import "prismjs/components/prism-perl";
|
55
|
+
import "prismjs/components/prism-php";
|
56
|
+
import "prismjs/components/prism-powershell";
|
57
|
+
import "prismjs/components/prism-python";
|
58
|
+
import "prismjs/components/prism-r";
|
59
|
+
import "prismjs/components/prism-ruby";
|
60
|
+
import "prismjs/components/prism-rust";
|
61
|
+
import "prismjs/components/prism-sas";
|
62
|
+
import "prismjs/components/prism-scala";
|
63
|
+
import "prismjs/components/prism-scheme";
|
64
|
+
import "prismjs/components/prism-sql";
|
65
|
+
import "prismjs/components/prism-stata";
|
66
|
+
import "prismjs/components/prism-swift";
|
67
|
+
import "prismjs/components/prism-typescript";
|
68
|
+
import "prismjs/components/prism-tsx";
|
69
|
+
import "prismjs/components/prism-vbnet";
|
70
|
+
import "prismjs/components/prism-yaml";
|
71
|
+
import { p as prefixFileUrlWithBackendUrl, u as usePrev, a as useDebounce } from "./useDebounce-DmuSJIF3.mjs";
|
21
72
|
import * as Toolbar from "@radix-ui/react-toolbar";
|
22
|
-
import { useLocation } from "react-router-dom";
|
73
|
+
import { useLocation, useMatch } from "react-router-dom";
|
23
74
|
import CodeMirror from "codemirror5";
|
24
75
|
import sanitizeHtml from "sanitize-html";
|
25
76
|
import { getLanguage, highlight, highlightAuto } from "highlight.js";
|
@@ -160,6 +211,224 @@ const useLazyComponents = (componentUids = []) => {
|
|
160
211
|
}, []);
|
161
212
|
return { isLazyLoading: loading, lazyComponentStore, cleanup };
|
162
213
|
};
|
214
|
+
const codeLanguages = [
|
215
|
+
{
|
216
|
+
value: "asm",
|
217
|
+
label: "Assembly",
|
218
|
+
decorate: "asmatmel"
|
219
|
+
},
|
220
|
+
{
|
221
|
+
value: "bash",
|
222
|
+
label: "Bash"
|
223
|
+
},
|
224
|
+
{
|
225
|
+
value: "c",
|
226
|
+
label: "C"
|
227
|
+
},
|
228
|
+
{
|
229
|
+
value: "clojure",
|
230
|
+
label: "Clojure"
|
231
|
+
},
|
232
|
+
{
|
233
|
+
value: "cobol",
|
234
|
+
label: "COBOL"
|
235
|
+
},
|
236
|
+
{
|
237
|
+
value: "cpp",
|
238
|
+
label: "C++"
|
239
|
+
},
|
240
|
+
{
|
241
|
+
value: "csharp",
|
242
|
+
label: "C#"
|
243
|
+
},
|
244
|
+
{
|
245
|
+
value: "css",
|
246
|
+
label: "CSS"
|
247
|
+
},
|
248
|
+
{
|
249
|
+
value: "dart",
|
250
|
+
label: "Dart"
|
251
|
+
},
|
252
|
+
{
|
253
|
+
value: "dockerfile",
|
254
|
+
label: "Dockerfile",
|
255
|
+
decorate: "docker"
|
256
|
+
},
|
257
|
+
{
|
258
|
+
value: "elixir",
|
259
|
+
label: "Elixir"
|
260
|
+
},
|
261
|
+
{
|
262
|
+
value: "erlang",
|
263
|
+
label: "Erlang"
|
264
|
+
},
|
265
|
+
{
|
266
|
+
value: "fortran",
|
267
|
+
label: "Fortran"
|
268
|
+
},
|
269
|
+
{
|
270
|
+
value: "fsharp",
|
271
|
+
label: "F#"
|
272
|
+
},
|
273
|
+
{
|
274
|
+
value: "go",
|
275
|
+
label: "Go"
|
276
|
+
},
|
277
|
+
{
|
278
|
+
value: "graphql",
|
279
|
+
label: "GraphQL"
|
280
|
+
},
|
281
|
+
{
|
282
|
+
value: "groovy",
|
283
|
+
label: "Groovy"
|
284
|
+
},
|
285
|
+
{
|
286
|
+
value: "haskell",
|
287
|
+
label: "Haskell"
|
288
|
+
},
|
289
|
+
{
|
290
|
+
value: "haxe",
|
291
|
+
label: "Haxe"
|
292
|
+
},
|
293
|
+
{
|
294
|
+
value: "html",
|
295
|
+
label: "HTML"
|
296
|
+
},
|
297
|
+
{
|
298
|
+
value: "ini",
|
299
|
+
label: "INI"
|
300
|
+
},
|
301
|
+
{
|
302
|
+
value: "java",
|
303
|
+
label: "Java"
|
304
|
+
},
|
305
|
+
{
|
306
|
+
value: "javascript",
|
307
|
+
label: "JavaScript"
|
308
|
+
},
|
309
|
+
{
|
310
|
+
value: "jsx",
|
311
|
+
label: "JavaScript (React)"
|
312
|
+
},
|
313
|
+
{
|
314
|
+
value: "json",
|
315
|
+
label: "JSON"
|
316
|
+
},
|
317
|
+
{
|
318
|
+
value: "julia",
|
319
|
+
label: "Julia"
|
320
|
+
},
|
321
|
+
{
|
322
|
+
value: "kotlin",
|
323
|
+
label: "Kotlin"
|
324
|
+
},
|
325
|
+
{
|
326
|
+
value: "latex",
|
327
|
+
label: "LaTeX"
|
328
|
+
},
|
329
|
+
{
|
330
|
+
value: "lua",
|
331
|
+
label: "Lua"
|
332
|
+
},
|
333
|
+
{
|
334
|
+
value: "markdown",
|
335
|
+
label: "Markdown"
|
336
|
+
},
|
337
|
+
{
|
338
|
+
value: "matlab",
|
339
|
+
label: "MATLAB"
|
340
|
+
},
|
341
|
+
{
|
342
|
+
value: "makefile",
|
343
|
+
label: "Makefile"
|
344
|
+
},
|
345
|
+
{
|
346
|
+
value: "objectivec",
|
347
|
+
label: "Objective-C"
|
348
|
+
},
|
349
|
+
{
|
350
|
+
value: "perl",
|
351
|
+
label: "Perl"
|
352
|
+
},
|
353
|
+
{
|
354
|
+
value: "php",
|
355
|
+
label: "PHP"
|
356
|
+
},
|
357
|
+
{
|
358
|
+
value: "plaintext",
|
359
|
+
label: "Plain text"
|
360
|
+
},
|
361
|
+
{
|
362
|
+
value: "powershell",
|
363
|
+
label: "PowerShell"
|
364
|
+
},
|
365
|
+
{
|
366
|
+
value: "python",
|
367
|
+
label: "Python"
|
368
|
+
},
|
369
|
+
{
|
370
|
+
value: "r",
|
371
|
+
label: "R"
|
372
|
+
},
|
373
|
+
{
|
374
|
+
value: "ruby",
|
375
|
+
label: "Ruby"
|
376
|
+
},
|
377
|
+
{
|
378
|
+
value: "rust",
|
379
|
+
label: "Rust"
|
380
|
+
},
|
381
|
+
{
|
382
|
+
value: "sas",
|
383
|
+
label: "SAS"
|
384
|
+
},
|
385
|
+
{
|
386
|
+
value: "scala",
|
387
|
+
label: "Scala"
|
388
|
+
},
|
389
|
+
{
|
390
|
+
value: "scheme",
|
391
|
+
label: "Scheme"
|
392
|
+
},
|
393
|
+
{
|
394
|
+
value: "shell",
|
395
|
+
label: "Shell"
|
396
|
+
},
|
397
|
+
{
|
398
|
+
value: "sql",
|
399
|
+
label: "SQL"
|
400
|
+
},
|
401
|
+
{
|
402
|
+
value: "stata",
|
403
|
+
label: "Stata"
|
404
|
+
},
|
405
|
+
{
|
406
|
+
value: "swift",
|
407
|
+
label: "Swift"
|
408
|
+
},
|
409
|
+
{
|
410
|
+
value: "typescript",
|
411
|
+
label: "TypeScript",
|
412
|
+
decorate: "ts"
|
413
|
+
},
|
414
|
+
{
|
415
|
+
value: "tsx",
|
416
|
+
label: "TypeScript (React)"
|
417
|
+
},
|
418
|
+
{
|
419
|
+
value: "vbnet",
|
420
|
+
label: "VB.NET"
|
421
|
+
},
|
422
|
+
{
|
423
|
+
value: "xml",
|
424
|
+
label: "XML"
|
425
|
+
},
|
426
|
+
{
|
427
|
+
value: "yaml",
|
428
|
+
label: "YAML",
|
429
|
+
decorate: "yml"
|
430
|
+
}
|
431
|
+
];
|
163
432
|
const baseHandleConvert = (editor, attributesToSet) => {
|
164
433
|
const [_, lastNodePath] = Editor$1.last(editor, []);
|
165
434
|
Transforms.unwrapNodes(editor, {
|
@@ -223,13 +492,37 @@ const pressEnterTwiceToExit = (editor) => {
|
|
223
492
|
});
|
224
493
|
}
|
225
494
|
};
|
226
|
-
const
|
495
|
+
const decorateCode = ([node, path]) => {
|
496
|
+
const ranges = [];
|
497
|
+
if (!Element.isElement(node) || node.type !== "code") return ranges;
|
498
|
+
const text = Node.string(node);
|
499
|
+
const language = codeLanguages.find((lang) => lang.value === node.language);
|
500
|
+
const decorateKey = language?.decorate ?? language?.value;
|
501
|
+
const selectedLanguage = Prism.languages[decorateKey || "plaintext"];
|
502
|
+
const tokens = Prism.tokenize(text, selectedLanguage);
|
503
|
+
let start = 0;
|
504
|
+
for (const token of tokens) {
|
505
|
+
const length = token.length;
|
506
|
+
const end = start + length;
|
507
|
+
if (typeof token !== "string") {
|
508
|
+
ranges.push({
|
509
|
+
anchor: { path, offset: start },
|
510
|
+
focus: { path, offset: end },
|
511
|
+
className: `token ${token.type}`
|
512
|
+
});
|
513
|
+
}
|
514
|
+
start = end;
|
515
|
+
}
|
516
|
+
return ranges;
|
517
|
+
};
|
518
|
+
const CodeBlock = styled.pre`
|
227
519
|
border-radius: ${({ theme }) => theme.borderRadius};
|
228
520
|
background-color: ${({ theme }) => theme.colors.neutral100};
|
229
521
|
max-width: 100%;
|
230
522
|
overflow: auto;
|
231
523
|
padding: ${({ theme }) => `${theme.spaces[3]} ${theme.spaces[4]}`};
|
232
524
|
flex-shrink: 1;
|
525
|
+
|
233
526
|
& > code {
|
234
527
|
font-family: 'SF Mono', SFMono-Regular, ui-monospace, 'DejaVu Sans Mono', Menlo, Consolas,
|
235
528
|
monospace;
|
@@ -238,10 +531,62 @@ const CodeBlock = styled.pre.attrs({ role: "code" })`
|
|
238
531
|
max-width: 100%;
|
239
532
|
}
|
240
533
|
`;
|
534
|
+
const CodeEditor = (props) => {
|
535
|
+
const { editor } = useBlocksEditorContext("ImageDialog");
|
536
|
+
const editorIsFocused = useFocused();
|
537
|
+
const imageIsSelected = useSelected();
|
538
|
+
const { formatMessage } = useIntl();
|
539
|
+
const [isSelectOpen, setIsSelectOpen] = React.useState(false);
|
540
|
+
const shouldDisplayLanguageSelect = editorIsFocused && imageIsSelected || isSelectOpen;
|
541
|
+
return /* @__PURE__ */ jsxs(Box, { position: "relative", width: "100%", children: [
|
542
|
+
/* @__PURE__ */ jsx(CodeBlock, { ...props.attributes, children: /* @__PURE__ */ jsx("code", { children: props.children }) }),
|
543
|
+
shouldDisplayLanguageSelect && /* @__PURE__ */ jsx(
|
544
|
+
Box,
|
545
|
+
{
|
546
|
+
position: "absolute",
|
547
|
+
background: "neutral0",
|
548
|
+
borderColor: "neutral150",
|
549
|
+
borderStyle: "solid",
|
550
|
+
borderWidth: "0.5px",
|
551
|
+
shadow: "tableShadow",
|
552
|
+
top: "100%",
|
553
|
+
marginTop: 1,
|
554
|
+
right: 0,
|
555
|
+
padding: 1,
|
556
|
+
hasRadius: true,
|
557
|
+
children: /* @__PURE__ */ jsx(
|
558
|
+
SingleSelect,
|
559
|
+
{
|
560
|
+
onChange: (open) => {
|
561
|
+
Transforms.setNodes(
|
562
|
+
editor,
|
563
|
+
{ language: open.toString() },
|
564
|
+
{ match: (node) => !Editor$1.isEditor(node) && node.type === "code" }
|
565
|
+
);
|
566
|
+
},
|
567
|
+
value: props.element.type === "code" && props.element.language || "plaintext",
|
568
|
+
onOpenChange: (open) => {
|
569
|
+
setIsSelectOpen(open);
|
570
|
+
if (!open) {
|
571
|
+
ReactEditor.focus(editor);
|
572
|
+
}
|
573
|
+
},
|
574
|
+
onCloseAutoFocus: (e) => e.preventDefault(),
|
575
|
+
"aria-label": formatMessage({
|
576
|
+
id: "components.Blocks.blocks.code.languageLabel",
|
577
|
+
defaultMessage: "Select a language"
|
578
|
+
}),
|
579
|
+
children: codeLanguages.map(({ value, label }) => /* @__PURE__ */ jsx(SingleSelectOption, { value, children: label }, value))
|
580
|
+
}
|
581
|
+
)
|
582
|
+
}
|
583
|
+
)
|
584
|
+
] });
|
585
|
+
};
|
241
586
|
const codeBlocks = {
|
242
587
|
code: {
|
243
|
-
renderElement: (props) => /* @__PURE__ */ jsx(
|
244
|
-
icon:
|
588
|
+
renderElement: (props) => /* @__PURE__ */ jsx(CodeEditor, { ...props }),
|
589
|
+
icon: CodeBlock$1,
|
245
590
|
label: {
|
246
591
|
id: "components.Blocks.blocks.code",
|
247
592
|
defaultMessage: "Code block"
|
@@ -249,36 +594,35 @@ const codeBlocks = {
|
|
249
594
|
matchNode: (node) => node.type === "code",
|
250
595
|
isInBlocksSelector: true,
|
251
596
|
handleConvert(editor) {
|
252
|
-
baseHandleConvert(editor, { type: "code" });
|
597
|
+
baseHandleConvert(editor, { type: "code", language: "plaintext" });
|
253
598
|
},
|
254
599
|
handleEnterKey(editor) {
|
255
600
|
pressEnterTwiceToExit(editor);
|
256
601
|
},
|
257
|
-
snippets: ["```"]
|
258
|
-
dragHandleTopMargin: "10px"
|
602
|
+
snippets: ["```"]
|
259
603
|
}
|
260
604
|
};
|
261
|
-
const H1 = styled(Typography).attrs({
|
605
|
+
const H1 = styled(Typography).attrs({ tag: "h1" })`
|
262
606
|
font-size: 4.2rem;
|
263
607
|
line-height: ${({ theme }) => theme.lineHeights[1]};
|
264
608
|
`;
|
265
|
-
const H2 = styled(Typography).attrs({
|
609
|
+
const H2 = styled(Typography).attrs({ tag: "h2" })`
|
266
610
|
font-size: 3.5rem;
|
267
611
|
line-height: ${({ theme }) => theme.lineHeights[1]};
|
268
612
|
`;
|
269
|
-
const H3 = styled(Typography).attrs({
|
613
|
+
const H3 = styled(Typography).attrs({ tag: "h3" })`
|
270
614
|
font-size: 2.9rem;
|
271
615
|
line-height: ${({ theme }) => theme.lineHeights[1]};
|
272
616
|
`;
|
273
|
-
const H4 = styled(Typography).attrs({
|
617
|
+
const H4 = styled(Typography).attrs({ tag: "h4" })`
|
274
618
|
font-size: 2.4rem;
|
275
619
|
line-height: ${({ theme }) => theme.lineHeights[1]};
|
276
620
|
`;
|
277
|
-
const H5 = styled(Typography).attrs({
|
621
|
+
const H5 = styled(Typography).attrs({ tag: "h5" })`
|
278
622
|
font-size: 2rem;
|
279
623
|
line-height: ${({ theme }) => theme.lineHeights[1]};
|
280
624
|
`;
|
281
|
-
const H6 = styled(Typography).attrs({
|
625
|
+
const H6 = styled(Typography).attrs({ tag: "h6" })`
|
282
626
|
font-size: 1.6rem;
|
283
627
|
line-height: ${({ theme }) => theme.lineHeights[1]};
|
284
628
|
`;
|
@@ -367,7 +711,7 @@ const headingBlocks = {
|
|
367
711
|
const ImageWrapper = styled(Flex)`
|
368
712
|
transition-property: box-shadow;
|
369
713
|
transition-duration: 0.2s;
|
370
|
-
${(props) => props
|
714
|
+
${(props) => props.$isFocused && css`
|
371
715
|
box-shadow: ${props.theme.colors.primary600} 0px 0px 0px 3px;
|
372
716
|
`}
|
373
717
|
|
@@ -419,7 +763,7 @@ const Image = ({ attributes, children, element }) => {
|
|
419
763
|
background: "neutral100",
|
420
764
|
contentEditable: false,
|
421
765
|
justifyContent: "center",
|
422
|
-
isFocused: editorIsFocused && imageIsSelected,
|
766
|
+
$isFocused: editorIsFocused && imageIsSelected,
|
423
767
|
hasRadius: true,
|
424
768
|
children: /* @__PURE__ */ jsx("img", { src: url, alt: alternativeText, width, height })
|
425
769
|
}
|
@@ -430,8 +774,7 @@ const ImageDialog = () => {
|
|
430
774
|
const [isOpen, setIsOpen] = React.useState(true);
|
431
775
|
const { editor } = useBlocksEditorContext("ImageDialog");
|
432
776
|
const components = useStrapiApp("ImageDialog", (state) => state.components);
|
433
|
-
if (!components || !isOpen)
|
434
|
-
return null;
|
777
|
+
if (!components || !isOpen) return null;
|
435
778
|
const MediaLibraryDialog = components["media-library"];
|
436
779
|
const insertImages = (images) => {
|
437
780
|
Transforms.unwrapNodes(editor, {
|
@@ -440,14 +783,12 @@ const ImageDialog = () => {
|
|
440
783
|
});
|
441
784
|
const nodeEntryBeingReplaced = Editor$1.above(editor, {
|
442
785
|
match(node) {
|
443
|
-
if (Editor$1.isEditor(node))
|
444
|
-
return false;
|
786
|
+
if (Editor$1.isEditor(node)) return false;
|
445
787
|
const isInlineNode = ["text", "link"].includes(node.type);
|
446
788
|
return !isInlineNode;
|
447
789
|
}
|
448
790
|
});
|
449
|
-
if (!nodeEntryBeingReplaced)
|
450
|
-
return;
|
791
|
+
if (!nodeEntryBeingReplaced) return;
|
451
792
|
const [, pathToInsert] = nodeEntryBeingReplaced;
|
452
793
|
Transforms.removeNodes(editor);
|
453
794
|
const nodesToInsert = images.map((image) => {
|
@@ -579,7 +920,7 @@ const StyledBaseLink = styled(BaseLink)`
|
|
579
920
|
text-decoration: none;
|
580
921
|
`;
|
581
922
|
const RemoveButton = styled(Button)`
|
582
|
-
visibility: ${(props) => props
|
923
|
+
visibility: ${(props) => props.$visible ? "visible" : "hidden"};
|
583
924
|
`;
|
584
925
|
const LinkContent = React.forwardRef(
|
585
926
|
({ link, children, attributes }, forwardedRef) => {
|
@@ -589,18 +930,12 @@ const LinkContent = React.forwardRef(
|
|
589
930
|
const [popoverOpen, setPopoverOpen] = React.useState(
|
590
931
|
editor.lastInsertedLinkPath ? Path.equals(path, editor.lastInsertedLinkPath) : false
|
591
932
|
);
|
592
|
-
const linkRef = React.useRef(null);
|
593
933
|
const elementText = link.children.map((child) => child.text).join("");
|
594
934
|
const [linkText, setLinkText] = React.useState(elementText);
|
595
935
|
const [linkUrl, setLinkUrl] = React.useState(link.url);
|
596
936
|
const linkInputRef = React.useRef(null);
|
597
|
-
const
|
937
|
+
const isLastInsertedLink = editor.lastInsertedLinkPath ? !Path.equals(path, editor.lastInsertedLinkPath) : true;
|
598
938
|
const [isSaveDisabled, setIsSaveDisabled] = React.useState(false);
|
599
|
-
const handleOpenEditPopover = (e) => {
|
600
|
-
e.preventDefault();
|
601
|
-
setPopoverOpen(true);
|
602
|
-
setShowRemoveButton(true);
|
603
|
-
};
|
604
939
|
const onLinkChange = (e) => {
|
605
940
|
setIsSaveDisabled(false);
|
606
941
|
setLinkUrl(e.target.value);
|
@@ -621,40 +956,39 @@ const LinkContent = React.forwardRef(
|
|
621
956
|
editLink(editor, { url: linkUrl, text: linkText });
|
622
957
|
setPopoverOpen(false);
|
623
958
|
editor.lastInsertedLinkPath = null;
|
959
|
+
ReactEditor.focus(editor);
|
624
960
|
};
|
625
|
-
const
|
626
|
-
setPopoverOpen(false);
|
961
|
+
const handleClose = () => {
|
627
962
|
if (link.url === "") {
|
628
963
|
removeLink(editor);
|
629
964
|
}
|
965
|
+
setPopoverOpen(false);
|
630
966
|
ReactEditor.focus(editor);
|
631
967
|
};
|
632
|
-
const inputNotDirty = !linkText || !linkUrl || link.url && link.url === linkUrl && elementText && elementText === linkText;
|
633
|
-
const composedRefs = useComposedRefs(linkRef, forwardedRef);
|
634
968
|
React.useEffect(() => {
|
635
|
-
if (popoverOpen)
|
636
|
-
linkInputRef.current?.focus();
|
969
|
+
if (popoverOpen) linkInputRef.current?.focus();
|
637
970
|
}, [popoverOpen]);
|
638
|
-
|
639
|
-
|
971
|
+
const inputNotDirty = !linkText || !linkUrl || link.url && link.url === linkUrl && elementText && elementText === linkText;
|
972
|
+
return /* @__PURE__ */ jsxs(Popover.Root, { open: popoverOpen, children: [
|
973
|
+
/* @__PURE__ */ jsx(Popover.Trigger, { children: /* @__PURE__ */ jsx(
|
640
974
|
StyledBaseLink,
|
641
975
|
{
|
642
976
|
...attributes,
|
643
|
-
ref:
|
977
|
+
ref: forwardedRef,
|
644
978
|
href: link.url,
|
645
|
-
onClick:
|
979
|
+
onClick: () => setPopoverOpen(true),
|
646
980
|
color: "primary600",
|
647
981
|
children
|
648
982
|
}
|
649
|
-
),
|
650
|
-
|
651
|
-
/* @__PURE__ */ jsx(Field, { width: "368px", children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, alignItems: "stretch", children: [
|
652
|
-
/* @__PURE__ */ jsx(
|
983
|
+
) }),
|
984
|
+
/* @__PURE__ */ jsx(Popover.Content, { onPointerDownOutside: handleClose, children: /* @__PURE__ */ jsxs(Flex, { padding: 4, direction: "column", gap: 4, children: [
|
985
|
+
/* @__PURE__ */ jsx(Field.Root, { width: "368px", children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, alignItems: "stretch", children: [
|
986
|
+
/* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
|
653
987
|
id: "components.Blocks.popover.text",
|
654
988
|
defaultMessage: "Text"
|
655
989
|
}) }),
|
656
990
|
/* @__PURE__ */ jsx(
|
657
|
-
|
991
|
+
Field.Input,
|
658
992
|
{
|
659
993
|
name: "text",
|
660
994
|
placeholder: formatMessage({
|
@@ -668,13 +1002,13 @@ const LinkContent = React.forwardRef(
|
|
668
1002
|
}
|
669
1003
|
)
|
670
1004
|
] }) }),
|
671
|
-
/* @__PURE__ */ jsx(Field, { width: "368px", children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, alignItems: "stretch", children: [
|
672
|
-
/* @__PURE__ */ jsx(
|
1005
|
+
/* @__PURE__ */ jsx(Field.Root, { width: "368px", children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, alignItems: "stretch", children: [
|
1006
|
+
/* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
|
673
1007
|
id: "components.Blocks.popover.link",
|
674
1008
|
defaultMessage: "Link"
|
675
1009
|
}) }),
|
676
1010
|
/* @__PURE__ */ jsx(
|
677
|
-
|
1011
|
+
Field.Input,
|
678
1012
|
{
|
679
1013
|
ref: linkInputRef,
|
680
1014
|
name: "url",
|
@@ -693,7 +1027,7 @@ const LinkContent = React.forwardRef(
|
|
693
1027
|
{
|
694
1028
|
variant: "danger-light",
|
695
1029
|
onClick: () => removeLink(editor),
|
696
|
-
visible:
|
1030
|
+
$visible: isLastInsertedLink,
|
697
1031
|
children: formatMessage({
|
698
1032
|
id: "components.Blocks.popover.remove",
|
699
1033
|
defaultMessage: "Remove"
|
@@ -701,12 +1035,12 @@ const LinkContent = React.forwardRef(
|
|
701
1035
|
}
|
702
1036
|
),
|
703
1037
|
/* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
704
|
-
/* @__PURE__ */ jsx(Button, { variant: "tertiary", onClick:
|
705
|
-
id: "
|
1038
|
+
/* @__PURE__ */ jsx(Button, { variant: "tertiary", onClick: handleClose, children: formatMessage({
|
1039
|
+
id: "global.cancel",
|
706
1040
|
defaultMessage: "Cancel"
|
707
1041
|
}) }),
|
708
|
-
/* @__PURE__ */ jsx(Button, {
|
709
|
-
id: "
|
1042
|
+
/* @__PURE__ */ jsx(Button, { disabled: Boolean(inputNotDirty) || isSaveDisabled, onClick: handleSave, children: formatMessage({
|
1043
|
+
id: "global.save",
|
710
1044
|
defaultMessage: "Save"
|
711
1045
|
}) })
|
712
1046
|
] })
|
@@ -748,11 +1082,11 @@ const listStyle = css`
|
|
748
1082
|
}
|
749
1083
|
`;
|
750
1084
|
const Orderedlist = styled.ol`
|
751
|
-
list-style-type: ${(props) => props
|
1085
|
+
list-style-type: ${(props) => props.$listStyleType};
|
752
1086
|
${listStyle}
|
753
1087
|
`;
|
754
1088
|
const Unorderedlist = styled.ul`
|
755
|
-
list-style-type: ${(props) => props
|
1089
|
+
list-style-type: ${(props) => props.$listStyleType};
|
756
1090
|
${listStyle}
|
757
1091
|
`;
|
758
1092
|
const orderedStyles = ["decimal", "lower-alpha", "upper-roman"];
|
@@ -765,9 +1099,9 @@ const List = ({ attributes, children, element }) => {
|
|
765
1099
|
const nextIndex = (element.indentLevel || 0) % listStyles.length;
|
766
1100
|
const listStyleType = listStyles[nextIndex];
|
767
1101
|
if (element.format === "ordered") {
|
768
|
-
return /* @__PURE__ */ jsx(Orderedlist, { listStyleType, ...attributes, children });
|
1102
|
+
return /* @__PURE__ */ jsx(Orderedlist, { $listStyleType: listStyleType, ...attributes, children });
|
769
1103
|
}
|
770
|
-
return /* @__PURE__ */ jsx(Unorderedlist, { listStyleType, ...attributes, children });
|
1104
|
+
return /* @__PURE__ */ jsx(Unorderedlist, { $listStyleType: listStyleType, ...attributes, children });
|
771
1105
|
};
|
772
1106
|
const replaceListWithEmptyBlock = (editor, currentListPath) => {
|
773
1107
|
Transforms.removeNodes(editor, { at: currentListPath });
|
@@ -787,8 +1121,7 @@ const isText$1 = (node) => {
|
|
787
1121
|
return Node.isNode(node) && !Editor$1.isEditor(node) && node.type === "text";
|
788
1122
|
};
|
789
1123
|
const handleBackspaceKeyOnList = (editor, event) => {
|
790
|
-
if (!editor.selection)
|
791
|
-
return;
|
1124
|
+
if (!editor.selection) return;
|
792
1125
|
const [currentListItem, currentListItemPath] = Editor$1.parent(editor, editor.selection.anchor);
|
793
1126
|
const [currentList, currentListPath] = Editor$1.parent(editor, currentListItemPath);
|
794
1127
|
const isListEmpty = currentList.children.length === 1 && isText$1(currentListItem.children[0]) && currentListItem.children[0].text === "";
|
@@ -897,8 +1230,7 @@ const handleEnterKeyOnList = (editor) => {
|
|
897
1230
|
};
|
898
1231
|
const handleConvertToList = (editor, format) => {
|
899
1232
|
const convertedPath = baseHandleConvert(editor, { type: "list-item" });
|
900
|
-
if (!convertedPath)
|
901
|
-
return;
|
1233
|
+
if (!convertedPath) return;
|
902
1234
|
Transforms.wrapNodes(editor, { type: "list", format, children: [] }, { at: convertedPath });
|
903
1235
|
};
|
904
1236
|
const handleTabOnList = (editor) => {
|
@@ -910,8 +1242,7 @@ const handleTabOnList = (editor) => {
|
|
910
1242
|
}
|
911
1243
|
const [currentListItem, currentListItemPath] = currentListItemEntry;
|
912
1244
|
const [currentList] = Editor$1.parent(editor, currentListItemPath);
|
913
|
-
if (currentListItem === currentList.children[0])
|
914
|
-
return;
|
1245
|
+
if (currentListItem === currentList.children[0]) return;
|
915
1246
|
const currentListItemIndex = currentList.children.findIndex((item) => item === currentListItem);
|
916
1247
|
const previousNode = currentList.children[currentListItemIndex - 1];
|
917
1248
|
if (previousNode.type === "list") {
|
@@ -964,7 +1295,7 @@ const listBlocks = {
|
|
964
1295
|
snippets: ["-", "*", "+"]
|
965
1296
|
},
|
966
1297
|
"list-item": {
|
967
|
-
renderElement: (props) => /* @__PURE__ */ jsx(Typography, {
|
1298
|
+
renderElement: (props) => /* @__PURE__ */ jsx(Typography, { tag: "li", ...props.attributes, children: props.children }),
|
968
1299
|
// No handleConvert, list items are created when converting to the parent list
|
969
1300
|
matchNode: (node) => node.type === "list-item",
|
970
1301
|
isInBlocksSelector: false,
|
@@ -973,7 +1304,7 @@ const listBlocks = {
|
|
973
1304
|
};
|
974
1305
|
const paragraphBlocks = {
|
975
1306
|
paragraph: {
|
976
|
-
renderElement: (props) => /* @__PURE__ */ jsx(Typography, {
|
1307
|
+
renderElement: (props) => /* @__PURE__ */ jsx(Typography, { tag: "p", variant: "omega", ...props.attributes, children: props.children }),
|
977
1308
|
icon: Paragraph,
|
978
1309
|
label: {
|
979
1310
|
id: "components.Blocks.blocks.text",
|
@@ -1047,13 +1378,13 @@ const quoteBlocks = {
|
|
1047
1378
|
handleEnterKey(editor) {
|
1048
1379
|
pressEnterTwiceToExit(editor);
|
1049
1380
|
},
|
1050
|
-
snippets: [">"]
|
1051
|
-
dragHandleTopMargin: "6px"
|
1381
|
+
snippets: [">"]
|
1052
1382
|
}
|
1053
1383
|
};
|
1054
1384
|
const ToolbarWrapper = styled(Flex)`
|
1055
1385
|
&[aria-disabled='true'] {
|
1056
1386
|
cursor: not-allowed;
|
1387
|
+
background: ${({ theme }) => theme.colors.neutral150};
|
1057
1388
|
}
|
1058
1389
|
`;
|
1059
1390
|
const Separator = styled(Toolbar.Separator)`
|
@@ -1064,7 +1395,7 @@ const Separator = styled(Toolbar.Separator)`
|
|
1064
1395
|
const FlexButton = styled(Flex)`
|
1065
1396
|
// Inherit the not-allowed cursor from ToolbarWrapper when disabled
|
1066
1397
|
&[aria-disabled] {
|
1067
|
-
cursor:
|
1398
|
+
cursor: not-allowed;
|
1068
1399
|
}
|
1069
1400
|
|
1070
1401
|
&[aria-disabled='false'] {
|
@@ -1139,14 +1470,14 @@ const ToolbarButton = ({
|
|
1139
1470
|
children: /* @__PURE__ */ jsx(
|
1140
1471
|
FlexButton,
|
1141
1472
|
{
|
1142
|
-
|
1473
|
+
tag: "button",
|
1143
1474
|
background: isActive ? "primary100" : "",
|
1144
1475
|
alignItems: "center",
|
1145
1476
|
justifyContent: "center",
|
1146
1477
|
width: 7,
|
1147
1478
|
height: 7,
|
1148
1479
|
hasRadius: true,
|
1149
|
-
children: /* @__PURE__ */ jsx(Icon, {
|
1480
|
+
children: /* @__PURE__ */ jsx(Icon, { fill: disabled ? "neutral300" : enabledColor })
|
1150
1481
|
}
|
1151
1482
|
)
|
1152
1483
|
}
|
@@ -1278,8 +1609,7 @@ const isListNode = (node) => {
|
|
1278
1609
|
const ListButton = ({ block, format }) => {
|
1279
1610
|
const { editor, disabled, blocks } = useBlocksEditorContext("ListButton");
|
1280
1611
|
const isListActive = () => {
|
1281
|
-
if (!editor.selection)
|
1282
|
-
return false;
|
1612
|
+
if (!editor.selection) return false;
|
1283
1613
|
const currentListEntry = Editor$1.above(editor, {
|
1284
1614
|
match: (node) => !Editor$1.isEditor(node) && node.type === "list",
|
1285
1615
|
at: editor.selection.anchor
|
@@ -1291,6 +1621,26 @@ const ListButton = ({ block, format }) => {
|
|
1291
1621
|
}
|
1292
1622
|
return false;
|
1293
1623
|
};
|
1624
|
+
const isListDisabled = () => {
|
1625
|
+
if (disabled) {
|
1626
|
+
return true;
|
1627
|
+
}
|
1628
|
+
if (!editor.selection) {
|
1629
|
+
return false;
|
1630
|
+
}
|
1631
|
+
const anchorNodeEntry = Editor$1.above(editor, {
|
1632
|
+
at: editor.selection.anchor,
|
1633
|
+
match: (node) => !Editor$1.isEditor(node) && node.type !== "text"
|
1634
|
+
});
|
1635
|
+
const focusNodeEntry = Editor$1.above(editor, {
|
1636
|
+
at: editor.selection.focus,
|
1637
|
+
match: (node) => !Editor$1.isEditor(node) && node.type !== "text"
|
1638
|
+
});
|
1639
|
+
if (!anchorNodeEntry || !focusNodeEntry) {
|
1640
|
+
return false;
|
1641
|
+
}
|
1642
|
+
return anchorNodeEntry[0] !== focusNodeEntry[0];
|
1643
|
+
};
|
1294
1644
|
const toggleList = (format2) => {
|
1295
1645
|
let currentListEntry;
|
1296
1646
|
if (editor.selection) {
|
@@ -1324,7 +1674,7 @@ const ListButton = ({ block, format }) => {
|
|
1324
1674
|
name: format,
|
1325
1675
|
label: block.label,
|
1326
1676
|
isActive: isListActive(),
|
1327
|
-
disabled,
|
1677
|
+
disabled: isListDisabled(),
|
1328
1678
|
handleClick: () => toggleList(format)
|
1329
1679
|
}
|
1330
1680
|
);
|
@@ -1333,8 +1683,7 @@ const LinkButton = ({ disabled }) => {
|
|
1333
1683
|
const { editor } = useBlocksEditorContext("LinkButton");
|
1334
1684
|
const isLinkActive = () => {
|
1335
1685
|
const { selection } = editor;
|
1336
|
-
if (!selection)
|
1337
|
-
return false;
|
1686
|
+
if (!selection) return false;
|
1338
1687
|
const [match] = Array.from(
|
1339
1688
|
Editor$1.nodes(editor, {
|
1340
1689
|
at: Editor$1.unhangRange(editor, selection),
|
@@ -1398,7 +1747,7 @@ const BlocksToolbar = () => {
|
|
1398
1747
|
return false;
|
1399
1748
|
};
|
1400
1749
|
const isButtonDisabled = checkButtonDisabled();
|
1401
|
-
return /* @__PURE__ */ jsx(Toolbar.Root, { "aria-disabled": disabled, asChild: true, children: /* @__PURE__ */ jsxs(ToolbarWrapper, { gap: 2, padding: 2, children: [
|
1750
|
+
return /* @__PURE__ */ jsx(Toolbar.Root, { "aria-disabled": disabled, asChild: true, children: /* @__PURE__ */ jsxs(ToolbarWrapper, { gap: 2, padding: 2, width: "100%", children: [
|
1402
1751
|
/* @__PURE__ */ jsx(BlocksDropdown, {}),
|
1403
1752
|
/* @__PURE__ */ jsx(Separator, {}),
|
1404
1753
|
/* @__PURE__ */ jsx(Toolbar.ToggleGroup, { type: "multiple", asChild: true, children: /* @__PURE__ */ jsxs(Flex, { gap: 1, children: [
|
@@ -1460,7 +1809,7 @@ const DragItem = styled(Flex)`
|
|
1460
1809
|
|
1461
1810
|
// Set the visibility of drag button
|
1462
1811
|
[role='button'] {
|
1463
|
-
visibility: ${(props) => props
|
1812
|
+
visibility: ${(props) => props.$dragVisibility};
|
1464
1813
|
opacity: inherit;
|
1465
1814
|
}
|
1466
1815
|
&[aria-disabled='true'] {
|
@@ -1468,33 +1817,36 @@ const DragItem = styled(Flex)`
|
|
1468
1817
|
}
|
1469
1818
|
`;
|
1470
1819
|
const DragIconButton = styled(IconButton)`
|
1820
|
+
user-select: none;
|
1471
1821
|
display: flex;
|
1472
1822
|
align-items: center;
|
1473
1823
|
justify-content: center;
|
1824
|
+
border: none;
|
1474
1825
|
border-radius: ${({ theme }) => theme.borderRadius};
|
1475
|
-
|
1476
|
-
|
1826
|
+
padding-left: ${({ theme }) => theme.spaces[0]};
|
1827
|
+
padding-right: ${({ theme }) => theme.spaces[0]};
|
1828
|
+
padding-top: ${({ theme }) => theme.spaces[1]};
|
1829
|
+
padding-bottom: ${({ theme }) => theme.spaces[1]};
|
1477
1830
|
visibility: hidden;
|
1478
1831
|
cursor: grab;
|
1479
1832
|
opacity: inherit;
|
1480
|
-
margin-top: ${(props) => props
|
1833
|
+
margin-top: ${(props) => props.$dragHandleTopMargin ?? 0};
|
1481
1834
|
|
1482
1835
|
&:hover {
|
1483
|
-
background: ${({ theme }) => theme.colors.
|
1836
|
+
background: ${({ theme }) => theme.colors.neutral100};
|
1484
1837
|
}
|
1485
1838
|
&:active {
|
1486
1839
|
cursor: grabbing;
|
1840
|
+
background: ${({ theme }) => theme.colors.neutral150};
|
1487
1841
|
}
|
1488
1842
|
&[aria-disabled='true'] {
|
1489
|
-
|
1490
|
-
background: transparent;
|
1843
|
+
visibility: hidden;
|
1491
1844
|
}
|
1492
1845
|
svg {
|
1493
|
-
|
1494
|
-
width: ${({ theme }) => theme.spaces[3]};
|
1846
|
+
min-width: ${({ theme }) => theme.spaces[3]};
|
1495
1847
|
|
1496
1848
|
path {
|
1497
|
-
fill: ${({ theme }) => theme.colors.
|
1849
|
+
fill: ${({ theme }) => theme.colors.neutral500};
|
1498
1850
|
}
|
1499
1851
|
}
|
1500
1852
|
`;
|
@@ -1539,8 +1891,7 @@ const DragAndDropElement = ({
|
|
1539
1891
|
displayedValue: children
|
1540
1892
|
},
|
1541
1893
|
onDropItem(currentIndex, newIndex) {
|
1542
|
-
if (newIndex)
|
1543
|
-
handleMoveBlock(newIndex, currentIndex);
|
1894
|
+
if (newIndex) handleMoveBlock(newIndex, currentIndex);
|
1544
1895
|
}
|
1545
1896
|
});
|
1546
1897
|
const composedBoxRefs = useComposedRefs(blockRef, dropRef);
|
@@ -1552,7 +1903,7 @@ const DragAndDropElement = ({
|
|
1552
1903
|
React.useEffect(() => {
|
1553
1904
|
setDragVisibility("hidden");
|
1554
1905
|
}, [editor.selection]);
|
1555
|
-
return /* @__PURE__ */ jsxs(Wrapper$1, { ref:
|
1906
|
+
return /* @__PURE__ */ jsxs(Wrapper$1, { ref: composedBoxRefs, isOverDropTarget, children: [
|
1556
1907
|
isOverDropTarget && /* @__PURE__ */ jsx(
|
1557
1908
|
DropPlaceholder,
|
1558
1909
|
{
|
@@ -1590,15 +1941,17 @@ const DragAndDropElement = ({
|
|
1590
1941
|
onSelect: () => setDragVisibility("visible"),
|
1591
1942
|
onMouseLeave: () => setDragVisibility("hidden"),
|
1592
1943
|
"aria-disabled": disabled,
|
1593
|
-
dragVisibility,
|
1944
|
+
$dragVisibility: dragVisibility,
|
1594
1945
|
children: [
|
1595
1946
|
/* @__PURE__ */ jsx(
|
1596
1947
|
DragIconButton,
|
1597
1948
|
{
|
1598
|
-
|
1949
|
+
tag: "div",
|
1950
|
+
contentEditable: false,
|
1599
1951
|
role: "button",
|
1600
1952
|
tabIndex: 0,
|
1601
|
-
|
1953
|
+
withTooltip: false,
|
1954
|
+
label: formatMessage({
|
1602
1955
|
id: getTranslation("components.DragHandle-label"),
|
1603
1956
|
defaultMessage: "Drag"
|
1604
1957
|
}),
|
@@ -1606,8 +1959,8 @@ const DragAndDropElement = ({
|
|
1606
1959
|
"aria-disabled": disabled,
|
1607
1960
|
disabled,
|
1608
1961
|
draggable: true,
|
1609
|
-
dragHandleTopMargin,
|
1610
|
-
children: /* @__PURE__ */ jsx(Drag, { color: "
|
1962
|
+
$dragHandleTopMargin: dragHandleTopMargin,
|
1963
|
+
children: /* @__PURE__ */ jsx(Drag, { color: "primary500" })
|
1611
1964
|
}
|
1612
1965
|
),
|
1613
1966
|
children
|
@@ -1618,17 +1971,18 @@ const DragAndDropElement = ({
|
|
1618
1971
|
};
|
1619
1972
|
const CloneDragItem = ({ children, dragHandleTopMargin }) => {
|
1620
1973
|
const { formatMessage } = useIntl();
|
1621
|
-
return /* @__PURE__ */ jsxs(DragItem, { gap: 2, paddingLeft: 2, alignItems: "start", dragVisibility: "visible", children: [
|
1974
|
+
return /* @__PURE__ */ jsxs(DragItem, { gap: 2, paddingLeft: 2, alignItems: "start", $dragVisibility: "visible", children: [
|
1622
1975
|
/* @__PURE__ */ jsx(
|
1623
1976
|
DragIconButton,
|
1624
1977
|
{
|
1625
|
-
|
1978
|
+
tag: "div",
|
1626
1979
|
role: "button",
|
1627
|
-
|
1980
|
+
withTooltip: false,
|
1981
|
+
label: formatMessage({
|
1628
1982
|
id: getTranslation("components.DragHandle-label"),
|
1629
1983
|
defaultMessage: "Drag"
|
1630
1984
|
}),
|
1631
|
-
dragHandleTopMargin,
|
1985
|
+
$dragHandleTopMargin: dragHandleTopMargin,
|
1632
1986
|
children: /* @__PURE__ */ jsx(Drag, { color: "neutral600" })
|
1633
1987
|
}
|
1634
1988
|
),
|
@@ -1643,7 +1997,7 @@ const baseRenderLeaf = (props, modifiers2) => {
|
|
1643
1997
|
}
|
1644
1998
|
return currentChildren;
|
1645
1999
|
}, props.children);
|
1646
|
-
return /* @__PURE__ */ jsx("span", { ...props.attributes, children: wrappedChildren });
|
2000
|
+
return /* @__PURE__ */ jsx("span", { ...props.attributes, className: props.leaf.className, children: wrappedChildren });
|
1647
2001
|
};
|
1648
2002
|
const baseRenderElement = ({
|
1649
2003
|
props,
|
@@ -1681,8 +2035,7 @@ const BlocksContent = ({ placeholder, ariaLabelId }) => {
|
|
1681
2035
|
[modifiers2]
|
1682
2036
|
);
|
1683
2037
|
const handleMoveBlocks = (editor2, event) => {
|
1684
|
-
if (!editor2.selection)
|
1685
|
-
return;
|
2038
|
+
if (!editor2.selection) return;
|
1686
2039
|
const start = Range.start(editor2.selection);
|
1687
2040
|
const currentIndex = [start.path[0]];
|
1688
2041
|
let newIndexPosition = 0;
|
@@ -1819,8 +2172,7 @@ const BlocksContent = ({ placeholder, ariaLabelId }) => {
|
|
1819
2172
|
}
|
1820
2173
|
};
|
1821
2174
|
const handleScrollSelectionIntoView = () => {
|
1822
|
-
if (!editor.selection)
|
1823
|
-
return;
|
2175
|
+
if (!editor.selection) return;
|
1824
2176
|
const domRange = ReactEditor.toDOMRange(editor, editor.selection);
|
1825
2177
|
const domRect = domRange.getBoundingClientRect();
|
1826
2178
|
const blocksInput = blocksRef.current;
|
@@ -1847,7 +2199,7 @@ const BlocksContent = ({ placeholder, ariaLabelId }) => {
|
|
1847
2199
|
background: "neutral0",
|
1848
2200
|
color: "neutral800",
|
1849
2201
|
lineHeight: 6,
|
1850
|
-
paddingRight:
|
2202
|
+
paddingRight: 7,
|
1851
2203
|
paddingTop: 6,
|
1852
2204
|
paddingBottom: 3,
|
1853
2205
|
children: [
|
@@ -1858,6 +2210,7 @@ const BlocksContent = ({ placeholder, ariaLabelId }) => {
|
|
1858
2210
|
readOnly: disabled,
|
1859
2211
|
placeholder,
|
1860
2212
|
isExpandedMode,
|
2213
|
+
decorate: decorateCode,
|
1861
2214
|
renderElement,
|
1862
2215
|
renderLeaf,
|
1863
2216
|
onKeyDown: handleKeyDown,
|
@@ -1930,7 +2283,7 @@ const EditorLayout$1 = ({
|
|
1930
2283
|
/* @__PURE__ */ jsx(
|
1931
2284
|
CollapseIconButton,
|
1932
2285
|
{
|
1933
|
-
|
2286
|
+
label: formatMessage({
|
1934
2287
|
id: getTranslation("components.Blocks.collapse"),
|
1935
2288
|
defaultMessage: "Collapse"
|
1936
2289
|
}),
|
@@ -1950,8 +2303,8 @@ const EditorLayout$1 = ({
|
|
1950
2303
|
direction: "column",
|
1951
2304
|
alignItems: "flex-start",
|
1952
2305
|
height: "512px",
|
1953
|
-
disabled,
|
1954
|
-
hasError: Boolean(error),
|
2306
|
+
$disabled: disabled,
|
2307
|
+
$hasError: Boolean(error),
|
1955
2308
|
style: { overflow: "hidden" },
|
1956
2309
|
"aria-describedby": ariaDescriptionId,
|
1957
2310
|
position: "relative",
|
@@ -1959,6 +2312,29 @@ const EditorLayout$1 = ({
|
|
1959
2312
|
}
|
1960
2313
|
);
|
1961
2314
|
};
|
2315
|
+
const InputWrapper = styled(Flex)`
|
2316
|
+
border: 1px solid
|
2317
|
+
${({ theme, $hasError }) => $hasError ? theme.colors.danger600 : theme.colors.neutral200};
|
2318
|
+
border-radius: ${({ theme }) => theme.borderRadius};
|
2319
|
+
background: ${({ theme }) => theme.colors.neutral0};
|
2320
|
+
|
2321
|
+
${({ theme, $hasError = false }) => css`
|
2322
|
+
outline: none;
|
2323
|
+
box-shadow: 0;
|
2324
|
+
transition-property: border-color, box-shadow, fill;
|
2325
|
+
transition-duration: 0.2s;
|
2326
|
+
|
2327
|
+
&:focus-within {
|
2328
|
+
border: 1px solid ${$hasError ? theme.colors.danger600 : theme.colors.primary600};
|
2329
|
+
box-shadow: ${$hasError ? theme.colors.danger600 : theme.colors.primary600} 0px 0px 0px 2px;
|
2330
|
+
}
|
2331
|
+
`}
|
2332
|
+
|
2333
|
+
${({ theme, $disabled }) => $disabled ? css`
|
2334
|
+
color: ${theme.colors.neutral600};
|
2335
|
+
background: ${theme.colors.neutral150};
|
2336
|
+
` : void 0}
|
2337
|
+
`;
|
1962
2338
|
const stylesToInherit = css`
|
1963
2339
|
font-size: inherit;
|
1964
2340
|
color: inherit;
|
@@ -1971,10 +2347,14 @@ const ItalicText = styled(Typography)`
|
|
1971
2347
|
font-style: italic;
|
1972
2348
|
${stylesToInherit}
|
1973
2349
|
`;
|
1974
|
-
const UnderlineText = styled(Typography).attrs({
|
2350
|
+
const UnderlineText = styled(Typography).attrs({
|
2351
|
+
textDecoration: "underline"
|
2352
|
+
})`
|
1975
2353
|
${stylesToInherit}
|
1976
2354
|
`;
|
1977
|
-
const StrikeThroughText = styled(Typography).attrs({
|
2355
|
+
const StrikeThroughText = styled(Typography).attrs({
|
2356
|
+
textDecoration: "line-through"
|
2357
|
+
})`
|
1978
2358
|
${stylesToInherit}
|
1979
2359
|
`;
|
1980
2360
|
const InlineCode = styled.code`
|
@@ -1987,8 +2367,7 @@ const InlineCode = styled.code`
|
|
1987
2367
|
`;
|
1988
2368
|
const baseCheckIsActive = (editor, name2) => {
|
1989
2369
|
const marks = Editor$1.marks(editor);
|
1990
|
-
if (!marks)
|
1991
|
-
return false;
|
2370
|
+
if (!marks) return false;
|
1992
2371
|
return Boolean(marks[name2]);
|
1993
2372
|
};
|
1994
2373
|
const baseHandleToggle = (editor, name2) => {
|
@@ -2154,6 +2533,7 @@ const ExpandIconButton = styled(IconButton)`
|
|
2154
2533
|
position: absolute;
|
2155
2534
|
bottom: 1.2rem;
|
2156
2535
|
right: 1.2rem;
|
2536
|
+
box-shadow: ${({ theme }) => theme.shadows.filterShadow};
|
2157
2537
|
`;
|
2158
2538
|
function useResetKey(value) {
|
2159
2539
|
const slateUpdatesCount = React.useRef(0);
|
@@ -2242,7 +2622,7 @@ const BlocksEditor = React.forwardRef(
|
|
2242
2622
|
!isExpandedMode && /* @__PURE__ */ jsx(
|
2243
2623
|
ExpandIconButton,
|
2244
2624
|
{
|
2245
|
-
|
2625
|
+
label: formatMessage({
|
2246
2626
|
id: getTranslation("components.Blocks.expand"),
|
2247
2627
|
defaultMessage: "Expand"
|
2248
2628
|
}),
|
@@ -2265,8 +2645,8 @@ const BlocksInput = React.forwardRef(
|
|
2265
2645
|
({ label, name: name2, required = false, hint, labelAction, ...editorProps }, forwardedRef) => {
|
2266
2646
|
const id = React.useId();
|
2267
2647
|
const field = useField(name2);
|
2268
|
-
return /* @__PURE__ */ jsx(Field, { id, name: name2, hint, error: field.error, required, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
|
2269
|
-
/* @__PURE__ */ jsx(
|
2648
|
+
return /* @__PURE__ */ jsx(Field.Root, { id, name: name2, hint, error: field.error, required, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
|
2649
|
+
/* @__PURE__ */ jsx(Field.Label, { action: labelAction, children: label }),
|
2270
2650
|
/* @__PURE__ */ jsx(
|
2271
2651
|
BlocksEditor,
|
2272
2652
|
{
|
@@ -2279,11 +2659,12 @@ const BlocksInput = React.forwardRef(
|
|
2279
2659
|
...editorProps
|
2280
2660
|
}
|
2281
2661
|
),
|
2282
|
-
/* @__PURE__ */ jsx(
|
2283
|
-
/* @__PURE__ */ jsx(
|
2662
|
+
/* @__PURE__ */ jsx(Field.Hint, {}),
|
2663
|
+
/* @__PURE__ */ jsx(Field.Error, {})
|
2284
2664
|
] }) });
|
2285
2665
|
}
|
2286
2666
|
);
|
2667
|
+
const MemoizedBlocksInput = React.memo(BlocksInput);
|
2287
2668
|
const createDefaultForm = (contentType, components = {}) => {
|
2288
2669
|
const traverseSchema = (attributes) => {
|
2289
2670
|
return Object.entries(attributes).reduce((acc, [key, attribute]) => {
|
@@ -2307,47 +2688,44 @@ const createDefaultForm = (contentType, components = {}) => {
|
|
2307
2688
|
const Initializer = ({ disabled, name: name2, onClick }) => {
|
2308
2689
|
const { formatMessage } = useIntl();
|
2309
2690
|
const field = useField(name2);
|
2310
|
-
return /* @__PURE__ */
|
2311
|
-
|
2312
|
-
|
2313
|
-
|
2314
|
-
|
2315
|
-
|
2316
|
-
|
2317
|
-
|
2318
|
-
|
2319
|
-
|
2320
|
-
|
2321
|
-
|
2322
|
-
|
2323
|
-
|
2324
|
-
|
2325
|
-
|
2326
|
-
|
2327
|
-
|
2328
|
-
|
2329
|
-
|
2330
|
-
|
2331
|
-
|
2332
|
-
|
2333
|
-
|
2691
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
2692
|
+
Box,
|
2693
|
+
{
|
2694
|
+
tag: "button",
|
2695
|
+
background: disabled ? "neutral150" : "neutral100",
|
2696
|
+
borderColor: field.error ? "danger600" : "neutral200",
|
2697
|
+
hasRadius: true,
|
2698
|
+
disabled,
|
2699
|
+
onClick,
|
2700
|
+
paddingTop: 9,
|
2701
|
+
paddingBottom: 9,
|
2702
|
+
type: "button",
|
2703
|
+
style: { cursor: disabled ? "not-allowed" : "pointer" },
|
2704
|
+
children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, children: [
|
2705
|
+
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", color: disabled ? "neutral500" : "primary600", children: /* @__PURE__ */ jsx(PlusCircle, { width: "3.2rem", height: "3.2rem" }) }),
|
2706
|
+
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(
|
2707
|
+
Typography,
|
2708
|
+
{
|
2709
|
+
textColor: disabled ? "neutral600" : "primary600",
|
2710
|
+
variant: "pi",
|
2711
|
+
fontWeight: "bold",
|
2712
|
+
children: formatMessage({
|
2713
|
+
id: getTranslation("components.empty-repeatable"),
|
2714
|
+
defaultMessage: "No entry yet. Click to add one."
|
2715
|
+
})
|
2716
|
+
}
|
2717
|
+
) })
|
2718
|
+
] })
|
2719
|
+
}
|
2720
|
+
) });
|
2334
2721
|
};
|
2335
|
-
const CircleIcon = styled(PlusCircle)`
|
2336
|
-
width: 2.4rem;
|
2337
|
-
height: 2.4rem;
|
2338
|
-
> circle {
|
2339
|
-
fill: ${({ theme }) => theme.colors.primary200};
|
2340
|
-
}
|
2341
|
-
> path {
|
2342
|
-
fill: ${({ theme }) => theme.colors.primary600};
|
2343
|
-
}
|
2344
|
-
`;
|
2345
2722
|
const NonRepeatableComponent = ({
|
2346
2723
|
attribute,
|
2347
2724
|
name: name2,
|
2348
2725
|
children,
|
2349
2726
|
layout
|
2350
2727
|
}) => {
|
2728
|
+
const { formatMessage } = useIntl();
|
2351
2729
|
const { value } = useField(name2);
|
2352
2730
|
const level = useComponent("NonRepeatableComponent", (state) => state.level);
|
2353
2731
|
const isNested = level > 0;
|
@@ -2362,9 +2740,24 @@ const NonRepeatableComponent = ({
|
|
2362
2740
|
hasRadius: isNested,
|
2363
2741
|
borderColor: isNested ? "neutral200" : void 0,
|
2364
2742
|
children: /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: layout.map((row, index) => {
|
2365
|
-
return /* @__PURE__ */ jsx(Grid$1, { gap: 4, children: row.map(({ size, ...field }) => {
|
2743
|
+
return /* @__PURE__ */ jsx(Grid$1.Root, { gap: 4, children: row.map(({ size, ...field }) => {
|
2366
2744
|
const completeFieldName = `${name2}.${field.name}`;
|
2367
|
-
|
2745
|
+
const translatedLabel = formatMessage({
|
2746
|
+
id: `content-manager.components.${attribute.component}.${field.name}`,
|
2747
|
+
defaultMessage: field.label
|
2748
|
+
});
|
2749
|
+
return /* @__PURE__ */ jsx(
|
2750
|
+
Grid$1.Item,
|
2751
|
+
{
|
2752
|
+
col: size,
|
2753
|
+
s: 12,
|
2754
|
+
xs: 12,
|
2755
|
+
direction: "column",
|
2756
|
+
alignItems: "stretch",
|
2757
|
+
children: children({ ...field, label: translatedLabel, name: completeFieldName })
|
2758
|
+
},
|
2759
|
+
completeFieldName
|
2760
|
+
);
|
2368
2761
|
}) }, index);
|
2369
2762
|
}) })
|
2370
2763
|
}
|
@@ -2383,13 +2776,34 @@ const RepeatableComponent = ({
|
|
2383
2776
|
const { search: searchString } = useLocation();
|
2384
2777
|
const search = React.useMemo(() => new URLSearchParams(searchString), [searchString]);
|
2385
2778
|
const { components } = useDoc();
|
2386
|
-
const {
|
2779
|
+
const {
|
2780
|
+
value = [],
|
2781
|
+
error,
|
2782
|
+
rawError
|
2783
|
+
} = useField(name2);
|
2387
2784
|
const addFieldRow = useForm("RepeatableComponent", (state) => state.addFieldRow);
|
2388
2785
|
const moveFieldRow = useForm("RepeatableComponent", (state) => state.moveFieldRow);
|
2389
2786
|
const removeFieldRow = useForm("RepeatableComponent", (state) => state.removeFieldRow);
|
2390
2787
|
const { max = Infinity } = attribute;
|
2391
|
-
const [collapseToOpen, setCollapseToOpen] = React.useState(
|
2788
|
+
const [collapseToOpen, setCollapseToOpen] = React.useState("");
|
2392
2789
|
const [liveText, setLiveText] = React.useState("");
|
2790
|
+
React.useEffect(() => {
|
2791
|
+
const hasNestedErrors = rawError && Array.isArray(rawError) && rawError.length > 0;
|
2792
|
+
const hasNestedValue = value && Array.isArray(value) && value.length > 0;
|
2793
|
+
if (hasNestedErrors && hasNestedValue) {
|
2794
|
+
const errorOpenItems = rawError.map((_, idx) => {
|
2795
|
+
return value[idx] ? value[idx].__temp_key__ : null;
|
2796
|
+
}).filter((value2) => !!value2);
|
2797
|
+
if (errorOpenItems && errorOpenItems.length > 0) {
|
2798
|
+
setCollapseToOpen((collapseToOpen2) => {
|
2799
|
+
if (!errorOpenItems.includes(collapseToOpen2)) {
|
2800
|
+
return errorOpenItems[0];
|
2801
|
+
}
|
2802
|
+
return collapseToOpen2;
|
2803
|
+
});
|
2804
|
+
}
|
2805
|
+
}
|
2806
|
+
}, [rawError, value]);
|
2393
2807
|
const componentTmpKeyWithFocussedField = React.useMemo(() => {
|
2394
2808
|
if (search.has("field")) {
|
2395
2809
|
const fieldParam = search.get("field");
|
@@ -2404,13 +2818,19 @@ const RepeatableComponent = ({
|
|
2404
2818
|
}
|
2405
2819
|
return void 0;
|
2406
2820
|
}, [search, name2, value]);
|
2821
|
+
const prevValue = usePrev(value);
|
2822
|
+
React.useEffect(() => {
|
2823
|
+
if (prevValue && prevValue.length < value.length) {
|
2824
|
+
setCollapseToOpen(value[value.length - 1].__temp_key__);
|
2825
|
+
}
|
2826
|
+
}, [value, prevValue]);
|
2407
2827
|
React.useEffect(() => {
|
2408
|
-
if (typeof componentTmpKeyWithFocussedField === "
|
2828
|
+
if (typeof componentTmpKeyWithFocussedField === "string") {
|
2409
2829
|
setCollapseToOpen(componentTmpKeyWithFocussedField);
|
2410
2830
|
}
|
2411
2831
|
}, [componentTmpKeyWithFocussedField]);
|
2412
2832
|
const toggleCollapses = () => {
|
2413
|
-
setCollapseToOpen(
|
2833
|
+
setCollapseToOpen("");
|
2414
2834
|
};
|
2415
2835
|
const handleClick = () => {
|
2416
2836
|
if (value.length < max) {
|
@@ -2442,12 +2862,8 @@ const RepeatableComponent = ({
|
|
2442
2862
|
);
|
2443
2863
|
moveFieldRow(name2, currentIndex, newIndex);
|
2444
2864
|
};
|
2445
|
-
const
|
2446
|
-
|
2447
|
-
setCollapseToOpen(null);
|
2448
|
-
} else {
|
2449
|
-
setCollapseToOpen(key);
|
2450
|
-
}
|
2865
|
+
const handleValueChange = (key) => {
|
2866
|
+
setCollapseToOpen(key);
|
2451
2867
|
};
|
2452
2868
|
const getItemPos = (index) => `${index + 1} of ${value.length}`;
|
2453
2869
|
const handleCancel = (index) => {
|
@@ -2502,158 +2918,123 @@ const RepeatableComponent = ({
|
|
2502
2918
|
defaultMessage: `Press spacebar to grab and re-order`
|
2503
2919
|
}) }),
|
2504
2920
|
/* @__PURE__ */ jsx(VisuallyHidden, { "aria-live": "assertive", children: liveText }),
|
2505
|
-
/* @__PURE__ */ jsxs(
|
2506
|
-
|
2507
|
-
|
2508
|
-
|
2509
|
-
|
2510
|
-
|
2511
|
-
|
2512
|
-
|
2513
|
-
|
2514
|
-
|
2515
|
-
|
2516
|
-
|
2921
|
+
/* @__PURE__ */ jsxs(
|
2922
|
+
AccordionRoot,
|
2923
|
+
{
|
2924
|
+
$error: error,
|
2925
|
+
value: collapseToOpen,
|
2926
|
+
onValueChange: handleValueChange,
|
2927
|
+
"aria-describedby": ariaDescriptionId,
|
2928
|
+
children: [
|
2929
|
+
value.map(({ __temp_key__: key, id }, index) => {
|
2930
|
+
const nameWithIndex = `${name2}.${index}`;
|
2931
|
+
return /* @__PURE__ */ jsx(
|
2932
|
+
ComponentProvider,
|
2517
2933
|
{
|
2518
|
-
|
2519
|
-
|
2520
|
-
|
2521
|
-
|
2522
|
-
|
2523
|
-
|
2524
|
-
|
2525
|
-
|
2526
|
-
|
2527
|
-
|
2528
|
-
|
2529
|
-
|
2530
|
-
|
2531
|
-
|
2532
|
-
|
2533
|
-
|
2534
|
-
|
2535
|
-
|
2536
|
-
|
2537
|
-
|
2538
|
-
|
2539
|
-
|
2540
|
-
|
2541
|
-
|
2542
|
-
|
2543
|
-
|
2544
|
-
|
2545
|
-
|
2546
|
-
|
2547
|
-
|
2548
|
-
|
2549
|
-
|
2550
|
-
|
2934
|
+
id,
|
2935
|
+
uid: attribute.component,
|
2936
|
+
level: level + 1,
|
2937
|
+
type: "repeatable",
|
2938
|
+
children: /* @__PURE__ */ jsx(
|
2939
|
+
Component,
|
2940
|
+
{
|
2941
|
+
disabled,
|
2942
|
+
name: nameWithIndex,
|
2943
|
+
attribute,
|
2944
|
+
index,
|
2945
|
+
mainField,
|
2946
|
+
onMoveItem: handleMoveComponentField,
|
2947
|
+
onDeleteComponent: () => {
|
2948
|
+
removeFieldRow(name2, index);
|
2949
|
+
toggleCollapses();
|
2950
|
+
},
|
2951
|
+
toggleCollapses,
|
2952
|
+
onCancel: handleCancel,
|
2953
|
+
onDropItem: handleDropItem,
|
2954
|
+
onGrabItem: handleGrabItem,
|
2955
|
+
__temp_key__: key,
|
2956
|
+
children: layout.map((row, index2) => {
|
2957
|
+
return /* @__PURE__ */ jsx(Grid$1.Root, { gap: 4, children: row.map(({ size, ...field }) => {
|
2958
|
+
const completeFieldName = `${nameWithIndex}.${field.name}`;
|
2959
|
+
const translatedLabel = formatMessage({
|
2960
|
+
id: `content-manager.components.${attribute.component}.${field.name}`,
|
2961
|
+
defaultMessage: field.label
|
2962
|
+
});
|
2963
|
+
return /* @__PURE__ */ jsx(
|
2964
|
+
Grid$1.Item,
|
2965
|
+
{
|
2966
|
+
col: size,
|
2967
|
+
s: 12,
|
2968
|
+
xs: 12,
|
2969
|
+
direction: "column",
|
2970
|
+
alignItems: "stretch",
|
2971
|
+
children: children({
|
2972
|
+
...field,
|
2973
|
+
label: translatedLabel,
|
2974
|
+
name: completeFieldName
|
2975
|
+
})
|
2976
|
+
},
|
2977
|
+
completeFieldName
|
2978
|
+
);
|
2979
|
+
}) }, index2);
|
2980
|
+
})
|
2981
|
+
}
|
2982
|
+
)
|
2983
|
+
},
|
2984
|
+
key
|
2985
|
+
);
|
2986
|
+
}),
|
2987
|
+
/* @__PURE__ */ jsx(TextButtonCustom, { disabled, onClick: handleClick, startIcon: /* @__PURE__ */ jsx(Plus, {}), children: formatMessage({
|
2988
|
+
id: getTranslation("containers.EditView.add.new-entry"),
|
2989
|
+
defaultMessage: "Add an entry"
|
2990
|
+
}) })
|
2991
|
+
]
|
2992
|
+
}
|
2993
|
+
)
|
2551
2994
|
] });
|
2552
2995
|
};
|
2996
|
+
const AccordionRoot = styled(Accordion.Root)`
|
2997
|
+
border: 1px solid
|
2998
|
+
${({ theme, $error }) => $error ? theme.colors.danger600 : theme.colors.neutral200};
|
2999
|
+
`;
|
2553
3000
|
const TextButtonCustom = styled(TextButton)`
|
2554
|
-
height: 100%;
|
2555
3001
|
width: 100%;
|
2556
|
-
border-radius: 0 0 4px 4px;
|
2557
3002
|
display: flex;
|
2558
3003
|
justify-content: center;
|
2559
|
-
|
2560
|
-
|
2561
|
-
|
2562
|
-
}
|
2563
|
-
`;
|
2564
|
-
const AccordionFooter = styled(Box)`
|
2565
|
-
overflow: hidden;
|
2566
|
-
border-bottom: 1px solid ${({ theme }) => theme.colors.neutral200};
|
2567
|
-
border-right: 1px solid ${({ theme }) => theme.colors.neutral200};
|
2568
|
-
border-left: 1px solid ${({ theme }) => theme.colors.neutral200};
|
2569
|
-
border-radius: 0 0 ${({ theme }) => theme.borderRadius} ${({ theme }) => theme.borderRadius};
|
2570
|
-
`;
|
2571
|
-
const AccordionContent = styled(Box)`
|
2572
|
-
border-bottom: none;
|
3004
|
+
border-top: 1px solid ${({ theme }) => theme.colors.neutral200};
|
3005
|
+
padding-inline: ${(props) => props.theme.spaces[6]};
|
3006
|
+
padding-block: ${(props) => props.theme.spaces[3]};
|
2573
3007
|
|
2574
|
-
|
2575
|
-
|
2576
|
-
border: 1px solid ${({ theme }) => theme.colors.neutral200};
|
2577
|
-
border-top-color: transparent;
|
2578
|
-
}
|
2579
|
-
|
2580
|
-
/* the top accordion _does_ need a border though */
|
2581
|
-
& > div:first-child > div {
|
2582
|
-
border-top: 1px solid ${({ theme }) => theme.colors.neutral200};
|
2583
|
-
}
|
2584
|
-
|
2585
|
-
/* Reset all the border-radius' */
|
2586
|
-
& > div > div,
|
2587
|
-
& > div > div > div {
|
2588
|
-
border-radius: unset;
|
2589
|
-
}
|
2590
|
-
|
2591
|
-
/* Give the border radius back to the first accordion */
|
2592
|
-
& > div:first-child > div,
|
2593
|
-
& > div:first-child > div > div {
|
2594
|
-
border-radius: ${({ theme }) => theme.borderRadius} ${({ theme }) => theme.borderRadius} 0 0;
|
2595
|
-
}
|
2596
|
-
|
2597
|
-
& > div > div[data-strapi-expanded='true'] {
|
2598
|
-
border: 1px solid ${({ theme }) => theme.colors.primary600};
|
2599
|
-
}
|
2600
|
-
`;
|
2601
|
-
const AccordionGroup = ({ children, error }) => {
|
2602
|
-
return /* @__PURE__ */ jsxs(KeyboardNavigable, { attributeName: "data-strapi-accordion-toggle", children: [
|
2603
|
-
children,
|
2604
|
-
error && /* @__PURE__ */ jsx(Box, { paddingTop: 1, children: /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger600", children: error }) })
|
2605
|
-
] });
|
2606
|
-
};
|
2607
|
-
const CustomIconButton$1 = styled(IconButton)`
|
2608
|
-
background-color: transparent;
|
3008
|
+
&:not([disabled]) {
|
3009
|
+
cursor: pointer;
|
2609
3010
|
|
2610
|
-
|
2611
|
-
|
2612
|
-
fill: ${({ theme, expanded }) => expanded ? theme.colors.primary600 : theme.colors.neutral600};
|
3011
|
+
&:hover {
|
3012
|
+
background-color: ${(props) => props.theme.colors.primary100};
|
2613
3013
|
}
|
2614
3014
|
}
|
2615
3015
|
|
2616
|
-
|
2617
|
-
|
2618
|
-
|
2619
|
-
|
2620
|
-
}
|
2621
|
-
}
|
3016
|
+
span {
|
3017
|
+
font-weight: 600;
|
3018
|
+
font-size: 1.4rem;
|
3019
|
+
line-height: 2.4rem;
|
2622
3020
|
}
|
2623
|
-
`;
|
2624
|
-
const ActionsFlex$1 = styled(Flex)`
|
2625
|
-
& .drag-handle {
|
2626
|
-
background: unset;
|
2627
|
-
|
2628
|
-
svg {
|
2629
|
-
path {
|
2630
|
-
fill: ${({ theme, expanded }) => expanded ? theme.colors.primary600 : void 0};
|
2631
|
-
}
|
2632
|
-
}
|
2633
3021
|
|
2634
|
-
|
2635
|
-
|
2636
|
-
path {
|
2637
|
-
/* keeps the hover style of the accordion */
|
2638
|
-
fill: ${({ theme }) => theme.colors.primary600};
|
2639
|
-
}
|
2640
|
-
}
|
2641
|
-
}
|
3022
|
+
@media (prefers-reduced-motion: no-preference) {
|
3023
|
+
transition: background-color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};
|
2642
3024
|
}
|
2643
3025
|
`;
|
2644
3026
|
const Component = ({
|
2645
3027
|
disabled,
|
2646
3028
|
index,
|
2647
|
-
isOpen,
|
2648
3029
|
name: name2,
|
2649
3030
|
mainField = {
|
2650
3031
|
name: "id",
|
2651
3032
|
type: "integer"
|
2652
3033
|
},
|
2653
3034
|
children,
|
2654
|
-
onClickToggle,
|
2655
3035
|
onDeleteComponent,
|
2656
3036
|
toggleCollapses,
|
3037
|
+
__temp_key__,
|
2657
3038
|
...dragProps
|
2658
3039
|
}) => {
|
2659
3040
|
const { formatMessage } = useIntl();
|
@@ -2678,50 +3059,44 @@ const Component = ({
|
|
2678
3059
|
dragPreviewRef(getEmptyImage(), { captureDraggingState: false });
|
2679
3060
|
}, [dragPreviewRef, index]);
|
2680
3061
|
const composedAccordionRefs = useComposedRefs(accordionRef, dragRef);
|
2681
|
-
const composedBoxRefs = useComposedRefs(
|
2682
|
-
|
2683
|
-
|
2684
|
-
|
2685
|
-
|
2686
|
-
|
2687
|
-
|
2688
|
-
|
2689
|
-
|
2690
|
-
|
2691
|
-
|
2692
|
-
|
2693
|
-
|
2694
|
-
|
2695
|
-
|
2696
|
-
|
2697
|
-
|
2698
|
-
}
|
2699
|
-
|
2700
|
-
|
2701
|
-
|
2702
|
-
|
2703
|
-
|
2704
|
-
|
2705
|
-
|
2706
|
-
|
2707
|
-
|
2708
|
-
|
2709
|
-
|
2710
|
-
"
|
2711
|
-
|
2712
|
-
|
2713
|
-
|
2714
|
-
|
2715
|
-
|
2716
|
-
|
2717
|
-
|
2718
|
-
|
2719
|
-
] }),
|
2720
|
-
title: displayValue,
|
2721
|
-
togglePosition: "left"
|
2722
|
-
}
|
2723
|
-
),
|
2724
|
-
/* @__PURE__ */ jsx(AccordionContent$1, { children: /* @__PURE__ */ jsx(
|
3062
|
+
const composedBoxRefs = useComposedRefs(
|
3063
|
+
boxRef,
|
3064
|
+
dropRef
|
3065
|
+
);
|
3066
|
+
return /* @__PURE__ */ jsx(Fragment, { children: isDragging ? /* @__PURE__ */ jsx(Preview$1, {}) : /* @__PURE__ */ jsxs(Accordion.Item, { ref: composedBoxRefs, value: __temp_key__, children: [
|
3067
|
+
/* @__PURE__ */ jsxs(Accordion.Header, { children: [
|
3068
|
+
/* @__PURE__ */ jsx(Accordion.Trigger, { children: displayValue }),
|
3069
|
+
/* @__PURE__ */ jsxs(Accordion.Actions, { children: [
|
3070
|
+
/* @__PURE__ */ jsx(
|
3071
|
+
IconButton,
|
3072
|
+
{
|
3073
|
+
variant: "ghost",
|
3074
|
+
onClick: onDeleteComponent,
|
3075
|
+
label: formatMessage({
|
3076
|
+
id: getTranslation("containers.Edit.delete"),
|
3077
|
+
defaultMessage: "Delete"
|
3078
|
+
}),
|
3079
|
+
children: /* @__PURE__ */ jsx(Trash, {})
|
3080
|
+
}
|
3081
|
+
),
|
3082
|
+
/* @__PURE__ */ jsx(
|
3083
|
+
IconButton,
|
3084
|
+
{
|
3085
|
+
ref: composedAccordionRefs,
|
3086
|
+
variant: "ghost",
|
3087
|
+
onClick: (e) => e.stopPropagation(),
|
3088
|
+
"data-handler-id": handlerId,
|
3089
|
+
label: formatMessage({
|
3090
|
+
id: getTranslation("components.DragHandle-label"),
|
3091
|
+
defaultMessage: "Drag"
|
3092
|
+
}),
|
3093
|
+
onKeyDown: handleKeyDown,
|
3094
|
+
children: /* @__PURE__ */ jsx(Drag, {})
|
3095
|
+
}
|
3096
|
+
)
|
3097
|
+
] })
|
3098
|
+
] }),
|
3099
|
+
/* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsx(
|
2725
3100
|
Flex,
|
2726
3101
|
{
|
2727
3102
|
direction: "column",
|
@@ -2735,7 +3110,7 @@ const Component = ({
|
|
2735
3110
|
] }) });
|
2736
3111
|
};
|
2737
3112
|
const Preview$1 = () => {
|
2738
|
-
return /* @__PURE__ */ jsx(StyledSpan, {
|
3113
|
+
return /* @__PURE__ */ jsx(StyledSpan, { tag: "span", padding: 6, background: "primary100" });
|
2739
3114
|
};
|
2740
3115
|
const StyledSpan = styled(Box)`
|
2741
3116
|
display: block;
|
@@ -2761,29 +3136,15 @@ const ComponentInput = ({
|
|
2761
3136
|
const data = transformDocument(schema, components)(form);
|
2762
3137
|
field.onChange(name2, data);
|
2763
3138
|
};
|
2764
|
-
return /* @__PURE__ */ jsxs(
|
3139
|
+
return /* @__PURE__ */ jsxs(Field.Root, { error: field.error, required, children: [
|
2765
3140
|
/* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", children: [
|
2766
|
-
/* @__PURE__ */ jsxs(
|
2767
|
-
|
2768
|
-
|
2769
|
-
|
2770
|
-
|
2771
|
-
|
2772
|
-
|
2773
|
-
fontWeight: "bold",
|
2774
|
-
as: "label",
|
2775
|
-
children: [
|
2776
|
-
label,
|
2777
|
-
attribute.repeatable && /* @__PURE__ */ jsxs(Fragment, { children: [
|
2778
|
-
" (",
|
2779
|
-
Array.isArray(field.value) ? field.value.length : 0,
|
2780
|
-
")"
|
2781
|
-
] }),
|
2782
|
-
required && /* @__PURE__ */ jsx(Typography, { textColor: "danger600", children: "*" })
|
2783
|
-
]
|
2784
|
-
}
|
2785
|
-
),
|
2786
|
-
labelAction && /* @__PURE__ */ jsx(Box, { paddingLeft: 1, children: labelAction })
|
3141
|
+
/* @__PURE__ */ jsxs(Field.Label, { action: labelAction, children: [
|
3142
|
+
label,
|
3143
|
+
attribute.repeatable && /* @__PURE__ */ jsxs(Fragment, { children: [
|
3144
|
+
" (",
|
3145
|
+
Array.isArray(field.value) ? field.value.length : 0,
|
3146
|
+
")"
|
3147
|
+
] })
|
2787
3148
|
] }),
|
2788
3149
|
showResetComponent && /* @__PURE__ */ jsx(
|
2789
3150
|
IconButton,
|
@@ -2792,21 +3153,21 @@ const ComponentInput = ({
|
|
2792
3153
|
id: getTranslation("components.reset-entry"),
|
2793
3154
|
defaultMessage: "Reset Entry"
|
2794
3155
|
}),
|
2795
|
-
|
2796
|
-
borderWidth: 0,
|
3156
|
+
variant: "ghost",
|
2797
3157
|
onClick: () => {
|
2798
3158
|
field.onChange(name2, null);
|
2799
|
-
}
|
3159
|
+
},
|
3160
|
+
children: /* @__PURE__ */ jsx(Trash, {})
|
2800
3161
|
}
|
2801
3162
|
)
|
2802
3163
|
] }),
|
2803
|
-
/* @__PURE__ */
|
2804
|
-
|
2805
|
-
|
2806
|
-
|
2807
|
-
] })
|
3164
|
+
!attribute.repeatable && !field.value && /* @__PURE__ */ jsx(Initializer, { disabled, name: name2, onClick: handleInitialisationClick }),
|
3165
|
+
!attribute.repeatable && field.value ? /* @__PURE__ */ jsx(NonRepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }) : null,
|
3166
|
+
attribute.repeatable && /* @__PURE__ */ jsx(RepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }),
|
3167
|
+
/* @__PURE__ */ jsx(Field.Error, {})
|
2808
3168
|
] });
|
2809
3169
|
};
|
3170
|
+
const MemoizedComponentInput = React.memo(ComponentInput);
|
2810
3171
|
const AddComponentButton = ({
|
2811
3172
|
hasError,
|
2812
3173
|
isDisabled,
|
@@ -2821,19 +3182,16 @@ const AddComponentButton = ({
|
|
2821
3182
|
onClick,
|
2822
3183
|
disabled: isDisabled,
|
2823
3184
|
background: "neutral0",
|
2824
|
-
paddingTop: 3,
|
2825
|
-
paddingBottom: 3,
|
2826
|
-
paddingLeft: 4,
|
2827
|
-
paddingRight: 4,
|
2828
3185
|
style: { cursor: isDisabled ? "not-allowed" : "pointer" },
|
2829
|
-
|
3186
|
+
variant: "tertiary",
|
3187
|
+
children: /* @__PURE__ */ jsxs(Flex, { tag: "span", gap: 2, children: [
|
2830
3188
|
/* @__PURE__ */ jsx(StyledAddIcon, { "aria-hidden": true, $isOpen: isOpen, $hasError: hasError && !isOpen }),
|
2831
3189
|
/* @__PURE__ */ jsx(
|
2832
3190
|
Typography,
|
2833
3191
|
{
|
2834
3192
|
variant: "pi",
|
2835
3193
|
fontWeight: "bold",
|
2836
|
-
textColor: hasError && !isOpen ? "danger600" : "
|
3194
|
+
textColor: hasError && !isOpen ? "danger600" : "neutral600",
|
2837
3195
|
children
|
2838
3196
|
}
|
2839
3197
|
)
|
@@ -2850,67 +3208,28 @@ const StyledAddIcon = styled(PlusCircle)`
|
|
2850
3208
|
fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger200 : theme.colors.neutral150};
|
2851
3209
|
}
|
2852
3210
|
> path {
|
2853
|
-
fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger600 : theme.colors.
|
3211
|
+
fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger600 : theme.colors.neutral500};
|
2854
3212
|
}
|
2855
3213
|
`;
|
2856
|
-
const StyledButton = styled(
|
3214
|
+
const StyledButton = styled(Button)`
|
3215
|
+
padding-left: ${({ theme }) => theme.spaces[3]};
|
2857
3216
|
border-radius: 26px;
|
2858
|
-
border-color: ${({ theme }) => theme.colors.neutral150};
|
2859
3217
|
box-shadow: ${({ theme }) => theme.shadows.filterShadow};
|
2860
|
-
|
2861
|
-
&:hover {
|
2862
|
-
${Typography} {
|
2863
|
-
color: ${({ theme }) => theme.colors.primary600};
|
2864
|
-
}
|
2865
|
-
|
2866
|
-
${StyledAddIcon} {
|
2867
|
-
> circle {
|
2868
|
-
fill: ${({ theme }) => theme.colors.primary600};
|
2869
|
-
}
|
2870
|
-
> path {
|
2871
|
-
fill: ${({ theme }) => theme.colors.neutral100};
|
2872
|
-
}
|
2873
|
-
}
|
2874
|
-
}
|
2875
|
-
&:active {
|
2876
|
-
${Typography} {
|
2877
|
-
color: ${({ theme }) => theme.colors.primary600};
|
2878
|
-
}
|
2879
|
-
${StyledAddIcon} {
|
2880
|
-
> circle {
|
2881
|
-
fill: ${({ theme }) => theme.colors.primary600};
|
2882
|
-
}
|
2883
|
-
> path {
|
2884
|
-
fill: ${({ theme }) => theme.colors.neutral100};
|
2885
|
-
}
|
2886
|
-
}
|
2887
|
-
}
|
3218
|
+
height: 5rem;
|
2888
3219
|
`;
|
2889
3220
|
const ComponentCategory = ({
|
2890
3221
|
category,
|
2891
3222
|
components = [],
|
2892
3223
|
variant = "primary",
|
2893
|
-
|
2894
|
-
onAddComponent,
|
2895
|
-
onToggle
|
3224
|
+
onAddComponent
|
2896
3225
|
}) => {
|
2897
3226
|
const { formatMessage } = useIntl();
|
2898
|
-
|
2899
|
-
|
2900
|
-
|
2901
|
-
return /* @__PURE__ */ jsxs(Accordion, { expanded: isOpen, onToggle: handleToggle, size: "S", children: [
|
2902
|
-
/* @__PURE__ */ jsx(
|
2903
|
-
AccordionToggle,
|
2904
|
-
{
|
2905
|
-
variant,
|
2906
|
-
title: formatMessage({ id: category, defaultMessage: category }),
|
2907
|
-
togglePosition: "left"
|
2908
|
-
}
|
2909
|
-
),
|
2910
|
-
/* @__PURE__ */ jsx(AccordionContent$1, { children: /* @__PURE__ */ jsx(Box, { paddingTop: 4, paddingBottom: 4, paddingLeft: 3, paddingRight: 3, children: /* @__PURE__ */ jsx(Grid, { children: components.map(({ uid, displayName, icon }) => /* @__PURE__ */ jsx(
|
3227
|
+
return /* @__PURE__ */ jsxs(Accordion.Item, { value: category, children: [
|
3228
|
+
/* @__PURE__ */ jsx(Accordion.Header, { variant, children: /* @__PURE__ */ jsx(Accordion.Trigger, { children: formatMessage({ id: category, defaultMessage: category }) }) }),
|
3229
|
+
/* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsx(Grid, { paddingTop: 4, paddingBottom: 4, paddingLeft: 3, paddingRight: 3, children: components.map(({ uid, displayName, icon }) => /* @__PURE__ */ jsx(
|
2911
3230
|
ComponentBox,
|
2912
3231
|
{
|
2913
|
-
|
3232
|
+
tag: "button",
|
2914
3233
|
type: "button",
|
2915
3234
|
background: "neutral100",
|
2916
3235
|
justifyContent: "center",
|
@@ -2920,34 +3239,32 @@ const ComponentCategory = ({
|
|
2920
3239
|
shrink: 0,
|
2921
3240
|
borderColor: "neutral200",
|
2922
3241
|
children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, alignItems: "center", justifyContent: "center", children: [
|
2923
|
-
/* @__PURE__ */ jsx(ComponentIcon, { icon }),
|
2924
|
-
/* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold",
|
3242
|
+
/* @__PURE__ */ jsx(ComponentIcon, { color: "currentColor", background: "primary200", icon }),
|
3243
|
+
/* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", children: displayName })
|
2925
3244
|
] })
|
2926
3245
|
},
|
2927
3246
|
uid
|
2928
|
-
)) }) })
|
3247
|
+
)) }) })
|
2929
3248
|
] });
|
2930
3249
|
};
|
2931
|
-
const Grid = styled
|
3250
|
+
const Grid = styled(Box)`
|
2932
3251
|
display: grid;
|
2933
3252
|
grid-template-columns: repeat(auto-fit, 14rem);
|
2934
3253
|
grid-gap: ${({ theme }) => theme.spaces[1]};
|
2935
3254
|
`;
|
2936
3255
|
const ComponentBox = styled(Flex)`
|
3256
|
+
color: ${({ theme }) => theme.colors.neutral600};
|
3257
|
+
cursor: pointer;
|
3258
|
+
|
3259
|
+
@media (prefers-reduced-motion: no-preference) {
|
3260
|
+
transition: color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};
|
3261
|
+
}
|
3262
|
+
|
2937
3263
|
&:focus,
|
2938
3264
|
&:hover {
|
2939
3265
|
border: 1px solid ${({ theme }) => theme.colors.primary200};
|
2940
3266
|
background: ${({ theme }) => theme.colors.primary100};
|
2941
|
-
|
2942
|
-
${Typography} {
|
2943
|
-
color: ${({ theme }) => theme.colors.primary600};
|
2944
|
-
}
|
2945
|
-
|
2946
|
-
/* > Flex > ComponentIcon */
|
2947
|
-
> div > div:first-child {
|
2948
|
-
background: ${({ theme }) => theme.colors.primary200};
|
2949
|
-
color: ${({ theme }) => theme.colors.primary600};
|
2950
|
-
}
|
3267
|
+
color: ${({ theme }) => theme.colors.primary600};
|
2951
3268
|
}
|
2952
3269
|
`;
|
2953
3270
|
const ComponentPicker = ({
|
@@ -2956,19 +3273,8 @@ const ComponentPicker = ({
|
|
2956
3273
|
onClickAddComponent
|
2957
3274
|
}) => {
|
2958
3275
|
const { formatMessage } = useIntl();
|
2959
|
-
const [categoryToOpen, setCategoryToOpen] = React.useState("");
|
2960
|
-
React.useEffect(() => {
|
2961
|
-
const categoryKeys = Object.keys(dynamicComponentsByCategory);
|
2962
|
-
if (isOpen && categoryKeys.length > 0) {
|
2963
|
-
setCategoryToOpen(categoryKeys[0]);
|
2964
|
-
}
|
2965
|
-
}, [isOpen, dynamicComponentsByCategory]);
|
2966
3276
|
const handleAddComponentToDz = (componentUid) => () => {
|
2967
3277
|
onClickAddComponent(componentUid);
|
2968
|
-
setCategoryToOpen("");
|
2969
|
-
};
|
2970
|
-
const handleClickToggle = (categoryName) => {
|
2971
|
-
setCategoryToOpen((currentCat) => currentCat === categoryName ? "" : categoryName);
|
2972
3278
|
};
|
2973
3279
|
if (!isOpen) {
|
2974
3280
|
return null;
|
@@ -2989,14 +3295,12 @@ const ComponentPicker = ({
|
|
2989
3295
|
id: getTranslation("components.DynamicZone.ComponentPicker-label"),
|
2990
3296
|
defaultMessage: "Pick one component"
|
2991
3297
|
}) }) }),
|
2992
|
-
/* @__PURE__ */ jsx(Box, { paddingTop: 2, children: /* @__PURE__ */ jsx(
|
3298
|
+
/* @__PURE__ */ jsx(Box, { paddingTop: 2, children: /* @__PURE__ */ jsx(Accordion.Root, { defaultValue: Object.keys(dynamicComponentsByCategory)[0], children: Object.entries(dynamicComponentsByCategory).map(([category, components], index) => /* @__PURE__ */ jsx(
|
2993
3299
|
ComponentCategory,
|
2994
3300
|
{
|
2995
3301
|
category,
|
2996
3302
|
components,
|
2997
3303
|
onAddComponent: handleAddComponentToDz,
|
2998
|
-
isOpen: category === categoryToOpen,
|
2999
|
-
onToggle: handleClickToggle,
|
3000
3304
|
variant: index % 2 === 1 ? "primary" : "secondary"
|
3001
3305
|
},
|
3002
3306
|
category
|
@@ -3011,39 +3315,21 @@ const NotAllowedInput = ({ hint, label, required, name: name2 }) => {
|
|
3011
3315
|
id: "components.NotAllowedInput.text",
|
3012
3316
|
defaultMessage: "No permissions to see this field"
|
3013
3317
|
});
|
3014
|
-
return /* @__PURE__ */
|
3015
|
-
|
3016
|
-
|
3017
|
-
|
3018
|
-
|
3019
|
-
|
3020
|
-
|
3021
|
-
|
3022
|
-
|
3023
|
-
|
3024
|
-
|
3025
|
-
|
3026
|
-
|
3027
|
-
|
3028
|
-
);
|
3318
|
+
return /* @__PURE__ */ jsxs(Field.Root, { id: name2, hint, name: name2, required, children: [
|
3319
|
+
/* @__PURE__ */ jsx(Field.Label, { children: label }),
|
3320
|
+
/* @__PURE__ */ jsx(
|
3321
|
+
TextInput,
|
3322
|
+
{
|
3323
|
+
disabled: true,
|
3324
|
+
placeholder,
|
3325
|
+
startAction: /* @__PURE__ */ jsx(EyeStriked, { fill: "neutral600" }),
|
3326
|
+
type: "text",
|
3327
|
+
value: ""
|
3328
|
+
}
|
3329
|
+
),
|
3330
|
+
/* @__PURE__ */ jsx(Field.Hint, {})
|
3331
|
+
] });
|
3029
3332
|
};
|
3030
|
-
const StyledIcon = styled(EyeStriked)`
|
3031
|
-
& > path {
|
3032
|
-
fill: ${({ theme }) => theme.colors.neutral600};
|
3033
|
-
}
|
3034
|
-
`;
|
3035
|
-
function useDebounce(value, delay) {
|
3036
|
-
const [debouncedValue, setDebouncedValue] = useState(value);
|
3037
|
-
useEffect(() => {
|
3038
|
-
const handler = setTimeout(() => {
|
3039
|
-
setDebouncedValue(value);
|
3040
|
-
}, delay);
|
3041
|
-
return () => {
|
3042
|
-
clearTimeout(handler);
|
3043
|
-
};
|
3044
|
-
}, [value, delay]);
|
3045
|
-
return debouncedValue;
|
3046
|
-
}
|
3047
3333
|
const uidApi = contentManagerApi.injectEndpoints({
|
3048
3334
|
endpoints: (builder) => ({
|
3049
3335
|
getDefaultUID: builder.query({
|
@@ -3078,194 +3364,206 @@ const uidApi = contentManagerApi.injectEndpoints({
|
|
3078
3364
|
config: {
|
3079
3365
|
params
|
3080
3366
|
}
|
3081
|
-
})
|
3367
|
+
}),
|
3368
|
+
providesTags: (_res, _error, params) => [
|
3369
|
+
{ type: "UidAvailability", id: params.contentTypeUID }
|
3370
|
+
]
|
3082
3371
|
})
|
3083
3372
|
})
|
3084
3373
|
});
|
3085
3374
|
const { useGenerateUIDMutation, useGetDefaultUIDQuery, useGetAvailabilityQuery } = uidApi;
|
3086
3375
|
const UID_REGEX = /^[A-Za-z0-9-_.~]*$/;
|
3087
|
-
const UIDInput = React.forwardRef(
|
3088
|
-
|
3089
|
-
|
3090
|
-
|
3091
|
-
|
3092
|
-
|
3093
|
-
|
3094
|
-
|
3095
|
-
|
3096
|
-
|
3097
|
-
|
3098
|
-
|
3099
|
-
|
3100
|
-
|
3101
|
-
|
3102
|
-
|
3103
|
-
|
3104
|
-
|
3105
|
-
|
3106
|
-
|
3107
|
-
|
3108
|
-
id: id ?? "",
|
3109
|
-
...allFormValues
|
3110
|
-
},
|
3111
|
-
params
|
3112
|
-
},
|
3113
|
-
{
|
3114
|
-
skip: field.value || !props.required
|
3115
|
-
}
|
3116
|
-
);
|
3117
|
-
React.useEffect(() => {
|
3118
|
-
if (apiError) {
|
3119
|
-
toggleNotification({
|
3120
|
-
type: "warning",
|
3121
|
-
message: formatAPIError(apiError)
|
3122
|
-
});
|
3123
|
-
}
|
3124
|
-
}, [apiError, formatAPIError, toggleNotification]);
|
3125
|
-
React.useEffect(() => {
|
3126
|
-
if (defaultGeneratedUID && field.value === void 0) {
|
3127
|
-
field.onChange(props.name, defaultGeneratedUID);
|
3128
|
-
}
|
3129
|
-
}, [defaultGeneratedUID, field, props.name]);
|
3130
|
-
const [generateUID, { isLoading: isGeneratingUID }] = useGenerateUIDMutation();
|
3131
|
-
const handleRegenerateClick = async () => {
|
3132
|
-
try {
|
3133
|
-
const res = await generateUID({
|
3376
|
+
const UIDInput = React.forwardRef(
|
3377
|
+
({ hint, label, labelAction, name: name2, required, ...props }, ref) => {
|
3378
|
+
const { model, id } = useDoc();
|
3379
|
+
const allFormValues = useForm("InputUID", (form) => form.values);
|
3380
|
+
const [availability, setAvailability] = React.useState();
|
3381
|
+
const [showRegenerate, setShowRegenerate] = React.useState(false);
|
3382
|
+
const isCloning = useMatch(CLONE_PATH) !== null;
|
3383
|
+
const field = useField(name2);
|
3384
|
+
const debouncedValue = useDebounce(field.value, 300);
|
3385
|
+
const hasChanged = debouncedValue !== field.initialValue;
|
3386
|
+
const { toggleNotification } = useNotification();
|
3387
|
+
const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
|
3388
|
+
const { formatMessage } = useIntl();
|
3389
|
+
const [{ query }] = useQueryParams();
|
3390
|
+
const params = React.useMemo(() => buildValidParams(query), [query]);
|
3391
|
+
const {
|
3392
|
+
data: defaultGeneratedUID,
|
3393
|
+
isLoading: isGeneratingDefaultUID,
|
3394
|
+
error: apiError
|
3395
|
+
} = useGetDefaultUIDQuery(
|
3396
|
+
{
|
3134
3397
|
contentTypeUID: model,
|
3135
|
-
field:
|
3136
|
-
data: {
|
3398
|
+
field: name2,
|
3399
|
+
data: {
|
3400
|
+
id: id ?? "",
|
3401
|
+
...allFormValues
|
3402
|
+
},
|
3137
3403
|
params
|
3138
|
-
}
|
3139
|
-
|
3140
|
-
field.
|
3141
|
-
}
|
3404
|
+
},
|
3405
|
+
{
|
3406
|
+
skip: field.value || !required
|
3407
|
+
}
|
3408
|
+
);
|
3409
|
+
React.useEffect(() => {
|
3410
|
+
if (apiError) {
|
3142
3411
|
toggleNotification({
|
3143
|
-
type: "
|
3144
|
-
message: formatAPIError(
|
3412
|
+
type: "warning",
|
3413
|
+
message: formatAPIError(apiError)
|
3145
3414
|
});
|
3146
3415
|
}
|
3147
|
-
}
|
3148
|
-
|
3149
|
-
|
3150
|
-
|
3151
|
-
|
3152
|
-
|
3153
|
-
|
3154
|
-
|
3155
|
-
|
3156
|
-
|
3157
|
-
|
3158
|
-
|
3159
|
-
|
3160
|
-
|
3161
|
-
|
3162
|
-
|
3163
|
-
|
3164
|
-
|
3165
|
-
|
3166
|
-
|
3167
|
-
|
3168
|
-
|
3169
|
-
|
3170
|
-
|
3171
|
-
|
3172
|
-
|
3173
|
-
|
3174
|
-
|
3175
|
-
|
3176
|
-
|
3177
|
-
|
3178
|
-
message: formatAPIError(availabilityError)
|
3179
|
-
});
|
3180
|
-
}
|
3181
|
-
}, [availabilityError, formatAPIError, toggleNotification]);
|
3182
|
-
React.useEffect(() => {
|
3183
|
-
setAvailability(availabilityData);
|
3184
|
-
let timer;
|
3185
|
-
if (availabilityData?.isAvailable) {
|
3186
|
-
timer = window.setTimeout(() => {
|
3187
|
-
setAvailability(void 0);
|
3188
|
-
}, 4e3);
|
3189
|
-
}
|
3190
|
-
return () => {
|
3191
|
-
if (timer) {
|
3192
|
-
clearTimeout(timer);
|
3416
|
+
}, [apiError, formatAPIError, toggleNotification]);
|
3417
|
+
React.useEffect(() => {
|
3418
|
+
if (defaultGeneratedUID && field.value === void 0) {
|
3419
|
+
field.onChange(name2, defaultGeneratedUID);
|
3420
|
+
}
|
3421
|
+
}, [defaultGeneratedUID, field, name2]);
|
3422
|
+
const [generateUID, { isLoading: isGeneratingUID }] = useGenerateUIDMutation();
|
3423
|
+
const handleRegenerateClick = async () => {
|
3424
|
+
try {
|
3425
|
+
const res = await generateUID({
|
3426
|
+
contentTypeUID: model,
|
3427
|
+
field: name2,
|
3428
|
+
data: { id: id ?? "", ...allFormValues },
|
3429
|
+
params
|
3430
|
+
});
|
3431
|
+
if ("data" in res) {
|
3432
|
+
field.onChange(name2, res.data);
|
3433
|
+
} else {
|
3434
|
+
toggleNotification({
|
3435
|
+
type: "danger",
|
3436
|
+
message: formatAPIError(res.error)
|
3437
|
+
});
|
3438
|
+
}
|
3439
|
+
} catch (err) {
|
3440
|
+
toggleNotification({
|
3441
|
+
type: "danger",
|
3442
|
+
message: formatMessage({
|
3443
|
+
id: "notification.error",
|
3444
|
+
defaultMessage: "An error occurred."
|
3445
|
+
})
|
3446
|
+
});
|
3193
3447
|
}
|
3194
3448
|
};
|
3195
|
-
|
3196
|
-
|
3197
|
-
|
3198
|
-
|
3199
|
-
|
3200
|
-
// @ts-expect-error – label _could_ be a ReactNode since it's a child, this should be fixed in the DS.
|
3201
|
-
/* @__PURE__ */ jsx(
|
3202
|
-
TextInput,
|
3449
|
+
const {
|
3450
|
+
data: availabilityData,
|
3451
|
+
isLoading: isCheckingAvailability,
|
3452
|
+
error: availabilityError
|
3453
|
+
} = useGetAvailabilityQuery(
|
3203
3454
|
{
|
3204
|
-
|
3205
|
-
|
3206
|
-
|
3207
|
-
|
3208
|
-
|
3209
|
-
|
3210
|
-
|
3211
|
-
|
3212
|
-
|
3213
|
-
|
3214
|
-
|
3215
|
-
|
3216
|
-
|
3217
|
-
|
3218
|
-
|
3219
|
-
|
3220
|
-
|
3221
|
-
|
3222
|
-
|
3223
|
-
|
3224
|
-
|
3225
|
-
|
3226
|
-
|
3227
|
-
|
3228
|
-
|
3229
|
-
|
3230
|
-
|
3231
|
-
|
3232
|
-
|
3233
|
-
|
3234
|
-
|
3235
|
-
|
3236
|
-
|
3237
|
-
|
3238
|
-
|
3239
|
-
|
3240
|
-
|
3241
|
-
|
3242
|
-
|
3243
|
-
|
3244
|
-
|
3245
|
-
|
3246
|
-
|
3247
|
-
|
3455
|
+
contentTypeUID: model,
|
3456
|
+
field: name2,
|
3457
|
+
value: debouncedValue ? debouncedValue.trim() : "",
|
3458
|
+
params
|
3459
|
+
},
|
3460
|
+
{
|
3461
|
+
// Don't check availability if the value is empty or wasn't changed
|
3462
|
+
skip: !Boolean(
|
3463
|
+
(hasChanged || isCloning) && debouncedValue && UID_REGEX.test(debouncedValue.trim())
|
3464
|
+
)
|
3465
|
+
}
|
3466
|
+
);
|
3467
|
+
React.useEffect(() => {
|
3468
|
+
if (availabilityError) {
|
3469
|
+
toggleNotification({
|
3470
|
+
type: "warning",
|
3471
|
+
message: formatAPIError(availabilityError)
|
3472
|
+
});
|
3473
|
+
}
|
3474
|
+
}, [availabilityError, formatAPIError, toggleNotification]);
|
3475
|
+
React.useEffect(() => {
|
3476
|
+
setAvailability(availabilityData);
|
3477
|
+
let timer;
|
3478
|
+
if (availabilityData?.isAvailable) {
|
3479
|
+
timer = window.setTimeout(() => {
|
3480
|
+
setAvailability(void 0);
|
3481
|
+
}, 4e3);
|
3482
|
+
}
|
3483
|
+
return () => {
|
3484
|
+
if (timer) {
|
3485
|
+
clearTimeout(timer);
|
3486
|
+
}
|
3487
|
+
};
|
3488
|
+
}, [availabilityData]);
|
3489
|
+
const isLoading = isGeneratingDefaultUID || isGeneratingUID || isCheckingAvailability;
|
3490
|
+
const fieldRef = useFocusInputField(name2);
|
3491
|
+
const composedRefs = useComposedRefs(ref, fieldRef);
|
3492
|
+
const shouldShowAvailability = (hasChanged || isCloning) && debouncedValue != null && availability && !showRegenerate;
|
3493
|
+
return /* @__PURE__ */ jsxs(Field.Root, { hint, name: name2, error: field.error, required, children: [
|
3494
|
+
/* @__PURE__ */ jsx(Field.Label, { action: labelAction, children: label }),
|
3495
|
+
/* @__PURE__ */ jsx(
|
3496
|
+
TextInput,
|
3497
|
+
{
|
3498
|
+
ref: composedRefs,
|
3499
|
+
disabled: props.disabled,
|
3500
|
+
endAction: /* @__PURE__ */ jsxs(Flex, { position: "relative", gap: 1, children: [
|
3501
|
+
shouldShowAvailability && /* @__PURE__ */ jsxs(
|
3502
|
+
TextValidation,
|
3248
3503
|
{
|
3249
|
-
|
3250
|
-
|
3251
|
-
|
3252
|
-
|
3253
|
-
|
3254
|
-
|
3255
|
-
|
3256
|
-
|
3504
|
+
alignItems: "center",
|
3505
|
+
gap: 1,
|
3506
|
+
justifyContent: "flex-end",
|
3507
|
+
$available: !!availability?.isAvailable,
|
3508
|
+
"data-not-here-outer": true,
|
3509
|
+
position: "absolute",
|
3510
|
+
pointerEvents: "none",
|
3511
|
+
right: 6,
|
3512
|
+
width: "100px",
|
3513
|
+
children: [
|
3514
|
+
availability?.isAvailable ? /* @__PURE__ */ jsx(CheckCircle, {}) : /* @__PURE__ */ jsx(WarningCircle, {}),
|
3515
|
+
/* @__PURE__ */ jsx(
|
3516
|
+
Typography,
|
3517
|
+
{
|
3518
|
+
textColor: availability.isAvailable ? "success600" : "danger600",
|
3519
|
+
variant: "pi",
|
3520
|
+
children: formatMessage(
|
3521
|
+
availability.isAvailable ? {
|
3522
|
+
id: "content-manager.components.uid.available",
|
3523
|
+
defaultMessage: "Available"
|
3524
|
+
} : {
|
3525
|
+
id: "content-manager.components.uid.unavailable",
|
3526
|
+
defaultMessage: "Unavailable"
|
3527
|
+
}
|
3528
|
+
)
|
3529
|
+
}
|
3530
|
+
)
|
3531
|
+
]
|
3257
3532
|
}
|
3258
|
-
)
|
3259
|
-
|
3260
|
-
|
3261
|
-
|
3262
|
-
|
3263
|
-
|
3264
|
-
|
3265
|
-
|
3266
|
-
|
3267
|
-
|
3268
|
-
|
3533
|
+
),
|
3534
|
+
!props.disabled && /* @__PURE__ */ jsxs(Fragment, { children: [
|
3535
|
+
showRegenerate && /* @__PURE__ */ jsx(TextValidation, { alignItems: "center", justifyContent: "flex-end", gap: 1, children: /* @__PURE__ */ jsx(Typography, { textColor: "primary600", variant: "pi", children: formatMessage({
|
3536
|
+
id: "content-manager.components.uid.regenerate",
|
3537
|
+
defaultMessage: "Regenerate"
|
3538
|
+
}) }) }),
|
3539
|
+
/* @__PURE__ */ jsx(
|
3540
|
+
FieldActionWrapper,
|
3541
|
+
{
|
3542
|
+
onClick: handleRegenerateClick,
|
3543
|
+
label: formatMessage({
|
3544
|
+
id: "content-manager.components.uid.regenerate",
|
3545
|
+
defaultMessage: "Regenerate"
|
3546
|
+
}),
|
3547
|
+
onMouseEnter: () => setShowRegenerate(true),
|
3548
|
+
onMouseLeave: () => setShowRegenerate(false),
|
3549
|
+
children: isLoading ? /* @__PURE__ */ jsx(LoadingWrapper, { "data-testid": "loading-wrapper", children: /* @__PURE__ */ jsx(Loader, {}) }) : /* @__PURE__ */ jsx(ArrowClockwise, {})
|
3550
|
+
}
|
3551
|
+
)
|
3552
|
+
] })
|
3553
|
+
] }),
|
3554
|
+
onChange: field.onChange,
|
3555
|
+
value: field.value ?? "",
|
3556
|
+
...props
|
3557
|
+
}
|
3558
|
+
),
|
3559
|
+
/* @__PURE__ */ jsx(Field.Error, {}),
|
3560
|
+
/* @__PURE__ */ jsx(Field.Hint, {})
|
3561
|
+
] });
|
3562
|
+
}
|
3563
|
+
);
|
3564
|
+
const FieldActionWrapper = styled(Field.Action)`
|
3565
|
+
width: 1.6rem;
|
3566
|
+
|
3269
3567
|
svg {
|
3270
3568
|
height: 1.6rem;
|
3271
3569
|
width: 1.6rem;
|
@@ -3286,7 +3584,7 @@ const TextValidation = styled(Flex)`
|
|
3286
3584
|
width: 1.2rem;
|
3287
3585
|
|
3288
3586
|
path {
|
3289
|
-
fill: ${({ theme, available }) => available ? theme.colors.success600 : theme.colors.danger600};
|
3587
|
+
fill: ${({ theme, $available }) => $available ? theme.colors.success600 : theme.colors.danger600};
|
3290
3588
|
}
|
3291
3589
|
}
|
3292
3590
|
`;
|
@@ -3301,6 +3599,7 @@ const rotation = keyframes`
|
|
3301
3599
|
const LoadingWrapper = styled(Flex)`
|
3302
3600
|
animation: ${rotation} 2s infinite linear;
|
3303
3601
|
`;
|
3602
|
+
const MemoizedUIDInput = React.memo(UIDInput);
|
3304
3603
|
const md = new Markdown({
|
3305
3604
|
html: true,
|
3306
3605
|
// Enable HTML tags in source
|
@@ -3488,8 +3787,7 @@ const Wrapper = styled.div`
|
|
3488
3787
|
`;
|
3489
3788
|
var listRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]\s|[*+-]\s|(\d+)([.)]))(\s*)/, emptyListRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]|[*+-]|(\d+)[.)])(\s*)$/, unorderedListRE = /[*+-]\s/;
|
3490
3789
|
function newlineAndIndentContinueMarkdownList(cm) {
|
3491
|
-
if (cm.getOption("disableInput"))
|
3492
|
-
return CodeMirror.Pass;
|
3790
|
+
if (cm.getOption("disableInput")) return CodeMirror.Pass;
|
3493
3791
|
var ranges = cm.listSelections(), replacements = [];
|
3494
3792
|
for (var i = 0; i < ranges.length; i++) {
|
3495
3793
|
var pos = ranges[i].head;
|
@@ -3523,8 +3821,7 @@ function newlineAndIndentContinueMarkdownList(cm) {
|
|
3523
3821
|
var numbered = !(unorderedListRE.test(match[2]) || match[2].indexOf(">") >= 0);
|
3524
3822
|
var bullet = numbered ? parseInt(match[3], 10) + 1 + match[4] : match[2].replace("x", " ");
|
3525
3823
|
replacements[i] = "\n" + indent + bullet + after;
|
3526
|
-
if (numbered)
|
3527
|
-
incrementRemainingMarkdownListNumbers(cm, pos);
|
3824
|
+
if (numbered) incrementRemainingMarkdownListNumbers(cm, pos);
|
3528
3825
|
}
|
3529
3826
|
}
|
3530
3827
|
cm.replaceSelections(replacements);
|
@@ -3542,10 +3839,8 @@ function incrementRemainingMarkdownListNumbers(cm, pos) {
|
|
3542
3839
|
var newNumber = parseInt(startItem[3], 10) + lookAhead - skipCount;
|
3543
3840
|
var nextNumber = parseInt(nextItem[3], 10), itemNumber = nextNumber;
|
3544
3841
|
if (startIndent === nextIndent && !isNaN(nextNumber)) {
|
3545
|
-
if (newNumber === nextNumber)
|
3546
|
-
|
3547
|
-
if (newNumber > nextNumber)
|
3548
|
-
itemNumber = newNumber + 1;
|
3842
|
+
if (newNumber === nextNumber) itemNumber = nextNumber + 1;
|
3843
|
+
if (newNumber > nextNumber) itemNumber = newNumber + 1;
|
3549
3844
|
cm.replaceRange(
|
3550
3845
|
nextLine.replace(listRE, nextIndent + itemNumber + nextItem[4] + nextItem[5]),
|
3551
3846
|
{
|
@@ -3558,10 +3853,8 @@ function incrementRemainingMarkdownListNumbers(cm, pos) {
|
|
3558
3853
|
}
|
3559
3854
|
);
|
3560
3855
|
} else {
|
3561
|
-
if (startIndent.length > nextIndent.length)
|
3562
|
-
|
3563
|
-
if (startIndent.length < nextIndent.length && lookAhead === 1)
|
3564
|
-
return;
|
3856
|
+
if (startIndent.length > nextIndent.length) return;
|
3857
|
+
if (startIndent.length < nextIndent.length && lookAhead === 1) return;
|
3565
3858
|
skipCount += 1;
|
3566
3859
|
}
|
3567
3860
|
}
|
@@ -3635,7 +3928,7 @@ const Editor = React.forwardRef(
|
|
3635
3928
|
[editorRef]
|
3636
3929
|
);
|
3637
3930
|
return /* @__PURE__ */ jsxs(EditorAndPreviewWrapper, { children: [
|
3638
|
-
/* @__PURE__ */ jsx(EditorStylesContainer, { isExpandMode, disabled: disabled || isPreviewMode, children: /* @__PURE__ */ jsx("textarea", { ref: textareaRef }) }),
|
3931
|
+
/* @__PURE__ */ jsx(EditorStylesContainer, { $isExpandMode: isExpandMode, $disabled: disabled || isPreviewMode, children: /* @__PURE__ */ jsx("textarea", { ref: textareaRef }) }),
|
3639
3932
|
isPreviewMode && /* @__PURE__ */ jsx(PreviewWysiwyg, { data: value })
|
3640
3933
|
] });
|
3641
3934
|
}
|
@@ -3645,7 +3938,7 @@ const EditorAndPreviewWrapper = styled.div`
|
|
3645
3938
|
height: calc(100% - 48px);
|
3646
3939
|
`;
|
3647
3940
|
const EditorStylesContainer = styled.div`
|
3648
|
-
cursor: ${({ disabled }) => disabled ? "not-allowed !important" : "auto"};
|
3941
|
+
cursor: ${({ $disabled }) => $disabled ? "not-allowed !important" : "auto"};
|
3649
3942
|
height: 100%;
|
3650
3943
|
/* BASICS */
|
3651
3944
|
.CodeMirror-placeholder {
|
@@ -3655,7 +3948,7 @@ const EditorStylesContainer = styled.div`
|
|
3655
3948
|
.CodeMirror {
|
3656
3949
|
/* Set height, width, borders, and global font properties here */
|
3657
3950
|
font-size: 1.4rem;
|
3658
|
-
height: ${({ isExpandMode }) => isExpandMode ? "100%" : "410px"}; // 512px(total height) - 48px (header) - 52px(footer) - 2px border
|
3951
|
+
height: ${({ $isExpandMode }) => $isExpandMode ? "100%" : "410px"}; // 512px(total height) - 48px (header) - 52px(footer) - 2px border
|
3659
3952
|
color: ${({ theme }) => theme.colors.neutral800};
|
3660
3953
|
direction: ltr;
|
3661
3954
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell,
|
@@ -4033,7 +4326,7 @@ const EditorLayout = ({
|
|
4033
4326
|
justifyContent: "flex-end",
|
4034
4327
|
shrink: 0,
|
4035
4328
|
width: "100%",
|
4036
|
-
children: /* @__PURE__ */ jsxs(ExpandButton$1, { onClick: onCollapse, children: [
|
4329
|
+
children: /* @__PURE__ */ jsxs(ExpandButton$1, { onClick: onCollapse, variant: "tertiary", size: "M", children: [
|
4037
4330
|
/* @__PURE__ */ jsx(Typography, { children: formatMessage({
|
4038
4331
|
id: "components.Wysiwyg.collapse",
|
4039
4332
|
defaultMessage: "Collapse"
|
@@ -4051,12 +4344,14 @@ const EditorLayout = ({
|
|
4051
4344
|
) }) });
|
4052
4345
|
}
|
4053
4346
|
return /* @__PURE__ */ jsx(
|
4054
|
-
|
4347
|
+
Flex,
|
4055
4348
|
{
|
4056
4349
|
borderColor: error ? "danger600" : "neutral200",
|
4057
4350
|
borderStyle: "solid",
|
4058
4351
|
borderWidth: "1px",
|
4059
4352
|
hasRadius: true,
|
4353
|
+
direction: "column",
|
4354
|
+
alignItems: "stretch",
|
4060
4355
|
children
|
4061
4356
|
}
|
4062
4357
|
);
|
@@ -4067,11 +4362,19 @@ const ExpandWrapper = styled(Flex)`
|
|
4067
4362
|
const BoxWithBorder = styled(Box)`
|
4068
4363
|
border-right: 1px solid ${({ theme }) => theme.colors.neutral200};
|
4069
4364
|
`;
|
4070
|
-
const ExpandButton$1 = styled(
|
4365
|
+
const ExpandButton$1 = styled(Button)`
|
4071
4366
|
background-color: transparent;
|
4072
4367
|
border: none;
|
4073
4368
|
align-items: center;
|
4074
4369
|
|
4370
|
+
& > span {
|
4371
|
+
display: flex;
|
4372
|
+
justify-content: space-between;
|
4373
|
+
align-items: center;
|
4374
|
+
width: 100%;
|
4375
|
+
font-weight: ${({ theme }) => theme.fontWeights.regular};
|
4376
|
+
}
|
4377
|
+
|
4075
4378
|
svg {
|
4076
4379
|
margin-left: ${({ theme }) => `${theme.spaces[2]}`};
|
4077
4380
|
|
@@ -4338,42 +4641,28 @@ const quoteAndCodeHandler = (editor, markdownType) => {
|
|
4338
4641
|
insertWithoutTextToEdit(editor, markdownType, line, contentLength);
|
4339
4642
|
}
|
4340
4643
|
};
|
4341
|
-
const CustomIconButton = styled(IconButton)`
|
4342
|
-
padding: ${({ theme }) => theme.spaces[2]};
|
4343
|
-
/* Trick to prevent the outline from overflowing because of the general outline-offset */
|
4344
|
-
outline-offset: -2px !important;
|
4345
|
-
|
4346
|
-
svg {
|
4347
|
-
width: 1.8rem;
|
4348
|
-
height: 1.8rem;
|
4349
|
-
}
|
4350
|
-
`;
|
4351
|
-
const CustomLinkIconButton = styled(CustomIconButton)`
|
4352
|
-
svg {
|
4353
|
-
width: 0.8rem;
|
4354
|
-
height: 0.8rem;
|
4355
|
-
}
|
4356
|
-
`;
|
4357
4644
|
const MainButtons = styled(IconButtonGroup)`
|
4358
4645
|
margin-left: ${({ theme }) => theme.spaces[4]};
|
4359
4646
|
`;
|
4360
4647
|
const MoreButton = styled(IconButton)`
|
4361
4648
|
margin: ${({ theme }) => `0 ${theme.spaces[2]}`};
|
4362
|
-
padding: ${({ theme }) => theme.spaces[2]};
|
4363
|
-
|
4364
|
-
svg {
|
4365
|
-
width: 1.8rem;
|
4366
|
-
height: 1.8rem;
|
4367
|
-
}
|
4368
4649
|
`;
|
4369
4650
|
const IconButtonGroupMargin = styled(IconButtonGroup)`
|
4370
4651
|
margin-right: ${({ theme }) => `${theme.spaces[2]}`};
|
4371
4652
|
`;
|
4372
|
-
const ExpandButton = styled(
|
4653
|
+
const ExpandButton = styled(Button)`
|
4373
4654
|
background-color: transparent;
|
4374
4655
|
border: none;
|
4375
4656
|
align-items: center;
|
4376
4657
|
|
4658
|
+
& > span {
|
4659
|
+
display: flex;
|
4660
|
+
justify-content: space-between;
|
4661
|
+
align-items: center;
|
4662
|
+
width: 100%;
|
4663
|
+
font-weight: ${({ theme }) => theme.fontWeights.regular};
|
4664
|
+
}
|
4665
|
+
|
4377
4666
|
svg {
|
4378
4667
|
margin-left: ${({ theme }) => `${theme.spaces[2]}`};
|
4379
4668
|
path {
|
@@ -4385,8 +4674,8 @@ const ExpandButton = styled(BaseButton)`
|
|
4385
4674
|
`;
|
4386
4675
|
const WysiwygFooter = ({ onToggleExpand }) => {
|
4387
4676
|
const { formatMessage } = useIntl();
|
4388
|
-
return /* @__PURE__ */ jsx(Box, { padding: 2, background: "neutral100", borderRadius: `0 0 0.4rem 0.4rem`, children: /* @__PURE__ */ jsx(Flex, { justifyContent: "flex-end", alignItems: "flex-end", children: /* @__PURE__ */ jsxs(ExpandButton, { id: "expand", onClick: onToggleExpand, children: [
|
4389
|
-
/* @__PURE__ */ jsx(Typography, { children: formatMessage({
|
4677
|
+
return /* @__PURE__ */ jsx(Box, { padding: 2, background: "neutral100", borderRadius: `0 0 0.4rem 0.4rem`, children: /* @__PURE__ */ jsx(Flex, { justifyContent: "flex-end", alignItems: "flex-end", children: /* @__PURE__ */ jsxs(ExpandButton, { id: "expand", onClick: onToggleExpand, variant: "tertiary", size: "M", children: [
|
4678
|
+
/* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: formatMessage({
|
4390
4679
|
id: "components.WysiwygBottomControls.fullscreen",
|
4391
4680
|
defaultMessage: "Expand"
|
4392
4681
|
}) }),
|
@@ -4408,7 +4697,7 @@ const WysiwygNav = ({
|
|
4408
4697
|
id: "components.Wysiwyg.selectOptions.title",
|
4409
4698
|
defaultMessage: "Add a title"
|
4410
4699
|
});
|
4411
|
-
|
4700
|
+
React.useRef(null);
|
4412
4701
|
const handleTogglePopover = () => {
|
4413
4702
|
setVisiblePopover((prev) => !prev);
|
4414
4703
|
};
|
@@ -4421,21 +4710,30 @@ const WysiwygNav = ({
|
|
4421
4710
|
justifyContent: "space-between",
|
4422
4711
|
borderRadius: `0.4rem 0.4rem 0 0`,
|
4423
4712
|
children: [
|
4424
|
-
/* @__PURE__ */ jsxs(
|
4425
|
-
/* @__PURE__ */
|
4426
|
-
|
4427
|
-
|
4428
|
-
|
4429
|
-
|
4430
|
-
|
4431
|
-
|
4432
|
-
|
4713
|
+
/* @__PURE__ */ jsxs(Flex, { children: [
|
4714
|
+
/* @__PURE__ */ jsx(Field.Root, { children: /* @__PURE__ */ jsxs(
|
4715
|
+
SingleSelect,
|
4716
|
+
{
|
4717
|
+
disabled: true,
|
4718
|
+
placeholder: selectPlaceholder,
|
4719
|
+
"aria-label": selectPlaceholder,
|
4720
|
+
size: "S",
|
4721
|
+
children: [
|
4722
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "h1", children: "h1" }),
|
4723
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "h2", children: "h2" }),
|
4724
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "h3", children: "h3" }),
|
4725
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "h4", children: "h4" }),
|
4726
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "h5", children: "h5" }),
|
4727
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "h6", children: "h6" })
|
4728
|
+
]
|
4729
|
+
}
|
4730
|
+
) }),
|
4433
4731
|
/* @__PURE__ */ jsxs(MainButtons, { children: [
|
4434
|
-
/* @__PURE__ */ jsx(
|
4435
|
-
/* @__PURE__ */ jsx(
|
4436
|
-
/* @__PURE__ */ jsx(
|
4732
|
+
/* @__PURE__ */ jsx(IconButton, { disabled: true, label: "Bold", name: "Bold", children: /* @__PURE__ */ jsx(Bold, {}) }),
|
4733
|
+
/* @__PURE__ */ jsx(IconButton, { disabled: true, label: "Italic", name: "Italic", children: /* @__PURE__ */ jsx(Italic, {}) }),
|
4734
|
+
/* @__PURE__ */ jsx(IconButton, { disabled: true, label: "Underline", name: "Underline", children: /* @__PURE__ */ jsx(Underline, {}) })
|
4437
4735
|
] }),
|
4438
|
-
/* @__PURE__ */ jsx(MoreButton, { disabled: true, label: "More",
|
4736
|
+
/* @__PURE__ */ jsx(MoreButton, { disabled: true, label: "More", children: /* @__PURE__ */ jsx(More, {}) })
|
4439
4737
|
] }),
|
4440
4738
|
!isExpandMode && /* @__PURE__ */ jsx(Button, { onClick: onTogglePreviewMode, variant: "tertiary", children: formatMessage({
|
4441
4739
|
id: "components.Wysiwyg.ToggleMode.markdown-mode",
|
@@ -4453,14 +4751,14 @@ const WysiwygNav = ({
|
|
4453
4751
|
justifyContent: "space-between",
|
4454
4752
|
borderRadius: `0.4rem 0.4rem 0 0`,
|
4455
4753
|
children: [
|
4456
|
-
/* @__PURE__ */ jsxs(
|
4457
|
-
/* @__PURE__ */ jsxs(
|
4754
|
+
/* @__PURE__ */ jsxs(Flex, { children: [
|
4755
|
+
/* @__PURE__ */ jsx(Field.Root, { children: /* @__PURE__ */ jsxs(
|
4458
4756
|
SingleSelect,
|
4459
4757
|
{
|
4460
4758
|
placeholder: selectPlaceholder,
|
4461
|
-
label: selectPlaceholder,
|
4462
|
-
size: "S",
|
4759
|
+
"aria-label": selectPlaceholder,
|
4463
4760
|
onChange: (value) => onActionClick(value, editorRef),
|
4761
|
+
size: "S",
|
4464
4762
|
children: [
|
4465
4763
|
/* @__PURE__ */ jsx(SingleSelectOption, { value: "h1", children: "h1" }),
|
4466
4764
|
/* @__PURE__ */ jsx(SingleSelectOption, { value: "h2", children: "h2" }),
|
@@ -4470,117 +4768,103 @@ const WysiwygNav = ({
|
|
4470
4768
|
/* @__PURE__ */ jsx(SingleSelectOption, { value: "h6", children: "h6" })
|
4471
4769
|
]
|
4472
4770
|
}
|
4473
|
-
),
|
4771
|
+
) }),
|
4474
4772
|
/* @__PURE__ */ jsxs(MainButtons, { children: [
|
4773
|
+
/* @__PURE__ */ jsx(IconButton, { onClick: () => onActionClick("Bold", editorRef), label: "Bold", name: "Bold", children: /* @__PURE__ */ jsx(Bold, {}) }),
|
4475
4774
|
/* @__PURE__ */ jsx(
|
4476
|
-
|
4477
|
-
{
|
4478
|
-
onClick: () => onActionClick("Bold", editorRef),
|
4479
|
-
label: "Bold",
|
4480
|
-
name: "Bold",
|
4481
|
-
icon: /* @__PURE__ */ jsx(Bold, {})
|
4482
|
-
}
|
4483
|
-
),
|
4484
|
-
/* @__PURE__ */ jsx(
|
4485
|
-
CustomIconButton,
|
4775
|
+
IconButton,
|
4486
4776
|
{
|
4487
4777
|
onClick: () => onActionClick("Italic", editorRef),
|
4488
4778
|
label: "Italic",
|
4489
4779
|
name: "Italic",
|
4490
|
-
|
4780
|
+
children: /* @__PURE__ */ jsx(Italic, {})
|
4491
4781
|
}
|
4492
4782
|
),
|
4493
4783
|
/* @__PURE__ */ jsx(
|
4494
|
-
|
4784
|
+
IconButton,
|
4495
4785
|
{
|
4496
4786
|
onClick: () => onActionClick("Underline", editorRef),
|
4497
4787
|
label: "Underline",
|
4498
4788
|
name: "Underline",
|
4499
|
-
|
4789
|
+
children: /* @__PURE__ */ jsx(Underline, {})
|
4500
4790
|
}
|
4501
4791
|
)
|
4502
4792
|
] }),
|
4503
|
-
/* @__PURE__ */
|
4504
|
-
MoreButton,
|
4505
|
-
{
|
4506
|
-
|
4507
|
-
|
4508
|
-
|
4509
|
-
|
4510
|
-
|
4511
|
-
|
4512
|
-
|
4513
|
-
|
4514
|
-
|
4515
|
-
|
4516
|
-
|
4517
|
-
|
4518
|
-
|
4519
|
-
|
4520
|
-
|
4521
|
-
|
4522
|
-
|
4523
|
-
|
4524
|
-
|
4525
|
-
|
4526
|
-
|
4527
|
-
|
4528
|
-
|
4529
|
-
|
4530
|
-
|
4531
|
-
|
4532
|
-
|
4533
|
-
|
4534
|
-
|
4535
|
-
|
4536
|
-
|
4537
|
-
|
4538
|
-
|
4539
|
-
|
4540
|
-
|
4541
|
-
|
4542
|
-
|
4543
|
-
|
4544
|
-
|
4545
|
-
|
4546
|
-
|
4547
|
-
|
4548
|
-
|
4549
|
-
|
4550
|
-
|
4551
|
-
|
4552
|
-
|
4553
|
-
|
4554
|
-
|
4555
|
-
|
4556
|
-
|
4557
|
-
|
4558
|
-
|
4559
|
-
|
4560
|
-
|
4561
|
-
|
4562
|
-
|
4563
|
-
|
4564
|
-
|
4565
|
-
|
4566
|
-
|
4567
|
-
|
4568
|
-
|
4569
|
-
|
4570
|
-
|
4571
|
-
|
4572
|
-
|
4573
|
-
|
4574
|
-
|
4575
|
-
|
4576
|
-
|
4577
|
-
|
4578
|
-
name: "Quote",
|
4579
|
-
icon: /* @__PURE__ */ jsx(Quotes, {})
|
4580
|
-
}
|
4581
|
-
)
|
4582
|
-
] })
|
4583
|
-
] }) })
|
4793
|
+
/* @__PURE__ */ jsxs(Popover.Root, { children: [
|
4794
|
+
/* @__PURE__ */ jsx(Popover.Trigger, { children: /* @__PURE__ */ jsx(MoreButton, { label: "More", children: /* @__PURE__ */ jsx(More, {}) }) }),
|
4795
|
+
/* @__PURE__ */ jsx(Popover.Content, { sideOffset: 12, children: /* @__PURE__ */ jsxs(Flex, { padding: 2, children: [
|
4796
|
+
/* @__PURE__ */ jsxs(IconButtonGroupMargin, { children: [
|
4797
|
+
/* @__PURE__ */ jsx(
|
4798
|
+
IconButton,
|
4799
|
+
{
|
4800
|
+
onClick: () => onActionClick("Strikethrough", editorRef, handleTogglePopover),
|
4801
|
+
label: "Strikethrough",
|
4802
|
+
name: "Strikethrough",
|
4803
|
+
children: /* @__PURE__ */ jsx(StrikeThrough, {})
|
4804
|
+
}
|
4805
|
+
),
|
4806
|
+
/* @__PURE__ */ jsx(
|
4807
|
+
IconButton,
|
4808
|
+
{
|
4809
|
+
onClick: () => onActionClick("BulletList", editorRef, handleTogglePopover),
|
4810
|
+
label: "BulletList",
|
4811
|
+
name: "BulletList",
|
4812
|
+
children: /* @__PURE__ */ jsx(BulletList, {})
|
4813
|
+
}
|
4814
|
+
),
|
4815
|
+
/* @__PURE__ */ jsx(
|
4816
|
+
IconButton,
|
4817
|
+
{
|
4818
|
+
onClick: () => onActionClick("NumberList", editorRef, handleTogglePopover),
|
4819
|
+
label: "NumberList",
|
4820
|
+
name: "NumberList",
|
4821
|
+
children: /* @__PURE__ */ jsx(NumberList, {})
|
4822
|
+
}
|
4823
|
+
)
|
4824
|
+
] }),
|
4825
|
+
/* @__PURE__ */ jsxs(IconButtonGroup, { children: [
|
4826
|
+
/* @__PURE__ */ jsx(
|
4827
|
+
IconButton,
|
4828
|
+
{
|
4829
|
+
onClick: () => onActionClick("Code", editorRef, handleTogglePopover),
|
4830
|
+
label: "Code",
|
4831
|
+
name: "Code",
|
4832
|
+
children: /* @__PURE__ */ jsx(Code, {})
|
4833
|
+
}
|
4834
|
+
),
|
4835
|
+
/* @__PURE__ */ jsx(
|
4836
|
+
IconButton,
|
4837
|
+
{
|
4838
|
+
onClick: () => {
|
4839
|
+
handleTogglePopover();
|
4840
|
+
onToggleMediaLib();
|
4841
|
+
},
|
4842
|
+
label: "Image",
|
4843
|
+
name: "Image",
|
4844
|
+
children: /* @__PURE__ */ jsx(Image$1, {})
|
4845
|
+
}
|
4846
|
+
),
|
4847
|
+
/* @__PURE__ */ jsx(
|
4848
|
+
IconButton,
|
4849
|
+
{
|
4850
|
+
onClick: () => onActionClick("Link", editorRef, handleTogglePopover),
|
4851
|
+
label: "Link",
|
4852
|
+
name: "Link",
|
4853
|
+
children: /* @__PURE__ */ jsx(Link$1, {})
|
4854
|
+
}
|
4855
|
+
),
|
4856
|
+
/* @__PURE__ */ jsx(
|
4857
|
+
IconButton,
|
4858
|
+
{
|
4859
|
+
onClick: () => onActionClick("Quote", editorRef, handleTogglePopover),
|
4860
|
+
label: "Quote",
|
4861
|
+
name: "Quote",
|
4862
|
+
children: /* @__PURE__ */ jsx(Quotes, {})
|
4863
|
+
}
|
4864
|
+
)
|
4865
|
+
] })
|
4866
|
+
] }) })
|
4867
|
+
] })
|
4584
4868
|
] }),
|
4585
4869
|
onTogglePreviewMode && /* @__PURE__ */ jsx(Button, { onClick: onTogglePreviewMode, variant: "tertiary", children: formatMessage({
|
4586
4870
|
id: "components.Wysiwyg.ToggleMode.preview-mode",
|
@@ -4590,19 +4874,6 @@ const WysiwygNav = ({
|
|
4590
4874
|
}
|
4591
4875
|
);
|
4592
4876
|
};
|
4593
|
-
const StyledFlex = styled(Flex)`
|
4594
|
-
/* Hide the label, every input needs a label. */
|
4595
|
-
label {
|
4596
|
-
border: 0;
|
4597
|
-
clip: rect(0 0 0 0);
|
4598
|
-
height: 1px;
|
4599
|
-
margin: -1px;
|
4600
|
-
overflow: hidden;
|
4601
|
-
padding: 0;
|
4602
|
-
position: absolute;
|
4603
|
-
width: 1px;
|
4604
|
-
}
|
4605
|
-
`;
|
4606
4877
|
const Wysiwyg = React.forwardRef(
|
4607
4878
|
({ hint, disabled, label, name: name2, placeholder, required, labelAction }, forwardedRef) => {
|
4608
4879
|
const field = useField(name2);
|
@@ -4667,9 +4938,9 @@ const Wysiwyg = React.forwardRef(
|
|
4667
4938
|
insertFile(editorRef, formattedFiles);
|
4668
4939
|
setMediaLibVisible(false);
|
4669
4940
|
};
|
4670
|
-
return /* @__PURE__ */ jsxs(Field, { name: name2, hint, error: field.error, required, children: [
|
4941
|
+
return /* @__PURE__ */ jsxs(Field.Root, { name: name2, hint, error: field.error, required, children: [
|
4671
4942
|
/* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
|
4672
|
-
/* @__PURE__ */ jsx(
|
4943
|
+
/* @__PURE__ */ jsx(Field.Label, { action: labelAction, children: label }),
|
4673
4944
|
/* @__PURE__ */ jsxs(
|
4674
4945
|
EditorLayout,
|
4675
4946
|
{
|
@@ -4710,24 +4981,29 @@ const Wysiwyg = React.forwardRef(
|
|
4710
4981
|
]
|
4711
4982
|
}
|
4712
4983
|
),
|
4713
|
-
/* @__PURE__ */ jsx(
|
4714
|
-
/* @__PURE__ */ jsx(
|
4984
|
+
/* @__PURE__ */ jsx(Field.Hint, {}),
|
4985
|
+
/* @__PURE__ */ jsx(Field.Error, {})
|
4715
4986
|
] }),
|
4716
4987
|
mediaLibVisible && // @ts-expect-error – TODO: fix this way of injecting because it's not really typeable without a registry.
|
4717
4988
|
/* @__PURE__ */ jsx(MediaLibraryDialog, { onClose: handleToggleMediaLib, onSelectAssets: handleSelectAssets })
|
4718
4989
|
] });
|
4719
4990
|
}
|
4720
4991
|
);
|
4992
|
+
const MemoizedWysiwyg = React.memo(Wysiwyg);
|
4721
4993
|
const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
|
4722
|
-
const { id } = useDoc();
|
4994
|
+
const { id, document: document2, collectionType } = useDoc();
|
4723
4995
|
const isFormDisabled = useForm("InputRenderer", (state) => state.disabled);
|
4724
4996
|
const isInDynamicZone = useDynamicZone("isInDynamicZone", (state) => state.isInDynamicZone);
|
4725
4997
|
const canCreateFields = useDocumentRBAC("InputRenderer", (rbac) => rbac.canCreateFields);
|
4726
4998
|
const canReadFields = useDocumentRBAC("InputRenderer", (rbac) => rbac.canReadFields);
|
4727
4999
|
const canUpdateFields = useDocumentRBAC("InputRenderer", (rbac) => rbac.canUpdateFields);
|
4728
5000
|
const canUserAction = useDocumentRBAC("InputRenderer", (rbac) => rbac.canUserAction);
|
4729
|
-
|
4730
|
-
|
5001
|
+
let idToCheck = id;
|
5002
|
+
if (collectionType === SINGLE_TYPES) {
|
5003
|
+
idToCheck = document2?.documentId;
|
5004
|
+
}
|
5005
|
+
const editableFields = idToCheck ? canUpdateFields : canCreateFields;
|
5006
|
+
const readableFields = idToCheck ? canReadFields : canCreateFields;
|
4731
5007
|
const canUserReadField = canUserAction(props.name, readableFields, props.type);
|
4732
5008
|
const canUserEditField = canUserAction(props.name, editableFields, props.type);
|
4733
5009
|
const fields = useStrapiApp("InputRenderer", (app) => app.fields);
|
@@ -4738,6 +5014,7 @@ const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
|
|
4738
5014
|
const {
|
4739
5015
|
edit: { components }
|
4740
5016
|
} = useDocLayout();
|
5017
|
+
const field = useField(props.name);
|
4741
5018
|
if (!visible) {
|
4742
5019
|
return null;
|
4743
5020
|
}
|
@@ -4748,7 +5025,7 @@ const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
|
|
4748
5025
|
if (attributeHasCustomFieldProperty(props.attribute)) {
|
4749
5026
|
const CustomInput = lazyComponentStore[props.attribute.customField];
|
4750
5027
|
if (CustomInput) {
|
4751
|
-
return /* @__PURE__ */ jsx(CustomInput, { ...props, hint, disabled: fieldIsDisabled });
|
5028
|
+
return /* @__PURE__ */ jsx(CustomInput, { ...props, ...field, hint, disabled: fieldIsDisabled });
|
4752
5029
|
}
|
4753
5030
|
return /* @__PURE__ */ jsx(
|
4754
5031
|
InputRenderer$1,
|
@@ -4767,10 +5044,10 @@ const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
|
|
4767
5044
|
}
|
4768
5045
|
switch (props.type) {
|
4769
5046
|
case "blocks":
|
4770
|
-
return /* @__PURE__ */ jsx(
|
5047
|
+
return /* @__PURE__ */ jsx(MemoizedBlocksInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
|
4771
5048
|
case "component":
|
4772
5049
|
return /* @__PURE__ */ jsx(
|
4773
|
-
|
5050
|
+
MemoizedComponentInput,
|
4774
5051
|
{
|
4775
5052
|
...props,
|
4776
5053
|
hint,
|
@@ -4782,11 +5059,11 @@ const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
|
|
4782
5059
|
case "dynamiczone":
|
4783
5060
|
return /* @__PURE__ */ jsx(DynamicZone, { ...props, hint, disabled: fieldIsDisabled });
|
4784
5061
|
case "relation":
|
4785
|
-
return /* @__PURE__ */ jsx(
|
5062
|
+
return /* @__PURE__ */ jsx(MemoizedRelationsField, { ...props, hint, disabled: fieldIsDisabled });
|
4786
5063
|
case "richtext":
|
4787
|
-
return /* @__PURE__ */ jsx(
|
5064
|
+
return /* @__PURE__ */ jsx(MemoizedWysiwyg, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
|
4788
5065
|
case "uid":
|
4789
|
-
return /* @__PURE__ */ jsx(
|
5066
|
+
return /* @__PURE__ */ jsx(MemoizedUIDInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
|
4790
5067
|
case "enumeration":
|
4791
5068
|
return /* @__PURE__ */ jsx(
|
4792
5069
|
InputRenderer$1,
|
@@ -4818,7 +5095,9 @@ const useFieldHint = (hint = void 0, attribute) => {
|
|
4818
5095
|
if (!maximum && !minimum) {
|
4819
5096
|
return hint;
|
4820
5097
|
}
|
4821
|
-
const units = !["biginteger", "integer", "number"].includes(
|
5098
|
+
const units = !["biginteger", "integer", "number", "dynamiczone", "component"].includes(
|
5099
|
+
attribute.type
|
5100
|
+
) ? formatMessage(
|
4822
5101
|
{
|
4823
5102
|
id: "content-manager.form.Input.hint.character.unit",
|
4824
5103
|
defaultMessage: "{maxValue, plural, one { character} other { characters}}"
|
@@ -4858,6 +5137,7 @@ const getMinMax = (attribute) => {
|
|
4858
5137
|
return { maximum: void 0, minimum: void 0 };
|
4859
5138
|
}
|
4860
5139
|
};
|
5140
|
+
const MemoizedInputRenderer = memo(InputRenderer);
|
4861
5141
|
const DynamicComponent = ({
|
4862
5142
|
componentUid,
|
4863
5143
|
disabled,
|
@@ -4871,7 +5151,6 @@ const DynamicComponent = ({
|
|
4871
5151
|
dynamicComponentsByCategory = {},
|
4872
5152
|
onAddComponent
|
4873
5153
|
}) => {
|
4874
|
-
const [isOpen, setIsOpen] = React.useState(true);
|
4875
5154
|
const { formatMessage } = useIntl();
|
4876
5155
|
const formValues = useForm("DynamicComponent", (state) => state.values);
|
4877
5156
|
const {
|
@@ -4880,7 +5159,7 @@ const DynamicComponent = ({
|
|
4880
5159
|
const title = React.useMemo(() => {
|
4881
5160
|
const { mainField } = components[componentUid]?.settings ?? { mainField: "id" };
|
4882
5161
|
const mainFieldValue = getIn(formValues, `${name2}.${index}.${mainField}`);
|
4883
|
-
const displayedValue = mainField === "id" ? "" : String(mainFieldValue).trim();
|
5162
|
+
const displayedValue = mainField === "id" || !mainFieldValue ? "" : String(mainFieldValue).trim();
|
4884
5163
|
const mainValue = displayedValue.length > 0 ? `- ${displayedValue}` : displayedValue;
|
4885
5164
|
return mainValue;
|
4886
5165
|
}, [componentUid, components, formValues, name2, index]);
|
@@ -4891,9 +5170,6 @@ const DynamicComponent = ({
|
|
4891
5170
|
) ?? { icon: null, displayName: null };
|
4892
5171
|
return { icon: icon2, displayName: displayName2 };
|
4893
5172
|
}, [componentUid, dynamicComponentsByCategory]);
|
4894
|
-
const handleToggle = () => {
|
4895
|
-
setIsOpen((s) => !s);
|
4896
|
-
};
|
4897
5173
|
const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop(!disabled, {
|
4898
5174
|
type: `${ItemTypes.DYNAMIC_ZONE}_${name2}`,
|
4899
5175
|
index,
|
@@ -4910,12 +5186,20 @@ const DynamicComponent = ({
|
|
4910
5186
|
React.useEffect(() => {
|
4911
5187
|
dragPreviewRef(getEmptyImage(), { captureDraggingState: false });
|
4912
5188
|
}, [dragPreviewRef, index]);
|
5189
|
+
const accordionValue = React.useId();
|
5190
|
+
const { value = [], rawError } = useField(`${name2}.${index}`);
|
5191
|
+
const [collapseToOpen, setCollapseToOpen] = React.useState("");
|
5192
|
+
React.useEffect(() => {
|
5193
|
+
if (rawError && value) {
|
5194
|
+
setCollapseToOpen(accordionValue);
|
5195
|
+
}
|
5196
|
+
}, [rawError, value, accordionValue]);
|
4913
5197
|
const composedBoxRefs = useComposedRefs(boxRef, dropRef);
|
4914
|
-
const accordionActions = disabled ? null : /* @__PURE__ */ jsxs(
|
5198
|
+
const accordionActions = disabled ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
|
4915
5199
|
/* @__PURE__ */ jsx(
|
4916
|
-
|
5200
|
+
IconButton,
|
4917
5201
|
{
|
4918
|
-
|
5202
|
+
variant: "ghost",
|
4919
5203
|
label: formatMessage(
|
4920
5204
|
{
|
4921
5205
|
id: getTranslation("components.DynamicZone.delete-label"),
|
@@ -4930,10 +5214,7 @@ const DynamicComponent = ({
|
|
4930
5214
|
/* @__PURE__ */ jsx(
|
4931
5215
|
IconButton,
|
4932
5216
|
{
|
4933
|
-
|
4934
|
-
role: "button",
|
4935
|
-
borderWidth: 0,
|
4936
|
-
tabIndex: 0,
|
5217
|
+
variant: "ghost",
|
4937
5218
|
onClick: (e) => e.stopPropagation(),
|
4938
5219
|
"data-handler-id": handlerId,
|
4939
5220
|
ref: dragRef,
|
@@ -4948,7 +5229,7 @@ const DynamicComponent = ({
|
|
4948
5229
|
/* @__PURE__ */ jsxs(Menu.Root, { children: [
|
4949
5230
|
/* @__PURE__ */ jsxs(Menu.Trigger, { size: "S", endIcon: null, paddingLeft: 2, paddingRight: 2, children: [
|
4950
5231
|
/* @__PURE__ */ jsx(More, { "aria-hidden": true, focusable: false }),
|
4951
|
-
/* @__PURE__ */ jsx(VisuallyHidden, {
|
5232
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { tag: "span", children: formatMessage({
|
4952
5233
|
id: getTranslation("components.DynamicZone.more-actions"),
|
4953
5234
|
defaultMessage: "More actions"
|
4954
5235
|
}) })
|
@@ -4977,42 +5258,56 @@ const DynamicComponent = ({
|
|
4977
5258
|
] })
|
4978
5259
|
] })
|
4979
5260
|
] });
|
4980
|
-
|
5261
|
+
const accordionTitle = title ? `${displayName} ${title}` : displayName;
|
5262
|
+
return /* @__PURE__ */ jsxs(ComponentContainer, { tag: "li", width: "100%", children: [
|
4981
5263
|
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Rectangle, { background: "neutral200" }) }),
|
4982
|
-
/* @__PURE__ */ jsx(StyledBox, { ref: composedBoxRefs, hasRadius: true, children: isDragging ? /* @__PURE__ */ jsx(Preview, {}) : /* @__PURE__ */
|
4983
|
-
/* @__PURE__ */
|
4984
|
-
|
5264
|
+
/* @__PURE__ */ jsx(StyledBox, { ref: composedBoxRefs, hasRadius: true, children: isDragging ? /* @__PURE__ */ jsx(Preview, {}) : /* @__PURE__ */ jsx(Accordion.Root, { value: collapseToOpen, onValueChange: setCollapseToOpen, children: /* @__PURE__ */ jsxs(Accordion.Item, { value: accordionValue, children: [
|
5265
|
+
/* @__PURE__ */ jsxs(Accordion.Header, { children: [
|
5266
|
+
/* @__PURE__ */ jsx(
|
5267
|
+
Accordion.Trigger,
|
5268
|
+
{
|
5269
|
+
icon: icon && COMPONENT_ICONS[icon] ? COMPONENT_ICONS[icon] : COMPONENT_ICONS.dashboard,
|
5270
|
+
children: accordionTitle
|
5271
|
+
}
|
5272
|
+
),
|
5273
|
+
/* @__PURE__ */ jsx(Accordion.Actions, { children: accordionActions })
|
5274
|
+
] }),
|
5275
|
+
/* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsx(AccordionContentRadius, { background: "neutral0", children: /* @__PURE__ */ jsx(Box, { paddingLeft: 6, paddingRight: 6, paddingTop: 6, paddingBottom: 6, children: /* @__PURE__ */ jsx(Grid$1.Root, { gap: 4, children: components[componentUid]?.layout?.map((row, rowInd) => /* @__PURE__ */ jsx(
|
5276
|
+
Grid$1.Item,
|
4985
5277
|
{
|
4986
|
-
|
4987
|
-
|
4988
|
-
|
4989
|
-
|
4990
|
-
|
4991
|
-
|
4992
|
-
|
4993
|
-
|
4994
|
-
|
4995
|
-
|
4996
|
-
|
5278
|
+
col: 12,
|
5279
|
+
s: 12,
|
5280
|
+
xs: 12,
|
5281
|
+
direction: "column",
|
5282
|
+
alignItems: "stretch",
|
5283
|
+
children: /* @__PURE__ */ jsx(Grid$1.Root, { gap: 4, children: row.map(({ size, ...field }) => {
|
5284
|
+
const fieldName = `${name2}.${index}.${field.name}`;
|
5285
|
+
const fieldWithTranslatedLabel = {
|
5286
|
+
...field,
|
5287
|
+
label: formatMessage({
|
5288
|
+
id: `content-manager.components.${componentUid}.${field.name}`,
|
5289
|
+
defaultMessage: field.label
|
5290
|
+
})
|
5291
|
+
};
|
5292
|
+
return /* @__PURE__ */ jsx(
|
5293
|
+
Grid$1.Item,
|
5294
|
+
{
|
5295
|
+
col: size,
|
5296
|
+
s: 12,
|
5297
|
+
xs: 12,
|
5298
|
+
direction: "column",
|
5299
|
+
alignItems: "stretch",
|
5300
|
+
children: /* @__PURE__ */ jsx(MemoizedInputRenderer, { ...fieldWithTranslatedLabel, name: fieldName })
|
5301
|
+
},
|
5302
|
+
fieldName
|
5303
|
+
);
|
5304
|
+
}) })
|
5305
|
+
},
|
5306
|
+
rowInd
|
5307
|
+
)) }) }) }) })
|
5308
|
+
] }) }) })
|
4997
5309
|
] });
|
4998
5310
|
};
|
4999
|
-
const ActionsFlex = styled(Flex)`
|
5000
|
-
/*
|
5001
|
-
we need to remove the background from the button but we can't
|
5002
|
-
wrap the element in styled because it breaks the forwardedAs which
|
5003
|
-
we need for drag handler to work on firefox
|
5004
|
-
*/
|
5005
|
-
div[role='button'] {
|
5006
|
-
background: transparent;
|
5007
|
-
}
|
5008
|
-
`;
|
5009
|
-
const IconButtonCustom = styled(IconButton)`
|
5010
|
-
background-color: transparent;
|
5011
|
-
|
5012
|
-
svg path {
|
5013
|
-
fill: ${({ theme, expanded }) => expanded ? theme.colors.primary600 : theme.colors.neutral600};
|
5014
|
-
}
|
5015
|
-
`;
|
5016
5311
|
const StyledBox = styled(Box)`
|
5017
5312
|
> div:first-child {
|
5018
5313
|
box-shadow: ${({ theme }) => theme.shadows.tableShadow};
|
@@ -5083,7 +5378,7 @@ const [DynamicZoneProvider, useDynamicZone] = createContext(
|
|
5083
5378
|
);
|
5084
5379
|
const DynamicZone = ({
|
5085
5380
|
attribute,
|
5086
|
-
disabled,
|
5381
|
+
disabled: disabledProp,
|
5087
5382
|
hint,
|
5088
5383
|
label,
|
5089
5384
|
labelAction,
|
@@ -5093,7 +5388,8 @@ const DynamicZone = ({
|
|
5093
5388
|
const { max = Infinity, min = -Infinity } = attribute ?? {};
|
5094
5389
|
const [addComponentIsOpen, setAddComponentIsOpen] = React.useState(false);
|
5095
5390
|
const [liveText, setLiveText] = React.useState("");
|
5096
|
-
const { components } = useDoc();
|
5391
|
+
const { components, isLoading } = useDoc();
|
5392
|
+
const disabled = disabledProp || isLoading;
|
5097
5393
|
const { addFieldRow, removeFieldRow, moveFieldRow } = useForm(
|
5098
5394
|
"DynamicZone",
|
5099
5395
|
({ addFieldRow: addFieldRow2, removeFieldRow: removeFieldRow2, moveFieldRow: moveFieldRow2 }) => ({
|
@@ -5200,7 +5496,7 @@ const DynamicZone = ({
|
|
5200
5496
|
const handleRemoveComponent = (name22, currentIndex) => () => {
|
5201
5497
|
removeFieldRow(name22, currentIndex);
|
5202
5498
|
};
|
5203
|
-
const hasError = error !== void 0
|
5499
|
+
const hasError = error !== void 0;
|
5204
5500
|
const renderButtonLabel = () => {
|
5205
5501
|
if (addComponentIsOpen) {
|
5206
5502
|
return formatMessage({ id: "app.utils.close-label", defaultMessage: "Close" });
|
@@ -5301,19 +5597,19 @@ const DynamicZone = ({
|
|
5301
5597
|
] }) });
|
5302
5598
|
};
|
5303
5599
|
export {
|
5304
|
-
BlocksInput as B,
|
5305
|
-
ComponentInput as C,
|
5306
5600
|
DynamicZone as D,
|
5307
|
-
|
5601
|
+
MemoizedInputRenderer as M,
|
5308
5602
|
NotAllowedInput as N,
|
5309
|
-
UIDInput as U,
|
5310
|
-
Wysiwyg as W,
|
5311
5603
|
useDynamicZone as a,
|
5312
5604
|
useFieldHint as b,
|
5313
5605
|
createDefaultForm as c,
|
5606
|
+
MemoizedUIDInput as d,
|
5607
|
+
MemoizedWysiwyg as e,
|
5608
|
+
MemoizedComponentInput as f,
|
5609
|
+
MemoizedBlocksInput as g,
|
5314
5610
|
prepareTempKeys as p,
|
5315
5611
|
removeFieldsThatDontExistOnSchema as r,
|
5316
5612
|
transformDocument as t,
|
5317
5613
|
useLazyComponents as u
|
5318
5614
|
};
|
5319
|
-
//# sourceMappingURL=Field-
|
5615
|
+
//# sourceMappingURL=Field-D7dv2aUX.mjs.map
|