@wordpress/block-editor 12.13.0 → 12.14.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/block-heading-level-dropdown/index.js +1 -1
- package/build/components/block-heading-level-dropdown/index.js.map +1 -1
- package/build/components/block-list/index.js +2 -9
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-list-appender/index.js +16 -3
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-quick-navigation/index.js +6 -4
- package/build/components/block-quick-navigation/index.js.map +1 -1
- package/build/components/block-styles/index.js +0 -8
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-switcher/pattern-transformations-menu.js +18 -14
- package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build/components/block-tools/back-compat.js +2 -2
- package/build/components/block-tools/back-compat.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +11 -81
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/block-tools/empty-block-inserter.js +56 -0
- package/build/components/block-tools/empty-block-inserter.js.map +1 -0
- package/build/components/block-tools/index.js +48 -9
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/selected-block-tools.js +113 -0
- package/build/components/block-tools/selected-block-tools.js.map +1 -0
- package/build/components/block-tools/use-selected-block-tool-props.js +56 -0
- package/build/components/block-tools/use-selected-block-tool-props.js.map +1 -0
- package/build/components/editable-text/index.js +1 -2
- package/build/components/editable-text/index.js.map +1 -1
- package/build/components/iframe/index.js +4 -3
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/{explorer.js → index.js} +7 -7
- package/build/components/inserter/block-patterns-explorer/index.js.map +1 -0
- package/build/components/inserter/block-patterns-explorer/{sidebar.js → pattern-explorer-sidebar.js} +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -0
- package/build/components/inserter/block-patterns-explorer/{patterns-list.js → pattern-list.js} +4 -4
- package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -0
- package/build/components/inserter/block-patterns-tab/index.js +75 -0
- package/build/components/inserter/block-patterns-tab/index.js.map +1 -0
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +48 -0
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -0
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +108 -0
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -0
- package/build/components/inserter/{block-patterns-filter.js → block-patterns-tab/patterns-filter.js} +18 -34
- package/build/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -0
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.js +55 -0
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -0
- package/build/components/inserter/block-patterns-tab/utils.js +70 -0
- package/build/components/inserter/block-patterns-tab/utils.js.map +1 -0
- package/build/components/inserter/media-tab/media-list.js +9 -5
- package/build/components/inserter/media-tab/media-list.js.map +1 -1
- package/build/components/inserter/media-tab/media-preview.js +15 -12
- package/build/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build/components/inserter/menu.js +3 -4
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/link-control/index.js +6 -5
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +39 -0
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +16 -3
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/index.js +3 -2
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +69 -18
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/provider/use-block-sync.js +1 -14
- package/build/components/provider/use-block-sync.js.map +1 -1
- package/build/components/rich-text/index.js +0 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +3 -1
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/native/format-edit.js +45 -0
- package/build/components/rich-text/native/format-edit.js.map +1 -0
- package/build/components/rich-text/native/get-format-colors.native.js +41 -0
- package/build/components/rich-text/native/get-format-colors.native.js.map +1 -0
- package/build/components/rich-text/native/index.js +9 -0
- package/build/components/rich-text/native/index.js.map +1 -0
- package/build/components/rich-text/native/index.native.js +1158 -0
- package/build/components/rich-text/native/index.native.js.map +1 -0
- package/build/components/rich-text/native/toolbar-button-with-options.native.js +58 -0
- package/build/components/rich-text/native/toolbar-button-with-options.native.js.map +1 -0
- package/build/components/rich-text/native/use-format-types.js +111 -0
- package/build/components/rich-text/native/use-format-types.js.map +1 -0
- package/build/components/rich-text/use-paste-handler.js +2 -5
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/url-popover/image-url-input-ui.js +2 -1
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +7 -3
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/hooks/align.js +10 -10
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/align.native.js +2 -2
- package/build/hooks/align.native.js.map +1 -1
- package/build/hooks/anchor.js +7 -6
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/background.js +16 -4
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/block-hooks.js +7 -8
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/hooks/block-rename-ui.js +7 -5
- package/build/hooks/block-rename-ui.js.map +1 -1
- package/build/hooks/content-lock-ui.js +5 -5
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/custom-class-name.js +8 -7
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/custom-fields.js +4 -4
- package/build/hooks/custom-fields.js.map +1 -1
- package/build/hooks/duotone.js +9 -20
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/layout.js +90 -86
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/position.js +10 -9
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/style.js +10 -13
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/utils.js +30 -0
- package/build/hooks/utils.js.map +1 -1
- package/build/private-apis.js +3 -0
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +30 -37
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +18 -0
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +16 -13
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-heading-level-dropdown/index.js +1 -1
- package/build-module/components/block-heading-level-dropdown/index.js.map +1 -1
- package/build-module/components/block-list/index.js +3 -10
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-list-appender/index.js +16 -3
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-quick-navigation/index.js +7 -5
- package/build-module/components/block-quick-navigation/index.js.map +1 -1
- package/build-module/components/block-styles/index.js +0 -8
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-switcher/pattern-transformations-menu.js +17 -13
- package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build-module/components/block-tools/back-compat.js +1 -1
- package/build-module/components/block-tools/back-compat.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +11 -80
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/block-tools/empty-block-inserter.js +48 -0
- package/build-module/components/block-tools/empty-block-inserter.js.map +1 -0
- package/build-module/components/block-tools/index.js +48 -9
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/selected-block-tools.js +105 -0
- package/build-module/components/block-tools/selected-block-tools.js.map +1 -0
- package/build-module/components/block-tools/use-selected-block-tool-props.js +50 -0
- package/build-module/components/block-tools/use-selected-block-tool-props.js.map +1 -0
- package/build-module/components/editable-text/index.js +1 -2
- package/build-module/components/editable-text/index.js.map +1 -1
- package/build-module/components/iframe/index.js +4 -3
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/{explorer.js → index.js} +5 -5
- package/build-module/components/inserter/block-patterns-explorer/index.js.map +1 -0
- package/build-module/components/inserter/block-patterns-explorer/{sidebar.js → pattern-explorer-sidebar.js} +1 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -0
- package/build-module/components/inserter/block-patterns-explorer/{patterns-list.js → pattern-list.js} +2 -2
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab/index.js +66 -0
- package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +42 -0
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +100 -0
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -0
- package/build-module/components/inserter/{block-patterns-filter.js → block-patterns-tab/patterns-filter.js} +7 -20
- package/build-module/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js +47 -0
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab/utils.js +58 -0
- package/build-module/components/inserter/block-patterns-tab/utils.js.map +1 -0
- package/build-module/components/inserter/media-tab/media-list.js +9 -5
- package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-preview.js +15 -12
- package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build-module/components/inserter/menu.js +4 -3
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/link-control/index.js +7 -6
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +39 -0
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +16 -3
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/index.js +3 -2
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +69 -17
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +1 -14
- package/build-module/components/provider/use-block-sync.js.map +1 -1
- package/build-module/components/rich-text/index.js +0 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +3 -1
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/native/format-edit.js +38 -0
- package/build-module/components/rich-text/native/format-edit.js.map +1 -0
- package/build-module/components/rich-text/native/get-format-colors.native.js +34 -0
- package/build-module/components/rich-text/native/get-format-colors.native.js.map +1 -0
- package/build-module/components/rich-text/native/index.js +2 -0
- package/build-module/components/rich-text/native/index.js.map +1 -0
- package/build-module/components/rich-text/native/index.native.js +1148 -0
- package/build-module/components/rich-text/native/index.native.js.map +1 -0
- package/build-module/components/rich-text/native/toolbar-button-with-options.native.js +51 -0
- package/build-module/components/rich-text/native/toolbar-button-with-options.native.js.map +1 -0
- package/build-module/components/rich-text/native/use-format-types.js +104 -0
- package/build-module/components/rich-text/native/use-format-types.js.map +1 -0
- package/build-module/components/rich-text/use-paste-handler.js +2 -5
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js +2 -1
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +7 -3
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/hooks/align.js +8 -8
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/align.native.js +2 -2
- package/build-module/hooks/align.native.js.map +1 -1
- package/build-module/hooks/anchor.js +5 -4
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/background.js +17 -5
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/block-hooks.js +5 -6
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/hooks/block-rename-ui.js +5 -3
- package/build-module/hooks/block-rename-ui.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +3 -3
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/custom-class-name.js +6 -5
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/custom-fields.js +4 -4
- package/build-module/hooks/custom-fields.js.map +1 -1
- package/build-module/hooks/duotone.js +10 -21
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/layout.js +90 -86
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/position.js +11 -10
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/style.js +10 -13
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/utils.js +30 -1
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/private-apis.js +4 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +29 -37
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +17 -0
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +15 -13
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +16 -15
- package/build-style/style.css +16 -15
- package/package.json +31 -31
- package/src/components/block-heading-level-dropdown/index.js +1 -1
- package/src/components/block-list/index.js +4 -18
- package/src/components/block-list-appender/index.js +20 -4
- package/src/components/block-quick-navigation/index.js +11 -5
- package/src/components/block-styles/index.js +0 -10
- package/src/components/block-switcher/pattern-transformations-menu.js +20 -14
- package/src/components/block-toolbar/style.scss +8 -0
- package/src/components/block-tools/back-compat.js +1 -1
- package/src/components/block-tools/block-contextual-toolbar.js +11 -134
- package/src/components/block-tools/empty-block-inserter.js +56 -0
- package/src/components/block-tools/index.js +72 -16
- package/src/components/block-tools/selected-block-tools.js +127 -0
- package/src/components/block-tools/style.scss +0 -10
- package/src/components/block-tools/use-selected-block-tool-props.js +66 -0
- package/src/components/editable-text/index.js +1 -8
- package/src/components/iframe/index.js +4 -3
- package/src/components/inserter/block-patterns-explorer/{explorer.js → index.js} +4 -4
- package/src/components/inserter/block-patterns-explorer/{patterns-list.js → pattern-list.js} +4 -1
- package/src/components/inserter/block-patterns-tab/index.js +118 -0
- package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +48 -0
- package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +175 -0
- package/src/components/inserter/{block-patterns-filter.js → block-patterns-tab/patterns-filter.js} +15 -21
- package/src/components/inserter/block-patterns-tab/use-pattern-categories.js +96 -0
- package/src/components/inserter/block-patterns-tab/utils.js +76 -0
- package/src/components/inserter/media-tab/media-list.js +7 -7
- package/src/components/inserter/media-tab/media-preview.js +27 -22
- package/src/components/inserter/menu.js +4 -5
- package/src/components/link-control/README.md +2 -2
- package/src/components/link-control/index.js +15 -6
- package/src/components/link-control/style.scss +8 -5
- package/src/components/list-view/block-select-button.js +44 -1
- package/src/components/list-view/block.js +11 -11
- package/src/components/list-view/index.js +2 -0
- package/src/components/media-replace-flow/style.scss +2 -2
- package/src/components/navigable-toolbar/index.js +71 -25
- package/src/components/plain-text/README.md +3 -3
- package/src/components/provider/use-block-sync.js +2 -21
- package/src/components/rich-text/README.md +9 -8
- package/src/components/rich-text/index.js +0 -1
- package/src/components/rich-text/index.native.js +3 -1
- package/src/components/rich-text/native/format-edit.js +44 -0
- package/src/components/rich-text/native/get-format-colors.native.js +54 -0
- package/src/components/rich-text/native/index.js +1 -0
- package/src/components/rich-text/native/index.native.js +1363 -0
- package/src/components/rich-text/native/style.native.scss +28 -0
- package/src/components/rich-text/native/test/__snapshots__/index.native.js.snap +79 -0
- package/src/components/rich-text/native/test/index.native.js +278 -0
- package/src/components/rich-text/native/test/performance/rich-text.native.js +44 -0
- package/src/components/rich-text/native/toolbar-button-with-options.native.js +61 -0
- package/src/components/rich-text/native/use-format-types.js +146 -0
- package/src/components/rich-text/use-paste-handler.js +1 -6
- package/src/components/url-popover/image-url-input-ui.js +1 -0
- package/src/components/writing-flow/use-tab-nav.js +8 -3
- package/src/hooks/align.js +8 -8
- package/src/hooks/align.native.js +2 -2
- package/src/hooks/anchor.js +21 -23
- package/src/hooks/background.js +28 -6
- package/src/hooks/block-hooks.js +20 -16
- package/src/hooks/block-rename-ui.js +6 -4
- package/src/hooks/content-lock-ui.js +3 -3
- package/src/hooks/custom-class-name.js +7 -6
- package/src/hooks/custom-fields.js +5 -5
- package/src/hooks/duotone.js +23 -33
- package/src/hooks/layout.js +114 -105
- package/src/hooks/position.js +8 -21
- package/src/hooks/style.js +17 -31
- package/src/hooks/test/align.js +4 -4
- package/src/hooks/utils.js +33 -1
- package/src/private-apis.js +4 -1
- package/src/store/actions.js +26 -72
- package/src/store/reducer.js +19 -0
- package/src/store/selectors.js +13 -19
- package/build/components/block-tools/selected-block-popover.js +0 -221
- package/build/components/block-tools/selected-block-popover.js.map +0 -1
- package/build/components/inserter/block-patterns-explorer/explorer.js.map +0 -1
- package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +0 -1
- package/build/components/inserter/block-patterns-explorer/sidebar.js.map +0 -1
- package/build/components/inserter/block-patterns-filter.js.map +0 -1
- package/build/components/inserter/block-patterns-tab.js +0 -270
- package/build/components/inserter/block-patterns-tab.js.map +0 -1
- package/build/store/utils.js +0 -22
- package/build/store/utils.js.map +0 -1
- package/build-module/components/block-tools/selected-block-popover.js +0 -213
- package/build-module/components/block-tools/selected-block-popover.js.map +0 -1
- package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +0 -1
- package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +0 -1
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +0 -1
- package/build-module/components/inserter/block-patterns-filter.js.map +0 -1
- package/build-module/components/inserter/block-patterns-tab.js +0 -254
- package/build-module/components/inserter/block-patterns-tab.js.map +0 -1
- package/build-module/store/utils.js +0 -16
- package/build-module/store/utils.js.map +0 -1
- package/src/components/block-tools/selected-block-popover.js +0 -265
- package/src/components/inserter/block-patterns-tab.js +0 -448
- package/src/store/utils.js +0 -12
- /package/src/components/inserter/block-patterns-explorer/{sidebar.js → pattern-explorer-sidebar.js} +0 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import BlockPopover from '../block-popover';
|
|
10
|
+
import useBlockToolbarPopoverProps from './use-block-toolbar-popover-props';
|
|
11
|
+
import Inserter from '../inserter';
|
|
12
|
+
import useSelectedBlockToolProps from './use-selected-block-tool-props';
|
|
13
|
+
|
|
14
|
+
export default function EmptyBlockInserter( {
|
|
15
|
+
clientId,
|
|
16
|
+
__unstableContentRef,
|
|
17
|
+
} ) {
|
|
18
|
+
const {
|
|
19
|
+
capturingClientId,
|
|
20
|
+
isInsertionPointVisible,
|
|
21
|
+
lastClientId,
|
|
22
|
+
rootClientId,
|
|
23
|
+
} = useSelectedBlockToolProps( clientId );
|
|
24
|
+
|
|
25
|
+
const popoverProps = useBlockToolbarPopoverProps( {
|
|
26
|
+
contentElement: __unstableContentRef?.current,
|
|
27
|
+
clientId,
|
|
28
|
+
} );
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<BlockPopover
|
|
32
|
+
clientId={ capturingClientId || clientId }
|
|
33
|
+
__unstableCoverTarget
|
|
34
|
+
bottomClientId={ lastClientId }
|
|
35
|
+
className={ classnames(
|
|
36
|
+
'block-editor-block-list__block-side-inserter-popover',
|
|
37
|
+
{
|
|
38
|
+
'is-insertion-point-visible': isInsertionPointVisible,
|
|
39
|
+
}
|
|
40
|
+
) }
|
|
41
|
+
__unstableContentRef={ __unstableContentRef }
|
|
42
|
+
resize={ false }
|
|
43
|
+
shift={ false }
|
|
44
|
+
{ ...popoverProps }
|
|
45
|
+
>
|
|
46
|
+
<div className="block-editor-block-list__empty-block-inserter">
|
|
47
|
+
<Inserter
|
|
48
|
+
position="bottom right"
|
|
49
|
+
rootClientId={ rootClientId }
|
|
50
|
+
clientId={ clientId }
|
|
51
|
+
__experimentalIsQuick
|
|
52
|
+
/>
|
|
53
|
+
</div>
|
|
54
|
+
</BlockPopover>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -6,28 +6,48 @@ import { useViewportMatch } from '@wordpress/compose';
|
|
|
6
6
|
import { Popover } from '@wordpress/components';
|
|
7
7
|
import { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';
|
|
8
8
|
import { useRef } from '@wordpress/element';
|
|
9
|
+
import { isUnmodifiedDefaultBlock } from '@wordpress/blocks';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Internal dependencies
|
|
12
13
|
*/
|
|
14
|
+
import EmptyBlockInserter from './empty-block-inserter';
|
|
13
15
|
import {
|
|
14
16
|
InsertionPointOpenRef,
|
|
15
17
|
default as InsertionPoint,
|
|
16
18
|
} from './insertion-point';
|
|
17
|
-
import
|
|
19
|
+
import SelectedBlockTools from './selected-block-tools';
|
|
18
20
|
import { store as blockEditorStore } from '../../store';
|
|
19
21
|
import BlockContextualToolbar from './block-contextual-toolbar';
|
|
20
22
|
import usePopoverScroll from '../block-popover/use-popover-scroll';
|
|
21
23
|
import ZoomOutModeInserters from './zoom-out-mode-inserters';
|
|
22
24
|
|
|
23
25
|
function selector( select ) {
|
|
24
|
-
const {
|
|
25
|
-
|
|
26
|
+
const {
|
|
27
|
+
getSelectedBlockClientId,
|
|
28
|
+
getFirstMultiSelectedBlockClientId,
|
|
29
|
+
getBlock,
|
|
30
|
+
getSettings,
|
|
31
|
+
__unstableGetEditorMode,
|
|
32
|
+
isTyping,
|
|
33
|
+
} = select( blockEditorStore );
|
|
34
|
+
|
|
35
|
+
const clientId =
|
|
36
|
+
getSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();
|
|
37
|
+
|
|
38
|
+
const { name = '', attributes = {} } = getBlock( clientId ) || {};
|
|
26
39
|
|
|
27
40
|
return {
|
|
28
|
-
|
|
41
|
+
clientId,
|
|
29
42
|
hasFixedToolbar: getSettings().hasFixedToolbar,
|
|
43
|
+
hasSelectedBlock: clientId && name,
|
|
30
44
|
isTyping: isTyping(),
|
|
45
|
+
isZoomOutMode: __unstableGetEditorMode() === 'zoom-out',
|
|
46
|
+
showEmptyBlockSideInserter:
|
|
47
|
+
clientId &&
|
|
48
|
+
! isTyping() &&
|
|
49
|
+
__unstableGetEditorMode() === 'edit' &&
|
|
50
|
+
isUnmodifiedDefaultBlock( { name, attributes } ),
|
|
31
51
|
};
|
|
32
52
|
}
|
|
33
53
|
|
|
@@ -46,10 +66,14 @@ export default function BlockTools( {
|
|
|
46
66
|
...props
|
|
47
67
|
} ) {
|
|
48
68
|
const isLargeViewport = useViewportMatch( 'medium' );
|
|
49
|
-
const {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
69
|
+
const {
|
|
70
|
+
clientId,
|
|
71
|
+
hasFixedToolbar,
|
|
72
|
+
hasSelectedBlock,
|
|
73
|
+
isTyping,
|
|
74
|
+
isZoomOutMode,
|
|
75
|
+
showEmptyBlockSideInserter,
|
|
76
|
+
} = useSelect( selector, [] );
|
|
53
77
|
const isMatch = useShortcutEventMatch();
|
|
54
78
|
const { getSelectedBlockClientIds, getBlockRootClientId } =
|
|
55
79
|
useSelect( blockEditorStore );
|
|
@@ -106,6 +130,15 @@ export default function BlockTools( {
|
|
|
106
130
|
insertBeforeBlock( clientIds[ 0 ] );
|
|
107
131
|
}
|
|
108
132
|
} else if ( isMatch( 'core/block-editor/unselect', event ) ) {
|
|
133
|
+
if ( event.target.closest( '[role=toolbar]' ) ) {
|
|
134
|
+
// This shouldn't be necessary, but we have a combination of a few things all combining to create a situation where:
|
|
135
|
+
// - Because the block toolbar uses createPortal to populate the block toolbar fills, we can't rely on the React event bubbling to hit the onKeyDown listener for the block toolbar
|
|
136
|
+
// - Since we can't use the React tree, we use the DOM tree which _should_ handle the event bubbling correctly from a `createPortal` element.
|
|
137
|
+
// - This bubbles via the React tree, which hits this `unselect` escape keypress before the block toolbar DOM event listener has access to it.
|
|
138
|
+
// An alternative would be to remove the addEventListener on the navigableToolbar and use this event to handle it directly right here. That feels hacky too though.
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
109
142
|
const clientIds = getSelectedBlockClientIds();
|
|
110
143
|
if ( clientIds.length ) {
|
|
111
144
|
event.preventDefault();
|
|
@@ -129,6 +162,12 @@ export default function BlockTools( {
|
|
|
129
162
|
const blockToolbarRef = usePopoverScroll( __unstableContentRef );
|
|
130
163
|
const blockToolbarAfterRef = usePopoverScroll( __unstableContentRef );
|
|
131
164
|
|
|
165
|
+
// Conditions for fixed toolbar
|
|
166
|
+
// 1. Not zoom out mode
|
|
167
|
+
// 2. It's a large viewport. If it's a smaller viewport, let the floating toolbar handle it as it already has styles attached to make it render that way.
|
|
168
|
+
// 3. Fixed toolbar is enabled
|
|
169
|
+
const isTopToolbar = ! isZoomOutMode && hasFixedToolbar && isLargeViewport;
|
|
170
|
+
|
|
132
171
|
return (
|
|
133
172
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
134
173
|
<div { ...props } onKeyDown={ onKeyDown }>
|
|
@@ -138,17 +177,34 @@ export default function BlockTools( {
|
|
|
138
177
|
__unstableContentRef={ __unstableContentRef }
|
|
139
178
|
/>
|
|
140
179
|
) }
|
|
141
|
-
{
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
180
|
+
{ /* If there is no slot available, such as in the standalone block editor, render within the editor */ }
|
|
181
|
+
|
|
182
|
+
{ ! isLargeViewport && ( // Small viewports always get a fixed toolbar
|
|
183
|
+
<BlockContextualToolbar isFixed />
|
|
184
|
+
) }
|
|
185
|
+
|
|
186
|
+
{ showEmptyBlockSideInserter && (
|
|
187
|
+
<EmptyBlockInserter
|
|
188
|
+
__unstableContentRef={ __unstableContentRef }
|
|
189
|
+
clientId={ clientId }
|
|
190
|
+
/>
|
|
191
|
+
) }
|
|
145
192
|
{ /* Even if the toolbar is fixed, the block popover is still
|
|
146
193
|
needed for navigation and zoom-out mode. */ }
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
194
|
+
{ ! showEmptyBlockSideInserter && hasSelectedBlock && (
|
|
195
|
+
<SelectedBlockTools
|
|
196
|
+
__unstableContentRef={ __unstableContentRef }
|
|
197
|
+
clientId={ clientId }
|
|
198
|
+
/>
|
|
199
|
+
) }
|
|
200
|
+
|
|
150
201
|
{ /* Used for the inline rich text toolbar. */ }
|
|
151
|
-
|
|
202
|
+
{ ! isTopToolbar && (
|
|
203
|
+
<Popover.Slot
|
|
204
|
+
name="block-toolbar"
|
|
205
|
+
ref={ blockToolbarRef }
|
|
206
|
+
/>
|
|
207
|
+
) }
|
|
152
208
|
{ children }
|
|
153
209
|
{ /* Used for inline rich text popovers. */ }
|
|
154
210
|
<Popover.Slot
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { useRef, useEffect } from '@wordpress/element';
|
|
10
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
11
|
+
import { useShortcut } from '@wordpress/keyboard-shortcuts';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Internal dependencies
|
|
15
|
+
*/
|
|
16
|
+
import BlockSelectionButton from './block-selection-button';
|
|
17
|
+
import BlockContextualToolbar from './block-contextual-toolbar';
|
|
18
|
+
import { store as blockEditorStore } from '../../store';
|
|
19
|
+
import BlockPopover from '../block-popover';
|
|
20
|
+
import useBlockToolbarPopoverProps from './use-block-toolbar-popover-props';
|
|
21
|
+
import useSelectedBlockToolProps from './use-selected-block-tool-props';
|
|
22
|
+
import { useShouldContextualToolbarShow } from '../../utils/use-should-contextual-toolbar-show';
|
|
23
|
+
|
|
24
|
+
export default function SelectedBlockTools( {
|
|
25
|
+
clientId,
|
|
26
|
+
showEmptyBlockSideInserter,
|
|
27
|
+
__unstableContentRef,
|
|
28
|
+
} ) {
|
|
29
|
+
const {
|
|
30
|
+
capturingClientId,
|
|
31
|
+
isInsertionPointVisible,
|
|
32
|
+
lastClientId,
|
|
33
|
+
rootClientId,
|
|
34
|
+
} = useSelectedBlockToolProps( clientId );
|
|
35
|
+
|
|
36
|
+
const { shouldShowBreadcrumb } = useSelect( ( select ) => {
|
|
37
|
+
const { hasMultiSelection, __unstableGetEditorMode } =
|
|
38
|
+
select( blockEditorStore );
|
|
39
|
+
|
|
40
|
+
const editorMode = __unstableGetEditorMode();
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
shouldShowBreadcrumb:
|
|
44
|
+
! hasMultiSelection() &&
|
|
45
|
+
( editorMode === 'navigation' || editorMode === 'zoom-out' ),
|
|
46
|
+
};
|
|
47
|
+
}, [] );
|
|
48
|
+
|
|
49
|
+
const isToolbarForced = useRef( false );
|
|
50
|
+
const { shouldShowContextualToolbar, canFocusHiddenToolbar } =
|
|
51
|
+
useShouldContextualToolbarShow();
|
|
52
|
+
|
|
53
|
+
const { stopTyping } = useDispatch( blockEditorStore );
|
|
54
|
+
|
|
55
|
+
useShortcut(
|
|
56
|
+
'core/block-editor/focus-toolbar',
|
|
57
|
+
() => {
|
|
58
|
+
isToolbarForced.current = true;
|
|
59
|
+
stopTyping( true );
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
isDisabled: ! canFocusHiddenToolbar,
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
useEffect( () => {
|
|
67
|
+
isToolbarForced.current = false;
|
|
68
|
+
} );
|
|
69
|
+
|
|
70
|
+
// Stores the active toolbar item index so the block toolbar can return focus
|
|
71
|
+
// to it when re-mounting.
|
|
72
|
+
const initialToolbarItemIndexRef = useRef();
|
|
73
|
+
|
|
74
|
+
useEffect( () => {
|
|
75
|
+
// Resets the index whenever the active block changes so this is not
|
|
76
|
+
// persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169
|
|
77
|
+
initialToolbarItemIndexRef.current = undefined;
|
|
78
|
+
}, [ clientId ] );
|
|
79
|
+
|
|
80
|
+
const popoverProps = useBlockToolbarPopoverProps( {
|
|
81
|
+
contentElement: __unstableContentRef?.current,
|
|
82
|
+
clientId,
|
|
83
|
+
} );
|
|
84
|
+
|
|
85
|
+
if ( showEmptyBlockSideInserter ) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if ( shouldShowBreadcrumb || shouldShowContextualToolbar ) {
|
|
90
|
+
return (
|
|
91
|
+
<BlockPopover
|
|
92
|
+
clientId={ capturingClientId || clientId }
|
|
93
|
+
bottomClientId={ lastClientId }
|
|
94
|
+
className={ classnames(
|
|
95
|
+
'block-editor-block-list__block-popover',
|
|
96
|
+
{
|
|
97
|
+
'is-insertion-point-visible': isInsertionPointVisible,
|
|
98
|
+
}
|
|
99
|
+
) }
|
|
100
|
+
resize={ false }
|
|
101
|
+
{ ...popoverProps }
|
|
102
|
+
>
|
|
103
|
+
{ shouldShowContextualToolbar && (
|
|
104
|
+
<BlockContextualToolbar
|
|
105
|
+
// If the toolbar is being shown because of being forced
|
|
106
|
+
// it should focus the toolbar right after the mount.
|
|
107
|
+
focusOnMount={ isToolbarForced.current }
|
|
108
|
+
__experimentalInitialIndex={
|
|
109
|
+
initialToolbarItemIndexRef.current
|
|
110
|
+
}
|
|
111
|
+
__experimentalOnIndexChange={ ( index ) => {
|
|
112
|
+
initialToolbarItemIndexRef.current = index;
|
|
113
|
+
} }
|
|
114
|
+
/>
|
|
115
|
+
) }
|
|
116
|
+
{ shouldShowBreadcrumb && (
|
|
117
|
+
<BlockSelectionButton
|
|
118
|
+
clientId={ clientId }
|
|
119
|
+
rootClientId={ rootClientId }
|
|
120
|
+
/>
|
|
121
|
+
) }
|
|
122
|
+
</BlockPopover>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
@@ -118,16 +118,6 @@
|
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
// Add a scrim to the right of the collapsed button.
|
|
122
|
-
&.is-collapsed::after {
|
|
123
|
-
content: "";
|
|
124
|
-
position: absolute;
|
|
125
|
-
left: 100%;
|
|
126
|
-
width: $grid-unit-60;
|
|
127
|
-
height: 100%;
|
|
128
|
-
background: linear-gradient(to right, $white, transparent);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
121
|
@include break-medium() {
|
|
132
122
|
&.is-fixed {
|
|
133
123
|
& > .block-editor-block-toolbar {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect } from '@wordpress/data';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { store as blockEditorStore } from '../../store';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Returns props for the selected block tools and empty block inserter.
|
|
13
|
+
*
|
|
14
|
+
* @param {string} clientId Selected block client ID.
|
|
15
|
+
*/
|
|
16
|
+
export default function useSelectedBlockToolProps( clientId ) {
|
|
17
|
+
const selectedBlockProps = useSelect(
|
|
18
|
+
( select ) => {
|
|
19
|
+
const {
|
|
20
|
+
getBlockRootClientId,
|
|
21
|
+
getBlockParents,
|
|
22
|
+
__experimentalGetBlockListSettingsForBlocks,
|
|
23
|
+
isBlockInsertionPointVisible,
|
|
24
|
+
getBlockInsertionPoint,
|
|
25
|
+
getBlockOrder,
|
|
26
|
+
hasMultiSelection,
|
|
27
|
+
getLastMultiSelectedBlockClientId,
|
|
28
|
+
} = select( blockEditorStore );
|
|
29
|
+
|
|
30
|
+
const blockParentsClientIds = getBlockParents( clientId );
|
|
31
|
+
|
|
32
|
+
// Get Block List Settings for all ancestors of the current Block clientId.
|
|
33
|
+
const parentBlockListSettings =
|
|
34
|
+
__experimentalGetBlockListSettingsForBlocks(
|
|
35
|
+
blockParentsClientIds
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
// Get the clientId of the topmost parent with the capture toolbars setting.
|
|
39
|
+
const capturingClientId = blockParentsClientIds.find(
|
|
40
|
+
( parentClientId ) =>
|
|
41
|
+
parentBlockListSettings[ parentClientId ]
|
|
42
|
+
?.__experimentalCaptureToolbars
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
let isInsertionPointVisible = false;
|
|
46
|
+
if ( isBlockInsertionPointVisible() ) {
|
|
47
|
+
const insertionPoint = getBlockInsertionPoint();
|
|
48
|
+
const order = getBlockOrder( insertionPoint.rootClientId );
|
|
49
|
+
isInsertionPointVisible =
|
|
50
|
+
order[ insertionPoint.index ] === clientId;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
capturingClientId,
|
|
55
|
+
isInsertionPointVisible,
|
|
56
|
+
lastClientId: hasMultiSelection()
|
|
57
|
+
? getLastMultiSelectedBlockClientId()
|
|
58
|
+
: null,
|
|
59
|
+
rootClientId: getBlockRootClientId( clientId ),
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
[ clientId ]
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
return selectedBlockProps;
|
|
66
|
+
}
|
|
@@ -9,14 +9,7 @@ import { forwardRef } from '@wordpress/element';
|
|
|
9
9
|
import RichText from '../rich-text';
|
|
10
10
|
|
|
11
11
|
const EditableText = forwardRef( ( props, ref ) => {
|
|
12
|
-
return
|
|
13
|
-
<RichText
|
|
14
|
-
ref={ ref }
|
|
15
|
-
{ ...props }
|
|
16
|
-
__unstableDisableFormats
|
|
17
|
-
preserveWhiteSpace
|
|
18
|
-
/>
|
|
19
|
-
);
|
|
12
|
+
return <RichText ref={ ref } { ...props } __unstableDisableFormats />;
|
|
20
13
|
} );
|
|
21
14
|
|
|
22
15
|
EditableText.Content = ( { value = '', tagName: Tag = 'div', ...props } ) => {
|
|
@@ -73,12 +73,13 @@ function bubbleEvent( event, Constructor, frame ) {
|
|
|
73
73
|
* @param {Document} iframeDocument Document to attach listeners to.
|
|
74
74
|
*/
|
|
75
75
|
function useBubbleEvents( iframeDocument ) {
|
|
76
|
-
return useRefEffect( (
|
|
76
|
+
return useRefEffect( () => {
|
|
77
77
|
const { defaultView } = iframeDocument;
|
|
78
78
|
if ( ! defaultView ) {
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
81
|
const { frameElement } = defaultView;
|
|
82
|
+
const html = iframeDocument.documentElement;
|
|
82
83
|
const eventTypes = [ 'dragover', 'mousemove' ];
|
|
83
84
|
const handlers = {};
|
|
84
85
|
for ( const name of eventTypes ) {
|
|
@@ -88,12 +89,12 @@ function useBubbleEvents( iframeDocument ) {
|
|
|
88
89
|
const Constructor = window[ constructorName ];
|
|
89
90
|
bubbleEvent( event, Constructor, frameElement );
|
|
90
91
|
};
|
|
91
|
-
|
|
92
|
+
html.addEventListener( name, handlers[ name ] );
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
return () => {
|
|
95
96
|
for ( const name of eventTypes ) {
|
|
96
|
-
|
|
97
|
+
html.removeEventListener( name, handlers[ name ] );
|
|
97
98
|
}
|
|
98
99
|
};
|
|
99
100
|
} );
|
|
@@ -8,9 +8,9 @@ import { __ } from '@wordpress/i18n';
|
|
|
8
8
|
/**
|
|
9
9
|
* Internal dependencies
|
|
10
10
|
*/
|
|
11
|
-
import PatternExplorerSidebar from './sidebar';
|
|
12
|
-
import PatternList from './
|
|
13
|
-
import {
|
|
11
|
+
import PatternExplorerSidebar from './pattern-explorer-sidebar';
|
|
12
|
+
import PatternList from './pattern-list';
|
|
13
|
+
import { usePatternCategories } from '../block-patterns-tab/use-pattern-categories';
|
|
14
14
|
|
|
15
15
|
function PatternsExplorer( { initialCategory, rootClientId } ) {
|
|
16
16
|
const [ searchValue, setSearchValue ] = useState( '' );
|
|
@@ -20,7 +20,7 @@ function PatternsExplorer( { initialCategory, rootClientId } ) {
|
|
|
20
20
|
initialCategory?.name
|
|
21
21
|
);
|
|
22
22
|
|
|
23
|
-
const patternCategories =
|
|
23
|
+
const patternCategories = usePatternCategories(
|
|
24
24
|
rootClientId,
|
|
25
25
|
patternSourceFilter
|
|
26
26
|
);
|
package/src/components/inserter/block-patterns-explorer/{patterns-list.js → pattern-list.js}
RENAMED
|
@@ -17,7 +17,10 @@ import InserterListbox from '../../inserter-listbox';
|
|
|
17
17
|
import { searchItems } from '../search-items';
|
|
18
18
|
import BlockPatternsPaging from '../../block-patterns-paging';
|
|
19
19
|
import usePatternsPaging from '../hooks/use-patterns-paging';
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
allPatternsCategory,
|
|
22
|
+
myPatternsCategory,
|
|
23
|
+
} from '../block-patterns-tab/utils';
|
|
21
24
|
|
|
22
25
|
function PatternsListHeader( { filterValue, filteredBlockPatternsLength } ) {
|
|
23
26
|
if ( ! filterValue ) {
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useState } from '@wordpress/element';
|
|
5
|
+
import { __, isRTL } from '@wordpress/i18n';
|
|
6
|
+
import { useViewportMatch } from '@wordpress/compose';
|
|
7
|
+
import {
|
|
8
|
+
__experimentalItemGroup as ItemGroup,
|
|
9
|
+
__experimentalItem as Item,
|
|
10
|
+
__experimentalHStack as HStack,
|
|
11
|
+
FlexBlock,
|
|
12
|
+
Button,
|
|
13
|
+
} from '@wordpress/components';
|
|
14
|
+
import { Icon, chevronRight, chevronLeft } from '@wordpress/icons';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Internal dependencies
|
|
18
|
+
*/
|
|
19
|
+
import PatternsExplorerModal from '../block-patterns-explorer';
|
|
20
|
+
import MobileTabNavigation from '../mobile-tab-navigation';
|
|
21
|
+
import { PatternCategoryPreviews } from './pattern-category-previews';
|
|
22
|
+
import { usePatternCategories } from './use-pattern-categories';
|
|
23
|
+
|
|
24
|
+
function BlockPatternsTab( {
|
|
25
|
+
onSelectCategory,
|
|
26
|
+
selectedCategory,
|
|
27
|
+
onInsert,
|
|
28
|
+
rootClientId,
|
|
29
|
+
} ) {
|
|
30
|
+
const [ showPatternsExplorer, setShowPatternsExplorer ] = useState( false );
|
|
31
|
+
|
|
32
|
+
const categories = usePatternCategories( rootClientId );
|
|
33
|
+
|
|
34
|
+
const initialCategory = selectedCategory || categories[ 0 ];
|
|
35
|
+
const isMobile = useViewportMatch( 'medium', '<' );
|
|
36
|
+
return (
|
|
37
|
+
<>
|
|
38
|
+
{ ! isMobile && (
|
|
39
|
+
<div className="block-editor-inserter__block-patterns-tabs-container">
|
|
40
|
+
<nav
|
|
41
|
+
aria-label={ __( 'Block pattern categories' ) }
|
|
42
|
+
className="block-editor-inserter__block-patterns-tabs"
|
|
43
|
+
>
|
|
44
|
+
<ItemGroup role="list">
|
|
45
|
+
{ categories.map( ( category ) => (
|
|
46
|
+
<Item
|
|
47
|
+
role="listitem"
|
|
48
|
+
key={ category.name }
|
|
49
|
+
onClick={ () =>
|
|
50
|
+
onSelectCategory( category )
|
|
51
|
+
}
|
|
52
|
+
className={
|
|
53
|
+
category === selectedCategory
|
|
54
|
+
? 'block-editor-inserter__patterns-category block-editor-inserter__patterns-selected-category'
|
|
55
|
+
: 'block-editor-inserter__patterns-category'
|
|
56
|
+
}
|
|
57
|
+
aria-label={ category.label }
|
|
58
|
+
aria-current={
|
|
59
|
+
category === selectedCategory
|
|
60
|
+
? 'true'
|
|
61
|
+
: undefined
|
|
62
|
+
}
|
|
63
|
+
>
|
|
64
|
+
<HStack>
|
|
65
|
+
<FlexBlock>
|
|
66
|
+
{ category.label }
|
|
67
|
+
</FlexBlock>
|
|
68
|
+
<Icon
|
|
69
|
+
icon={
|
|
70
|
+
isRTL()
|
|
71
|
+
? chevronLeft
|
|
72
|
+
: chevronRight
|
|
73
|
+
}
|
|
74
|
+
/>
|
|
75
|
+
</HStack>
|
|
76
|
+
</Item>
|
|
77
|
+
) ) }
|
|
78
|
+
<div role="listitem">
|
|
79
|
+
<Button
|
|
80
|
+
className="block-editor-inserter__patterns-explore-button"
|
|
81
|
+
onClick={ () =>
|
|
82
|
+
setShowPatternsExplorer( true )
|
|
83
|
+
}
|
|
84
|
+
variant="secondary"
|
|
85
|
+
>
|
|
86
|
+
{ __( 'Explore all patterns' ) }
|
|
87
|
+
</Button>
|
|
88
|
+
</div>
|
|
89
|
+
</ItemGroup>
|
|
90
|
+
</nav>
|
|
91
|
+
</div>
|
|
92
|
+
) }
|
|
93
|
+
{ isMobile && (
|
|
94
|
+
<MobileTabNavigation categories={ categories }>
|
|
95
|
+
{ ( category ) => (
|
|
96
|
+
<PatternCategoryPreviews
|
|
97
|
+
key={ category.name }
|
|
98
|
+
onInsert={ onInsert }
|
|
99
|
+
rootClientId={ rootClientId }
|
|
100
|
+
category={ category }
|
|
101
|
+
showTitlesAsTooltip={ false }
|
|
102
|
+
/>
|
|
103
|
+
) }
|
|
104
|
+
</MobileTabNavigation>
|
|
105
|
+
) }
|
|
106
|
+
{ showPatternsExplorer && (
|
|
107
|
+
<PatternsExplorerModal
|
|
108
|
+
initialCategory={ initialCategory }
|
|
109
|
+
patternCategories={ categories }
|
|
110
|
+
onModalClose={ () => setShowPatternsExplorer( false ) }
|
|
111
|
+
rootClientId={ rootClientId }
|
|
112
|
+
/>
|
|
113
|
+
) }
|
|
114
|
+
</>
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export default BlockPatternsTab;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useRef, useEffect } from '@wordpress/element';
|
|
5
|
+
|
|
6
|
+
import { focus } from '@wordpress/dom';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { PatternCategoryPreviews } from './pattern-category-previews';
|
|
13
|
+
|
|
14
|
+
export function PatternCategoryPreviewPanel( {
|
|
15
|
+
rootClientId,
|
|
16
|
+
onInsert,
|
|
17
|
+
onHover,
|
|
18
|
+
category,
|
|
19
|
+
showTitlesAsTooltip,
|
|
20
|
+
patternFilter,
|
|
21
|
+
} ) {
|
|
22
|
+
const container = useRef();
|
|
23
|
+
|
|
24
|
+
useEffect( () => {
|
|
25
|
+
const timeout = setTimeout( () => {
|
|
26
|
+
const [ firstTabbable ] = focus.tabbable.find( container.current );
|
|
27
|
+
firstTabbable?.focus();
|
|
28
|
+
} );
|
|
29
|
+
return () => clearTimeout( timeout );
|
|
30
|
+
}, [ category ] );
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<div
|
|
34
|
+
ref={ container }
|
|
35
|
+
className="block-editor-inserter__patterns-category-dialog"
|
|
36
|
+
>
|
|
37
|
+
<PatternCategoryPreviews
|
|
38
|
+
key={ category.name }
|
|
39
|
+
rootClientId={ rootClientId }
|
|
40
|
+
onInsert={ onInsert }
|
|
41
|
+
onHover={ onHover }
|
|
42
|
+
category={ category }
|
|
43
|
+
showTitlesAsTooltip={ showTitlesAsTooltip }
|
|
44
|
+
patternFilter={ patternFilter }
|
|
45
|
+
/>
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
}
|