@wordpress/edit-site 5.31.0 → 5.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/block-editor/editor-canvas.js +8 -1
- package/build/components/block-editor/editor-canvas.js.map +1 -1
- package/build/components/block-editor/site-editor-canvas.js +15 -4
- package/build/components/block-editor/site-editor-canvas.js.map +1 -1
- package/build/components/editor/index.js +12 -3
- package/build/components/editor/index.js.map +1 -1
- package/build/components/editor-canvas-container/index.js +1 -2
- package/build/components/editor-canvas-container/index.js.map +1 -1
- package/build/components/global-styles/background-panel.js +38 -0
- package/build/components/global-styles/background-panel.js.map +1 -0
- package/build/components/global-styles/font-families.js +1 -1
- package/build/components/global-styles/font-families.js.map +1 -1
- package/build/components/global-styles/font-library-modal/context.js +38 -9
- package/build/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build/components/global-styles/font-library-modal/utils/index.js +20 -2
- package/build/components/global-styles/font-library-modal/utils/index.js.map +1 -1
- package/build/components/global-styles/palette.js +3 -1
- package/build/components/global-styles/palette.js.map +1 -1
- package/build/components/global-styles/preview-colors.js +2 -2
- package/build/components/global-styles/preview-colors.js.map +1 -1
- package/build/components/global-styles/root-menu.js +8 -2
- package/build/components/global-styles/root-menu.js.map +1 -1
- package/build/components/global-styles/screen-background.js +34 -0
- package/build/components/global-styles/screen-background.js.map +1 -0
- package/build/components/global-styles/screen-color-palette.js +2 -2
- package/build/components/global-styles/screen-color-palette.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +6 -4
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-style-variations.js +3 -37
- package/build/components/global-styles/screen-style-variations.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +6 -6
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/style-variations-container.js +5 -2
- package/build/components/global-styles/style-variations-container.js.map +1 -1
- package/build/components/global-styles/ui.js +4 -1
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles/variations/variations-color.js +10 -3
- package/build/components/global-styles/variations/variations-color.js.map +1 -1
- package/build/components/global-styles/variations/variations-typography.js +9 -2
- package/build/components/global-styles/variations/variations-typography.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +3 -0
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build/components/layout/animation.js +129 -0
- package/build/components/layout/animation.js.map +1 -0
- package/build/components/layout/index.js +9 -17
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/router.js +21 -18
- package/build/components/layout/router.js.map +1 -1
- package/build/components/page-pages/index.js +19 -17
- package/build/components/page-pages/index.js.map +1 -1
- package/build/components/page-patterns/index.js +18 -28
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/page-patterns/search-items.js +16 -58
- package/build/components/page-patterns/search-items.js.map +1 -1
- package/build/components/page-templates-template-parts/actions.js +54 -41
- package/build/components/page-templates-template-parts/actions.js.map +1 -1
- package/build/components/page-templates-template-parts/index.js +26 -59
- package/build/components/page-templates-template-parts/index.js.map +1 -1
- package/build/components/plugin-template-setting-panel/index.js +12 -1
- package/build/components/plugin-template-setting-panel/index.js.map +1 -1
- package/build/components/save-button/index.js +45 -16
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/save-hub/index.js +8 -112
- package/build/components/save-hub/index.js.map +1 -1
- package/build/components/sidebar/index.js +1 -5
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-dataviews/default-views.js +1 -1
- package/build/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build/components/sidebar-dataviews/index.js +1 -1
- package/build/components/sidebar-dataviews/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/index.js +1 -2
- package/build/components/sidebar-edit-mode/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/index.js +5 -15
- package/build/components/sidebar-edit-mode/page-panels/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/page-content.js +7 -5
- package/build/components/sidebar-edit-mode/page-panels/page-content.js.map +1 -1
- package/build/components/sidebar-edit-mode/template-panel/index.js +10 -16
- package/build/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-details-footer/index.js +5 -1
- package/build/components/sidebar-navigation-screen-details-footer/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js +10 -5
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/index.js +1 -5
- package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build/components/style-book/index.js +1 -1
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +2 -2
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build/components/sync-state-with-url/use-sync-path-with-url.js +1 -1
- package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build/hooks/index.js +0 -1
- package/build/hooks/index.js.map +1 -1
- package/build/store/selectors.js +1 -9
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-editor/editor-canvas.js +8 -1
- package/build-module/components/block-editor/editor-canvas.js.map +1 -1
- package/build-module/components/block-editor/site-editor-canvas.js +15 -4
- package/build-module/components/block-editor/site-editor-canvas.js.map +1 -1
- package/build-module/components/editor/index.js +13 -4
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/editor-canvas-container/index.js +1 -2
- package/build-module/components/editor-canvas-container/index.js.map +1 -1
- package/build-module/components/global-styles/background-panel.js +31 -0
- package/build-module/components/global-styles/background-panel.js.map +1 -0
- package/build-module/components/global-styles/font-families.js +1 -1
- package/build-module/components/global-styles/font-families.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/context.js +38 -9
- package/build-module/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/utils/index.js +20 -2
- package/build-module/components/global-styles/font-library-modal/utils/index.js.map +1 -1
- package/build-module/components/global-styles/palette.js +3 -1
- package/build-module/components/global-styles/palette.js.map +1 -1
- package/build-module/components/global-styles/preview-colors.js +2 -2
- package/build-module/components/global-styles/preview-colors.js.map +1 -1
- package/build-module/components/global-styles/root-menu.js +9 -3
- package/build-module/components/global-styles/root-menu.js.map +1 -1
- package/build-module/components/global-styles/screen-background.js +26 -0
- package/build-module/components/global-styles/screen-background.js.map +1 -0
- package/build-module/components/global-styles/screen-color-palette.js +2 -2
- package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +6 -4
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-style-variations.js +4 -38
- package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +6 -6
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/style-variations-container.js +5 -2
- package/build-module/components/global-styles/style-variations-container.js.map +1 -1
- package/build-module/components/global-styles/ui.js +4 -1
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles/variations/variations-color.js +10 -3
- package/build-module/components/global-styles/variations/variations-color.js.map +1 -1
- package/build-module/components/global-styles/variations/variations-typography.js +9 -2
- package/build-module/components/global-styles/variations/variations-typography.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +3 -0
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/layout/animation.js +122 -0
- package/build-module/components/layout/animation.js.map +1 -0
- package/build-module/components/layout/index.js +9 -17
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/router.js +21 -18
- package/build-module/components/layout/router.js.map +1 -1
- package/build-module/components/page-pages/index.js +19 -17
- package/build-module/components/page-pages/index.js.map +1 -1
- package/build-module/components/page-patterns/index.js +20 -30
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/page-patterns/search-items.js +14 -55
- package/build-module/components/page-patterns/search-items.js.map +1 -1
- package/build-module/components/page-templates-template-parts/actions.js +54 -40
- package/build-module/components/page-templates-template-parts/actions.js.map +1 -1
- package/build-module/components/page-templates-template-parts/index.js +29 -62
- package/build-module/components/page-templates-template-parts/index.js.map +1 -1
- package/build-module/components/plugin-template-setting-panel/index.js +12 -1
- package/build-module/components/plugin-template-setting-panel/index.js.map +1 -1
- package/build-module/components/save-button/index.js +46 -17
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/save-hub/index.js +10 -114
- package/build-module/components/save-hub/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +1 -5
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-dataviews/default-views.js +1 -1
- package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build-module/components/sidebar-dataviews/index.js +1 -1
- package/build-module/components/sidebar-dataviews/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/index.js +1 -2
- package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/index.js +8 -18
- package/build-module/components/sidebar-edit-mode/page-panels/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/page-content.js +7 -5
- package/build-module/components/sidebar-edit-mode/page-panels/page-content.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/template-panel/index.js +11 -17
- package/build-module/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-details-footer/index.js +5 -1
- package/build-module/components/sidebar-navigation-screen-details-footer/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +10 -5
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/index.js +1 -5
- package/build-module/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build-module/components/style-book/index.js +1 -1
- package/build-module/components/style-book/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +2 -2
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +1 -1
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build-module/hooks/index.js +0 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/store/selectors.js +1 -9
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +116 -104
- package/build-style/style.css +116 -104
- package/package.json +44 -44
- package/src/components/block-editor/editor-canvas.js +14 -2
- package/src/components/block-editor/site-editor-canvas.js +10 -7
- package/src/components/editor/index.js +11 -4
- package/src/components/editor-canvas-container/index.js +0 -1
- package/src/components/global-styles/background-panel.js +34 -0
- package/src/components/global-styles/font-families.js +1 -1
- package/src/components/global-styles/font-library-modal/context.js +43 -14
- package/src/components/global-styles/font-library-modal/style.scss +1 -1
- package/src/components/global-styles/font-library-modal/utils/index.js +17 -4
- package/src/components/global-styles/palette.js +3 -1
- package/src/components/global-styles/preview-colors.js +2 -2
- package/src/components/global-styles/root-menu.js +12 -1
- package/src/components/global-styles/screen-background.js +29 -0
- package/src/components/global-styles/screen-color-palette.js +2 -2
- package/src/components/global-styles/screen-colors.js +4 -4
- package/src/components/global-styles/screen-style-variations.js +4 -36
- package/src/components/global-styles/screen-typography.js +6 -9
- package/src/components/global-styles/style-variations-container.js +2 -1
- package/src/components/global-styles/style.scss +14 -12
- package/src/components/global-styles/ui.js +5 -0
- package/src/components/global-styles/variations/style.scss +32 -17
- package/src/components/global-styles/variations/variations-color.js +4 -2
- package/src/components/global-styles/variations/variations-typography.js +4 -1
- package/src/components/header-edit-mode/style.scss +28 -17
- package/src/components/keyboard-shortcut-help-modal/index.js +4 -0
- package/src/components/layout/animation.js +122 -0
- package/src/components/layout/index.js +12 -27
- package/src/components/layout/router.js +25 -19
- package/src/components/layout/style.scss +2 -0
- package/src/components/page-pages/index.js +27 -43
- package/src/components/page-patterns/index.js +20 -28
- package/src/components/page-patterns/search-items.js +13 -58
- package/src/components/page-templates-template-parts/actions.js +106 -91
- package/src/components/page-templates-template-parts/index.js +34 -78
- package/src/components/page-templates-template-parts/style.scss +5 -0
- package/src/components/plugin-template-setting-panel/index.js +14 -1
- package/src/components/save-button/index.js +55 -26
- package/src/components/save-hub/index.js +20 -164
- package/src/components/sidebar/index.js +0 -5
- package/src/components/sidebar-dataviews/default-views.js +1 -1
- package/src/components/sidebar-dataviews/index.js +1 -1
- package/src/components/sidebar-edit-mode/index.js +0 -2
- package/src/components/sidebar-edit-mode/page-panels/index.js +29 -60
- package/src/components/sidebar-edit-mode/page-panels/page-content.js +10 -10
- package/src/components/sidebar-edit-mode/template-panel/index.js +23 -33
- package/src/components/sidebar-edit-mode/template-panel/style.scss +1 -29
- package/src/components/sidebar-navigation-screen/style.scss +12 -9
- package/src/components/sidebar-navigation-screen-details-footer/index.js +6 -2
- package/src/components/sidebar-navigation-screen-global-styles/index.js +7 -13
- package/src/components/sidebar-navigation-screen-patterns/index.js +0 -7
- package/src/components/style-book/index.js +1 -3
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +2 -2
- package/src/components/sync-state-with-url/use-sync-path-with-url.js +1 -1
- package/src/hooks/index.js +0 -1
- package/src/store/selectors.js +3 -15
- package/src/style.scss +0 -1
- package/build/components/actions/index.js +0 -319
- package/build/components/actions/index.js.map +0 -1
- package/build/components/sidebar-edit-mode/sidebar-card/index.js +0 -48
- package/build/components/sidebar-edit-mode/sidebar-card/index.js.map +0 -1
- package/build/components/sidebar-edit-mode/template-panel/template-areas.js +0 -70
- package/build/components/sidebar-edit-mode/template-panel/template-areas.js.map +0 -1
- package/build/components/sidebar-navigation-screen-pages/index.js +0 -175
- package/build/components/sidebar-navigation-screen-pages/index.js.map +0 -1
- package/build/hooks/template-part-edit.js +0 -82
- package/build/hooks/template-part-edit.js.map +0 -1
- package/build/store/utils.js +0 -71
- package/build/store/utils.js.map +0 -1
- package/build-module/components/actions/index.js +0 -308
- package/build-module/components/actions/index.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/sidebar-card/index.js +0 -40
- package/build-module/components/sidebar-edit-mode/sidebar-card/index.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/template-panel/template-areas.js +0 -63
- package/build-module/components/sidebar-edit-mode/template-panel/template-areas.js.map +0 -1
- package/build-module/components/sidebar-navigation-screen-pages/index.js +0 -167
- package/build-module/components/sidebar-navigation-screen-pages/index.js.map +0 -1
- package/build-module/hooks/template-part-edit.js +0 -75
- package/build-module/hooks/template-part-edit.js.map +0 -1
- package/build-module/store/utils.js +0 -64
- package/build-module/store/utils.js.map +0 -1
- package/src/components/actions/index.js +0 -409
- package/src/components/sidebar-edit-mode/sidebar-card/index.js +0 -53
- package/src/components/sidebar-edit-mode/sidebar-card/style.scss +0 -36
- package/src/components/sidebar-edit-mode/template-panel/template-areas.js +0 -86
- package/src/components/sidebar-navigation-screen-pages/index.js +0 -238
- package/src/hooks/template-part-edit.js +0 -89
- package/src/store/test/utils.js +0 -191
- package/src/store/utils.js +0 -69
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_classnames","_interopRequireDefault","require","_components","SidebarCard","className","title","icon","description","actions","children","_react","createElement","classnames","__experimentalHStack","spacing","align","Icon","__experimentalText","numberOfLines","truncate","weight","as","__experimentalVStack"],"sources":["@wordpress/edit-site/src/components/sidebar-edit-mode/sidebar-card/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tIcon,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\n\nexport default function SidebarCard( {\n\tclassName,\n\ttitle,\n\ticon,\n\tdescription,\n\tactions,\n\tchildren,\n} ) {\n\treturn (\n\t\t<div className={ classnames( 'edit-site-sidebar-card', className ) }>\n\t\t\t<HStack\n\t\t\t\tspacing={ 2 }\n\t\t\t\tclassName=\"edit-site-sidebar-card__header\"\n\t\t\t\talign=\"flex-start\"\n\t\t\t>\n\t\t\t\t<Icon className=\"edit-site-sidebar-card__icon\" icon={ icon } />\n\t\t\t\t<Text\n\t\t\t\t\tnumberOfLines={ 2 }\n\t\t\t\t\ttruncate\n\t\t\t\t\tclassName=\"edit-site-sidebar-card__title\"\n\t\t\t\t\tweight={ 500 }\n\t\t\t\t\tas=\"h2\"\n\t\t\t\t>\n\t\t\t\t\t{ title }\n\t\t\t\t</Text>\n\t\t\t\t{ actions }\n\t\t\t</HStack>\n\t\t\t<VStack className=\"edit-site-sidebar-card__content\">\n\t\t\t\t{ description && (\n\t\t\t\t\t<div className=\"edit-site-sidebar-card__description\">\n\t\t\t\t\t\t{ description }\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t\t{ children }\n\t\t\t</VStack>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAQe,SAASE,WAAWA,CAAE;EACpCC,SAAS;EACTC,KAAK;EACLC,IAAI;EACJC,WAAW;EACXC,OAAO;EACPC;AACD,CAAC,EAAG;EACH,OACC,IAAAC,MAAA,CAAAC,aAAA;IAAKP,SAAS,EAAG,IAAAQ,mBAAU,EAAE,wBAAwB,EAAER,SAAU;EAAG,GACnE,IAAAM,MAAA,CAAAC,aAAA,EAACT,WAAA,CAAAW,oBAAM;IACNC,OAAO,EAAG,CAAG;IACbV,SAAS,EAAC,gCAAgC;IAC1CW,KAAK,EAAC;EAAY,GAElB,IAAAL,MAAA,CAAAC,aAAA,EAACT,WAAA,CAAAc,IAAI;IAACZ,SAAS,EAAC,8BAA8B;IAACE,IAAI,EAAGA;EAAM,CAAE,CAAC,EAC/D,IAAAI,MAAA,CAAAC,aAAA,EAACT,WAAA,CAAAe,kBAAI;IACJC,aAAa,EAAG,CAAG;IACnBC,QAAQ;IACRf,SAAS,EAAC,+BAA+B;IACzCgB,MAAM,EAAG,GAAK;IACdC,EAAE,EAAC;EAAI,GAELhB,KACG,CAAC,EACLG,OACK,CAAC,EACT,IAAAE,MAAA,CAAAC,aAAA,EAACT,WAAA,CAAAoB,oBAAM;IAAClB,SAAS,EAAC;EAAiC,GAChDG,WAAW,IACZ,IAAAG,MAAA,CAAAC,aAAA;IAAKP,SAAS,EAAC;EAAqC,GACjDG,WACE,CACL,EACCE,QACK,CACJ,CAAC;AAER"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = TemplateAreas;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _data = require("@wordpress/data");
|
|
9
|
-
var _components = require("@wordpress/components");
|
|
10
|
-
var _editor = require("@wordpress/editor");
|
|
11
|
-
var _blockEditor = require("@wordpress/block-editor");
|
|
12
|
-
var _i18n = require("@wordpress/i18n");
|
|
13
|
-
var _store = require("../../../store");
|
|
14
|
-
/**
|
|
15
|
-
* WordPress dependencies
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Internal dependencies
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
function TemplateAreaItem({
|
|
23
|
-
area,
|
|
24
|
-
clientId
|
|
25
|
-
}) {
|
|
26
|
-
const {
|
|
27
|
-
selectBlock,
|
|
28
|
-
toggleBlockHighlight
|
|
29
|
-
} = (0, _data.useDispatch)(_blockEditor.store);
|
|
30
|
-
const templatePartArea = (0, _data.useSelect)(select => {
|
|
31
|
-
const defaultAreas = select(_editor.store).__experimentalGetDefaultTemplatePartAreas();
|
|
32
|
-
return defaultAreas.find(defaultArea => defaultArea.area === area);
|
|
33
|
-
}, [area]);
|
|
34
|
-
const highlightBlock = () => toggleBlockHighlight(clientId, true);
|
|
35
|
-
const cancelHighlightBlock = () => toggleBlockHighlight(clientId, false);
|
|
36
|
-
return (0, _react.createElement)(_components.Button, {
|
|
37
|
-
className: "edit-site-template-card__template-areas-item",
|
|
38
|
-
icon: templatePartArea?.icon,
|
|
39
|
-
onMouseOver: highlightBlock,
|
|
40
|
-
onMouseLeave: cancelHighlightBlock,
|
|
41
|
-
onFocus: highlightBlock,
|
|
42
|
-
onBlur: cancelHighlightBlock,
|
|
43
|
-
onClick: () => {
|
|
44
|
-
selectBlock(clientId);
|
|
45
|
-
}
|
|
46
|
-
}, templatePartArea?.label);
|
|
47
|
-
}
|
|
48
|
-
function TemplateAreas() {
|
|
49
|
-
const templateParts = (0, _data.useSelect)(select => select(_store.store).getCurrentTemplateTemplateParts(), []);
|
|
50
|
-
if (!templateParts.length) {
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
return (0, _react.createElement)("section", {
|
|
54
|
-
className: "edit-site-template-card__template-areas"
|
|
55
|
-
}, (0, _react.createElement)(_components.__experimentalHeading, {
|
|
56
|
-
level: 3,
|
|
57
|
-
className: "edit-site-template-card__template-areas-title"
|
|
58
|
-
}, (0, _i18n.__)('Areas')), (0, _react.createElement)("ul", {
|
|
59
|
-
className: "edit-site-template-card__template-areas-list"
|
|
60
|
-
}, templateParts.map(({
|
|
61
|
-
templatePart,
|
|
62
|
-
block
|
|
63
|
-
}) => (0, _react.createElement)("li", {
|
|
64
|
-
key: block.clientId
|
|
65
|
-
}, (0, _react.createElement)(TemplateAreaItem, {
|
|
66
|
-
area: templatePart.area,
|
|
67
|
-
clientId: block.clientId
|
|
68
|
-
})))));
|
|
69
|
-
}
|
|
70
|
-
//# sourceMappingURL=template-areas.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_components","_editor","_blockEditor","_i18n","_store","TemplateAreaItem","area","clientId","selectBlock","toggleBlockHighlight","useDispatch","blockEditorStore","templatePartArea","useSelect","select","defaultAreas","editorStore","__experimentalGetDefaultTemplatePartAreas","find","defaultArea","highlightBlock","cancelHighlightBlock","_react","createElement","Button","className","icon","onMouseOver","onMouseLeave","onFocus","onBlur","onClick","label","TemplateAreas","templateParts","editSiteStore","getCurrentTemplateTemplateParts","length","__experimentalHeading","level","__","map","templatePart","block","key"],"sources":["@wordpress/edit-site/src/components/sidebar-edit-mode/template-panel/template-areas.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tButton,\n\t__experimentalHeading as Heading,\n} from '@wordpress/components';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../../store';\n\nfunction TemplateAreaItem( { area, clientId } ) {\n\tconst { selectBlock, toggleBlockHighlight } =\n\t\tuseDispatch( blockEditorStore );\n\tconst templatePartArea = useSelect(\n\t\t( select ) => {\n\t\t\tconst defaultAreas =\n\t\t\t\tselect(\n\t\t\t\t\teditorStore\n\t\t\t\t).__experimentalGetDefaultTemplatePartAreas();\n\n\t\t\treturn defaultAreas.find(\n\t\t\t\t( defaultArea ) => defaultArea.area === area\n\t\t\t);\n\t\t},\n\t\t[ area ]\n\t);\n\n\tconst highlightBlock = () => toggleBlockHighlight( clientId, true );\n\tconst cancelHighlightBlock = () => toggleBlockHighlight( clientId, false );\n\n\treturn (\n\t\t<Button\n\t\t\tclassName=\"edit-site-template-card__template-areas-item\"\n\t\t\ticon={ templatePartArea?.icon }\n\t\t\tonMouseOver={ highlightBlock }\n\t\t\tonMouseLeave={ cancelHighlightBlock }\n\t\t\tonFocus={ highlightBlock }\n\t\t\tonBlur={ cancelHighlightBlock }\n\t\t\tonClick={ () => {\n\t\t\t\tselectBlock( clientId );\n\t\t\t} }\n\t\t>\n\t\t\t{ templatePartArea?.label }\n\t\t</Button>\n\t);\n}\n\nexport default function TemplateAreas() {\n\tconst templateParts = useSelect(\n\t\t( select ) => select( editSiteStore ).getCurrentTemplateTemplateParts(),\n\t\t[]\n\t);\n\n\tif ( ! templateParts.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<section className=\"edit-site-template-card__template-areas\">\n\t\t\t<Heading\n\t\t\t\tlevel={ 3 }\n\t\t\t\tclassName=\"edit-site-template-card__template-areas-title\"\n\t\t\t>\n\t\t\t\t{ __( 'Areas' ) }\n\t\t\t</Heading>\n\n\t\t\t<ul className=\"edit-site-template-card__template-areas-list\">\n\t\t\t\t{ templateParts.map( ( { templatePart, block } ) => (\n\t\t\t\t\t<li key={ block.clientId }>\n\t\t\t\t\t\t<TemplateAreaItem\n\t\t\t\t\t\t\tarea={ templatePart.area }\n\t\t\t\t\t\t\tclientId={ block.clientId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</li>\n\t\t\t\t) ) }\n\t\t\t</ul>\n\t\t</section>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAIA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AAfA;AACA;AACA;;AAUA;AACA;AACA;;AAGA,SAASM,gBAAgBA,CAAE;EAAEC,IAAI;EAAEC;AAAS,CAAC,EAAG;EAC/C,MAAM;IAAEC,WAAW;IAAEC;EAAqB,CAAC,GAC1C,IAAAC,iBAAW,EAAEC,kBAAiB,CAAC;EAChC,MAAMC,gBAAgB,GAAG,IAAAC,eAAS,EAC/BC,MAAM,IAAM;IACb,MAAMC,YAAY,GACjBD,MAAM,CACLE,aACD,CAAC,CAACC,yCAAyC,CAAC,CAAC;IAE9C,OAAOF,YAAY,CAACG,IAAI,CACrBC,WAAW,IAAMA,WAAW,CAACb,IAAI,KAAKA,IACzC,CAAC;EACF,CAAC,EACD,CAAEA,IAAI,CACP,CAAC;EAED,MAAMc,cAAc,GAAGA,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YAAY,CAACpC,IAAM;IAC1BC,QAAQ,EAAGoC,KAAK,CAACpC;EAAU,CAC3B,CACE,CACH,CACC,CACI,CAAC;AAEZ"}
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = SidebarNavigationScreenPages;
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
var _components = require("@wordpress/components");
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
var _i18n = require("@wordpress/i18n");
|
|
12
|
-
var _coreData = require("@wordpress/core-data");
|
|
13
|
-
var _htmlEntities = require("@wordpress/html-entities");
|
|
14
|
-
var _router = require("@wordpress/router");
|
|
15
|
-
var _icons = require("@wordpress/icons");
|
|
16
|
-
var _data = require("@wordpress/data");
|
|
17
|
-
var _compose = require("@wordpress/compose");
|
|
18
|
-
var _sidebarNavigationScreen = _interopRequireDefault(require("../sidebar-navigation-screen"));
|
|
19
|
-
var _link = require("../routes/link");
|
|
20
|
-
var _sidebarNavigationItem = _interopRequireDefault(require("../sidebar-navigation-item"));
|
|
21
|
-
var _sidebarButton = _interopRequireDefault(require("../sidebar-button"));
|
|
22
|
-
var _addNewPage = _interopRequireDefault(require("../add-new-page"));
|
|
23
|
-
var _lockUnlock = require("../../lock-unlock");
|
|
24
|
-
var _constants = require("../../utils/constants");
|
|
25
|
-
/**
|
|
26
|
-
* WordPress dependencies
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Internal dependencies
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
const {
|
|
34
|
-
useHistory
|
|
35
|
-
} = (0, _lockUnlock.unlock)(_router.privateApis);
|
|
36
|
-
const PageItem = ({
|
|
37
|
-
postType = 'page',
|
|
38
|
-
postId,
|
|
39
|
-
...props
|
|
40
|
-
}) => {
|
|
41
|
-
const linkInfo = (0, _link.useLink)({
|
|
42
|
-
postType,
|
|
43
|
-
postId
|
|
44
|
-
}, {
|
|
45
|
-
backPath: '/page'
|
|
46
|
-
});
|
|
47
|
-
return (0, _react.createElement)(_sidebarNavigationItem.default, {
|
|
48
|
-
...linkInfo,
|
|
49
|
-
...props
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
function SidebarNavigationScreenPages() {
|
|
53
|
-
const isMobileViewport = (0, _compose.useViewportMatch)('medium', '<');
|
|
54
|
-
const {
|
|
55
|
-
records: pages,
|
|
56
|
-
isResolving: isLoadingPages
|
|
57
|
-
} = (0, _coreData.useEntityRecords)('postType', 'page', {
|
|
58
|
-
status: 'any',
|
|
59
|
-
per_page: -1
|
|
60
|
-
});
|
|
61
|
-
const {
|
|
62
|
-
records: templates,
|
|
63
|
-
isResolving: isLoadingTemplates
|
|
64
|
-
} = (0, _coreData.useEntityRecords)('postType', _constants.TEMPLATE_POST_TYPE, {
|
|
65
|
-
per_page: -1
|
|
66
|
-
});
|
|
67
|
-
const dynamicPageTemplates = templates?.filter(({
|
|
68
|
-
slug
|
|
69
|
-
}) => ['404', 'search'].includes(slug));
|
|
70
|
-
const homeTemplate = templates?.find(template => template.slug === 'front-page') || templates?.find(template => template.slug === 'home') || templates?.find(template => template.slug === 'index');
|
|
71
|
-
const getPostsPageTemplate = () => templates?.find(template => template.slug === 'home') || templates?.find(template => template.slug === 'index');
|
|
72
|
-
const pagesAndTemplates = pages?.concat(dynamicPageTemplates, [homeTemplate]);
|
|
73
|
-
const {
|
|
74
|
-
frontPage,
|
|
75
|
-
postsPage
|
|
76
|
-
} = (0, _data.useSelect)(select => {
|
|
77
|
-
const {
|
|
78
|
-
getEntityRecord
|
|
79
|
-
} = select(_coreData.store);
|
|
80
|
-
const siteSettings = getEntityRecord('root', 'site');
|
|
81
|
-
return {
|
|
82
|
-
frontPage: siteSettings?.page_on_front,
|
|
83
|
-
postsPage: siteSettings?.page_for_posts
|
|
84
|
-
};
|
|
85
|
-
}, []);
|
|
86
|
-
const isHomePageBlog = frontPage === postsPage;
|
|
87
|
-
const reorderedPages = pages && [...pages];
|
|
88
|
-
if (!isHomePageBlog && reorderedPages?.length) {
|
|
89
|
-
const homePageIndex = reorderedPages.findIndex(item => item.id === frontPage);
|
|
90
|
-
const homePage = reorderedPages.splice(homePageIndex, 1);
|
|
91
|
-
reorderedPages?.splice(0, 0, ...homePage);
|
|
92
|
-
const postsPageIndex = reorderedPages.findIndex(item => item.id === postsPage);
|
|
93
|
-
const blogPage = reorderedPages.splice(postsPageIndex, 1);
|
|
94
|
-
reorderedPages.splice(1, 0, ...blogPage);
|
|
95
|
-
}
|
|
96
|
-
const [showAddPage, setShowAddPage] = (0, _element.useState)(false);
|
|
97
|
-
const history = useHistory();
|
|
98
|
-
const handleNewPage = ({
|
|
99
|
-
type,
|
|
100
|
-
id
|
|
101
|
-
}) => {
|
|
102
|
-
// Navigate to the created template editor.
|
|
103
|
-
history.push({
|
|
104
|
-
postId: id,
|
|
105
|
-
postType: type,
|
|
106
|
-
canvas: 'edit'
|
|
107
|
-
});
|
|
108
|
-
setShowAddPage(false);
|
|
109
|
-
};
|
|
110
|
-
const getPageProps = id => {
|
|
111
|
-
let itemIcon = _icons.page;
|
|
112
|
-
const postsPageTemplateId = postsPage && postsPage === id ? getPostsPageTemplate()?.id : null;
|
|
113
|
-
switch (id) {
|
|
114
|
-
case frontPage:
|
|
115
|
-
itemIcon = _icons.home;
|
|
116
|
-
break;
|
|
117
|
-
case postsPage:
|
|
118
|
-
itemIcon = _icons.verse;
|
|
119
|
-
break;
|
|
120
|
-
}
|
|
121
|
-
return {
|
|
122
|
-
icon: itemIcon,
|
|
123
|
-
postType: postsPageTemplateId ? _constants.TEMPLATE_POST_TYPE : 'page',
|
|
124
|
-
postId: postsPageTemplateId || id
|
|
125
|
-
};
|
|
126
|
-
};
|
|
127
|
-
const pagesLink = (0, _link.useLink)({
|
|
128
|
-
path: '/pages'
|
|
129
|
-
});
|
|
130
|
-
return (0, _react.createElement)(_react.Fragment, null, showAddPage && (0, _react.createElement)(_addNewPage.default, {
|
|
131
|
-
onSave: handleNewPage,
|
|
132
|
-
onClose: () => setShowAddPage(false)
|
|
133
|
-
}), (0, _react.createElement)(_sidebarNavigationScreen.default, {
|
|
134
|
-
title: (0, _i18n.__)('Pages'),
|
|
135
|
-
description: (0, _i18n.__)('Browse and manage pages.'),
|
|
136
|
-
actions: (0, _react.createElement)(_sidebarButton.default, {
|
|
137
|
-
icon: _icons.plus,
|
|
138
|
-
label: (0, _i18n.__)('Draft a new page'),
|
|
139
|
-
onClick: () => setShowAddPage(true)
|
|
140
|
-
}),
|
|
141
|
-
content: (0, _react.createElement)(_react.Fragment, null, (isLoadingPages || isLoadingTemplates) && (0, _react.createElement)(_components.__experimentalItemGroup, null, (0, _react.createElement)(_components.__experimentalItem, null, (0, _i18n.__)('Loading pages…'))), !(isLoadingPages || isLoadingTemplates) && (0, _react.createElement)(_components.__experimentalItemGroup, null, !pagesAndTemplates?.length && (0, _react.createElement)(_components.__experimentalItem, null, (0, _i18n.__)('No page found')), isHomePageBlog && homeTemplate && (0, _react.createElement)(PageItem, {
|
|
142
|
-
postType: _constants.TEMPLATE_POST_TYPE,
|
|
143
|
-
postId: homeTemplate.id,
|
|
144
|
-
key: homeTemplate.id,
|
|
145
|
-
icon: _icons.home,
|
|
146
|
-
withChevron: true
|
|
147
|
-
}, (0, _react.createElement)(_components.__experimentalTruncate, {
|
|
148
|
-
numberOfLines: 1
|
|
149
|
-
}, (0, _htmlEntities.decodeEntities)(homeTemplate.title?.rendered || (0, _i18n.__)('(no title)')))), reorderedPages?.map(({
|
|
150
|
-
id,
|
|
151
|
-
title
|
|
152
|
-
}) => (0, _react.createElement)(PageItem, {
|
|
153
|
-
...getPageProps(id),
|
|
154
|
-
key: id,
|
|
155
|
-
withChevron: true
|
|
156
|
-
}, (0, _react.createElement)(_components.__experimentalTruncate, {
|
|
157
|
-
numberOfLines: 1
|
|
158
|
-
}, (0, _htmlEntities.decodeEntities)(title?.rendered || (0, _i18n.__)('(no title)'))))))),
|
|
159
|
-
footer: (0, _react.createElement)(_components.__experimentalVStack, {
|
|
160
|
-
spacing: 0
|
|
161
|
-
}, dynamicPageTemplates?.map(item => (0, _react.createElement)(PageItem, {
|
|
162
|
-
postType: _constants.TEMPLATE_POST_TYPE,
|
|
163
|
-
postId: item.id,
|
|
164
|
-
key: item.id,
|
|
165
|
-
icon: _icons.layout,
|
|
166
|
-
withChevron: true
|
|
167
|
-
}, (0, _react.createElement)(_components.__experimentalTruncate, {
|
|
168
|
-
numberOfLines: 1
|
|
169
|
-
}, (0, _htmlEntities.decodeEntities)(item.title?.rendered || (0, _i18n.__)('(no title)'))))), !isMobileViewport && (0, _react.createElement)(_sidebarNavigationItem.default, {
|
|
170
|
-
className: "edit-site-sidebar-navigation-screen-pages__see-all",
|
|
171
|
-
...pagesLink
|
|
172
|
-
}, (0, _i18n.__)('Manage all pages')))
|
|
173
|
-
}));
|
|
174
|
-
}
|
|
175
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_element","_i18n","_coreData","_htmlEntities","_router","_icons","_data","_compose","_sidebarNavigationScreen","_interopRequireDefault","_link","_sidebarNavigationItem","_sidebarButton","_addNewPage","_lockUnlock","_constants","useHistory","unlock","routerPrivateApis","PageItem","postType","postId","props","linkInfo","useLink","backPath","_react","createElement","default","SidebarNavigationScreenPages","isMobileViewport","useViewportMatch","records","pages","isResolving","isLoadingPages","useEntityRecords","status","per_page","templates","isLoadingTemplates","TEMPLATE_POST_TYPE","dynamicPageTemplates","filter","slug","includes","homeTemplate","find","template","getPostsPageTemplate","pagesAndTemplates","concat","frontPage","postsPage","useSelect","select","getEntityRecord","coreStore","siteSettings","page_on_front","page_for_posts","isHomePageBlog","reorderedPages","length","homePageIndex","findIndex","item","id","homePage","splice","postsPageIndex","blogPage","showAddPage","setShowAddPage","useState","history","handleNewPage","type","push","canvas","getPageProps","itemIcon","page","postsPageTemplateId","home","verse","icon","pagesLink","path","Fragment","onSave","onClose","title","__","description","actions","plus","label","onClick","content","__experimentalItemGroup","__experimentalItem","key","withChevron","__experimentalTruncate","numberOfLines","decodeEntities","rendered","map","footer","__experimentalVStack","spacing","layout","className"],"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-pages/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalItem as Item,\n\t__experimentalTruncate as Truncate,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { useEntityRecords, store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { layout, page, home, verse, plus } from '@wordpress/icons';\nimport { useSelect } from '@wordpress/data';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport { useLink } from '../routes/link';\nimport SidebarNavigationItem from '../sidebar-navigation-item';\nimport SidebarButton from '../sidebar-button';\nimport AddNewPageModal from '../add-new-page';\nimport { unlock } from '../../lock-unlock';\nimport { TEMPLATE_POST_TYPE } from '../../utils/constants';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nconst PageItem = ( { postType = 'page', postId, ...props } ) => {\n\tconst linkInfo = useLink(\n\t\t{\n\t\t\tpostType,\n\t\t\tpostId,\n\t\t},\n\t\t{\n\t\t\tbackPath: '/page',\n\t\t}\n\t);\n\treturn <SidebarNavigationItem { ...linkInfo } { ...props } />;\n};\n\nexport default function SidebarNavigationScreenPages() {\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst { records: pages, isResolving: isLoadingPages } = useEntityRecords(\n\t\t'postType',\n\t\t'page',\n\t\t{\n\t\t\tstatus: 'any',\n\t\t\tper_page: -1,\n\t\t}\n\t);\n\tconst { records: templates, isResolving: isLoadingTemplates } =\n\t\tuseEntityRecords( 'postType', TEMPLATE_POST_TYPE, {\n\t\t\tper_page: -1,\n\t\t} );\n\n\tconst dynamicPageTemplates = templates?.filter( ( { slug } ) =>\n\t\t[ '404', 'search' ].includes( slug )\n\t);\n\n\tconst homeTemplate =\n\t\ttemplates?.find( ( template ) => template.slug === 'front-page' ) ||\n\t\ttemplates?.find( ( template ) => template.slug === 'home' ) ||\n\t\ttemplates?.find( ( template ) => template.slug === 'index' );\n\n\tconst getPostsPageTemplate = () =>\n\t\ttemplates?.find( ( template ) => template.slug === 'home' ) ||\n\t\ttemplates?.find( ( template ) => template.slug === 'index' );\n\n\tconst pagesAndTemplates = pages?.concat( dynamicPageTemplates, [\n\t\thomeTemplate,\n\t] );\n\n\tconst { frontPage, postsPage } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord } = select( coreStore );\n\t\tconst siteSettings = getEntityRecord( 'root', 'site' );\n\t\treturn {\n\t\t\tfrontPage: siteSettings?.page_on_front,\n\t\t\tpostsPage: siteSettings?.page_for_posts,\n\t\t};\n\t}, [] );\n\n\tconst isHomePageBlog = frontPage === postsPage;\n\n\tconst reorderedPages = pages && [ ...pages ];\n\n\tif ( ! isHomePageBlog && reorderedPages?.length ) {\n\t\tconst homePageIndex = reorderedPages.findIndex(\n\t\t\t( item ) => item.id === frontPage\n\t\t);\n\t\tconst homePage = reorderedPages.splice( homePageIndex, 1 );\n\t\treorderedPages?.splice( 0, 0, ...homePage );\n\n\t\tconst postsPageIndex = reorderedPages.findIndex(\n\t\t\t( item ) => item.id === postsPage\n\t\t);\n\n\t\tconst blogPage = reorderedPages.splice( postsPageIndex, 1 );\n\n\t\treorderedPages.splice( 1, 0, ...blogPage );\n\t}\n\n\tconst [ showAddPage, setShowAddPage ] = useState( false );\n\n\tconst history = useHistory();\n\n\tconst handleNewPage = ( { type, id } ) => {\n\t\t// Navigate to the created template editor.\n\t\thistory.push( {\n\t\t\tpostId: id,\n\t\t\tpostType: type,\n\t\t\tcanvas: 'edit',\n\t\t} );\n\t\tsetShowAddPage( false );\n\t};\n\n\tconst getPageProps = ( id ) => {\n\t\tlet itemIcon = page;\n\t\tconst postsPageTemplateId =\n\t\t\tpostsPage && postsPage === id ? getPostsPageTemplate()?.id : null;\n\n\t\tswitch ( id ) {\n\t\t\tcase frontPage:\n\t\t\t\titemIcon = home;\n\t\t\t\tbreak;\n\t\t\tcase postsPage:\n\t\t\t\titemIcon = verse;\n\t\t\t\tbreak;\n\t\t}\n\n\t\treturn {\n\t\t\ticon: itemIcon,\n\t\t\tpostType: postsPageTemplateId ? TEMPLATE_POST_TYPE : 'page',\n\t\t\tpostId: postsPageTemplateId || id,\n\t\t};\n\t};\n\n\tconst pagesLink = useLink( { path: '/pages' } );\n\n\treturn (\n\t\t<>\n\t\t\t{ showAddPage && (\n\t\t\t\t<AddNewPageModal\n\t\t\t\t\tonSave={ handleNewPage }\n\t\t\t\t\tonClose={ () => setShowAddPage( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<SidebarNavigationScreen\n\t\t\t\ttitle={ __( 'Pages' ) }\n\t\t\t\tdescription={ __( 'Browse and manage pages.' ) }\n\t\t\t\tactions={\n\t\t\t\t\t<SidebarButton\n\t\t\t\t\t\ticon={ plus }\n\t\t\t\t\t\tlabel={ __( 'Draft a new page' ) }\n\t\t\t\t\t\tonClick={ () => setShowAddPage( true ) }\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t\tcontent={\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ ( isLoadingPages || isLoadingTemplates ) && (\n\t\t\t\t\t\t\t<ItemGroup>\n\t\t\t\t\t\t\t\t<Item>{ __( 'Loading pages…' ) }</Item>\n\t\t\t\t\t\t\t</ItemGroup>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ ! ( isLoadingPages || isLoadingTemplates ) && (\n\t\t\t\t\t\t\t<ItemGroup>\n\t\t\t\t\t\t\t\t{ ! pagesAndTemplates?.length && (\n\t\t\t\t\t\t\t\t\t<Item>{ __( 'No page found' ) }</Item>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t{ isHomePageBlog && homeTemplate && (\n\t\t\t\t\t\t\t\t\t<PageItem\n\t\t\t\t\t\t\t\t\t\tpostType={ TEMPLATE_POST_TYPE }\n\t\t\t\t\t\t\t\t\t\tpostId={ homeTemplate.id }\n\t\t\t\t\t\t\t\t\t\tkey={ homeTemplate.id }\n\t\t\t\t\t\t\t\t\t\ticon={ home }\n\t\t\t\t\t\t\t\t\t\twithChevron\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<Truncate numberOfLines={ 1 }>\n\t\t\t\t\t\t\t\t\t\t\t{ decodeEntities(\n\t\t\t\t\t\t\t\t\t\t\t\thomeTemplate.title?.rendered ||\n\t\t\t\t\t\t\t\t\t\t\t\t\t__( '(no title)' )\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t\t\t\t</PageItem>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t{ reorderedPages?.map( ( { id, title } ) => (\n\t\t\t\t\t\t\t\t\t<PageItem\n\t\t\t\t\t\t\t\t\t\t{ ...getPageProps( id ) }\n\t\t\t\t\t\t\t\t\t\tkey={ id }\n\t\t\t\t\t\t\t\t\t\twithChevron\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<Truncate numberOfLines={ 1 }>\n\t\t\t\t\t\t\t\t\t\t\t{ decodeEntities(\n\t\t\t\t\t\t\t\t\t\t\t\ttitle?.rendered ||\n\t\t\t\t\t\t\t\t\t\t\t\t\t__( '(no title)' )\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t\t\t\t</PageItem>\n\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t</ItemGroup>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t}\n\t\t\t\tfooter={\n\t\t\t\t\t<VStack spacing={ 0 }>\n\t\t\t\t\t\t{ dynamicPageTemplates?.map( ( item ) => (\n\t\t\t\t\t\t\t<PageItem\n\t\t\t\t\t\t\t\tpostType={ TEMPLATE_POST_TYPE }\n\t\t\t\t\t\t\t\tpostId={ item.id }\n\t\t\t\t\t\t\t\tkey={ item.id }\n\t\t\t\t\t\t\t\ticon={ layout }\n\t\t\t\t\t\t\t\twithChevron\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Truncate numberOfLines={ 1 }>\n\t\t\t\t\t\t\t\t\t{ decodeEntities(\n\t\t\t\t\t\t\t\t\t\titem.title?.rendered ||\n\t\t\t\t\t\t\t\t\t\t\t__( '(no title)' )\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t\t</PageItem>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t{ ! isMobileViewport && (\n\t\t\t\t\t\t\t<SidebarNavigationItem\n\t\t\t\t\t\t\t\tclassName=\"edit-site-sidebar-navigation-screen-pages__see-all\"\n\t\t\t\t\t\t\t\t{ ...pagesLink }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Manage all pages' ) }\n\t\t\t\t\t\t\t</SidebarNavigationItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</VStack>\n\t\t\t\t}\n\t\t\t/>\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAMA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAA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,IAAI,IAClC,IAAAxC,MAAA,CAAAC,aAAA,EAACR,QAAQ;MACRC,QAAQ,EAAGqB,6BAAoB;MAC/BpB,MAAM,EAAG6C,IAAI,CAACC,EAAI;MAClBmC,GAAG,EAAGpC,IAAI,CAACC,EAAI;MACfmB,IAAI,EAAG0B,aAAQ;MACfT,WAAW;IAAA,GAEX,IAAA7E,MAAA,CAAAC,aAAA,EAAC7B,WAAA,CAAA0G,sBAAQ;MAACC,aAAa,EAAG;IAAG,GAC1B,IAAAC,4BAAc,EACfxC,IAAI,CAAC0B,KAAK,EAAEe,QAAQ,IACnB,IAAAd,QAAE,EAAE,YAAa,CACnB,CACS,CACD,CACT,CAAC,EACD,CAAE/D,gBAAgB,IACnB,IAAAJ,MAAA,CAAAC,aAAA,EAAChB,sBAAA,CAAAiB,OAAqB;MACrBqF,SAAS,EAAC,oDAAoD;MAAA,GACzD1B;IAAS,GAEZ,IAAAM,QAAE,EAAE,kBAAmB,CACH,CAEjB;EACR,CACD,CACA,CAAC;AAEL"}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.withEditBlockControls = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _i18n = require("@wordpress/i18n");
|
|
9
|
-
var _data = require("@wordpress/data");
|
|
10
|
-
var _blockEditor = require("@wordpress/block-editor");
|
|
11
|
-
var _coreData = require("@wordpress/core-data");
|
|
12
|
-
var _components = require("@wordpress/components");
|
|
13
|
-
var _hooks = require("@wordpress/hooks");
|
|
14
|
-
var _compose = require("@wordpress/compose");
|
|
15
|
-
var _router = require("@wordpress/router");
|
|
16
|
-
var _link = require("../components/routes/link");
|
|
17
|
-
var _lockUnlock = require("../lock-unlock");
|
|
18
|
-
var _constants = require("../utils/constants");
|
|
19
|
-
/**
|
|
20
|
-
* WordPress dependencies
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Internal dependencies
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
const {
|
|
28
|
-
useLocation
|
|
29
|
-
} = (0, _lockUnlock.unlock)(_router.privateApis);
|
|
30
|
-
function EditTemplatePartMenuItem({
|
|
31
|
-
attributes
|
|
32
|
-
}) {
|
|
33
|
-
const {
|
|
34
|
-
theme,
|
|
35
|
-
slug
|
|
36
|
-
} = attributes;
|
|
37
|
-
const {
|
|
38
|
-
params
|
|
39
|
-
} = useLocation();
|
|
40
|
-
const templatePart = (0, _data.useSelect)(select => {
|
|
41
|
-
const {
|
|
42
|
-
getCurrentTheme,
|
|
43
|
-
getEntityRecord
|
|
44
|
-
} = select(_coreData.store);
|
|
45
|
-
return getEntityRecord('postType', _constants.TEMPLATE_PART_POST_TYPE,
|
|
46
|
-
// Ideally this should be an official public API.
|
|
47
|
-
`${theme || getCurrentTheme()?.stylesheet}//${slug}`);
|
|
48
|
-
}, [theme, slug]);
|
|
49
|
-
const linkProps = (0, _link.useLink)({
|
|
50
|
-
postId: templatePart?.id,
|
|
51
|
-
postType: templatePart?.type,
|
|
52
|
-
canvas: 'edit'
|
|
53
|
-
}, {
|
|
54
|
-
fromTemplateId: params.postId || templatePart?.id
|
|
55
|
-
});
|
|
56
|
-
if (!templatePart) {
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
return (0, _react.createElement)(_components.ToolbarButton, {
|
|
60
|
-
...linkProps,
|
|
61
|
-
onClick: event => {
|
|
62
|
-
linkProps.onClick(event);
|
|
63
|
-
}
|
|
64
|
-
}, (0, _i18n.__)('Edit'));
|
|
65
|
-
}
|
|
66
|
-
const withEditBlockControls = exports.withEditBlockControls = (0, _compose.createHigherOrderComponent)(BlockEdit => props => {
|
|
67
|
-
const {
|
|
68
|
-
attributes,
|
|
69
|
-
name
|
|
70
|
-
} = props;
|
|
71
|
-
const isDisplayed = name === 'core/template-part' && attributes.slug;
|
|
72
|
-
return (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(BlockEdit, {
|
|
73
|
-
key: "edit",
|
|
74
|
-
...props
|
|
75
|
-
}), isDisplayed && (0, _react.createElement)(_blockEditor.BlockControls, {
|
|
76
|
-
group: "other"
|
|
77
|
-
}, (0, _react.createElement)(EditTemplatePartMenuItem, {
|
|
78
|
-
attributes: attributes
|
|
79
|
-
})));
|
|
80
|
-
}, 'withEditBlockControls');
|
|
81
|
-
(0, _hooks.addFilter)('editor.BlockEdit', 'core/edit-site/template-part-edit-button', withEditBlockControls);
|
|
82
|
-
//# sourceMappingURL=template-part-edit.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_data","_blockEditor","_coreData","_components","_hooks","_compose","_router","_link","_lockUnlock","_constants","useLocation","unlock","routerPrivateApis","EditTemplatePartMenuItem","attributes","theme","slug","params","templatePart","useSelect","select","getCurrentTheme","getEntityRecord","coreStore","TEMPLATE_PART_POST_TYPE","stylesheet","linkProps","useLink","postId","id","postType","type","canvas","fromTemplateId","_react","createElement","ToolbarButton","onClick","event","__","withEditBlockControls","exports","createHigherOrderComponent","BlockEdit","props","name","isDisplayed","Fragment","key","BlockControls","group","addFilter"],"sources":["@wordpress/edit-site/src/hooks/template-part-edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { BlockControls } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { ToolbarButton } from '@wordpress/components';\nimport { addFilter } from '@wordpress/hooks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport { useLink } from '../components/routes/link';\nimport { unlock } from '../lock-unlock';\nimport { TEMPLATE_PART_POST_TYPE } from '../utils/constants';\n\nconst { useLocation } = unlock( routerPrivateApis );\n\nfunction EditTemplatePartMenuItem( { attributes } ) {\n\tconst { theme, slug } = attributes;\n\tconst { params } = useLocation();\n\tconst templatePart = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentTheme, getEntityRecord } = select( coreStore );\n\n\t\t\treturn getEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tTEMPLATE_PART_POST_TYPE,\n\t\t\t\t// Ideally this should be an official public API.\n\t\t\t\t`${ theme || getCurrentTheme()?.stylesheet }//${ slug }`\n\t\t\t);\n\t\t},\n\t\t[ theme, slug ]\n\t);\n\n\tconst linkProps = useLink(\n\t\t{\n\t\t\tpostId: templatePart?.id,\n\t\t\tpostType: templatePart?.type,\n\t\t\tcanvas: 'edit',\n\t\t},\n\t\t{\n\t\t\tfromTemplateId: params.postId || templatePart?.id,\n\t\t}\n\t);\n\n\tif ( ! templatePart ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ToolbarButton\n\t\t\t{ ...linkProps }\n\t\t\tonClick={ ( event ) => {\n\t\t\t\tlinkProps.onClick( event );\n\t\t\t} }\n\t\t>\n\t\t\t{ __( 'Edit' ) }\n\t\t</ToolbarButton>\n\t);\n}\n\nexport const withEditBlockControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { attributes, name } = props;\n\t\tconst isDisplayed = name === 'core/template-part' && attributes.slug;\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit key=\"edit\" { ...props } />\n\t\t\t\t{ isDisplayed && (\n\t\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t\t<EditTemplatePartMenuItem attributes={ attributes } />\n\t\t\t\t\t</BlockControls>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t},\n\t'withEditBlockControls'\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/edit-site/template-part-edit-button',\n\twithEditBlockControls\n);\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAA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AAS;IACdW,OAAO,EAAKC,KAAK,IAAM;MACtBZ,SAAS,CAACW,OAAO,CAAEC,KAAM,CAAC;IAC3B;EAAG,GAED,IAAAC,QAAE,EAAE,MAAO,CACC,CAAC;AAElB;AAEO,MAAMC,qBAAqB,GAAAC,OAAA,CAAAD,qBAAA,GAAG,IAAAE,mCAA0B,EAC5DC,SAAS,IAAQC,KAAK,IAAM;EAC7B,MAAM;IAAE9B,UAAU;IAAE+B;EAAK,CAAC,GAAGD,KAAK;EAClC,MAAME,WAAW,GAAGD,IAAI,KAAK,oBAAoB,IAAI/B,UAAU,CAACE,IAAI;EAEpE,OACC,IAAAkB,MAAA,CAAAC,aAAA,EAAAD,MAAA,CAAAa,QAAA,QACC,IAAAb,MAAA,CAAAC,aAAA,EAACQ,SAAS;IAACK,GAAG,EAAC,MAAM;IAAA,GAAMJ;EAAK,CAAI,CAAC,EACnCE,WAAW,IACZ,IAAAZ,MAAA,CAAAC,aAAA,EAAClC,YAAA,CAAAgD,aAAa;IAACC,KAAK,EAAC;EAAO,GAC3B,IAAAhB,MAAA,CAAAC,aAAA,EAACtB,wBAAwB;IAACC,UAAU,EAAGA;EAAY,CAAE,CACvC,CAEf,CAAC;AAEL,CAAC,EACD,uBACD,CAAC;AAED,IAAAqC,gBAAS,EACR,kBAAkB,EAClB,0CAA0C,EAC1CX,qBACD,CAAC"}
|
package/build/store/utils.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.getFilteredTemplatePartBlocks = void 0;
|
|
8
|
-
var _memize = _interopRequireDefault(require("memize"));
|
|
9
|
-
var _blocks = require("@wordpress/blocks");
|
|
10
|
-
/**
|
|
11
|
-
* External dependencies
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* WordPress dependencies
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
const EMPTY_ARRAY = [];
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Get a flattened and filtered list of template parts and the matching block for that template part.
|
|
22
|
-
*
|
|
23
|
-
* Takes a list of blocks defined within a template, and a list of template parts, and returns a
|
|
24
|
-
* flattened list of template parts and the matching block for that template part.
|
|
25
|
-
*
|
|
26
|
-
* @param {Array} blocks Blocks to flatten.
|
|
27
|
-
* @param {?Array} templateParts Available template parts.
|
|
28
|
-
* @return {Array} An array of template parts and their blocks.
|
|
29
|
-
*/
|
|
30
|
-
function getFilteredTemplatePartBlocks(blocks = EMPTY_ARRAY, templateParts) {
|
|
31
|
-
const templatePartsById = templateParts ?
|
|
32
|
-
// Key template parts by their ID.
|
|
33
|
-
templateParts.reduce((newTemplateParts, part) => ({
|
|
34
|
-
...newTemplateParts,
|
|
35
|
-
[part.id]: part
|
|
36
|
-
}), {}) : {};
|
|
37
|
-
const result = [];
|
|
38
|
-
|
|
39
|
-
// Iterate over all blocks, recursing into inner blocks.
|
|
40
|
-
// Output will be based on a depth-first traversal.
|
|
41
|
-
const stack = [...blocks];
|
|
42
|
-
while (stack.length) {
|
|
43
|
-
const {
|
|
44
|
-
innerBlocks,
|
|
45
|
-
...block
|
|
46
|
-
} = stack.shift();
|
|
47
|
-
// Place inner blocks at the beginning of the stack to preserve order.
|
|
48
|
-
stack.unshift(...innerBlocks);
|
|
49
|
-
if ((0, _blocks.isTemplatePart)(block)) {
|
|
50
|
-
const {
|
|
51
|
-
attributes: {
|
|
52
|
-
theme,
|
|
53
|
-
slug
|
|
54
|
-
}
|
|
55
|
-
} = block;
|
|
56
|
-
const templatePartId = `${theme}//${slug}`;
|
|
57
|
-
const templatePart = templatePartsById[templatePartId];
|
|
58
|
-
|
|
59
|
-
// Only add to output if the found template part block is in the list of available template parts.
|
|
60
|
-
if (templatePart) {
|
|
61
|
-
result.push({
|
|
62
|
-
templatePart,
|
|
63
|
-
block
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return result;
|
|
69
|
-
}
|
|
70
|
-
const memoizedGetFilteredTemplatePartBlocks = exports.getFilteredTemplatePartBlocks = (0, _memize.default)(getFilteredTemplatePartBlocks);
|
|
71
|
-
//# sourceMappingURL=utils.js.map
|
package/build/store/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_memize","_interopRequireDefault","require","_blocks","EMPTY_ARRAY","getFilteredTemplatePartBlocks","blocks","templateParts","templatePartsById","reduce","newTemplateParts","part","id","result","stack","length","innerBlocks","block","shift","unshift","isTemplatePart","attributes","theme","slug","templatePartId","templatePart","push","memoizedGetFilteredTemplatePartBlocks","exports","memoize"],"sources":["@wordpress/edit-site/src/store/utils.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { isTemplatePart } from '@wordpress/blocks';\n\nconst EMPTY_ARRAY = [];\n\n/**\n * Get a flattened and filtered list of template parts and the matching block for that template part.\n *\n * Takes a list of blocks defined within a template, and a list of template parts, and returns a\n * flattened list of template parts and the matching block for that template part.\n *\n * @param {Array} blocks Blocks to flatten.\n * @param {?Array} templateParts Available template parts.\n * @return {Array} An array of template parts and their blocks.\n */\nfunction getFilteredTemplatePartBlocks( blocks = EMPTY_ARRAY, templateParts ) {\n\tconst templatePartsById = templateParts\n\t\t? // Key template parts by their ID.\n\t\t templateParts.reduce(\n\t\t\t\t( newTemplateParts, part ) => ( {\n\t\t\t\t\t...newTemplateParts,\n\t\t\t\t\t[ part.id ]: part,\n\t\t\t\t} ),\n\t\t\t\t{}\n\t\t )\n\t\t: {};\n\n\tconst result = [];\n\n\t// Iterate over all blocks, recursing into inner blocks.\n\t// Output will be based on a depth-first traversal.\n\tconst stack = [ ...blocks ];\n\twhile ( stack.length ) {\n\t\tconst { innerBlocks, ...block } = stack.shift();\n\t\t// Place inner blocks at the beginning of the stack to preserve order.\n\t\tstack.unshift( ...innerBlocks );\n\n\t\tif ( isTemplatePart( block ) ) {\n\t\t\tconst {\n\t\t\t\tattributes: { theme, slug },\n\t\t\t} = block;\n\t\t\tconst templatePartId = `${ theme }//${ slug }`;\n\t\t\tconst templatePart = templatePartsById[ templatePartId ];\n\n\t\t\t// Only add to output if the found template part block is in the list of available template parts.\n\t\t\tif ( templatePart ) {\n\t\t\t\tresult.push( {\n\t\t\t\t\ttemplatePart,\n\t\t\t\t\tblock,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result;\n}\n\nconst memoizedGetFilteredTemplatePartBlocks = memoize(\n\tgetFilteredTemplatePartBlocks\n);\n\nexport { memoizedGetFilteredTemplatePartBlocks as getFilteredTemplatePartBlocks };\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,OAAA,GAAAD,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA,MAAME,WAAW,GAAG,EAAE;;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,6BAA6BA,CAAEC,MAAM,GAAGF,WAAW,EAAEG,aAAa,EAAG;EAC7E,MAAMC,iBAAiB,GAAGD,aAAa;EACpC;EACAA,aAAa,CAACE,MAAM,CACpB,CAAEC,gBAAgB,EAAEC,IAAI,MAAQ;IAC/B,GAAGD,gBAAgB;IACnB,CAAEC,IAAI,CAACC,EAAE,GAAID;EACd,CAAC,CAAE,EACH,CAAC,CACD,CAAC,GACD,CAAC,CAAC;EAEL,MAAME,MAAM,GAAG,EAAE;;EAEjB;EACA;EACA,MAAMC,KAAK,GAAG,CAAE,GAAGR,MAAM,CAAE;EAC3B,OAAQQ,KAAK,CAACC,MAAM,EAAG;IACtB,MAAM;MAAEC,WAAW;MAAE,GAAGC;IAAM,CAAC,GAAGH,KAAK,CAACI,KAAK,CAAC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