@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
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { get, set } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -18,6 +13,7 @@ import { __, sprintf } from '@wordpress/i18n';
|
|
|
18
13
|
import {
|
|
19
14
|
__EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY,
|
|
20
15
|
getBlockType,
|
|
16
|
+
hasBlockSupport,
|
|
21
17
|
} from '@wordpress/blocks';
|
|
22
18
|
import { useContext, useMemo, useCallback } from '@wordpress/element';
|
|
23
19
|
import { useDispatch } from '@wordpress/data';
|
|
@@ -29,9 +25,12 @@ import { store as noticesStore } from '@wordpress/notices';
|
|
|
29
25
|
import { useSupportedStyles } from '../../components/global-styles/hooks';
|
|
30
26
|
import { unlock } from '../../lock-unlock';
|
|
31
27
|
|
|
32
|
-
const {
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
const {
|
|
29
|
+
GlobalStylesContext,
|
|
30
|
+
useBlockEditingMode,
|
|
31
|
+
__experimentalUseGlobalBehaviors: useGlobalBehaviors,
|
|
32
|
+
__experimentalUseHasBehaviorsPanel: useHasBehaviorsPanel,
|
|
33
|
+
} = unlock( blockEditorPrivateApis );
|
|
35
34
|
|
|
36
35
|
// TODO: Temporary duplication of constant in @wordpress/block-editor. Can be
|
|
37
36
|
// removed by moving PushChangesToGlobalStylesControl to
|
|
@@ -93,6 +92,16 @@ const STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {
|
|
|
93
92
|
'typography.fontFamily': 'fontFamily',
|
|
94
93
|
};
|
|
95
94
|
|
|
95
|
+
const SUPPORTED_STYLES = [ 'border', 'color', 'spacing', 'typography' ];
|
|
96
|
+
|
|
97
|
+
const getValueFromObjectPath = ( object, path ) => {
|
|
98
|
+
let value = object;
|
|
99
|
+
path.forEach( ( fieldName ) => {
|
|
100
|
+
value = value?.[ fieldName ];
|
|
101
|
+
} );
|
|
102
|
+
return value;
|
|
103
|
+
};
|
|
104
|
+
|
|
96
105
|
function useChangesToPush( name, attributes ) {
|
|
97
106
|
const supports = useSupportedStyles( name );
|
|
98
107
|
|
|
@@ -112,13 +121,53 @@ function useChangesToPush( name, attributes ) {
|
|
|
112
121
|
];
|
|
113
122
|
const value = presetAttributeValue
|
|
114
123
|
? `var:preset|${ STYLE_PATH_TO_CSS_VAR_INFIX[ presetAttributeKey ] }|${ presetAttributeValue }`
|
|
115
|
-
:
|
|
124
|
+
: getValueFromObjectPath( attributes.style, path );
|
|
116
125
|
return value ? [ { path, value } ] : [];
|
|
117
126
|
} ),
|
|
118
|
-
[ supports,
|
|
127
|
+
[ supports, attributes ]
|
|
119
128
|
);
|
|
120
129
|
}
|
|
121
130
|
|
|
131
|
+
/**
|
|
132
|
+
* Sets the value at path of object.
|
|
133
|
+
* If a portion of path doesn’t exist, it’s created.
|
|
134
|
+
* Arrays are created for missing index properties while objects are created
|
|
135
|
+
* for all other missing properties.
|
|
136
|
+
*
|
|
137
|
+
* This function intentionally mutates the input object.
|
|
138
|
+
*
|
|
139
|
+
* Inspired by _.set().
|
|
140
|
+
*
|
|
141
|
+
* @see https://lodash.com/docs/4.17.15#set
|
|
142
|
+
*
|
|
143
|
+
* @todo Needs to be deduplicated with its copy in `@wordpress/core-data`.
|
|
144
|
+
*
|
|
145
|
+
* @param {Object} object Object to modify
|
|
146
|
+
* @param {Array} path Path of the property to set.
|
|
147
|
+
* @param {*} value Value to set.
|
|
148
|
+
*/
|
|
149
|
+
function setNestedValue( object, path, value ) {
|
|
150
|
+
if ( ! object || typeof object !== 'object' ) {
|
|
151
|
+
return object;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
path.reduce( ( acc, key, idx ) => {
|
|
155
|
+
if ( acc[ key ] === undefined ) {
|
|
156
|
+
if ( Number.isInteger( path[ idx + 1 ] ) ) {
|
|
157
|
+
acc[ key ] = [];
|
|
158
|
+
} else {
|
|
159
|
+
acc[ key ] = {};
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if ( idx === path.length - 1 ) {
|
|
163
|
+
acc[ key ] = value;
|
|
164
|
+
}
|
|
165
|
+
return acc[ key ];
|
|
166
|
+
}, object );
|
|
167
|
+
|
|
168
|
+
return object;
|
|
169
|
+
}
|
|
170
|
+
|
|
122
171
|
function cloneDeep( object ) {
|
|
123
172
|
return ! object ? {} : JSON.parse( JSON.stringify( object ) );
|
|
124
173
|
}
|
|
@@ -130,6 +179,9 @@ function PushChangesToGlobalStylesControl( {
|
|
|
130
179
|
} ) {
|
|
131
180
|
const changes = useChangesToPush( name, attributes );
|
|
132
181
|
|
|
182
|
+
const hasBehaviorsPanel = useHasBehaviorsPanel( attributes, name, {
|
|
183
|
+
blockSupportOnly: true,
|
|
184
|
+
} );
|
|
133
185
|
const { user: userConfig, setUserConfig } =
|
|
134
186
|
useContext( GlobalStylesContext );
|
|
135
187
|
|
|
@@ -137,51 +189,86 @@ function PushChangesToGlobalStylesControl( {
|
|
|
137
189
|
useDispatch( blockEditorStore );
|
|
138
190
|
const { createSuccessNotice } = useDispatch( noticesStore );
|
|
139
191
|
|
|
192
|
+
const { inheritedBehaviors, setBehavior } = useGlobalBehaviors( name );
|
|
193
|
+
|
|
194
|
+
const userHasEditedBehaviors =
|
|
195
|
+
attributes.hasOwnProperty( 'behaviors' ) && hasBehaviorsPanel;
|
|
196
|
+
|
|
140
197
|
const pushChanges = useCallback( () => {
|
|
141
|
-
if ( changes.length === 0 ) {
|
|
198
|
+
if ( changes.length === 0 && ! userHasEditedBehaviors ) {
|
|
142
199
|
return;
|
|
143
200
|
}
|
|
201
|
+
if ( changes.length > 0 ) {
|
|
202
|
+
const { style: blockStyles } = attributes;
|
|
144
203
|
|
|
145
|
-
|
|
204
|
+
const newBlockStyles = cloneDeep( blockStyles );
|
|
205
|
+
const newUserConfig = cloneDeep( userConfig );
|
|
146
206
|
|
|
147
|
-
|
|
148
|
-
|
|
207
|
+
for ( const { path, value } of changes ) {
|
|
208
|
+
setNestedValue( newBlockStyles, path, undefined );
|
|
209
|
+
setNestedValue(
|
|
210
|
+
newUserConfig,
|
|
211
|
+
[ 'styles', 'blocks', name, ...path ],
|
|
212
|
+
value
|
|
213
|
+
);
|
|
214
|
+
}
|
|
149
215
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
216
|
+
// @wordpress/core-data doesn't support editing multiple entity types in
|
|
217
|
+
// a single undo level. So for now, we disable @wordpress/core-data undo
|
|
218
|
+
// tracking and implement our own Undo button in the snackbar
|
|
219
|
+
// notification.
|
|
220
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
221
|
+
setAttributes( { style: newBlockStyles } );
|
|
222
|
+
setUserConfig( () => newUserConfig, { undoIgnore: true } );
|
|
223
|
+
createSuccessNotice(
|
|
224
|
+
sprintf(
|
|
225
|
+
// translators: %s: Title of the block e.g. 'Heading'.
|
|
226
|
+
__( '%s styles applied.' ),
|
|
227
|
+
getBlockType( name ).title
|
|
228
|
+
),
|
|
229
|
+
{
|
|
230
|
+
type: 'snackbar',
|
|
231
|
+
actions: [
|
|
232
|
+
{
|
|
233
|
+
label: __( 'Undo' ),
|
|
234
|
+
onClick() {
|
|
235
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
236
|
+
setAttributes( { style: blockStyles } );
|
|
237
|
+
setUserConfig( () => userConfig, {
|
|
238
|
+
undoIgnore: true,
|
|
239
|
+
} );
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
],
|
|
243
|
+
}
|
|
244
|
+
);
|
|
153
245
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
__unstableMarkNextChangeAsNotPersistent();
|
|
176
|
-
setAttributes( { style: blockStyles } );
|
|
177
|
-
setUserConfig( () => userConfig, {
|
|
178
|
-
undoIgnore: true,
|
|
179
|
-
} );
|
|
246
|
+
if ( userHasEditedBehaviors ) {
|
|
247
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
248
|
+
setBehavior( attributes.behaviors );
|
|
249
|
+
createSuccessNotice(
|
|
250
|
+
sprintf(
|
|
251
|
+
// translators: %s: Title of the block e.g. 'Heading'.
|
|
252
|
+
__( '%s behaviors applied.' ),
|
|
253
|
+
getBlockType( name ).title
|
|
254
|
+
),
|
|
255
|
+
{
|
|
256
|
+
type: 'snackbar',
|
|
257
|
+
actions: [
|
|
258
|
+
{
|
|
259
|
+
label: __( 'Undo' ),
|
|
260
|
+
onClick() {
|
|
261
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
262
|
+
setBehavior( inheritedBehaviors );
|
|
263
|
+
setUserConfig( () => userConfig, {
|
|
264
|
+
undoIgnore: true,
|
|
265
|
+
} );
|
|
266
|
+
},
|
|
180
267
|
},
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
268
|
+
],
|
|
269
|
+
}
|
|
270
|
+
);
|
|
271
|
+
}
|
|
185
272
|
}, [ changes, attributes, userConfig, name ] );
|
|
186
273
|
|
|
187
274
|
return (
|
|
@@ -190,7 +277,7 @@ function PushChangesToGlobalStylesControl( {
|
|
|
190
277
|
help={ sprintf(
|
|
191
278
|
// translators: %s: Title of the block e.g. 'Heading'.
|
|
192
279
|
__(
|
|
193
|
-
'Apply this block’s typography, spacing, dimensions,
|
|
280
|
+
'Apply this block’s typography, spacing, dimensions, color styles, and behaviors to all %s blocks.'
|
|
194
281
|
),
|
|
195
282
|
getBlockType( name ).title
|
|
196
283
|
) }
|
|
@@ -200,7 +287,7 @@ function PushChangesToGlobalStylesControl( {
|
|
|
200
287
|
</BaseControl.VisualLabel>
|
|
201
288
|
<Button
|
|
202
289
|
variant="primary"
|
|
203
|
-
disabled={ changes.length === 0 }
|
|
290
|
+
disabled={ changes.length === 0 && ! userHasEditedBehaviors }
|
|
204
291
|
onClick={ pushChanges }
|
|
205
292
|
>
|
|
206
293
|
{ __( 'Apply globally' ) }
|
|
@@ -212,10 +299,14 @@ function PushChangesToGlobalStylesControl( {
|
|
|
212
299
|
const withPushChangesToGlobalStyles = createHigherOrderComponent(
|
|
213
300
|
( BlockEdit ) => ( props ) => {
|
|
214
301
|
const blockEditingMode = useBlockEditingMode();
|
|
302
|
+
const supportsStyles = SUPPORTED_STYLES.some( ( feature ) =>
|
|
303
|
+
hasBlockSupport( props.name, feature )
|
|
304
|
+
);
|
|
305
|
+
|
|
215
306
|
return (
|
|
216
307
|
<>
|
|
217
308
|
<BlockEdit { ...props } />
|
|
218
|
-
{ blockEditingMode === 'default' && (
|
|
309
|
+
{ blockEditingMode === 'default' && supportsStyles && (
|
|
219
310
|
<InspectorAdvancedControls>
|
|
220
311
|
<PushChangesToGlobalStylesControl { ...props } />
|
|
221
312
|
</InspectorAdvancedControls>
|
|
@@ -11,21 +11,29 @@ import { store as preferencesStore } from '@wordpress/preferences';
|
|
|
11
11
|
*/
|
|
12
12
|
export const setCanvasMode =
|
|
13
13
|
( mode ) =>
|
|
14
|
-
( { registry, dispatch } ) => {
|
|
14
|
+
( { registry, dispatch, select } ) => {
|
|
15
15
|
registry.dispatch( blockEditorStore ).__unstableSetEditorMode( 'edit' );
|
|
16
16
|
dispatch( {
|
|
17
17
|
type: 'SET_CANVAS_MODE',
|
|
18
18
|
mode,
|
|
19
19
|
} );
|
|
20
20
|
// Check if the block list view should be open by default.
|
|
21
|
+
// If `distractionFree` mode is enabled, the block list view should not be open.
|
|
21
22
|
if (
|
|
22
23
|
mode === 'edit' &&
|
|
23
24
|
registry
|
|
24
25
|
.select( preferencesStore )
|
|
25
|
-
.get( 'core/edit-site', 'showListViewByDefault' )
|
|
26
|
+
.get( 'core/edit-site', 'showListViewByDefault' ) &&
|
|
27
|
+
! registry
|
|
28
|
+
.select( preferencesStore )
|
|
29
|
+
.get( 'core/edit-site', 'distractionFree' )
|
|
26
30
|
) {
|
|
27
31
|
dispatch.setIsListViewOpened( true );
|
|
28
32
|
}
|
|
33
|
+
// Switch focus away from editing the template when switching to view mode.
|
|
34
|
+
if ( mode === 'view' && select.isPage() ) {
|
|
35
|
+
dispatch.setHasPageContentFocus( true );
|
|
36
|
+
}
|
|
29
37
|
};
|
|
30
38
|
|
|
31
39
|
/**
|
package/src/style.scss
CHANGED
|
@@ -47,27 +47,20 @@
|
|
|
47
47
|
@import "./components/resizable-frame/style.scss";
|
|
48
48
|
@import "./hooks/push-changes-to-global-styles/style.scss";
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
body.js #wpadminbar {
|
|
51
51
|
display: none;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
body.js #wpbody {
|
|
55
55
|
padding-top: 0;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
html.wp-toolbar {
|
|
61
|
-
background: $white;
|
|
62
|
-
padding-top: 0;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
body.appearance_page_gutenberg-template-parts,
|
|
66
|
-
body.site-editor-php {
|
|
58
|
+
body.js.appearance_page_gutenberg-template-parts,
|
|
59
|
+
body.js.site-editor-php {
|
|
67
60
|
@include wp-admin-reset(".edit-site");
|
|
68
61
|
}
|
|
69
62
|
|
|
70
|
-
body.site-editor-php {
|
|
63
|
+
body.js.site-editor-php {
|
|
71
64
|
background: $gray-900;
|
|
72
65
|
}
|
|
73
66
|
|
|
@@ -91,6 +84,11 @@ body.site-editor-php {
|
|
|
91
84
|
top: 0;
|
|
92
85
|
}
|
|
93
86
|
|
|
87
|
+
.no-js & {
|
|
88
|
+
min-height: 0;
|
|
89
|
+
position: static;
|
|
90
|
+
}
|
|
91
|
+
|
|
94
92
|
.interface-interface-skeleton {
|
|
95
93
|
top: 0;
|
|
96
94
|
}
|
|
@@ -29,7 +29,7 @@ export function useActivateTheme() {
|
|
|
29
29
|
'themes.php?action=activate&stylesheet=' +
|
|
30
30
|
currentlyPreviewingTheme() +
|
|
31
31
|
'&_wpnonce=' +
|
|
32
|
-
window.
|
|
32
|
+
window.WP_BLOCK_THEME_ACTIVATE_NONCE;
|
|
33
33
|
await window.fetch( activationURL );
|
|
34
34
|
const { wp_theme_preview: themePreview, ...params } =
|
|
35
35
|
location.params;
|
|
@@ -6,12 +6,13 @@ import { useDebounce } from '@wordpress/compose';
|
|
|
6
6
|
|
|
7
7
|
export default function useDebouncedInput( defaultValue = '' ) {
|
|
8
8
|
const [ input, setInput ] = useState( defaultValue );
|
|
9
|
-
const [
|
|
10
|
-
|
|
9
|
+
const [ debouncedInput, setDebouncedState ] = useState( defaultValue );
|
|
10
|
+
|
|
11
|
+
const setDebouncedInput = useDebounce( setDebouncedState, 250 );
|
|
12
|
+
|
|
11
13
|
useEffect( () => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return [ input, setInput, debounced ];
|
|
14
|
+
setDebouncedInput( input );
|
|
15
|
+
}, [ input ] );
|
|
16
|
+
|
|
17
|
+
return [ input, setInput, debouncedInput ];
|
|
17
18
|
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = CodeEditorTextArea;
|
|
9
|
-
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
|
-
var _reactAutosizeTextarea = _interopRequireDefault(require("react-autosize-textarea"));
|
|
13
|
-
|
|
14
|
-
var _i18n = require("@wordpress/i18n");
|
|
15
|
-
|
|
16
|
-
var _compose = require("@wordpress/compose");
|
|
17
|
-
|
|
18
|
-
var _components = require("@wordpress/components");
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* External dependencies
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* WordPress dependencies
|
|
26
|
-
*/
|
|
27
|
-
function CodeEditorTextArea({
|
|
28
|
-
value,
|
|
29
|
-
onChange,
|
|
30
|
-
onInput
|
|
31
|
-
}) {
|
|
32
|
-
const [stateValue, setStateValue] = (0, _element.useState)(value);
|
|
33
|
-
const [isDirty, setIsDirty] = (0, _element.useState)(false);
|
|
34
|
-
const instanceId = (0, _compose.useInstanceId)(CodeEditorTextArea);
|
|
35
|
-
const valueRef = (0, _element.useRef)();
|
|
36
|
-
|
|
37
|
-
if (!isDirty && stateValue !== value) {
|
|
38
|
-
setStateValue(value);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Handles a textarea change event to notify the onChange prop callback and
|
|
42
|
-
* reflect the new value in the component's own state. This marks the start
|
|
43
|
-
* of the user's edits, if not already changed, preventing future props
|
|
44
|
-
* changes to value from replacing the rendered value. This is expected to
|
|
45
|
-
* be followed by a reset to dirty state via `stopEditing`.
|
|
46
|
-
*
|
|
47
|
-
* @see stopEditing
|
|
48
|
-
*
|
|
49
|
-
* @param {Event} event Change event.
|
|
50
|
-
*/
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const onChangeHandler = event => {
|
|
54
|
-
const newValue = event.target.value;
|
|
55
|
-
onInput(newValue);
|
|
56
|
-
setStateValue(newValue);
|
|
57
|
-
setIsDirty(true);
|
|
58
|
-
valueRef.current = newValue;
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Function called when the user has completed their edits, responsible for
|
|
62
|
-
* ensuring that changes, if made, are surfaced to the onPersist prop
|
|
63
|
-
* callback and resetting dirty state.
|
|
64
|
-
*/
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const stopEditing = () => {
|
|
68
|
-
if (isDirty) {
|
|
69
|
-
onChange(stateValue);
|
|
70
|
-
setIsDirty(false);
|
|
71
|
-
}
|
|
72
|
-
}; // Ensure changes aren't lost when component unmounts.
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
(0, _element.useEffect)(() => {
|
|
76
|
-
return () => {
|
|
77
|
-
if (valueRef.current) {
|
|
78
|
-
onChange(valueRef.current);
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
}, []);
|
|
82
|
-
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.VisuallyHidden, {
|
|
83
|
-
as: "label",
|
|
84
|
-
htmlFor: `code-editor-text-area-${instanceId}`
|
|
85
|
-
}, (0, _i18n.__)('Type text or HTML')), (0, _element.createElement)(_reactAutosizeTextarea.default, {
|
|
86
|
-
autoComplete: "off",
|
|
87
|
-
dir: "auto",
|
|
88
|
-
value: stateValue,
|
|
89
|
-
onChange: onChangeHandler,
|
|
90
|
-
onBlur: stopEditing,
|
|
91
|
-
className: "edit-site-code-editor-text-area",
|
|
92
|
-
id: `code-editor-text-area-${instanceId}`,
|
|
93
|
-
placeholder: (0, _i18n.__)('Start writing with text or HTML')
|
|
94
|
-
}));
|
|
95
|
-
}
|
|
96
|
-
//# sourceMappingURL=code-editor-text-area.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/code-editor/code-editor-text-area.js"],"names":["CodeEditorTextArea","value","onChange","onInput","stateValue","setStateValue","isDirty","setIsDirty","instanceId","valueRef","onChangeHandler","event","newValue","target","current","stopEditing"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AACA;;AAXA;AACA;AACA;;AAGA;AACA;AACA;AAMe,SAASA,kBAAT,CAA6B;AAAEC,EAAAA,KAAF;AAASC,EAAAA,QAAT;AAAmBC,EAAAA;AAAnB,CAA7B,EAA4D;AAC1E,QAAM,CAAEC,UAAF,EAAcC,aAAd,IAAgC,uBAAUJ,KAAV,CAAtC;AACA,QAAM,CAAEK,OAAF,EAAWC,UAAX,IAA0B,uBAAU,KAAV,CAAhC;AACA,QAAMC,UAAU,GAAG,4BAAeR,kBAAf,CAAnB;AACA,QAAMS,QAAQ,GAAG,sBAAjB;;AAEA,MAAK,CAAEH,OAAF,IAAaF,UAAU,KAAKH,KAAjC,EAAyC;AACxCI,IAAAA,aAAa,CAAEJ,KAAF,CAAb;AACA;AAED;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACC,QAAMS,eAAe,GAAKC,KAAF,IAAa;AACpC,UAAMC,QAAQ,GAAGD,KAAK,CAACE,MAAN,CAAaZ,KAA9B;AACAE,IAAAA,OAAO,CAAES,QAAF,CAAP;AACAP,IAAAA,aAAa,CAAEO,QAAF,CAAb;AACAL,IAAAA,UAAU,CAAE,IAAF,CAAV;AACAE,IAAAA,QAAQ,CAACK,OAAT,GAAmBF,QAAnB;AACA,GAND;AAQA;AACD;AACA;AACA;AACA;;;AACC,QAAMG,WAAW,GAAG,MAAM;AACzB,QAAKT,OAAL,EAAe;AACdJ,MAAAA,QAAQ,CAAEE,UAAF,CAAR;AACAG,MAAAA,UAAU,CAAE,KAAF,CAAV;AACA;AACD,GALD,CAlC0E,CAyC1E;;;AACA,0BAAW,MAAM;AAChB,WAAO,MAAM;AACZ,UAAKE,QAAQ,CAACK,OAAd,EAAwB;AACvBZ,QAAAA,QAAQ,CAAEO,QAAQ,CAACK,OAAX,CAAR;AACA;AACD,KAJD;AAKA,GAND,EAMG,EANH;AAQA,SACC,qDACC,4BAAC,0BAAD;AACC,IAAA,EAAE,EAAC,OADJ;AAEC,IAAA,OAAO,EAAI,yBAAyBN,UAAY;AAFjD,KAIG,cAAI,mBAAJ,CAJH,CADD,EAOC,4BAAC,8BAAD;AACC,IAAA,YAAY,EAAC,KADd;AAEC,IAAA,GAAG,EAAC,MAFL;AAGC,IAAA,KAAK,EAAGJ,UAHT;AAIC,IAAA,QAAQ,EAAGM,eAJZ;AAKC,IAAA,MAAM,EAAGK,WALV;AAMC,IAAA,SAAS,EAAC,iCANX;AAOC,IAAA,EAAE,EAAI,yBAAyBP,UAAY,EAP5C;AAQC,IAAA,WAAW,EAAG,cAAI,iCAAJ;AARf,IAPD,CADD;AAoBA","sourcesContent":["/**\n * External dependencies\n */\nimport Textarea from 'react-autosize-textarea';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useEffect, useState, useRef } from '@wordpress/element';\nimport { useInstanceId } from '@wordpress/compose';\nimport { VisuallyHidden } from '@wordpress/components';\n\nexport default function CodeEditorTextArea( { value, onChange, onInput } ) {\n\tconst [ stateValue, setStateValue ] = useState( value );\n\tconst [ isDirty, setIsDirty ] = useState( false );\n\tconst instanceId = useInstanceId( CodeEditorTextArea );\n\tconst valueRef = useRef();\n\n\tif ( ! isDirty && stateValue !== value ) {\n\t\tsetStateValue( value );\n\t}\n\n\t/**\n\t * Handles a textarea change event to notify the onChange prop callback and\n\t * reflect the new value in the component's own state. This marks the start\n\t * of the user's edits, if not already changed, preventing future props\n\t * changes to value from replacing the rendered value. This is expected to\n\t * be followed by a reset to dirty state via `stopEditing`.\n\t *\n\t * @see stopEditing\n\t *\n\t * @param {Event} event Change event.\n\t */\n\tconst onChangeHandler = ( event ) => {\n\t\tconst newValue = event.target.value;\n\t\tonInput( newValue );\n\t\tsetStateValue( newValue );\n\t\tsetIsDirty( true );\n\t\tvalueRef.current = newValue;\n\t};\n\n\t/**\n\t * Function called when the user has completed their edits, responsible for\n\t * ensuring that changes, if made, are surfaced to the onPersist prop\n\t * callback and resetting dirty state.\n\t */\n\tconst stopEditing = () => {\n\t\tif ( isDirty ) {\n\t\t\tonChange( stateValue );\n\t\t\tsetIsDirty( false );\n\t\t}\n\t};\n\n\t// Ensure changes aren't lost when component unmounts.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tif ( valueRef.current ) {\n\t\t\t\tonChange( valueRef.current );\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<>\n\t\t\t<VisuallyHidden\n\t\t\t\tas=\"label\"\n\t\t\t\thtmlFor={ `code-editor-text-area-${ instanceId }` }\n\t\t\t>\n\t\t\t\t{ __( 'Type text or HTML' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t<Textarea\n\t\t\t\tautoComplete=\"off\"\n\t\t\t\tdir=\"auto\"\n\t\t\t\tvalue={ stateValue }\n\t\t\t\tonChange={ onChangeHandler }\n\t\t\t\tonBlur={ stopEditing }\n\t\t\t\tclassName=\"edit-site-code-editor-text-area\"\n\t\t\t\tid={ `code-editor-text-area-${ instanceId }` }\n\t\t\t\tplaceholder={ __( 'Start writing with text or HTML' ) }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _keyboardShortcuts = require("@wordpress/keyboard-shortcuts");
|
|
9
|
-
|
|
10
|
-
var _data = require("@wordpress/data");
|
|
11
|
-
|
|
12
|
-
var _coreData = require("@wordpress/core-data");
|
|
13
|
-
|
|
14
|
-
var _blockEditor = require("@wordpress/block-editor");
|
|
15
|
-
|
|
16
|
-
var _interface = require("@wordpress/interface");
|
|
17
|
-
|
|
18
|
-
var _blocks = require("@wordpress/blocks");
|
|
19
|
-
|
|
20
|
-
var _store = require("../../store");
|
|
21
|
-
|
|
22
|
-
var _constants = require("../sidebar-edit-mode/constants");
|
|
23
|
-
|
|
24
|
-
var _constants2 = require("../../store/constants");
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* WordPress dependencies
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Internal dependencies
|
|
32
|
-
*/
|
|
33
|
-
function KeyboardShortcuts() {
|
|
34
|
-
const {
|
|
35
|
-
__experimentalGetDirtyEntityRecords,
|
|
36
|
-
isSavingEntityRecord
|
|
37
|
-
} = (0, _data.useSelect)(_coreData.store);
|
|
38
|
-
const {
|
|
39
|
-
getEditorMode
|
|
40
|
-
} = (0, _data.useSelect)(_store.store);
|
|
41
|
-
const isListViewOpen = (0, _data.useSelect)(select => select(_store.store).isListViewOpened(), []);
|
|
42
|
-
const isBlockInspectorOpen = (0, _data.useSelect)(select => select(_interface.store).getActiveComplementaryArea(_store.store.name) === _constants.SIDEBAR_BLOCK, []);
|
|
43
|
-
const {
|
|
44
|
-
redo,
|
|
45
|
-
undo
|
|
46
|
-
} = (0, _data.useDispatch)(_coreData.store);
|
|
47
|
-
const {
|
|
48
|
-
setIsListViewOpened,
|
|
49
|
-
switchEditorMode
|
|
50
|
-
} = (0, _data.useDispatch)(_store.store);
|
|
51
|
-
const {
|
|
52
|
-
enableComplementaryArea,
|
|
53
|
-
disableComplementaryArea
|
|
54
|
-
} = (0, _data.useDispatch)(_interface.store);
|
|
55
|
-
const {
|
|
56
|
-
setIsSaveViewOpened
|
|
57
|
-
} = (0, _data.useDispatch)(_store.store);
|
|
58
|
-
const {
|
|
59
|
-
replaceBlocks
|
|
60
|
-
} = (0, _data.useDispatch)(_blockEditor.store);
|
|
61
|
-
const {
|
|
62
|
-
getBlockName,
|
|
63
|
-
getSelectedBlockClientId,
|
|
64
|
-
getBlockAttributes
|
|
65
|
-
} = (0, _data.useSelect)(_blockEditor.store);
|
|
66
|
-
|
|
67
|
-
const handleTextLevelShortcut = (event, level) => {
|
|
68
|
-
event.preventDefault();
|
|
69
|
-
const destinationBlockName = level === 0 ? 'core/paragraph' : 'core/heading';
|
|
70
|
-
const currentClientId = getSelectedBlockClientId();
|
|
71
|
-
|
|
72
|
-
if (currentClientId === null) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const blockName = getBlockName(currentClientId);
|
|
77
|
-
|
|
78
|
-
if (blockName !== 'core/paragraph' && blockName !== 'core/heading') {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const attributes = getBlockAttributes(currentClientId);
|
|
83
|
-
const textAlign = blockName === 'core/paragraph' ? 'align' : 'textAlign';
|
|
84
|
-
const destinationTextAlign = destinationBlockName === 'core/paragraph' ? 'align' : 'textAlign';
|
|
85
|
-
replaceBlocks(currentClientId, (0, _blocks.createBlock)(destinationBlockName, {
|
|
86
|
-
level,
|
|
87
|
-
content: attributes.content,
|
|
88
|
-
...{
|
|
89
|
-
[destinationTextAlign]: attributes[textAlign]
|
|
90
|
-
}
|
|
91
|
-
}));
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
(0, _keyboardShortcuts.useShortcut)('core/edit-site/save', event => {
|
|
95
|
-
event.preventDefault();
|
|
96
|
-
|
|
97
|
-
const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
|
|
98
|
-
|
|
99
|
-
const isDirty = !!dirtyEntityRecords.length;
|
|
100
|
-
const isSaving = dirtyEntityRecords.some(record => isSavingEntityRecord(record.kind, record.name, record.key));
|
|
101
|
-
|
|
102
|
-
if (!isSaving && isDirty) {
|
|
103
|
-
setIsSaveViewOpened(true);
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
(0, _keyboardShortcuts.useShortcut)('core/edit-site/undo', event => {
|
|
107
|
-
undo();
|
|
108
|
-
event.preventDefault();
|
|
109
|
-
});
|
|
110
|
-
(0, _keyboardShortcuts.useShortcut)('core/edit-site/redo', event => {
|
|
111
|
-
redo();
|
|
112
|
-
event.preventDefault();
|
|
113
|
-
}); // Only opens the list view. Other functionality for this shortcut happens in the rendered sidebar.
|
|
114
|
-
|
|
115
|
-
(0, _keyboardShortcuts.useShortcut)('core/edit-site/toggle-list-view', () => {
|
|
116
|
-
if (!isListViewOpen) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
setIsListViewOpened(true);
|
|
121
|
-
});
|
|
122
|
-
(0, _keyboardShortcuts.useShortcut)('core/edit-site/toggle-block-settings-sidebar', event => {
|
|
123
|
-
// This shortcut has no known clashes, but use preventDefault to prevent any
|
|
124
|
-
// obscure shortcuts from triggering.
|
|
125
|
-
event.preventDefault();
|
|
126
|
-
|
|
127
|
-
if (isBlockInspectorOpen) {
|
|
128
|
-
disableComplementaryArea(_constants2.STORE_NAME);
|
|
129
|
-
} else {
|
|
130
|
-
enableComplementaryArea(_constants2.STORE_NAME, _constants.SIDEBAR_BLOCK);
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
(0, _keyboardShortcuts.useShortcut)('core/edit-site/toggle-mode', () => {
|
|
134
|
-
switchEditorMode(getEditorMode() === 'visual' ? 'text' : 'visual');
|
|
135
|
-
});
|
|
136
|
-
(0, _keyboardShortcuts.useShortcut)('core/edit-site/transform-heading-to-paragraph', event => handleTextLevelShortcut(event, 0));
|
|
137
|
-
[1, 2, 3, 4, 5, 6].forEach(level => {
|
|
138
|
-
//the loop is based off on a constant therefore
|
|
139
|
-
//the hook will execute the same way every time
|
|
140
|
-
//eslint-disable-next-line react-hooks/rules-of-hooks
|
|
141
|
-
(0, _keyboardShortcuts.useShortcut)(`core/edit-site/transform-paragraph-to-heading-${level}`, event => handleTextLevelShortcut(event, level));
|
|
142
|
-
});
|
|
143
|
-
return null;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
var _default = KeyboardShortcuts;
|
|
147
|
-
exports.default = _default;
|
|
148
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/keyboard-shortcuts/index.js"],"names":["KeyboardShortcuts","__experimentalGetDirtyEntityRecords","isSavingEntityRecord","coreStore","getEditorMode","editSiteStore","isListViewOpen","select","isListViewOpened","isBlockInspectorOpen","interfaceStore","getActiveComplementaryArea","name","SIDEBAR_BLOCK","redo","undo","setIsListViewOpened","switchEditorMode","enableComplementaryArea","disableComplementaryArea","setIsSaveViewOpened","replaceBlocks","blockEditorStore","getBlockName","getSelectedBlockClientId","getBlockAttributes","handleTextLevelShortcut","event","level","preventDefault","destinationBlockName","currentClientId","blockName","attributes","textAlign","destinationTextAlign","content","dirtyEntityRecords","isDirty","length","isSaving","some","record","kind","key","STORE_NAME","forEach"],"mappings":"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","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { SIDEBAR_BLOCK } from '../sidebar-edit-mode/constants';\nimport { STORE_NAME } from '../../store/constants';\n\nfunction KeyboardShortcuts() {\n\tconst { __experimentalGetDirtyEntityRecords, isSavingEntityRecord } =\n\t\tuseSelect( coreStore );\n\tconst { getEditorMode } = useSelect( editSiteStore );\n\tconst isListViewOpen = useSelect(\n\t\t( select ) => select( editSiteStore ).isListViewOpened(),\n\t\t[]\n\t);\n\tconst isBlockInspectorOpen = useSelect(\n\t\t( select ) =>\n\t\t\tselect( interfaceStore ).getActiveComplementaryArea(\n\t\t\t\teditSiteStore.name\n\t\t\t) === SIDEBAR_BLOCK,\n\t\t[]\n\t);\n\tconst { redo, undo } = useDispatch( coreStore );\n\tconst { setIsListViewOpened, switchEditorMode } =\n\t\tuseDispatch( editSiteStore );\n\tconst { enableComplementaryArea, disableComplementaryArea } =\n\t\tuseDispatch( interfaceStore );\n\tconst { setIsSaveViewOpened } = useDispatch( editSiteStore );\n\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst { getBlockName, getSelectedBlockClientId, getBlockAttributes } =\n\t\tuseSelect( blockEditorStore );\n\n\tconst handleTextLevelShortcut = ( event, level ) => {\n\t\tevent.preventDefault();\n\t\tconst destinationBlockName =\n\t\t\tlevel === 0 ? 'core/paragraph' : 'core/heading';\n\t\tconst currentClientId = getSelectedBlockClientId();\n\t\tif ( currentClientId === null ) {\n\t\t\treturn;\n\t\t}\n\t\tconst blockName = getBlockName( currentClientId );\n\t\tif ( blockName !== 'core/paragraph' && blockName !== 'core/heading' ) {\n\t\t\treturn;\n\t\t}\n\t\tconst attributes = getBlockAttributes( currentClientId );\n\t\tconst textAlign =\n\t\t\tblockName === 'core/paragraph' ? 'align' : 'textAlign';\n\t\tconst destinationTextAlign =\n\t\t\tdestinationBlockName === 'core/paragraph' ? 'align' : 'textAlign';\n\n\t\treplaceBlocks(\n\t\t\tcurrentClientId,\n\t\t\tcreateBlock( destinationBlockName, {\n\t\t\t\tlevel,\n\t\t\t\tcontent: attributes.content,\n\t\t\t\t...{ [ destinationTextAlign ]: attributes[ textAlign ] },\n\t\t\t} )\n\t\t);\n\t};\n\n\tuseShortcut( 'core/edit-site/save', ( event ) => {\n\t\tevent.preventDefault();\n\n\t\tconst dirtyEntityRecords = __experimentalGetDirtyEntityRecords();\n\t\tconst isDirty = !! dirtyEntityRecords.length;\n\t\tconst isSaving = dirtyEntityRecords.some( ( record ) =>\n\t\t\tisSavingEntityRecord( record.kind, record.name, record.key )\n\t\t);\n\n\t\tif ( ! isSaving && isDirty ) {\n\t\t\tsetIsSaveViewOpened( true );\n\t\t}\n\t} );\n\n\tuseShortcut( 'core/edit-site/undo', ( event ) => {\n\t\tundo();\n\t\tevent.preventDefault();\n\t} );\n\n\tuseShortcut( 'core/edit-site/redo', ( event ) => {\n\t\tredo();\n\t\tevent.preventDefault();\n\t} );\n\n\t// Only opens the list view. Other functionality for this shortcut happens in the rendered sidebar.\n\tuseShortcut( 'core/edit-site/toggle-list-view', () => {\n\t\tif ( ! isListViewOpen ) {\n\t\t\treturn;\n\t\t}\n\t\tsetIsListViewOpened( true );\n\t} );\n\n\tuseShortcut( 'core/edit-site/toggle-block-settings-sidebar', ( event ) => {\n\t\t// This shortcut has no known clashes, but use preventDefault to prevent any\n\t\t// obscure shortcuts from triggering.\n\t\tevent.preventDefault();\n\n\t\tif ( isBlockInspectorOpen ) {\n\t\t\tdisableComplementaryArea( STORE_NAME );\n\t\t} else {\n\t\t\tenableComplementaryArea( STORE_NAME, SIDEBAR_BLOCK );\n\t\t}\n\t} );\n\n\tuseShortcut( 'core/edit-site/toggle-mode', () => {\n\t\tswitchEditorMode( getEditorMode() === 'visual' ? 'text' : 'visual' );\n\t} );\n\n\tuseShortcut( 'core/edit-site/transform-heading-to-paragraph', ( event ) =>\n\t\thandleTextLevelShortcut( event, 0 )\n\t);\n\n\t[ 1, 2, 3, 4, 5, 6 ].forEach( ( level ) => {\n\t\t//the loop is based off on a constant therefore\n\t\t//the hook will execute the same way every time\n\t\t//eslint-disable-next-line react-hooks/rules-of-hooks\n\t\tuseShortcut(\n\t\t\t`core/edit-site/transform-paragraph-to-heading-${ level }`,\n\t\t\t( event ) => handleTextLevelShortcut( event, level )\n\t\t);\n\t} );\n\n\treturn null;\n}\n\nexport default KeyboardShortcuts;\n"]}
|