@wordpress/edit-site 5.30.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 +4 -0
- package/build/components/block-editor/editor-canvas.js +24 -4
- 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/block-editor/use-site-editor-settings.js +1 -1
- package/build/components/block-editor/use-site-editor-settings.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/color-palette-panel.js +0 -9
- package/build/components/global-styles/color-palette-panel.js.map +1 -1
- 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 +53 -17
- package/build/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build/components/global-styles/font-library-modal/font-collection.js +4 -3
- package/build/components/global-styles/font-library-modal/font-collection.js.map +1 -1
- package/build/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js +3 -2
- package/build/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js.map +1 -1
- package/build/components/global-styles/font-library-modal/installed-fonts.js +1 -1
- package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build/components/global-styles/font-library-modal/upload-fonts.js +44 -10
- package/build/components/global-styles/font-library-modal/upload-fonts.js.map +1 -1
- package/build/components/global-styles/font-library-modal/utils/index.js +22 -4
- package/build/components/global-styles/font-library-modal/utils/index.js.map +1 -1
- package/build/components/global-styles/font-library-modal/utils/preview-styles.js +3 -0
- package/build/components/global-styles/font-library-modal/utils/preview-styles.js.map +1 -1
- package/build/components/global-styles/header.js +1 -1
- package/build/components/global-styles/header.js.map +1 -1
- package/build/components/global-styles/hooks.js +50 -1
- package/build/components/global-styles/hooks.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/preview-iframe.js +0 -1
- package/build/components/global-styles/preview-iframe.js.map +1 -1
- package/build/components/global-styles/preview-styles.js +2 -2
- package/build/components/global-styles/preview-styles.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 +5 -10
- 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 -11
- 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/typography-elements.js +3 -1
- package/build/components/global-styles/typography-elements.js.map +1 -1
- package/build/components/global-styles/{preview-typography.js → typography-example.js} +4 -2
- package/build/components/global-styles/typography-example.js.map +1 -0
- package/build/components/global-styles/typography-preview.js +3 -1
- package/build/components/global-styles/typography-preview.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/utils.js +1 -1
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/global-styles/variations/variations-color.js +13 -7
- package/build/components/global-styles/variations/variations-color.js.map +1 -1
- package/build/components/global-styles/variations/variations-typography.js +34 -37
- package/build/components/global-styles/variations/variations-typography.js.map +1 -1
- package/build/components/header-edit-mode/index.js +2 -1
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +6 -0
- package/build/components/keyboard-shortcut-help-modal/config.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/keyboard-shortcuts/global.js +17 -3
- package/build/components/keyboard-shortcuts/global.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 +22 -22
- package/build/components/layout/router.js.map +1 -1
- package/build/components/page-pages/index.js +24 -27
- package/build/components/page-pages/index.js.map +1 -1
- package/build/components/page-patterns/delete-category-menu-item.js +6 -1
- package/build/components/page-patterns/delete-category-menu-item.js.map +1 -1
- package/build/components/page-patterns/index.js +19 -32
- 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-patterns/use-patterns.js +9 -9
- package/build/components/page-patterns/use-patterns.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 +31 -69
- 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/save-panel/index.js +14 -9
- package/build/components/save-panel/index.js.map +1 -1
- package/build/components/sidebar/index.js +3 -8
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-dataviews/custom-dataviews-list.js +2 -2
- package/build/components/sidebar-dataviews/custom-dataviews-list.js.map +1 -1
- package/build/components/sidebar-dataviews/dataview-item.js +2 -2
- package/build/components/sidebar-dataviews/dataview-item.js.map +1 -1
- package/build/components/sidebar-dataviews/default-views.js +3 -3
- package/build/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build/components/sidebar-dataviews/index.js +5 -4
- 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 +7 -17
- 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/page-panels/page-summary.js +3 -1
- package/build/components/sidebar-edit-mode/page-panels/page-summary.js.map +1 -1
- package/build/components/sidebar-edit-mode/template-panel/index.js +32 -18
- 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 +18 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/{delete-modal.js → delete-confirm-dialog.js} +4 -5
- package/build/components/sidebar-navigation-screen-navigation-menu/delete-confirm-dialog.js.map +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menu/more-menu.js +6 -6
- package/build/components/sidebar-navigation-screen-navigation-menu/more-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.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/sidebar-navigation-screen-template/index.js +5 -1
- package/build/components/sidebar-navigation-screen-template/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/content.js +2 -2
- package/build/components/sidebar-navigation-screen-templates-browse/content.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 +3 -3
- 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 -11
- package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build/components/template-actions/index.js +44 -27
- package/build/components/template-actions/index.js.map +1 -1
- package/build/components/welcome-guide/editor.js +11 -2
- package/build/components/welcome-guide/editor.js.map +1 -1
- package/build/hooks/index.js +0 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +15 -2
- package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
- package/build/store/selectors.js +1 -9
- package/build/store/selectors.js.map +1 -1
- package/build/utils/constants.js +5 -3
- package/build/utils/constants.js.map +1 -1
- package/build/utils/get-is-list-page.js +1 -1
- package/build/utils/get-is-list-page.js.map +1 -1
- package/build/utils/math.js +98 -0
- package/build/utils/math.js.map +1 -0
- package/build-module/components/block-editor/editor-canvas.js +24 -4
- 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/block-editor/use-site-editor-settings.js +1 -1
- package/build-module/components/block-editor/use-site-editor-settings.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/color-palette-panel.js +0 -8
- package/build-module/components/global-styles/color-palette-panel.js.map +1 -1
- 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 +54 -18
- package/build-module/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/font-collection.js +4 -3
- package/build-module/components/global-styles/font-library-modal/font-collection.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js +4 -3
- package/build-module/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js +1 -1
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/upload-fonts.js +44 -10
- package/build-module/components/global-styles/font-library-modal/upload-fonts.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/utils/index.js +22 -4
- package/build-module/components/global-styles/font-library-modal/utils/index.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/utils/preview-styles.js +3 -0
- package/build-module/components/global-styles/font-library-modal/utils/preview-styles.js.map +1 -1
- package/build-module/components/global-styles/header.js +1 -1
- package/build-module/components/global-styles/header.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +48 -1
- package/build-module/components/global-styles/hooks.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/preview-iframe.js +0 -1
- package/build-module/components/global-styles/preview-iframe.js.map +1 -1
- package/build-module/components/global-styles/preview-styles.js +2 -2
- package/build-module/components/global-styles/preview-styles.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 +5 -10
- 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 -11
- 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/typography-elements.js +3 -1
- package/build-module/components/global-styles/typography-elements.js.map +1 -1
- package/build-module/components/global-styles/{preview-typography.js → typography-example.js} +4 -2
- package/build-module/components/global-styles/typography-example.js.map +1 -0
- package/build-module/components/global-styles/typography-preview.js +3 -1
- package/build-module/components/global-styles/typography-preview.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/utils.js +1 -1
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/global-styles/variations/variations-color.js +13 -7
- package/build-module/components/global-styles/variations/variations-color.js.map +1 -1
- package/build-module/components/global-styles/variations/variations-typography.js +35 -38
- package/build-module/components/global-styles/variations/variations-typography.js.map +1 -1
- package/build-module/components/header-edit-mode/index.js +2 -1
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +6 -0
- package/build-module/components/keyboard-shortcut-help-modal/config.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/keyboard-shortcuts/global.js +17 -3
- package/build-module/components/keyboard-shortcuts/global.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 +22 -22
- package/build-module/components/layout/router.js.map +1 -1
- package/build-module/components/page-pages/index.js +25 -28
- package/build-module/components/page-pages/index.js.map +1 -1
- package/build-module/components/page-patterns/delete-category-menu-item.js +6 -1
- package/build-module/components/page-patterns/delete-category-menu-item.js.map +1 -1
- package/build-module/components/page-patterns/index.js +21 -34
- 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-patterns/use-patterns.js +9 -9
- package/build-module/components/page-patterns/use-patterns.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 +34 -72
- 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/save-panel/index.js +14 -9
- package/build-module/components/save-panel/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +3 -8
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-dataviews/custom-dataviews-list.js +2 -2
- package/build-module/components/sidebar-dataviews/custom-dataviews-list.js.map +1 -1
- package/build-module/components/sidebar-dataviews/dataview-item.js +2 -2
- package/build-module/components/sidebar-dataviews/dataview-item.js.map +1 -1
- package/build-module/components/sidebar-dataviews/default-views.js +4 -4
- package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build-module/components/sidebar-dataviews/index.js +5 -4
- 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 +10 -20
- 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/page-panels/page-summary.js +4 -2
- package/build-module/components/sidebar-edit-mode/page-panels/page-summary.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/template-panel/index.js +33 -19
- 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 +19 -2
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/{delete-modal.js → delete-confirm-dialog.js} +3 -4
- package/build-module/components/sidebar-navigation-screen-navigation-menu/delete-confirm-dialog.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menu/more-menu.js +6 -6
- package/build-module/components/sidebar-navigation-screen-navigation-menu/more-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.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/sidebar-navigation-screen-template/index.js +5 -1
- package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/content.js +2 -2
- package/build-module/components/sidebar-navigation-screen-templates-browse/content.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 +3 -3
- 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 -11
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build-module/components/template-actions/index.js +44 -27
- package/build-module/components/template-actions/index.js.map +1 -1
- package/build-module/components/welcome-guide/editor.js +11 -2
- package/build-module/components/welcome-guide/editor.js.map +1 -1
- package/build-module/hooks/index.js +0 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +15 -2
- package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
- package/build-module/store/selectors.js +1 -9
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/constants.js +4 -2
- package/build-module/utils/constants.js.map +1 -1
- package/build-module/utils/get-is-list-page.js +1 -1
- package/build-module/utils/get-is-list-page.js.map +1 -1
- package/build-module/utils/math.js +92 -0
- package/build-module/utils/math.js.map +1 -0
- package/build-style/style-rtl.css +146 -130
- package/build-style/style.css +146 -130
- package/package.json +44 -44
- package/src/components/block-editor/editor-canvas.js +34 -9
- package/src/components/block-editor/site-editor-canvas.js +10 -7
- package/src/components/block-editor/use-site-editor-settings.js +0 -2
- 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/color-palette-panel.js +0 -11
- package/src/components/global-styles/font-families.js +1 -1
- package/src/components/global-styles/font-library-modal/context.js +77 -31
- package/src/components/global-styles/font-library-modal/font-collection.js +4 -3
- package/src/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js +9 -2
- package/src/components/global-styles/font-library-modal/installed-fonts.js +1 -1
- package/src/components/global-styles/font-library-modal/style.scss +15 -6
- package/src/components/global-styles/font-library-modal/upload-fonts.js +53 -8
- package/src/components/global-styles/font-library-modal/utils/index.js +21 -8
- package/src/components/global-styles/font-library-modal/utils/preview-styles.js +4 -0
- package/src/components/global-styles/header.js +1 -1
- package/src/components/global-styles/hooks.js +68 -1
- package/src/components/global-styles/palette.js +3 -1
- package/src/components/global-styles/preview-colors.js +2 -2
- package/src/components/global-styles/preview-iframe.js +0 -1
- package/src/components/global-styles/preview-styles.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 -15
- package/src/components/global-styles/screen-style-variations.js +4 -36
- package/src/components/global-styles/screen-typography.js +6 -20
- package/src/components/global-styles/style-variations-container.js +2 -1
- package/src/components/global-styles/style.scss +15 -10
- package/src/components/global-styles/typography-elements.js +5 -1
- package/src/components/global-styles/{preview-typography.js → typography-example.js} +3 -1
- package/src/components/global-styles/typography-preview.js +3 -1
- package/src/components/global-styles/ui.js +5 -0
- package/src/components/global-styles/utils.js +1 -1
- package/src/components/global-styles/variations/style.scss +32 -23
- package/src/components/global-styles/variations/variations-color.js +12 -6
- package/src/components/global-styles/variations/variations-typography.js +41 -60
- package/src/components/header-edit-mode/index.js +1 -0
- package/src/components/header-edit-mode/style.scss +28 -17
- package/src/components/keyboard-shortcut-help-modal/config.js +4 -0
- package/src/components/keyboard-shortcut-help-modal/index.js +4 -0
- package/src/components/keyboard-shortcuts/global.js +16 -4
- package/src/components/layout/animation.js +122 -0
- package/src/components/layout/index.js +12 -27
- package/src/components/layout/router.js +26 -25
- package/src/components/layout/style.scss +2 -0
- package/src/components/page-pages/index.js +33 -54
- package/src/components/page-patterns/delete-category-menu-item.js +7 -0
- package/src/components/page-patterns/index.js +22 -31
- package/src/components/page-patterns/search-items.js +13 -58
- package/src/components/page-patterns/use-patterns.js +17 -10
- package/src/components/page-templates-template-parts/actions.js +106 -91
- package/src/components/page-templates-template-parts/index.js +41 -93
- 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/save-panel/index.js +24 -17
- package/src/components/sidebar/index.js +2 -8
- package/src/components/sidebar-dataviews/custom-dataviews-list.js +2 -2
- package/src/components/sidebar-dataviews/dataview-item.js +2 -2
- package/src/components/sidebar-dataviews/default-views.js +12 -4
- package/src/components/sidebar-dataviews/index.js +5 -4
- package/src/components/sidebar-edit-mode/index.js +0 -2
- package/src/components/sidebar-edit-mode/page-panels/index.js +31 -62
- package/src/components/sidebar-edit-mode/page-panels/page-content.js +10 -10
- package/src/components/sidebar-edit-mode/page-panels/page-summary.js +2 -0
- package/src/components/sidebar-edit-mode/template-panel/index.js +33 -24
- package/src/components/sidebar-edit-mode/template-panel/style.scss +1 -29
- package/src/components/sidebar-navigation-screen/style.scss +21 -9
- package/src/components/sidebar-navigation-screen-details-footer/index.js +6 -2
- package/src/components/sidebar-navigation-screen-global-styles/index.js +29 -2
- package/src/components/sidebar-navigation-screen-navigation-menu/{delete-modal.js → delete-confirm-dialog.js} +2 -3
- package/src/components/sidebar-navigation-screen-navigation-menu/more-menu.js +11 -9
- package/src/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +6 -3
- package/src/components/sidebar-navigation-screen-patterns/index.js +0 -7
- package/src/components/sidebar-navigation-screen-template/index.js +6 -1
- package/src/components/sidebar-navigation-screen-templates-browse/content.js +2 -2
- package/src/components/style-book/index.js +1 -3
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +3 -3
- package/src/components/sync-state-with-url/use-sync-path-with-url.js +3 -19
- package/src/components/template-actions/index.js +63 -46
- package/src/components/welcome-guide/editor.js +9 -6
- package/src/hooks/index.js +0 -1
- package/src/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +21 -4
- package/src/store/selectors.js +3 -15
- package/src/style.scss +0 -2
- package/src/utils/constants.js +4 -2
- package/src/utils/get-is-list-page.js +1 -1
- package/src/utils/math.js +93 -0
- package/build/components/actions/index.js +0 -321
- package/build/components/actions/index.js.map +0 -1
- package/build/components/global-styles/preview-typography.js.map +0 -1
- package/build/components/sidebar-edit-mode/sidebar-card/index.js +0 -42
- package/build/components/sidebar-edit-mode/sidebar-card/index.js.map +0 -1
- package/build/components/sidebar-edit-mode/template-panel/template-actions.js +0 -50
- package/build/components/sidebar-edit-mode/template-panel/template-actions.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-navigation-menu/delete-modal.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/components/sidebar-navigation-screen-templates/index.js +0 -132
- package/build/components/sidebar-navigation-screen-templates/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 -310
- package/build-module/components/actions/index.js.map +0 -1
- package/build-module/components/global-styles/preview-typography.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/sidebar-card/index.js +0 -34
- package/build-module/components/sidebar-edit-mode/sidebar-card/index.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/template-panel/template-actions.js +0 -42
- package/build-module/components/sidebar-edit-mode/template-panel/template-actions.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-navigation-menu/delete-modal.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/components/sidebar-navigation-screen-templates/index.js +0 -124
- package/build-module/components/sidebar-navigation-screen-templates/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 -411
- package/src/components/sidebar-edit-mode/sidebar-card/index.js +0 -34
- package/src/components/sidebar-edit-mode/sidebar-card/style.scss +0 -37
- package/src/components/sidebar-edit-mode/template-panel/template-actions.js +0 -49
- 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/components/sidebar-navigation-screen-templates/index.js +0 -156
- package/src/components/sidebar-navigation-screen-templates/style.scss +0 -9
- 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,167 +0,0 @@
|
|
|
1
|
-
import { createElement, Fragment } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* WordPress dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { __experimentalItemGroup as ItemGroup, __experimentalItem as Item, __experimentalTruncate as Truncate, __experimentalVStack as VStack } from '@wordpress/components';
|
|
6
|
-
import { useState } from '@wordpress/element';
|
|
7
|
-
import { __ } from '@wordpress/i18n';
|
|
8
|
-
import { useEntityRecords, store as coreStore } from '@wordpress/core-data';
|
|
9
|
-
import { decodeEntities } from '@wordpress/html-entities';
|
|
10
|
-
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
11
|
-
import { layout, page, home, verse, plus } from '@wordpress/icons';
|
|
12
|
-
import { useSelect } from '@wordpress/data';
|
|
13
|
-
import { useViewportMatch } from '@wordpress/compose';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Internal dependencies
|
|
17
|
-
*/
|
|
18
|
-
import SidebarNavigationScreen from '../sidebar-navigation-screen';
|
|
19
|
-
import { useLink } from '../routes/link';
|
|
20
|
-
import SidebarNavigationItem from '../sidebar-navigation-item';
|
|
21
|
-
import SidebarButton from '../sidebar-button';
|
|
22
|
-
import AddNewPageModal from '../add-new-page';
|
|
23
|
-
import { unlock } from '../../lock-unlock';
|
|
24
|
-
import { TEMPLATE_POST_TYPE } from '../../utils/constants';
|
|
25
|
-
const {
|
|
26
|
-
useHistory
|
|
27
|
-
} = unlock(routerPrivateApis);
|
|
28
|
-
const PageItem = ({
|
|
29
|
-
postType = 'page',
|
|
30
|
-
postId,
|
|
31
|
-
...props
|
|
32
|
-
}) => {
|
|
33
|
-
const linkInfo = useLink({
|
|
34
|
-
postType,
|
|
35
|
-
postId
|
|
36
|
-
}, {
|
|
37
|
-
backPath: '/page'
|
|
38
|
-
});
|
|
39
|
-
return createElement(SidebarNavigationItem, {
|
|
40
|
-
...linkInfo,
|
|
41
|
-
...props
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
export default function SidebarNavigationScreenPages() {
|
|
45
|
-
const isMobileViewport = useViewportMatch('medium', '<');
|
|
46
|
-
const {
|
|
47
|
-
records: pages,
|
|
48
|
-
isResolving: isLoadingPages
|
|
49
|
-
} = useEntityRecords('postType', 'page', {
|
|
50
|
-
status: 'any',
|
|
51
|
-
per_page: -1
|
|
52
|
-
});
|
|
53
|
-
const {
|
|
54
|
-
records: templates,
|
|
55
|
-
isResolving: isLoadingTemplates
|
|
56
|
-
} = useEntityRecords('postType', TEMPLATE_POST_TYPE, {
|
|
57
|
-
per_page: -1
|
|
58
|
-
});
|
|
59
|
-
const dynamicPageTemplates = templates?.filter(({
|
|
60
|
-
slug
|
|
61
|
-
}) => ['404', 'search'].includes(slug));
|
|
62
|
-
const homeTemplate = templates?.find(template => template.slug === 'front-page') || templates?.find(template => template.slug === 'home') || templates?.find(template => template.slug === 'index');
|
|
63
|
-
const getPostsPageTemplate = () => templates?.find(template => template.slug === 'home') || templates?.find(template => template.slug === 'index');
|
|
64
|
-
const pagesAndTemplates = pages?.concat(dynamicPageTemplates, [homeTemplate]);
|
|
65
|
-
const {
|
|
66
|
-
frontPage,
|
|
67
|
-
postsPage
|
|
68
|
-
} = useSelect(select => {
|
|
69
|
-
const {
|
|
70
|
-
getEntityRecord
|
|
71
|
-
} = select(coreStore);
|
|
72
|
-
const siteSettings = getEntityRecord('root', 'site');
|
|
73
|
-
return {
|
|
74
|
-
frontPage: siteSettings?.page_on_front,
|
|
75
|
-
postsPage: siteSettings?.page_for_posts
|
|
76
|
-
};
|
|
77
|
-
}, []);
|
|
78
|
-
const isHomePageBlog = frontPage === postsPage;
|
|
79
|
-
const reorderedPages = pages && [...pages];
|
|
80
|
-
if (!isHomePageBlog && reorderedPages?.length) {
|
|
81
|
-
const homePageIndex = reorderedPages.findIndex(item => item.id === frontPage);
|
|
82
|
-
const homePage = reorderedPages.splice(homePageIndex, 1);
|
|
83
|
-
reorderedPages?.splice(0, 0, ...homePage);
|
|
84
|
-
const postsPageIndex = reorderedPages.findIndex(item => item.id === postsPage);
|
|
85
|
-
const blogPage = reorderedPages.splice(postsPageIndex, 1);
|
|
86
|
-
reorderedPages.splice(1, 0, ...blogPage);
|
|
87
|
-
}
|
|
88
|
-
const [showAddPage, setShowAddPage] = useState(false);
|
|
89
|
-
const history = useHistory();
|
|
90
|
-
const handleNewPage = ({
|
|
91
|
-
type,
|
|
92
|
-
id
|
|
93
|
-
}) => {
|
|
94
|
-
// Navigate to the created template editor.
|
|
95
|
-
history.push({
|
|
96
|
-
postId: id,
|
|
97
|
-
postType: type,
|
|
98
|
-
canvas: 'edit'
|
|
99
|
-
});
|
|
100
|
-
setShowAddPage(false);
|
|
101
|
-
};
|
|
102
|
-
const getPageProps = id => {
|
|
103
|
-
let itemIcon = page;
|
|
104
|
-
const postsPageTemplateId = postsPage && postsPage === id ? getPostsPageTemplate()?.id : null;
|
|
105
|
-
switch (id) {
|
|
106
|
-
case frontPage:
|
|
107
|
-
itemIcon = home;
|
|
108
|
-
break;
|
|
109
|
-
case postsPage:
|
|
110
|
-
itemIcon = verse;
|
|
111
|
-
break;
|
|
112
|
-
}
|
|
113
|
-
return {
|
|
114
|
-
icon: itemIcon,
|
|
115
|
-
postType: postsPageTemplateId ? TEMPLATE_POST_TYPE : 'page',
|
|
116
|
-
postId: postsPageTemplateId || id
|
|
117
|
-
};
|
|
118
|
-
};
|
|
119
|
-
const pagesLink = useLink({
|
|
120
|
-
path: '/pages'
|
|
121
|
-
});
|
|
122
|
-
return createElement(Fragment, null, showAddPage && createElement(AddNewPageModal, {
|
|
123
|
-
onSave: handleNewPage,
|
|
124
|
-
onClose: () => setShowAddPage(false)
|
|
125
|
-
}), createElement(SidebarNavigationScreen, {
|
|
126
|
-
title: __('Pages'),
|
|
127
|
-
description: __('Browse and manage pages.'),
|
|
128
|
-
actions: createElement(SidebarButton, {
|
|
129
|
-
icon: plus,
|
|
130
|
-
label: __('Draft a new page'),
|
|
131
|
-
onClick: () => setShowAddPage(true)
|
|
132
|
-
}),
|
|
133
|
-
content: createElement(Fragment, null, (isLoadingPages || isLoadingTemplates) && createElement(ItemGroup, null, createElement(Item, null, __('Loading pages…'))), !(isLoadingPages || isLoadingTemplates) && createElement(ItemGroup, null, !pagesAndTemplates?.length && createElement(Item, null, __('No page found')), isHomePageBlog && homeTemplate && createElement(PageItem, {
|
|
134
|
-
postType: TEMPLATE_POST_TYPE,
|
|
135
|
-
postId: homeTemplate.id,
|
|
136
|
-
key: homeTemplate.id,
|
|
137
|
-
icon: home,
|
|
138
|
-
withChevron: true
|
|
139
|
-
}, createElement(Truncate, {
|
|
140
|
-
numberOfLines: 1
|
|
141
|
-
}, decodeEntities(homeTemplate.title?.rendered || __('(no title)')))), reorderedPages?.map(({
|
|
142
|
-
id,
|
|
143
|
-
title
|
|
144
|
-
}) => createElement(PageItem, {
|
|
145
|
-
...getPageProps(id),
|
|
146
|
-
key: id,
|
|
147
|
-
withChevron: true
|
|
148
|
-
}, createElement(Truncate, {
|
|
149
|
-
numberOfLines: 1
|
|
150
|
-
}, decodeEntities(title?.rendered || __('(no title)'))))))),
|
|
151
|
-
footer: createElement(VStack, {
|
|
152
|
-
spacing: 0
|
|
153
|
-
}, dynamicPageTemplates?.map(item => createElement(PageItem, {
|
|
154
|
-
postType: TEMPLATE_POST_TYPE,
|
|
155
|
-
postId: item.id,
|
|
156
|
-
key: item.id,
|
|
157
|
-
icon: layout,
|
|
158
|
-
withChevron: true
|
|
159
|
-
}, createElement(Truncate, {
|
|
160
|
-
numberOfLines: 1
|
|
161
|
-
}, decodeEntities(item.title?.rendered || __('(no title)'))))), !isMobileViewport && createElement(SidebarNavigationItem, {
|
|
162
|
-
className: "edit-site-sidebar-navigation-screen-pages__see-all",
|
|
163
|
-
...pagesLink
|
|
164
|
-
}, __('Manage all pages')))
|
|
165
|
-
}));
|
|
166
|
-
}
|
|
167
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["__experimentalItemGroup","ItemGroup","__experimentalItem","Item","__experimentalTruncate","Truncate","__experimentalVStack","VStack","useState","__","useEntityRecords","store","coreStore","decodeEntities","privateApis","routerPrivateApis","layout","page","home","verse","plus","useSelect","useViewportMatch","SidebarNavigationScreen","useLink","SidebarNavigationItem","SidebarButton","AddNewPageModal","unlock","TEMPLATE_POST_TYPE","useHistory","PageItem","postType","postId","props","linkInfo","backPath","createElement","SidebarNavigationScreenPages","isMobileViewport","records","pages","isResolving","isLoadingPages","status","per_page","templates","isLoadingTemplates","dynamicPageTemplates","filter","slug","includes","homeTemplate","find","template","getPostsPageTemplate","pagesAndTemplates","concat","frontPage","postsPage","select","getEntityRecord","siteSettings","page_on_front","page_for_posts","isHomePageBlog","reorderedPages","length","homePageIndex","findIndex","item","id","homePage","splice","postsPageIndex","blogPage","showAddPage","setShowAddPage","history","handleNewPage","type","push","canvas","getPageProps","itemIcon","postsPageTemplateId","icon","pagesLink","path","Fragment","onSave","onClose","title","description","actions","label","onClick","content","key","withChevron","numberOfLines","rendered","map","footer","spacing","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":";AAAA;AACA;AACA;AACA,SACCA,uBAAuB,IAAIC,SAAS,EACpCC,kBAAkB,IAAIC,IAAI,EAC1BC,sBAAsB,IAAIC,QAAQ,EAClCC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,gBAAgB,EAAEC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AAC3E,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,WAAW,IAAIC,iBAAiB,QAAQ,mBAAmB;AACpE,SAASC,MAAM,EAAEC,IAAI,EAAEC,IAAI,EAAEC,KAAK,EAAEC,IAAI,QAAQ,kBAAkB;AAClE,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,gBAAgB,QAAQ,oBAAoB;;AAErD;AACA;AACA;AACA,OAAOC,uBAAuB,MAAM,8BAA8B;AAClE,SAASC,OAAO,QAAQ,gBAAgB;AACxC,OAAOC,qBAAqB,MAAM,4BAA4B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CAAE;MAAE/B,EAAE;MAAEqB;IAAM,CAAC,KACrCvD,aAAA,CAACN,QAAQ;MAAA,GACHoD,YAAY,CAAEZ,EAAG,CAAC;MACvB2B,GAAG,EAAG3B,EAAI;MACV4B,WAAW;IAAA,GAEX9D,aAAA,CAAChC,QAAQ;MAAC+F,aAAa,EAAG;IAAG,GAC1BvF,cAAc,CACf+E,KAAK,EAAES,QAAQ,IACd5F,EAAE,CAAE,YAAa,CACnB,CACS,CACD,CACT,CACQ,CAEX,CACF;IACD8F,MAAM,EACLlE,aAAA,CAAC9B,MAAM;MAACiG,OAAO,EAAG;IAAG,GAClBxD,oBAAoB,EAAEsD,GAAG,CAAIhC,IAAI,IAClCjC,aAAA,CAACN,QAAQ;MACRC,QAAQ,EAAGH,kBAAoB;MAC/BI,MAAM,EAAGqC,IAAI,CAACC,EAAI;MAClB2B,GAAG,EAAG5B,IAAI,CAACC,EAAI;MACfe,IAAI,EAAGtE,MAAQ;MACfmF,WAAW;IAAA,GAEX9D,aAAA,CAAChC,QAAQ;MAAC+F,aAAa,EAAG;IAAG,GAC1BvF,cAAc,CACfyD,IAAI,CAACsB,KAAK,EAAES,QAAQ,IACnB5F,EAAE,CAAE,YAAa,CACnB,CACS,CACD,CACT,CAAC,EACD,CAAE8B,gBAAgB,IACnBF,aAAA,CAACZ,qBAAqB;MACrBgF,SAAS,EAAC,oDAAoD;MAAA,GACzDlB;IAAS,GAEZ9E,EAAE,CAAE,kBAAmB,CACH,CAEjB;EACR,CACD,CACA,CAAC;AAEL"}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { createElement, Fragment } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* WordPress dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { __experimentalItemGroup as ItemGroup, __experimentalItem as Item, __experimentalVStack as VStack } from '@wordpress/components';
|
|
6
|
-
import { __ } from '@wordpress/i18n';
|
|
7
|
-
import { useEntityRecords } from '@wordpress/core-data';
|
|
8
|
-
import { decodeEntities } from '@wordpress/html-entities';
|
|
9
|
-
import { useViewportMatch } from '@wordpress/compose';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Internal dependencies
|
|
13
|
-
*/
|
|
14
|
-
import SidebarNavigationScreen from '../sidebar-navigation-screen';
|
|
15
|
-
import { useLink } from '../routes/link';
|
|
16
|
-
import SidebarNavigationItem from '../sidebar-navigation-item';
|
|
17
|
-
import AddNewTemplate from '../add-new-template';
|
|
18
|
-
import SidebarButton from '../sidebar-button';
|
|
19
|
-
import { TEMPLATE_POST_TYPE } from '../../utils/constants';
|
|
20
|
-
const TemplateItem = ({
|
|
21
|
-
postType,
|
|
22
|
-
postId,
|
|
23
|
-
...props
|
|
24
|
-
}) => {
|
|
25
|
-
const linkInfo = useLink({
|
|
26
|
-
postType,
|
|
27
|
-
postId
|
|
28
|
-
});
|
|
29
|
-
return createElement(SidebarNavigationItem, {
|
|
30
|
-
...linkInfo,
|
|
31
|
-
...props
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
export default function SidebarNavigationScreenTemplates() {
|
|
35
|
-
const isMobileViewport = useViewportMatch('medium', '<');
|
|
36
|
-
const {
|
|
37
|
-
records: templates,
|
|
38
|
-
isResolving: isLoading
|
|
39
|
-
} = useEntityRecords('postType', TEMPLATE_POST_TYPE, {
|
|
40
|
-
per_page: -1
|
|
41
|
-
});
|
|
42
|
-
const browseAllLink = useLink({
|
|
43
|
-
path: '/wp_template/all'
|
|
44
|
-
});
|
|
45
|
-
const canCreate = !isMobileViewport;
|
|
46
|
-
return createElement(SidebarNavigationScreen, {
|
|
47
|
-
title: __('Templates'),
|
|
48
|
-
description: __('Express the layout of your site with templates.'),
|
|
49
|
-
actions: canCreate && createElement(AddNewTemplate, {
|
|
50
|
-
templateType: TEMPLATE_POST_TYPE,
|
|
51
|
-
toggleProps: {
|
|
52
|
-
as: SidebarButton
|
|
53
|
-
}
|
|
54
|
-
}),
|
|
55
|
-
content: createElement(Fragment, null, isLoading && __('Loading templates…'), !isLoading && createElement(SidebarTemplatesList, {
|
|
56
|
-
templates: templates
|
|
57
|
-
})),
|
|
58
|
-
footer: !isMobileViewport && createElement(SidebarNavigationItem, {
|
|
59
|
-
withChevron: true,
|
|
60
|
-
...browseAllLink
|
|
61
|
-
}, __('Manage all templates'))
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
function TemplatesGroup({
|
|
65
|
-
title,
|
|
66
|
-
templates
|
|
67
|
-
}) {
|
|
68
|
-
return createElement(ItemGroup, null, !!title && createElement(Item, {
|
|
69
|
-
className: "edit-site-sidebar-navigation-screen-templates__templates-group-title"
|
|
70
|
-
}, title), templates.map(template => createElement(TemplateItem, {
|
|
71
|
-
postType: TEMPLATE_POST_TYPE,
|
|
72
|
-
postId: template.id,
|
|
73
|
-
key: template.id,
|
|
74
|
-
withChevron: true
|
|
75
|
-
}, decodeEntities(template.title?.rendered || template.slug))));
|
|
76
|
-
}
|
|
77
|
-
function SidebarTemplatesList({
|
|
78
|
-
templates
|
|
79
|
-
}) {
|
|
80
|
-
if (!templates?.length) {
|
|
81
|
-
return createElement(ItemGroup, null, createElement(Item, null, __('No templates found')));
|
|
82
|
-
}
|
|
83
|
-
const sortedTemplates = templates ? [...templates] : [];
|
|
84
|
-
sortedTemplates.sort((a, b) => a.title.rendered.localeCompare(b.title.rendered));
|
|
85
|
-
const {
|
|
86
|
-
hierarchyTemplates,
|
|
87
|
-
customTemplates,
|
|
88
|
-
...plugins
|
|
89
|
-
} = sortedTemplates.reduce((accumulator, template) => {
|
|
90
|
-
const {
|
|
91
|
-
original_source: originalSource,
|
|
92
|
-
author_text: authorText
|
|
93
|
-
} = template;
|
|
94
|
-
if (originalSource === 'plugin') {
|
|
95
|
-
if (!accumulator[authorText]) {
|
|
96
|
-
accumulator[authorText] = [];
|
|
97
|
-
}
|
|
98
|
-
accumulator[authorText].push(template);
|
|
99
|
-
} else if (template.is_custom) {
|
|
100
|
-
accumulator.customTemplates.push(template);
|
|
101
|
-
} else {
|
|
102
|
-
accumulator.hierarchyTemplates.push(template);
|
|
103
|
-
}
|
|
104
|
-
return accumulator;
|
|
105
|
-
}, {
|
|
106
|
-
hierarchyTemplates: [],
|
|
107
|
-
customTemplates: []
|
|
108
|
-
});
|
|
109
|
-
return createElement(VStack, {
|
|
110
|
-
spacing: 3
|
|
111
|
-
}, !!hierarchyTemplates.length && createElement(TemplatesGroup, {
|
|
112
|
-
templates: hierarchyTemplates
|
|
113
|
-
}), !!customTemplates.length && createElement(TemplatesGroup, {
|
|
114
|
-
title: __('Custom'),
|
|
115
|
-
templates: customTemplates
|
|
116
|
-
}), Object.entries(plugins).map(([plugin, pluginTemplates]) => {
|
|
117
|
-
return createElement(TemplatesGroup, {
|
|
118
|
-
key: plugin,
|
|
119
|
-
title: plugin,
|
|
120
|
-
templates: pluginTemplates
|
|
121
|
-
});
|
|
122
|
-
}));
|
|
123
|
-
}
|
|
124
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["__experimentalItemGroup","ItemGroup","__experimentalItem","Item","__experimentalVStack","VStack","__","useEntityRecords","decodeEntities","useViewportMatch","SidebarNavigationScreen","useLink","SidebarNavigationItem","AddNewTemplate","SidebarButton","TEMPLATE_POST_TYPE","TemplateItem","postType","postId","props","linkInfo","createElement","SidebarNavigationScreenTemplates","isMobileViewport","records","templates","isResolving","isLoading","per_page","browseAllLink","path","canCreate","title","description","actions","templateType","toggleProps","as","content","Fragment","SidebarTemplatesList","footer","withChevron","TemplatesGroup","className","map","template","id","key","rendered","slug","length","sortedTemplates","sort","a","b","localeCompare","hierarchyTemplates","customTemplates","plugins","reduce","accumulator","original_source","originalSource","author_text","authorText","push","is_custom","spacing","Object","entries","plugin","pluginTemplates"],"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-templates/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalItem as Item,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\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 AddNewTemplate from '../add-new-template';\nimport SidebarButton from '../sidebar-button';\nimport { TEMPLATE_POST_TYPE } from '../../utils/constants';\n\nconst TemplateItem = ( { postType, postId, ...props } ) => {\n\tconst linkInfo = useLink( {\n\t\tpostType,\n\t\tpostId,\n\t} );\n\treturn <SidebarNavigationItem { ...linkInfo } { ...props } />;\n};\n\nexport default function SidebarNavigationScreenTemplates() {\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst { records: templates, isResolving: isLoading } = useEntityRecords(\n\t\t'postType',\n\t\tTEMPLATE_POST_TYPE,\n\t\t{ per_page: -1 }\n\t);\n\tconst browseAllLink = useLink( { path: '/wp_template/all' } );\n\tconst canCreate = ! isMobileViewport;\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\ttitle={ __( 'Templates' ) }\n\t\t\tdescription={ __(\n\t\t\t\t'Express the layout of your site with templates.'\n\t\t\t) }\n\t\t\tactions={\n\t\t\t\tcanCreate && (\n\t\t\t\t\t<AddNewTemplate\n\t\t\t\t\t\ttemplateType={ TEMPLATE_POST_TYPE }\n\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\tas: SidebarButton,\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t}\n\t\t\tcontent={\n\t\t\t\t<>\n\t\t\t\t\t{ isLoading && __( 'Loading templates…' ) }\n\t\t\t\t\t{ ! isLoading && (\n\t\t\t\t\t\t<SidebarTemplatesList templates={ templates } />\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t}\n\t\t\tfooter={\n\t\t\t\t! isMobileViewport && (\n\t\t\t\t\t<SidebarNavigationItem withChevron { ...browseAllLink }>\n\t\t\t\t\t\t{ __( 'Manage all templates' ) }\n\t\t\t\t\t</SidebarNavigationItem>\n\t\t\t\t)\n\t\t\t}\n\t\t/>\n\t);\n}\n\nfunction TemplatesGroup( { title, templates } ) {\n\treturn (\n\t\t<ItemGroup>\n\t\t\t{ !! title && (\n\t\t\t\t<Item className=\"edit-site-sidebar-navigation-screen-templates__templates-group-title\">\n\t\t\t\t\t{ title }\n\t\t\t\t</Item>\n\t\t\t) }\n\t\t\t{ templates.map( ( template ) => (\n\t\t\t\t<TemplateItem\n\t\t\t\t\tpostType={ TEMPLATE_POST_TYPE }\n\t\t\t\t\tpostId={ template.id }\n\t\t\t\t\tkey={ template.id }\n\t\t\t\t\twithChevron\n\t\t\t\t>\n\t\t\t\t\t{ decodeEntities(\n\t\t\t\t\t\ttemplate.title?.rendered || template.slug\n\t\t\t\t\t) }\n\t\t\t\t</TemplateItem>\n\t\t\t) ) }\n\t\t</ItemGroup>\n\t);\n}\nfunction SidebarTemplatesList( { templates } ) {\n\tif ( ! templates?.length ) {\n\t\treturn (\n\t\t\t<ItemGroup>\n\t\t\t\t<Item>{ __( 'No templates found' ) }</Item>\n\t\t\t</ItemGroup>\n\t\t);\n\t}\n\tconst sortedTemplates = templates ? [ ...templates ] : [];\n\tsortedTemplates.sort( ( a, b ) =>\n\t\ta.title.rendered.localeCompare( b.title.rendered )\n\t);\n\tconst { hierarchyTemplates, customTemplates, ...plugins } =\n\t\tsortedTemplates.reduce(\n\t\t\t( accumulator, template ) => {\n\t\t\t\tconst {\n\t\t\t\t\toriginal_source: originalSource,\n\t\t\t\t\tauthor_text: authorText,\n\t\t\t\t} = template;\n\t\t\t\tif ( originalSource === 'plugin' ) {\n\t\t\t\t\tif ( ! accumulator[ authorText ] ) {\n\t\t\t\t\t\taccumulator[ authorText ] = [];\n\t\t\t\t\t}\n\t\t\t\t\taccumulator[ authorText ].push( template );\n\t\t\t\t} else if ( template.is_custom ) {\n\t\t\t\t\taccumulator.customTemplates.push( template );\n\t\t\t\t} else {\n\t\t\t\t\taccumulator.hierarchyTemplates.push( template );\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t{ hierarchyTemplates: [], customTemplates: [] }\n\t\t);\n\treturn (\n\t\t<VStack spacing={ 3 }>\n\t\t\t{ !! hierarchyTemplates.length && (\n\t\t\t\t<TemplatesGroup templates={ hierarchyTemplates } />\n\t\t\t) }\n\t\t\t{ !! customTemplates.length && (\n\t\t\t\t<TemplatesGroup\n\t\t\t\t\ttitle={ __( 'Custom' ) }\n\t\t\t\t\ttemplates={ customTemplates }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ Object.entries( plugins ).map(\n\t\t\t\t( [ plugin, pluginTemplates ] ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<TemplatesGroup\n\t\t\t\t\t\t\tkey={ plugin }\n\t\t\t\t\t\t\ttitle={ plugin }\n\t\t\t\t\t\t\ttemplates={ pluginTemplates }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,uBAAuB,IAAIC,SAAS,EACpCC,kBAAkB,IAAIC,IAAI,EAC1BC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,gBAAgB,QAAQ,sBAAsB;AACvD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,gBAAgB,QAAQ,oBAAoB;;AAErD;AACA;AACA;AACA,OAAOC,uBAAuB,MAAM,8BAA8B;AAClE,SAASC,OAAO,QAAQ,gBAAgB;AACxC,OAAOC,qBAAqB,MAAM,4BAA4B;AAC9D,OAAOC,cAAc,MAAM,qBAAqB;AAChD,OAAOC,aAAa,MAAM,mBAAmB;AAC7C,SAASC,kBAAk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i18n';
|
|
6
|
-
import { useSelect } from '@wordpress/data';
|
|
7
|
-
import { BlockControls } from '@wordpress/block-editor';
|
|
8
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
9
|
-
import { ToolbarButton } from '@wordpress/components';
|
|
10
|
-
import { addFilter } from '@wordpress/hooks';
|
|
11
|
-
import { createHigherOrderComponent } from '@wordpress/compose';
|
|
12
|
-
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Internal dependencies
|
|
16
|
-
*/
|
|
17
|
-
import { useLink } from '../components/routes/link';
|
|
18
|
-
import { unlock } from '../lock-unlock';
|
|
19
|
-
import { TEMPLATE_PART_POST_TYPE } from '../utils/constants';
|
|
20
|
-
const {
|
|
21
|
-
useLocation
|
|
22
|
-
} = unlock(routerPrivateApis);
|
|
23
|
-
function EditTemplatePartMenuItem({
|
|
24
|
-
attributes
|
|
25
|
-
}) {
|
|
26
|
-
const {
|
|
27
|
-
theme,
|
|
28
|
-
slug
|
|
29
|
-
} = attributes;
|
|
30
|
-
const {
|
|
31
|
-
params
|
|
32
|
-
} = useLocation();
|
|
33
|
-
const templatePart = useSelect(select => {
|
|
34
|
-
const {
|
|
35
|
-
getCurrentTheme,
|
|
36
|
-
getEntityRecord
|
|
37
|
-
} = select(coreStore);
|
|
38
|
-
return getEntityRecord('postType', TEMPLATE_PART_POST_TYPE,
|
|
39
|
-
// Ideally this should be an official public API.
|
|
40
|
-
`${theme || getCurrentTheme()?.stylesheet}//${slug}`);
|
|
41
|
-
}, [theme, slug]);
|
|
42
|
-
const linkProps = useLink({
|
|
43
|
-
postId: templatePart?.id,
|
|
44
|
-
postType: templatePart?.type,
|
|
45
|
-
canvas: 'edit'
|
|
46
|
-
}, {
|
|
47
|
-
fromTemplateId: params.postId || templatePart?.id
|
|
48
|
-
});
|
|
49
|
-
if (!templatePart) {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
return createElement(ToolbarButton, {
|
|
53
|
-
...linkProps,
|
|
54
|
-
onClick: event => {
|
|
55
|
-
linkProps.onClick(event);
|
|
56
|
-
}
|
|
57
|
-
}, __('Edit'));
|
|
58
|
-
}
|
|
59
|
-
export const withEditBlockControls = createHigherOrderComponent(BlockEdit => props => {
|
|
60
|
-
const {
|
|
61
|
-
attributes,
|
|
62
|
-
name
|
|
63
|
-
} = props;
|
|
64
|
-
const isDisplayed = name === 'core/template-part' && attributes.slug;
|
|
65
|
-
return createElement(Fragment, null, createElement(BlockEdit, {
|
|
66
|
-
key: "edit",
|
|
67
|
-
...props
|
|
68
|
-
}), isDisplayed && createElement(BlockControls, {
|
|
69
|
-
group: "other"
|
|
70
|
-
}, createElement(EditTemplatePartMenuItem, {
|
|
71
|
-
attributes: attributes
|
|
72
|
-
})));
|
|
73
|
-
}, 'withEditBlockControls');
|
|
74
|
-
addFilter('editor.BlockEdit', 'core/edit-site/template-part-edit-button', withEditBlockControls);
|
|
75
|
-
//# sourceMappingURL=template-part-edit.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["__","useSelect","BlockControls","store","coreStore","ToolbarButton","addFilter","createHigherOrderComponent","privateApis","routerPrivateApis","useLink","unlock","TEMPLATE_PART_POST_TYPE","useLocation","EditTemplatePartMenuItem","attributes","theme","slug","params","templatePart","select","getCurrentTheme","getEntityRecord","stylesheet","linkProps","postId","id","postType","type","canvas","fromTemplateId","createElement","onClick","event","withEditBlockControls","BlockEdit","props","name","isDisplayed","Fragment","key","group"],"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);\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CC,cAAc,EAAEZ,MAAM,CAACO,MAAM,IAAIN,YAAY,EAAEO;EAChD,CACD,CAAC;EAED,IAAK,CAAEP,YAAY,EAAG;IACrB,OAAO,IAAI;EACZ;EAEA,OACCY,aAAA,CAAC1B,aAAa;IAAA,GACRmB,SAAS;IACdQ,OAAO,EAAKC,KAAK,IAAM;MACtBT,SAAS,CAACQ,OAAO,CAAEC,KAAM,CAAC;IAC3B;EAAG,GAEDjC,EAAE,CAAE,MAAO,CACC,CAAC;AAElB;AAEA,OAAO,MAAMkC,qBAAqB,GAAG3B,0BAA0B,CAC5D4B,SAAS,IAAQC,KAAK,IAAM;EAC7B,MAAM;IAAErB,UAAU;IAAEsB;EAAK,CAAC,GAAGD,KAAK;EAClC,MAAME,WAAW,GAAGD,IAAI,KAAK,oBAAoB,IAAItB,UAAU,CAACE,IAAI;EAEpE,OACCc,aAAA,CAAAQ,QAAA,QACCR,aAAA,CAACI,SAAS;IAACK,GAAG,EAAC,MAAM;IAAA,GAAMJ;EAAK,CAAI,CAAC,EACnCE,WAAW,IACZP,aAAA,CAAC7B,aAAa;IAACuC,KAAK,EAAC;EAAO,GAC3BV,aAAA,CAACjB,wBAAwB;IAACC,UAAU,EAAGA;EAAY,CAAE,CACvC,CAEf,CAAC;AAEL,CAAC,EACD,uBACD,CAAC;AAEDT,SAAS,CACR,kBAAkB,EAClB,0CAA0C,EAC1C4B,qBACD,CAAC"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import memoize from 'memize';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { isTemplatePart } from '@wordpress/blocks';
|
|
10
|
-
const EMPTY_ARRAY = [];
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Get a flattened and filtered list of template parts and the matching block for that template part.
|
|
14
|
-
*
|
|
15
|
-
* Takes a list of blocks defined within a template, and a list of template parts, and returns a
|
|
16
|
-
* flattened list of template parts and the matching block for that template part.
|
|
17
|
-
*
|
|
18
|
-
* @param {Array} blocks Blocks to flatten.
|
|
19
|
-
* @param {?Array} templateParts Available template parts.
|
|
20
|
-
* @return {Array} An array of template parts and their blocks.
|
|
21
|
-
*/
|
|
22
|
-
function getFilteredTemplatePartBlocks(blocks = EMPTY_ARRAY, templateParts) {
|
|
23
|
-
const templatePartsById = templateParts ?
|
|
24
|
-
// Key template parts by their ID.
|
|
25
|
-
templateParts.reduce((newTemplateParts, part) => ({
|
|
26
|
-
...newTemplateParts,
|
|
27
|
-
[part.id]: part
|
|
28
|
-
}), {}) : {};
|
|
29
|
-
const result = [];
|
|
30
|
-
|
|
31
|
-
// Iterate over all blocks, recursing into inner blocks.
|
|
32
|
-
// Output will be based on a depth-first traversal.
|
|
33
|
-
const stack = [...blocks];
|
|
34
|
-
while (stack.length) {
|
|
35
|
-
const {
|
|
36
|
-
innerBlocks,
|
|
37
|
-
...block
|
|
38
|
-
} = stack.shift();
|
|
39
|
-
// Place inner blocks at the beginning of the stack to preserve order.
|
|
40
|
-
stack.unshift(...innerBlocks);
|
|
41
|
-
if (isTemplatePart(block)) {
|
|
42
|
-
const {
|
|
43
|
-
attributes: {
|
|
44
|
-
theme,
|
|
45
|
-
slug
|
|
46
|
-
}
|
|
47
|
-
} = block;
|
|
48
|
-
const templatePartId = `${theme}//${slug}`;
|
|
49
|
-
const templatePart = templatePartsById[templatePartId];
|
|
50
|
-
|
|
51
|
-
// Only add to output if the found template part block is in the list of available template parts.
|
|
52
|
-
if (templatePart) {
|
|
53
|
-
result.push({
|
|
54
|
-
templatePart,
|
|
55
|
-
block
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return result;
|
|
61
|
-
}
|
|
62
|
-
const memoizedGetFilteredTemplatePartBlocks = memoize(getFilteredTemplatePartBlocks);
|
|
63
|
-
export { memoizedGetFilteredTemplatePartBlocks as getFilteredTemplatePartBlocks };
|
|
64
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["memoize","isTemplatePart","EMPTY_ARRAY","getFilteredTemplatePartBlocks","blocks","templateParts","templatePartsById","reduce","newTemplateParts","part","id","result","stack","length","innerBlocks","block","shift","unshift","attributes","theme","slug","templatePartId","templatePart","push","memoizedGetFilteredTemplatePartBlocks"],"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":"AAAA;AACA;AACA;AACA,OAAOA,OAAO,MAAM,QAAQ;;AAE5B;AACA;AACA;AACA,SAASC,cAAc,QAAQ,mBAAmB;AAElD,MAAMC,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,CAAC;IAC/C;IACAJ,KAAK,CAACK,OAAO,CAAE,GAAGH,WAAY,CAAC;IAE/B,IAAKb,cAAc,CAAEc,KAAM,CAAC,EAAG;MAC9B,MAAM;QACLG,UAAU,EAAE;UAAEC,KAAK;UAAEC;QAAK;MAC3B,CAAC,GAAGL,KAAK;MACT,MAAMM,cAAc,GAAI,GAAGF,KAAO,KAAKC,IAAM,EAAC;M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