@strapi/content-manager 0.0.0-experimental.d1602f22dc638a4c3c5084965fd6126fff5e9d4f → 0.0.0-experimental.d2a56e52af31fcf0f0c582a5a2e58e310966e96b
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/dist/admin/chunks/{CardDragPreview-DwuraT0K.js → CardDragPreview-DwuraT0K.mjs} +1 -1
- package/dist/admin/chunks/CardDragPreview-DwuraT0K.mjs.map +1 -0
- package/dist/admin/chunks/{ComponentConfigurationPage-DXwOtpq1.js → ComponentConfigurationPage-CGn9IYeg.js} +6 -6
- package/dist/admin/chunks/{ComponentConfigurationPage-DXwOtpq1.js.map → ComponentConfigurationPage-CGn9IYeg.js.map} +1 -1
- package/dist/admin/chunks/{ComponentConfigurationPage-DhYZp4nN.js → ComponentConfigurationPage-DgYK4xW6.mjs} +9 -9
- package/dist/admin/chunks/ComponentConfigurationPage-DgYK4xW6.mjs.map +1 -0
- package/dist/admin/chunks/{ComponentIcon-BZcTc4rj.js → ComponentIcon-BZcTc4rj.mjs} +1 -1
- package/dist/admin/chunks/ComponentIcon-BZcTc4rj.mjs.map +1 -0
- package/dist/admin/chunks/{EditConfigurationPage-D0Ng758X.js → EditConfigurationPage-7w_-4jF4.js} +6 -6
- package/dist/admin/chunks/{EditConfigurationPage-D0Ng758X.js.map → EditConfigurationPage-7w_-4jF4.js.map} +1 -1
- package/dist/admin/chunks/{EditConfigurationPage-DDuPch5d.js → EditConfigurationPage-C05SwwH-.mjs} +9 -9
- package/dist/admin/chunks/EditConfigurationPage-C05SwwH-.mjs.map +1 -0
- package/dist/admin/chunks/EditViewPage-CVRJBOEv.mjs +318 -0
- package/dist/admin/chunks/EditViewPage-CVRJBOEv.mjs.map +1 -0
- package/dist/admin/chunks/EditViewPage-CuQfZJDf.js +341 -0
- package/dist/admin/chunks/EditViewPage-CuQfZJDf.js.map +1 -0
- package/dist/admin/chunks/{FieldTypeIcon-BY6MrVF4.js → FieldTypeIcon-BY6MrVF4.mjs} +1 -1
- package/dist/admin/chunks/FieldTypeIcon-BY6MrVF4.mjs.map +1 -0
- package/dist/admin/chunks/{Form-BEqiuSvQ.js → Form-BqNYRsCb.js} +5 -5
- package/dist/admin/chunks/{Form-BEqiuSvQ.js.map → Form-BqNYRsCb.js.map} +1 -1
- package/dist/admin/chunks/{Form-CZmB6JIg.js → Form-DaEnqAeV.mjs} +5 -5
- package/dist/admin/chunks/Form-DaEnqAeV.mjs.map +1 -0
- package/dist/admin/chunks/{History-CPYXgxkS.js → History-B7dGNfmx.mjs} +68 -15
- package/dist/admin/chunks/History-B7dGNfmx.mjs.map +1 -0
- package/dist/admin/chunks/{History-BlLKDZSw.js → History-CEoOna4w.js} +67 -14
- package/dist/admin/chunks/History-CEoOna4w.js.map +1 -0
- package/dist/admin/chunks/{Input-CLX3C5DI.js → Input-B3QUS9rv.mjs} +2273 -511
- package/dist/admin/chunks/Input-B3QUS9rv.mjs.map +1 -0
- package/dist/admin/chunks/{Input-DiR2Xfa7.js → Input-B8I0b9aD.js} +2284 -519
- package/dist/admin/chunks/Input-B8I0b9aD.js.map +1 -0
- package/dist/admin/chunks/{ListConfigurationPage-DdTp-HxB.js → ListConfigurationPage-BbjJweN-.js} +7 -7
- package/dist/admin/chunks/{ListConfigurationPage-DdTp-HxB.js.map → ListConfigurationPage-BbjJweN-.js.map} +1 -1
- package/dist/admin/chunks/{ListConfigurationPage-CNvotSqe.js → ListConfigurationPage-VtFQ5mOK.mjs} +8 -8
- package/dist/admin/chunks/ListConfigurationPage-VtFQ5mOK.mjs.map +1 -0
- package/dist/admin/chunks/{ListViewPage-MJNfQTp-.js → ListViewPage-Cg3zbT7Y.mjs} +5 -5
- package/dist/admin/chunks/ListViewPage-Cg3zbT7Y.mjs.map +1 -0
- package/dist/admin/chunks/{ListViewPage-BtXYjEYz.js → ListViewPage-CzUm2VJN.js} +8 -8
- package/dist/admin/chunks/{ListViewPage-BtXYjEYz.js.map → ListViewPage-CzUm2VJN.js.map} +1 -1
- package/dist/admin/chunks/{NoContentTypePage-CVvVpwj4.js → NoContentTypePage-FcLLn2Wt.js} +3 -2
- package/dist/admin/chunks/{NoContentTypePage-BJrZvYPY.js.map → NoContentTypePage-FcLLn2Wt.js.map} +1 -1
- package/dist/admin/chunks/{NoContentTypePage-BJrZvYPY.js → NoContentTypePage-NOf7Aq_E.mjs} +3 -2
- package/dist/admin/chunks/NoContentTypePage-NOf7Aq_E.mjs.map +1 -0
- package/dist/admin/chunks/{NoPermissionsPage-C5yWg70d.js → NoPermissionsPage-DmeyXtCk.js} +3 -2
- package/dist/admin/chunks/{NoPermissionsPage-BulvG4hB.js.map → NoPermissionsPage-DmeyXtCk.js.map} +1 -1
- package/dist/admin/chunks/{NoPermissionsPage-BulvG4hB.js → NoPermissionsPage-OVr9KG6L.mjs} +3 -2
- package/dist/admin/chunks/NoPermissionsPage-OVr9KG6L.mjs.map +1 -0
- package/dist/admin/chunks/Preview-BH9l1QXk.mjs +593 -0
- package/dist/admin/chunks/Preview-BH9l1QXk.mjs.map +1 -0
- package/dist/admin/chunks/Preview-BYKkpc11.js +615 -0
- package/dist/admin/chunks/Preview-BYKkpc11.js.map +1 -0
- package/dist/admin/chunks/{ar-DckYq_WK.js → ar-DckYq_WK.mjs} +1 -1
- package/dist/admin/chunks/ar-DckYq_WK.mjs.map +1 -0
- package/dist/admin/chunks/{ca-DviY7mRj.js → ca-DviY7mRj.mjs} +1 -1
- package/dist/admin/chunks/ca-DviY7mRj.mjs.map +1 -0
- package/dist/admin/chunks/{cs-C7OSYFQ7.js → cs-C7OSYFQ7.mjs} +1 -1
- package/dist/admin/chunks/cs-C7OSYFQ7.mjs.map +1 -0
- package/dist/admin/chunks/{de-5QRlDHyR.js → de-5QRlDHyR.mjs} +1 -1
- package/dist/admin/chunks/de-5QRlDHyR.mjs.map +1 -0
- package/dist/admin/chunks/{en-LfhocNG2.js → en-C2zEwS3-.mjs} +6 -1
- package/dist/admin/chunks/en-C2zEwS3-.mjs.map +1 -0
- package/dist/admin/chunks/{en-C1CjdAtC.js → en-G976DLsg.js} +6 -1
- package/dist/admin/chunks/{en-LfhocNG2.js.map → en-G976DLsg.js.map} +1 -1
- package/dist/admin/chunks/{es-DkoWSExG.js → es-DkoWSExG.mjs} +1 -1
- package/dist/admin/chunks/es-DkoWSExG.mjs.map +1 -0
- package/dist/admin/chunks/{eu-BG1xX7HK.js → eu-BG1xX7HK.mjs} +1 -1
- package/dist/admin/chunks/eu-BG1xX7HK.mjs.map +1 -0
- package/dist/admin/chunks/{fr-CFdRaRVj.js → fr-CFdRaRVj.mjs} +1 -1
- package/dist/admin/chunks/fr-CFdRaRVj.mjs.map +1 -0
- package/dist/admin/chunks/{gu-D5MMMXRs.js → gu-D5MMMXRs.mjs} +1 -1
- package/dist/admin/chunks/gu-D5MMMXRs.mjs.map +1 -0
- package/dist/admin/chunks/{hi-lp17SCjr.js → hi-lp17SCjr.mjs} +1 -1
- package/dist/admin/chunks/hi-lp17SCjr.mjs.map +1 -0
- package/dist/admin/chunks/{hooks-DMvik5y_.js → hooks-DMvik5y_.mjs} +1 -1
- package/dist/admin/chunks/hooks-DMvik5y_.mjs.map +1 -0
- package/dist/admin/chunks/{hu-CLka1U2C.js → hu-CLka1U2C.mjs} +1 -1
- package/dist/admin/chunks/hu-CLka1U2C.mjs.map +1 -0
- package/dist/admin/chunks/{id-USfY9m1g.js → id-USfY9m1g.mjs} +1 -1
- package/dist/admin/chunks/id-USfY9m1g.mjs.map +1 -0
- package/dist/admin/chunks/{index-BRlRBRLb.js → index-BE7PI9Wp.mjs} +273 -173
- package/dist/admin/chunks/index-BE7PI9Wp.mjs.map +1 -0
- package/dist/admin/chunks/{index-ZIwOPk6p.js → index-BwIhYBsG.js} +246 -142
- package/dist/admin/chunks/index-BwIhYBsG.js.map +1 -0
- package/dist/admin/chunks/{it-BAHrwmYS.js → it-BAHrwmYS.mjs} +1 -1
- package/dist/admin/chunks/it-BAHrwmYS.mjs.map +1 -0
- package/dist/admin/chunks/{ja-BWKmBJFT.js → ja-BWKmBJFT.mjs} +1 -1
- package/dist/admin/chunks/ja-BWKmBJFT.mjs.map +1 -0
- package/dist/admin/chunks/{ko-CgADGBNt.js → ko-CgADGBNt.mjs} +1 -1
- package/dist/admin/chunks/ko-CgADGBNt.mjs.map +1 -0
- package/dist/admin/chunks/{layout-B3-guCPG.js → layout-9zlUM9V3.mjs} +81 -7
- package/dist/admin/chunks/layout-9zlUM9V3.mjs.map +1 -0
- package/dist/admin/chunks/{layout-ameRNiAM.js → layout-Cr0HaJVS.js} +87 -13
- package/dist/admin/chunks/layout-Cr0HaJVS.js.map +1 -0
- package/dist/admin/chunks/{ml-CnhCfOn_.js → ml-CnhCfOn_.mjs} +1 -1
- package/dist/admin/chunks/ml-CnhCfOn_.mjs.map +1 -0
- package/dist/admin/chunks/{ms-Bh09NFff.js → ms-Bh09NFff.mjs} +1 -1
- package/dist/admin/chunks/ms-Bh09NFff.mjs.map +1 -0
- package/dist/admin/chunks/{nl-C8HYflTc.js → nl-C8HYflTc.mjs} +1 -1
- package/dist/admin/chunks/nl-C8HYflTc.mjs.map +1 -0
- package/dist/admin/chunks/{useDragAndDrop-gcqEJMnO.js → objects-BJTP843m.js} +73 -1
- package/dist/admin/chunks/objects-BJTP843m.js.map +1 -0
- package/dist/admin/chunks/{useDragAndDrop-HYwNDExe.js → objects-D2z-IJgu.mjs} +72 -2
- package/dist/admin/chunks/objects-D2z-IJgu.mjs.map +1 -0
- package/dist/admin/chunks/{pl-MFCZJZuZ.js → pl-MFCZJZuZ.mjs} +1 -1
- package/dist/admin/chunks/pl-MFCZJZuZ.mjs.map +1 -0
- package/dist/admin/chunks/{pt-BR-CcotyBGJ.js → pt-BR-CcotyBGJ.mjs} +1 -1
- package/dist/admin/chunks/pt-BR-CcotyBGJ.mjs.map +1 -0
- package/dist/admin/chunks/{pt-HbmgeiYO.js → pt-HbmgeiYO.mjs} +1 -1
- package/dist/admin/chunks/pt-HbmgeiYO.mjs.map +1 -0
- package/dist/admin/chunks/{ru-CB4BUyQp.js → ru-CB4BUyQp.mjs} +1 -1
- package/dist/admin/chunks/{ru-CB4BUyQp.js.map → ru-CB4BUyQp.mjs.map} +1 -1
- package/dist/admin/chunks/{sa-n_aPA-pU.js → sa-n_aPA-pU.mjs} +1 -1
- package/dist/admin/chunks/sa-n_aPA-pU.mjs.map +1 -0
- package/dist/admin/chunks/{sk-tn_BDjE2.js → sk-tn_BDjE2.mjs} +1 -1
- package/dist/admin/chunks/sk-tn_BDjE2.mjs.map +1 -0
- package/dist/admin/chunks/{sv-cq4ZrQRd.js → sv-cq4ZrQRd.mjs} +1 -1
- package/dist/admin/chunks/sv-cq4ZrQRd.mjs.map +1 -0
- package/dist/admin/chunks/{th-mUH7hEtc.js → th-mUH7hEtc.mjs} +1 -1
- package/dist/admin/chunks/th-mUH7hEtc.mjs.map +1 -0
- package/dist/admin/chunks/{tr-Yt38daxh.js → tr-Yt38daxh.mjs} +1 -1
- package/dist/admin/chunks/tr-Yt38daxh.mjs.map +1 -0
- package/dist/admin/chunks/uk-BtM6WnaE.mjs +313 -0
- package/dist/admin/chunks/uk-BtM6WnaE.mjs.map +1 -0
- package/dist/admin/chunks/uk-DB6OgySY.js +318 -0
- package/dist/admin/chunks/{en-C1CjdAtC.js.map → uk-DB6OgySY.js.map} +1 -1
- package/dist/admin/chunks/{relations-CmoFVrKj.js → usePrev-DgZBp9Oo.js} +18 -2
- package/dist/admin/chunks/usePrev-DgZBp9Oo.js.map +1 -0
- package/dist/admin/chunks/{relations-DYQAaXwZ.js → usePrev-PisKKvhT.mjs} +18 -4
- package/dist/admin/chunks/usePrev-PisKKvhT.mjs.map +1 -0
- package/dist/admin/chunks/{vi-CvBGlTjr.js → vi-CvBGlTjr.mjs} +1 -1
- package/dist/admin/chunks/vi-CvBGlTjr.mjs.map +1 -0
- package/dist/admin/chunks/{zh-BmF-sHaT.js → zh-BmF-sHaT.mjs} +1 -1
- package/dist/admin/chunks/zh-BmF-sHaT.mjs.map +1 -0
- package/dist/admin/chunks/{zh-Hans-CI0HKio3.js → zh-Hans-CI0HKio3.mjs} +1 -1
- package/dist/admin/chunks/{zh-Hans-CI0HKio3.js.map → zh-Hans-CI0HKio3.mjs.map} +1 -1
- package/dist/admin/index.js +2 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +2 -1
- package/dist/admin/index.mjs.map +1 -1
- package/dist/admin/src/components/InjectionZone.d.ts +7 -1
- package/dist/admin/src/content-manager.d.ts +4 -0
- package/dist/admin/src/features/DocumentContext.d.ts +53 -0
- package/dist/admin/src/features/DocumentRBAC.d.ts +3 -2
- package/dist/admin/src/hooks/useDocument.d.ts +2 -0
- package/dist/admin/src/hooks/useDocumentActions.d.ts +1 -0
- package/dist/admin/src/index.d.ts +1 -0
- package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +2 -1
- package/dist/admin/src/pages/EditView/components/EditorToolbarObserver.d.ts +11 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.d.ts +49 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/Relations/RelationModal.d.ts +8 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/{Relations.d.ts → Relations/Relations.d.ts} +8 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygNav.d.ts +1 -2
- package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +9 -3
- package/dist/admin/src/pages/EditView/components/InputRenderer.d.ts +7 -4
- package/dist/admin/src/preview/components/PreviewHeader.d.ts +1 -2
- package/dist/admin/src/preview/pages/Preview.d.ts +2 -0
- package/dist/server/index.js +1 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +1 -1
- package/dist/server/index.mjs.map +1 -1
- package/package.json +8 -8
- package/dist/admin/chunks/CardDragPreview-DwuraT0K.js.map +0 -1
- package/dist/admin/chunks/ComponentConfigurationPage-DhYZp4nN.js.map +0 -1
- package/dist/admin/chunks/ComponentIcon-BZcTc4rj.js.map +0 -1
- package/dist/admin/chunks/EditConfigurationPage-DDuPch5d.js.map +0 -1
- package/dist/admin/chunks/EditViewPage-jCZnUuCR.js +0 -265
- package/dist/admin/chunks/EditViewPage-jCZnUuCR.js.map +0 -1
- package/dist/admin/chunks/EditViewPage-zSnDwLz3.js +0 -288
- package/dist/admin/chunks/EditViewPage-zSnDwLz3.js.map +0 -1
- package/dist/admin/chunks/FieldTypeIcon-BY6MrVF4.js.map +0 -1
- package/dist/admin/chunks/Form-CZmB6JIg.js.map +0 -1
- package/dist/admin/chunks/History-BlLKDZSw.js.map +0 -1
- package/dist/admin/chunks/History-CPYXgxkS.js.map +0 -1
- package/dist/admin/chunks/Input-CLX3C5DI.js.map +0 -1
- package/dist/admin/chunks/Input-DiR2Xfa7.js.map +0 -1
- package/dist/admin/chunks/ListConfigurationPage-CNvotSqe.js.map +0 -1
- package/dist/admin/chunks/ListViewPage-MJNfQTp-.js.map +0 -1
- package/dist/admin/chunks/NoContentTypePage-CVvVpwj4.js.map +0 -1
- package/dist/admin/chunks/NoPermissionsPage-C5yWg70d.js.map +0 -1
- package/dist/admin/chunks/Preview-DEuQgQg2.js +0 -482
- package/dist/admin/chunks/Preview-DEuQgQg2.js.map +0 -1
- package/dist/admin/chunks/Preview-H74FQ9Cq.js +0 -504
- package/dist/admin/chunks/Preview-H74FQ9Cq.js.map +0 -1
- package/dist/admin/chunks/Relations-C8jbZPVK.js +0 -827
- package/dist/admin/chunks/Relations-C8jbZPVK.js.map +0 -1
- package/dist/admin/chunks/Relations-mxOUS7TJ.js +0 -853
- package/dist/admin/chunks/Relations-mxOUS7TJ.js.map +0 -1
- package/dist/admin/chunks/ar-DckYq_WK.js.map +0 -1
- package/dist/admin/chunks/ca-DviY7mRj.js.map +0 -1
- package/dist/admin/chunks/cs-C7OSYFQ7.js.map +0 -1
- package/dist/admin/chunks/de-5QRlDHyR.js.map +0 -1
- package/dist/admin/chunks/es-DkoWSExG.js.map +0 -1
- package/dist/admin/chunks/eu-BG1xX7HK.js.map +0 -1
- package/dist/admin/chunks/fr-CFdRaRVj.js.map +0 -1
- package/dist/admin/chunks/gu-D5MMMXRs.js.map +0 -1
- package/dist/admin/chunks/hi-lp17SCjr.js.map +0 -1
- package/dist/admin/chunks/hooks-DMvik5y_.js.map +0 -1
- package/dist/admin/chunks/hu-CLka1U2C.js.map +0 -1
- package/dist/admin/chunks/id-USfY9m1g.js.map +0 -1
- package/dist/admin/chunks/index-BRlRBRLb.js.map +0 -1
- package/dist/admin/chunks/index-ZIwOPk6p.js.map +0 -1
- package/dist/admin/chunks/it-BAHrwmYS.js.map +0 -1
- package/dist/admin/chunks/ja-BWKmBJFT.js.map +0 -1
- package/dist/admin/chunks/ko-CgADGBNt.js.map +0 -1
- package/dist/admin/chunks/layout-B3-guCPG.js.map +0 -1
- package/dist/admin/chunks/layout-ameRNiAM.js.map +0 -1
- package/dist/admin/chunks/ml-CnhCfOn_.js.map +0 -1
- package/dist/admin/chunks/ms-Bh09NFff.js.map +0 -1
- package/dist/admin/chunks/nl-C8HYflTc.js.map +0 -1
- package/dist/admin/chunks/objects-C3EebVVe.js +0 -76
- package/dist/admin/chunks/objects-C3EebVVe.js.map +0 -1
- package/dist/admin/chunks/objects-wl73iEma.js +0 -73
- package/dist/admin/chunks/objects-wl73iEma.js.map +0 -1
- package/dist/admin/chunks/pl-MFCZJZuZ.js.map +0 -1
- package/dist/admin/chunks/pt-BR-CcotyBGJ.js.map +0 -1
- package/dist/admin/chunks/pt-HbmgeiYO.js.map +0 -1
- package/dist/admin/chunks/relations-CmoFVrKj.js.map +0 -1
- package/dist/admin/chunks/relations-DYQAaXwZ.js.map +0 -1
- package/dist/admin/chunks/sa-n_aPA-pU.js.map +0 -1
- package/dist/admin/chunks/sk-tn_BDjE2.js.map +0 -1
- package/dist/admin/chunks/sv-cq4ZrQRd.js.map +0 -1
- package/dist/admin/chunks/th-mUH7hEtc.js.map +0 -1
- package/dist/admin/chunks/tr-Yt38daxh.js.map +0 -1
- package/dist/admin/chunks/uk-B24MoTVg.js +0 -145
- package/dist/admin/chunks/uk-B24MoTVg.js.map +0 -1
- package/dist/admin/chunks/uk-Cpgmm7gE.js +0 -140
- package/dist/admin/chunks/uk-Cpgmm7gE.js.map +0 -1
- package/dist/admin/chunks/useDragAndDrop-HYwNDExe.js.map +0 -1
- package/dist/admin/chunks/useDragAndDrop-gcqEJMnO.js.map +0 -1
- package/dist/admin/chunks/usePrev-Bjw2dhmq.js +0 -18
- package/dist/admin/chunks/usePrev-Bjw2dhmq.js.map +0 -1
- package/dist/admin/chunks/usePrev-DIYl-IAL.js +0 -21
- package/dist/admin/chunks/usePrev-DIYl-IAL.js.map +0 -1
- package/dist/admin/chunks/vi-CvBGlTjr.js.map +0 -1
- package/dist/admin/chunks/zh-BmF-sHaT.js.map +0 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/utils/prismLanguages.d.ts +0 -0
- package/dist/admin/src/preview/components/PreviewContent.d.ts +0 -3
@@ -6,23 +6,71 @@ var strapiAdmin = require('@strapi/admin/strapi-admin');
|
|
6
6
|
var designSystem = require('@strapi/design-system');
|
7
7
|
var Icons = require('@strapi/icons');
|
8
8
|
var reactIntl = require('react-intl');
|
9
|
-
var index = require('./index-
|
9
|
+
var index = require('./index-BwIhYBsG.js');
|
10
10
|
var styledComponents = require('styled-components');
|
11
11
|
var slate = require('slate');
|
12
12
|
var slateHistory = require('slate-history');
|
13
13
|
var slateReact = require('slate-react');
|
14
14
|
var Prism = require('prismjs');
|
15
15
|
require('prismjs/themes/prism-solarizedlight.css');
|
16
|
-
|
17
|
-
|
16
|
+
require('prismjs/components/prism-asmatmel');
|
17
|
+
require('prismjs/components/prism-bash');
|
18
|
+
require('prismjs/components/prism-basic');
|
19
|
+
require('prismjs/components/prism-c');
|
20
|
+
require('prismjs/components/prism-clojure');
|
21
|
+
require('prismjs/components/prism-cobol');
|
22
|
+
require('prismjs/components/prism-cpp');
|
23
|
+
require('prismjs/components/prism-csharp');
|
24
|
+
require('prismjs/components/prism-dart');
|
25
|
+
require('prismjs/components/prism-docker');
|
26
|
+
require('prismjs/components/prism-elixir');
|
27
|
+
require('prismjs/components/prism-erlang');
|
28
|
+
require('prismjs/components/prism-fortran');
|
29
|
+
require('prismjs/components/prism-fsharp');
|
30
|
+
require('prismjs/components/prism-go');
|
31
|
+
require('prismjs/components/prism-graphql');
|
32
|
+
require('prismjs/components/prism-groovy');
|
33
|
+
require('prismjs/components/prism-haskell');
|
34
|
+
require('prismjs/components/prism-haxe');
|
35
|
+
require('prismjs/components/prism-ini');
|
36
|
+
require('prismjs/components/prism-java');
|
37
|
+
require('prismjs/components/prism-javascript');
|
38
|
+
require('prismjs/components/prism-jsx');
|
39
|
+
require('prismjs/components/prism-json');
|
40
|
+
require('prismjs/components/prism-julia');
|
41
|
+
require('prismjs/components/prism-kotlin');
|
42
|
+
require('prismjs/components/prism-latex');
|
43
|
+
require('prismjs/components/prism-lua');
|
44
|
+
require('prismjs/components/prism-markdown');
|
45
|
+
require('prismjs/components/prism-matlab');
|
46
|
+
require('prismjs/components/prism-makefile');
|
47
|
+
require('prismjs/components/prism-objectivec');
|
48
|
+
require('prismjs/components/prism-perl');
|
49
|
+
require('prismjs/components/prism-php');
|
50
|
+
require('prismjs/components/prism-powershell');
|
51
|
+
require('prismjs/components/prism-python');
|
52
|
+
require('prismjs/components/prism-r');
|
53
|
+
require('prismjs/components/prism-ruby');
|
54
|
+
require('prismjs/components/prism-rust');
|
55
|
+
require('prismjs/components/prism-sas');
|
56
|
+
require('prismjs/components/prism-scala');
|
57
|
+
require('prismjs/components/prism-scheme');
|
58
|
+
require('prismjs/components/prism-sql');
|
59
|
+
require('prismjs/components/prism-stata');
|
60
|
+
require('prismjs/components/prism-swift');
|
61
|
+
require('prismjs/components/prism-typescript');
|
62
|
+
require('prismjs/components/prism-tsx');
|
63
|
+
require('prismjs/components/prism-vbnet');
|
64
|
+
require('prismjs/components/prism-yaml');
|
65
|
+
var usePrev = require('./usePrev-DgZBp9Oo.js');
|
66
|
+
var objects = require('./objects-BJTP843m.js');
|
18
67
|
var Toolbar = require('@radix-ui/react-toolbar');
|
19
68
|
var reactDndHtml5Backend = require('react-dnd-html5-backend');
|
20
69
|
var reactRouterDom = require('react-router-dom');
|
21
|
-
var objects = require('./objects-C3EebVVe.js');
|
22
|
-
var Relations = require('./Relations-mxOUS7TJ.js');
|
23
70
|
var pipe$1 = require('lodash/fp/pipe');
|
24
71
|
var ComponentIcon = require('./ComponentIcon-C-EjOUPA.js');
|
25
|
-
var
|
72
|
+
var fractionalIndexing = require('fractional-indexing');
|
73
|
+
var reactWindow = require('react-window');
|
26
74
|
var CodeMirror = require('codemirror5');
|
27
75
|
var sanitizeHtml = require('sanitize-html');
|
28
76
|
var highlight_js = require('highlight.js');
|
@@ -432,11 +480,6 @@ const isText$2 = (node)=>{
|
|
432
480
|
}
|
433
481
|
};
|
434
482
|
|
435
|
-
if (typeof window !== 'undefined' && !window.Prism) {
|
436
|
-
window.Prism = Prism__namespace;
|
437
|
-
}
|
438
|
-
// NOTE: use dynamic requires to ensure they are run after Prism is set globally
|
439
|
-
require('./utils/prismLanguages');
|
440
483
|
const decorateCode = ([node, path])=>{
|
441
484
|
const ranges = [];
|
442
485
|
// make sure it is an Slate Element
|
@@ -1009,7 +1052,7 @@ const isListNode$1 = (element)=>{
|
|
1009
1052
|
return element.type === 'list';
|
1010
1053
|
};
|
1011
1054
|
|
1012
|
-
const
|
1055
|
+
const StyledLink = styledComponents.styled(designSystem.Box)`
|
1013
1056
|
text-decoration: none;
|
1014
1057
|
`;
|
1015
1058
|
const RemoveButton = styledComponents.styled(designSystem.Button)`
|
@@ -1069,9 +1112,10 @@ const LinkContent = /*#__PURE__*/ React__namespace.forwardRef(({ link, children,
|
|
1069
1112
|
open: popoverOpen,
|
1070
1113
|
children: [
|
1071
1114
|
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Popover.Trigger, {
|
1072
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(
|
1115
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(StyledLink, {
|
1073
1116
|
...attributes,
|
1074
1117
|
ref: forwardedRef,
|
1118
|
+
tag: "a",
|
1075
1119
|
href: link.url,
|
1076
1120
|
onClick: ()=>setPopoverOpen(true),
|
1077
1121
|
color: "primary600",
|
@@ -1675,13 +1719,103 @@ const quoteBlocks = {
|
|
1675
1719
|
}
|
1676
1720
|
};
|
1677
1721
|
|
1722
|
+
const ObservedToolbarComponent = ({ index, lastVisibleIndex, setLastVisibleIndex, rootRef, children })=>{
|
1723
|
+
const isVisible = index <= lastVisibleIndex;
|
1724
|
+
const containerRef = strapiAdmin.useElementOnScreen((isVisible)=>{
|
1725
|
+
/**
|
1726
|
+
* It's the MoreMenu's job to make an item not visible when there's not room for it.
|
1727
|
+
* But we need to react here to the element becoming visible again.
|
1728
|
+
*/ if (isVisible) {
|
1729
|
+
setLastVisibleIndex((prev)=>Math.max(prev, index));
|
1730
|
+
}
|
1731
|
+
}, {
|
1732
|
+
threshold: 1,
|
1733
|
+
root: rootRef.current
|
1734
|
+
});
|
1735
|
+
return /*#__PURE__*/ jsxRuntime.jsx("div", {
|
1736
|
+
ref: containerRef,
|
1737
|
+
style: {
|
1738
|
+
/**
|
1739
|
+
* Use visibility so that the element occupies the space if requires even when there's not
|
1740
|
+
* enough room for it to be visible. The empty reserved space will be clipped by the
|
1741
|
+
* overflow:hidden rule on the parent, so it doesn't affect the UI.
|
1742
|
+
* This way we can keep observing its visiblity and react to browser resize events.
|
1743
|
+
*/ visibility: isVisible ? 'visible' : 'hidden'
|
1744
|
+
},
|
1745
|
+
children: children
|
1746
|
+
});
|
1747
|
+
};
|
1748
|
+
const EditorToolbarObserver = ({ observedComponents, menuTriggerVariant = 'ghost' })=>{
|
1749
|
+
const { formatMessage } = reactIntl.useIntl();
|
1750
|
+
const toolbarRef = React__namespace.useRef(null);
|
1751
|
+
const [lastVisibleIndex, setLastVisibleIndex] = React__namespace.useState(observedComponents.length - 1);
|
1752
|
+
const hasHiddenItems = lastVisibleIndex < observedComponents.length - 1;
|
1753
|
+
const menuIndex = lastVisibleIndex + 1;
|
1754
|
+
const [open, setOpen] = React__namespace.useState(false);
|
1755
|
+
const isMenuOpenWithContent = open && hasHiddenItems;
|
1756
|
+
const menuTriggerRef = strapiAdmin.useElementOnScreen((isVisible)=>{
|
1757
|
+
// We only react to the menu becoming invisible. When that happens, we hide the last item.
|
1758
|
+
if (!isVisible) {
|
1759
|
+
/**
|
1760
|
+
* If there's no room for any item, the index can be -1.
|
1761
|
+
* This is intentional, in that case only the more menu will be visible.
|
1762
|
+
**/ setLastVisibleIndex((prev)=>prev - 1);
|
1763
|
+
// Maintain the menu state if it has content
|
1764
|
+
setOpen(isMenuOpenWithContent);
|
1765
|
+
}
|
1766
|
+
}, {
|
1767
|
+
threshold: 1,
|
1768
|
+
root: toolbarRef.current
|
1769
|
+
});
|
1770
|
+
return observedComponents.map((component, index)=>{
|
1771
|
+
return /*#__PURE__*/ jsxRuntime.jsx(ObservedToolbarComponent, {
|
1772
|
+
index: index,
|
1773
|
+
lastVisibleIndex: lastVisibleIndex,
|
1774
|
+
setLastVisibleIndex: setLastVisibleIndex,
|
1775
|
+
rootRef: toolbarRef,
|
1776
|
+
children: component.toolbar
|
1777
|
+
}, component.key);
|
1778
|
+
}).toSpliced(menuIndex, 0, /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Menu.Root, {
|
1779
|
+
defaultOpen: false,
|
1780
|
+
open: isMenuOpenWithContent,
|
1781
|
+
onOpenChange: setOpen,
|
1782
|
+
children: [
|
1783
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Menu.Trigger, {
|
1784
|
+
paddingLeft: 0,
|
1785
|
+
paddingRight: 0,
|
1786
|
+
ref: menuTriggerRef,
|
1787
|
+
variant: menuTriggerVariant,
|
1788
|
+
style: {
|
1789
|
+
visibility: hasHiddenItems ? 'visible' : 'hidden'
|
1790
|
+
},
|
1791
|
+
label: formatMessage({
|
1792
|
+
id: 'global.more',
|
1793
|
+
defaultMessage: 'More'
|
1794
|
+
}),
|
1795
|
+
tag: designSystem.IconButton,
|
1796
|
+
icon: /*#__PURE__*/ jsxRuntime.jsx(Icons.More, {})
|
1797
|
+
}),
|
1798
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Menu.Content, {
|
1799
|
+
onCloseAutoFocus: (e)=>e.preventDefault(),
|
1800
|
+
maxHeight: "100%",
|
1801
|
+
minWidth: "256px",
|
1802
|
+
popoverPlacement: "bottom-end",
|
1803
|
+
zIndex: 2,
|
1804
|
+
children: observedComponents.slice(menuIndex).map((component)=>/*#__PURE__*/ jsxRuntime.jsx(React__namespace.Fragment, {
|
1805
|
+
children: component.menu
|
1806
|
+
}, component.key))
|
1807
|
+
})
|
1808
|
+
]
|
1809
|
+
}, "more-menu"));
|
1810
|
+
};
|
1811
|
+
|
1678
1812
|
const ToolbarWrapper = styledComponents.styled(designSystem.Flex)`
|
1679
1813
|
&[aria-disabled='true'] {
|
1680
1814
|
cursor: not-allowed;
|
1681
1815
|
background: ${({ theme })=>theme.colors.neutral150};
|
1682
1816
|
}
|
1683
1817
|
`;
|
1684
|
-
const
|
1818
|
+
const ToolbarSeparator = styledComponents.styled(Toolbar__namespace.Separator)`
|
1685
1819
|
background: ${({ theme })=>theme.colors.neutral150};
|
1686
1820
|
width: 1px;
|
1687
1821
|
height: 2.4rem;
|
@@ -1751,7 +1885,7 @@ const ToolbarButton = ({ icon: Icon, name, label, isActive, disabled, handleClic
|
|
1751
1885
|
const labelMessage = formatMessage(label);
|
1752
1886
|
const enabledColor = isActive ? 'primary600' : 'neutral600';
|
1753
1887
|
return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Tooltip, {
|
1754
|
-
|
1888
|
+
label: labelMessage,
|
1755
1889
|
children: /*#__PURE__*/ jsxRuntime.jsx(Toolbar__namespace.ToggleItem, {
|
1756
1890
|
value: name,
|
1757
1891
|
"data-state": isActive ? 'on' : 'off',
|
@@ -1943,8 +2077,9 @@ const BlockOption = ({ value, icon: Icon, label, blockSelected })=>{
|
|
1943
2077
|
const isListNode = (node)=>{
|
1944
2078
|
return slate.Node.isNode(node) && !slate.Editor.isEditor(node) && node.type === 'list';
|
1945
2079
|
};
|
1946
|
-
const ListButton = ({ block, format })=>{
|
2080
|
+
const ListButton = ({ block, format, location = 'toolbar' })=>{
|
1947
2081
|
const { editor, disabled, blocks } = useBlocksEditorContext('ListButton');
|
2082
|
+
const { formatMessage } = reactIntl.useIntl();
|
1948
2083
|
const isListActive = ()=>{
|
1949
2084
|
if (!editor.selection) return false;
|
1950
2085
|
// Get the parent list at selection anchor node
|
@@ -2020,6 +2155,18 @@ const ListButton = ({ block, format })=>{
|
|
2020
2155
|
}
|
2021
2156
|
}
|
2022
2157
|
};
|
2158
|
+
if (location === 'menu') {
|
2159
|
+
const Icon = block.icon;
|
2160
|
+
return /*#__PURE__*/ jsxRuntime.jsxs(StyledMenuItem, {
|
2161
|
+
onSelect: ()=>toggleList(format),
|
2162
|
+
isActive: isListActive(),
|
2163
|
+
disabled: isListDisabled(),
|
2164
|
+
children: [
|
2165
|
+
/*#__PURE__*/ jsxRuntime.jsx(Icon, {}),
|
2166
|
+
formatMessage(block.label)
|
2167
|
+
]
|
2168
|
+
});
|
2169
|
+
}
|
2023
2170
|
return /*#__PURE__*/ jsxRuntime.jsx(ToolbarButton, {
|
2024
2171
|
icon: block.icon,
|
2025
2172
|
name: format,
|
@@ -2029,8 +2176,9 @@ const ListButton = ({ block, format })=>{
|
|
2029
2176
|
handleClick: ()=>toggleList(format)
|
2030
2177
|
});
|
2031
2178
|
};
|
2032
|
-
const LinkButton = ({ disabled })=>{
|
2179
|
+
const LinkButton = ({ disabled, location = 'toolbar' })=>{
|
2033
2180
|
const { editor } = useBlocksEditorContext('LinkButton');
|
2181
|
+
const { formatMessage } = reactIntl.useIntl();
|
2034
2182
|
const isLinkActive = ()=>{
|
2035
2183
|
const { selection } = editor;
|
2036
2184
|
if (!selection) return false;
|
@@ -2071,20 +2219,55 @@ const LinkButton = ({ disabled })=>{
|
|
2071
2219
|
url: ''
|
2072
2220
|
});
|
2073
2221
|
};
|
2222
|
+
const label = {
|
2223
|
+
id: 'components.Blocks.link',
|
2224
|
+
defaultMessage: 'Link'
|
2225
|
+
};
|
2226
|
+
if (location === 'menu') {
|
2227
|
+
return /*#__PURE__*/ jsxRuntime.jsxs(StyledMenuItem, {
|
2228
|
+
onSelect: addLink,
|
2229
|
+
isActive: isLinkActive(),
|
2230
|
+
disabled: isLinkDisabled(),
|
2231
|
+
children: [
|
2232
|
+
/*#__PURE__*/ jsxRuntime.jsx(Icons.Link, {}),
|
2233
|
+
formatMessage(label)
|
2234
|
+
]
|
2235
|
+
});
|
2236
|
+
}
|
2074
2237
|
return /*#__PURE__*/ jsxRuntime.jsx(ToolbarButton, {
|
2075
2238
|
icon: Icons.Link,
|
2076
2239
|
name: "link",
|
2077
|
-
label:
|
2078
|
-
id: 'components.Blocks.link',
|
2079
|
-
defaultMessage: 'Link'
|
2080
|
-
},
|
2240
|
+
label: label,
|
2081
2241
|
isActive: isLinkActive(),
|
2082
2242
|
handleClick: addLink,
|
2083
2243
|
disabled: isLinkDisabled()
|
2084
2244
|
});
|
2085
2245
|
};
|
2246
|
+
const StyledMenuItem = styledComponents.styled(designSystem.Menu.Item)`
|
2247
|
+
&:hover {
|
2248
|
+
background-color: ${({ theme })=>theme.colors.primary100};
|
2249
|
+
}
|
2250
|
+
|
2251
|
+
${(props)=>props.isActive && styledComponents.css`
|
2252
|
+
font-weight: bold;
|
2253
|
+
background-color: ${({ theme })=>theme.colors.primary100};
|
2254
|
+
color: ${({ theme })=>theme.colors.primary600};
|
2255
|
+
font-weight: bold;
|
2256
|
+
`}
|
2257
|
+
|
2258
|
+
> span {
|
2259
|
+
display: inline-flex;
|
2260
|
+
gap: ${({ theme })=>theme.spaces[2]};
|
2261
|
+
align-items: center;
|
2262
|
+
}
|
2263
|
+
|
2264
|
+
svg {
|
2265
|
+
fill: ${({ theme, isActive })=>isActive ? theme.colors.primary600 : theme.colors.neutral600};
|
2266
|
+
}
|
2267
|
+
`;
|
2086
2268
|
const BlocksToolbar = ()=>{
|
2087
2269
|
const { editor, blocks, modifiers, disabled } = useBlocksEditorContext('BlocksToolbar');
|
2270
|
+
const { formatMessage } = reactIntl.useIntl();
|
2088
2271
|
/**
|
2089
2272
|
* The modifier buttons are disabled when an image is selected.
|
2090
2273
|
*/ const checkButtonDisabled = ()=>{
|
@@ -2105,6 +2288,94 @@ const BlocksToolbar = ()=>{
|
|
2105
2288
|
return false;
|
2106
2289
|
};
|
2107
2290
|
const isButtonDisabled = checkButtonDisabled();
|
2291
|
+
/**
|
2292
|
+
* Observed components are ones that may or may not be visible in the toolbar, depending on the
|
2293
|
+
* available space. They provide two render props:
|
2294
|
+
* - renderInToolbar: for when we try to render the component in the toolbar (may be hidden)
|
2295
|
+
* - renderInMenu: for when the component didn't fit in the toolbar and is relegated
|
2296
|
+
* to the "more" menu
|
2297
|
+
*/ const observedComponents = [
|
2298
|
+
...Object.entries(modifiers).map(([name, modifier])=>{
|
2299
|
+
const Icon = modifier.icon;
|
2300
|
+
const isActive = modifier.checkIsActive(editor);
|
2301
|
+
const handleSelect = ()=>modifier.handleToggle(editor);
|
2302
|
+
return {
|
2303
|
+
toolbar: /*#__PURE__*/ jsxRuntime.jsx(ToolbarButton, {
|
2304
|
+
name: name,
|
2305
|
+
icon: modifier.icon,
|
2306
|
+
label: modifier.label,
|
2307
|
+
isActive: modifier.checkIsActive(editor),
|
2308
|
+
handleClick: handleSelect,
|
2309
|
+
disabled: isButtonDisabled
|
2310
|
+
}, name),
|
2311
|
+
menu: /*#__PURE__*/ jsxRuntime.jsxs(StyledMenuItem, {
|
2312
|
+
onSelect: handleSelect,
|
2313
|
+
isActive: isActive,
|
2314
|
+
children: [
|
2315
|
+
/*#__PURE__*/ jsxRuntime.jsx(Icon, {}),
|
2316
|
+
formatMessage(modifier.label)
|
2317
|
+
]
|
2318
|
+
}),
|
2319
|
+
key: `modifier.${name}`
|
2320
|
+
};
|
2321
|
+
}),
|
2322
|
+
{
|
2323
|
+
toolbar: /*#__PURE__*/ jsxRuntime.jsx(LinkButton, {
|
2324
|
+
disabled: isButtonDisabled,
|
2325
|
+
location: "toolbar"
|
2326
|
+
}),
|
2327
|
+
menu: /*#__PURE__*/ jsxRuntime.jsx(LinkButton, {
|
2328
|
+
disabled: isButtonDisabled,
|
2329
|
+
location: "menu"
|
2330
|
+
}),
|
2331
|
+
key: 'block.link'
|
2332
|
+
},
|
2333
|
+
{
|
2334
|
+
// List buttons can only be rendered together when in the toolbar
|
2335
|
+
toolbar: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
2336
|
+
direction: "row",
|
2337
|
+
gap: 1,
|
2338
|
+
children: [
|
2339
|
+
/*#__PURE__*/ jsxRuntime.jsx(ToolbarSeparator, {}),
|
2340
|
+
/*#__PURE__*/ jsxRuntime.jsx(Toolbar__namespace.ToggleGroup, {
|
2341
|
+
type: "single",
|
2342
|
+
asChild: true,
|
2343
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
2344
|
+
gap: 1,
|
2345
|
+
children: [
|
2346
|
+
/*#__PURE__*/ jsxRuntime.jsx(ListButton, {
|
2347
|
+
block: blocks['list-unordered'],
|
2348
|
+
format: "unordered",
|
2349
|
+
location: "toolbar"
|
2350
|
+
}),
|
2351
|
+
/*#__PURE__*/ jsxRuntime.jsx(ListButton, {
|
2352
|
+
block: blocks['list-ordered'],
|
2353
|
+
format: "ordered",
|
2354
|
+
location: "toolbar"
|
2355
|
+
})
|
2356
|
+
]
|
2357
|
+
})
|
2358
|
+
})
|
2359
|
+
]
|
2360
|
+
}),
|
2361
|
+
menu: /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
2362
|
+
children: [
|
2363
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Menu.Separator, {}),
|
2364
|
+
/*#__PURE__*/ jsxRuntime.jsx(ListButton, {
|
2365
|
+
block: blocks['list-unordered'],
|
2366
|
+
format: "unordered",
|
2367
|
+
location: "menu"
|
2368
|
+
}),
|
2369
|
+
/*#__PURE__*/ jsxRuntime.jsx(ListButton, {
|
2370
|
+
block: blocks['list-ordered'],
|
2371
|
+
format: "ordered",
|
2372
|
+
location: "menu"
|
2373
|
+
})
|
2374
|
+
]
|
2375
|
+
}),
|
2376
|
+
key: 'block.list'
|
2377
|
+
}
|
2378
|
+
];
|
2108
2379
|
return /*#__PURE__*/ jsxRuntime.jsx(Toolbar__namespace.Root, {
|
2109
2380
|
"aria-disabled": disabled,
|
2110
2381
|
asChild: true,
|
@@ -2114,43 +2385,18 @@ const BlocksToolbar = ()=>{
|
|
2114
2385
|
width: "100%",
|
2115
2386
|
children: [
|
2116
2387
|
/*#__PURE__*/ jsxRuntime.jsx(BlocksDropdown, {}),
|
2117
|
-
/*#__PURE__*/ jsxRuntime.jsx(
|
2388
|
+
/*#__PURE__*/ jsxRuntime.jsx(ToolbarSeparator, {}),
|
2118
2389
|
/*#__PURE__*/ jsxRuntime.jsx(Toolbar__namespace.ToggleGroup, {
|
2119
2390
|
type: "multiple",
|
2120
2391
|
asChild: true,
|
2121
|
-
children: /*#__PURE__*/ jsxRuntime.
|
2122
|
-
|
2123
|
-
children: [
|
2124
|
-
Object.entries(modifiers).map(([name, modifier])=>/*#__PURE__*/ jsxRuntime.jsx(ToolbarButton, {
|
2125
|
-
name: name,
|
2126
|
-
icon: modifier.icon,
|
2127
|
-
label: modifier.label,
|
2128
|
-
isActive: modifier.checkIsActive(editor),
|
2129
|
-
handleClick: ()=>modifier.handleToggle(editor),
|
2130
|
-
disabled: isButtonDisabled
|
2131
|
-
}, name)),
|
2132
|
-
/*#__PURE__*/ jsxRuntime.jsx(LinkButton, {
|
2133
|
-
disabled: isButtonDisabled
|
2134
|
-
})
|
2135
|
-
]
|
2136
|
-
})
|
2137
|
-
}),
|
2138
|
-
/*#__PURE__*/ jsxRuntime.jsx(Separator, {}),
|
2139
|
-
/*#__PURE__*/ jsxRuntime.jsx(Toolbar__namespace.ToggleGroup, {
|
2140
|
-
type: "single",
|
2141
|
-
asChild: true,
|
2142
|
-
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
2392
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Flex, {
|
2393
|
+
direction: "row",
|
2143
2394
|
gap: 1,
|
2144
|
-
|
2145
|
-
|
2146
|
-
|
2147
|
-
|
2148
|
-
|
2149
|
-
/*#__PURE__*/ jsxRuntime.jsx(ListButton, {
|
2150
|
-
block: blocks['list-ordered'],
|
2151
|
-
format: "ordered"
|
2152
|
-
})
|
2153
|
-
]
|
2395
|
+
grow: 1,
|
2396
|
+
overflow: "hidden",
|
2397
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(EditorToolbarObserver, {
|
2398
|
+
observedComponents: observedComponents
|
2399
|
+
})
|
2154
2400
|
})
|
2155
2401
|
})
|
2156
2402
|
]
|
@@ -2182,8 +2428,8 @@ const DropPlaceholder = styledComponents.styled(designSystem.Box)`
|
|
2182
2428
|
|
2183
2429
|
// Show drop placeholder 8px above or below the drop target
|
2184
2430
|
${({ dragDirection, theme, placeholderMargin })=>styledComponents.css`
|
2185
|
-
top: ${dragDirection ===
|
2186
|
-
bottom: ${dragDirection ===
|
2431
|
+
top: ${dragDirection === objects.DIRECTIONS.UPWARD && `-${theme.spaces[placeholderMargin]}`};
|
2432
|
+
bottom: ${dragDirection === objects.DIRECTIONS.DOWNWARD && `-${theme.spaces[placeholderMargin]}`};
|
2187
2433
|
`}
|
2188
2434
|
`;
|
2189
2435
|
const DragItem = styledComponents.styled(designSystem.Flex)`
|
@@ -2267,8 +2513,8 @@ const DragAndDropElement = ({ children, index: index$1, setDragDirection, dragDi
|
|
2267
2513
|
name1,
|
2268
2514
|
setLiveText
|
2269
2515
|
]);
|
2270
|
-
const [{ handlerId, isDragging, isOverDropTarget, direction }, blockRef, dropRef, dragRef] =
|
2271
|
-
type: `${
|
2516
|
+
const [{ handlerId, isDragging, isOverDropTarget, direction }, blockRef, dropRef, dragRef] = objects.useDragAndDrop(!disabled, {
|
2517
|
+
type: `${objects.ItemTypes.BLOCKS}_${name1}`,
|
2272
2518
|
index: index$1,
|
2273
2519
|
item: {
|
2274
2520
|
index: index$1,
|
@@ -3239,6 +3485,20 @@ const Initializer = ({ disabled, name, onClick })=>{
|
|
3239
3485
|
});
|
3240
3486
|
};
|
3241
3487
|
|
3488
|
+
/**
|
3489
|
+
* We use this component to wrap any individual component field in the Edit View,
|
3490
|
+
* this could be a component field in a dynamic zone, a component within a repeatable space,
|
3491
|
+
* or even nested components.
|
3492
|
+
*
|
3493
|
+
* We primarily need this to provide the component id to the components so that they can
|
3494
|
+
* correctly fetch their relations.
|
3495
|
+
*/ const [ComponentProvider, useComponent] = strapiAdmin.createContext('ComponentContext', {
|
3496
|
+
id: undefined,
|
3497
|
+
level: -1,
|
3498
|
+
uid: undefined,
|
3499
|
+
type: undefined
|
3500
|
+
});
|
3501
|
+
|
3242
3502
|
const AddComponentButton = ({ hasError, isDisabled, isOpen, children, onClick })=>{
|
3243
3503
|
return /*#__PURE__*/ jsxRuntime.jsx(StyledButton, {
|
3244
3504
|
type: "button",
|
@@ -3344,15 +3604,24 @@ const ComponentCategory = ({ category, components = [], variant = 'primary', onA
|
|
3344
3604
|
const ResponsiveAccordionContent = styledComponents.styled(designSystem.Accordion.Content)`
|
3345
3605
|
container-type: inline-size;
|
3346
3606
|
`;
|
3347
|
-
|
3348
|
-
|
3349
|
-
|
3350
|
-
|
3351
|
-
|
3352
|
-
|
3353
|
-
|
3354
|
-
|
3355
|
-
|
3607
|
+
/**
|
3608
|
+
* TODO:
|
3609
|
+
* JSDOM cannot handle container queries.
|
3610
|
+
* This is a temporary workaround so that tests do not fail in the CI when jestdom throws an error
|
3611
|
+
* for failing to parse the stylesheet.
|
3612
|
+
*/ const Grid = process.env.NODE_ENV !== 'test' ? styledComponents.styled(designSystem.Box)`
|
3613
|
+
display: grid;
|
3614
|
+
grid-template-columns: repeat(auto-fill, 100%);
|
3615
|
+
grid-gap: 4px;
|
3616
|
+
|
3617
|
+
@container (min-width: ${()=>RESPONSIVE_CONTAINER_BREAKPOINTS.sm}) {
|
3618
|
+
grid-template-columns: repeat(auto-fill, 14rem);
|
3619
|
+
}
|
3620
|
+
` : styledComponents.styled(designSystem.Box)`
|
3621
|
+
display: grid;
|
3622
|
+
grid-template-columns: repeat(auto-fill, 100%);
|
3623
|
+
grid-gap: 4px;
|
3624
|
+
`;
|
3356
3625
|
const ComponentBox = styledComponents.styled(designSystem.Flex)`
|
3357
3626
|
color: ${({ theme })=>theme.colors.neutral600};
|
3358
3627
|
cursor: pointer;
|
@@ -3417,7 +3686,19 @@ const ComponentPicker = ({ dynamicComponentsByCategory = {}, isOpen, onClickAddC
|
|
3417
3686
|
const DynamicComponent = ({ componentUid, disabled, index: index$1, name, onRemoveComponentClick, onMoveComponent, onGrabItem, onDropItem, onCancel, dynamicComponentsByCategory = {}, onAddComponent, children })=>{
|
3418
3687
|
const { formatMessage } = reactIntl.useIntl();
|
3419
3688
|
const formValues = strapiAdmin.useForm('DynamicComponent', (state)=>state.values);
|
3420
|
-
const
|
3689
|
+
const documentMeta = index.useDocumentContext('DynamicComponent', (state)=>state.meta);
|
3690
|
+
const rootDocumentMeta = index.useDocumentContext('DynamicComponent', (state)=>state.rootDocumentMeta);
|
3691
|
+
const { edit: { components: rootComponents } } = index.useDocumentLayout(rootDocumentMeta.model);
|
3692
|
+
const { edit: { components: relatedComponents } } = index.useDocumentLayout(documentMeta.model);
|
3693
|
+
// Merge the root level components and related components
|
3694
|
+
const components = React__namespace.useMemo(()=>({
|
3695
|
+
...rootComponents,
|
3696
|
+
...relatedComponents
|
3697
|
+
}), [
|
3698
|
+
rootComponents,
|
3699
|
+
relatedComponents
|
3700
|
+
]);
|
3701
|
+
const document = index.useDocumentContext('DynamicComponent', (state)=>state.document);
|
3421
3702
|
const title = React__namespace.useMemo(()=>{
|
3422
3703
|
const { mainField } = components[componentUid]?.settings ?? {
|
3423
3704
|
mainField: 'id'
|
@@ -3447,8 +3728,8 @@ const DynamicComponent = ({ componentUid, disabled, index: index$1, name, onRemo
|
|
3447
3728
|
componentUid,
|
3448
3729
|
dynamicComponentsByCategory
|
3449
3730
|
]);
|
3450
|
-
const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] =
|
3451
|
-
type: `${
|
3731
|
+
const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] = objects.useDragAndDrop(!disabled, {
|
3732
|
+
type: `${objects.ItemTypes.DYNAMIC_ZONE}_${name}`,
|
3452
3733
|
index: index$1,
|
3453
3734
|
item: {
|
3454
3735
|
index: index$1,
|
@@ -3649,9 +3930,11 @@ const DynamicComponent = ({ componentUid, disabled, index: index$1, name, onRemo
|
|
3649
3930
|
alignItems: "stretch",
|
3650
3931
|
children: children ? children({
|
3651
3932
|
...fieldWithTranslatedLabel,
|
3933
|
+
document,
|
3652
3934
|
name: fieldName
|
3653
3935
|
}) : /*#__PURE__*/ jsxRuntime.jsx(MemoizedInputRenderer, {
|
3654
3936
|
...fieldWithTranslatedLabel,
|
3937
|
+
document: document,
|
3655
3938
|
name: fieldName
|
3656
3939
|
})
|
3657
3940
|
}, fieldName);
|
@@ -3769,7 +4052,8 @@ const DynamicZone = ({ attribute, disabled: disabledProp, hint, label, labelActi
|
|
3769
4052
|
const { max = Infinity, min = -Infinity } = attribute ?? {};
|
3770
4053
|
const [addComponentIsOpen, setAddComponentIsOpen] = React__namespace.useState(false);
|
3771
4054
|
const [liveText, setLiveText] = React__namespace.useState('');
|
3772
|
-
const
|
4055
|
+
const document = index.useDocumentContext('DynamicZone', (state)=>state.document);
|
4056
|
+
const { components, isLoading } = document;
|
3773
4057
|
const disabled = disabledProp || isLoading;
|
3774
4058
|
const { addFieldRow, removeFieldRow, moveFieldRow } = strapiAdmin.useForm('DynamicZone', ({ addFieldRow, removeFieldRow, moveFieldRow })=>({
|
3775
4059
|
addFieldRow,
|
@@ -3897,7 +4181,7 @@ const DynamicZone = ({ attribute, disabled: disabledProp, hint, label, labelActi
|
|
3897
4181
|
componentName: label || name
|
3898
4182
|
});
|
3899
4183
|
};
|
3900
|
-
const level =
|
4184
|
+
const level = useComponent('DynamicZone', (state)=>state.level);
|
3901
4185
|
const ariaDescriptionId = React__namespace.useId();
|
3902
4186
|
return /*#__PURE__*/ jsxRuntime.jsx(DynamicZoneProvider, {
|
3903
4187
|
isInDynamicZone: true,
|
@@ -3929,7 +4213,7 @@ const DynamicZone = ({ attribute, disabled: disabledProp, hint, label, labelActi
|
|
3929
4213
|
}),
|
3930
4214
|
/*#__PURE__*/ jsxRuntime.jsx("ol", {
|
3931
4215
|
"aria-describedby": ariaDescriptionId,
|
3932
|
-
children: value.map((field, index)=>/*#__PURE__*/ jsxRuntime.jsx(
|
4216
|
+
children: value.map((field, index)=>/*#__PURE__*/ jsxRuntime.jsx(ComponentProvider, {
|
3933
4217
|
level: level + 1,
|
3934
4218
|
uid: field.__component,
|
3935
4219
|
// id is always a number in a dynamic zone.
|
@@ -4002,154 +4286,1387 @@ const NotAllowedInput = ({ hint, label, required, name })=>{
|
|
4002
4286
|
});
|
4003
4287
|
};
|
4004
4288
|
|
4005
|
-
|
4006
|
-
|
4007
|
-
|
4008
|
-
|
4009
|
-
|
4010
|
-
|
4011
|
-
|
4012
|
-
|
4013
|
-
|
4014
|
-
|
4015
|
-
|
4016
|
-
|
4017
|
-
|
4018
|
-
|
4019
|
-
}),
|
4020
|
-
generateUID: builder.mutation({
|
4021
|
-
query: ({ params, ...data })=>({
|
4022
|
-
url: '/content-manager/uid/generate',
|
4023
|
-
method: 'POST',
|
4024
|
-
data,
|
4025
|
-
config: {
|
4026
|
-
params
|
4027
|
-
}
|
4028
|
-
}),
|
4029
|
-
transformResponse: (response)=>response.data
|
4030
|
-
}),
|
4031
|
-
getAvailability: builder.query({
|
4032
|
-
query: ({ params, ...data })=>({
|
4033
|
-
url: '/content-manager/uid/check-availability',
|
4034
|
-
method: 'POST',
|
4035
|
-
data,
|
4036
|
-
config: {
|
4037
|
-
params
|
4038
|
-
}
|
4039
|
-
}),
|
4040
|
-
providesTags: (_res, _error, params)=>[
|
4041
|
-
{
|
4042
|
-
type: 'UidAvailability',
|
4043
|
-
id: params.contentTypeUID
|
4044
|
-
}
|
4045
|
-
]
|
4046
|
-
})
|
4047
|
-
})
|
4289
|
+
function getCollectionType(url) {
|
4290
|
+
const regex = new RegExp(`(${index.COLLECTION_TYPES}|${index.SINGLE_TYPES})`);
|
4291
|
+
const match = url.match(regex);
|
4292
|
+
return match ? match[1] : undefined;
|
4293
|
+
}
|
4294
|
+
const CustomModalContent = styledComponents.styled(designSystem.Modal.Content)`
|
4295
|
+
width: 90%;
|
4296
|
+
max-width: 100%;
|
4297
|
+
height: 90%;
|
4298
|
+
max-height: 100%;
|
4299
|
+
`;
|
4300
|
+
const [RelationModalProvider, useRelationModal] = strapiAdmin.createContext('RelationModal', {
|
4301
|
+
parentModified: false,
|
4302
|
+
depth: 0
|
4048
4303
|
});
|
4049
|
-
const {
|
4050
|
-
|
4051
|
-
|
4052
|
-
* InputUID
|
4053
|
-
* -----------------------------------------------------------------------------------------------*/ const UID_REGEX = /^[A-Za-z0-9-_.~]*$/;
|
4054
|
-
const UIDInput = /*#__PURE__*/ React__namespace.forwardRef(({ hint, label, labelAction, name, required, ...props }, ref)=>{
|
4055
|
-
const { model, id } = index.useDoc();
|
4056
|
-
const allFormValues = strapiAdmin.useForm('InputUID', (form)=>form.values);
|
4057
|
-
const [availability, setAvailability] = React__namespace.useState();
|
4058
|
-
const [showRegenerate, setShowRegenerate] = React__namespace.useState(false);
|
4059
|
-
const isCloning = reactRouterDom.useMatch(index.CLONE_PATH) !== null;
|
4060
|
-
const field = strapiAdmin.useField(name);
|
4061
|
-
const debouncedValue = relations.useDebounce(field.value, 300);
|
4062
|
-
const hasChanged = debouncedValue !== field.initialValue;
|
4063
|
-
const { toggleNotification } = strapiAdmin.useNotification();
|
4064
|
-
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
4304
|
+
const RelationModalForm = ({ relation, triggerButtonLabel })=>{
|
4305
|
+
const navigate = reactRouterDom.useNavigate();
|
4306
|
+
const { pathname, search } = reactRouterDom.useLocation();
|
4065
4307
|
const { formatMessage } = reactIntl.useIntl();
|
4066
|
-
const [
|
4067
|
-
const
|
4068
|
-
|
4069
|
-
|
4070
|
-
const
|
4071
|
-
|
4072
|
-
|
4073
|
-
|
4074
|
-
|
4075
|
-
|
4076
|
-
|
4077
|
-
|
4078
|
-
|
4079
|
-
|
4080
|
-
|
4081
|
-
|
4082
|
-
|
4083
|
-
|
4084
|
-
|
4085
|
-
|
4086
|
-
|
4308
|
+
const [triggerRefetchDocument] = index.useLazyGetDocumentQuery();
|
4309
|
+
const currentDocument = index.useDocumentContext('RelationModalForm', (state)=>state.document);
|
4310
|
+
const rootDocumentMeta = index.useDocumentContext('RelationModalForm', (state)=>state.rootDocumentMeta);
|
4311
|
+
const currentDocumentMeta = index.useDocumentContext('RelationModalForm', (state)=>state.meta);
|
4312
|
+
const changeDocument = index.useDocumentContext('RelationModalForm', (state)=>state.changeDocument);
|
4313
|
+
const documentHistory = index.useDocumentContext('RelationModalForm', (state)=>state.documentHistory);
|
4314
|
+
const setDocumentHistory = index.useDocumentContext('RelationModalForm', (state)=>state.setDocumentHistory);
|
4315
|
+
const [isConfirmationOpen, setIsConfirmationOpen] = React__namespace.useState(false);
|
4316
|
+
const [actionPosition, setActionPosition] = React__namespace.useState('cancel');
|
4317
|
+
const [isModalOpen, setIsModalOpen] = React__namespace.useState(false);
|
4318
|
+
// NOTE: Not sure about this relation modal context, maybe we should move this to DocumentContext?
|
4319
|
+
// Get parent modal context if it exists
|
4320
|
+
const parentContext = useRelationModal('RelationModalForm', (state)=>state);
|
4321
|
+
// Get depth of nested modals
|
4322
|
+
const depth = parentContext ? parentContext.depth + 1 : 0;
|
4323
|
+
// Check if this is a nested modal
|
4324
|
+
const isNested = depth > 0;
|
4325
|
+
const addDocumentToHistory = (document)=>setDocumentHistory((prev)=>[
|
4326
|
+
...prev,
|
4327
|
+
document
|
4328
|
+
]);
|
4329
|
+
const getPreviousDocument = ()=>{
|
4330
|
+
if (documentHistory.length === 0) return undefined;
|
4331
|
+
const lastDocument = documentHistory[documentHistory.length - 1];
|
4332
|
+
return lastDocument;
|
4333
|
+
};
|
4334
|
+
const removeLastDocumentFromHistory = ()=>{
|
4335
|
+
setDocumentHistory((prev)=>[
|
4336
|
+
...prev
|
4337
|
+
].slice(0, prev.length - 1));
|
4338
|
+
};
|
4339
|
+
const handleToggleModal = ()=>{
|
4340
|
+
if (isModalOpen) {
|
4341
|
+
setIsModalOpen(false);
|
4342
|
+
const document = {
|
4343
|
+
collectionType: rootDocumentMeta.collectionType,
|
4344
|
+
model: rootDocumentMeta.model,
|
4345
|
+
documentId: rootDocumentMeta.documentId
|
4346
|
+
};
|
4347
|
+
// Change back to the root document
|
4348
|
+
changeDocument(document);
|
4349
|
+
// Reset the document history
|
4350
|
+
setDocumentHistory([]);
|
4351
|
+
// Reset action position
|
4352
|
+
setActionPosition('cancel');
|
4353
|
+
// Read from cache or refetch root document
|
4354
|
+
triggerRefetchDocument(document, // Favor the cache
|
4355
|
+
true);
|
4356
|
+
} else {
|
4357
|
+
changeDocument(relation);
|
4358
|
+
setIsModalOpen(true);
|
4087
4359
|
}
|
4088
|
-
}
|
4089
|
-
|
4090
|
-
|
4091
|
-
|
4092
|
-
|
4093
|
-
|
4094
|
-
|
4095
|
-
|
4096
|
-
|
4097
|
-
if (
|
4098
|
-
|
4360
|
+
};
|
4361
|
+
const getFullPageLink = ()=>{
|
4362
|
+
const isSingleType = currentDocumentMeta.collectionType === index.SINGLE_TYPES;
|
4363
|
+
const queryParams = currentDocumentMeta.params?.locale ? `?plugins[i18n][locale]=${currentDocumentMeta.params.locale}` : '';
|
4364
|
+
return `/content-manager/${currentDocumentMeta.collectionType}/${currentDocumentMeta.model}${isSingleType ? '' : '/' + currentDocumentMeta.documentId}${queryParams}`;
|
4365
|
+
};
|
4366
|
+
const handleRedirection = ()=>{
|
4367
|
+
const editViewUrl = `${pathname}${search}`;
|
4368
|
+
const isRootDocumentUrl = editViewUrl.includes(getFullPageLink());
|
4369
|
+
if (isRootDocumentUrl) {
|
4370
|
+
handleToggleModal();
|
4371
|
+
} else {
|
4372
|
+
navigate(getFullPageLink());
|
4099
4373
|
}
|
4100
|
-
}
|
4101
|
-
|
4102
|
-
|
4103
|
-
|
4104
|
-
|
4105
|
-
|
4106
|
-
|
4107
|
-
|
4108
|
-
|
4109
|
-
contentTypeUID: model,
|
4110
|
-
field: name,
|
4111
|
-
data: {
|
4112
|
-
id: id ?? '',
|
4113
|
-
...allFormValues
|
4114
|
-
},
|
4115
|
-
params
|
4116
|
-
});
|
4117
|
-
if ('data' in res) {
|
4118
|
-
field.onChange(name, res.data);
|
4119
|
-
} else {
|
4120
|
-
toggleNotification({
|
4121
|
-
type: 'danger',
|
4122
|
-
message: formatAPIError(res.error)
|
4123
|
-
});
|
4374
|
+
};
|
4375
|
+
const handleConfirm = ()=>{
|
4376
|
+
if (actionPosition === 'navigate') {
|
4377
|
+
handleRedirection();
|
4378
|
+
} else if (actionPosition === 'back') {
|
4379
|
+
const previousRelation = getPreviousDocument();
|
4380
|
+
if (previousRelation) {
|
4381
|
+
removeLastDocumentFromHistory();
|
4382
|
+
changeDocument(previousRelation);
|
4124
4383
|
}
|
4125
|
-
}
|
4126
|
-
|
4127
|
-
|
4128
|
-
|
4129
|
-
|
4130
|
-
|
4131
|
-
})
|
4132
|
-
});
|
4384
|
+
} else {
|
4385
|
+
// Add current relation to history before opening a new one in case we are opening a new one
|
4386
|
+
if (currentDocumentMeta && Object.keys(currentDocumentMeta).length > 0) {
|
4387
|
+
addDocumentToHistory(currentDocumentMeta);
|
4388
|
+
}
|
4389
|
+
handleToggleModal();
|
4133
4390
|
}
|
4134
4391
|
};
|
4135
|
-
|
4136
|
-
|
4137
|
-
|
4138
|
-
|
4139
|
-
|
4140
|
-
|
4141
|
-
|
4142
|
-
skip: !Boolean((hasChanged || isCloning) && debouncedValue && UID_REGEX.test(debouncedValue.trim()))
|
4143
|
-
});
|
4144
|
-
React__namespace.useEffect(()=>{
|
4145
|
-
if (availabilityError) {
|
4146
|
-
toggleNotification({
|
4147
|
-
type: 'warning',
|
4148
|
-
message: formatAPIError(availabilityError)
|
4392
|
+
return /*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.Form, {
|
4393
|
+
method: "PUT",
|
4394
|
+
initialValues: currentDocument.getInitialFormValues(),
|
4395
|
+
validate: (values, options)=>{
|
4396
|
+
const yupSchema = index.createYupSchema(currentDocument.schema?.attributes, currentDocument.components, {
|
4397
|
+
status: currentDocument.document?.status,
|
4398
|
+
...options
|
4149
4399
|
});
|
4150
|
-
|
4151
|
-
|
4152
|
-
|
4400
|
+
return yupSchema.validate(values, {
|
4401
|
+
abortEarly: false
|
4402
|
+
});
|
4403
|
+
},
|
4404
|
+
children: ({ modified, isSubmitting, resetForm })=>{
|
4405
|
+
// We don't count the root document, so history starts after 1
|
4406
|
+
const hasHistory = documentHistory.length > 1;
|
4407
|
+
return /*#__PURE__*/ jsxRuntime.jsxs(RelationModalProvider, {
|
4408
|
+
parentModified: modified,
|
4409
|
+
depth: depth,
|
4410
|
+
children: [
|
4411
|
+
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Modal.Root, {
|
4412
|
+
open: isModalOpen,
|
4413
|
+
onOpenChange: ()=>{
|
4414
|
+
if (isModalOpen) {
|
4415
|
+
if (modified && !isSubmitting) {
|
4416
|
+
setIsConfirmationOpen(true);
|
4417
|
+
} else {
|
4418
|
+
handleToggleModal();
|
4419
|
+
}
|
4420
|
+
}
|
4421
|
+
},
|
4422
|
+
children: [
|
4423
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Modal.Trigger, {
|
4424
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Tooltip, {
|
4425
|
+
description: triggerButtonLabel,
|
4426
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(CustomTextButton, {
|
4427
|
+
onClick: ()=>{
|
4428
|
+
// Check if parent modal has unsaved changes
|
4429
|
+
if (isNested && parentContext.parentModified) {
|
4430
|
+
setIsConfirmationOpen(true);
|
4431
|
+
// Return early to avoid opening the modal
|
4432
|
+
return;
|
4433
|
+
} else {
|
4434
|
+
if (modified && !isSubmitting) {
|
4435
|
+
setIsConfirmationOpen(true);
|
4436
|
+
} else {
|
4437
|
+
// Add current relation to history before opening a new one
|
4438
|
+
if (currentDocumentMeta && Object.keys(currentDocumentMeta).length > 0) {
|
4439
|
+
addDocumentToHistory(currentDocumentMeta);
|
4440
|
+
}
|
4441
|
+
handleToggleModal();
|
4442
|
+
}
|
4443
|
+
if (!isModalOpen) {
|
4444
|
+
setIsModalOpen(true);
|
4445
|
+
}
|
4446
|
+
}
|
4447
|
+
},
|
4448
|
+
width: "100%",
|
4449
|
+
children: triggerButtonLabel
|
4450
|
+
})
|
4451
|
+
})
|
4452
|
+
}),
|
4453
|
+
/*#__PURE__*/ jsxRuntime.jsxs(CustomModalContent, {
|
4454
|
+
children: [
|
4455
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Modal.Header, {
|
4456
|
+
gap: 2,
|
4457
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Flex, {
|
4458
|
+
justifyContent: "space-between",
|
4459
|
+
alignItems: "center",
|
4460
|
+
width: "100%",
|
4461
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
4462
|
+
gap: 2,
|
4463
|
+
children: [
|
4464
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
|
4465
|
+
withTooltip: false,
|
4466
|
+
label: "Back",
|
4467
|
+
variant: "ghost",
|
4468
|
+
disabled: !hasHistory,
|
4469
|
+
onClick: ()=>{
|
4470
|
+
setActionPosition('back');
|
4471
|
+
if (modified && !isSubmitting) {
|
4472
|
+
setIsConfirmationOpen(true);
|
4473
|
+
} else {
|
4474
|
+
const previousRelation = getPreviousDocument();
|
4475
|
+
if (previousRelation) {
|
4476
|
+
removeLastDocumentFromHistory();
|
4477
|
+
changeDocument(previousRelation);
|
4478
|
+
}
|
4479
|
+
}
|
4480
|
+
},
|
4481
|
+
marginRight: 1,
|
4482
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.ArrowLeft, {})
|
4483
|
+
}),
|
4484
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
|
4485
|
+
tag: "span",
|
4486
|
+
fontWeight: 600,
|
4487
|
+
children: formatMessage({
|
4488
|
+
id: 'content-manager.components.RelationInputModal.modal-title',
|
4489
|
+
defaultMessage: 'Edit a relation'
|
4490
|
+
})
|
4491
|
+
})
|
4492
|
+
]
|
4493
|
+
})
|
4494
|
+
})
|
4495
|
+
}),
|
4496
|
+
/*#__PURE__*/ jsxRuntime.jsx(RelationModalBody, {
|
4497
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
|
4498
|
+
onClick: ()=>{
|
4499
|
+
setActionPosition('navigate');
|
4500
|
+
if (modified && !isSubmitting) {
|
4501
|
+
setIsConfirmationOpen(true);
|
4502
|
+
} else {
|
4503
|
+
navigate(getFullPageLink());
|
4504
|
+
}
|
4505
|
+
},
|
4506
|
+
variant: "tertiary",
|
4507
|
+
label: formatMessage({
|
4508
|
+
id: 'content-manager.components.RelationInputModal.button-fullpage',
|
4509
|
+
defaultMessage: 'Go to entry'
|
4510
|
+
}),
|
4511
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.ArrowsOut, {})
|
4512
|
+
})
|
4513
|
+
}),
|
4514
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Modal.Footer, {
|
4515
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Button, {
|
4516
|
+
onClick: ()=>{
|
4517
|
+
if (modified && !isSubmitting) {
|
4518
|
+
setIsConfirmationOpen(true);
|
4519
|
+
} else {
|
4520
|
+
handleToggleModal();
|
4521
|
+
}
|
4522
|
+
},
|
4523
|
+
variant: "tertiary",
|
4524
|
+
children: formatMessage({
|
4525
|
+
id: 'app.components.Button.cancel',
|
4526
|
+
defaultMessage: 'Cancel'
|
4527
|
+
})
|
4528
|
+
})
|
4529
|
+
})
|
4530
|
+
]
|
4531
|
+
})
|
4532
|
+
]
|
4533
|
+
}),
|
4534
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Dialog.Root, {
|
4535
|
+
open: isConfirmationOpen,
|
4536
|
+
onOpenChange: setIsConfirmationOpen,
|
4537
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.ConfirmDialog, {
|
4538
|
+
onConfirm: ()=>{
|
4539
|
+
handleConfirm();
|
4540
|
+
setIsConfirmationOpen(false);
|
4541
|
+
resetForm();
|
4542
|
+
},
|
4543
|
+
onCancel: ()=>{
|
4544
|
+
setIsConfirmationOpen(false);
|
4545
|
+
},
|
4546
|
+
variant: "danger",
|
4547
|
+
children: formatMessage({
|
4548
|
+
id: 'content-manager.components.RelationInputModal.confirmation-message',
|
4549
|
+
defaultMessage: 'Some changes were not saved. Are you sure you want to close this relation? All changes that were not saved will be lost.'
|
4550
|
+
})
|
4551
|
+
})
|
4552
|
+
})
|
4553
|
+
]
|
4554
|
+
});
|
4555
|
+
}
|
4556
|
+
});
|
4557
|
+
};
|
4558
|
+
const CustomTextButton = styledComponents.styled(designSystem.TextButton)`
|
4559
|
+
& > span {
|
4560
|
+
font-size: ${({ theme })=>theme.fontSizes[2]};
|
4561
|
+
width: inherit;
|
4562
|
+
overflow: hidden;
|
4563
|
+
white-space: nowrap;
|
4564
|
+
text-overflow: ellipsis;
|
4565
|
+
}
|
4566
|
+
`;
|
4567
|
+
const RelationModalBody = ({ children })=>{
|
4568
|
+
const { formatMessage } = reactIntl.useIntl();
|
4569
|
+
const documentMeta = index.useDocumentContext('RelationModalBody', (state)=>state.meta);
|
4570
|
+
const documentResponse = index.useDocumentContext('RelationModalBody', (state)=>state.document);
|
4571
|
+
const onPreview = index.useDocumentContext('RelationModalBody', (state)=>state.onPreview);
|
4572
|
+
const documentLayoutResponse = index.useDocumentLayout(documentMeta.model);
|
4573
|
+
const plugins = strapiAdmin.useStrapiApp('RelationModalBody', (state)=>state.plugins);
|
4574
|
+
const initialValues = documentResponse.getInitialFormValues();
|
4575
|
+
const { permissions = [], isLoading: isLoadingPermissions, error } = strapiAdmin.useRBAC(index.PERMISSIONS.map((action)=>({
|
4576
|
+
action,
|
4577
|
+
subject: documentMeta.model
|
4578
|
+
})));
|
4579
|
+
const isLoading = isLoadingPermissions || documentLayoutResponse.isLoading || documentResponse.isLoading;
|
4580
|
+
if (isLoading && !documentResponse.document?.documentId) {
|
4581
|
+
return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Loader, {
|
4582
|
+
small: true,
|
4583
|
+
children: formatMessage({
|
4584
|
+
id: 'content-manager.ListViewTable.relation-loading',
|
4585
|
+
defaultMessage: 'Relations are loading'
|
4586
|
+
})
|
4587
|
+
});
|
4588
|
+
}
|
4589
|
+
if (error || !documentMeta.model || documentLayoutResponse.error || !documentResponse.document || !documentResponse.meta || !documentResponse.schema || !initialValues) {
|
4590
|
+
return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Flex, {
|
4591
|
+
alignItems: "center",
|
4592
|
+
height: "100%",
|
4593
|
+
justifyContent: "center",
|
4594
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.EmptyStateLayout, {
|
4595
|
+
icon: /*#__PURE__*/ jsxRuntime.jsx(Icons.WarningCircle, {
|
4596
|
+
width: "16rem"
|
4597
|
+
}),
|
4598
|
+
content: formatMessage({
|
4599
|
+
id: 'anErrorOccurred',
|
4600
|
+
defaultMessage: 'Whoops! Something went wrong. Please, try again.'
|
4601
|
+
})
|
4602
|
+
})
|
4603
|
+
});
|
4604
|
+
}
|
4605
|
+
const documentTitle = documentResponse.getTitle(documentLayoutResponse.edit.settings.mainField);
|
4606
|
+
const hasDraftAndPublished = documentResponse.schema?.options?.draftAndPublish ?? false;
|
4607
|
+
const props = {
|
4608
|
+
activeTab: 'draft',
|
4609
|
+
collectionType: documentMeta.collectionType,
|
4610
|
+
model: documentMeta.model,
|
4611
|
+
documentId: documentMeta.documentId,
|
4612
|
+
document: documentResponse.document,
|
4613
|
+
meta: documentResponse.meta,
|
4614
|
+
onPreview
|
4615
|
+
};
|
4616
|
+
return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Modal.Body, {
|
4617
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs(index.DocumentRBAC, {
|
4618
|
+
permissions: permissions,
|
4619
|
+
model: documentMeta.model,
|
4620
|
+
children: [
|
4621
|
+
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
4622
|
+
alignItems: "flex-start",
|
4623
|
+
direction: "column",
|
4624
|
+
gap: 2,
|
4625
|
+
children: [
|
4626
|
+
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
4627
|
+
width: "100%",
|
4628
|
+
justifyContent: "space-between",
|
4629
|
+
gap: 2,
|
4630
|
+
children: [
|
4631
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
|
4632
|
+
tag: "h2",
|
4633
|
+
variant: "alpha",
|
4634
|
+
children: documentTitle
|
4635
|
+
}),
|
4636
|
+
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
4637
|
+
gap: 2,
|
4638
|
+
children: [
|
4639
|
+
children,
|
4640
|
+
/*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.DescriptionComponentRenderer, {
|
4641
|
+
props: props,
|
4642
|
+
descriptions: plugins['content-manager'].apis.getDocumentActions('relation-modal'),
|
4643
|
+
children: (actions)=>{
|
4644
|
+
const filteredActions = actions.filter((action)=>{
|
4645
|
+
return [
|
4646
|
+
action.position
|
4647
|
+
].flat().includes('relation-modal');
|
4648
|
+
});
|
4649
|
+
const [primaryAction, secondaryAction] = filteredActions;
|
4650
|
+
if (!primaryAction && !secondaryAction) return null;
|
4651
|
+
// Both actions are available when draft and publish enabled
|
4652
|
+
if (primaryAction && secondaryAction) {
|
4653
|
+
return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
4654
|
+
children: [
|
4655
|
+
/*#__PURE__*/ jsxRuntime.jsx(index.DocumentActionButton, {
|
4656
|
+
...secondaryAction,
|
4657
|
+
variant: secondaryAction.variant || 'secondary'
|
4658
|
+
}),
|
4659
|
+
/*#__PURE__*/ jsxRuntime.jsx(index.DocumentActionButton, {
|
4660
|
+
...primaryAction,
|
4661
|
+
variant: primaryAction.variant || 'default'
|
4662
|
+
})
|
4663
|
+
]
|
4664
|
+
});
|
4665
|
+
}
|
4666
|
+
// Otherwise we just have the save action
|
4667
|
+
return /*#__PURE__*/ jsxRuntime.jsx(index.DocumentActionButton, {
|
4668
|
+
...primaryAction,
|
4669
|
+
variant: primaryAction.variant || 'secondary'
|
4670
|
+
});
|
4671
|
+
}
|
4672
|
+
})
|
4673
|
+
]
|
4674
|
+
})
|
4675
|
+
]
|
4676
|
+
}),
|
4677
|
+
hasDraftAndPublished ? /*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
|
4678
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(index.DocumentStatus, {
|
4679
|
+
status: documentResponse.document?.status
|
4680
|
+
})
|
4681
|
+
}) : null
|
4682
|
+
]
|
4683
|
+
}),
|
4684
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Flex, {
|
4685
|
+
flex: 1,
|
4686
|
+
overflow: "auto",
|
4687
|
+
alignItems: "stretch",
|
4688
|
+
paddingTop: 7,
|
4689
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
|
4690
|
+
overflow: "auto",
|
4691
|
+
flex: 1,
|
4692
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(FormLayout, {
|
4693
|
+
layout: documentLayoutResponse.edit.layout,
|
4694
|
+
document: documentResponse,
|
4695
|
+
hasBackground: false
|
4696
|
+
})
|
4697
|
+
})
|
4698
|
+
})
|
4699
|
+
]
|
4700
|
+
})
|
4701
|
+
});
|
4702
|
+
};
|
4703
|
+
|
4704
|
+
/**
|
4705
|
+
* Remove a relation, whether it's been already saved or not.
|
4706
|
+
* It's used both in RelationsList, where the "remove relation" button is, and in the input,
|
4707
|
+
* because we sometimes need to remove a previous relation when selecting a new one.
|
4708
|
+
*/ function useHandleDisconnect(fieldName, consumerName) {
|
4709
|
+
const field = strapiAdmin.useField(fieldName);
|
4710
|
+
const removeFieldRow = strapiAdmin.useForm(consumerName, (state)=>state.removeFieldRow);
|
4711
|
+
const addFieldRow = strapiAdmin.useForm(consumerName, (state)=>state.addFieldRow);
|
4712
|
+
const handleDisconnect = (relation)=>{
|
4713
|
+
if (field.value && field.value.connect) {
|
4714
|
+
/**
|
4715
|
+
* A relation will exist in the `connect` array _if_ it has
|
4716
|
+
* been added without saving. In this case, we just remove it
|
4717
|
+
* from the connect array
|
4718
|
+
*/ const indexOfRelationInConnectArray = field.value.connect.findIndex((rel)=>rel.id === relation.id);
|
4719
|
+
if (indexOfRelationInConnectArray >= 0) {
|
4720
|
+
removeFieldRow(`${fieldName}.connect`, indexOfRelationInConnectArray);
|
4721
|
+
return;
|
4722
|
+
}
|
4723
|
+
}
|
4724
|
+
addFieldRow(`${fieldName}.disconnect`, {
|
4725
|
+
id: relation.id,
|
4726
|
+
apiData: {
|
4727
|
+
id: relation.id,
|
4728
|
+
documentId: relation.documentId,
|
4729
|
+
locale: relation.locale
|
4730
|
+
}
|
4731
|
+
});
|
4732
|
+
};
|
4733
|
+
return handleDisconnect;
|
4734
|
+
}
|
4735
|
+
/* -------------------------------------------------------------------------------------------------
|
4736
|
+
* RelationsField
|
4737
|
+
* -----------------------------------------------------------------------------------------------*/ const RELATIONS_TO_DISPLAY = 5;
|
4738
|
+
const ONE_WAY_RELATIONS = [
|
4739
|
+
'oneWay',
|
4740
|
+
'oneToOne',
|
4741
|
+
'manyToOne',
|
4742
|
+
'oneToManyMorph',
|
4743
|
+
'oneToOneMorph'
|
4744
|
+
];
|
4745
|
+
/**
|
4746
|
+
* TODO: we get a rather ugly flash when we remove a single relation from the list leaving
|
4747
|
+
* no other relations when we press save. The initial relation re-renders, probably because
|
4748
|
+
* of the lag in the Form cleaning it's "disconnect" array, whilst our data has not been invalidated.
|
4749
|
+
*
|
4750
|
+
* Could we invalidate relation data on the document actions? Should we?
|
4751
|
+
*/ /**
|
4752
|
+
* @internal
|
4753
|
+
* @description The relations field holds a lot of domain logic for handling relations which is rather complicated
|
4754
|
+
* At present we do not expose this to plugin developers, however, they are able to overwrite it themselves should
|
4755
|
+
* they wish to do so.
|
4756
|
+
*/ const RelationsField = /*#__PURE__*/ React__namespace.forwardRef(({ disabled, label, ...props }, ref)=>{
|
4757
|
+
const currentDocumentMeta = index.useDocumentContext('RelationsField', (state)=>state.meta);
|
4758
|
+
const currentDocument = index.useDocumentContext('RelationsField', (state)=>state.document);
|
4759
|
+
const rootDocumentMeta = index.useDocumentContext('RelationsField', (state)=>state.rootDocumentMeta);
|
4760
|
+
const [currentPage, setCurrentPage] = React__namespace.useState(1);
|
4761
|
+
const isRootDocument = rootDocumentMeta.documentId === currentDocumentMeta.documentId;
|
4762
|
+
const documentMeta = isRootDocument ? rootDocumentMeta : currentDocumentMeta;
|
4763
|
+
// Use the documentId from the actual document, not the params (meta)
|
4764
|
+
const documentId = currentDocument.document?.documentId;
|
4765
|
+
const { formatMessage } = reactIntl.useIntl();
|
4766
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
4767
|
+
const params = documentMeta.params ?? index.buildValidParams(query);
|
4768
|
+
const isMorph = props.attribute.relation.toLowerCase().includes('morph');
|
4769
|
+
const isDisabled = isMorph || disabled;
|
4770
|
+
const { componentId, componentUID } = useComponent('RelationsField', ({ uid, id })=>({
|
4771
|
+
componentId: id,
|
4772
|
+
componentUID: uid
|
4773
|
+
}));
|
4774
|
+
const isSubmitting = strapiAdmin.useForm('RelationsList', (state)=>state.isSubmitting);
|
4775
|
+
React__namespace.useEffect(()=>{
|
4776
|
+
setCurrentPage(1);
|
4777
|
+
}, [
|
4778
|
+
isSubmitting
|
4779
|
+
]);
|
4780
|
+
const component = componentUID && currentDocument.components[componentUID];
|
4781
|
+
/**
|
4782
|
+
* We'll always have a documentId in a created entry, so we look for a componentId first.
|
4783
|
+
* Same with `uid` and `documentModel`.
|
4784
|
+
*/ const model = component ? component.uid : documentMeta.model;
|
4785
|
+
const id = component && componentId ? componentId.toString() : documentId;
|
4786
|
+
/**
|
4787
|
+
* The `name` prop is a complete path to the field, e.g. `field1.field2.field3`.
|
4788
|
+
* Where the above example would a nested field within two components, however
|
4789
|
+
* we only require the field on the component not the complete path since we query
|
4790
|
+
* individual components. Therefore we split the string and take the last item.
|
4791
|
+
*/ const [targetField] = props.name.split('.').slice(-1);
|
4792
|
+
const schemaAttributes = component ? component.attributes ?? {} : currentDocument.schema?.attributes ?? {};
|
4793
|
+
/**
|
4794
|
+
* Confirm the target field is related to the current document.
|
4795
|
+
* Since relations can exist in a modal on top of the root document,
|
4796
|
+
* we need to ensure we are fetching relations for the correct document (root document vs related document),
|
4797
|
+
*/ const isRelatedToCurrentDocument = Object.values(schemaAttributes).filter((attribute)=>attribute.type === 'relation' && 'target' in attribute && 'target' in props.attribute && attribute.target === props.attribute.target).length > 0;
|
4798
|
+
const { data, isLoading, isFetching } = usePrev.useGetRelationsQuery({
|
4799
|
+
model,
|
4800
|
+
targetField,
|
4801
|
+
// below we don't run the query if there is no id.
|
4802
|
+
id,
|
4803
|
+
params: {
|
4804
|
+
...params,
|
4805
|
+
pageSize: RELATIONS_TO_DISPLAY,
|
4806
|
+
page: currentPage
|
4807
|
+
}
|
4808
|
+
}, {
|
4809
|
+
refetchOnMountOrArgChange: true,
|
4810
|
+
skip: !id || !isRelatedToCurrentDocument,
|
4811
|
+
selectFromResult: (result)=>{
|
4812
|
+
return {
|
4813
|
+
...result,
|
4814
|
+
data: {
|
4815
|
+
...result.data,
|
4816
|
+
results: result.data?.results ? result.data.results : []
|
4817
|
+
}
|
4818
|
+
};
|
4819
|
+
}
|
4820
|
+
});
|
4821
|
+
const handleLoadMore = ()=>{
|
4822
|
+
setCurrentPage((prev)=>prev + 1);
|
4823
|
+
};
|
4824
|
+
const field = strapiAdmin.useField(props.name);
|
4825
|
+
const isFetchingMoreRelations = isLoading || isFetching;
|
4826
|
+
const realServerRelationsCount = 'pagination' in data && data.pagination ? data.pagination.total : 0;
|
4827
|
+
/**
|
4828
|
+
* Items that are already connected, but reordered would be in
|
4829
|
+
* this list, so to get an accurate figure, we remove them.
|
4830
|
+
*/ const relationsConnected = (field.value?.connect ?? []).filter((rel)=>data.results.findIndex((relation)=>relation.id === rel.id) === -1).length ?? 0;
|
4831
|
+
const relationsDisconnected = field.value?.disconnect?.length ?? 0;
|
4832
|
+
const relationsCount = realServerRelationsCount + relationsConnected - relationsDisconnected;
|
4833
|
+
/**
|
4834
|
+
* This is it, the source of truth for reordering in conjunction with partial loading & updating
|
4835
|
+
* of relations. Relations on load are given __temp_key__ when fetched, because we don't want to
|
4836
|
+
* create brand new keys everytime the data updates, just keep adding them onto the newly loaded ones.
|
4837
|
+
*/ const relations = React__namespace.useMemo(()=>{
|
4838
|
+
const ctx = {
|
4839
|
+
field: field.value,
|
4840
|
+
// @ts-expect-error – targetModel does exist on the attribute. But it's not typed.
|
4841
|
+
href: `../${index.COLLECTION_TYPES}/${props.attribute.targetModel}`,
|
4842
|
+
mainField: props.mainField
|
4843
|
+
};
|
4844
|
+
/**
|
4845
|
+
* Tidy up our data.
|
4846
|
+
*/ const transformations = pipe$1(removeConnected(ctx), removeDisconnected(ctx), addLabelAndHref(ctx));
|
4847
|
+
const transformedRels = transformations([
|
4848
|
+
...data.results
|
4849
|
+
]);
|
4850
|
+
/**
|
4851
|
+
* THIS IS CRUCIAL. If you don't sort by the __temp_key__ which comes from fractional indexing
|
4852
|
+
* then the list will be in the wrong order.
|
4853
|
+
*/ return [
|
4854
|
+
...transformedRels,
|
4855
|
+
...field.value?.connect ?? []
|
4856
|
+
].sort((a, b)=>{
|
4857
|
+
if (a.__temp_key__ < b.__temp_key__) return -1;
|
4858
|
+
if (a.__temp_key__ > b.__temp_key__) return 1;
|
4859
|
+
return 0;
|
4860
|
+
});
|
4861
|
+
}, [
|
4862
|
+
data.results,
|
4863
|
+
field.value,
|
4864
|
+
// @ts-expect-error – targetModel does exist on the attribute. But it's not typed.
|
4865
|
+
props.attribute.targetModel,
|
4866
|
+
props.mainField
|
4867
|
+
]);
|
4868
|
+
const handleDisconnect = useHandleDisconnect(props.name, 'RelationsField');
|
4869
|
+
const handleConnect = (relation)=>{
|
4870
|
+
const [lastItemInList] = relations.slice(-1);
|
4871
|
+
const item = {
|
4872
|
+
id: relation.id,
|
4873
|
+
apiData: {
|
4874
|
+
id: relation.id,
|
4875
|
+
documentId: relation.documentId,
|
4876
|
+
locale: relation.locale
|
4877
|
+
},
|
4878
|
+
status: relation.status,
|
4879
|
+
/**
|
4880
|
+
* If there's a last item, that's the first key we use to generate out next one.
|
4881
|
+
*/ __temp_key__: fractionalIndexing.generateNKeysBetween(lastItemInList?.__temp_key__ ?? null, null, 1)[0],
|
4882
|
+
// Fallback to `id` if there is no `mainField` value, which will overwrite the above `id` property with the exact same data.
|
4883
|
+
[props.mainField?.name ?? 'documentId']: relation[props.mainField?.name ?? 'documentId'],
|
4884
|
+
label: usePrev.getRelationLabel(relation, props.mainField),
|
4885
|
+
// @ts-expect-error – targetModel does exist on the attribute, but it's not typed.
|
4886
|
+
href: `../${index.COLLECTION_TYPES}/${props.attribute.targetModel}/${relation.documentId}?${relation.locale ? `plugins[i18n][locale]=${relation.locale}` : ''}`
|
4887
|
+
};
|
4888
|
+
if (ONE_WAY_RELATIONS.includes(props.attribute.relation)) {
|
4889
|
+
// Remove any existing relation so they can be replaced with the new one
|
4890
|
+
field.value?.connect?.forEach(handleDisconnect);
|
4891
|
+
relations.forEach(handleDisconnect);
|
4892
|
+
field.onChange(`${props.name}.connect`, [
|
4893
|
+
item
|
4894
|
+
]);
|
4895
|
+
} else {
|
4896
|
+
field.onChange(`${props.name}.connect`, [
|
4897
|
+
...field.value?.connect ?? [],
|
4898
|
+
item
|
4899
|
+
]);
|
4900
|
+
}
|
4901
|
+
};
|
4902
|
+
return /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
4903
|
+
ref: ref,
|
4904
|
+
direction: "column",
|
4905
|
+
gap: 3,
|
4906
|
+
justifyContent: "space-between",
|
4907
|
+
alignItems: "stretch",
|
4908
|
+
wrap: "wrap",
|
4909
|
+
children: [
|
4910
|
+
/*#__PURE__*/ jsxRuntime.jsxs(StyledFlex, {
|
4911
|
+
direction: "column",
|
4912
|
+
alignItems: "start",
|
4913
|
+
gap: 2,
|
4914
|
+
width: "100%",
|
4915
|
+
children: [
|
4916
|
+
/*#__PURE__*/ jsxRuntime.jsx(RelationsInput, {
|
4917
|
+
disabled: isDisabled,
|
4918
|
+
// NOTE: we should not default to using the documentId if the component is being created (componentUID is undefined)
|
4919
|
+
id: componentUID && component ? componentId ? `${componentId}` : '' : documentId,
|
4920
|
+
label: `${label} ${relationsCount > 0 ? `(${relationsCount})` : ''}`,
|
4921
|
+
model: model,
|
4922
|
+
onChange: handleConnect,
|
4923
|
+
isRelatedToCurrentDocument: isRelatedToCurrentDocument,
|
4924
|
+
...props
|
4925
|
+
}),
|
4926
|
+
'pagination' in data && data.pagination && data.pagination.pageCount > data.pagination.page ? /*#__PURE__*/ jsxRuntime.jsx(designSystem.TextButton, {
|
4927
|
+
disabled: isFetchingMoreRelations,
|
4928
|
+
onClick: handleLoadMore,
|
4929
|
+
loading: isFetchingMoreRelations,
|
4930
|
+
startIcon: /*#__PURE__*/ jsxRuntime.jsx(Icons.ArrowClockwise, {}),
|
4931
|
+
// prevent the label from line-wrapping
|
4932
|
+
shrink: 0,
|
4933
|
+
children: formatMessage({
|
4934
|
+
id: index.getTranslation('relation.loadMore'),
|
4935
|
+
defaultMessage: 'Load More'
|
4936
|
+
})
|
4937
|
+
}) : null
|
4938
|
+
]
|
4939
|
+
}),
|
4940
|
+
/*#__PURE__*/ jsxRuntime.jsx(RelationsList, {
|
4941
|
+
data: relations,
|
4942
|
+
serverData: data.results,
|
4943
|
+
disabled: isDisabled,
|
4944
|
+
name: props.name,
|
4945
|
+
isLoading: isFetchingMoreRelations,
|
4946
|
+
relationType: props.attribute.relation,
|
4947
|
+
// @ts-expect-error – targetModel does exist on the attribute. But it's not typed.
|
4948
|
+
targetModel: props.attribute.targetModel
|
4949
|
+
})
|
4950
|
+
]
|
4951
|
+
});
|
4952
|
+
});
|
4953
|
+
/**
|
4954
|
+
* TODO: this can be removed once we stop shipping Inputs with
|
4955
|
+
* labels wrapped round in DS@2.
|
4956
|
+
*/ const StyledFlex = styledComponents.styled(designSystem.Flex)`
|
4957
|
+
& > div {
|
4958
|
+
width: 100%;
|
4959
|
+
}
|
4960
|
+
`;
|
4961
|
+
/**
|
4962
|
+
* If it's in the connected array, it can get out of our data array,
|
4963
|
+
* we'll be putting it back in later and sorting it anyway.
|
4964
|
+
*/ const removeConnected = ({ field })=>(relations)=>{
|
4965
|
+
return relations.filter((relation)=>{
|
4966
|
+
const connectedRelations = field?.connect ?? [];
|
4967
|
+
return connectedRelations.findIndex((rel)=>rel.id === relation.id) === -1;
|
4968
|
+
});
|
4969
|
+
};
|
4970
|
+
/**
|
4971
|
+
* @description Removes relations that are in the `disconnect` array of the field
|
4972
|
+
*/ const removeDisconnected = ({ field })=>(relations)=>relations.filter((relation)=>{
|
4973
|
+
const disconnectedRelations = field?.disconnect ?? [];
|
4974
|
+
return disconnectedRelations.findIndex((rel)=>rel.id === relation.id) === -1;
|
4975
|
+
});
|
4976
|
+
/**
|
4977
|
+
* @description Adds a label and href to the relation object we use this to render
|
4978
|
+
* a better UI where we can link to the relation and display a human-readable label.
|
4979
|
+
*/ const addLabelAndHref = ({ mainField, href })=>(relations)=>relations.map((relation)=>{
|
4980
|
+
return {
|
4981
|
+
...relation,
|
4982
|
+
// Fallback to `id` if there is no `mainField` value, which will overwrite the above `documentId` property with the exact same data.
|
4983
|
+
[mainField?.name ?? 'documentId']: relation[mainField?.name ?? 'documentId'],
|
4984
|
+
label: usePrev.getRelationLabel(relation, mainField),
|
4985
|
+
href: `${href}/${relation.documentId}?${relation.locale ? `plugins[i18n][locale]=${relation.locale}` : ''}`
|
4986
|
+
};
|
4987
|
+
});
|
4988
|
+
/**
|
4989
|
+
* @description Contains all the logic for the combobox that can search
|
4990
|
+
* for relations and then add them to the field's connect array.
|
4991
|
+
*/ const RelationsInput = ({ hint, id, model, label, labelAction, name, mainField, placeholder, required, unique: _unique, 'aria-label': _ariaLabel, onChange, isRelatedToCurrentDocument, ...props })=>{
|
4992
|
+
const [textValue, setTextValue] = React__namespace.useState('');
|
4993
|
+
const [searchParams, setSearchParams] = React__namespace.useState({
|
4994
|
+
_q: '',
|
4995
|
+
page: 1
|
4996
|
+
});
|
4997
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
4998
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
4999
|
+
const currentDocumentMeta = index.useDocumentContext('RelationsInput', (state)=>state.meta);
|
5000
|
+
const rootDocumentMeta = index.useDocumentContext('RelationsInput', (state)=>state.rootDocumentMeta);
|
5001
|
+
const isRootDocument = rootDocumentMeta.documentId === currentDocumentMeta.documentId;
|
5002
|
+
const documentMeta = isRootDocument ? rootDocumentMeta : currentDocumentMeta;
|
5003
|
+
const { formatMessage } = reactIntl.useIntl();
|
5004
|
+
const fieldRef = strapiAdmin.useFocusInputField(name);
|
5005
|
+
const field = strapiAdmin.useField(name);
|
5006
|
+
const searchParamsDebounced = usePrev.useDebounce(searchParams, 300);
|
5007
|
+
const [searchForTrigger, { data, isLoading }] = usePrev.useLazySearchRelationsQuery();
|
5008
|
+
/**
|
5009
|
+
* Because we're using a lazy query, we need to trigger the search
|
5010
|
+
* when the component mounts and when the search params change.
|
5011
|
+
* We also need to trigger the search when the field value changes
|
5012
|
+
* so that we can filter out the relations that are already connected.
|
5013
|
+
*/ React__namespace.useEffect(()=>{
|
5014
|
+
/**
|
5015
|
+
* The `name` prop is a complete path to the field, e.g. `field1.field2.field3`.
|
5016
|
+
* Where the above example would a nested field within two components, however
|
5017
|
+
* we only require the field on the component not the complete path since we query
|
5018
|
+
* individual components. Therefore we split the string and take the last item.
|
5019
|
+
*/ const [targetField] = name.split('.').slice(-1);
|
5020
|
+
// Return early if there is no relation to the document
|
5021
|
+
if (!isRelatedToCurrentDocument) return;
|
5022
|
+
const params = documentMeta.params ?? index.buildValidParams(query);
|
5023
|
+
searchForTrigger({
|
5024
|
+
model,
|
5025
|
+
targetField,
|
5026
|
+
params: {
|
5027
|
+
...params,
|
5028
|
+
id: id ?? '',
|
5029
|
+
pageSize: 10,
|
5030
|
+
idsToInclude: field.value?.disconnect?.map((rel)=>rel.id.toString()) ?? [],
|
5031
|
+
idsToOmit: field.value?.connect?.map((rel)=>rel.id.toString()) ?? [],
|
5032
|
+
...searchParamsDebounced
|
5033
|
+
}
|
5034
|
+
});
|
5035
|
+
}, [
|
5036
|
+
field.value?.connect,
|
5037
|
+
field.value?.disconnect,
|
5038
|
+
id,
|
5039
|
+
model,
|
5040
|
+
name,
|
5041
|
+
query,
|
5042
|
+
searchForTrigger,
|
5043
|
+
searchParamsDebounced,
|
5044
|
+
isRelatedToCurrentDocument,
|
5045
|
+
documentMeta
|
5046
|
+
]);
|
5047
|
+
const handleSearch = async (search)=>{
|
5048
|
+
setSearchParams((s)=>({
|
5049
|
+
...s,
|
5050
|
+
_q: search,
|
5051
|
+
page: 1
|
5052
|
+
}));
|
5053
|
+
};
|
5054
|
+
const hasNextPage = data?.pagination ? data.pagination.page < data.pagination.pageCount : false;
|
5055
|
+
const options = data?.results ?? [];
|
5056
|
+
const handleChange = (relationId)=>{
|
5057
|
+
if (!relationId) {
|
5058
|
+
return;
|
5059
|
+
}
|
5060
|
+
const relation = options.find((opt)=>opt.id.toString() === relationId);
|
5061
|
+
if (!relation) {
|
5062
|
+
// This is very unlikely to happen, but it ensures we don't have any data for.
|
5063
|
+
console.error("You've tried to add a relation with an id that does not exist in the options you can see, this is likely a bug with Strapi. Please open an issue.");
|
5064
|
+
toggleNotification({
|
5065
|
+
message: formatMessage({
|
5066
|
+
id: index.getTranslation('relation.error-adding-relation'),
|
5067
|
+
defaultMessage: 'An error occurred while trying to add the relation.'
|
5068
|
+
}),
|
5069
|
+
type: 'danger'
|
5070
|
+
});
|
5071
|
+
return;
|
5072
|
+
}
|
5073
|
+
/**
|
5074
|
+
* You need to give this relation a correct _temp_key_ but
|
5075
|
+
* this component doesn't know about those ones, you can't rely
|
5076
|
+
* on the connect array because that doesn't hold items that haven't
|
5077
|
+
* moved. So use a callback to fill in the gaps when connecting.
|
5078
|
+
*
|
5079
|
+
*/ onChange(relation);
|
5080
|
+
};
|
5081
|
+
const handleLoadMore = ()=>{
|
5082
|
+
if (!data || !data.pagination) {
|
5083
|
+
return;
|
5084
|
+
} else if (data.pagination.page < data.pagination.pageCount) {
|
5085
|
+
setSearchParams((s)=>({
|
5086
|
+
...s,
|
5087
|
+
page: s.page + 1
|
5088
|
+
}));
|
5089
|
+
}
|
5090
|
+
};
|
5091
|
+
React__namespace.useLayoutEffect(()=>{
|
5092
|
+
setTextValue('');
|
5093
|
+
}, [
|
5094
|
+
field.value
|
5095
|
+
]);
|
5096
|
+
return /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Field.Root, {
|
5097
|
+
error: field.error,
|
5098
|
+
hint: hint,
|
5099
|
+
name: name,
|
5100
|
+
required: required,
|
5101
|
+
children: [
|
5102
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Label, {
|
5103
|
+
action: labelAction,
|
5104
|
+
children: label
|
5105
|
+
}),
|
5106
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Combobox, {
|
5107
|
+
ref: fieldRef,
|
5108
|
+
name: name,
|
5109
|
+
autocomplete: "list",
|
5110
|
+
placeholder: placeholder || formatMessage({
|
5111
|
+
id: index.getTranslation('relation.add'),
|
5112
|
+
defaultMessage: 'Add relation'
|
5113
|
+
}),
|
5114
|
+
hasMoreItems: hasNextPage,
|
5115
|
+
loading: isLoading,
|
5116
|
+
onOpenChange: ()=>{
|
5117
|
+
handleSearch(textValue ?? '');
|
5118
|
+
},
|
5119
|
+
noOptionsMessage: ()=>formatMessage({
|
5120
|
+
id: index.getTranslation('relation.notAvailable'),
|
5121
|
+
defaultMessage: 'No relations available'
|
5122
|
+
}),
|
5123
|
+
loadingMessage: formatMessage({
|
5124
|
+
id: index.getTranslation('relation.isLoading'),
|
5125
|
+
defaultMessage: 'Relations are loading'
|
5126
|
+
}),
|
5127
|
+
onLoadMore: handleLoadMore,
|
5128
|
+
textValue: textValue,
|
5129
|
+
onChange: handleChange,
|
5130
|
+
onTextValueChange: (text)=>{
|
5131
|
+
setTextValue(text);
|
5132
|
+
},
|
5133
|
+
onInputChange: (event)=>{
|
5134
|
+
handleSearch(event.currentTarget.value);
|
5135
|
+
},
|
5136
|
+
...props,
|
5137
|
+
children: options.map((opt)=>{
|
5138
|
+
const textValue = usePrev.getRelationLabel(opt, mainField);
|
5139
|
+
return /*#__PURE__*/ jsxRuntime.jsx(designSystem.ComboboxOption, {
|
5140
|
+
value: opt.id.toString(),
|
5141
|
+
textValue: textValue,
|
5142
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
5143
|
+
gap: 2,
|
5144
|
+
justifyContent: "space-between",
|
5145
|
+
children: [
|
5146
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
|
5147
|
+
ellipsis: true,
|
5148
|
+
children: textValue
|
5149
|
+
}),
|
5150
|
+
opt.status ? /*#__PURE__*/ jsxRuntime.jsx(index.DocumentStatus, {
|
5151
|
+
status: opt.status
|
5152
|
+
}) : null
|
5153
|
+
]
|
5154
|
+
})
|
5155
|
+
}, opt.id);
|
5156
|
+
})
|
5157
|
+
}),
|
5158
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Error, {}),
|
5159
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Hint, {})
|
5160
|
+
]
|
5161
|
+
});
|
5162
|
+
};
|
5163
|
+
/* -------------------------------------------------------------------------------------------------
|
5164
|
+
* RelationsList
|
5165
|
+
* -----------------------------------------------------------------------------------------------*/ const RELATION_ITEM_HEIGHT = 50;
|
5166
|
+
const RELATION_GUTTER = 4;
|
5167
|
+
const RelationsList = ({ data, serverData, disabled, name, isLoading, relationType, targetModel })=>{
|
5168
|
+
const ariaDescriptionId = React__namespace.useId();
|
5169
|
+
const { formatMessage } = reactIntl.useIntl();
|
5170
|
+
const listRef = React__namespace.useRef(null);
|
5171
|
+
const outerListRef = React__namespace.useRef(null);
|
5172
|
+
const [overflow, setOverflow] = React__namespace.useState();
|
5173
|
+
const [liveText, setLiveText] = React__namespace.useState('');
|
5174
|
+
const field = strapiAdmin.useField(name);
|
5175
|
+
React__namespace.useEffect(()=>{
|
5176
|
+
if (data.length <= RELATIONS_TO_DISPLAY) {
|
5177
|
+
return setOverflow(undefined);
|
5178
|
+
}
|
5179
|
+
const handleNativeScroll = (e)=>{
|
5180
|
+
const el = e.target;
|
5181
|
+
const parentScrollContainerHeight = el.parentNode.scrollHeight;
|
5182
|
+
const maxScrollBottom = el.scrollHeight - el.scrollTop;
|
5183
|
+
if (el.scrollTop === 0) {
|
5184
|
+
return setOverflow('bottom');
|
5185
|
+
}
|
5186
|
+
if (maxScrollBottom === parentScrollContainerHeight) {
|
5187
|
+
return setOverflow('top');
|
5188
|
+
}
|
5189
|
+
return setOverflow('top-bottom');
|
5190
|
+
};
|
5191
|
+
const outerListRefCurrent = outerListRef?.current;
|
5192
|
+
if (!isLoading && data.length > 0 && outerListRefCurrent) {
|
5193
|
+
outerListRef.current.addEventListener('scroll', handleNativeScroll);
|
5194
|
+
}
|
5195
|
+
return ()=>{
|
5196
|
+
if (outerListRefCurrent) {
|
5197
|
+
outerListRefCurrent.removeEventListener('scroll', handleNativeScroll);
|
5198
|
+
}
|
5199
|
+
};
|
5200
|
+
}, [
|
5201
|
+
isLoading,
|
5202
|
+
data.length
|
5203
|
+
]);
|
5204
|
+
const getItemPos = (index)=>`${index + 1} of ${data.length}`;
|
5205
|
+
const handleMoveItem = (newIndex, oldIndex)=>{
|
5206
|
+
const item = data[oldIndex];
|
5207
|
+
setLiveText(formatMessage({
|
5208
|
+
id: index.getTranslation('dnd.reorder'),
|
5209
|
+
defaultMessage: '{item}, moved. New position in list: {position}.'
|
5210
|
+
}, {
|
5211
|
+
item: item.label ?? item.documentId,
|
5212
|
+
position: getItemPos(newIndex)
|
5213
|
+
}));
|
5214
|
+
/**
|
5215
|
+
* Splicing mutates the array, so we need to create a new array
|
5216
|
+
*/ const newData = [
|
5217
|
+
...data
|
5218
|
+
];
|
5219
|
+
const currentRow = data[oldIndex];
|
5220
|
+
const startKey = oldIndex > newIndex ? newData[newIndex - 1]?.__temp_key__ : newData[newIndex]?.__temp_key__;
|
5221
|
+
const endKey = oldIndex > newIndex ? newData[newIndex]?.__temp_key__ : newData[newIndex + 1]?.__temp_key__;
|
5222
|
+
/**
|
5223
|
+
* We're moving the relation between two other relations, so
|
5224
|
+
* we need to generate a new key that keeps the order
|
5225
|
+
*/ const [newKey] = fractionalIndexing.generateNKeysBetween(startKey, endKey, 1);
|
5226
|
+
newData.splice(oldIndex, 1);
|
5227
|
+
newData.splice(newIndex, 0, {
|
5228
|
+
...currentRow,
|
5229
|
+
__temp_key__: newKey
|
5230
|
+
});
|
5231
|
+
/**
|
5232
|
+
* Now we diff against the server to understand what's different so we
|
5233
|
+
* can keep the connect array nice and tidy. It also needs reversing because
|
5234
|
+
* we reverse the relations from the server in the first place.
|
5235
|
+
*/ const connectedRelations = newData.reduce((acc, relation, currentIndex, array)=>{
|
5236
|
+
const relationOnServer = serverData.find((oldRelation)=>oldRelation.id === relation.id);
|
5237
|
+
const relationInFront = array[currentIndex + 1];
|
5238
|
+
if (!relationOnServer || relationOnServer.__temp_key__ !== relation.__temp_key__) {
|
5239
|
+
const position = relationInFront ? {
|
5240
|
+
before: relationInFront.documentId,
|
5241
|
+
locale: relationInFront.locale,
|
5242
|
+
status: 'publishedAt' in relationInFront && relationInFront.publishedAt ? 'published' : 'draft'
|
5243
|
+
} : {
|
5244
|
+
end: true
|
5245
|
+
};
|
5246
|
+
const relationWithPosition = {
|
5247
|
+
...relation,
|
5248
|
+
...{
|
5249
|
+
apiData: {
|
5250
|
+
id: relation.id,
|
5251
|
+
documentId: relation.documentId ?? relation.apiData?.documentId ?? '',
|
5252
|
+
locale: relation.locale || relation.apiData?.locale,
|
5253
|
+
position
|
5254
|
+
}
|
5255
|
+
}
|
5256
|
+
};
|
5257
|
+
return [
|
5258
|
+
...acc,
|
5259
|
+
relationWithPosition
|
5260
|
+
];
|
5261
|
+
}
|
5262
|
+
return acc;
|
5263
|
+
}, []).toReversed();
|
5264
|
+
field.onChange(`${name}.connect`, connectedRelations);
|
5265
|
+
};
|
5266
|
+
const handleGrabItem = (index$1)=>{
|
5267
|
+
const item = data[index$1];
|
5268
|
+
setLiveText(formatMessage({
|
5269
|
+
id: index.getTranslation('dnd.grab-item'),
|
5270
|
+
defaultMessage: `{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel.`
|
5271
|
+
}, {
|
5272
|
+
item: item.label ?? item.documentId,
|
5273
|
+
position: getItemPos(index$1)
|
5274
|
+
}));
|
5275
|
+
};
|
5276
|
+
const handleDropItem = (index$1)=>{
|
5277
|
+
const { href: _href, label, ...item } = data[index$1];
|
5278
|
+
setLiveText(formatMessage({
|
5279
|
+
id: index.getTranslation('dnd.drop-item'),
|
5280
|
+
defaultMessage: `{item}, dropped. Final position in list: {position}.`
|
5281
|
+
}, {
|
5282
|
+
item: label ?? item.documentId,
|
5283
|
+
position: getItemPos(index$1)
|
5284
|
+
}));
|
5285
|
+
};
|
5286
|
+
const handleCancel = (index$1)=>{
|
5287
|
+
const item = data[index$1];
|
5288
|
+
setLiveText(formatMessage({
|
5289
|
+
id: index.getTranslation('dnd.cancel-item'),
|
5290
|
+
defaultMessage: '{item}, dropped. Re-order cancelled.'
|
5291
|
+
}, {
|
5292
|
+
item: item.label ?? item.documentId
|
5293
|
+
}));
|
5294
|
+
};
|
5295
|
+
const handleDisconnect = useHandleDisconnect(name, 'RelationsList');
|
5296
|
+
/**
|
5297
|
+
* These relation types will only ever have one item
|
5298
|
+
* in their list, so you can't reorder a single item!
|
5299
|
+
*/ const canReorder = !ONE_WAY_RELATIONS.includes(relationType);
|
5300
|
+
const dynamicListHeight = data.length > RELATIONS_TO_DISPLAY ? Math.min(data.length, RELATIONS_TO_DISPLAY) * (RELATION_ITEM_HEIGHT + RELATION_GUTTER) + RELATION_ITEM_HEIGHT / 2 : Math.min(data.length, RELATIONS_TO_DISPLAY) * (RELATION_ITEM_HEIGHT + RELATION_GUTTER);
|
5301
|
+
return /*#__PURE__*/ jsxRuntime.jsxs(ShadowBox, {
|
5302
|
+
$overflowDirection: overflow,
|
5303
|
+
children: [
|
5304
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.VisuallyHidden, {
|
5305
|
+
id: ariaDescriptionId,
|
5306
|
+
children: formatMessage({
|
5307
|
+
id: index.getTranslation('dnd.instructions'),
|
5308
|
+
defaultMessage: `Press spacebar to grab and re-order`
|
5309
|
+
})
|
5310
|
+
}),
|
5311
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.VisuallyHidden, {
|
5312
|
+
"aria-live": "assertive",
|
5313
|
+
children: liveText
|
5314
|
+
}),
|
5315
|
+
/*#__PURE__*/ jsxRuntime.jsx(reactWindow.FixedSizeList, {
|
5316
|
+
height: dynamicListHeight,
|
5317
|
+
ref: listRef,
|
5318
|
+
outerRef: outerListRef,
|
5319
|
+
itemCount: data.length,
|
5320
|
+
itemSize: RELATION_ITEM_HEIGHT + RELATION_GUTTER,
|
5321
|
+
itemData: {
|
5322
|
+
ariaDescribedBy: ariaDescriptionId,
|
5323
|
+
canDrag: canReorder,
|
5324
|
+
disabled,
|
5325
|
+
handleCancel,
|
5326
|
+
handleDropItem,
|
5327
|
+
handleGrabItem,
|
5328
|
+
handleMoveItem,
|
5329
|
+
name,
|
5330
|
+
handleDisconnect,
|
5331
|
+
relations: data,
|
5332
|
+
targetModel
|
5333
|
+
},
|
5334
|
+
itemKey: (index)=>data[index].id,
|
5335
|
+
innerElementType: "ol",
|
5336
|
+
children: ListItem
|
5337
|
+
})
|
5338
|
+
]
|
5339
|
+
});
|
5340
|
+
};
|
5341
|
+
const ShadowBox = styledComponents.styled(designSystem.Box)`
|
5342
|
+
position: relative;
|
5343
|
+
overflow: hidden;
|
5344
|
+
flex: 1;
|
5345
|
+
|
5346
|
+
&:before,
|
5347
|
+
&:after {
|
5348
|
+
position: absolute;
|
5349
|
+
width: 100%;
|
5350
|
+
height: 4px;
|
5351
|
+
z-index: 1;
|
5352
|
+
}
|
5353
|
+
|
5354
|
+
&:before {
|
5355
|
+
/* TODO: as for DS Table component we would need this to be handled by the DS theme */
|
5356
|
+
content: '';
|
5357
|
+
background: linear-gradient(rgba(3, 3, 5, 0.2) 0%, rgba(0, 0, 0, 0) 100%);
|
5358
|
+
top: 0;
|
5359
|
+
opacity: ${({ $overflowDirection })=>$overflowDirection === 'top-bottom' || $overflowDirection === 'top' ? 1 : 0};
|
5360
|
+
transition: opacity 0.2s ease-in-out;
|
5361
|
+
}
|
5362
|
+
|
5363
|
+
&:after {
|
5364
|
+
/* TODO: as for DS Table component we would need this to be handled by the DS theme */
|
5365
|
+
content: '';
|
5366
|
+
background: linear-gradient(0deg, rgba(3, 3, 5, 0.2) 0%, rgba(0, 0, 0, 0) 100%);
|
5367
|
+
bottom: 0;
|
5368
|
+
opacity: ${({ $overflowDirection })=>$overflowDirection === 'top-bottom' || $overflowDirection === 'bottom' ? 1 : 0};
|
5369
|
+
transition: opacity 0.2s ease-in-out;
|
5370
|
+
}
|
5371
|
+
`;
|
5372
|
+
const ListItem = ({ data, index: index$1, style })=>{
|
5373
|
+
const { ariaDescribedBy, canDrag = false, disabled = false, handleCancel, handleDisconnect, handleDropItem, handleGrabItem, handleMoveItem, name, relations, targetModel } = data;
|
5374
|
+
const { formatMessage } = reactIntl.useIntl();
|
5375
|
+
const { href, id, label, status, documentId, apiData, locale } = relations[index$1];
|
5376
|
+
const [{ handlerId, isDragging, handleKeyDown }, relationRef, dropRef, dragRef, dragPreviewRef] = objects.useDragAndDrop(canDrag && !disabled, {
|
5377
|
+
type: `${objects.ItemTypes.RELATION}_${name}`,
|
5378
|
+
index: index$1,
|
5379
|
+
item: {
|
5380
|
+
displayedValue: label,
|
5381
|
+
status,
|
5382
|
+
id: id,
|
5383
|
+
index: index$1
|
5384
|
+
},
|
5385
|
+
onMoveItem: handleMoveItem,
|
5386
|
+
onDropItem: handleDropItem,
|
5387
|
+
onGrabItem: handleGrabItem,
|
5388
|
+
onCancel: handleCancel,
|
5389
|
+
dropSensitivity: objects.DROP_SENSITIVITY.REGULAR
|
5390
|
+
});
|
5391
|
+
const composedRefs = designSystem.useComposedRefs(relationRef, dragRef);
|
5392
|
+
React__namespace.useEffect(()=>{
|
5393
|
+
dragPreviewRef(reactDndHtml5Backend.getEmptyImage());
|
5394
|
+
}, [
|
5395
|
+
dragPreviewRef
|
5396
|
+
]);
|
5397
|
+
return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
|
5398
|
+
style: style,
|
5399
|
+
tag: "li",
|
5400
|
+
ref: dropRef,
|
5401
|
+
"aria-describedby": ariaDescribedBy,
|
5402
|
+
cursor: canDrag ? 'all-scroll' : 'default',
|
5403
|
+
children: isDragging ? /*#__PURE__*/ jsxRuntime.jsx(RelationItemPlaceholder, {}) : /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
5404
|
+
paddingTop: 2,
|
5405
|
+
paddingBottom: 2,
|
5406
|
+
paddingLeft: canDrag ? 2 : 4,
|
5407
|
+
paddingRight: 4,
|
5408
|
+
hasRadius: true,
|
5409
|
+
borderColor: "neutral200",
|
5410
|
+
background: disabled ? 'neutral150' : 'neutral0',
|
5411
|
+
justifyContent: "space-between",
|
5412
|
+
ref: composedRefs,
|
5413
|
+
"data-handler-id": handlerId,
|
5414
|
+
children: [
|
5415
|
+
/*#__PURE__*/ jsxRuntime.jsxs(FlexWrapper, {
|
5416
|
+
gap: 1,
|
5417
|
+
children: [
|
5418
|
+
canDrag ? /*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
|
5419
|
+
tag: "div",
|
5420
|
+
role: "button",
|
5421
|
+
tabIndex: 0,
|
5422
|
+
withTooltip: false,
|
5423
|
+
label: formatMessage({
|
5424
|
+
id: index.getTranslation('components.RelationInput.icon-button-aria-label'),
|
5425
|
+
defaultMessage: 'Drag'
|
5426
|
+
}),
|
5427
|
+
variant: "ghost",
|
5428
|
+
onKeyDown: handleKeyDown,
|
5429
|
+
disabled: disabled,
|
5430
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.Drag, {})
|
5431
|
+
}) : null,
|
5432
|
+
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
5433
|
+
width: "100%",
|
5434
|
+
minWidth: 0,
|
5435
|
+
justifyContent: "space-between",
|
5436
|
+
children: [
|
5437
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
|
5438
|
+
minWidth: 0,
|
5439
|
+
paddingTop: 1,
|
5440
|
+
paddingBottom: 1,
|
5441
|
+
paddingRight: 4,
|
5442
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(RelationModalForm, {
|
5443
|
+
triggerButtonLabel: label,
|
5444
|
+
relation: {
|
5445
|
+
documentId: documentId ?? apiData?.documentId,
|
5446
|
+
model: targetModel,
|
5447
|
+
collectionType: getCollectionType(href),
|
5448
|
+
params: {
|
5449
|
+
locale: locale || apiData?.locale || null
|
5450
|
+
}
|
5451
|
+
}
|
5452
|
+
})
|
5453
|
+
}),
|
5454
|
+
status ? /*#__PURE__*/ jsxRuntime.jsx(index.DocumentStatus, {
|
5455
|
+
status: status
|
5456
|
+
}) : null
|
5457
|
+
]
|
5458
|
+
})
|
5459
|
+
]
|
5460
|
+
}),
|
5461
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
|
5462
|
+
paddingLeft: 4,
|
5463
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
|
5464
|
+
onClick: ()=>handleDisconnect(relations[index$1]),
|
5465
|
+
disabled: disabled,
|
5466
|
+
label: formatMessage({
|
5467
|
+
id: index.getTranslation('relation.disconnect'),
|
5468
|
+
defaultMessage: 'Remove'
|
5469
|
+
}),
|
5470
|
+
variant: "ghost",
|
5471
|
+
size: "S",
|
5472
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.Cross, {})
|
5473
|
+
})
|
5474
|
+
})
|
5475
|
+
]
|
5476
|
+
})
|
5477
|
+
});
|
5478
|
+
};
|
5479
|
+
const FlexWrapper = styledComponents.styled(designSystem.Flex)`
|
5480
|
+
width: 100%;
|
5481
|
+
/* Used to prevent endAction to be pushed out of container */
|
5482
|
+
min-width: 0;
|
5483
|
+
|
5484
|
+
& > div[role='button'] {
|
5485
|
+
cursor: all-scroll;
|
5486
|
+
}
|
5487
|
+
`;
|
5488
|
+
const DisconnectButton = styledComponents.styled.button`
|
5489
|
+
svg path {
|
5490
|
+
fill: ${({ theme, disabled })=>disabled ? theme.colors.neutral600 : theme.colors.neutral500};
|
5491
|
+
}
|
5492
|
+
|
5493
|
+
&:hover svg path,
|
5494
|
+
&:focus svg path {
|
5495
|
+
fill: ${({ theme, disabled })=>!disabled && theme.colors.neutral600};
|
5496
|
+
}
|
5497
|
+
`;
|
5498
|
+
const LinkEllipsis = styledComponents.styled(designSystem.Link)`
|
5499
|
+
display: block;
|
5500
|
+
|
5501
|
+
& > span {
|
5502
|
+
white-space: nowrap;
|
5503
|
+
overflow: hidden;
|
5504
|
+
text-overflow: ellipsis;
|
5505
|
+
display: block;
|
5506
|
+
}
|
5507
|
+
`;
|
5508
|
+
const RelationItemPlaceholder = ()=>/*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
|
5509
|
+
paddingTop: 2,
|
5510
|
+
paddingBottom: 2,
|
5511
|
+
paddingLeft: 4,
|
5512
|
+
paddingRight: 4,
|
5513
|
+
hasRadius: true,
|
5514
|
+
borderStyle: "dashed",
|
5515
|
+
borderColor: "primary600",
|
5516
|
+
borderWidth: "1px",
|
5517
|
+
background: "primary100",
|
5518
|
+
height: `calc(100% - ${RELATION_GUTTER}px)`
|
5519
|
+
});
|
5520
|
+
const MemoizedRelationsField = /*#__PURE__*/ React__namespace.memo(RelationsField);
|
5521
|
+
|
5522
|
+
const uidApi = index.contentManagerApi.injectEndpoints({
|
5523
|
+
endpoints: (builder)=>({
|
5524
|
+
getDefaultUID: builder.query({
|
5525
|
+
query: ({ params, ...data })=>{
|
5526
|
+
return {
|
5527
|
+
url: '/content-manager/uid/generate',
|
5528
|
+
method: 'POST',
|
5529
|
+
data,
|
5530
|
+
config: {
|
5531
|
+
params
|
5532
|
+
}
|
5533
|
+
};
|
5534
|
+
},
|
5535
|
+
transformResponse: (response)=>response.data
|
5536
|
+
}),
|
5537
|
+
generateUID: builder.mutation({
|
5538
|
+
query: ({ params, ...data })=>({
|
5539
|
+
url: '/content-manager/uid/generate',
|
5540
|
+
method: 'POST',
|
5541
|
+
data,
|
5542
|
+
config: {
|
5543
|
+
params
|
5544
|
+
}
|
5545
|
+
}),
|
5546
|
+
transformResponse: (response)=>response.data
|
5547
|
+
}),
|
5548
|
+
getAvailability: builder.query({
|
5549
|
+
query: ({ params, ...data })=>({
|
5550
|
+
url: '/content-manager/uid/check-availability',
|
5551
|
+
method: 'POST',
|
5552
|
+
data,
|
5553
|
+
config: {
|
5554
|
+
params
|
5555
|
+
}
|
5556
|
+
}),
|
5557
|
+
providesTags: (_res, _error, params)=>[
|
5558
|
+
{
|
5559
|
+
type: 'UidAvailability',
|
5560
|
+
id: params.contentTypeUID
|
5561
|
+
}
|
5562
|
+
]
|
5563
|
+
})
|
5564
|
+
})
|
5565
|
+
});
|
5566
|
+
const { useGenerateUIDMutation, useGetDefaultUIDQuery, useGetAvailabilityQuery } = uidApi;
|
5567
|
+
|
5568
|
+
/* -------------------------------------------------------------------------------------------------
|
5569
|
+
* InputUID
|
5570
|
+
* -----------------------------------------------------------------------------------------------*/ const UID_REGEX = /^[A-Za-z0-9-_.~]*$/;
|
5571
|
+
const UIDInput = /*#__PURE__*/ React__namespace.forwardRef(({ hint, label, labelAction, name, required, ...props }, ref)=>{
|
5572
|
+
const { model, id } = index.useDoc();
|
5573
|
+
const allFormValues = strapiAdmin.useForm('InputUID', (form)=>form.values);
|
5574
|
+
const [availability, setAvailability] = React__namespace.useState();
|
5575
|
+
const [showRegenerate, setShowRegenerate] = React__namespace.useState(false);
|
5576
|
+
const isCloning = reactRouterDom.useMatch(index.CLONE_PATH) !== null;
|
5577
|
+
const field = strapiAdmin.useField(name);
|
5578
|
+
const debouncedValue = usePrev.useDebounce(field.value, 300);
|
5579
|
+
const hasChanged = debouncedValue !== field.initialValue;
|
5580
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
5581
|
+
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
5582
|
+
const { formatMessage } = reactIntl.useIntl();
|
5583
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
5584
|
+
const params = React__namespace.useMemo(()=>index.buildValidParams(query), [
|
5585
|
+
query
|
5586
|
+
]);
|
5587
|
+
const { data: defaultGeneratedUID, isLoading: isGeneratingDefaultUID, error: apiError } = useGetDefaultUIDQuery({
|
5588
|
+
contentTypeUID: model,
|
5589
|
+
field: name,
|
5590
|
+
data: {
|
5591
|
+
id: id ?? '',
|
5592
|
+
...allFormValues
|
5593
|
+
},
|
5594
|
+
params
|
5595
|
+
}, {
|
5596
|
+
skip: field.value || !required
|
5597
|
+
});
|
5598
|
+
React__namespace.useEffect(()=>{
|
5599
|
+
if (apiError) {
|
5600
|
+
toggleNotification({
|
5601
|
+
type: 'warning',
|
5602
|
+
message: formatAPIError(apiError)
|
5603
|
+
});
|
5604
|
+
}
|
5605
|
+
}, [
|
5606
|
+
apiError,
|
5607
|
+
formatAPIError,
|
5608
|
+
toggleNotification
|
5609
|
+
]);
|
5610
|
+
/**
|
5611
|
+
* If the defaultGeneratedUID is available, then we set it as the value,
|
5612
|
+
* but we also want to set it as the initialValue too.
|
5613
|
+
*/ React__namespace.useEffect(()=>{
|
5614
|
+
if (defaultGeneratedUID && field.value === undefined) {
|
5615
|
+
field.onChange(name, defaultGeneratedUID);
|
5616
|
+
}
|
5617
|
+
}, [
|
5618
|
+
defaultGeneratedUID,
|
5619
|
+
field,
|
5620
|
+
name
|
5621
|
+
]);
|
5622
|
+
const [generateUID, { isLoading: isGeneratingUID }] = useGenerateUIDMutation();
|
5623
|
+
const handleRegenerateClick = async ()=>{
|
5624
|
+
try {
|
5625
|
+
const res = await generateUID({
|
5626
|
+
contentTypeUID: model,
|
5627
|
+
field: name,
|
5628
|
+
data: {
|
5629
|
+
id: id ?? '',
|
5630
|
+
...allFormValues
|
5631
|
+
},
|
5632
|
+
params
|
5633
|
+
});
|
5634
|
+
if ('data' in res) {
|
5635
|
+
field.onChange(name, res.data);
|
5636
|
+
} else {
|
5637
|
+
toggleNotification({
|
5638
|
+
type: 'danger',
|
5639
|
+
message: formatAPIError(res.error)
|
5640
|
+
});
|
5641
|
+
}
|
5642
|
+
} catch (err) {
|
5643
|
+
toggleNotification({
|
5644
|
+
type: 'danger',
|
5645
|
+
message: formatMessage({
|
5646
|
+
id: 'notification.error',
|
5647
|
+
defaultMessage: 'An error occurred.'
|
5648
|
+
})
|
5649
|
+
});
|
5650
|
+
}
|
5651
|
+
};
|
5652
|
+
const { data: availabilityData, isLoading: isCheckingAvailability, error: availabilityError } = useGetAvailabilityQuery({
|
5653
|
+
contentTypeUID: model,
|
5654
|
+
field: name,
|
5655
|
+
value: debouncedValue ? debouncedValue.trim() : '',
|
5656
|
+
params
|
5657
|
+
}, {
|
5658
|
+
// Don't check availability if the value is empty or wasn't changed
|
5659
|
+
skip: !Boolean((hasChanged || isCloning) && debouncedValue && UID_REGEX.test(debouncedValue.trim()))
|
5660
|
+
});
|
5661
|
+
React__namespace.useEffect(()=>{
|
5662
|
+
if (availabilityError) {
|
5663
|
+
toggleNotification({
|
5664
|
+
type: 'warning',
|
5665
|
+
message: formatAPIError(availabilityError)
|
5666
|
+
});
|
5667
|
+
}
|
5668
|
+
}, [
|
5669
|
+
availabilityError,
|
4153
5670
|
formatAPIError,
|
4154
5671
|
toggleNotification
|
4155
5672
|
]);
|
@@ -5506,14 +7023,14 @@ const quoteAndCodeHandler = (editor, markdownType)=>{
|
|
5506
7023
|
};
|
5507
7024
|
|
5508
7025
|
// NAV BUTTONS
|
5509
|
-
|
7026
|
+
styledComponents.styled(designSystem.IconButtonGroup)`
|
5510
7027
|
margin-left: ${({ theme })=>theme.spaces[4]};
|
5511
7028
|
`;
|
5512
|
-
|
7029
|
+
styledComponents.styled(designSystem.IconButton)`
|
5513
7030
|
margin: ${({ theme })=>`0 ${theme.spaces[2]}`};
|
5514
7031
|
`;
|
5515
7032
|
// NAV
|
5516
|
-
|
7033
|
+
styledComponents.styled(designSystem.IconButtonGroup)`
|
5517
7034
|
margin-right: ${({ theme })=>`${theme.spaces[2]}`};
|
5518
7035
|
`;
|
5519
7036
|
// FOOTER
|
@@ -5562,254 +7079,524 @@ const WysiwygFooter = ({ onToggleExpand })=>{
|
|
5562
7079
|
defaultMessage: 'Expand'
|
5563
7080
|
})
|
5564
7081
|
}),
|
5565
|
-
/*#__PURE__*/ jsxRuntime.jsx(Icons.Expand, {})
|
7082
|
+
/*#__PURE__*/ jsxRuntime.jsx(Icons.Expand, {})
|
7083
|
+
]
|
7084
|
+
})
|
7085
|
+
})
|
7086
|
+
});
|
7087
|
+
};
|
7088
|
+
|
7089
|
+
/**
|
7090
|
+
* TODO: refactor this mess.
|
7091
|
+
*/ const WysiwygNav = ({ disabled, editorRef, isPreviewMode, onToggleMediaLib, onTogglePreviewMode })=>{
|
7092
|
+
const { formatMessage } = reactIntl.useIntl();
|
7093
|
+
const isDisabled = disabled || isPreviewMode;
|
7094
|
+
const handleActionClick = (value, currentEditorRef)=>{
|
7095
|
+
switch(value){
|
7096
|
+
case 'Link':
|
7097
|
+
{
|
7098
|
+
markdownHandler(currentEditorRef, value);
|
7099
|
+
break;
|
7100
|
+
}
|
7101
|
+
case 'Code':
|
7102
|
+
case 'Quote':
|
7103
|
+
{
|
7104
|
+
quoteAndCodeHandler(currentEditorRef, value);
|
7105
|
+
break;
|
7106
|
+
}
|
7107
|
+
case 'Bold':
|
7108
|
+
case 'Italic':
|
7109
|
+
case 'Underline':
|
7110
|
+
case 'Strikethrough':
|
7111
|
+
{
|
7112
|
+
markdownHandler(currentEditorRef, value);
|
7113
|
+
break;
|
7114
|
+
}
|
7115
|
+
case 'BulletList':
|
7116
|
+
case 'NumberList':
|
7117
|
+
{
|
7118
|
+
listHandler(currentEditorRef, value);
|
7119
|
+
break;
|
7120
|
+
}
|
7121
|
+
case 'h1':
|
7122
|
+
case 'h2':
|
7123
|
+
case 'h3':
|
7124
|
+
case 'h4':
|
7125
|
+
case 'h5':
|
7126
|
+
case 'h6':
|
7127
|
+
{
|
7128
|
+
titleHandler(currentEditorRef, value);
|
7129
|
+
break;
|
7130
|
+
}
|
7131
|
+
}
|
7132
|
+
};
|
7133
|
+
const observedComponents = [
|
7134
|
+
{
|
7135
|
+
toolbar: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.IconButtonGroup, {
|
7136
|
+
children: [
|
7137
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
|
7138
|
+
disabled: isDisabled,
|
7139
|
+
onClick: ()=>handleActionClick('Bold', editorRef),
|
7140
|
+
label: formatMessage({
|
7141
|
+
id: 'components.Blocks.modifiers.bold',
|
7142
|
+
defaultMessage: 'Bold'
|
7143
|
+
}),
|
7144
|
+
name: formatMessage({
|
7145
|
+
id: 'components.Blocks.modifiers.bold',
|
7146
|
+
defaultMessage: 'Bold'
|
7147
|
+
}),
|
7148
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.Bold, {})
|
7149
|
+
}),
|
7150
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
|
7151
|
+
disabled: isDisabled,
|
7152
|
+
onClick: ()=>handleActionClick('Italic', editorRef),
|
7153
|
+
label: formatMessage({
|
7154
|
+
id: 'components.Blocks.modifiers.italic',
|
7155
|
+
defaultMessage: 'Italic'
|
7156
|
+
}),
|
7157
|
+
name: formatMessage({
|
7158
|
+
id: 'components.Blocks.modifiers.italic',
|
7159
|
+
defaultMessage: 'Italic'
|
7160
|
+
}),
|
7161
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.Italic, {})
|
7162
|
+
}),
|
7163
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
|
7164
|
+
disabled: isDisabled,
|
7165
|
+
onClick: ()=>handleActionClick('Underline', editorRef),
|
7166
|
+
label: formatMessage({
|
7167
|
+
id: 'components.Blocks.modifiers.underline',
|
7168
|
+
defaultMessage: 'Underline'
|
7169
|
+
}),
|
7170
|
+
name: formatMessage({
|
7171
|
+
id: 'components.Blocks.modifiers.underline',
|
7172
|
+
defaultMessage: 'Underline'
|
7173
|
+
}),
|
7174
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.Underline, {})
|
7175
|
+
}),
|
7176
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
|
7177
|
+
disabled: isDisabled,
|
7178
|
+
onClick: ()=>handleActionClick('Strikethrough', editorRef),
|
7179
|
+
label: formatMessage({
|
7180
|
+
id: 'components.Blocks.modifiers.strikethrough',
|
7181
|
+
defaultMessage: 'Strikethrough'
|
7182
|
+
}),
|
7183
|
+
name: formatMessage({
|
7184
|
+
id: 'components.Blocks.modifiers.strikethrough',
|
7185
|
+
defaultMessage: 'Strikethrough'
|
7186
|
+
}),
|
7187
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.StrikeThrough, {})
|
7188
|
+
})
|
7189
|
+
]
|
7190
|
+
}),
|
7191
|
+
menu: /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
7192
|
+
children: [
|
7193
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Menu.Separator, {}),
|
7194
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Menu.Item, {
|
7195
|
+
onSelect: ()=>handleActionClick('Bold', editorRef),
|
7196
|
+
disabled: isDisabled,
|
7197
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
7198
|
+
tag: "span",
|
7199
|
+
gap: 2,
|
7200
|
+
children: [
|
7201
|
+
/*#__PURE__*/ jsxRuntime.jsx(Icons.Bold, {
|
7202
|
+
"aria-hidden": true,
|
7203
|
+
fill: "neutral600"
|
7204
|
+
}),
|
7205
|
+
formatMessage({
|
7206
|
+
id: 'components.Blocks.modifiers.bold',
|
7207
|
+
defaultMessage: 'Bold'
|
7208
|
+
})
|
7209
|
+
]
|
7210
|
+
})
|
7211
|
+
}),
|
7212
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Menu.Item, {
|
7213
|
+
onSelect: ()=>handleActionClick('Italic', editorRef),
|
7214
|
+
disabled: isDisabled,
|
7215
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
7216
|
+
tag: "span",
|
7217
|
+
gap: 2,
|
7218
|
+
children: [
|
7219
|
+
/*#__PURE__*/ jsxRuntime.jsx(Icons.Italic, {
|
7220
|
+
"aria-hidden": true,
|
7221
|
+
fill: "neutral600"
|
7222
|
+
}),
|
7223
|
+
formatMessage({
|
7224
|
+
id: 'components.Blocks.modifiers.italic',
|
7225
|
+
defaultMessage: 'Italic'
|
7226
|
+
})
|
7227
|
+
]
|
7228
|
+
})
|
7229
|
+
}),
|
7230
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Menu.Item, {
|
7231
|
+
onSelect: ()=>handleActionClick('Underline', editorRef),
|
7232
|
+
disabled: isDisabled,
|
7233
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
7234
|
+
tag: "span",
|
7235
|
+
gap: 2,
|
7236
|
+
children: [
|
7237
|
+
/*#__PURE__*/ jsxRuntime.jsx(Icons.Underline, {
|
7238
|
+
"aria-hidden": true,
|
7239
|
+
fill: "neutral600"
|
7240
|
+
}),
|
7241
|
+
formatMessage({
|
7242
|
+
id: 'components.Blocks.modifiers.underline',
|
7243
|
+
defaultMessage: 'Underline'
|
7244
|
+
})
|
7245
|
+
]
|
7246
|
+
})
|
7247
|
+
}),
|
7248
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Menu.Item, {
|
7249
|
+
onSelect: ()=>handleActionClick('Strikethrough', editorRef),
|
7250
|
+
disabled: isDisabled,
|
7251
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
7252
|
+
tag: "span",
|
7253
|
+
gap: 2,
|
7254
|
+
children: [
|
7255
|
+
/*#__PURE__*/ jsxRuntime.jsx(Icons.StrikeThrough, {
|
7256
|
+
"aria-hidden": true,
|
7257
|
+
fill: "neutral600"
|
7258
|
+
}),
|
7259
|
+
formatMessage({
|
7260
|
+
id: 'components.Blocks.modifiers.strikethrough',
|
7261
|
+
defaultMessage: 'Strikethrough'
|
7262
|
+
})
|
7263
|
+
]
|
7264
|
+
})
|
7265
|
+
})
|
5566
7266
|
]
|
5567
|
-
})
|
5568
|
-
|
5569
|
-
|
5570
|
-
|
5571
|
-
|
5572
|
-
|
5573
|
-
|
5574
|
-
|
5575
|
-
|
5576
|
-
|
5577
|
-
|
5578
|
-
|
5579
|
-
|
5580
|
-
|
5581
|
-
|
5582
|
-
|
5583
|
-
|
5584
|
-
|
5585
|
-
|
5586
|
-
|
5587
|
-
|
5588
|
-
|
5589
|
-
|
5590
|
-
|
5591
|
-
|
5592
|
-
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
5593
|
-
children: [
|
5594
|
-
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Root, {
|
5595
|
-
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.SingleSelect, {
|
5596
|
-
disabled: true,
|
5597
|
-
placeholder: selectPlaceholder,
|
5598
|
-
"aria-label": selectPlaceholder,
|
5599
|
-
size: "S",
|
5600
|
-
children: [
|
5601
|
-
/*#__PURE__*/ jsxRuntime.jsx(designSystem.SingleSelectOption, {
|
5602
|
-
value: "h1",
|
5603
|
-
children: "h1"
|
5604
|
-
}),
|
5605
|
-
/*#__PURE__*/ jsxRuntime.jsx(designSystem.SingleSelectOption, {
|
5606
|
-
value: "h2",
|
5607
|
-
children: "h2"
|
5608
|
-
}),
|
5609
|
-
/*#__PURE__*/ jsxRuntime.jsx(designSystem.SingleSelectOption, {
|
5610
|
-
value: "h3",
|
5611
|
-
children: "h3"
|
5612
|
-
}),
|
5613
|
-
/*#__PURE__*/ jsxRuntime.jsx(designSystem.SingleSelectOption, {
|
5614
|
-
value: "h4",
|
5615
|
-
children: "h4"
|
5616
|
-
}),
|
5617
|
-
/*#__PURE__*/ jsxRuntime.jsx(designSystem.SingleSelectOption, {
|
5618
|
-
value: "h5",
|
5619
|
-
children: "h5"
|
5620
|
-
}),
|
5621
|
-
/*#__PURE__*/ jsxRuntime.jsx(designSystem.SingleSelectOption, {
|
5622
|
-
value: "h6",
|
5623
|
-
children: "h6"
|
5624
|
-
})
|
5625
|
-
]
|
5626
|
-
})
|
7267
|
+
}),
|
7268
|
+
key: 'formatting-group-1'
|
7269
|
+
},
|
7270
|
+
{
|
7271
|
+
toolbar: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.IconButtonGroup, {
|
7272
|
+
children: [
|
7273
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
|
7274
|
+
disabled: isDisabled,
|
7275
|
+
onClick: ()=>handleActionClick('BulletList', editorRef),
|
7276
|
+
label: formatMessage({
|
7277
|
+
id: 'components.Blocks.blocks.bulletList',
|
7278
|
+
defaultMessage: 'Bulleted list'
|
7279
|
+
}),
|
7280
|
+
name: formatMessage({
|
7281
|
+
id: 'components.Blocks.blocks.bulletList',
|
7282
|
+
defaultMessage: 'Bulleted list'
|
7283
|
+
}),
|
7284
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.BulletList, {})
|
7285
|
+
}),
|
7286
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
|
7287
|
+
disabled: isDisabled,
|
7288
|
+
onClick: ()=>handleActionClick('NumberList', editorRef),
|
7289
|
+
label: formatMessage({
|
7290
|
+
id: 'components.Blocks.blocks.numberList',
|
7291
|
+
defaultMessage: 'Numbered list'
|
5627
7292
|
}),
|
5628
|
-
|
7293
|
+
name: formatMessage({
|
7294
|
+
id: 'components.Blocks.blocks.numberList',
|
7295
|
+
defaultMessage: 'Numbered list'
|
7296
|
+
}),
|
7297
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.NumberList, {})
|
7298
|
+
})
|
7299
|
+
]
|
7300
|
+
}),
|
7301
|
+
menu: /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
7302
|
+
children: [
|
7303
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Menu.Separator, {}),
|
7304
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Menu.Item, {
|
7305
|
+
onSelect: ()=>handleActionClick('BulletList', editorRef),
|
7306
|
+
disabled: isDisabled,
|
7307
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
7308
|
+
tag: "span",
|
7309
|
+
gap: 2,
|
5629
7310
|
children: [
|
5630
|
-
/*#__PURE__*/ jsxRuntime.jsx(
|
5631
|
-
|
5632
|
-
|
5633
|
-
name: "Bold",
|
5634
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.Bold, {})
|
7311
|
+
/*#__PURE__*/ jsxRuntime.jsx(Icons.BulletList, {
|
7312
|
+
"aria-hidden": true,
|
7313
|
+
fill: "neutral600"
|
5635
7314
|
}),
|
5636
|
-
|
5637
|
-
|
5638
|
-
|
5639
|
-
|
5640
|
-
|
7315
|
+
formatMessage({
|
7316
|
+
id: 'components.Blocks.blocks.unorderedList',
|
7317
|
+
defaultMessage: 'Bulleted list'
|
7318
|
+
})
|
7319
|
+
]
|
7320
|
+
})
|
7321
|
+
}),
|
7322
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Menu.Item, {
|
7323
|
+
onSelect: ()=>handleActionClick('NumberList', editorRef),
|
7324
|
+
disabled: isDisabled,
|
7325
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
7326
|
+
tag: "span",
|
7327
|
+
gap: 2,
|
7328
|
+
children: [
|
7329
|
+
/*#__PURE__*/ jsxRuntime.jsx(Icons.NumberList, {
|
7330
|
+
"aria-hidden": true,
|
7331
|
+
fill: "neutral600"
|
5641
7332
|
}),
|
5642
|
-
|
5643
|
-
|
5644
|
-
|
5645
|
-
name: "Underline",
|
5646
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.Underline, {})
|
7333
|
+
formatMessage({
|
7334
|
+
id: 'components.Blocks.blocks.orderedList',
|
7335
|
+
defaultMessage: 'Numbered list'
|
5647
7336
|
})
|
5648
7337
|
]
|
5649
|
-
}),
|
5650
|
-
/*#__PURE__*/ jsxRuntime.jsx(MoreButton, {
|
5651
|
-
disabled: true,
|
5652
|
-
label: "More",
|
5653
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.More, {})
|
5654
7338
|
})
|
5655
|
-
]
|
5656
|
-
}),
|
5657
|
-
!isExpandMode && /*#__PURE__*/ jsxRuntime.jsx(designSystem.Button, {
|
5658
|
-
onClick: onTogglePreviewMode,
|
5659
|
-
variant: "tertiary",
|
5660
|
-
children: formatMessage({
|
5661
|
-
id: 'components.Wysiwyg.ToggleMode.markdown-mode',
|
5662
|
-
defaultMessage: 'Markdown mode'
|
5663
7339
|
})
|
5664
|
-
|
5665
|
-
|
5666
|
-
|
5667
|
-
|
5668
|
-
|
5669
|
-
|
5670
|
-
|
5671
|
-
|
5672
|
-
|
5673
|
-
|
5674
|
-
|
7340
|
+
]
|
7341
|
+
}),
|
7342
|
+
key: 'formatting-group-2'
|
7343
|
+
},
|
7344
|
+
{
|
7345
|
+
toolbar: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.IconButtonGroup, {
|
7346
|
+
children: [
|
7347
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
|
7348
|
+
disabled: isDisabled,
|
7349
|
+
onClick: ()=>handleActionClick('Code', editorRef),
|
7350
|
+
label: formatMessage({
|
7351
|
+
id: 'components.Wysiwyg.blocks.code',
|
7352
|
+
defaultMessage: 'Code'
|
7353
|
+
}),
|
7354
|
+
name: formatMessage({
|
7355
|
+
id: 'components.Wysiwyg.blocks.code',
|
7356
|
+
defaultMessage: 'Code'
|
7357
|
+
}),
|
7358
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.Code, {})
|
7359
|
+
}),
|
7360
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
|
7361
|
+
disabled: isDisabled,
|
7362
|
+
onClick: ()=>{
|
7363
|
+
onToggleMediaLib();
|
7364
|
+
},
|
7365
|
+
label: formatMessage({
|
7366
|
+
id: 'components.Blocks.blocks.image',
|
7367
|
+
defaultMessage: 'Image'
|
7368
|
+
}),
|
7369
|
+
name: formatMessage({
|
7370
|
+
id: 'components.Blocks.blocks.image',
|
7371
|
+
defaultMessage: 'Image'
|
7372
|
+
}),
|
7373
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.Image, {})
|
7374
|
+
}),
|
7375
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
|
7376
|
+
disabled: isDisabled,
|
7377
|
+
onClick: ()=>handleActionClick('Link', editorRef),
|
7378
|
+
label: formatMessage({
|
7379
|
+
id: 'components.Blocks.popover.link',
|
7380
|
+
defaultMessage: 'Link'
|
7381
|
+
}),
|
7382
|
+
name: formatMessage({
|
7383
|
+
id: 'components.Blocks.popover.link',
|
7384
|
+
defaultMessage: 'Link'
|
7385
|
+
}),
|
7386
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.Link, {})
|
7387
|
+
}),
|
7388
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
|
7389
|
+
disabled: isDisabled,
|
7390
|
+
onClick: ()=>handleActionClick('Quote', editorRef),
|
7391
|
+
label: formatMessage({
|
7392
|
+
id: 'components.Blocks.blocks.quote',
|
7393
|
+
defaultMessage: 'Quote'
|
7394
|
+
}),
|
7395
|
+
name: formatMessage({
|
7396
|
+
id: 'components.Blocks.blocks.quote',
|
7397
|
+
defaultMessage: 'Quote'
|
7398
|
+
}),
|
7399
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.Quotes, {})
|
7400
|
+
})
|
7401
|
+
]
|
7402
|
+
}),
|
7403
|
+
menu: /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
5675
7404
|
children: [
|
5676
|
-
/*#__PURE__*/ jsxRuntime.jsx(designSystem.
|
5677
|
-
|
5678
|
-
|
5679
|
-
|
5680
|
-
|
5681
|
-
|
5682
|
-
|
7405
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Menu.Separator, {}),
|
7406
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Menu.Item, {
|
7407
|
+
onSelect: ()=>handleActionClick('Code', editorRef),
|
7408
|
+
disabled: isDisabled,
|
7409
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
7410
|
+
tag: "span",
|
7411
|
+
gap: 2,
|
5683
7412
|
children: [
|
5684
|
-
/*#__PURE__*/ jsxRuntime.jsx(
|
5685
|
-
|
5686
|
-
|
5687
|
-
}),
|
5688
|
-
/*#__PURE__*/ jsxRuntime.jsx(designSystem.SingleSelectOption, {
|
5689
|
-
value: "h2",
|
5690
|
-
children: "h2"
|
7413
|
+
/*#__PURE__*/ jsxRuntime.jsx(Icons.Code, {
|
7414
|
+
"aria-hidden": true,
|
7415
|
+
fill: "neutral600"
|
5691
7416
|
}),
|
5692
|
-
|
5693
|
-
|
5694
|
-
|
7417
|
+
formatMessage({
|
7418
|
+
id: 'components.Wysiwyg.blocks.code',
|
7419
|
+
defaultMessage: 'Code'
|
7420
|
+
})
|
7421
|
+
]
|
7422
|
+
})
|
7423
|
+
}),
|
7424
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Menu.Item, {
|
7425
|
+
startIcon: /*#__PURE__*/ jsxRuntime.jsx(Icons.Image, {}),
|
7426
|
+
onSelect: ()=>{
|
7427
|
+
onToggleMediaLib();
|
7428
|
+
},
|
7429
|
+
disabled: isDisabled,
|
7430
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
7431
|
+
tag: "span",
|
7432
|
+
gap: 2,
|
7433
|
+
children: [
|
7434
|
+
/*#__PURE__*/ jsxRuntime.jsx(Icons.Image, {
|
7435
|
+
"aria-hidden": true,
|
7436
|
+
fill: "neutral600"
|
5695
7437
|
}),
|
5696
|
-
|
5697
|
-
|
5698
|
-
|
7438
|
+
formatMessage({
|
7439
|
+
id: 'components.Blocks.blocks.image',
|
7440
|
+
defaultMessage: 'Image'
|
7441
|
+
})
|
7442
|
+
]
|
7443
|
+
})
|
7444
|
+
}),
|
7445
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Menu.Item, {
|
7446
|
+
startIcon: /*#__PURE__*/ jsxRuntime.jsx(Icons.Link, {}),
|
7447
|
+
onSelect: ()=>handleActionClick('Link', editorRef),
|
7448
|
+
disabled: isDisabled,
|
7449
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
7450
|
+
tag: "span",
|
7451
|
+
gap: 2,
|
7452
|
+
children: [
|
7453
|
+
/*#__PURE__*/ jsxRuntime.jsx(Icons.Link, {
|
7454
|
+
"aria-hidden": true,
|
7455
|
+
fill: "neutral600"
|
5699
7456
|
}),
|
5700
|
-
|
5701
|
-
|
5702
|
-
|
7457
|
+
formatMessage({
|
7458
|
+
id: 'components.Blocks.popover.link',
|
7459
|
+
defaultMessage: 'Link'
|
7460
|
+
})
|
7461
|
+
]
|
7462
|
+
})
|
7463
|
+
}),
|
7464
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Menu.Item, {
|
7465
|
+
onSelect: ()=>handleActionClick('Quote', editorRef),
|
7466
|
+
disabled: isDisabled,
|
7467
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
7468
|
+
tag: "span",
|
7469
|
+
gap: 2,
|
7470
|
+
children: [
|
7471
|
+
/*#__PURE__*/ jsxRuntime.jsx(Icons.Quotes, {
|
7472
|
+
"aria-hidden": true,
|
7473
|
+
fill: "neutral600"
|
5703
7474
|
}),
|
5704
|
-
|
5705
|
-
|
5706
|
-
|
7475
|
+
formatMessage({
|
7476
|
+
id: 'components.Blocks.blocks.quote',
|
7477
|
+
defaultMessage: 'Quote'
|
5707
7478
|
})
|
5708
7479
|
]
|
5709
7480
|
})
|
7481
|
+
})
|
7482
|
+
]
|
7483
|
+
}),
|
7484
|
+
key: 'formatting-group-3'
|
7485
|
+
}
|
7486
|
+
];
|
7487
|
+
return /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
7488
|
+
padding: 2,
|
7489
|
+
background: "neutral100",
|
7490
|
+
justifyContent: "space-between",
|
7491
|
+
borderRadius: "0.4rem 0.4rem 0 0",
|
7492
|
+
width: "100%",
|
7493
|
+
gap: 4,
|
7494
|
+
children: [
|
7495
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Root, {
|
7496
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.SingleSelect, {
|
7497
|
+
disabled: isDisabled,
|
7498
|
+
placeholder: formatMessage({
|
7499
|
+
id: 'components.Wysiwyg.selectOptions.title',
|
7500
|
+
defaultMessage: 'Headings'
|
5710
7501
|
}),
|
5711
|
-
|
5712
|
-
|
5713
|
-
|
5714
|
-
|
5715
|
-
|
5716
|
-
|
5717
|
-
|
7502
|
+
"aria-label": formatMessage({
|
7503
|
+
id: 'components.Wysiwyg.selectOptions.title',
|
7504
|
+
defaultMessage: 'Headings'
|
7505
|
+
}),
|
7506
|
+
// @ts-expect-error – DS v2 will only allow strings.
|
7507
|
+
onChange: (value)=>handleActionClick(value, editorRef),
|
7508
|
+
size: "S",
|
7509
|
+
children: [
|
7510
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.SingleSelectOption, {
|
7511
|
+
value: "h1",
|
7512
|
+
startIcon: /*#__PURE__*/ jsxRuntime.jsx(Icons.HeadingOne, {
|
7513
|
+
fill: "neutral600"
|
5718
7514
|
}),
|
5719
|
-
|
5720
|
-
|
5721
|
-
|
5722
|
-
|
5723
|
-
|
7515
|
+
children: formatMessage({
|
7516
|
+
id: 'components.Wysiwyg.selectOptions.H1',
|
7517
|
+
defaultMessage: 'Heading 1'
|
7518
|
+
})
|
7519
|
+
}),
|
7520
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.SingleSelectOption, {
|
7521
|
+
value: "h2",
|
7522
|
+
startIcon: /*#__PURE__*/ jsxRuntime.jsx(Icons.HeadingTwo, {
|
7523
|
+
fill: "neutral600"
|
5724
7524
|
}),
|
5725
|
-
|
5726
|
-
|
5727
|
-
|
5728
|
-
name: "Underline",
|
5729
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.Underline, {})
|
7525
|
+
children: formatMessage({
|
7526
|
+
id: 'components.Wysiwyg.selectOptions.H2',
|
7527
|
+
defaultMessage: 'Heading 2'
|
5730
7528
|
})
|
5731
|
-
|
5732
|
-
|
5733
|
-
|
5734
|
-
|
5735
|
-
|
5736
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(MoreButton, {
|
5737
|
-
label: "More",
|
5738
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.More, {})
|
5739
|
-
})
|
7529
|
+
}),
|
7530
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.SingleSelectOption, {
|
7531
|
+
value: "h3",
|
7532
|
+
startIcon: /*#__PURE__*/ jsxRuntime.jsx(Icons.HeadingThree, {
|
7533
|
+
fill: "neutral600"
|
5740
7534
|
}),
|
5741
|
-
|
5742
|
-
|
5743
|
-
|
5744
|
-
padding: 2,
|
5745
|
-
children: [
|
5746
|
-
/*#__PURE__*/ jsxRuntime.jsxs(IconButtonGroupMargin, {
|
5747
|
-
children: [
|
5748
|
-
/*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
|
5749
|
-
onClick: ()=>onActionClick('Strikethrough', editorRef, handleTogglePopover),
|
5750
|
-
label: "Strikethrough",
|
5751
|
-
name: "Strikethrough",
|
5752
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.StrikeThrough, {})
|
5753
|
-
}),
|
5754
|
-
/*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
|
5755
|
-
onClick: ()=>onActionClick('BulletList', editorRef, handleTogglePopover),
|
5756
|
-
label: "BulletList",
|
5757
|
-
name: "BulletList",
|
5758
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.BulletList, {})
|
5759
|
-
}),
|
5760
|
-
/*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
|
5761
|
-
onClick: ()=>onActionClick('NumberList', editorRef, handleTogglePopover),
|
5762
|
-
label: "NumberList",
|
5763
|
-
name: "NumberList",
|
5764
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.NumberList, {})
|
5765
|
-
})
|
5766
|
-
]
|
5767
|
-
}),
|
5768
|
-
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.IconButtonGroup, {
|
5769
|
-
children: [
|
5770
|
-
/*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
|
5771
|
-
onClick: ()=>onActionClick('Code', editorRef, handleTogglePopover),
|
5772
|
-
label: "Code",
|
5773
|
-
name: "Code",
|
5774
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.Code, {})
|
5775
|
-
}),
|
5776
|
-
/*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
|
5777
|
-
onClick: ()=>{
|
5778
|
-
handleTogglePopover();
|
5779
|
-
onToggleMediaLib();
|
5780
|
-
},
|
5781
|
-
label: "Image",
|
5782
|
-
name: "Image",
|
5783
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.Image, {})
|
5784
|
-
}),
|
5785
|
-
/*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
|
5786
|
-
onClick: ()=>onActionClick('Link', editorRef, handleTogglePopover),
|
5787
|
-
label: "Link",
|
5788
|
-
name: "Link",
|
5789
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.Link, {})
|
5790
|
-
}),
|
5791
|
-
/*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
|
5792
|
-
onClick: ()=>onActionClick('Quote', editorRef, handleTogglePopover),
|
5793
|
-
label: "Quote",
|
5794
|
-
name: "Quote",
|
5795
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.Quotes, {})
|
5796
|
-
})
|
5797
|
-
]
|
5798
|
-
})
|
5799
|
-
]
|
5800
|
-
})
|
7535
|
+
children: formatMessage({
|
7536
|
+
id: 'components.Wysiwyg.selectOptions.H3',
|
7537
|
+
defaultMessage: 'Heading 3'
|
5801
7538
|
})
|
5802
|
-
|
7539
|
+
}),
|
7540
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.SingleSelectOption, {
|
7541
|
+
value: "h4",
|
7542
|
+
startIcon: /*#__PURE__*/ jsxRuntime.jsx(Icons.HeadingFour, {
|
7543
|
+
fill: "neutral600"
|
7544
|
+
}),
|
7545
|
+
children: formatMessage({
|
7546
|
+
id: 'components.Wysiwyg.selectOptions.H4',
|
7547
|
+
defaultMessage: 'Heading 4'
|
7548
|
+
})
|
7549
|
+
}),
|
7550
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.SingleSelectOption, {
|
7551
|
+
value: "h5",
|
7552
|
+
startIcon: /*#__PURE__*/ jsxRuntime.jsx(Icons.HeadingFive, {
|
7553
|
+
fill: "neutral600"
|
7554
|
+
}),
|
7555
|
+
children: formatMessage({
|
7556
|
+
id: 'components.Wysiwyg.selectOptions.H5',
|
7557
|
+
defaultMessage: 'Heading 5'
|
7558
|
+
})
|
7559
|
+
}),
|
7560
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.SingleSelectOption, {
|
7561
|
+
value: "h6",
|
7562
|
+
startIcon: /*#__PURE__*/ jsxRuntime.jsx(Icons.HeadingSix, {
|
7563
|
+
fill: "neutral600"
|
7564
|
+
}),
|
7565
|
+
children: formatMessage({
|
7566
|
+
id: 'components.Wysiwyg.selectOptions.H6',
|
7567
|
+
defaultMessage: 'Heading 6'
|
7568
|
+
})
|
7569
|
+
})
|
7570
|
+
]
|
7571
|
+
})
|
7572
|
+
}),
|
7573
|
+
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
7574
|
+
width: "100%",
|
7575
|
+
justifyContent: "space-between",
|
7576
|
+
overflow: "hidden",
|
7577
|
+
children: [
|
7578
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Flex, {
|
7579
|
+
gap: 2,
|
7580
|
+
overflow: "hidden",
|
7581
|
+
width: "100%",
|
7582
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(EditorToolbarObserver, {
|
7583
|
+
menuTriggerVariant: "tertiary",
|
7584
|
+
observedComponents: observedComponents
|
7585
|
+
})
|
7586
|
+
}),
|
7587
|
+
onTogglePreviewMode && /*#__PURE__*/ jsxRuntime.jsx(designSystem.Button, {
|
7588
|
+
onClick: onTogglePreviewMode,
|
7589
|
+
variant: "tertiary",
|
7590
|
+
minWidth: "132px",
|
7591
|
+
children: isPreviewMode ? formatMessage({
|
7592
|
+
id: 'components.Wysiwyg.ToggleMode.markdown-mode',
|
7593
|
+
defaultMessage: 'Markdown mode'
|
7594
|
+
}) : formatMessage({
|
7595
|
+
id: 'components.Wysiwyg.ToggleMode.preview-mode',
|
7596
|
+
defaultMessage: 'Preview mode'
|
7597
|
+
})
|
5803
7598
|
})
|
5804
7599
|
]
|
5805
|
-
}),
|
5806
|
-
onTogglePreviewMode && /*#__PURE__*/ jsxRuntime.jsx(designSystem.Button, {
|
5807
|
-
onClick: onTogglePreviewMode,
|
5808
|
-
variant: "tertiary",
|
5809
|
-
children: formatMessage({
|
5810
|
-
id: 'components.Wysiwyg.ToggleMode.preview-mode',
|
5811
|
-
defaultMessage: 'Preview mode'
|
5812
|
-
})
|
5813
7600
|
})
|
5814
7601
|
]
|
5815
7602
|
});
|
@@ -5830,48 +7617,6 @@ const Wysiwyg = /*#__PURE__*/ React__namespace.forwardRef(({ hint, disabled, lab
|
|
5830
7617
|
setIsPreviewMode(false);
|
5831
7618
|
setIsExpandMode((prev)=>!prev);
|
5832
7619
|
};
|
5833
|
-
const handleActionClick = (value, currentEditorRef, togglePopover)=>{
|
5834
|
-
switch(value){
|
5835
|
-
case 'Link':
|
5836
|
-
case 'Strikethrough':
|
5837
|
-
{
|
5838
|
-
markdownHandler(currentEditorRef, value);
|
5839
|
-
togglePopover?.();
|
5840
|
-
break;
|
5841
|
-
}
|
5842
|
-
case 'Code':
|
5843
|
-
case 'Quote':
|
5844
|
-
{
|
5845
|
-
quoteAndCodeHandler(currentEditorRef, value);
|
5846
|
-
togglePopover?.();
|
5847
|
-
break;
|
5848
|
-
}
|
5849
|
-
case 'Bold':
|
5850
|
-
case 'Italic':
|
5851
|
-
case 'Underline':
|
5852
|
-
{
|
5853
|
-
markdownHandler(currentEditorRef, value);
|
5854
|
-
break;
|
5855
|
-
}
|
5856
|
-
case 'BulletList':
|
5857
|
-
case 'NumberList':
|
5858
|
-
{
|
5859
|
-
listHandler(currentEditorRef, value);
|
5860
|
-
togglePopover?.();
|
5861
|
-
break;
|
5862
|
-
}
|
5863
|
-
case 'h1':
|
5864
|
-
case 'h2':
|
5865
|
-
case 'h3':
|
5866
|
-
case 'h4':
|
5867
|
-
case 'h5':
|
5868
|
-
case 'h6':
|
5869
|
-
{
|
5870
|
-
titleHandler(currentEditorRef, value);
|
5871
|
-
break;
|
5872
|
-
}
|
5873
|
-
}
|
5874
|
-
};
|
5875
7620
|
const handleSelectAssets = (files)=>{
|
5876
7621
|
const formattedFiles = files.map((f)=>({
|
5877
7622
|
alt: f.alternativeText || f.name,
|
@@ -5906,7 +7651,6 @@ const Wysiwyg = /*#__PURE__*/ React__namespace.forwardRef(({ hint, disabled, lab
|
|
5906
7651
|
isExpandMode: isExpandMode,
|
5907
7652
|
editorRef: editorRef,
|
5908
7653
|
isPreviewMode: isPreviewMode,
|
5909
|
-
onActionClick: handleActionClick,
|
5910
7654
|
onToggleMediaLib: handleToggleMediaLib,
|
5911
7655
|
onTogglePreviewMode: isExpandMode ? undefined : handleTogglePreviewMode,
|
5912
7656
|
disabled: disabled
|
@@ -5950,17 +7694,25 @@ const MemoizedWysiwyg = /*#__PURE__*/ React__namespace.memo(Wysiwyg);
|
|
5950
7694
|
* specifically to be used in the EditView of the content-manager this understands
|
5951
7695
|
* the complete EditFieldLayout and will handle RBAC conditions and rendering CM specific
|
5952
7696
|
* components such as Blocks / Relations.
|
5953
|
-
*/ const InputRenderer = ({ visible, hint: providedHint, ...props })=>{
|
5954
|
-
const {
|
5955
|
-
const
|
7697
|
+
*/ const InputRenderer = ({ visible, hint: providedHint, document, ...props })=>{
|
7698
|
+
const { model: rootModel } = index.useDoc();
|
7699
|
+
const rootDocumentMeta = index.useDocumentContext('DynamicComponent', (state)=>state.rootDocumentMeta);
|
7700
|
+
const { edit: { components: rootComponents } } = index.useDocumentLayout(rootDocumentMeta.model);
|
7701
|
+
const { edit: { components: relatedComponents } } = index.useDocumentLayout(document.schema?.uid ?? rootModel);
|
7702
|
+
const components = {
|
7703
|
+
...rootComponents,
|
7704
|
+
...relatedComponents
|
7705
|
+
};
|
7706
|
+
const collectionType = document.schema?.kind === 'collectionType' ? 'collection-types' : 'single-types';
|
5956
7707
|
const isInDynamicZone = useDynamicZone('isInDynamicZone', (state)=>state.isInDynamicZone);
|
7708
|
+
const isFormDisabled = strapiAdmin.useForm('InputRenderer', (state)=>state.disabled);
|
5957
7709
|
const canCreateFields = index.useDocumentRBAC('InputRenderer', (rbac)=>rbac.canCreateFields);
|
5958
7710
|
const canReadFields = index.useDocumentRBAC('InputRenderer', (rbac)=>rbac.canReadFields);
|
5959
7711
|
const canUpdateFields = index.useDocumentRBAC('InputRenderer', (rbac)=>rbac.canUpdateFields);
|
5960
7712
|
const canUserAction = index.useDocumentRBAC('InputRenderer', (rbac)=>rbac.canUserAction);
|
5961
|
-
let idToCheck =
|
7713
|
+
let idToCheck = document.document?.documentId;
|
5962
7714
|
if (collectionType === index.SINGLE_TYPES) {
|
5963
|
-
idToCheck = document?.documentId;
|
7715
|
+
idToCheck = document?.document?.documentId;
|
5964
7716
|
}
|
5965
7717
|
const editableFields = idToCheck ? canUpdateFields : canCreateFields;
|
5966
7718
|
const readableFields = idToCheck ? canReadFields : canCreateFields;
|
@@ -5974,7 +7726,6 @@ const MemoizedWysiwyg = /*#__PURE__*/ React__namespace.memo(Wysiwyg);
|
|
5974
7726
|
props.attribute.customField
|
5975
7727
|
] : undefined);
|
5976
7728
|
const hint = useFieldHint(providedHint, props.attribute);
|
5977
|
-
const { edit: { components } } = index.useDocLayout();
|
5978
7729
|
// We pass field in case of Custom Fields to keep backward compatibility
|
5979
7730
|
const field = strapiAdmin.useField(props.name);
|
5980
7731
|
if (!visible) {
|
@@ -6051,7 +7802,7 @@ const MemoizedWysiwyg = /*#__PURE__*/ React__namespace.memo(Wysiwyg);
|
|
6051
7802
|
disabled: fieldIsDisabled
|
6052
7803
|
});
|
6053
7804
|
case 'relation':
|
6054
|
-
return /*#__PURE__*/ jsxRuntime.jsx(
|
7805
|
+
return /*#__PURE__*/ jsxRuntime.jsx(MemoizedRelationsField, {
|
6055
7806
|
...props,
|
6056
7807
|
hint: hint,
|
6057
7808
|
disabled: fieldIsDisabled
|
@@ -6148,7 +7899,7 @@ const getMinMax = (attribute)=>{
|
|
6148
7899
|
};
|
6149
7900
|
}
|
6150
7901
|
};
|
6151
|
-
const MemoizedInputRenderer = /*#__PURE__*/
|
7902
|
+
const MemoizedInputRenderer = /*#__PURE__*/ React__namespace.memo(InputRenderer);
|
6152
7903
|
|
6153
7904
|
const RESPONSIVE_CONTAINER_BREAKPOINTS = {
|
6154
7905
|
sm: '27.5rem'
|
@@ -6156,16 +7907,22 @@ const RESPONSIVE_CONTAINER_BREAKPOINTS = {
|
|
6156
7907
|
const ResponsiveGridRoot = styledComponents.styled(designSystem.Grid.Root)`
|
6157
7908
|
container-type: inline-size;
|
6158
7909
|
`;
|
6159
|
-
const ResponsiveGridItem =
|
6160
|
-
|
6161
|
-
|
6162
|
-
|
6163
|
-
|
6164
|
-
|
6165
|
-
|
6166
|
-
|
7910
|
+
const ResponsiveGridItem = /**
|
7911
|
+
* TODO:
|
7912
|
+
* JSDOM cannot handle container queries.
|
7913
|
+
* This is a temporary workaround so that tests do not fail in the CI when jestdom throws an error
|
7914
|
+
* for failing to parse the stylesheet.
|
7915
|
+
*/ process.env.NODE_ENV !== 'test' ? styledComponents.styled(designSystem.Grid.Item)`
|
7916
|
+
grid-column: span 12;
|
7917
|
+
@container (min-width: ${RESPONSIVE_CONTAINER_BREAKPOINTS.sm}) {
|
7918
|
+
${({ col })=>col && `grid-column: span ${col};`}
|
7919
|
+
}
|
7920
|
+
` : styledComponents.styled(designSystem.Grid.Item)`
|
7921
|
+
grid-column: span 12;
|
7922
|
+
`;
|
7923
|
+
const FormLayout = ({ layout, document, hasBackground = true })=>{
|
6167
7924
|
const { formatMessage } = reactIntl.useIntl();
|
6168
|
-
const
|
7925
|
+
const model = document.schema?.modelName;
|
6169
7926
|
return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Flex, {
|
6170
7927
|
direction: "column",
|
6171
7928
|
alignItems: "stretch",
|
@@ -6190,20 +7947,20 @@ const FormLayout = ({ layout })=>{
|
|
6190
7947
|
direction: "column",
|
6191
7948
|
alignItems: "stretch",
|
6192
7949
|
children: /*#__PURE__*/ jsxRuntime.jsx(MemoizedInputRenderer, {
|
6193
|
-
...fieldWithTranslatedLabel
|
7950
|
+
...fieldWithTranslatedLabel,
|
7951
|
+
document: document
|
6194
7952
|
})
|
6195
7953
|
})
|
6196
7954
|
}, field.name);
|
6197
7955
|
}
|
6198
7956
|
return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
|
6199
|
-
|
6200
|
-
|
6201
|
-
|
6202
|
-
|
6203
|
-
|
6204
|
-
|
6205
|
-
|
6206
|
-
borderColor: "neutral150",
|
7957
|
+
...hasBackground && {
|
7958
|
+
padding: 6,
|
7959
|
+
borderColor: 'neutral150',
|
7960
|
+
background: 'neutral0',
|
7961
|
+
hasRadius: true,
|
7962
|
+
shadow: 'tableShadow'
|
7963
|
+
},
|
6207
7964
|
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Flex, {
|
6208
7965
|
direction: "column",
|
6209
7966
|
alignItems: "stretch",
|
@@ -6225,7 +7982,8 @@ const FormLayout = ({ layout })=>{
|
|
6225
7982
|
direction: "column",
|
6226
7983
|
alignItems: "stretch",
|
6227
7984
|
children: /*#__PURE__*/ jsxRuntime.jsx(MemoizedInputRenderer, {
|
6228
|
-
...fieldWithTranslatedLabel
|
7985
|
+
...fieldWithTranslatedLabel,
|
7986
|
+
document: document
|
6229
7987
|
})
|
6230
7988
|
}, field.name);
|
6231
7989
|
})
|
@@ -6239,9 +7997,10 @@ const FormLayout = ({ layout })=>{
|
|
6239
7997
|
const NonRepeatableComponent = ({ attribute, name, children, layout })=>{
|
6240
7998
|
const { formatMessage } = reactIntl.useIntl();
|
6241
7999
|
const { value } = strapiAdmin.useField(name);
|
6242
|
-
const level =
|
8000
|
+
const level = useComponent('NonRepeatableComponent', (state)=>state.level);
|
6243
8001
|
const isNested = level > 0;
|
6244
|
-
|
8002
|
+
const currentDocument = index.useDocumentContext('NonRepeatableComponent', (state)=>state.document);
|
8003
|
+
return /*#__PURE__*/ jsxRuntime.jsx(ComponentProvider, {
|
6245
8004
|
id: value?.id,
|
6246
8005
|
uid: attribute.component,
|
6247
8006
|
level: level + 1,
|
@@ -6281,7 +8040,8 @@ const NonRepeatableComponent = ({ attribute, name, children, layout })=>{
|
|
6281
8040
|
children: children({
|
6282
8041
|
...field,
|
6283
8042
|
label: translatedLabel,
|
6284
|
-
name: completeFieldName
|
8043
|
+
name: completeFieldName,
|
8044
|
+
document: currentDocument
|
6285
8045
|
})
|
6286
8046
|
}, completeFieldName);
|
6287
8047
|
})
|
@@ -6299,7 +8059,8 @@ const RepeatableComponent = ({ attribute, disabled, name, mainField, children, l
|
|
6299
8059
|
const search = React__namespace.useMemo(()=>new URLSearchParams(searchString), [
|
6300
8060
|
searchString
|
6301
8061
|
]);
|
6302
|
-
const
|
8062
|
+
const currentDocument = index.useDocumentContext('RepeatableComponent', (state)=>state.document);
|
8063
|
+
const components = currentDocument.components;
|
6303
8064
|
const { value = [], error, rawError } = strapiAdmin.useField(name);
|
6304
8065
|
const addFieldRow = strapiAdmin.useForm('RepeatableComponent', (state)=>state.addFieldRow);
|
6305
8066
|
const moveFieldRow = strapiAdmin.useForm('RepeatableComponent', (state)=>state.moveFieldRow);
|
@@ -6427,7 +8188,7 @@ const RepeatableComponent = ({ attribute, disabled, name, mainField, children, l
|
|
6427
8188
|
}));
|
6428
8189
|
};
|
6429
8190
|
const ariaDescriptionId = React__namespace.useId();
|
6430
|
-
const level =
|
8191
|
+
const level = useComponent('RepeatableComponent', (state)=>state.level);
|
6431
8192
|
if (value.length === 0) {
|
6432
8193
|
return /*#__PURE__*/ jsxRuntime.jsx(Initializer, {
|
6433
8194
|
disabled: disabled,
|
@@ -6457,7 +8218,7 @@ const RepeatableComponent = ({ attribute, disabled, name, mainField, children, l
|
|
6457
8218
|
children: [
|
6458
8219
|
value.map(({ __temp_key__: key, id }, index)=>{
|
6459
8220
|
const nameWithIndex = `${name}.${index}`;
|
6460
|
-
return /*#__PURE__*/ jsxRuntime.jsx(
|
8221
|
+
return /*#__PURE__*/ jsxRuntime.jsx(ComponentProvider, {
|
6461
8222
|
// id is always a number in a component
|
6462
8223
|
id: id,
|
6463
8224
|
uid: attribute.component,
|
@@ -6502,7 +8263,8 @@ const RepeatableComponent = ({ attribute, disabled, name, mainField, children, l
|
|
6502
8263
|
children: children({
|
6503
8264
|
...field,
|
6504
8265
|
label: translatedLabel,
|
6505
|
-
name: completeFieldName
|
8266
|
+
name: completeFieldName,
|
8267
|
+
document: currentDocument
|
6506
8268
|
})
|
6507
8269
|
}, completeFieldName);
|
6508
8270
|
})
|
@@ -6573,8 +8335,8 @@ const Component = ({ disabled, index: index$1, name, mainField = {
|
|
6573
8335
|
* components are not affected by the drag and drop of the parent component in
|
6574
8336
|
* their own re-ordering context.
|
6575
8337
|
*/ const componentKey = name.split('.').slice(0, -1).join('.');
|
6576
|
-
const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] =
|
6577
|
-
type: `${
|
8338
|
+
const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] = objects.useDragAndDrop(!disabled, {
|
8339
|
+
type: `${objects.ItemTypes.COMPONENT}_${componentKey}`,
|
6578
8340
|
index: index$1,
|
6579
8341
|
item: {
|
6580
8342
|
index: index$1,
|
@@ -6664,7 +8426,7 @@ const ComponentInput = ({ label, required, name, attribute, disabled, labelActio
|
|
6664
8426
|
const { formatMessage } = reactIntl.useIntl();
|
6665
8427
|
const field = strapiAdmin.useField(name);
|
6666
8428
|
const showResetComponent = !attribute.repeatable && field.value && !disabled;
|
6667
|
-
const
|
8429
|
+
const components = index.useDocumentContext('ComponentInput', (state)=>state.document.components);
|
6668
8430
|
const handleInitialisationClick = ()=>{
|
6669
8431
|
const schema = components[attribute.component];
|
6670
8432
|
const form = index.createDefaultForm(schema, components);
|
@@ -6729,8 +8491,11 @@ const ComponentInput = ({ label, required, name, attribute, disabled, labelActio
|
|
6729
8491
|
};
|
6730
8492
|
const MemoizedComponentInput = /*#__PURE__*/ React__namespace.memo(ComponentInput);
|
6731
8493
|
|
8494
|
+
exports.DisconnectButton = DisconnectButton;
|
6732
8495
|
exports.DynamicZone = DynamicZone;
|
8496
|
+
exports.FlexWrapper = FlexWrapper;
|
6733
8497
|
exports.FormLayout = FormLayout;
|
8498
|
+
exports.LinkEllipsis = LinkEllipsis;
|
6734
8499
|
exports.MemoizedBlocksInput = MemoizedBlocksInput;
|
6735
8500
|
exports.MemoizedComponentInput = MemoizedComponentInput;
|
6736
8501
|
exports.MemoizedUIDInput = MemoizedUIDInput;
|
@@ -6739,4 +8504,4 @@ exports.NotAllowedInput = NotAllowedInput;
|
|
6739
8504
|
exports.useDynamicZone = useDynamicZone;
|
6740
8505
|
exports.useFieldHint = useFieldHint;
|
6741
8506
|
exports.useLazyComponents = useLazyComponents;
|
6742
|
-
//# sourceMappingURL=Input-
|
8507
|
+
//# sourceMappingURL=Input-B8I0b9aD.js.map
|