@wordpress/edit-site 5.14.0 → 5.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/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 +21 -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 +87 -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 +1 -1
- package/build/components/editor/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/layout/index.js +8 -3
- package/build/components/layout/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 +95 -30
- 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 +102 -121
- 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 +2 -23
- package/build/components/page-template-parts/index.js.map +1 -1
- package/build/components/resizable-frame/index.js +78 -36
- package/build/components/resizable-frame/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-navigation-screen/index.js +14 -8
- package/build/components/sidebar-navigation-screen/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 +4 -3
- 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-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 +33 -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 +3 -2
- 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 +11 -3
- 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 +5 -2
- package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/index.js +72 -51
- 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/site-hub/index.js +24 -11
- 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-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 +78 -20
- package/build/hooks/commands/use-common-commands.js.map +1 -1
- package/build/hooks/push-changes-to-global-styles/index.js +56 -10
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build/store/private-actions.js +7 -1
- 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-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 +19 -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 +89 -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 +1 -1
- package/build-module/components/editor/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/layout/index.js +8 -3
- package/build-module/components/layout/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 +96 -33
- 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 +103 -122
- 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 +3 -22
- package/build-module/components/page-template-parts/index.js.map +1 -1
- package/build-module/components/resizable-frame/index.js +79 -39
- package/build-module/components/resizable-frame/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-navigation-screen/index.js +15 -9
- package/build-module/components/sidebar-navigation-screen/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 +4 -3
- 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-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 +33 -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 +3 -2
- 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 +11 -3
- 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 +4 -2
- package/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/index.js +76 -53
- 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/site-hub/index.js +24 -11
- 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-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 +74 -20
- package/build-module/hooks/commands/use-common-commands.js.map +1 -1
- package/build-module/hooks/push-changes-to-global-styles/index.js +57 -10
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build-module/store/private-actions.js +7 -1
- 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-style/style-rtl.css +221 -63
- package/build-style/style.css +221 -63
- package/package.json +39 -40
- package/src/components/add-new-page/index.js +0 -3
- package/src/components/add-new-pattern/index.js +23 -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 +99 -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 +2 -2
- package/src/components/header-edit-mode/document-actions/style.scss +4 -0
- package/src/components/header-edit-mode/index.js +29 -22
- package/src/components/layout/index.js +16 -2
- package/src/components/layout/style.scss +2 -1
- 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 +160 -72
- package/src/components/page-patterns/rename-menu-item.js +115 -0
- package/src/components/page-patterns/style.scss +140 -30
- package/src/components/page-patterns/use-patterns.js +102 -172
- package/src/components/page-template-parts/add-new-template-part.js +57 -0
- package/src/components/page-template-parts/index.js +3 -22
- package/src/components/resizable-frame/index.js +102 -34
- package/src/components/resizable-frame/style.scss +9 -9
- 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-navigation-item/style.scss +5 -12
- package/src/components/sidebar-navigation-screen/index.js +14 -7
- package/src/components/sidebar-navigation-screen/style.scss +14 -0
- 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 +15 -5
- package/src/components/sidebar-navigation-screen-navigation-menus/constants.js +2 -0
- 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 +39 -29
- package/src/components/sidebar-navigation-screen-pattern/index.js +5 -2
- package/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +2 -1
- 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 +12 -2
- package/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js +5 -2
- package/src/components/sidebar-navigation-screen-patterns/index.js +103 -98
- 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/site-hub/index.js +45 -28
- package/src/components/site-hub/style.scss +13 -0
- 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-path-with-url.js +73 -66
- 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 +56 -23
- package/src/hooks/push-changes-to-global-styles/index.js +63 -9
- package/src/store/private-actions.js +5 -1
- 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/build/components/code-editor/code-editor-text-area.js +0 -96
- package/build/components/code-editor/code-editor-text-area.js.map +0 -1
- package/build/components/keyboard-shortcuts/index.js +0 -148
- package/build/components/keyboard-shortcuts/index.js.map +0 -1
- package/build/components/page-actions/delete-page-menu-item.js.map +0 -1
- package/build/components/page-content-focus-manager/constants.js +0 -9
- package/build/components/page-content-focus-manager/constants.js.map +0 -1
- package/build-module/components/code-editor/code-editor-text-area.js +0 -84
- package/build-module/components/code-editor/code-editor-text-area.js.map +0 -1
- package/build-module/components/keyboard-shortcuts/index.js +0 -132
- package/build-module/components/keyboard-shortcuts/index.js.map +0 -1
- package/build-module/components/page-actions/delete-page-menu-item.js.map +0 -1
- package/build-module/components/page-content-focus-manager/constants.js +0 -2
- package/build-module/components/page-content-focus-manager/constants.js.map +0 -1
- package/src/components/code-editor/code-editor-text-area.js +0 -84
- package/src/components/keyboard-shortcuts/index.js +0 -137
- package/src/components/page-content-focus-manager/constants.js +0 -5
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import { createElement, Fragment } from "@wordpress/element";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* External dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { get, set } from 'lodash';
|
|
7
3
|
/**
|
|
8
4
|
* WordPress dependencies
|
|
9
5
|
*/
|
|
10
|
-
|
|
11
6
|
import { addFilter } from '@wordpress/hooks';
|
|
12
7
|
import { createHigherOrderComponent } from '@wordpress/compose';
|
|
13
8
|
import { InspectorAdvancedControls, store as blockEditorStore, privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
14
9
|
import { BaseControl, Button } from '@wordpress/components';
|
|
15
10
|
import { __, sprintf } from '@wordpress/i18n';
|
|
16
|
-
import { __EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY, getBlockType } from '@wordpress/blocks';
|
|
11
|
+
import { __EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY, getBlockType, hasBlockSupport } from '@wordpress/blocks';
|
|
17
12
|
import { useContext, useMemo, useCallback } from '@wordpress/element';
|
|
18
13
|
import { useDispatch } from '@wordpress/data';
|
|
19
14
|
import { store as noticesStore } from '@wordpress/notices';
|
|
@@ -85,6 +80,15 @@ const STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {
|
|
|
85
80
|
'typography.fontSize': 'fontSize',
|
|
86
81
|
'typography.fontFamily': 'fontFamily'
|
|
87
82
|
};
|
|
83
|
+
const SUPPORTED_STYLES = ['border', 'color', 'spacing', 'typography'];
|
|
84
|
+
|
|
85
|
+
const getValueFromObjectPath = (object, path) => {
|
|
86
|
+
let value = object;
|
|
87
|
+
path.forEach(fieldName => {
|
|
88
|
+
value = value?.[fieldName];
|
|
89
|
+
});
|
|
90
|
+
return value;
|
|
91
|
+
};
|
|
88
92
|
|
|
89
93
|
function useChangesToPush(name, attributes) {
|
|
90
94
|
const supports = useSupportedStyles(name);
|
|
@@ -98,13 +102,55 @@ function useChangesToPush(name, attributes) {
|
|
|
98
102
|
} = STYLE_PROPERTY[key];
|
|
99
103
|
const presetAttributeKey = path.join('.');
|
|
100
104
|
const presetAttributeValue = attributes[STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE[presetAttributeKey]];
|
|
101
|
-
const value = presetAttributeValue ? `var:preset|${STYLE_PATH_TO_CSS_VAR_INFIX[presetAttributeKey]}|${presetAttributeValue}` :
|
|
105
|
+
const value = presetAttributeValue ? `var:preset|${STYLE_PATH_TO_CSS_VAR_INFIX[presetAttributeKey]}|${presetAttributeValue}` : getValueFromObjectPath(attributes.style, path);
|
|
102
106
|
return value ? [{
|
|
103
107
|
path,
|
|
104
108
|
value
|
|
105
109
|
}] : [];
|
|
106
110
|
}), [supports, name, attributes]);
|
|
107
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Sets the value at path of object.
|
|
114
|
+
* If a portion of path doesn’t exist, it’s created.
|
|
115
|
+
* Arrays are created for missing index properties while objects are created
|
|
116
|
+
* for all other missing properties.
|
|
117
|
+
*
|
|
118
|
+
* This function intentionally mutates the input object.
|
|
119
|
+
*
|
|
120
|
+
* Inspired by _.set().
|
|
121
|
+
*
|
|
122
|
+
* @see https://lodash.com/docs/4.17.15#set
|
|
123
|
+
*
|
|
124
|
+
* @todo Needs to be deduplicated with its copy in `@wordpress/core-data`.
|
|
125
|
+
*
|
|
126
|
+
* @param {Object} object Object to modify
|
|
127
|
+
* @param {Array} path Path of the property to set.
|
|
128
|
+
* @param {*} value Value to set.
|
|
129
|
+
*/
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
function setNestedValue(object, path, value) {
|
|
133
|
+
if (!object || typeof object !== 'object') {
|
|
134
|
+
return object;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
path.reduce((acc, key, idx) => {
|
|
138
|
+
if (acc[key] === undefined) {
|
|
139
|
+
if (Number.isInteger(path[idx + 1])) {
|
|
140
|
+
acc[key] = [];
|
|
141
|
+
} else {
|
|
142
|
+
acc[key] = {};
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (idx === path.length - 1) {
|
|
147
|
+
acc[key] = value;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return acc[key];
|
|
151
|
+
}, object);
|
|
152
|
+
return object;
|
|
153
|
+
}
|
|
108
154
|
|
|
109
155
|
function cloneDeep(object) {
|
|
110
156
|
return !object ? {} : JSON.parse(JSON.stringify(object));
|
|
@@ -141,8 +187,8 @@ function PushChangesToGlobalStylesControl({
|
|
|
141
187
|
path,
|
|
142
188
|
value
|
|
143
189
|
} of changes) {
|
|
144
|
-
|
|
145
|
-
|
|
190
|
+
setNestedValue(newBlockStyles, path, undefined);
|
|
191
|
+
setNestedValue(newUserConfig, ['styles', 'blocks', name, ...path], value);
|
|
146
192
|
} // @wordpress/core-data doesn't support editing multiple entity types in
|
|
147
193
|
// a single undo level. So for now, we disable @wordpress/core-data undo
|
|
148
194
|
// tracking and implement our own Undo button in the snackbar
|
|
@@ -190,8 +236,9 @@ function PushChangesToGlobalStylesControl({
|
|
|
190
236
|
|
|
191
237
|
const withPushChangesToGlobalStyles = createHigherOrderComponent(BlockEdit => props => {
|
|
192
238
|
const blockEditingMode = useBlockEditingMode();
|
|
239
|
+
const supportsStyles = SUPPORTED_STYLES.some(feature => hasBlockSupport(props.name, feature));
|
|
193
240
|
return createElement(Fragment, null, createElement(BlockEdit, { ...props
|
|
194
|
-
}), blockEditingMode === 'default' && createElement(InspectorAdvancedControls, null, createElement(PushChangesToGlobalStylesControl, { ...props
|
|
241
|
+
}), blockEditingMode === 'default' && supportsStyles && createElement(InspectorAdvancedControls, null, createElement(PushChangesToGlobalStylesControl, { ...props
|
|
195
242
|
})));
|
|
196
243
|
});
|
|
197
244
|
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":["get","set","addFilter","createHigherOrderComponent","InspectorAdvancedControls","store","blockEditorStore","privateApis","blockEditorPrivateApis","BaseControl","Button","__","sprintf","__EXPERIMENTAL_STYLE_PROPERTY","STYLE_PROPERTY","getBlockType","useContext","useMemo","useCallback","useDispatch","noticesStore","useSupportedStyles","unlock","GlobalStylesContext","useBlockEditingMode","STYLE_PATH_TO_CSS_VAR_INFIX","STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE","useChangesToPush","name","attributes","supports","flatMap","key","value","path","presetAttributeKey","join","presetAttributeValue","style","cloneDeep","object","JSON","parse","stringify","PushChangesToGlobalStylesControl","setAttributes","changes","user","userConfig","setUserConfig","__unstableMarkNextChangeAsNotPersistent","createSuccessNotice","pushChanges","length","blockStyles","newBlockStyles","newUserConfig","undefined","undoIgnore","title","type","actions","label","onClick","withPushChangesToGlobalStyles","BlockEdit","props","blockEditingMode"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,EAAcC,GAAd,QAAyB,QAAzB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,0BAAT,QAA2C,oBAA3C;AACA,SACCC,yBADD,EAECC,KAAK,IAAIC,gBAFV,EAGCC,WAAW,IAAIC,sBAHhB,QAIO,yBAJP;AAKA,SAASC,WAAT,EAAsBC,MAAtB,QAAoC,uBAApC;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SACCC,6BAA6B,IAAIC,cADlC,EAECC,YAFD,QAGO,mBAHP;AAIA,SAASC,UAAT,EAA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OAAgB0C;AAAhB,IADD,EAEGC,gBAAgB,KAAK,SAArB,IACD,cAAC,yBAAD,QACC,cAAC,gCAAD,OAAuCD;AAAvC,IADD,CAHF,CADD;AAUA,CAb8D,CAAhE;AAgBAhE,SAAS,CACR,kBADQ,EAER,8CAFQ,EAGR8D,6BAHQ,CAAT","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":["addFilter","createHigherOrderComponent","InspectorAdvancedControls","store","blockEditorStore","privateApis","blockEditorPrivateApis","BaseControl","Button","__","sprintf","__EXPERIMENTAL_STYLE_PROPERTY","STYLE_PROPERTY","getBlockType","hasBlockSupport","useContext","useMemo","useCallback","useDispatch","noticesStore","useSupportedStyles","unlock","GlobalStylesContext","useBlockEditingMode","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","presetAttributeKey","join","presetAttributeValue","style","setNestedValue","reduce","acc","idx","undefined","Number","isInteger","length","cloneDeep","JSON","parse","stringify","PushChangesToGlobalStylesControl","setAttributes","changes","user","userConfig","setUserConfig","__unstableMarkNextChangeAsNotPersistent","createSuccessNotice","pushChanges","blockStyles","newBlockStyles","newUserConfig","undoIgnore","title","type","actions","label","onClick","withPushChangesToGlobalStyles","BlockEdit","props","blockEditingMode","supportsStyles","some","feature"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,kBAA1B;AACA,SAASC,0BAAT,QAA2C,oBAA3C;AACA,SACCC,yBADD,EAECC,KAAK,IAAIC,gBAFV,EAGCC,WAAW,IAAIC,sBAHhB,QAIO,yBAJP;AAKA,SAASC,WAAT,EAAsBC,MAAtB,QAAoC,uBAApC;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SACCC,6BAA6B,IAAIC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AMsD,cAAc,GAAGnD,gBAAgB,CAACoD,IAAjB,CAAyBC,OAAF,IAC7CjE,eAAe,CAAE6D,KAAK,CAACzC,IAAR,EAAc6C,OAAd,CADO,CAAvB;AAIA,SACC,8BACC,cAAC,SAAD,OAAgBJ;AAAhB,IADD,EAEGC,gBAAgB,KAAK,SAArB,IAAkCC,cAAlC,IACD,cAAC,yBAAD,QACC,cAAC,gCAAD,OAAuCF;AAAvC,IADD,CAHF,CADD;AAUA,CAjB8D,CAAhE;AAoBA3E,SAAS,CACR,kBADQ,EAER,8CAFQ,EAGRyE,6BAHQ,CAAT","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 { 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\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, name, 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 { 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\tsetNestedValue( newBlockStyles, path, undefined );\n\t\t\tsetNestedValue(\n\t\t\t\tnewUserConfig,\n\t\t\t\t[ 'styles', 'blocks', name, ...path ],\n\t\t\t\tvalue\n\t\t\t);\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\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"]}
|
|
@@ -11,7 +11,8 @@ import { store as preferencesStore } from '@wordpress/preferences';
|
|
|
11
11
|
|
|
12
12
|
export const setCanvasMode = mode => ({
|
|
13
13
|
registry,
|
|
14
|
-
dispatch
|
|
14
|
+
dispatch,
|
|
15
|
+
select
|
|
15
16
|
}) => {
|
|
16
17
|
registry.dispatch(blockEditorStore).__unstableSetEditorMode('edit');
|
|
17
18
|
|
|
@@ -22,6 +23,11 @@ export const setCanvasMode = mode => ({
|
|
|
22
23
|
|
|
23
24
|
if (mode === 'edit' && registry.select(preferencesStore).get('core/edit-site', 'showListViewByDefault')) {
|
|
24
25
|
dispatch.setIsListViewOpened(true);
|
|
26
|
+
} // Switch focus away from editing the template when switching to view mode.
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
if (mode === 'view' && select.isPage()) {
|
|
30
|
+
dispatch.setHasPageContentFocus(true);
|
|
25
31
|
}
|
|
26
32
|
};
|
|
27
33
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/store/private-actions.js"],"names":["store","blockEditorStore","preferencesStore","setCanvasMode","mode","registry","dispatch","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/store/private-actions.js"],"names":["store","blockEditorStore","preferencesStore","setCanvasMode","mode","registry","dispatch","select","__unstableSetEditorMode","type","get","setIsListViewOpened","isPage","setHasPageContentFocus","setEditorCanvasContainerView","view"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,gBAAlB,QAA0C,yBAA1C;AACA,SAASD,KAAK,IAAIE,gBAAlB,QAA0C,wBAA1C;AAEA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,aAAa,GACvBC,IAAF,IACA,CAAE;AAAEC,EAAAA,QAAF;AAAYC,EAAAA,QAAZ;AAAsBC,EAAAA;AAAtB,CAAF,KAAsC;AACrCF,EAAAA,QAAQ,CAACC,QAAT,CAAmBL,gBAAnB,EAAsCO,uBAAtC,CAA+D,MAA/D;;AACAF,EAAAA,QAAQ,CAAE;AACTG,IAAAA,IAAI,EAAE,iBADG;AAETL,IAAAA;AAFS,GAAF,CAAR,CAFqC,CAMrC;;AACA,MACCA,IAAI,KAAK,MAAT,IACAC,QAAQ,CACNE,MADF,CACUL,gBADV,EAEEQ,GAFF,CAEO,gBAFP,EAEyB,uBAFzB,CAFD,EAKE;AACDJ,IAAAA,QAAQ,CAACK,mBAAT,CAA8B,IAA9B;AACA,GAdoC,CAerC;;;AACA,MAAKP,IAAI,KAAK,MAAT,IAAmBG,MAAM,CAACK,MAAP,EAAxB,EAA0C;AACzCN,IAAAA,QAAQ,CAACO,sBAAT,CAAiC,IAAjC;AACA;AACD,CArBK;AAuBP;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,4BAA4B,GACtCC,IAAF,IACA,CAAE;AAAET,EAAAA;AAAF,CAAF,KAAoB;AACnBA,EAAAA,QAAQ,CAAE;AACTG,IAAAA,IAAI,EAAE,kCADG;AAETM,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\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) {\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,12 @@
|
|
|
1
|
+
function isNumericID(str) {
|
|
2
|
+
return /^\s*\d+\s*$/.test(str);
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export default function normalizeRecordKey(postId) {
|
|
6
|
+
if (isNumericID(postId)) {
|
|
7
|
+
postId = Number(postId);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return postId;
|
|
11
|
+
}
|
|
12
|
+
//# 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;;AAED,eAAe,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"]}
|
|
@@ -23,7 +23,7 @@ export function useActivateTheme() {
|
|
|
23
23
|
const location = useLocation();
|
|
24
24
|
return async () => {
|
|
25
25
|
if (isPreviewingTheme()) {
|
|
26
|
-
const activationURL = 'themes.php?action=activate&stylesheet=' + currentlyPreviewingTheme() + '&_wpnonce=' + window.
|
|
26
|
+
const activationURL = 'themes.php?action=activate&stylesheet=' + currentlyPreviewingTheme() + '&_wpnonce=' + window.WP_BLOCK_THEME_ACTIVATE_NONCE;
|
|
27
27
|
await window.fetch(activationURL);
|
|
28
28
|
const {
|
|
29
29
|
wp_theme_preview: themePreview,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/utils/use-activate-theme.js"],"names":["privateApis","routerPrivateApis","unlock","isPreviewingTheme","currentlyPreviewingTheme","useHistory","useLocation","useActivateTheme","history","location","activationURL","window","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/utils/use-activate-theme.js"],"names":["privateApis","routerPrivateApis","unlock","isPreviewingTheme","currentlyPreviewingTheme","useHistory","useLocation","useActivateTheme","history","location","activationURL","window","WP_BLOCK_THEME_ACTIVATE_NONCE","fetch","wp_theme_preview","themePreview","params","replace"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,IAAIC,iBAAxB,QAAiD,mBAAjD;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,gBAAvB;AACA,SACCC,iBADD,EAECC,wBAFD,QAGO,uBAHP;AAKA,MAAM;AAAEC,EAAAA,UAAF;AAAcC,EAAAA;AAAd,IAA8BJ,MAAM,CAAED,iBAAF,CAA1C;AAEA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASM,gBAAT,GAA4B;AAClC,QAAMC,OAAO,GAAGH,UAAU,EAA1B;AACA,QAAMI,QAAQ,GAAGH,WAAW,EAA5B;AAEA,SAAO,YAAY;AAClB,QAAKH,iBAAiB,EAAtB,EAA2B;AAC1B,YAAMO,aAAa,GAClB,2CACAN,wBAAwB,EADxB,GAEA,YAFA,GAGAO,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"]}
|