@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
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var _element = require("@wordpress/element");
|
|
4
4
|
|
|
5
|
-
var _lodash = require("lodash");
|
|
6
|
-
|
|
7
5
|
var _hooks = require("@wordpress/hooks");
|
|
8
6
|
|
|
9
7
|
var _compose = require("@wordpress/compose");
|
|
@@ -24,10 +22,6 @@ var _hooks2 = require("../../components/global-styles/hooks");
|
|
|
24
22
|
|
|
25
23
|
var _lockUnlock = require("../../lock-unlock");
|
|
26
24
|
|
|
27
|
-
/**
|
|
28
|
-
* External dependencies
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
25
|
/**
|
|
32
26
|
* WordPress dependencies
|
|
33
27
|
*/
|
|
@@ -37,7 +31,9 @@ var _lockUnlock = require("../../lock-unlock");
|
|
|
37
31
|
*/
|
|
38
32
|
const {
|
|
39
33
|
GlobalStylesContext,
|
|
40
|
-
useBlockEditingMode
|
|
34
|
+
useBlockEditingMode,
|
|
35
|
+
__experimentalUseGlobalBehaviors: useGlobalBehaviors,
|
|
36
|
+
__experimentalUseHasBehaviorsPanel: useHasBehaviorsPanel
|
|
41
37
|
} = (0, _lockUnlock.unlock)(_blockEditor.privateApis); // TODO: Temporary duplication of constant in @wordpress/block-editor. Can be
|
|
42
38
|
// removed by moving PushChangesToGlobalStylesControl to
|
|
43
39
|
// @wordpress/block-editor.
|
|
@@ -97,6 +93,15 @@ const STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {
|
|
|
97
93
|
'typography.fontSize': 'fontSize',
|
|
98
94
|
'typography.fontFamily': 'fontFamily'
|
|
99
95
|
};
|
|
96
|
+
const SUPPORTED_STYLES = ['border', 'color', 'spacing', 'typography'];
|
|
97
|
+
|
|
98
|
+
const getValueFromObjectPath = (object, path) => {
|
|
99
|
+
let value = object;
|
|
100
|
+
path.forEach(fieldName => {
|
|
101
|
+
value = value?.[fieldName];
|
|
102
|
+
});
|
|
103
|
+
return value;
|
|
104
|
+
};
|
|
100
105
|
|
|
101
106
|
function useChangesToPush(name, attributes) {
|
|
102
107
|
const supports = (0, _hooks2.useSupportedStyles)(name);
|
|
@@ -110,12 +115,54 @@ function useChangesToPush(name, attributes) {
|
|
|
110
115
|
} = _blocks.__EXPERIMENTAL_STYLE_PROPERTY[key];
|
|
111
116
|
const presetAttributeKey = path.join('.');
|
|
112
117
|
const presetAttributeValue = attributes[STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE[presetAttributeKey]];
|
|
113
|
-
const value = presetAttributeValue ? `var:preset|${STYLE_PATH_TO_CSS_VAR_INFIX[presetAttributeKey]}|${presetAttributeValue}` : (
|
|
118
|
+
const value = presetAttributeValue ? `var:preset|${STYLE_PATH_TO_CSS_VAR_INFIX[presetAttributeKey]}|${presetAttributeValue}` : getValueFromObjectPath(attributes.style, path);
|
|
114
119
|
return value ? [{
|
|
115
120
|
path,
|
|
116
121
|
value
|
|
117
122
|
}] : [];
|
|
118
|
-
}), [supports,
|
|
123
|
+
}), [supports, attributes]);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Sets the value at path of object.
|
|
127
|
+
* If a portion of path doesn’t exist, it’s created.
|
|
128
|
+
* Arrays are created for missing index properties while objects are created
|
|
129
|
+
* for all other missing properties.
|
|
130
|
+
*
|
|
131
|
+
* This function intentionally mutates the input object.
|
|
132
|
+
*
|
|
133
|
+
* Inspired by _.set().
|
|
134
|
+
*
|
|
135
|
+
* @see https://lodash.com/docs/4.17.15#set
|
|
136
|
+
*
|
|
137
|
+
* @todo Needs to be deduplicated with its copy in `@wordpress/core-data`.
|
|
138
|
+
*
|
|
139
|
+
* @param {Object} object Object to modify
|
|
140
|
+
* @param {Array} path Path of the property to set.
|
|
141
|
+
* @param {*} value Value to set.
|
|
142
|
+
*/
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
function setNestedValue(object, path, value) {
|
|
146
|
+
if (!object || typeof object !== 'object') {
|
|
147
|
+
return object;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
path.reduce((acc, key, idx) => {
|
|
151
|
+
if (acc[key] === undefined) {
|
|
152
|
+
if (Number.isInteger(path[idx + 1])) {
|
|
153
|
+
acc[key] = [];
|
|
154
|
+
} else {
|
|
155
|
+
acc[key] = {};
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (idx === path.length - 1) {
|
|
160
|
+
acc[key] = value;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return acc[key];
|
|
164
|
+
}, object);
|
|
165
|
+
return object;
|
|
119
166
|
}
|
|
120
167
|
|
|
121
168
|
function cloneDeep(object) {
|
|
@@ -128,6 +175,9 @@ function PushChangesToGlobalStylesControl({
|
|
|
128
175
|
setAttributes
|
|
129
176
|
}) {
|
|
130
177
|
const changes = useChangesToPush(name, attributes);
|
|
178
|
+
const hasBehaviorsPanel = useHasBehaviorsPanel(attributes, name, {
|
|
179
|
+
blockSupportOnly: true
|
|
180
|
+
});
|
|
131
181
|
const {
|
|
132
182
|
user: userConfig,
|
|
133
183
|
setUserConfig
|
|
@@ -138,72 +188,103 @@ function PushChangesToGlobalStylesControl({
|
|
|
138
188
|
const {
|
|
139
189
|
createSuccessNotice
|
|
140
190
|
} = (0, _data.useDispatch)(_notices.store);
|
|
191
|
+
const {
|
|
192
|
+
inheritedBehaviors,
|
|
193
|
+
setBehavior
|
|
194
|
+
} = useGlobalBehaviors(name);
|
|
195
|
+
const userHasEditedBehaviors = attributes.hasOwnProperty('behaviors') && hasBehaviorsPanel;
|
|
141
196
|
const pushChanges = (0, _element.useCallback)(() => {
|
|
142
|
-
if (changes.length === 0) {
|
|
197
|
+
if (changes.length === 0 && !userHasEditedBehaviors) {
|
|
143
198
|
return;
|
|
144
199
|
}
|
|
145
200
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
201
|
+
if (changes.length > 0) {
|
|
202
|
+
const {
|
|
203
|
+
style: blockStyles
|
|
204
|
+
} = attributes;
|
|
205
|
+
const newBlockStyles = cloneDeep(blockStyles);
|
|
206
|
+
const newUserConfig = cloneDeep(userConfig);
|
|
151
207
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
208
|
+
for (const {
|
|
209
|
+
path,
|
|
210
|
+
value
|
|
211
|
+
} of changes) {
|
|
212
|
+
setNestedValue(newBlockStyles, path, undefined);
|
|
213
|
+
setNestedValue(newUserConfig, ['styles', 'blocks', name, ...path], value);
|
|
214
|
+
} // @wordpress/core-data doesn't support editing multiple entity types in
|
|
215
|
+
// a single undo level. So for now, we disable @wordpress/core-data undo
|
|
216
|
+
// tracking and implement our own Undo button in the snackbar
|
|
217
|
+
// notification.
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
221
|
+
|
|
222
|
+
setAttributes({
|
|
223
|
+
style: newBlockStyles
|
|
224
|
+
});
|
|
225
|
+
setUserConfig(() => newUserConfig, {
|
|
226
|
+
undoIgnore: true
|
|
227
|
+
});
|
|
228
|
+
createSuccessNotice((0, _i18n.sprintf)( // translators: %s: Title of the block e.g. 'Heading'.
|
|
229
|
+
(0, _i18n.__)('%s styles applied.'), (0, _blocks.getBlockType)(name).title), {
|
|
230
|
+
type: 'snackbar',
|
|
231
|
+
actions: [{
|
|
232
|
+
label: (0, _i18n.__)('Undo'),
|
|
233
|
+
|
|
234
|
+
onClick() {
|
|
235
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
236
|
+
|
|
237
|
+
setAttributes({
|
|
238
|
+
style: blockStyles
|
|
239
|
+
});
|
|
240
|
+
setUserConfig(() => userConfig, {
|
|
241
|
+
undoIgnore: true
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
}]
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (userHasEditedBehaviors) {
|
|
250
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
251
|
+
|
|
252
|
+
setBehavior(attributes.behaviors);
|
|
253
|
+
createSuccessNotice((0, _i18n.sprintf)( // translators: %s: Title of the block e.g. 'Heading'.
|
|
254
|
+
(0, _i18n.__)('%s behaviors applied.'), (0, _blocks.getBlockType)(name).title), {
|
|
255
|
+
type: 'snackbar',
|
|
256
|
+
actions: [{
|
|
257
|
+
label: (0, _i18n.__)('Undo'),
|
|
258
|
+
|
|
259
|
+
onClick() {
|
|
260
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
261
|
+
|
|
262
|
+
setBehavior(inheritedBehaviors);
|
|
263
|
+
setUserConfig(() => userConfig, {
|
|
264
|
+
undoIgnore: true
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
}]
|
|
269
|
+
});
|
|
270
|
+
}
|
|
191
271
|
}, [changes, attributes, userConfig, name]);
|
|
192
272
|
return (0, _element.createElement)(_components.BaseControl, {
|
|
193
273
|
className: "edit-site-push-changes-to-global-styles-control",
|
|
194
274
|
help: (0, _i18n.sprintf)( // translators: %s: Title of the block e.g. 'Heading'.
|
|
195
|
-
(0, _i18n.__)('Apply this block’s typography, spacing, dimensions,
|
|
275
|
+
(0, _i18n.__)('Apply this block’s typography, spacing, dimensions, color styles, and behaviors to all %s blocks.'), (0, _blocks.getBlockType)(name).title)
|
|
196
276
|
}, (0, _element.createElement)(_components.BaseControl.VisualLabel, null, (0, _i18n.__)('Styles')), (0, _element.createElement)(_components.Button, {
|
|
197
277
|
variant: "primary",
|
|
198
|
-
disabled: changes.length === 0,
|
|
278
|
+
disabled: changes.length === 0 && !userHasEditedBehaviors,
|
|
199
279
|
onClick: pushChanges
|
|
200
280
|
}, (0, _i18n.__)('Apply globally')));
|
|
201
281
|
}
|
|
202
282
|
|
|
203
283
|
const withPushChangesToGlobalStyles = (0, _compose.createHigherOrderComponent)(BlockEdit => props => {
|
|
204
284
|
const blockEditingMode = useBlockEditingMode();
|
|
285
|
+
const supportsStyles = SUPPORTED_STYLES.some(feature => (0, _blocks.hasBlockSupport)(props.name, feature));
|
|
205
286
|
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(BlockEdit, { ...props
|
|
206
|
-
}), blockEditingMode === 'default' && (0, _element.createElement)(_blockEditor.InspectorAdvancedControls, null, (0, _element.createElement)(PushChangesToGlobalStylesControl, { ...props
|
|
287
|
+
}), blockEditingMode === 'default' && supportsStyles && (0, _element.createElement)(_blockEditor.InspectorAdvancedControls, null, (0, _element.createElement)(PushChangesToGlobalStylesControl, { ...props
|
|
207
288
|
})));
|
|
208
289
|
});
|
|
209
290
|
(0, _hooks.addFilter)('editor.BlockEdit', 'core/edit-site/push-changes-to-global-styles', withPushChangesToGlobalStyles);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/hooks/push-changes-to-global-styles/index.js"],"names":["GlobalStylesContext","useBlockEditingMode","blockEditorPrivateApis","STYLE_PATH_TO_CSS_VAR_INFIX","STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE","useChangesToPush","name","attributes","supports","flatMap","key","STYLE_PROPERTY","value","path","presetAttributeKey","join","presetAttributeValue","style","cloneDeep","object","JSON","parse","stringify","PushChangesToGlobalStylesControl","setAttributes","changes","user","userConfig","setUserConfig","__unstableMarkNextChangeAsNotPersistent","blockEditorStore","createSuccessNotice","noticesStore","pushChanges","length","blockStyles","newBlockStyles","newUserConfig","undefined","undoIgnore","title","type","actions","label","onClick","withPushChangesToGlobalStyles","BlockEdit","props","blockEditingMode"],"mappings":";;AAqBA;;AAl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AAO,EAAE,CACR;AACCC,QAAAA,KAAK,EAAE,cAAI,MAAJ,CADR;;AAECC,QAAAA,OAAO,GAAG;AACTf,UAAAA,uCAAuC;;AACvCL,UAAAA,aAAa,CAAE;AAAEP,YAAAA,KAAK,EAAEkB;AAAT,WAAF,CAAb;AACAP,UAAAA,aAAa,CAAE,MAAMD,UAAR,EAAoB;AAChCY,YAAAA,UAAU,EAAE;AADoB,WAApB,CAAb;AAGA;;AARF,OADQ;AAFV,KANkB,CAAnB;AAsBA,GA7CmB,EA6CjB,CAAEd,OAAF,EAAWlB,UAAX,EAAuBoB,UAAvB,EAAmCrB,IAAnC,CA7CiB,CAApB;AA+CA,SACC,4BAAC,uBAAD;AACC,IAAA,SAAS,EAAC,iDADX;AAEC,IAAA,IAAI,EAAG,oBACN;AACA,kBACC,wFADD,CAFM,EAKN,0BAAcA,IAAd,EAAqBkC,KALf;AAFR,KAUC,4BAAC,uBAAD,CAAa,WAAb,QACG,cAAI,QAAJ,CADH,CAVD,EAaC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,SADT;AAEC,IAAA,QAAQ,EAAGf,OAAO,CAACS,MAAR,KAAmB,CAF/B;AAGC,IAAA,OAAO,EAAGD;AAHX,KAKG,cAAI,gBAAJ,CALH,CAbD,CADD;AAuBA;;AAED,MAAMY,6BAA6B,GAAG,yCACnCC,SAAF,IAAmBC,KAAF,IAAa;AAC7B,QAAMC,gBAAgB,GAAG/C,mBAAmB,EAA5C;AACA,SACC,qDACC,4BAAC,SAAD,OAAgB8C;AAAhB,IADD,EAEGC,gBAAgB,KAAK,SAArB,IACD,4BAAC,sCAAD,QACC,4BAAC,gCAAD,OAAuCD;AAAvC,IADD,CAHF,CADD;AAUA,CAboC,CAAtC;AAgBA,sBACC,kBADD,EAEC,8CAFD,EAGCF,6BAHD","sourcesContent":["/**\n * External dependencies\n */\nimport { get, set } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport {\n\tInspectorAdvancedControls,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { BaseControl, Button } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\t__EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY,\n\tgetBlockType,\n} from '@wordpress/blocks';\nimport { useContext, useMemo, useCallback } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { useSupportedStyles } from '../../components/global-styles/hooks';\nimport { unlock } from '../../lock-unlock';\n\nconst { GlobalStylesContext, useBlockEditingMode } = unlock(\n\tblockEditorPrivateApis\n);\n\n// TODO: Temporary duplication of constant in @wordpress/block-editor. Can be\n// removed by moving PushChangesToGlobalStylesControl to\n// @wordpress/block-editor.\nconst STYLE_PATH_TO_CSS_VAR_INFIX = {\n\t'color.background': 'color',\n\t'color.text': 'color',\n\t'elements.link.color.text': 'color',\n\t'elements.link.:hover.color.text': 'color',\n\t'elements.link.typography.fontFamily': 'font-family',\n\t'elements.link.typography.fontSize': 'font-size',\n\t'elements.button.color.text': 'color',\n\t'elements.button.color.background': 'color',\n\t'elements.button.typography.fontFamily': 'font-family',\n\t'elements.button.typography.fontSize': 'font-size',\n\t'elements.caption.color.text': 'color',\n\t'elements.heading.color': 'color',\n\t'elements.heading.color.background': 'color',\n\t'elements.heading.typography.fontFamily': 'font-family',\n\t'elements.heading.gradient': 'gradient',\n\t'elements.heading.color.gradient': 'gradient',\n\t'elements.h1.color': 'color',\n\t'elements.h1.color.background': 'color',\n\t'elements.h1.typography.fontFamily': 'font-family',\n\t'elements.h1.color.gradient': 'gradient',\n\t'elements.h2.color': 'color',\n\t'elements.h2.color.background': 'color',\n\t'elements.h2.typography.fontFamily': 'font-family',\n\t'elements.h2.color.gradient': 'gradient',\n\t'elements.h3.color': 'color',\n\t'elements.h3.color.background': 'color',\n\t'elements.h3.typography.fontFamily': 'font-family',\n\t'elements.h3.color.gradient': 'gradient',\n\t'elements.h4.color': 'color',\n\t'elements.h4.color.background': 'color',\n\t'elements.h4.typography.fontFamily': 'font-family',\n\t'elements.h4.color.gradient': 'gradient',\n\t'elements.h5.color': 'color',\n\t'elements.h5.color.background': 'color',\n\t'elements.h5.typography.fontFamily': 'font-family',\n\t'elements.h5.color.gradient': 'gradient',\n\t'elements.h6.color': 'color',\n\t'elements.h6.color.background': 'color',\n\t'elements.h6.typography.fontFamily': 'font-family',\n\t'elements.h6.color.gradient': 'gradient',\n\t'color.gradient': 'gradient',\n\t'typography.fontSize': 'font-size',\n\t'typography.fontFamily': 'font-family',\n};\n\n// TODO: Temporary duplication of constant in @wordpress/block-editor. Can be\n// removed by moving PushChangesToGlobalStylesControl to\n// @wordpress/block-editor.\nconst STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {\n\t'color.background': 'backgroundColor',\n\t'color.text': 'textColor',\n\t'color.gradient': 'gradient',\n\t'typography.fontSize': 'fontSize',\n\t'typography.fontFamily': 'fontFamily',\n};\n\nfunction useChangesToPush( name, attributes ) {\n\tconst supports = useSupportedStyles( name );\n\n\treturn useMemo(\n\t\t() =>\n\t\t\tsupports.flatMap( ( key ) => {\n\t\t\t\tif ( ! STYLE_PROPERTY[ key ] ) {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t\tconst { value: path } = STYLE_PROPERTY[ key ];\n\t\t\t\tconst presetAttributeKey = path.join( '.' );\n\t\t\t\tconst presetAttributeValue =\n\t\t\t\t\tattributes[\n\t\t\t\t\t\tSTYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE[\n\t\t\t\t\t\t\tpresetAttributeKey\n\t\t\t\t\t\t]\n\t\t\t\t\t];\n\t\t\t\tconst value = presetAttributeValue\n\t\t\t\t\t? `var:preset|${ STYLE_PATH_TO_CSS_VAR_INFIX[ presetAttributeKey ] }|${ presetAttributeValue }`\n\t\t\t\t\t: get( attributes.style, path );\n\t\t\t\treturn value ? [ { path, value } ] : [];\n\t\t\t} ),\n\t\t[ supports, name, attributes ]\n\t);\n}\n\nfunction cloneDeep( object ) {\n\treturn ! object ? {} : JSON.parse( JSON.stringify( object ) );\n}\n\nfunction PushChangesToGlobalStylesControl( {\n\tname,\n\tattributes,\n\tsetAttributes,\n} ) {\n\tconst changes = useChangesToPush( name, attributes );\n\n\tconst { user: userConfig, setUserConfig } =\n\t\tuseContext( GlobalStylesContext );\n\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tconst pushChanges = useCallback( () => {\n\t\tif ( changes.length === 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { style: blockStyles } = attributes;\n\n\t\tconst newBlockStyles = cloneDeep( blockStyles );\n\t\tconst newUserConfig = cloneDeep( userConfig );\n\n\t\tfor ( const { path, value } of changes ) {\n\t\t\tset( newBlockStyles, path, undefined );\n\t\t\tset( newUserConfig, [ 'styles', 'blocks', name, ...path ], value );\n\t\t}\n\n\t\t// @wordpress/core-data doesn't support editing multiple entity types in\n\t\t// a single undo level. So for now, we disable @wordpress/core-data undo\n\t\t// tracking and implement our own Undo button in the snackbar\n\t\t// notification.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tsetAttributes( { style: newBlockStyles } );\n\t\tsetUserConfig( () => newUserConfig, { undoIgnore: true } );\n\n\t\tcreateSuccessNotice(\n\t\t\tsprintf(\n\t\t\t\t// translators: %s: Title of the block e.g. 'Heading'.\n\t\t\t\t__( '%s styles applied.' ),\n\t\t\t\tgetBlockType( name ).title\n\t\t\t),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tactions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\tonClick() {\n\t\t\t\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\t\t\t\tsetAttributes( { style: blockStyles } );\n\t\t\t\t\t\t\tsetUserConfig( () => userConfig, {\n\t\t\t\t\t\t\t\tundoIgnore: true,\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],\n\t\t\t}\n\t\t);\n\t}, [ changes, attributes, userConfig, name ] );\n\n\treturn (\n\t\t<BaseControl\n\t\t\tclassName=\"edit-site-push-changes-to-global-styles-control\"\n\t\t\thelp={ sprintf(\n\t\t\t\t// translators: %s: Title of the block e.g. 'Heading'.\n\t\t\t\t__(\n\t\t\t\t\t'Apply this block’s typography, spacing, dimensions, and color styles to all %s blocks.'\n\t\t\t\t),\n\t\t\t\tgetBlockType( name ).title\n\t\t\t) }\n\t\t>\n\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t{ __( 'Styles' ) }\n\t\t\t</BaseControl.VisualLabel>\n\t\t\t<Button\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tdisabled={ changes.length === 0 }\n\t\t\t\tonClick={ pushChanges }\n\t\t\t>\n\t\t\t\t{ __( 'Apply globally' ) }\n\t\t\t</Button>\n\t\t</BaseControl>\n\t);\n}\n\nconst withPushChangesToGlobalStyles = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst blockEditingMode = useBlockEditingMode();\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t{ blockEditingMode === 'default' && (\n\t\t\t\t\t<InspectorAdvancedControls>\n\t\t\t\t\t\t<PushChangesToGlobalStylesControl { ...props } />\n\t\t\t\t\t</InspectorAdvancedControls>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/edit-site/push-changes-to-global-styles',\n\twithPushChangesToGlobalStyles\n);\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/hooks/push-changes-to-global-styles/index.js"],"names":["GlobalStylesContext","useBlockEditingMode","__experimentalUseGlobalBehaviors","useGlobalBehaviors","__experimentalUseHasBehaviorsPanel","useHasBehaviorsPanel","blockEditorPrivateApis","STYLE_PATH_TO_CSS_VAR_INFIX","STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE","SUPPORTED_STYLES","getValueFromObjectPath","object","path","value","forEach","fieldName","useChangesToPush","name","attributes","supports","flatMap","key","STYLE_PROPERTY","presetAttributeKey","join","presetAttributeValue","style","setNestedValue","reduce","acc","idx","undefined","Number","isInteger","length","cloneDeep","JSON","parse","stringify","PushChangesToGlobalStylesControl","setAttributes","changes","hasBehaviorsPanel","blockSupportOnly","user","userConfig","setUserConfig","__unstableMarkNextChangeAsNotPersistent","blockEditorStore","createSuccessNotice","noticesStore","inheritedBehaviors","setBehavior","userHasEditedBehaviors","hasOwnProperty","pushChanges","blockStyles","newBlockStyles","newUserConfig","undoIgnore","title","type","actions","label","onClick","behaviors","withPushChangesToGlobalStyles","BlockEdit","props","blockEditingMode","supportsStyles","some","feature"],"mappings":";;AAiBA;;AAdA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAMA;;AACA;;AAKA;;AACA;;AAzBA;AACA;AACA;;AAmBA;AACA;AACA;AAIA,MAAM;AACLA,EAAAA,mBADK;AAELC,EAAAA,mBAFK;AAGLC,EAAAA,gCAAgC,EAAEC,kBAH7B;AAILC,EAAAA,kCAAkC,EAAEC;AAJ/B,IAKF,wBAAQC,wBAAR,CALJ,C,CAOA;AACA;AACA;;AACA,MAAMC,2BAA2B,GAAG;AACnC,sBAAoB,OADe;AAEnC,gBAAc,OAFqB;AAGnC,8BAA4B,OAHO;AAInC,qCAAmC,OAJA;AAKnC,yCAAuC,aALJ;AAMnC,uCAAqC,WANF;AAOnC,gCAA8B,OAPK;AAQnC,sCAAoC,OARD;AASnC,2CAAyC,aATN;AAUnC,yCAAuC,WAVJ;AAWnC,iCAA+B,OAXI;AAYnC,4BAA0B,OAZS;AAanC,uCAAqC,OAbF;AAcnC,4CAA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IAAmBC,KAAF,IAAa;AAC7B,QAAMC,gBAAgB,GAAGpE,mBAAmB,EAA5C;AACA,QAAMqE,cAAc,GAAG7D,gBAAgB,CAAC8D,IAAjB,CAAyBC,OAAF,IAC7C,6BAAiBJ,KAAK,CAACnD,IAAvB,EAA6BuD,OAA7B,CADsB,CAAvB;AAIA,SACC,qDACC,4BAAC,SAAD,OAAgBJ;AAAhB,IADD,EAEGC,gBAAgB,KAAK,SAArB,IAAkCC,cAAlC,IACD,4BAAC,sCAAD,QACC,4BAAC,gCAAD,OAAuCF;AAAvC,IADD,CAHF,CADD;AAUA,CAjBoC,CAAtC;AAoBA,sBACC,kBADD,EAEC,8CAFD,EAGCF,6BAHD","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport {\n\tInspectorAdvancedControls,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { BaseControl, Button } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\t__EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY,\n\tgetBlockType,\n\thasBlockSupport,\n} from '@wordpress/blocks';\nimport { useContext, useMemo, useCallback } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { useSupportedStyles } from '../../components/global-styles/hooks';\nimport { unlock } from '../../lock-unlock';\n\nconst {\n\tGlobalStylesContext,\n\tuseBlockEditingMode,\n\t__experimentalUseGlobalBehaviors: useGlobalBehaviors,\n\t__experimentalUseHasBehaviorsPanel: useHasBehaviorsPanel,\n} = unlock( blockEditorPrivateApis );\n\n// TODO: Temporary duplication of constant in @wordpress/block-editor. Can be\n// removed by moving PushChangesToGlobalStylesControl to\n// @wordpress/block-editor.\nconst STYLE_PATH_TO_CSS_VAR_INFIX = {\n\t'color.background': 'color',\n\t'color.text': 'color',\n\t'elements.link.color.text': 'color',\n\t'elements.link.:hover.color.text': 'color',\n\t'elements.link.typography.fontFamily': 'font-family',\n\t'elements.link.typography.fontSize': 'font-size',\n\t'elements.button.color.text': 'color',\n\t'elements.button.color.background': 'color',\n\t'elements.button.typography.fontFamily': 'font-family',\n\t'elements.button.typography.fontSize': 'font-size',\n\t'elements.caption.color.text': 'color',\n\t'elements.heading.color': 'color',\n\t'elements.heading.color.background': 'color',\n\t'elements.heading.typography.fontFamily': 'font-family',\n\t'elements.heading.gradient': 'gradient',\n\t'elements.heading.color.gradient': 'gradient',\n\t'elements.h1.color': 'color',\n\t'elements.h1.color.background': 'color',\n\t'elements.h1.typography.fontFamily': 'font-family',\n\t'elements.h1.color.gradient': 'gradient',\n\t'elements.h2.color': 'color',\n\t'elements.h2.color.background': 'color',\n\t'elements.h2.typography.fontFamily': 'font-family',\n\t'elements.h2.color.gradient': 'gradient',\n\t'elements.h3.color': 'color',\n\t'elements.h3.color.background': 'color',\n\t'elements.h3.typography.fontFamily': 'font-family',\n\t'elements.h3.color.gradient': 'gradient',\n\t'elements.h4.color': 'color',\n\t'elements.h4.color.background': 'color',\n\t'elements.h4.typography.fontFamily': 'font-family',\n\t'elements.h4.color.gradient': 'gradient',\n\t'elements.h5.color': 'color',\n\t'elements.h5.color.background': 'color',\n\t'elements.h5.typography.fontFamily': 'font-family',\n\t'elements.h5.color.gradient': 'gradient',\n\t'elements.h6.color': 'color',\n\t'elements.h6.color.background': 'color',\n\t'elements.h6.typography.fontFamily': 'font-family',\n\t'elements.h6.color.gradient': 'gradient',\n\t'color.gradient': 'gradient',\n\t'typography.fontSize': 'font-size',\n\t'typography.fontFamily': 'font-family',\n};\n\n// TODO: Temporary duplication of constant in @wordpress/block-editor. Can be\n// removed by moving PushChangesToGlobalStylesControl to\n// @wordpress/block-editor.\nconst STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {\n\t'color.background': 'backgroundColor',\n\t'color.text': 'textColor',\n\t'color.gradient': 'gradient',\n\t'typography.fontSize': 'fontSize',\n\t'typography.fontFamily': 'fontFamily',\n};\n\nconst SUPPORTED_STYLES = [ 'border', 'color', 'spacing', 'typography' ];\n\nconst getValueFromObjectPath = ( object, path ) => {\n\tlet value = object;\n\tpath.forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value;\n};\n\nfunction useChangesToPush( name, attributes ) {\n\tconst supports = useSupportedStyles( name );\n\n\treturn useMemo(\n\t\t() =>\n\t\t\tsupports.flatMap( ( key ) => {\n\t\t\t\tif ( ! STYLE_PROPERTY[ key ] ) {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t\tconst { value: path } = STYLE_PROPERTY[ key ];\n\t\t\t\tconst presetAttributeKey = path.join( '.' );\n\t\t\t\tconst presetAttributeValue =\n\t\t\t\t\tattributes[\n\t\t\t\t\t\tSTYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE[\n\t\t\t\t\t\t\tpresetAttributeKey\n\t\t\t\t\t\t]\n\t\t\t\t\t];\n\t\t\t\tconst value = presetAttributeValue\n\t\t\t\t\t? `var:preset|${ STYLE_PATH_TO_CSS_VAR_INFIX[ presetAttributeKey ] }|${ presetAttributeValue }`\n\t\t\t\t\t: getValueFromObjectPath( attributes.style, path );\n\t\t\t\treturn value ? [ { path, value } ] : [];\n\t\t\t} ),\n\t\t[ supports, attributes ]\n\t);\n}\n\n/**\n * Sets the value at path of object.\n * If a portion of path doesn’t exist, it’s created.\n * Arrays are created for missing index properties while objects are created\n * for all other missing properties.\n *\n * This function intentionally mutates the input object.\n *\n * Inspired by _.set().\n *\n * @see https://lodash.com/docs/4.17.15#set\n *\n * @todo Needs to be deduplicated with its copy in `@wordpress/core-data`.\n *\n * @param {Object} object Object to modify\n * @param {Array} path Path of the property to set.\n * @param {*} value Value to set.\n */\nfunction setNestedValue( object, path, value ) {\n\tif ( ! object || typeof object !== 'object' ) {\n\t\treturn object;\n\t}\n\n\tpath.reduce( ( acc, key, idx ) => {\n\t\tif ( acc[ key ] === undefined ) {\n\t\t\tif ( Number.isInteger( path[ idx + 1 ] ) ) {\n\t\t\t\tacc[ key ] = [];\n\t\t\t} else {\n\t\t\t\tacc[ key ] = {};\n\t\t\t}\n\t\t}\n\t\tif ( idx === path.length - 1 ) {\n\t\t\tacc[ key ] = value;\n\t\t}\n\t\treturn acc[ key ];\n\t}, object );\n\n\treturn object;\n}\n\nfunction cloneDeep( object ) {\n\treturn ! object ? {} : JSON.parse( JSON.stringify( object ) );\n}\n\nfunction PushChangesToGlobalStylesControl( {\n\tname,\n\tattributes,\n\tsetAttributes,\n} ) {\n\tconst changes = useChangesToPush( name, attributes );\n\n\tconst hasBehaviorsPanel = useHasBehaviorsPanel( attributes, name, {\n\t\tblockSupportOnly: true,\n\t} );\n\tconst { user: userConfig, setUserConfig } =\n\t\tuseContext( GlobalStylesContext );\n\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tconst { inheritedBehaviors, setBehavior } = useGlobalBehaviors( name );\n\n\tconst userHasEditedBehaviors =\n\t\tattributes.hasOwnProperty( 'behaviors' ) && hasBehaviorsPanel;\n\n\tconst pushChanges = useCallback( () => {\n\t\tif ( changes.length === 0 && ! userHasEditedBehaviors ) {\n\t\t\treturn;\n\t\t}\n\t\tif ( changes.length > 0 ) {\n\t\t\tconst { style: blockStyles } = attributes;\n\n\t\t\tconst newBlockStyles = cloneDeep( blockStyles );\n\t\t\tconst newUserConfig = cloneDeep( userConfig );\n\n\t\t\tfor ( const { path, value } of changes ) {\n\t\t\t\tsetNestedValue( newBlockStyles, path, undefined );\n\t\t\t\tsetNestedValue(\n\t\t\t\t\tnewUserConfig,\n\t\t\t\t\t[ 'styles', 'blocks', name, ...path ],\n\t\t\t\t\tvalue\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// @wordpress/core-data doesn't support editing multiple entity types in\n\t\t\t// a single undo level. So for now, we disable @wordpress/core-data undo\n\t\t\t// tracking and implement our own Undo button in the snackbar\n\t\t\t// notification.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( { style: newBlockStyles } );\n\t\t\tsetUserConfig( () => newUserConfig, { undoIgnore: true } );\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: Title of the block e.g. 'Heading'.\n\t\t\t\t\t__( '%s styles applied.' ),\n\t\t\t\t\tgetBlockType( name ).title\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick() {\n\t\t\t\t\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\t\t\t\t\tsetAttributes( { style: blockStyles } );\n\t\t\t\t\t\t\t\tsetUserConfig( () => userConfig, {\n\t\t\t\t\t\t\t\t\tundoIgnore: true,\n\t\t\t\t\t\t\t\t} );\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}\n\t\t\t);\n\t\t}\n\t\tif ( userHasEditedBehaviors ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetBehavior( attributes.behaviors );\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: Title of the block e.g. 'Heading'.\n\t\t\t\t\t__( '%s behaviors applied.' ),\n\t\t\t\t\tgetBlockType( name ).title\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick() {\n\t\t\t\t\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\t\t\t\t\tsetBehavior( inheritedBehaviors );\n\t\t\t\t\t\t\t\tsetUserConfig( () => userConfig, {\n\t\t\t\t\t\t\t\t\tundoIgnore: true,\n\t\t\t\t\t\t\t\t} );\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}\n\t\t\t);\n\t\t}\n\t}, [ changes, attributes, userConfig, name ] );\n\n\treturn (\n\t\t<BaseControl\n\t\t\tclassName=\"edit-site-push-changes-to-global-styles-control\"\n\t\t\thelp={ sprintf(\n\t\t\t\t// translators: %s: Title of the block e.g. 'Heading'.\n\t\t\t\t__(\n\t\t\t\t\t'Apply this block’s typography, spacing, dimensions, color styles, and behaviors to all %s blocks.'\n\t\t\t\t),\n\t\t\t\tgetBlockType( name ).title\n\t\t\t) }\n\t\t>\n\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t{ __( 'Styles' ) }\n\t\t\t</BaseControl.VisualLabel>\n\t\t\t<Button\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tdisabled={ changes.length === 0 && ! userHasEditedBehaviors }\n\t\t\t\tonClick={ pushChanges }\n\t\t\t>\n\t\t\t\t{ __( 'Apply globally' ) }\n\t\t\t</Button>\n\t\t</BaseControl>\n\t);\n}\n\nconst withPushChangesToGlobalStyles = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst blockEditingMode = useBlockEditingMode();\n\t\tconst supportsStyles = SUPPORTED_STYLES.some( ( feature ) =>\n\t\t\thasBlockSupport( props.name, feature )\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t{ blockEditingMode === 'default' && supportsStyles && (\n\t\t\t\t\t<InspectorAdvancedControls>\n\t\t\t\t\t\t<PushChangesToGlobalStylesControl { ...props } />\n\t\t\t\t\t</InspectorAdvancedControls>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/edit-site/push-changes-to-global-styles',\n\twithPushChangesToGlobalStyles\n);\n"]}
|
|
@@ -20,7 +20,8 @@ var _preferences = require("@wordpress/preferences");
|
|
|
20
20
|
*/
|
|
21
21
|
const setCanvasMode = mode => ({
|
|
22
22
|
registry,
|
|
23
|
-
dispatch
|
|
23
|
+
dispatch,
|
|
24
|
+
select
|
|
24
25
|
}) => {
|
|
25
26
|
registry.dispatch(_blockEditor.store).__unstableSetEditorMode('edit');
|
|
26
27
|
|
|
@@ -28,9 +29,15 @@ const setCanvasMode = mode => ({
|
|
|
28
29
|
type: 'SET_CANVAS_MODE',
|
|
29
30
|
mode
|
|
30
31
|
}); // Check if the block list view should be open by default.
|
|
32
|
+
// If `distractionFree` mode is enabled, the block list view should not be open.
|
|
31
33
|
|
|
32
|
-
if (mode === 'edit' && registry.select(_preferences.store).get('core/edit-site', 'showListViewByDefault')) {
|
|
34
|
+
if (mode === 'edit' && registry.select(_preferences.store).get('core/edit-site', 'showListViewByDefault') && !registry.select(_preferences.store).get('core/edit-site', 'distractionFree')) {
|
|
33
35
|
dispatch.setIsListViewOpened(true);
|
|
36
|
+
} // Switch focus away from editing the template when switching to view mode.
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
if (mode === 'view' && select.isPage()) {
|
|
40
|
+
dispatch.setHasPageContentFocus(true);
|
|
34
41
|
}
|
|
35
42
|
};
|
|
36
43
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/store/private-actions.js"],"names":["setCanvasMode","mode","registry","dispatch","blockEditorStore","__unstableSetEditorMode","type","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/store/private-actions.js"],"names":["setCanvasMode","mode","registry","dispatch","select","blockEditorStore","__unstableSetEditorMode","type","preferencesStore","get","setIsListViewOpened","isPage","setHasPageContentFocus","setEditorCanvasContainerView","view"],"mappings":";;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACO,MAAMA,aAAa,GACvBC,IAAF,IACA,CAAE;AAAEC,EAAAA,QAAF;AAAYC,EAAAA,QAAZ;AAAsBC,EAAAA;AAAtB,CAAF,KAAsC;AACrCF,EAAAA,QAAQ,CAACC,QAAT,CAAmBE,kBAAnB,EAAsCC,uBAAtC,CAA+D,MAA/D;;AACAH,EAAAA,QAAQ,CAAE;AACTI,IAAAA,IAAI,EAAE,iBADG;AAETN,IAAAA;AAFS,GAAF,CAAR,CAFqC,CAMrC;AACA;;AACA,MACCA,IAAI,KAAK,MAAT,IACAC,QAAQ,CACNE,MADF,CACUI,kBADV,EAEEC,GAFF,CAEO,gBAFP,EAEyB,uBAFzB,CADA,IAIA,CAAEP,QAAQ,CACRE,MADA,CACQI,kBADR,EAEAC,GAFA,CAEK,gBAFL,EAEuB,iBAFvB,CALH,EAQE;AACDN,IAAAA,QAAQ,CAACO,mBAAT,CAA8B,IAA9B;AACA,GAlBoC,CAmBrC;;;AACA,MAAKT,IAAI,KAAK,MAAT,IAAmBG,MAAM,CAACO,MAAP,EAAxB,EAA0C;AACzCR,IAAAA,QAAQ,CAACS,sBAAT,CAAiC,IAAjC;AACA;AACD,CAzBK;AA2BP;AACA;AACA;AACA;AACA;;;;;AACO,MAAMC,4BAA4B,GACtCC,IAAF,IACA,CAAE;AAAEX,EAAAA;AAAF,CAAF,KAAoB;AACnBA,EAAAA,QAAQ,CAAE;AACTI,IAAAA,IAAI,EAAE,kCADG;AAETO,IAAAA;AAFS,GAAF,CAAR;AAIA,CAPK","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Action that switches the canvas mode.\n *\n * @param {?string} mode Canvas mode.\n */\nexport const setCanvasMode =\n\t( mode ) =>\n\t( { registry, dispatch, select } ) => {\n\t\tregistry.dispatch( blockEditorStore ).__unstableSetEditorMode( 'edit' );\n\t\tdispatch( {\n\t\t\ttype: 'SET_CANVAS_MODE',\n\t\t\tmode,\n\t\t} );\n\t\t// Check if the block list view should be open by default.\n\t\t// If `distractionFree` mode is enabled, the block list view should not be open.\n\t\tif (\n\t\t\tmode === 'edit' &&\n\t\t\tregistry\n\t\t\t\t.select( preferencesStore )\n\t\t\t\t.get( 'core/edit-site', 'showListViewByDefault' ) &&\n\t\t\t! registry\n\t\t\t\t.select( preferencesStore )\n\t\t\t\t.get( 'core/edit-site', 'distractionFree' )\n\t\t) {\n\t\t\tdispatch.setIsListViewOpened( true );\n\t\t}\n\t\t// Switch focus away from editing the template when switching to view mode.\n\t\tif ( mode === 'view' && select.isPage() ) {\n\t\t\tdispatch.setHasPageContentFocus( true );\n\t\t}\n\t};\n\n/**\n * Action that switches the editor canvas container view.\n *\n * @param {?string} view Editor canvas container view.\n */\nexport const setEditorCanvasContainerView =\n\t( view ) =>\n\t( { dispatch } ) => {\n\t\tdispatch( {\n\t\t\ttype: 'SET_EDITOR_CANVAS_CONTAINER_VIEW',\n\t\t\tview,\n\t\t} );\n\t};\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = normalizeRecordKey;
|
|
7
|
+
|
|
8
|
+
function isNumericID(str) {
|
|
9
|
+
return /^\s*\d+\s*$/.test(str);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function normalizeRecordKey(postId) {
|
|
13
|
+
if (isNumericID(postId)) {
|
|
14
|
+
postId = Number(postId);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return postId;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=normalize-record-key.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/utils/normalize-record-key.js"],"names":["isNumericID","str","test","normalizeRecordKey","postId","Number"],"mappings":";;;;;;;AAAA,SAASA,WAAT,CAAsBC,GAAtB,EAA4B;AAC3B,SAAO,cAAcC,IAAd,CAAoBD,GAApB,CAAP;AACA;;AAEc,SAASE,kBAAT,CAA6BC,MAA7B,EAAsC;AACpD,MAAKJ,WAAW,CAAEI,MAAF,CAAhB,EAA6B;AAC5BA,IAAAA,MAAM,GAAGC,MAAM,CAAED,MAAF,CAAf;AACA;;AAED,SAAOA,MAAP;AACA","sourcesContent":["function isNumericID( str ) {\n\treturn /^\\s*\\d+\\s*$/.test( str );\n}\n\nexport default function normalizeRecordKey( postId ) {\n\tif ( isNumericID( postId ) ) {\n\t\tpostId = Number( postId );\n\t}\n\n\treturn postId;\n}\n"]}
|
|
@@ -33,7 +33,7 @@ function useActivateTheme() {
|
|
|
33
33
|
const location = useLocation();
|
|
34
34
|
return async () => {
|
|
35
35
|
if ((0, _isPreviewingTheme.isPreviewingTheme)()) {
|
|
36
|
-
const activationURL = 'themes.php?action=activate&stylesheet=' + (0, _isPreviewingTheme.currentlyPreviewingTheme)() + '&_wpnonce=' + window.
|
|
36
|
+
const activationURL = 'themes.php?action=activate&stylesheet=' + (0, _isPreviewingTheme.currentlyPreviewingTheme)() + '&_wpnonce=' + window.WP_BLOCK_THEME_ACTIVATE_NONCE;
|
|
37
37
|
await window.fetch(activationURL);
|
|
38
38
|
const {
|
|
39
39
|
wp_theme_preview: themePreview,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/utils/use-activate-theme.js"],"names":["useHistory","useLocation","routerPrivateApis","useActivateTheme","history","location","activationURL","window","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/utils/use-activate-theme.js"],"names":["useHistory","useLocation","routerPrivateApis","useActivateTheme","history","location","activationURL","window","WP_BLOCK_THEME_ACTIVATE_NONCE","fetch","wp_theme_preview","themePreview","params","replace"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AATA;AACA;AACA;;AAGA;AACA;AACA;AAOA,MAAM;AAAEA,EAAAA,UAAF;AAAcC,EAAAA;AAAd,IAA8B,wBAAQC,mBAAR,CAApC;AAEA;AACA;AACA;AACA;AACA;;AACO,SAASC,gBAAT,GAA4B;AAClC,QAAMC,OAAO,GAAGJ,UAAU,EAA1B;AACA,QAAMK,QAAQ,GAAGJ,WAAW,EAA5B;AAEA,SAAO,YAAY;AAClB,QAAK,2CAAL,EAA2B;AAC1B,YAAMK,aAAa,GAClB,2CACA,kDADA,GAEA,YAFA,GAGAC,MAAM,CAACC,6BAJR;AAKA,YAAMD,MAAM,CAACE,KAAP,CAAcH,aAAd,CAAN;AACA,YAAM;AAAEI,QAAAA,gBAAgB,EAAEC,YAApB;AAAkC,WAAGC;AAArC,UACLP,QAAQ,CAACO,MADV;AAEAR,MAAAA,OAAO,CAACS,OAAR,CAAiBD,MAAjB;AACA;AACD,GAZD;AAaA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\nimport {\n\tisPreviewingTheme,\n\tcurrentlyPreviewingTheme,\n} from './is-previewing-theme';\n\nconst { useHistory, useLocation } = unlock( routerPrivateApis );\n\n/**\n * This should be refactored to use the REST API, once the REST API can activate themes.\n *\n * @return {Function} A function that activates the theme.\n */\nexport function useActivateTheme() {\n\tconst history = useHistory();\n\tconst location = useLocation();\n\n\treturn async () => {\n\t\tif ( isPreviewingTheme() ) {\n\t\t\tconst activationURL =\n\t\t\t\t'themes.php?action=activate&stylesheet=' +\n\t\t\t\tcurrentlyPreviewingTheme() +\n\t\t\t\t'&_wpnonce=' +\n\t\t\t\twindow.WP_BLOCK_THEME_ACTIVATE_NONCE;\n\t\t\tawait window.fetch( activationURL );\n\t\t\tconst { wp_theme_preview: themePreview, ...params } =\n\t\t\t\tlocation.params;\n\t\t\thistory.replace( params );\n\t\t}\n\t};\n}\n"]}
|
|
@@ -14,13 +14,11 @@ var _compose = require("@wordpress/compose");
|
|
|
14
14
|
*/
|
|
15
15
|
function useDebouncedInput(defaultValue = '') {
|
|
16
16
|
const [input, setInput] = (0, _element.useState)(defaultValue);
|
|
17
|
-
const [
|
|
18
|
-
const
|
|
17
|
+
const [debouncedInput, setDebouncedState] = (0, _element.useState)(defaultValue);
|
|
18
|
+
const setDebouncedInput = (0, _compose.useDebounce)(setDebouncedState, 250);
|
|
19
19
|
(0, _element.useEffect)(() => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}, [debounced, input]);
|
|
24
|
-
return [input, setInput, debounced];
|
|
20
|
+
setDebouncedInput(input);
|
|
21
|
+
}, [input]);
|
|
22
|
+
return [input, setInput, debouncedInput];
|
|
25
23
|
}
|
|
26
24
|
//# sourceMappingURL=use-debounced-input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/utils/use-debounced-input.js"],"names":["useDebouncedInput","defaultValue","input","setInput","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/utils/use-debounced-input.js"],"names":["useDebouncedInput","defaultValue","input","setInput","debouncedInput","setDebouncedState","setDebouncedInput"],"mappings":";;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIe,SAASA,iBAAT,CAA4BC,YAAY,GAAG,EAA3C,EAAgD;AAC9D,QAAM,CAAEC,KAAF,EAASC,QAAT,IAAsB,uBAAUF,YAAV,CAA5B;AACA,QAAM,CAAEG,cAAF,EAAkBC,iBAAlB,IAAwC,uBAAUJ,YAAV,CAA9C;AAEA,QAAMK,iBAAiB,GAAG,0BAAaD,iBAAb,EAAgC,GAAhC,CAA1B;AAEA,0BAAW,MAAM;AAChBC,IAAAA,iBAAiB,CAAEJ,KAAF,CAAjB;AACA,GAFD,EAEG,CAAEA,KAAF,CAFH;AAIA,SAAO,CAAEA,KAAF,EAASC,QAAT,EAAmBC,cAAnB,CAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState } from '@wordpress/element';\nimport { useDebounce } from '@wordpress/compose';\n\nexport default function useDebouncedInput( defaultValue = '' ) {\n\tconst [ input, setInput ] = useState( defaultValue );\n\tconst [ debouncedInput, setDebouncedState ] = useState( defaultValue );\n\n\tconst setDebouncedInput = useDebounce( setDebouncedState, 250 );\n\n\tuseEffect( () => {\n\t\tsetDebouncedInput( input );\n\t}, [ input ] );\n\n\treturn [ input, setInput, debouncedInput ];\n}\n"]}
|
|
@@ -62,12 +62,7 @@ export default function AddNewPageModal({
|
|
|
62
62
|
onSubmit: createPage
|
|
63
63
|
}, createElement(VStack, {
|
|
64
64
|
spacing: 3
|
|
65
|
-
}, createElement(TextControl
|
|
66
|
-
/* eslint-disable jsx-a11y/no-autofocus */
|
|
67
|
-
, {
|
|
68
|
-
autoFocus: true
|
|
69
|
-
/* eslint-enable jsx-a11y/no-autofocus */
|
|
70
|
-
,
|
|
65
|
+
}, createElement(TextControl, {
|
|
71
66
|
label: __('Page title'),
|
|
72
67
|
onChange: setTitle,
|
|
73
68
|
placeholder: __('No title'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/add-new-page/index.js"],"names":["Button","Modal","__experimentalHStack","HStack","__experimentalVStack","VStack","TextControl","__","sprintf","useDispatch","useState","store","coreStore","noticesStore","AddNewPageModal","onSave","onClose","isCreatingPage","setIsCreatingPage","title","setTitle","saveEntityRecord","createErrorNotice","createSuccessNotice","createPage","event","preventDefault","newPage","status","slug","throwOnError","rendered","type","error","errorMessage","message","code"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,MADD,EAECC,KAFD,EAGCC,oBAAoB,IAAIC,MAHzB,EAICC,oBAAoB,IAAIC,MAJzB,EAKCC,WALD,QAMO,uBANP;AAOA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASD,KAAK,IAAIE,YAAlB,QAAsC,o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KAe,MAAAA,iBAAiB,CAAEY,YAAF,EAAgB;AAChCF,QAAAA,IAAI,EAAE;AAD0B,OAAhB,CAAjB;AAGA,KAjCD,SAiCU;AACTd,MAAAA,iBAAiB,CAAE,KAAF,CAAjB;AACA;AACD;;AAED,SACC,cAAC,KAAD;AAAO,IAAA,KAAK,EAAGX,EAAE,CAAE,kBAAF,CAAjB;AAA0C,IAAA,cAAc,EAAGS;AAA3D,KACC;AAAM,IAAA,QAAQ,EAAGQ;AAAjB,KACC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAG;AAAlB,KACC,cAAC
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/add-new-page/index.js"],"names":["Button","Modal","__experimentalHStack","HStack","__experimentalVStack","VStack","TextControl","__","sprintf","useDispatch","useState","store","coreStore","noticesStore","AddNewPageModal","onSave","onClose","isCreatingPage","setIsCreatingPage","title","setTitle","saveEntityRecord","createErrorNotice","createSuccessNotice","createPage","event","preventDefault","newPage","status","slug","throwOnError","rendered","type","error","errorMessage","message","code"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,MADD,EAECC,KAFD,EAGCC,oBAAoB,IAAIC,MAHzB,EAICC,oBAAoB,IAAIC,MAJzB,EAKCC,WALD,QAMO,uBANP;AAOA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASD,KAAK,IAAIE,YAAlB,QAAsC,oBAAtC;AAEA,eAAe,SAASC,eAAT,CAA0B;AAAEC,EAAAA,MAAF;AAAUC,EAAAA;AAAV,CAA1B,EAAgD;AAC9D,QAAM,CAAEC,cAAF,EAAkBC,iBAAlB,IAAwCR,QAAQ,CAAE,KAAF,CAAtD;AACA,QAAM,CAAES,KAAF,EAASC,QAAT,IAAsBV,QAAQ,CAAE,EAAF,CAApC;AAEA,QAAM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c,EAAGS;AAA3D,KACC;AAAM,IAAA,QAAQ,EAAGQ;AAAjB,KACC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAG;AAAlB,KACC,cAAC,WAAD;AACC,IAAA,KAAK,EAAGjB,EAAE,CAAE,YAAF,CADX;AAEC,IAAA,QAAQ,EAAGa,QAFZ;AAGC,IAAA,WAAW,EAAGb,EAAE,CAAE,UAAF,CAHjB;AAIC,IAAA,KAAK,EAAGY;AAJT,IADD,EAOC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAG,CAAlB;AAAsB,IAAA,OAAO,EAAC;AAA9B,KACC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,UAAhB;AAA2B,IAAA,OAAO,EAAGH;AAArC,KACGT,EAAE,CAAE,QAAF,CADL,CADD,EAIC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,SADT;AAEC,IAAA,IAAI,EAAC,QAFN;AAGC,IAAA,MAAM,EAAGU,cAHV;AAIC,qBAAgBA;AAJjB,KAMGV,EAAE,CAAE,cAAF,CANL,CAJD,CAPD,CADD,CADD,CADD;AA2BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tModal,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tTextControl,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\n\nexport default function AddNewPageModal( { onSave, onClose } ) {\n\tconst [ isCreatingPage, setIsCreatingPage ] = useState( false );\n\tconst [ title, setTitle ] = useState( '' );\n\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tasync function createPage( event ) {\n\t\tevent.preventDefault();\n\n\t\tif ( isCreatingPage ) {\n\t\t\treturn;\n\t\t}\n\t\tsetIsCreatingPage( true );\n\t\ttry {\n\t\t\tconst newPage = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'page',\n\t\t\t\t{\n\t\t\t\t\tstatus: 'draft',\n\t\t\t\t\ttitle,\n\t\t\t\t\tslug: title || __( 'No title' ),\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\tonSave( newPage );\n\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: Title of the created template e.g: \"Category\".\n\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\tnewPage.title?.rendered || title\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\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 creating the page.' );\n\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} finally {\n\t\t\tsetIsCreatingPage( false );\n\t\t}\n\t}\n\n\treturn (\n\t\t<Modal title={ __( 'Draft a new page' ) } onRequestClose={ onClose }>\n\t\t\t<form onSubmit={ createPage }>\n\t\t\t\t<VStack spacing={ 3 }>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tlabel={ __( 'Page title' ) }\n\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\tplaceholder={ __( 'No title' ) }\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack spacing={ 2 } justify=\"end\">\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ onClose }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\tisBusy={ isCreatingPage }\n\t\t\t\t\t\t\taria-disabled={ isCreatingPage }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Create draft' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"]}
|
|
@@ -7,6 +7,7 @@ import { DropdownMenu } from '@wordpress/components';
|
|
|
7
7
|
import { useState } from '@wordpress/element';
|
|
8
8
|
import { __ } from '@wordpress/i18n';
|
|
9
9
|
import { plus, symbol, symbolFilled } from '@wordpress/icons';
|
|
10
|
+
import { useSelect } from '@wordpress/data';
|
|
10
11
|
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
11
12
|
/**
|
|
12
13
|
* Internal dependencies
|
|
@@ -16,6 +17,7 @@ import CreatePatternModal from '../create-pattern-modal';
|
|
|
16
17
|
import CreateTemplatePartModal from '../create-template-part-modal';
|
|
17
18
|
import SidebarButton from '../sidebar-button';
|
|
18
19
|
import { unlock } from '../../lock-unlock';
|
|
20
|
+
import { store as editSiteStore } from '../../store';
|
|
19
21
|
const {
|
|
20
22
|
useHistory
|
|
21
23
|
} = unlock(routerPrivateApis);
|
|
@@ -23,6 +25,10 @@ export default function AddNewPattern() {
|
|
|
23
25
|
const history = useHistory();
|
|
24
26
|
const [showPatternModal, setShowPatternModal] = useState(false);
|
|
25
27
|
const [showTemplatePartModal, setShowTemplatePartModal] = useState(false);
|
|
28
|
+
const isTemplatePartsMode = useSelect(select => {
|
|
29
|
+
const settings = select(editSiteStore).getSettings();
|
|
30
|
+
return !!settings.supportsTemplatePartsMode;
|
|
31
|
+
}, []);
|
|
26
32
|
|
|
27
33
|
function handleCreatePattern({
|
|
28
34
|
pattern,
|
|
@@ -53,16 +59,23 @@ export default function AddNewPattern() {
|
|
|
53
59
|
setShowTemplatePartModal(false);
|
|
54
60
|
}
|
|
55
61
|
|
|
56
|
-
|
|
57
|
-
|
|
62
|
+
const controls = [{
|
|
63
|
+
icon: symbol,
|
|
64
|
+
onClick: () => setShowPatternModal(true),
|
|
65
|
+
title: __('Create pattern')
|
|
66
|
+
}]; // Remove condition when command palette issues are resolved.
|
|
67
|
+
// See: https://github.com/WordPress/gutenberg/issues/52154.
|
|
68
|
+
|
|
69
|
+
if (!isTemplatePartsMode) {
|
|
70
|
+
controls.push({
|
|
58
71
|
icon: symbolFilled,
|
|
59
72
|
onClick: () => setShowTemplatePartModal(true),
|
|
60
73
|
title: __('Create template part')
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return createElement(Fragment, null, createElement(DropdownMenu, {
|
|
78
|
+
controls: controls,
|
|
66
79
|
toggleProps: {
|
|
67
80
|
as: SidebarButton
|
|
68
81
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/add-new-pattern/index.js"],"names":["DropdownMenu","useState","__","plus","symbol","symbolFilled","privateApis","routerPrivateApis","CreatePatternModal","CreateTemplatePartModal","SidebarButton","unlock","useHistory","AddNewPattern","history","showPatternModal","setShowPatternModal","showTemplatePartModal","setShowTemplatePartModal","handleCreatePattern","pattern","categoryId","push","postId","id","postType","categoryType","canvas","handleCreateTemplatePart","templatePart","handleError","icon","onClick","title","as"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,YAAT,QAA6B,uBAA7B;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,IAAT,EAAeC,MAAf,EAAuBC,YAAvB,QAA2C,kBAA3C;AACA,SAASC,WAAW,IAAIC,iBAAxB,QAAiD,mBAAjD;AAEA;AACA;AACA;;AACA,OAAOC,kBAAP,MAA+B,yBAA/B;AACA,OAAOC,uBAAP,MAAoC,+BAApC;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,SAASC,MAAT,QAAuB,mBAAvB;AAEA,MAAM;AAAEC,EAAAA;AAAF,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/add-new-pattern/index.js"],"names":["DropdownMenu","useState","__","plus","symbol","symbolFilled","useSelect","privateApis","routerPrivateApis","CreatePatternModal","CreateTemplatePartModal","SidebarButton","unlock","store","editSiteStore","useHistory","AddNewPattern","history","showPatternModal","setShowPatternModal","showTemplatePartModal","setShowTemplatePartModal","isTemplatePartsMode","select","settings","getSettings","supportsTemplatePartsMode","handleCreatePattern","pattern","categoryId","push","postId","id","postType","categoryType","canvas","handleCreateTemplatePart","templatePart","handleError","controls","icon","onClick","title","as"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,YAAT,QAA6B,uBAA7B;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,IAAT,EAAeC,MAAf,EAAuBC,YAAvB,QAA2C,kBAA3C;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,WAAW,IAAIC,iBAAxB,QAAiD,mBAAjD;AAEA;AACA;AACA;;AACA,OAAOC,kBAAP,MAA+B,yBAA/B;AACA,OAAOC,uBAAP,MAAoC,+BAApC;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,SAASC,MAAT,QAAuB,mBAAvB;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,aAAvC;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAiBH,MAAM,CAAEJ,iBAAF,CAA7B;AAEA,eAAe,SAASQ,aAAT,GAAyB;AACvC,QAAMC,OAAO,GAAGF,UAAU,EAA1B;AACA,QAAM,CAAEG,gBAAF,EAAoBC,mBAApB,IAA4ClB,QAAQ,CAAE,KAAF,CAA1D;AACA,QAAM,CAAEmB,qBAAF,EAAyBC,wBAAzB,IACLpB,QAAQ,CAAE,KAAF,CADT;AAEA,QAAMqB,mBAAmB,GAAGhB,SAAS,CAAIiB,MAAF,IAAc;AACpD,UAAMC,QA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,CAFzB;AAGdqB,MAAAA,KAAK,EAAExC,EAAE,CAAE,sBAAF;AAHK,KAAf;AAKA;;AAED,SACC,8BACC,cAAC,YAAD;AACC,IAAA,QAAQ,EAAGqC,QADZ;AAEC,IAAA,WAAW,EAAG;AACbI,MAAAA,EAAE,EAAEhC;AADS,KAFf;AAKC,IAAA,IAAI,EAAGR,IALR;AAMC,IAAA,KAAK,EAAGD,EAAE,CAAE,gBAAF;AANX,IADD,EASGgB,gBAAgB,IACjB,cAAC,kBAAD;AACC,IAAA,UAAU,EAAG,MAAMC,mBAAmB,CAAE,KAAF,CADvC;AAEC,IAAA,QAAQ,EAAGQ,mBAFZ;AAGC,IAAA,OAAO,EAAGW;AAHX,IAVF,EAgBGlB,qBAAqB,IACtB,cAAC,uBAAD;AACC,IAAA,UAAU,EAAG,MAAMC,wBAAwB,CAAE,KAAF,CAD5C;AAEC,IAAA,MAAM,EAAG,EAFV;AAGC,IAAA,QAAQ,EAAGe,wBAHZ;AAIC,IAAA,OAAO,EAAGE;AAJX,IAjBF,CADD;AA2BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { DropdownMenu } from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { plus, symbol, symbolFilled } from '@wordpress/icons';\nimport { useSelect } from '@wordpress/data';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport CreatePatternModal from '../create-pattern-modal';\nimport CreateTemplatePartModal from '../create-template-part-modal';\nimport SidebarButton from '../sidebar-button';\nimport { unlock } from '../../lock-unlock';\nimport { store as editSiteStore } from '../../store';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nexport default function AddNewPattern() {\n\tconst history = useHistory();\n\tconst [ showPatternModal, setShowPatternModal ] = useState( false );\n\tconst [ showTemplatePartModal, setShowTemplatePartModal ] =\n\t\tuseState( false );\n\tconst isTemplatePartsMode = useSelect( ( select ) => {\n\t\tconst settings = select( editSiteStore ).getSettings();\n\t\treturn !! settings.supportsTemplatePartsMode;\n\t}, [] );\n\n\tfunction handleCreatePattern( { pattern, categoryId } ) {\n\t\tsetShowPatternModal( false );\n\n\t\thistory.push( {\n\t\t\tpostId: pattern.id,\n\t\t\tpostType: 'wp_block',\n\t\t\tcategoryType: 'wp_block',\n\t\t\tcategoryId,\n\t\t\tcanvas: 'edit',\n\t\t} );\n\t}\n\n\tfunction handleCreateTemplatePart( templatePart ) {\n\t\tsetShowTemplatePartModal( false );\n\n\t\t// Navigate to the created template part editor.\n\t\thistory.push( {\n\t\t\tpostId: templatePart.id,\n\t\t\tpostType: 'wp_template_part',\n\t\t\tcanvas: 'edit',\n\t\t} );\n\t}\n\n\tfunction handleError() {\n\t\tsetShowPatternModal( false );\n\t\tsetShowTemplatePartModal( false );\n\t}\n\n\tconst controls = [\n\t\t{\n\t\t\ticon: symbol,\n\t\t\tonClick: () => setShowPatternModal( true ),\n\t\t\ttitle: __( 'Create pattern' ),\n\t\t},\n\t];\n\n\t// Remove condition when command palette issues are resolved.\n\t// See: https://github.com/WordPress/gutenberg/issues/52154.\n\tif ( ! isTemplatePartsMode ) {\n\t\tcontrols.push( {\n\t\t\ticon: symbolFilled,\n\t\t\tonClick: () => setShowTemplatePartModal( true ),\n\t\t\ttitle: __( 'Create template part' ),\n\t\t} );\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<DropdownMenu\n\t\t\t\tcontrols={ controls }\n\t\t\t\ttoggleProps={ {\n\t\t\t\t\tas: SidebarButton,\n\t\t\t\t} }\n\t\t\t\ticon={ plus }\n\t\t\t\tlabel={ __( 'Create pattern' ) }\n\t\t\t/>\n\t\t\t{ showPatternModal && (\n\t\t\t\t<CreatePatternModal\n\t\t\t\t\tcloseModal={ () => setShowPatternModal( false ) }\n\t\t\t\t\tonCreate={ handleCreatePattern }\n\t\t\t\t\tonError={ handleError }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showTemplatePartModal && (\n\t\t\t\t<CreateTemplatePartModal\n\t\t\t\t\tcloseModal={ () => setShowTemplatePartModal( false ) }\n\t\t\t\t\tblocks={ [] }\n\t\t\t\t\tonCreate={ handleCreateTemplatePart }\n\t\t\t\t\tonError={ handleError }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
|