@wordpress/edit-site 5.14.0 → 5.16.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/add-new-page/index.js +1 -6
- package/build/components/add-new-page/index.js.map +1 -1
- package/build/components/add-new-pattern/index.js +22 -7
- package/build/components/add-new-pattern/index.js.map +1 -1
- package/build/components/add-new-template/utils.js +10 -8
- package/build/components/add-new-template/utils.js.map +1 -1
- package/build/components/block-editor/constants.js +1 -1
- package/build/components/block-editor/constants.js.map +1 -1
- package/build/components/block-editor/editor-canvas.js +1 -1
- package/build/components/block-editor/editor-canvas.js.map +1 -1
- package/build/components/block-editor/index.js +0 -4
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/block-editor/use-site-editor-settings.js +114 -13
- package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build/components/code-editor/index.js +60 -28
- package/build/components/code-editor/index.js.map +1 -1
- package/build/components/create-pattern-modal/index.js +7 -3
- package/build/components/create-pattern-modal/index.js.map +1 -1
- package/build/components/editor/index.js +5 -5
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/global-styles-provider.js +12 -7
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/screen-block.js +16 -0
- package/build/components/global-styles/screen-block.js.map +1 -1
- package/build/components/global-styles/screen-revisions/index.js +12 -5
- package/build/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build/components/global-styles/screen-revisions/revisions-buttons.js +10 -22
- package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js +32 -25
- package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
- package/build/components/global-styles/style-variations-container.js +5 -3
- package/build/components/global-styles/style-variations-container.js.map +1 -1
- package/build/components/header-edit-mode/document-actions/index.js +4 -2
- package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build/components/header-edit-mode/index.js +13 -9
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/edit-mode.js +7 -5
- package/build/components/keyboard-shortcuts/edit-mode.js.map +1 -1
- package/build/components/layout/index.js +17 -5
- package/build/components/layout/index.js.map +1 -1
- package/build/components/page/index.js +3 -3
- package/build/components/page/index.js.map +1 -1
- package/build/components/page-actions/index.js +2 -2
- package/build/components/page-actions/index.js.map +1 -1
- package/build/components/page-actions/{delete-page-menu-item.js → trash-page-menu-item.js} +8 -16
- package/build/components/page-actions/trash-page-menu-item.js.map +1 -0
- package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js +5 -5
- package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +1 -1
- package/build/components/page-patterns/duplicate-menu-item.js +163 -0
- package/build/components/page-patterns/duplicate-menu-item.js.map +1 -0
- package/build/components/page-patterns/grid-item.js +83 -58
- package/build/components/page-patterns/grid-item.js.map +1 -1
- package/build/components/page-patterns/grid.js +5 -18
- package/build/components/page-patterns/grid.js.map +1 -1
- package/build/components/page-patterns/header.js +69 -0
- package/build/components/page-patterns/header.js.map +1 -0
- package/build/components/page-patterns/index.js +3 -1
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/page-patterns/pagination.js +63 -0
- package/build/components/page-patterns/pagination.js.map +1 -0
- package/build/components/page-patterns/patterns-list.js +110 -31
- package/build/components/page-patterns/patterns-list.js.map +1 -1
- package/build/components/page-patterns/rename-menu-item.js +109 -0
- package/build/components/page-patterns/rename-menu-item.js.map +1 -0
- package/build/components/page-patterns/use-patterns.js +116 -118
- package/build/components/page-patterns/use-patterns.js.map +1 -1
- package/build/components/page-template-parts/add-new-template-part.js +74 -0
- package/build/components/page-template-parts/add-new-template-part.js.map +1 -0
- package/build/components/page-template-parts/index.js +3 -25
- package/build/components/page-template-parts/index.js.map +1 -1
- package/build/components/page-templates/index.js +1 -16
- package/build/components/page-templates/index.js.map +1 -1
- package/build/components/resizable-frame/index.js +85 -51
- package/build/components/resizable-frame/index.js.map +1 -1
- package/build/components/save-button/index.js +4 -2
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/save-hub/index.js +10 -4
- package/build/components/save-hub/index.js.map +1 -1
- package/build/components/save-panel/index.js +5 -5
- package/build/components/save-panel/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/page-content.js +4 -3
- package/build/components/sidebar-edit-mode/page-panels/page-content.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/page-status.js +3 -8
- package/build/components/sidebar-edit-mode/page-panels/page-status.js.map +1 -1
- package/build/components/sidebar-edit-mode/template-panel/index.js +15 -8
- package/build/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +31 -15
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js +34 -40
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/index.js +4 -2
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/template-part-hint.js +45 -0
- package/build/components/sidebar-navigation-screen-main/template-part-hint.js.map +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menu/index.js +4 -4
- package/build/components/sidebar-navigation-screen-navigation-menu/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/more-menu.js +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menu/more-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +3 -3
- package/build/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +5 -4
- package/build/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/constants.js +2 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/constants.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js +4 -4
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +8 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
- package/build/components/sidebar-navigation-screen-page/index.js +2 -3
- package/build/components/sidebar-navigation-screen-page/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-page/status-label.js +1 -34
- package/build/components/sidebar-navigation-screen-page/status-label.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pages/index.js +35 -25
- package/build/components/sidebar-navigation-screen-pages/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/index.js +9 -7
- package/build/components/sidebar-navigation-screen-pattern/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +4 -3
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js +3 -2
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js +19 -4
- package/build/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js +55 -28
- package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/category-item.js +0 -5
- package/build/components/sidebar-navigation-screen-patterns/category-item.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/index.js +72 -60
- package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-my-patterns.js +9 -5
- package/build/components/sidebar-navigation-screen-patterns/use-my-patterns.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +11 -1
- package/build/components/sidebar-navigation-screen-patterns/use-pattern-categories.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +20 -9
- package/build/components/sidebar-navigation-screen-patterns/use-template-part-areas.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-theme-patterns.js +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-theme-patterns.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates/index.js +1 -10
- package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/index.js +9 -0
- package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build/components/site-hub/index.js +29 -13
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +10 -5
- 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-canvas-mode-with-url.js +1 -1
- package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
- package/build/components/sync-state-with-url/use-sync-path-with-url.js +15 -12
- package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build/components/template-actions/index.js +3 -1
- package/build/components/template-actions/index.js.map +1 -1
- package/build/components/template-actions/rename-menu-item.js +12 -8
- package/build/components/template-actions/rename-menu-item.js.map +1 -1
- package/build/components/use-edited-entity-record/index.js +6 -1
- package/build/components/use-edited-entity-record/index.js.map +1 -1
- package/build/hooks/commands/use-common-commands.js +120 -32
- package/build/hooks/commands/use-common-commands.js.map +1 -1
- package/build/hooks/commands/use-edit-mode-commands.js +65 -7
- package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build/hooks/push-changes-to-global-styles/index.js +138 -57
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build/store/private-actions.js +9 -2
- package/build/store/private-actions.js.map +1 -1
- package/build/utils/normalize-record-key.js +19 -0
- package/build/utils/normalize-record-key.js.map +1 -0
- package/build/utils/use-activate-theme.js +1 -1
- package/build/utils/use-activate-theme.js.map +1 -1
- package/build/utils/use-debounced-input.js +5 -7
- package/build/utils/use-debounced-input.js.map +1 -1
- package/build-module/components/add-new-page/index.js +1 -6
- package/build-module/components/add-new-page/index.js.map +1 -1
- package/build-module/components/add-new-pattern/index.js +20 -7
- package/build-module/components/add-new-pattern/index.js.map +1 -1
- package/build-module/components/add-new-template/utils.js +9 -6
- package/build-module/components/add-new-template/utils.js.map +1 -1
- package/build-module/components/block-editor/constants.js +1 -1
- package/build-module/components/block-editor/constants.js.map +1 -1
- package/build-module/components/block-editor/editor-canvas.js +1 -1
- package/build-module/components/block-editor/editor-canvas.js.map +1 -1
- package/build-module/components/block-editor/index.js +0 -4
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/block-editor/use-site-editor-settings.js +116 -14
- package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build-module/components/code-editor/index.js +62 -30
- package/build-module/components/code-editor/index.js.map +1 -1
- package/build-module/components/create-pattern-modal/index.js +6 -3
- package/build-module/components/create-pattern-modal/index.js.map +1 -1
- package/build-module/components/editor/index.js +5 -5
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/global-styles-provider.js +12 -7
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/screen-block.js +16 -0
- package/build-module/components/global-styles/screen-block.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/index.js +13 -6
- package/build-module/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +10 -22
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js +28 -21
- package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
- package/build-module/components/global-styles/style-variations-container.js +5 -3
- package/build-module/components/global-styles/style-variations-container.js.map +1 -1
- package/build-module/components/header-edit-mode/document-actions/index.js +6 -4
- package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build-module/components/header-edit-mode/index.js +13 -9
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/edit-mode.js +7 -5
- package/build-module/components/keyboard-shortcuts/edit-mode.js.map +1 -1
- package/build-module/components/layout/index.js +17 -5
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/page/index.js +3 -3
- package/build-module/components/page/index.js.map +1 -1
- package/build-module/components/page-actions/index.js +2 -2
- package/build-module/components/page-actions/index.js.map +1 -1
- package/build-module/components/page-actions/{delete-page-menu-item.js → trash-page-menu-item.js} +8 -17
- package/build-module/components/page-actions/trash-page-menu-item.js.map +1 -0
- package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js +5 -3
- package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +1 -1
- package/build-module/components/page-patterns/duplicate-menu-item.js +147 -0
- package/build-module/components/page-patterns/duplicate-menu-item.js.map +1 -0
- package/build-module/components/page-patterns/grid-item.js +84 -64
- package/build-module/components/page-patterns/grid-item.js.map +1 -1
- package/build-module/components/page-patterns/grid.js +5 -17
- package/build-module/components/page-patterns/grid.js.map +1 -1
- package/build-module/components/page-patterns/header.js +54 -0
- package/build-module/components/page-patterns/header.js.map +1 -0
- package/build-module/components/page-patterns/index.js +3 -1
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/page-patterns/pagination.js +54 -0
- package/build-module/components/page-patterns/pagination.js.map +1 -0
- package/build-module/components/page-patterns/patterns-list.js +111 -34
- package/build-module/components/page-patterns/patterns-list.js.map +1 -1
- package/build-module/components/page-patterns/rename-menu-item.js +97 -0
- package/build-module/components/page-patterns/rename-menu-item.js.map +1 -0
- package/build-module/components/page-patterns/use-patterns.js +116 -119
- package/build-module/components/page-patterns/use-patterns.js.map +1 -1
- package/build-module/components/page-template-parts/add-new-template-part.js +58 -0
- package/build-module/components/page-template-parts/add-new-template-part.js.map +1 -0
- package/build-module/components/page-template-parts/index.js +4 -24
- package/build-module/components/page-template-parts/index.js.map +1 -1
- package/build-module/components/page-templates/index.js +2 -15
- package/build-module/components/page-templates/index.js.map +1 -1
- package/build-module/components/resizable-frame/index.js +87 -55
- package/build-module/components/resizable-frame/index.js.map +1 -1
- package/build-module/components/save-button/index.js +4 -2
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/save-hub/index.js +10 -4
- package/build-module/components/save-hub/index.js.map +1 -1
- package/build-module/components/save-panel/index.js +5 -5
- package/build-module/components/save-panel/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/page-content.js +5 -2
- 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-status.js +3 -8
- package/build-module/components/sidebar-edit-mode/page-panels/page-status.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/template-panel/index.js +15 -9
- package/build-module/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +29 -16
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +34 -40
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js +4 -3
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/template-part-hint.js +33 -0
- package/build-module/components/sidebar-navigation-screen-main/template-part-hint.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menu/index.js +4 -4
- package/build-module/components/sidebar-navigation-screen-navigation-menu/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/more-menu.js +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menu/more-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +3 -3
- package/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +5 -4
- package/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/constants.js +2 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/constants.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +4 -4
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +7 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +2 -2
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-page/index.js +2 -3
- package/build-module/components/sidebar-navigation-screen-page/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-page/status-label.js +1 -32
- package/build-module/components/sidebar-navigation-screen-page/status-label.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pages/index.js +35 -25
- package/build-module/components/sidebar-navigation-screen-pages/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/index.js +8 -7
- package/build-module/components/sidebar-navigation-screen-pattern/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +4 -3
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js +3 -2
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js +18 -4
- package/build-module/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js +53 -28
- package/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/category-item.js +0 -5
- package/build-module/components/sidebar-navigation-screen-patterns/category-item.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/index.js +76 -60
- package/build-module/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-my-patterns.js +9 -5
- package/build-module/components/sidebar-navigation-screen-patterns/use-my-patterns.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +10 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-pattern-categories.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +18 -9
- package/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-theme-patterns.js +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-theme-patterns.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates/index.js +1 -8
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +7 -0
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build-module/components/site-hub/index.js +28 -13
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +7 -5
- 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-canvas-mode-with-url.js +1 -1
- package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +16 -12
- 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 +2 -1
- package/build-module/components/template-actions/index.js.map +1 -1
- package/build-module/components/template-actions/rename-menu-item.js +11 -8
- package/build-module/components/template-actions/rename-menu-item.js.map +1 -1
- package/build-module/components/use-edited-entity-record/index.js +3 -1
- package/build-module/components/use-edited-entity-record/index.js.map +1 -1
- package/build-module/hooks/commands/use-common-commands.js +116 -32
- package/build-module/hooks/commands/use-common-commands.js.map +1 -1
- package/build-module/hooks/commands/use-edit-mode-commands.js +65 -9
- package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build-module/hooks/push-changes-to-global-styles/index.js +139 -57
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build-module/store/private-actions.js +9 -2
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/utils/normalize-record-key.js +12 -0
- package/build-module/utils/normalize-record-key.js.map +1 -0
- package/build-module/utils/use-activate-theme.js +1 -1
- package/build-module/utils/use-activate-theme.js.map +1 -1
- package/build-module/utils/use-debounced-input.js +5 -7
- package/build-module/utils/use-debounced-input.js.map +1 -1
- package/build-style/style-rtl.css +281 -103
- package/build-style/style.css +281 -103
- package/package.json +39 -40
- package/src/components/add-new-page/index.js +0 -3
- package/src/components/add-new-pattern/index.js +25 -12
- package/src/components/add-new-template/utils.js +9 -6
- package/src/components/block-editor/constants.js +5 -1
- package/src/components/block-editor/editor-canvas.js +1 -1
- package/src/components/block-editor/index.js +0 -4
- package/src/components/block-editor/use-site-editor-settings.js +119 -20
- package/src/components/canvas-spinner/style.scss +14 -0
- package/src/components/code-editor/index.js +51 -33
- package/src/components/create-pattern-modal/index.js +5 -2
- package/src/components/editor/index.js +5 -5
- package/src/components/global-styles/global-styles-provider.js +7 -2
- package/src/components/global-styles/screen-block.js +15 -0
- package/src/components/global-styles/screen-revisions/index.js +64 -58
- package/src/components/global-styles/screen-revisions/revisions-buttons.js +17 -31
- package/src/components/global-styles/screen-revisions/test/use-global-styles-revisions.js +14 -1
- package/src/components/global-styles/screen-revisions/use-global-styles-revisions.js +64 -48
- package/src/components/global-styles/style-variations-container.js +2 -0
- package/src/components/header-edit-mode/document-actions/index.js +8 -4
- package/src/components/header-edit-mode/document-actions/style.scss +45 -28
- package/src/components/header-edit-mode/index.js +29 -22
- package/src/components/keyboard-shortcuts/edit-mode.js +4 -5
- package/src/components/layout/index.js +49 -22
- package/src/components/layout/style.scss +4 -3
- package/src/components/page/index.js +8 -8
- package/src/components/page/style.scss +8 -5
- package/src/components/page-actions/index.js +2 -2
- package/src/components/page-actions/{delete-page-menu-item.js → trash-page-menu-item.js} +9 -22
- package/src/components/page-content-focus-manager/disable-non-page-content-blocks.js +12 -3
- package/src/components/page-patterns/duplicate-menu-item.js +196 -0
- package/src/components/page-patterns/grid-item.js +189 -133
- package/src/components/page-patterns/grid.js +3 -20
- package/src/components/page-patterns/header.js +69 -0
- package/src/components/page-patterns/index.js +6 -1
- package/src/components/page-patterns/pagination.js +80 -0
- package/src/components/page-patterns/patterns-list.js +172 -71
- package/src/components/page-patterns/rename-menu-item.js +115 -0
- package/src/components/page-patterns/style.scss +141 -30
- package/src/components/page-patterns/use-patterns.js +115 -169
- package/src/components/page-template-parts/add-new-template-part.js +57 -0
- package/src/components/page-template-parts/index.js +3 -23
- package/src/components/page-templates/index.js +6 -19
- package/src/components/resizable-frame/index.js +104 -51
- package/src/components/resizable-frame/style.scss +9 -9
- package/src/components/save-button/index.js +2 -0
- package/src/components/save-hub/index.js +6 -1
- package/src/components/save-hub/style.scss +1 -1
- package/src/components/save-panel/index.js +10 -4
- package/src/components/sidebar-edit-mode/page-panels/page-content.js +7 -5
- package/src/components/sidebar-edit-mode/page-panels/page-status.js +2 -5
- package/src/components/sidebar-edit-mode/template-panel/index.js +15 -11
- package/src/components/sidebar-navigation-item/style.scss +5 -12
- package/src/components/sidebar-navigation-screen/index.js +30 -15
- package/src/components/sidebar-navigation-screen/style.scss +18 -0
- package/src/components/sidebar-navigation-screen-details-panel/style.scss +1 -0
- package/src/components/sidebar-navigation-screen-global-styles/index.js +48 -44
- package/src/components/sidebar-navigation-screen-main/index.js +44 -40
- package/src/components/sidebar-navigation-screen-main/template-part-hint.js +34 -0
- package/src/components/sidebar-navigation-screen-navigation-menu/index.js +4 -3
- package/src/components/sidebar-navigation-screen-navigation-menu/more-menu.js +1 -0
- package/src/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +1 -1
- package/src/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +16 -7
- package/src/components/sidebar-navigation-screen-navigation-menus/constants.js +2 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/index.js +4 -4
- package/src/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +27 -15
- package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +1 -4
- package/src/components/sidebar-navigation-screen-page/index.js +3 -3
- package/src/components/sidebar-navigation-screen-page/status-label.js +1 -35
- package/src/components/sidebar-navigation-screen-pages/index.js +48 -33
- package/src/components/sidebar-navigation-screen-pattern/index.js +5 -2
- package/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +3 -2
- package/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js +2 -1
- package/src/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js +23 -3
- package/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js +74 -43
- package/src/components/sidebar-navigation-screen-patterns/category-item.js +5 -13
- package/src/components/sidebar-navigation-screen-patterns/index.js +103 -106
- package/src/components/sidebar-navigation-screen-patterns/style.scss +20 -0
- package/src/components/sidebar-navigation-screen-patterns/use-my-patterns.js +7 -6
- package/src/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +9 -0
- package/src/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +31 -9
- package/src/components/sidebar-navigation-screen-patterns/use-theme-patterns.js +2 -1
- package/src/components/sidebar-navigation-screen-templates/index.js +1 -9
- package/src/components/sidebar-navigation-screen-templates-browse/index.js +10 -0
- package/src/components/site-hub/index.js +48 -29
- package/src/components/site-hub/style.scss +14 -2
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +8 -2
- package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +1 -4
- package/src/components/sync-state-with-url/use-sync-path-with-url.js +73 -66
- package/src/components/table/style.scss +1 -0
- package/src/components/template-actions/index.js +2 -1
- package/src/components/template-actions/rename-menu-item.js +17 -10
- package/src/components/use-edited-entity-record/index.js +6 -1
- package/src/hooks/commands/use-common-commands.js +105 -32
- package/src/hooks/commands/use-edit-mode-commands.js +94 -23
- package/src/hooks/push-changes-to-global-styles/index.js +141 -50
- package/src/store/private-actions.js +10 -2
- package/src/style.scss +10 -12
- package/src/utils/normalize-record-key.js +11 -0
- package/src/utils/use-activate-theme.js +1 -1
- package/src/utils/use-debounced-input.js +8 -7
- package/build/components/code-editor/code-editor-text-area.js +0 -96
- package/build/components/code-editor/code-editor-text-area.js.map +0 -1
- package/build/components/keyboard-shortcuts/index.js +0 -148
- package/build/components/keyboard-shortcuts/index.js.map +0 -1
- package/build/components/page-actions/delete-page-menu-item.js.map +0 -1
- package/build/components/page-content-focus-manager/constants.js +0 -9
- package/build/components/page-content-focus-manager/constants.js.map +0 -1
- package/build-module/components/code-editor/code-editor-text-area.js +0 -84
- package/build-module/components/code-editor/code-editor-text-area.js.map +0 -1
- package/build-module/components/keyboard-shortcuts/index.js +0 -132
- package/build-module/components/keyboard-shortcuts/index.js.map +0 -1
- package/build-module/components/page-actions/delete-page-menu-item.js.map +0 -1
- package/build-module/components/page-content-focus-manager/constants.js +0 -2
- package/build-module/components/page-content-focus-manager/constants.js.map +0 -1
- package/src/components/code-editor/code-editor-text-area.js +0 -84
- package/src/components/keyboard-shortcuts/index.js +0 -137
- package/src/components/page-content-focus-manager/constants.js +0 -5
|
@@ -29,6 +29,8 @@ var _icons = require("@wordpress/icons");
|
|
|
29
29
|
|
|
30
30
|
var _commands = require("@wordpress/commands");
|
|
31
31
|
|
|
32
|
+
var _keycodes = require("@wordpress/keycodes");
|
|
33
|
+
|
|
32
34
|
var _store = require("../../store");
|
|
33
35
|
|
|
34
36
|
var _siteIcon = _interopRequireDefault(require("../site-icon"));
|
|
@@ -47,24 +49,30 @@ var _lockUnlock = require("../../lock-unlock");
|
|
|
47
49
|
* Internal dependencies
|
|
48
50
|
*/
|
|
49
51
|
const HUB_ANIMATION_DURATION = 0.3;
|
|
50
|
-
const SiteHub = (0, _element.forwardRef)((
|
|
52
|
+
const SiteHub = (0, _element.forwardRef)(({
|
|
53
|
+
isTransparent,
|
|
54
|
+
...restProps
|
|
55
|
+
}, ref) => {
|
|
51
56
|
const {
|
|
52
57
|
canvasMode,
|
|
53
58
|
dashboardLink,
|
|
54
|
-
homeUrl
|
|
59
|
+
homeUrl,
|
|
60
|
+
siteTitle
|
|
55
61
|
} = (0, _data.useSelect)(select => {
|
|
56
62
|
const {
|
|
57
63
|
getCanvasMode,
|
|
58
64
|
getSettings
|
|
59
65
|
} = (0, _lockUnlock.unlock)(select(_store.store));
|
|
60
66
|
const {
|
|
67
|
+
getSite,
|
|
61
68
|
getUnstableBase // Site index.
|
|
62
69
|
|
|
63
70
|
} = select(_coreData.store);
|
|
64
71
|
return {
|
|
65
72
|
canvasMode: getCanvasMode(),
|
|
66
73
|
dashboardLink: getSettings().__experimentalDashboardLink || 'index.php',
|
|
67
|
-
homeUrl: getUnstableBase()?.home
|
|
74
|
+
homeUrl: getUnstableBase()?.home,
|
|
75
|
+
siteTitle: getSite()?.title
|
|
68
76
|
};
|
|
69
77
|
}, []);
|
|
70
78
|
const {
|
|
@@ -72,7 +80,8 @@ const SiteHub = (0, _element.forwardRef)((props, ref) => {
|
|
|
72
80
|
} = (0, _data.useDispatch)(_commands.store);
|
|
73
81
|
const disableMotion = (0, _compose.useReducedMotion)();
|
|
74
82
|
const {
|
|
75
|
-
setCanvasMode
|
|
83
|
+
setCanvasMode,
|
|
84
|
+
__experimentalSetPreviewDeviceType: setPreviewDeviceType
|
|
76
85
|
} = (0, _lockUnlock.unlock)((0, _data.useDispatch)(_store.store));
|
|
77
86
|
const {
|
|
78
87
|
clearSelectedBlock
|
|
@@ -80,7 +89,7 @@ const SiteHub = (0, _element.forwardRef)((props, ref) => {
|
|
|
80
89
|
const isBackToDashboardButton = canvasMode === 'view';
|
|
81
90
|
const siteIconButtonProps = isBackToDashboardButton ? {
|
|
82
91
|
href: dashboardLink,
|
|
83
|
-
label: (0, _i18n.__)('Go
|
|
92
|
+
label: (0, _i18n.__)('Go to the Dashboard')
|
|
84
93
|
} : {
|
|
85
94
|
href: dashboardLink,
|
|
86
95
|
// We need to keep the `href` here so the component doesn't remount as a `<button>` and break the animation.
|
|
@@ -91,15 +100,15 @@ const SiteHub = (0, _element.forwardRef)((props, ref) => {
|
|
|
91
100
|
|
|
92
101
|
if (canvasMode === 'edit') {
|
|
93
102
|
clearSelectedBlock();
|
|
103
|
+
setPreviewDeviceType('desktop');
|
|
94
104
|
setCanvasMode('view');
|
|
95
105
|
}
|
|
96
106
|
}
|
|
97
107
|
};
|
|
98
|
-
const siteTitle = (0, _data.useSelect)(select => select(_coreData.store).getEntityRecord('root', 'site')?.title, []);
|
|
99
108
|
return (0, _element.createElement)(_components.__unstableMotion.div, {
|
|
100
109
|
ref: ref,
|
|
101
|
-
...
|
|
102
|
-
className: (0, _classnames.default)('edit-site-site-hub',
|
|
110
|
+
...restProps,
|
|
111
|
+
className: (0, _classnames.default)('edit-site-site-hub', restProps.className),
|
|
103
112
|
initial: false,
|
|
104
113
|
transition: {
|
|
105
114
|
type: 'tween',
|
|
@@ -115,7 +124,9 @@ const SiteHub = (0, _element.forwardRef)((props, ref) => {
|
|
|
115
124
|
className: "edit-site-site-hub__text-content",
|
|
116
125
|
spacing: "0"
|
|
117
126
|
}, (0, _element.createElement)(_components.__unstableMotion.div, {
|
|
118
|
-
className:
|
|
127
|
+
className: (0, _classnames.default)('edit-site-site-hub__view-mode-toggle-container', {
|
|
128
|
+
'has-transparent-background': isTransparent
|
|
129
|
+
}),
|
|
119
130
|
layout: true,
|
|
120
131
|
transition: {
|
|
121
132
|
type: 'tween',
|
|
@@ -147,7 +158,9 @@ const SiteHub = (0, _element.forwardRef)((props, ref) => {
|
|
|
147
158
|
exit: {
|
|
148
159
|
opacity: 0
|
|
149
160
|
},
|
|
150
|
-
className:
|
|
161
|
+
className: (0, _classnames.default)('edit-site-site-hub__site-title', {
|
|
162
|
+
'is-transparent': isTransparent
|
|
163
|
+
}),
|
|
151
164
|
transition: {
|
|
152
165
|
type: 'tween',
|
|
153
166
|
duration: disableMotion ? 0 : 0.2,
|
|
@@ -157,15 +170,18 @@ const SiteHub = (0, _element.forwardRef)((props, ref) => {
|
|
|
157
170
|
}, (0, _htmlEntities.decodeEntities)(siteTitle))), canvasMode === 'view' && (0, _element.createElement)(_components.Button, {
|
|
158
171
|
href: homeUrl,
|
|
159
172
|
target: "_blank",
|
|
160
|
-
label: (0, _i18n.__)('View site'),
|
|
173
|
+
label: (0, _i18n.__)('View site (opens in a new tab)'),
|
|
161
174
|
"aria-label": (0, _i18n.__)('View site (opens in a new tab)'),
|
|
162
175
|
icon: _icons.external,
|
|
163
176
|
className: "edit-site-site-hub__site-view-link"
|
|
164
177
|
})), canvasMode === 'view' && (0, _element.createElement)(_components.Button, {
|
|
165
|
-
className:
|
|
178
|
+
className: (0, _classnames.default)('edit-site-site-hub_toggle-command-center', {
|
|
179
|
+
'is-transparent': isTransparent
|
|
180
|
+
}),
|
|
166
181
|
icon: _icons.search,
|
|
167
182
|
onClick: () => openCommandCenter(),
|
|
168
|
-
label: (0, _i18n.__)('Open command palette')
|
|
183
|
+
label: (0, _i18n.__)('Open command palette'),
|
|
184
|
+
shortcut: _keycodes.displayShortcut.primary('k')
|
|
169
185
|
})));
|
|
170
186
|
});
|
|
171
187
|
var _default = SiteHub;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/site-hub/index.js"],"names":["HUB_ANIMATION_DURATION","SiteHub","props","ref","canvasMode","dashboardLink","homeUrl","select","getCanvasMode","getSettings","editSiteStore","getUnstableBase","coreStore","__experimentalDashboardLink","home","open","openCommandCenter","commandsStore","disableMotion","setCanvasMode","clearSelectedBlock","blockEditorStore","isBackToDashboardButton","siteIconButtonProps","href","label","role","onClick","event","preventDefault","siteTitle","getEntityRecord","title","className","type","duration","ease","scale","opacity","delay","external","search"],"mappings":";;;;;;;;;AAoBA;;AAjBA;;AAKA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAKA;;AACA;;AACA;;AA7BA;AACA;AACA;;AAGA;AACA;AACA;;AAiBA;AACA;AACA;AAKA,MAAMA,sBAAsB,GAAG,GAA/B;AAEA,MAAMC,OAAO,GAAG,yBAAY,CAAEC,KAAF,EAASC,GAAT,KAAkB;AAC7C,QAAM;AAAEC,IAAAA,UAAF;AAAcC,IAAAA,aAAd;AAA6BC,IAAAA;AAA7B,MAAyC,qBAAaC,MAAF,IAAc;AACvE,UAAM;AAAEC,MAAAA,aAAF;AAAiBC,MAAAA;AAAjB,QAAiC,wBACtCF,MAAM,CAAEG,YAAF,CADgC,CAAvC;AAIA,UAAM;AACLC,MAAAA,eADK,CACY;;AADZ,QAEFJ,MAAM,CAAEK,eAAF,CAFV;AAIA,WAAO;AACNR,MAAAA,UAAU,EAAEI,aAAa,EADnB;AAENH,MAAAA,aAAa,EACZI,WAAW,GAAGI,2BAAd,IAA6C,WAHxC;AAINP,MAAAA,OAAO,EAAEK,eAAe,IAAIG;AAJtB,KAAP;AAMA,GAf8C,EAe5C,EAf4C,CAA/C;AAgBA,QAAM;AAAEC,IAAAA,IAAI,EAAEC;AAAR,MAA8B,uBAAaC,eAAb,CAApC;AAEA,QAAMC,aAAa,GAAG,gCAAtB;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAoB,wBAAQ,uBAAaT,YAAb,CAAR,CAA1B;AACA,QAAM;AAAEU,IAAAA;AAAF,MAAyB,uBAAaC,kBAAb,CAA/B;AACA,QAAMC,uBAA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,MAAAA,KAAK,EAAEnC,UAAU,KAAK,MAAf,GAAwB,GAAxB,GAA8B;AAJzB;AATd,KAgBG,kCAAgB0B,SAAhB,CAhBH,CADD,CAzCD,EA6DG1B,UAAU,KAAK,MAAf,IACD,4BAAC,kBAAD;AACC,IAAA,IAAI,EAAGE,OADR;AAEC,IAAA,MAAM,EAAC,QAFR;AAGC,IAAA,KAAK,EAAG,cAAI,WAAJ,CAHT;AAIC,kBAAa,cACZ,gCADY,CAJd;AAOC,IAAA,IAAI,EAAGkC,eAPR;AAQC,IAAA,SAAS,EAAC;AARX,IA9DF,CALD,EA+EGpC,UAAU,KAAK,MAAf,IACD,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAC,0CADX;AAEC,IAAA,IAAI,EAAGqC,aAFR;AAGC,IAAA,OAAO,EAAG,MAAMzB,iBAAiB,EAHlC;AAIC,IAAA,KAAK,EAAG,cAAI,sBAAJ;AAJT,IAhFF,CAXD,CADD;AAsGA,CArJe,CAAhB;eAuJef,O","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tButton,\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { useReducedMotion } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { forwardRef } from '@wordpress/element';\nimport { search, external } from '@wordpress/icons';\nimport { store as commandsStore } from '@wordpress/commands';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport SiteIcon from '../site-icon';\nimport { unlock } from '../../lock-unlock';\n\nconst HUB_ANIMATION_DURATION = 0.3;\n\nconst SiteHub = forwardRef( ( props, ref ) => {\n\tconst { canvasMode, dashboardLink, homeUrl } = useSelect( ( select ) => {\n\t\tconst { getCanvasMode, getSettings } = unlock(\n\t\t\tselect( editSiteStore )\n\t\t);\n\n\t\tconst {\n\t\t\tgetUnstableBase, // Site index.\n\t\t} = select( coreStore );\n\n\t\treturn {\n\t\t\tcanvasMode: getCanvasMode(),\n\t\t\tdashboardLink:\n\t\t\t\tgetSettings().__experimentalDashboardLink || 'index.php',\n\t\t\thomeUrl: getUnstableBase()?.home,\n\t\t};\n\t}, [] );\n\tconst { open: openCommandCenter } = useDispatch( commandsStore );\n\n\tconst disableMotion = useReducedMotion();\n\tconst { setCanvasMode } = unlock( useDispatch( editSiteStore ) );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst isBackToDashboardButton = canvasMode === 'view';\n\tconst siteIconButtonProps = isBackToDashboardButton\n\t\t? {\n\t\t\t\thref: dashboardLink,\n\t\t\t\tlabel: __( 'Go back to the Dashboard' ),\n\t\t }\n\t\t: {\n\t\t\t\thref: dashboardLink, // We need to keep the `href` here so the component doesn't remount as a `<button>` and break the animation.\n\t\t\t\trole: 'button',\n\t\t\t\tlabel: __( 'Open Navigation' ),\n\t\t\t\tonClick: ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tif ( canvasMode === 'edit' ) {\n\t\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t\t\tsetCanvasMode( 'view' );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t };\n\n\tconst siteTitle = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecord( 'root', 'site' )?.title,\n\t\t[]\n\t);\n\n\treturn (\n\t\t<motion.div\n\t\t\tref={ ref }\n\t\t\t{ ...props }\n\t\t\tclassName={ classnames( 'edit-site-site-hub', props.className ) }\n\t\t\tinitial={ false }\n\t\t\ttransition={ {\n\t\t\t\ttype: 'tween',\n\t\t\t\tduration: disableMotion ? 0 : HUB_ANIMATION_DURATION,\n\t\t\t\tease: 'easeOut',\n\t\t\t} }\n\t\t>\n\t\t\t<HStack\n\t\t\t\tjustify=\"space-between\"\n\t\t\t\talignment=\"center\"\n\t\t\t\tclassName=\"edit-site-site-hub__container\"\n\t\t\t>\n\t\t\t\t<HStack\n\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\tclassName=\"edit-site-site-hub__text-content\"\n\t\t\t\t\tspacing=\"0\"\n\t\t\t\t>\n\t\t\t\t\t<motion.div\n\t\t\t\t\t\tclassName=\"edit-site-site-hub__view-mode-toggle-container\"\n\t\t\t\t\t\tlayout\n\t\t\t\t\t\ttransition={ {\n\t\t\t\t\t\t\ttype: 'tween',\n\t\t\t\t\t\t\tduration: disableMotion\n\t\t\t\t\t\t\t\t? 0\n\t\t\t\t\t\t\t\t: HUB_ANIMATION_DURATION,\n\t\t\t\t\t\t\tease: 'easeOut',\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t{ ...siteIconButtonProps }\n\t\t\t\t\t\t\tclassName=\"edit-site-layout__view-mode-toggle\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<motion.div\n\t\t\t\t\t\t\t\tinitial={ false }\n\t\t\t\t\t\t\t\tanimate={ {\n\t\t\t\t\t\t\t\t\tscale: canvasMode === 'view' ? 0.5 : 1,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\twhileHover={ {\n\t\t\t\t\t\t\t\t\tscale: canvasMode === 'view' ? 0.5 : 0.96,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\ttransition={ {\n\t\t\t\t\t\t\t\t\ttype: 'tween',\n\t\t\t\t\t\t\t\t\tduration: disableMotion\n\t\t\t\t\t\t\t\t\t\t? 0\n\t\t\t\t\t\t\t\t\t\t: HUB_ANIMATION_DURATION,\n\t\t\t\t\t\t\t\t\tease: 'easeOut',\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<SiteIcon className=\"edit-site-layout__view-mode-toggle-icon\" />\n\t\t\t\t\t\t\t</motion.div>\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</motion.div>\n\n\t\t\t\t\t<AnimatePresence>\n\t\t\t\t\t\t<motion.div\n\t\t\t\t\t\t\tlayout={ canvasMode === 'edit' }\n\t\t\t\t\t\t\tanimate={ {\n\t\t\t\t\t\t\t\topacity: canvasMode === 'view' ? 1 : 0,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\texit={ {\n\t\t\t\t\t\t\t\topacity: 0,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tclassName=\"edit-site-site-hub__site-title\"\n\t\t\t\t\t\t\ttransition={ {\n\t\t\t\t\t\t\t\ttype: 'tween',\n\t\t\t\t\t\t\t\tduration: disableMotion ? 0 : 0.2,\n\t\t\t\t\t\t\t\tease: 'easeOut',\n\t\t\t\t\t\t\t\tdelay: canvasMode === 'view' ? 0.1 : 0,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ decodeEntities( siteTitle ) }\n\t\t\t\t\t\t</motion.div>\n\t\t\t\t\t</AnimatePresence>\n\t\t\t\t\t{ canvasMode === 'view' && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\thref={ homeUrl }\n\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\tlabel={ __( 'View site' ) }\n\t\t\t\t\t\t\taria-label={ __(\n\t\t\t\t\t\t\t\t'View site (opens in a new tab)'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\ticon={ external }\n\t\t\t\t\t\t\tclassName=\"edit-site-site-hub__site-view-link\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</HStack>\n\t\t\t\t{ canvasMode === 'view' && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"edit-site-site-hub_toggle-command-center\"\n\t\t\t\t\t\ticon={ search }\n\t\t\t\t\t\tonClick={ () => openCommandCenter() }\n\t\t\t\t\t\tlabel={ __( 'Open command palette' ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</HStack>\n\t\t</motion.div>\n\t);\n} );\n\nexport default SiteHub;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/site-hub/index.js"],"names":["HUB_ANIMATION_DURATION","SiteHub","isTransparent","restProps","ref","canvasMode","dashboardLink","homeUrl","siteTitle","select","getCanvasMode","getSettings","editSiteStore","getSite","getUnstableBase","coreStore","__experimentalDashboardLink","home","title","open","openCommandCenter","commandsStore","disableMotion","setCanvasMode","__experimentalSetPreviewDeviceType","setPreviewDeviceType","clearSelectedBlock","blockEditorStore","isBackToDashboardButton","siteIconButtonProps","href","label","role","onClick","event","preventDefault","className","type","duration","ease","scale","opacity","delay","external","search","displayShortcut","primary"],"mappings":";;;;;;;;;AAoBA;;AAjBA;;AAKA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AA9BA;AACA;AACA;;AAGA;AACA;AACA;;AAkBA;AACA;AACA;AAKA,MAAMA,sBAAsB,GAAG,GAA/B;AAEA,MAAMC,OAAO,GAAG,yBAAY,CAAE;AAAEC,EAAAA,aAAF;AAAiB,KAAGC;AAApB,CAAF,EAAmCC,GAAnC,KAA4C;AACvE,QAAM;AAAEC,IAAAA,UAAF;AAAcC,IAAAA,aAAd;AAA6BC,IAAAA,OAA7B;AAAsCC,IAAAA;AAAtC,MAAoD,qBACvDC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA,aAAF;AAAiBC,MAAAA;AAAjB,QAAiC,wBACtCF,MAAM,CAAEG,YAAF,CADgC,CAAvC;AAIA,UAAM;AACLC,MAAAA,OADK;AAELC,MAAAA,eAFK,CAEY;;AAFZ,QAGFL,MAAM,CAAEM,eAAF,CAHV;AAKA,WAAO;AACNV,MAAAA,UAAU,EAAEK,aAAa,EADnB;AAENJ,MAAAA,aAAa,EACZK,WAAW,GAAGK,2BAAd,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C,UAAU,KAAK,MADzB;AAEC,IAAA,OAAO,EAAG;AACToC,MAAAA,OAAO,EAAEpC,UAAU,KAAK,MAAf,GAAwB,CAAxB,GAA4B;AAD5B,KAFX;AAKC,IAAA,IAAI,EAAG;AACNoC,MAAAA,OAAO,EAAE;AADH,KALR;AAQC,IAAA,SAAS,EAAG,yBACX,gCADW,EAEX;AAAE,wBAAkBvC;AAApB,KAFW,CARb;AAYC,IAAA,UAAU,EAAG;AACZmC,MAAAA,IAAI,EAAE,OADM;AAEZC,MAAAA,QAAQ,EAAEhB,aAAa,GAAG,CAAH,GAAO,GAFlB;AAGZiB,MAAAA,IAAI,EAAE,SAHM;AAIZG,MAAAA,KAAK,EAAErC,UAAU,KAAK,MAAf,GAAwB,GAAxB,GAA8B;AAJzB;AAZd,KAmBG,kCAAgBG,SAAhB,CAnBH,CADD,CA9CD,EAqEGH,UAAU,KAAK,MAAf,IACD,4BAAC,kBAAD;AACC,IAAA,IAAI,EAAGE,OADR;AAEC,IAAA,MAAM,EAAC,QAFR;AAGC,IAAA,KAAK,EAAG,cAAI,gCAAJ,CAHT;AAIC,kBAAa,cACZ,gCADY,CAJd;AAOC,IAAA,IAAI,EAAGoC,eAPR;AAQC,IAAA,SAAS,EAAC;AARX,IAtEF,CALD,EAuFGtC,UAAU,KAAK,MAAf,IACD,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAG,yBACX,0CADW,EAEX;AAAE,wBAAkBH;AAApB,KAFW,CADb;AAKC,IAAA,IAAI,EAAG0C,aALR;AAMC,IAAA,OAAO,EAAG,MAAMxB,iBAAiB,EANlC;AAOC,IAAA,KAAK,EAAG,cAAI,sBAAJ,CAPT;AAQC,IAAA,QAAQ,EAAGyB,0BAAgBC,OAAhB,CAAyB,GAAzB;AARZ,IAxFF,CAdD,CADD;AAqHA,CAvKe,CAAhB;eAyKe7C,O","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tButton,\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { useReducedMotion } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { forwardRef } from '@wordpress/element';\nimport { search, external } from '@wordpress/icons';\nimport { store as commandsStore } from '@wordpress/commands';\nimport { displayShortcut } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport SiteIcon from '../site-icon';\nimport { unlock } from '../../lock-unlock';\n\nconst HUB_ANIMATION_DURATION = 0.3;\n\nconst SiteHub = forwardRef( ( { isTransparent, ...restProps }, ref ) => {\n\tconst { canvasMode, dashboardLink, homeUrl, siteTitle } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCanvasMode, getSettings } = unlock(\n\t\t\t\tselect( editSiteStore )\n\t\t\t);\n\n\t\t\tconst {\n\t\t\t\tgetSite,\n\t\t\t\tgetUnstableBase, // Site index.\n\t\t\t} = select( coreStore );\n\n\t\t\treturn {\n\t\t\t\tcanvasMode: getCanvasMode(),\n\t\t\t\tdashboardLink:\n\t\t\t\t\tgetSettings().__experimentalDashboardLink || 'index.php',\n\t\t\t\thomeUrl: getUnstableBase()?.home,\n\t\t\t\tsiteTitle: getSite()?.title,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst { open: openCommandCenter } = useDispatch( commandsStore );\n\n\tconst disableMotion = useReducedMotion();\n\tconst {\n\t\tsetCanvasMode,\n\t\t__experimentalSetPreviewDeviceType: setPreviewDeviceType,\n\t} = unlock( useDispatch( editSiteStore ) );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst isBackToDashboardButton = canvasMode === 'view';\n\tconst siteIconButtonProps = isBackToDashboardButton\n\t\t? {\n\t\t\t\thref: dashboardLink,\n\t\t\t\tlabel: __( 'Go to the Dashboard' ),\n\t\t }\n\t\t: {\n\t\t\t\thref: dashboardLink, // We need to keep the `href` here so the component doesn't remount as a `<button>` and break the animation.\n\t\t\t\trole: 'button',\n\t\t\t\tlabel: __( 'Open Navigation' ),\n\t\t\t\tonClick: ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tif ( canvasMode === 'edit' ) {\n\t\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t\t\tsetPreviewDeviceType( 'desktop' );\n\t\t\t\t\t\tsetCanvasMode( 'view' );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t };\n\n\treturn (\n\t\t<motion.div\n\t\t\tref={ ref }\n\t\t\t{ ...restProps }\n\t\t\tclassName={ classnames(\n\t\t\t\t'edit-site-site-hub',\n\t\t\t\trestProps.className\n\t\t\t) }\n\t\t\tinitial={ false }\n\t\t\ttransition={ {\n\t\t\t\ttype: 'tween',\n\t\t\t\tduration: disableMotion ? 0 : HUB_ANIMATION_DURATION,\n\t\t\t\tease: 'easeOut',\n\t\t\t} }\n\t\t>\n\t\t\t<HStack\n\t\t\t\tjustify=\"space-between\"\n\t\t\t\talignment=\"center\"\n\t\t\t\tclassName=\"edit-site-site-hub__container\"\n\t\t\t>\n\t\t\t\t<HStack\n\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\tclassName=\"edit-site-site-hub__text-content\"\n\t\t\t\t\tspacing=\"0\"\n\t\t\t\t>\n\t\t\t\t\t<motion.div\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'edit-site-site-hub__view-mode-toggle-container',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'has-transparent-background': isTransparent,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tlayout\n\t\t\t\t\t\ttransition={ {\n\t\t\t\t\t\t\ttype: 'tween',\n\t\t\t\t\t\t\tduration: disableMotion\n\t\t\t\t\t\t\t\t? 0\n\t\t\t\t\t\t\t\t: HUB_ANIMATION_DURATION,\n\t\t\t\t\t\t\tease: 'easeOut',\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t{ ...siteIconButtonProps }\n\t\t\t\t\t\t\tclassName=\"edit-site-layout__view-mode-toggle\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<motion.div\n\t\t\t\t\t\t\t\tinitial={ false }\n\t\t\t\t\t\t\t\tanimate={ {\n\t\t\t\t\t\t\t\t\tscale: canvasMode === 'view' ? 0.5 : 1,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\twhileHover={ {\n\t\t\t\t\t\t\t\t\tscale: canvasMode === 'view' ? 0.5 : 0.96,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\ttransition={ {\n\t\t\t\t\t\t\t\t\ttype: 'tween',\n\t\t\t\t\t\t\t\t\tduration: disableMotion\n\t\t\t\t\t\t\t\t\t\t? 0\n\t\t\t\t\t\t\t\t\t\t: HUB_ANIMATION_DURATION,\n\t\t\t\t\t\t\t\t\tease: 'easeOut',\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<SiteIcon className=\"edit-site-layout__view-mode-toggle-icon\" />\n\t\t\t\t\t\t\t</motion.div>\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</motion.div>\n\n\t\t\t\t\t<AnimatePresence>\n\t\t\t\t\t\t<motion.div\n\t\t\t\t\t\t\tlayout={ canvasMode === 'edit' }\n\t\t\t\t\t\t\tanimate={ {\n\t\t\t\t\t\t\t\topacity: canvasMode === 'view' ? 1 : 0,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\texit={ {\n\t\t\t\t\t\t\t\topacity: 0,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'edit-site-site-hub__site-title',\n\t\t\t\t\t\t\t\t{ 'is-transparent': isTransparent }\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\ttransition={ {\n\t\t\t\t\t\t\t\ttype: 'tween',\n\t\t\t\t\t\t\t\tduration: disableMotion ? 0 : 0.2,\n\t\t\t\t\t\t\t\tease: 'easeOut',\n\t\t\t\t\t\t\t\tdelay: canvasMode === 'view' ? 0.1 : 0,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ decodeEntities( siteTitle ) }\n\t\t\t\t\t\t</motion.div>\n\t\t\t\t\t</AnimatePresence>\n\t\t\t\t\t{ canvasMode === 'view' && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\thref={ homeUrl }\n\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\tlabel={ __( 'View site (opens in a new tab)' ) }\n\t\t\t\t\t\t\taria-label={ __(\n\t\t\t\t\t\t\t\t'View site (opens in a new tab)'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\ticon={ external }\n\t\t\t\t\t\t\tclassName=\"edit-site-site-hub__site-view-link\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</HStack>\n\t\t\t\t{ canvasMode === 'view' && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'edit-site-site-hub_toggle-command-center',\n\t\t\t\t\t\t\t{ 'is-transparent': isTransparent }\n\t\t\t\t\t\t) }\n\t\t\t\t\t\ticon={ search }\n\t\t\t\t\t\tonClick={ () => openCommandCenter() }\n\t\t\t\t\t\tlabel={ __( 'Open command palette' ) }\n\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</HStack>\n\t\t</motion.div>\n\t);\n} );\n\nexport default SiteHub;\n"]}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -17,6 +19,8 @@ var _store = require("../../store");
|
|
|
17
19
|
|
|
18
20
|
var _lockUnlock = require("../../lock-unlock");
|
|
19
21
|
|
|
22
|
+
var _normalizeRecordKey = _interopRequireDefault(require("../../utils/normalize-record-key"));
|
|
23
|
+
|
|
20
24
|
/**
|
|
21
25
|
* WordPress dependencies
|
|
22
26
|
*/
|
|
@@ -30,11 +34,12 @@ const {
|
|
|
30
34
|
|
|
31
35
|
function useInitEditedEntityFromURL() {
|
|
32
36
|
const {
|
|
33
|
-
params
|
|
34
|
-
postId,
|
|
35
|
-
postType
|
|
36
|
-
} = {}
|
|
37
|
+
params
|
|
37
38
|
} = useLocation();
|
|
39
|
+
const {
|
|
40
|
+
postType
|
|
41
|
+
} = params;
|
|
42
|
+
const postId = (0, _normalizeRecordKey.default)(params?.postId);
|
|
38
43
|
const {
|
|
39
44
|
isRequestingSite,
|
|
40
45
|
homepageId,
|
|
@@ -95,7 +100,7 @@ function useInitEditedEntityFromURL() {
|
|
|
95
100
|
setPage({
|
|
96
101
|
context: {
|
|
97
102
|
postType: 'page',
|
|
98
|
-
postId: homepageId
|
|
103
|
+
postId: Number(homepageId)
|
|
99
104
|
}
|
|
100
105
|
});
|
|
101
106
|
} else if (!isRequestingSite) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js"],"names":["useLocation","routerPrivateApis","useInitEditedEntityFromURL","params","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js"],"names":["useLocation","routerPrivateApis","useInitEditedEntityFromURL","params","postType","postId","isRequestingSite","homepageId","url","select","getSite","getUnstableBase","coreDataStore","siteData","base","show_on_front","page_on_front","home","setEditedEntity","setTemplate","setTemplatePart","setPage","setNavigationMenu","editSiteStore","context","Number","path"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAbA;AACA;AACA;;AAMA;AACA;AACA;AAKA,MAAM;AAAEA,EAAAA;AAAF,IAAkB,wBAAQC,mBAAR,CAAxB;;AAEe,SAASC,0BAAT,GAAsC;AACpD,QAAM;AAAEC,IAAAA;AAAF,MAAaH,WAAW,EAA9B;AAEA,QAAM;AAAEI,IAAAA;AAAF,MAAeD,MAArB;AAEA,QAAME,MAAM,GAAG,iCAAoBF,MAAM,EAAEE,MAA5B,CAAf;AAEA,QAAM;AAAEC,IAAAA,gBAAF;AAAoBC,IAAAA,UAApB;AAAgCC,IAAAA;AAAhC,MAAwC,qBAAaC,MAAF,IAAc;AACtE,UAAM;AAAEC,MAAAA,OAAF;AAAWC,MAAAA;AAAX,QAA+BF,MAAM,CAAEG,eAAF,CAA3C;AACA,UAAMC,QAAQ,GAAGH,OAAO,EAAxB;AACA,UAAMI,IAAI,GAAGH,eAAe,EAA5B;AAEA,WAAO;AACNL,MAAAA,gBAAgB,EAAE,CAAEQ,IADd;AAENP,MAAAA,UAAU,EACTM,QAAQ,EAAEE,aAAV,KAA4B,MAA5B,GACGF,QAAQ,CAACG,aADZ,GAEG,IALE;AAMNR,MAAAA,GAAG,EAAEM,IAAI,EAAEG;AANL,KAAP;AAQA,GAb6C,EAa3C,EAb2C,CAA9C;AAeA,QAAM;AACLC,IAAAA,eADK;AAELC,IAAAA,WAFK;AAGLC,IAAAA,eAHK;AAILC,IAAAA,OAJK;AAKLC,IAAAA;AALK,MAMF,uBAAaC,YAAb,CANJ;AAQA,0BAAW,MAAM;AAChB,QAAKnB,QAAQ,IAAIC,MAAjB,EAA0B;AACzB,cAASD,QAAT;AACC,aAAK,aAAL;AACCe,UAAAA,WAAW,CAAEd,MAAF,CAAX;AACA;;AACD,aAAK,kBAAL;AACCe,UAAAA,eAAe,CAAEf,MAAF,CAAf;AACA;;AACD,aAAK,eAAL;AACCiB,UAAAA,iBAAiB,CAAEjB,MAAF,CAAjB;AACA;;AACD,aAAK,UAAL;AACCa,UAAAA,eAAe,CAAEd,QAAF,EAAYC,MAAZ,CAAf;AACA;;AACD;AACCgB,UAAAA,OAAO,CAAE;AACRG,YAAAA,OAAO,EAAE;AAAEpB,cAAAA,QAAF;AAAYC,cAAAA;AAAZ;AADD,WAAF,CAAP;AAdF;;AAmBA;AACA,KAtBe,CAwBhB;;;AACA,QAAKE,UAAL,EAAkB;AACjBc,MAAAA,OAAO,CAAE;AACRG,QAAAA,OAAO,EAAE;AAAEpB,UAAAA,QAAQ,EAAE,MAAZ;AAAoBC,UAAAA,MAAM,EAAEoB,MAAM,CAAElB,UAAF;AAAlC;AADD,OAAF,CAAP;AAGA,KAJD,MAIO,IAAK,CAAED,gBAAP,EAA0B;AAChCe,MAAAA,OAAO,CAAE;AACRK,QAAAA,IAAI,EAAElB;AADE,OAAF,CAAP;AAGA;AACD,GAlCD,EAkCG,CACFA,GADE,EAEFH,MAFE,EAGFD,QAHE,EAIFG,UAJE,EAKFD,gBALE,EAMFY,eANE,EAOFG,OAPE,EAQFF,WARE,EASFC,eATE,EAUFE,iBAVE,CAlCH;AA8CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport normalizeRecordKey from '../../utils/normalize-record-key';\n\nconst { useLocation } = unlock( routerPrivateApis );\n\nexport default function useInitEditedEntityFromURL() {\n\tconst { params } = useLocation();\n\n\tconst { postType } = params;\n\n\tconst postId = normalizeRecordKey( params?.postId );\n\n\tconst { isRequestingSite, homepageId, url } = useSelect( ( select ) => {\n\t\tconst { getSite, getUnstableBase } = select( coreDataStore );\n\t\tconst siteData = getSite();\n\t\tconst base = getUnstableBase();\n\n\t\treturn {\n\t\t\tisRequestingSite: ! base,\n\t\t\thomepageId:\n\t\t\t\tsiteData?.show_on_front === 'page'\n\t\t\t\t\t? siteData.page_on_front\n\t\t\t\t\t: null,\n\t\t\turl: base?.home,\n\t\t};\n\t}, [] );\n\n\tconst {\n\t\tsetEditedEntity,\n\t\tsetTemplate,\n\t\tsetTemplatePart,\n\t\tsetPage,\n\t\tsetNavigationMenu,\n\t} = useDispatch( editSiteStore );\n\n\tuseEffect( () => {\n\t\tif ( postType && postId ) {\n\t\t\tswitch ( postType ) {\n\t\t\t\tcase 'wp_template':\n\t\t\t\t\tsetTemplate( postId );\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'wp_template_part':\n\t\t\t\t\tsetTemplatePart( postId );\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'wp_navigation':\n\t\t\t\t\tsetNavigationMenu( postId );\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'wp_block':\n\t\t\t\t\tsetEditedEntity( postType, postId );\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tsetPage( {\n\t\t\t\t\t\tcontext: { postType, postId },\n\t\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\t// In all other cases, we need to set the home page in the site editor view.\n\t\tif ( homepageId ) {\n\t\t\tsetPage( {\n\t\t\t\tcontext: { postType: 'page', postId: Number( homepageId ) },\n\t\t\t} );\n\t\t} else if ( ! isRequestingSite ) {\n\t\t\tsetPage( {\n\t\t\t\tpath: url,\n\t\t\t} );\n\t\t}\n\t}, [\n\t\turl,\n\t\tpostId,\n\t\tpostType,\n\t\thomepageId,\n\t\tisRequestingSite,\n\t\tsetEditedEntity,\n\t\tsetPage,\n\t\tsetTemplate,\n\t\tsetTemplatePart,\n\t\tsetNavigationMenu,\n\t] );\n}\n"]}
|
|
@@ -67,7 +67,7 @@ function useSyncCanvasModeWithURL() {
|
|
|
67
67
|
(0, _element.useEffect)(() => {
|
|
68
68
|
currentCanvasInUrl.current = canvasInUrl;
|
|
69
69
|
|
|
70
|
-
if (canvasInUrl
|
|
70
|
+
if (canvasInUrl !== 'edit' && currentCanvasMode.current !== 'view') {
|
|
71
71
|
setCanvasMode('view');
|
|
72
72
|
} else if (canvasInUrl === 'edit' && currentCanvasMode.current !== 'edit') {
|
|
73
73
|
setCanvasMode('edit');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js"],"names":["useLocation","useHistory","routerPrivateApis","useSyncCanvasModeWithURL","history","params","canvasMode","select","editSiteStore","getCanvasMode","setCanvasMode","currentCanvasMode","canvas","canvasInUrl","currentCanvasInUrl","currentUrlParams","current","push","undefined"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AAXA;AACA;AACA;;AAKA;AACA;AACA;AAIA,MAAM;AAAEA,EAAAA,WAAF;AAAeC,EAAAA;AAAf,IAA8B,wBAAQC,mBAAR,CAApC;;AAEe,SAASC,wBAAT,GAAoC;AAClD,QAAMC,OAAO,GAAGH,UAAU,EAA1B;AACA,QAAM;AAAEI,IAAAA;AAAF,MAAaL,WAAW,EAA9B;AACA,QAAMM,UAAU,GAAG,qBAChBC,MAAF,IAAc,wBAAQA,MAAM,CAAEC,YAAF,CAAd,EAAkCC,aAAlC,EADI,EAElB,EAFkB,CAAnB;AAIA,QAAM;AAAEC,IAAAA;AAAF,MAAoB,wBAAQ,uBAAaF,YAAb,CAAR,CAA1B;AACA,QAAMG,iBAAiB,GAAG,qBAAQL,UAAR,CAA1B;AACA,QAAM;AAAEM,IAAAA,MAAM,EAAEC;AAAV,MAA0BR,MAAhC;AACA,QAAMS,kBAAkB,GAAG,qBAAQD,WAAR,CAA3B;AACA,QAAME,gBAAgB,GAAG,qBAAQV,MAAR,CAAzB;AACA,0BAAW,MAAM;AAChBU,IAAAA,gBAAgB,CAACC,OAAjB,GAA2BX,MAA3B;AACA,GAFD,EAEG,CAAEA,MAAF,CAFH;AAIA,0BAAW,MAAM;AAChBM,IAAAA,iBAAiB,CAACK,OAAlB,GAA4BV,UAA5B;;AACA,QAAKA,UAAU,KAAK,MAApB,EAA6B;AAC5B;AACA;;AAED,QACCA,UAAU,KAAK,MAAf,IACAQ,kBAAkB,CAACE,OAAnB,KAA+BV,UAFhC,EAGE;AACDF,MAAAA,OAAO,CAACa,IAAR,CAAc,EACb,GAAGF,gBAAgB,CAACC,OADP;AAEbJ,QAAAA,MAAM,EAAE;AAFK,OAAd;AAIA;;AAED,QACCN,UAAU,KAAK,MAAf,IACAQ,kBAAkB,CAACE,OAAnB,KAA+BE,SAFhC,EAGE;AACDd,MAAAA,OAAO,CAACa,IAAR,CAAc,EACb,GAAGF,gBAAgB,CAACC,OADP;AAEbJ,QAAAA,MAAM,EAAEM;AAFK,OAAd;AAIA;AACD,GAzBD,EAyBG,CAAEZ,UAAF,EAAcF,OAAd,CAzBH;AA2BA,0BAAW,MAAM;AAChBU,IAAAA,kBAAkB,CAACE,OAAnB,GAA6BH,WAA7B;;AACA,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js"],"names":["useLocation","useHistory","routerPrivateApis","useSyncCanvasModeWithURL","history","params","canvasMode","select","editSiteStore","getCanvasMode","setCanvasMode","currentCanvasMode","canvas","canvasInUrl","currentCanvasInUrl","currentUrlParams","current","push","undefined"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AAXA;AACA;AACA;;AAKA;AACA;AACA;AAIA,MAAM;AAAEA,EAAAA,WAAF;AAAeC,EAAAA;AAAf,IAA8B,wBAAQC,mBAAR,CAApC;;AAEe,SAASC,wBAAT,GAAoC;AAClD,QAAMC,OAAO,GAAGH,UAAU,EAA1B;AACA,QAAM;AAAEI,IAAAA;AAAF,MAAaL,WAAW,EAA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ACrEN,MAAAA,aAAa,CAAE,MAAF,CAAb;AACA,KAFD,MAEO,IACNG,WAAW,KAAK,MAAhB,IACAF,iBAAiB,CAACK,OAAlB,KAA8B,MAFxB,EAGL;AACDN,MAAAA,aAAa,CAAE,MAAF,CAAb;AACA;AACD,GAVD,EAUG,CAAEG,WAAF,EAAeH,aAAf,CAVH;AAWA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { useLocation, useHistory } = unlock( routerPrivateApis );\n\nexport default function useSyncCanvasModeWithURL() {\n\tconst history = useHistory();\n\tconst { params } = useLocation();\n\tconst canvasMode = useSelect(\n\t\t( select ) => unlock( select( editSiteStore ) ).getCanvasMode(),\n\t\t[]\n\t);\n\tconst { setCanvasMode } = unlock( useDispatch( editSiteStore ) );\n\tconst currentCanvasMode = useRef( canvasMode );\n\tconst { canvas: canvasInUrl } = params;\n\tconst currentCanvasInUrl = useRef( canvasInUrl );\n\tconst currentUrlParams = useRef( params );\n\tuseEffect( () => {\n\t\tcurrentUrlParams.current = params;\n\t}, [ params ] );\n\n\tuseEffect( () => {\n\t\tcurrentCanvasMode.current = canvasMode;\n\t\tif ( canvasMode === 'init' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\tcanvasMode === 'edit' &&\n\t\t\tcurrentCanvasInUrl.current !== canvasMode\n\t\t) {\n\t\t\thistory.push( {\n\t\t\t\t...currentUrlParams.current,\n\t\t\t\tcanvas: 'edit',\n\t\t\t} );\n\t\t}\n\n\t\tif (\n\t\t\tcanvasMode === 'view' &&\n\t\t\tcurrentCanvasInUrl.current !== undefined\n\t\t) {\n\t\t\thistory.push( {\n\t\t\t\t...currentUrlParams.current,\n\t\t\t\tcanvas: undefined,\n\t\t\t} );\n\t\t}\n\t}, [ canvasMode, history ] );\n\n\tuseEffect( () => {\n\t\tcurrentCanvasInUrl.current = canvasInUrl;\n\t\tif ( canvasInUrl !== 'edit' && currentCanvasMode.current !== 'view' ) {\n\t\t\tsetCanvasMode( 'view' );\n\t\t} else if (\n\t\t\tcanvasInUrl === 'edit' &&\n\t\t\tcurrentCanvasMode.current !== 'edit'\n\t\t) {\n\t\t\tsetCanvasMode( 'edit' );\n\t\t}\n\t}, [ canvasInUrl, setCanvasMode ] );\n}\n"]}
|
|
@@ -48,6 +48,12 @@ function getPathFromURL(urlParams) {
|
|
|
48
48
|
return path;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
function isSubset(subset, superset) {
|
|
52
|
+
return Object.entries(subset).every(([key, value]) => {
|
|
53
|
+
return superset[key] === value;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
51
57
|
function useSyncPathWithURL() {
|
|
52
58
|
const history = useHistory();
|
|
53
59
|
const {
|
|
@@ -58,8 +64,6 @@ function useSyncPathWithURL() {
|
|
|
58
64
|
params: navigatorParams,
|
|
59
65
|
goTo
|
|
60
66
|
} = (0, _components.__experimentalUseNavigator)();
|
|
61
|
-
const currentUrlParams = (0, _element.useRef)(urlParams);
|
|
62
|
-
const currentPath = (0, _element.useRef)(navigatorLocation.path);
|
|
63
67
|
const isMounting = (0, _element.useRef)(true);
|
|
64
68
|
(0, _element.useEffect)(() => {
|
|
65
69
|
// The navigatorParams are only initially filled properly when the
|
|
@@ -70,16 +74,13 @@ function useSyncPathWithURL() {
|
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
function updateUrlParams(newUrlParams) {
|
|
73
|
-
if (
|
|
74
|
-
return currentUrlParams.current[key] === value;
|
|
75
|
-
})) {
|
|
77
|
+
if (isSubset(newUrlParams, urlParams)) {
|
|
76
78
|
return;
|
|
77
79
|
}
|
|
78
80
|
|
|
79
|
-
const updatedParams = { ...
|
|
81
|
+
const updatedParams = { ...urlParams,
|
|
80
82
|
...newUrlParams
|
|
81
83
|
};
|
|
82
|
-
currentUrlParams.current = updatedParams;
|
|
83
84
|
history.push(updatedParams);
|
|
84
85
|
}
|
|
85
86
|
|
|
@@ -111,15 +112,17 @@ function useSyncPathWithURL() {
|
|
|
111
112
|
path: navigatorLocation.path === '/' ? undefined : navigatorLocation.path
|
|
112
113
|
});
|
|
113
114
|
}
|
|
114
|
-
},
|
|
115
|
+
}, // Trigger only when navigator changes to prevent infinite loops.
|
|
116
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
117
|
+
[navigatorLocation?.path, navigatorParams]);
|
|
115
118
|
(0, _element.useEffect)(() => {
|
|
116
|
-
currentUrlParams.current = urlParams;
|
|
117
119
|
const path = getPathFromURL(urlParams);
|
|
118
120
|
|
|
119
|
-
if (
|
|
120
|
-
currentPath.current = path;
|
|
121
|
+
if (navigatorLocation.path !== path) {
|
|
121
122
|
goTo(path);
|
|
122
123
|
}
|
|
123
|
-
},
|
|
124
|
+
}, // Trigger only when URL changes to prevent infinite loops.
|
|
125
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
126
|
+
[urlParams]);
|
|
124
127
|
}
|
|
125
128
|
//# sourceMappingURL=use-sync-path-with-url.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-sync-path-with-url.js"],"names":["useLocation","useHistory","routerPrivateApis","getPathFromURL","urlParams","path","postType","postId","encodeURIComponent","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-sync-path-with-url.js"],"names":["useLocation","useHistory","routerPrivateApis","getPathFromURL","urlParams","path","postType","postId","encodeURIComponent","isSubset","subset","superset","Object","entries","every","key","value","useSyncPathWithURL","history","params","location","navigatorLocation","navigatorParams","goTo","isMounting","current","updateUrlParams","newUrlParams","updatedParams","push","undefined","startsWith","canvas","categoryType","categoryId"],"mappings":";;;;;;;;AAGA;;AACA;;AACA;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AA,eAAe,CAAE;AAChBpB,QAAAA,QAAQ,EAAEwB,SADM;AAEhBvB,QAAAA,MAAM,EAAEuB,SAFQ;AAGhBG,QAAAA,YAAY,EAAEH,SAHE;AAIhBI,QAAAA,UAAU,EAAEJ,SAJI;AAKhBzB,QAAAA,IAAI,EACHgB,iBAAiB,CAAChB,IAAlB,KAA2B,GAA3B,GACGyB,SADH,GAEGT,iBAAiB,CAAChB;AARN,OAAF,CAAf;AAUA;AACD,GAtDF,EAuDC;AACA;AACA,GAAEgB,iBAAiB,EAAEhB,IAArB,EAA2BiB,eAA3B,CAzDD;AA4DA,0BACC,MAAM;AACL,UAAMjB,IAAI,GAAGF,cAAc,CAAEC,SAAF,CAA3B;;AACA,QAAKiB,iBAAiB,CAAChB,IAAlB,KAA2BA,IAAhC,EAAuC;AACtCkB,MAAAA,IAAI,CAAElB,IAAF,CAAJ;AACA;AACD,GANF,EAOC;AACA;AACA,GAAED,SAAF,CATD;AAWA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalUseNavigator as useNavigator } from '@wordpress/components';\nimport { useEffect, useRef } from '@wordpress/element';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { useLocation, useHistory } = unlock( routerPrivateApis );\n\nexport function getPathFromURL( urlParams ) {\n\tlet path = urlParams?.path ?? '/';\n\n\t// Compute the navigator path based on the URL params.\n\tif ( urlParams?.postType && urlParams?.postId ) {\n\t\tswitch ( urlParams.postType ) {\n\t\t\tcase 'wp_block':\n\t\t\tcase 'wp_template':\n\t\t\tcase 'wp_template_part':\n\t\t\tcase 'page':\n\t\t\t\tpath = `/${ encodeURIComponent(\n\t\t\t\t\turlParams.postType\n\t\t\t\t) }/${ encodeURIComponent( urlParams.postId ) }`;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tpath = `/navigation/${ encodeURIComponent(\n\t\t\t\t\turlParams.postType\n\t\t\t\t) }/${ encodeURIComponent( urlParams.postId ) }`;\n\t\t}\n\t}\n\n\treturn path;\n}\n\nfunction isSubset( subset, superset ) {\n\treturn Object.entries( subset ).every( ( [ key, value ] ) => {\n\t\treturn superset[ key ] === value;\n\t} );\n}\n\nexport default function useSyncPathWithURL() {\n\tconst history = useHistory();\n\tconst { params: urlParams } = useLocation();\n\tconst {\n\t\tlocation: navigatorLocation,\n\t\tparams: navigatorParams,\n\t\tgoTo,\n\t} = useNavigator();\n\tconst isMounting = useRef( true );\n\n\tuseEffect(\n\t\t() => {\n\t\t\t// The navigatorParams are only initially filled properly when the\n\t\t\t// navigator screens mount. so we ignore the first synchronisation.\n\t\t\tif ( isMounting.current ) {\n\t\t\t\tisMounting.current = false;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfunction updateUrlParams( newUrlParams ) {\n\t\t\t\tif ( isSubset( newUrlParams, urlParams ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst updatedParams = {\n\t\t\t\t\t...urlParams,\n\t\t\t\t\t...newUrlParams,\n\t\t\t\t};\n\t\t\t\thistory.push( updatedParams );\n\t\t\t}\n\n\t\t\tif ( navigatorParams?.postType && navigatorParams?.postId ) {\n\t\t\t\tupdateUrlParams( {\n\t\t\t\t\tpostType: navigatorParams?.postType,\n\t\t\t\t\tpostId: navigatorParams?.postId,\n\t\t\t\t\tpath: undefined,\n\t\t\t\t} );\n\t\t\t} else if (\n\t\t\t\tnavigatorLocation.path.startsWith( '/page/' ) &&\n\t\t\t\tnavigatorParams?.postId\n\t\t\t) {\n\t\t\t\tupdateUrlParams( {\n\t\t\t\t\tpostType: 'page',\n\t\t\t\t\tpostId: navigatorParams?.postId,\n\t\t\t\t\tpath: undefined,\n\t\t\t\t} );\n\t\t\t} else if ( navigatorLocation.path === '/patterns' ) {\n\t\t\t\tupdateUrlParams( {\n\t\t\t\t\tpostType: undefined,\n\t\t\t\t\tpostId: undefined,\n\t\t\t\t\tcanvas: undefined,\n\t\t\t\t\tpath: navigatorLocation.path,\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tupdateUrlParams( {\n\t\t\t\t\tpostType: undefined,\n\t\t\t\t\tpostId: undefined,\n\t\t\t\t\tcategoryType: undefined,\n\t\t\t\t\tcategoryId: undefined,\n\t\t\t\t\tpath:\n\t\t\t\t\t\tnavigatorLocation.path === '/'\n\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t: navigatorLocation.path,\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t// Trigger only when navigator changes to prevent infinite loops.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[ navigatorLocation?.path, navigatorParams ]\n\t);\n\n\tuseEffect(\n\t\t() => {\n\t\t\tconst path = getPathFromURL( urlParams );\n\t\t\tif ( navigatorLocation.path !== path ) {\n\t\t\t\tgoTo( path );\n\t\t\t}\n\t\t},\n\t\t// Trigger only when URL changes to prevent infinite loops.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[ urlParams ]\n\t);\n}\n"]}
|
|
@@ -21,6 +21,8 @@ var _icons = require("@wordpress/icons");
|
|
|
21
21
|
|
|
22
22
|
var _notices = require("@wordpress/notices");
|
|
23
23
|
|
|
24
|
+
var _htmlEntities = require("@wordpress/html-entities");
|
|
25
|
+
|
|
24
26
|
var _store = require("../../store");
|
|
25
27
|
|
|
26
28
|
var _isTemplateRemovable = _interopRequireDefault(require("../../utils/is-template-removable"));
|
|
@@ -70,7 +72,7 @@ function TemplateActions({
|
|
|
70
72
|
await saveEditedEntityRecord('postType', template.type, template.id);
|
|
71
73
|
createSuccessNotice((0, _i18n.sprintf)(
|
|
72
74
|
/* translators: The template/part's name. */
|
|
73
|
-
(0, _i18n.__)('"%s" reverted.'), template.title.rendered), {
|
|
75
|
+
(0, _i18n.__)('"%s" reverted.'), (0, _htmlEntities.decodeEntities)(template.title.rendered)), {
|
|
74
76
|
type: 'snackbar',
|
|
75
77
|
id: 'edit-site-template-reverted'
|
|
76
78
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/template-actions/index.js"],"names":["TemplateActions","postType","postId","className","toggleProps","onRemove","template","select","coreStore","getEntityRecord","removeTemplate","revertTemplate","editSiteStore","saveEditedEntityRecord","createSuccessNotice","createErrorNotice","noticesStore","isRemovable","isRevertable","revertAndSaveTemplate","allowUndo","type","id","title","rendered","error","errorMessage","message","code","moreVertical","onClose","DeleteMenuItem","isTemplate","isModalOpen","setIsModalOpen"],"mappings":";;;;;;;;;AAKA;;AAFA;;AACA;;AAEA;;AACA;;AAMA;;AACA;;AAKA;;AACA;;AACA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/template-actions/index.js"],"names":["TemplateActions","postType","postId","className","toggleProps","onRemove","template","select","coreStore","getEntityRecord","removeTemplate","revertTemplate","editSiteStore","saveEditedEntityRecord","createSuccessNotice","createErrorNotice","noticesStore","isRemovable","isRevertable","revertAndSaveTemplate","allowUndo","type","id","title","rendered","error","errorMessage","message","code","moreVertical","onClose","DeleteMenuItem","isTemplate","isModalOpen","setIsModalOpen"],"mappings":";;;;;;;;;AAKA;;AAFA;;AACA;;AAEA;;AACA;;AAMA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAvBA;AACA;AACA;;AAeA;AACA;AACA;AAMe,SAASA,eAAT,CAA0B;AACxCC,EAAAA,QADwC;AAExCC,EAAAA,MAFwC;AAGxCC,EAAAA,SAHwC;AAIxCC,EAAAA,WAJwC;AAKxCC,EAAAA;AALwC,CAA1B,EAMX;AACH,QAAMC,QAAQ,GAAG,qBACdC,MAAF,IACCA,MAAM,CAAEC,eAAF,CAAN,CAAoBC,eAApB,CAAqC,UAArC,EAAiDR,QAAjD,EAA2DC,MAA3D,CAFe,EAGhB,CAAED,QAAF,EAAYC,MAAZ,CAHgB,CAAjB;AAKA,QAAM;AAAEQ,IAAAA,cAAF;AAAkBC,IAAAA;AAAlB,MA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AAAA;AAAF,GAAF,KACD,4BAAC,qBAAD,QACGb,WAAW,IACZ,qDACC,4BAAC,uBAAD;AACC,IAAA,QAAQ,EAAGX,QADZ;AAEC,IAAA,OAAO,EAAGwB;AAFX,IADD,EAKC,4BAAC,cAAD;AACC,IAAA,QAAQ,EAAG,MAAM;AAChBpB,MAAAA,cAAc,CAAEJ,QAAF,CAAd;AACAD,MAAAA,QAAQ;AACRyB,MAAAA,OAAO;AACP,KALF;AAMC,IAAA,UAAU,EAAGxB,QAAQ,CAACe,IAAT,KAAkB;AANhC,IALD,CAFF,EAiBGH,YAAY,IACb,4BAAC,oBAAD;AACC,IAAA,IAAI,EAAG,cACN,4CADM,CADR;AAIC,IAAA,OAAO,EAAG,MAAM;AACfC,MAAAA,qBAAqB;AACrBW,MAAAA,OAAO;AACP;AAPF,KASG,cAAI,sBAAJ,CATH,CAlBF,CAPF,CADD;AA0CA;;AAED,SAASC,cAAT,CAAyB;AAAE1B,EAAAA,QAAF;AAAY2B,EAAAA;AAAZ,CAAzB,EAAoD;AACnD,QAAM,CAAEC,WAAF,EAAeC,cAAf,IAAkC,uBAAU,KAAV,CAAxC;AACA,SACC,qDACC,4BAAC,oBAAD;AACC,IAAA,aAAa,MADd;AAEC,IAAA,UAAU,MAFX;AAGC,IAAA,OAAO,EAAG,MAAMA,cAAc,CAAE,IAAF;AAH/B,KAKG,cAAI,QAAJ,CALH,CADD,EAQC,4BAAC,uCAAD;AACC,IAAA,MAAM,EAAGD,WADV;AAEC,IAAA,SAAS,EAAG5B,QAFb;AAGC,IAAA,QAAQ,EAAG,MAAM6B,cAAc,CAAE,KAAF,CAHhC;AAIC,IAAA,iBAAiB,EAAG,cAAI,QAAJ;AAJrB,KAMGF,UAAU,GACT,cAAI,gDAAJ,CADS,GAET,cACA,qDADA,CARJ,CARD,CADD;AAuBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { moreVertical } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport isTemplateRemovable from '../../utils/is-template-removable';\nimport isTemplateRevertable from '../../utils/is-template-revertable';\nimport RenameMenuItem from './rename-menu-item';\n\nexport default function TemplateActions( {\n\tpostType,\n\tpostId,\n\tclassName,\n\ttoggleProps,\n\tonRemove,\n} ) {\n\tconst template = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecord( 'postType', postType, postId ),\n\t\t[ postType, postId ]\n\t);\n\tconst { removeTemplate, revertTemplate } = useDispatch( editSiteStore );\n\tconst { saveEditedEntityRecord } = useDispatch( coreStore );\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst isRemovable = isTemplateRemovable( template );\n\tconst isRevertable = isTemplateRevertable( template );\n\n\tif ( ! isRemovable && ! isRevertable ) {\n\t\treturn null;\n\t}\n\n\tasync function revertAndSaveTemplate() {\n\t\ttry {\n\t\t\tawait revertTemplate( template, { allowUndo: false } );\n\t\t\tawait saveEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\ttemplate.type,\n\t\t\t\ttemplate.id\n\t\t\t);\n\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: The template/part's name. */\n\t\t\t\t\t__( '\"%s\" reverted.' ),\n\t\t\t\t\tdecodeEntities( template.title.rendered )\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tid: 'edit-site-template-reverted',\n\t\t\t\t}\n\t\t\t);\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while reverting the entity.' );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t}\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\ticon={ moreVertical }\n\t\t\tlabel={ __( 'Actions' ) }\n\t\t\tclassName={ className }\n\t\t\ttoggleProps={ toggleProps }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<MenuGroup>\n\t\t\t\t\t{ isRemovable && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<RenameMenuItem\n\t\t\t\t\t\t\t\ttemplate={ template }\n\t\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<DeleteMenuItem\n\t\t\t\t\t\t\t\tonRemove={ () => {\n\t\t\t\t\t\t\t\t\tremoveTemplate( template );\n\t\t\t\t\t\t\t\t\tonRemove?.();\n\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tisTemplate={ template.type === 'wp_template' }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t\t{ isRevertable && (\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t'Use the template as supplied by the theme.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\trevertAndSaveTemplate();\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Clear customizations' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t) }\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n\nfunction DeleteMenuItem( { onRemove, isTemplate } ) {\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\tisDestructive\n\t\t\t\tisTertiary\n\t\t\t\tonClick={ () => setIsModalOpen( true ) }\n\t\t\t>\n\t\t\t\t{ __( 'Delete' ) }\n\t\t\t</MenuItem>\n\t\t\t<ConfirmDialog\n\t\t\t\tisOpen={ isModalOpen }\n\t\t\t\tonConfirm={ onRemove }\n\t\t\t\tonCancel={ () => setIsModalOpen( false ) }\n\t\t\t\tconfirmButtonText={ __( 'Delete' ) }\n\t\t\t>\n\t\t\t\t{ isTemplate\n\t\t\t\t\t? __( 'Are you sure you want to delete this template?' )\n\t\t\t\t\t: __(\n\t\t\t\t\t\t\t'Are you sure you want to delete this template part?'\n\t\t\t\t\t ) }\n\t\t\t</ConfirmDialog>\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -17,6 +17,8 @@ var _coreData = require("@wordpress/core-data");
|
|
|
17
17
|
|
|
18
18
|
var _notices = require("@wordpress/notices");
|
|
19
19
|
|
|
20
|
+
var _htmlEntities = require("@wordpress/html-entities");
|
|
21
|
+
|
|
20
22
|
/**
|
|
21
23
|
* WordPress dependencies
|
|
22
24
|
*/
|
|
@@ -24,11 +26,12 @@ function RenameMenuItem({
|
|
|
24
26
|
template,
|
|
25
27
|
onClose
|
|
26
28
|
}) {
|
|
27
|
-
const
|
|
29
|
+
const title = (0, _htmlEntities.decodeEntities)(template.title.rendered);
|
|
30
|
+
const [editedTitle, setEditedTitle] = (0, _element.useState)(title);
|
|
28
31
|
const [isModalOpen, setIsModalOpen] = (0, _element.useState)(false);
|
|
29
32
|
const {
|
|
30
33
|
editEntityRecord,
|
|
31
|
-
|
|
34
|
+
__experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits
|
|
32
35
|
} = (0, _data.useDispatch)(_coreData.store);
|
|
33
36
|
const {
|
|
34
37
|
createSuccessNotice,
|
|
@@ -44,14 +47,15 @@ function RenameMenuItem({
|
|
|
44
47
|
|
|
45
48
|
try {
|
|
46
49
|
await editEntityRecord('postType', template.type, template.id, {
|
|
47
|
-
title
|
|
50
|
+
title: editedTitle
|
|
48
51
|
}); // Update state before saving rerenders the list.
|
|
49
52
|
|
|
50
|
-
|
|
53
|
+
setEditedTitle('');
|
|
51
54
|
setIsModalOpen(false);
|
|
52
55
|
onClose(); // Persist edited entity.
|
|
53
56
|
|
|
54
|
-
await
|
|
57
|
+
await saveSpecifiedEntityEdits('postType', template.type, template.id, ['title'], // Only save title to avoid persisting other edits.
|
|
58
|
+
{
|
|
55
59
|
throwOnError: true
|
|
56
60
|
});
|
|
57
61
|
createSuccessNotice((0, _i18n.__)('Entity renamed.'), {
|
|
@@ -68,7 +72,7 @@ function RenameMenuItem({
|
|
|
68
72
|
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.MenuItem, {
|
|
69
73
|
onClick: () => {
|
|
70
74
|
setIsModalOpen(true);
|
|
71
|
-
|
|
75
|
+
setEditedTitle(title);
|
|
72
76
|
}
|
|
73
77
|
}, (0, _i18n.__)('Rename')), isModalOpen && (0, _element.createElement)(_components.Modal, {
|
|
74
78
|
title: (0, _i18n.__)('Rename'),
|
|
@@ -83,8 +87,8 @@ function RenameMenuItem({
|
|
|
83
87
|
}, (0, _element.createElement)(_components.TextControl, {
|
|
84
88
|
__nextHasNoMarginBottom: true,
|
|
85
89
|
label: (0, _i18n.__)('Name'),
|
|
86
|
-
value:
|
|
87
|
-
onChange:
|
|
90
|
+
value: editedTitle,
|
|
91
|
+
onChange: setEditedTitle,
|
|
88
92
|
required: true
|
|
89
93
|
}), (0, _element.createElement)(_components.__experimentalHStack, {
|
|
90
94
|
justify: "right"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/template-actions/rename-menu-item.js"],"names":["RenameMenuItem","template","onClose","title","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/template-actions/rename-menu-item.js"],"names":["RenameMenuItem","template","onClose","title","rendered","editedTitle","setEditedTitle","isModalOpen","setIsModalOpen","editEntityRecord","__experimentalSaveSpecifiedEntityEdits","saveSpecifiedEntityEdits","coreStore","createSuccessNotice","createErrorNotice","noticesStore","type","is_custom","onTemplateRename","event","preventDefault","id","throwOnError","error","errorMessage","message","code"],"mappings":";;;;;;;AAIA;;AADA;;AAEA;;AACA;;AAQA;;AACA;;AACA;;AAhBA;AACA;AACA;AAgBe,SAASA,cAAT,CAAyB;AAAEC,EAAAA,QAAF;AAAYC,EAAAA;AAAZ,CAAzB,EAAiD;AAC/D,QAAMC,KAAK,GAAG,kCAAgBF,QAAQ,CAACE,KAAT,CAAeC,QAA/B,CAAd;AACA,QAAM,CAAEC,WAAF,EAAeC,cAAf,IAAkC,uBAAUH,KAAV,CAAxC;AACA,QAAM,CAAEI,WAAF,EAAeC,cAAf,IAAkC,uBAAU,KAAV,CAAxC;AAEA,QAAM;AACLC,IAAAA,gBADK;AAELC,IAAAA,sCAAsC,EAAEC;AAFnC,MAGF,uBAAaC,eAAb,CAHJ;AAIA,QAAM;AAAEC,IAAAA,mBAAF;AAAuBC,IAAAA;AAAvB,MACL,uBAAaC,cAAb,CADD;;AAGA,MAAKd,QAAQ,CAACe,IAAT,KAAkB,aAAlB,IAAmC,CAAEf,QAAQ,CAACgB,SAAnD,EAA+D;AAC9D,WAAO,IAAP;AACA;;AAED,iBAAeC,gBAAf,CAAiCC,KAAjC,EAAyC;AACxCA,IAAAA,KAAK,CAACC,cAAN;;AAEA,QAAI;AACH,YAAMX,gBAAgB,CAAE,UAAF,EAAcR,QAAQ,CAACe,IAAvB,EAA6Bf,QAAQ,CAACoB,EAAtC,EAA0C;AAC/DlB,QAAAA,KAAK,EAAEE;AADwD,OAA1C,CAAtB,CADG,CAKH;;AACAC,MAAAA,cAAc,CAAE,EAAF,CAAd;AACAE,MAAAA,cAAc,CAAE,KAAF,CAAd;AACAN,MAAAA,OAAO,GARJ,CAUH;;AACA,YAAMS,wBAAwB,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AC,kBAAD;AACC,IAAA,OAAO,EAAC,UADT;AAEC,IAAA,OAAO,EAAG,MAAM;AACfE,MAAAA,cAAc,CAAE,KAAF,CAAd;AACA;AAJF,KAMG,cAAI,QAAJ,CANH,CADD,EAUC,4BAAC,kBAAD;AAAQ,IAAA,OAAO,EAAC,SAAhB;AAA0B,IAAA,IAAI,EAAC;AAA/B,KACG,cAAI,MAAJ,CADH,CAVD,CATD,CADD,CAPD,CAVF,CADD;AAgDA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport {\n\tButton,\n\tMenuItem,\n\tModal,\n\tTextControl,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { decodeEntities } from '@wordpress/html-entities';\n\nexport default function RenameMenuItem( { template, onClose } ) {\n\tconst title = decodeEntities( template.title.rendered );\n\tconst [ editedTitle, setEditedTitle ] = useState( title );\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\n\tconst {\n\t\teditEntityRecord,\n\t\t__experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits,\n\t} = useDispatch( coreStore );\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tif ( template.type === 'wp_template' && ! template.is_custom ) {\n\t\treturn null;\n\t}\n\n\tasync function onTemplateRename( event ) {\n\t\tevent.preventDefault();\n\n\t\ttry {\n\t\t\tawait editEntityRecord( 'postType', template.type, template.id, {\n\t\t\t\ttitle: editedTitle,\n\t\t\t} );\n\n\t\t\t// Update state before saving rerenders the list.\n\t\t\tsetEditedTitle( '' );\n\t\t\tsetIsModalOpen( false );\n\t\t\tonClose();\n\n\t\t\t// Persist edited entity.\n\t\t\tawait saveSpecifiedEntityEdits(\n\t\t\t\t'postType',\n\t\t\t\ttemplate.type,\n\t\t\t\ttemplate.id,\n\t\t\t\t[ 'title' ], // Only save title to avoid persisting other edits.\n\t\t\t\t{\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tcreateSuccessNotice( __( 'Entity renamed.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while renaming the entity.' );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetIsModalOpen( true );\n\t\t\t\t\tsetEditedTitle( title );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ __( 'Rename' ) }\n\t\t\t</MenuItem>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Rename' ) }\n\t\t\t\t\tonRequestClose={ () => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t} }\n\t\t\t\t\toverlayClassName=\"edit-site-list__rename-modal\"\n\t\t\t\t>\n\t\t\t\t\t<form onSubmit={ onTemplateRename }>\n\t\t\t\t\t\t<VStack spacing=\"5\">\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\t\t\tvalue={ editedTitle }\n\t\t\t\t\t\t\t\tonChange={ setEditedTitle }\n\t\t\t\t\t\t\t\trequired\n\t\t\t\t\t\t\t/>\n\n\t\t\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t\t\t</Button>\n\n\t\t\t\t\t\t\t\t<Button variant=\"primary\" type=\"submit\">\n\t\t\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t</VStack>\n\t\t\t\t\t</form>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -15,6 +17,8 @@ var _htmlEntities = require("@wordpress/html-entities");
|
|
|
15
17
|
|
|
16
18
|
var _store = require("../../store");
|
|
17
19
|
|
|
20
|
+
var _normalizeRecordKey = _interopRequireDefault(require("../../utils/normalize-record-key"));
|
|
21
|
+
|
|
18
22
|
/**
|
|
19
23
|
* WordPress dependencies
|
|
20
24
|
*/
|
|
@@ -42,7 +46,8 @@ function useEditedEntityRecord(postType, postId) {
|
|
|
42
46
|
__experimentalGetTemplateInfo: getTemplateInfo
|
|
43
47
|
} = select(_editor.store);
|
|
44
48
|
const usedPostType = postType !== null && postType !== void 0 ? postType : getEditedPostType();
|
|
45
|
-
|
|
49
|
+
let usedPostId = postId !== null && postId !== void 0 ? postId : getEditedPostId();
|
|
50
|
+
usedPostId = (0, _normalizeRecordKey.default)(usedPostId, usedPostType);
|
|
46
51
|
|
|
47
52
|
const _record = getEditedEntityRecord('postType', usedPostType, usedPostId);
|
|
48
53
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/use-edited-entity-record/index.js"],"names":["useEditedEntityRecord","postType","postId","record","title","description","isLoaded","icon","select","getEditedPostType","getEditedPostId","editSiteStore","getEditedEntityRecord","hasFinishedResolution","coreStore","__experimentalGetTemplateInfo","getTemplateInfo","editorStore","usedPostType","usedPostId","_record","_isLoaded","templateInfo","getTitle","getDescription"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/use-edited-entity-record/index.js"],"names":["useEditedEntityRecord","postType","postId","record","title","description","isLoaded","icon","select","getEditedPostType","getEditedPostId","editSiteStore","getEditedEntityRecord","hasFinishedResolution","coreStore","__experimentalGetTemplateInfo","getTemplateInfo","editorStore","usedPostType","usedPostId","_record","_isLoaded","templateInfo","getTitle","getDescription"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAZA;AACA;AACA;;AAMA;AACA;AACA;AAIe,SAASA,qBAAT,CAAgCC,QAAhC,EAA0CC,MAA1C,EAAmD;AACjE,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA,KAAV;AAAiBC,IAAAA,WAAjB;AAA8BC,IAAAA,QAA9B;AAAwCC,IAAAA;AAAxC,MAAiD,qBACpDC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA,iBAAF;AAAqBC,MAAAA;AAArB,QACLF,MAAM,CAAEG,YAAF,CADP;AAEA,UAAM;AAAEC,MAAAA,qBAAF;AAAyBC,MAAAA;AAAzB,QACLL,MAAM,CAAEM,eAAF,CADP;AAEA,UAAM;AAAEC,MAAAA,6BAA6B,EAAEC;AAAjC,QACLR,MAAM,CAAES,aAAF,CADP;AAEA,UAAMC,YAAY,GAAGjB,QAAH,aAAGA,QAAH,cAAGA,QAAH,GAAeQ,iBAAiB,EAAlD;AAEA,QAAIU,UAAU,GAAGjB,MAAH,aAAGA,MAAH,cAAGA,MAAH,GAAaQ,eAAe,EAA1C;AAEAS,IAAAA,UAAU,GAAG,iCAAoBA,UAApB,EAAgCD,YAAhC,CAAb;;AAEA,UAAME,OAAO,GAAGR,qBAAqB,CACpC,UADoC,EAEpCM,YAFoC,EAGpCC,UAHoC,CAArC;;AAKA,UAAME,SAAS,GACdF,UAAU,IACVN,qBAAqB,CAAE,uBAAF,EAA2B,CAC/C,UAD+C,EAE/CK,YAF+C,EAG/CC,UAH+C,CAA3B,CAFtB;;AAOA,UAAMG,YAAY,GAAGN,eAAe,CAAEI,OAAF,CAApC;AAEA,WAAO;AACNjB,MAAAA,MAAM,EAAEiB,OADF;AAENhB,MAAAA,KAAK,EAAEkB,YAAY,CAAClB,KAFd;AAGNC,MAAAA,WAAW,EAAEiB,YAAY,CAACjB,WAHpB;AAINC,MAAAA,QAAQ,EAAEe,SAJJ;AAKNd,MAAAA,IAAI,EAAEe,YAAY,CAACf;AALb,KAAP;AAOA,GAnCqD,EAoCtD,CAAEN,QAAF,EAAYC,MAAZ,CApCsD,CAAvD;AAuCA,SAAO;AACNI,IAAAA,QADM;AAENC,IAAAA,IAFM;AAGNJ,IAAAA,MAHM;AAINoB,IAAAA,QAAQ,EAAE,MAAQnB,KAAK,GAAG,kCAAgBA,KAAhB,CAAH,GAA6B,IAJ9C;AAKNoB,IAAAA,cAAc,EAAE,MACfnB,WAAW,GAAG,kCAAgBA,WAAhB,CAAH,GAAmC;AANzC,GAAP;AAQA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport normalizeRecordKey from '../../utils/normalize-record-key';\n\nexport default function useEditedEntityRecord( postType, postId ) {\n\tconst { record, title, description, isLoaded, icon } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedPostType, getEditedPostId } =\n\t\t\t\tselect( editSiteStore );\n\t\t\tconst { getEditedEntityRecord, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst { __experimentalGetTemplateInfo: getTemplateInfo } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst usedPostType = postType ?? getEditedPostType();\n\n\t\t\tlet usedPostId = postId ?? getEditedPostId();\n\n\t\t\tusedPostId = normalizeRecordKey( usedPostId, usedPostType );\n\n\t\t\tconst _record = getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tusedPostType,\n\t\t\t\tusedPostId\n\t\t\t);\n\t\t\tconst _isLoaded =\n\t\t\t\tusedPostId &&\n\t\t\t\thasFinishedResolution( 'getEditedEntityRecord', [\n\t\t\t\t\t'postType',\n\t\t\t\t\tusedPostType,\n\t\t\t\t\tusedPostId,\n\t\t\t\t] );\n\t\t\tconst templateInfo = getTemplateInfo( _record );\n\n\t\t\treturn {\n\t\t\t\trecord: _record,\n\t\t\t\ttitle: templateInfo.title,\n\t\t\t\tdescription: templateInfo.description,\n\t\t\t\tisLoaded: _isLoaded,\n\t\t\t\ticon: templateInfo.icon,\n\t\t\t};\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\treturn {\n\t\tisLoaded,\n\t\ticon,\n\t\trecord,\n\t\tgetTitle: () => ( title ? decodeEntities( title ) : null ),\n\t\tgetDescription: () =>\n\t\t\tdescription ? decodeEntities( description ) : null,\n\t};\n}\n"]}
|