@wordpress/block-editor 14.3.3 → 14.4.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/README.md +46 -0
- package/build/autocompleters/link.js +2 -1
- package/build/autocompleters/link.js.map +1 -1
- package/build/components/block-actions/index.js +1 -13
- package/build/components/block-actions/index.js.map +1 -1
- package/build/components/block-inspector/index.js +56 -75
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block.js +5 -19
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/index.js +5 -8
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +3 -11
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-zoom-out-mode-exit.js +9 -12
- package/build/components/block-list/use-block-props/use-zoom-out-mode-exit.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +5 -3
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-list/zoom-out-separator.js +14 -6
- package/build/components/block-list/zoom-out-separator.js.map +1 -1
- package/build/components/block-navigation/dropdown.js +2 -4
- package/build/components/block-navigation/dropdown.js.map +1 -1
- package/build/components/block-parent-selector/index.js +13 -10
- package/build/components/block-parent-selector/index.js.map +1 -1
- package/build/components/block-pattern-setup/setup-toolbar.js +10 -20
- package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build/components/block-patterns-paging/index.js +11 -13
- package/build/components/block-patterns-paging/index.js.map +1 -1
- package/build/components/block-quick-navigation/index.js +2 -4
- package/build/components/block-quick-navigation/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +79 -76
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +1 -6
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-switcher/index.js +17 -14
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-toolbar/index.js +16 -19
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-toolbar/use-has-block-toolbar.js +3 -5
- package/build/components/block-toolbar/use-has-block-toolbar.js.map +1 -1
- package/build/components/block-tools/index.js +8 -11
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +1 -4
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/use-show-block-tools.js +2 -5
- package/build/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build/components/block-tools/zoom-out-mode-inserter-button.js +1 -12
- package/build/components/block-tools/zoom-out-mode-inserter-button.js.map +1 -1
- package/build/components/block-tools/zoom-out-mode-inserters.js +14 -17
- package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build/components/block-tools/zoom-out-toolbar.js +2 -12
- package/build/components/block-tools/zoom-out-toolbar.js.map +1 -1
- package/build/components/block-variation-picker/index.js +2 -4
- package/build/components/block-variation-picker/index.js.map +1 -1
- package/build/components/block-variation-transforms/index.js +3 -4
- package/build/components/block-variation-transforms/index.js.map +1 -1
- package/build/components/button-block-appender/index.js +2 -4
- package/build/components/button-block-appender/index.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +2 -4
- package/build/components/colors-gradients/dropdown.js.map +1 -1
- package/build/components/global-styles/border-panel.js +1 -1
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.js +2 -4
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +3 -3
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/filters-panel.js +2 -4
- package/build/components/global-styles/filters-panel.js.map +1 -1
- package/build/components/global-styles/shadow-panel-components.js +24 -29
- package/build/components/global-styles/shadow-panel-components.js.map +1 -1
- package/build/components/inner-blocks/index.js +1 -9
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inserter/block-types-tab.js +1 -1
- package/build/components/inserter/block-types-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-block-types-state.js +24 -5
- package/build/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build/components/inserter/hooks/use-insertion-point.js +22 -12
- package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build/components/inserter/hooks/use-patterns-state.js +23 -10
- package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build/components/inserter/media-tab/media-preview.js +35 -13
- package/build/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build/components/inserter/menu.js +2 -2
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/mobile-tab-navigation.js +5 -5
- package/build/components/inserter/mobile-tab-navigation.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +4 -4
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inspector-controls-tabs/index.js +11 -8
- package/build/components/inspector-controls-tabs/index.js.map +1 -1
- package/build/components/inspector-popover-header/index.js +4 -8
- package/build/components/inspector-popover-header/index.js.map +1 -1
- package/build/components/link-control/index.js +5 -10
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/settings-drawer.js +2 -4
- package/build/components/link-control/settings-drawer.js.map +1 -1
- package/build/components/list-view/block-contents.js +1 -25
- package/build/components/list-view/block-contents.js.map +1 -1
- package/build/components/list-view/block-select-button.js +1 -4
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/media-placeholder/index.js +29 -43
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/rich-text/index.js +4 -8
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/skip-to-selected-block/index.js +2 -4
- package/build/components/skip-to-selected-block/index.js.map +1 -1
- package/build/components/tool-selector/index.js +13 -12
- package/build/components/tool-selector/index.js.map +1 -1
- package/build/components/url-input/button.js +14 -16
- package/build/components/url-input/button.js.map +1 -1
- package/build/components/url-input/index.js +2 -4
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-block-commands/index.js +0 -61
- package/build/components/use-block-commands/index.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +2 -25
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/hooks/block-bindings.js +6 -13
- package/build/hooks/block-bindings.js.map +1 -1
- package/build/hooks/duotone.js +4 -1
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/layout-child.js +3 -1
- package/build/hooks/layout-child.js.map +1 -1
- package/build/hooks/position.js +3 -2
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +5 -4
- package/build/hooks/use-bindings-attributes.js.map +1 -1
- package/build/layouts/flex.js +6 -38
- package/build/layouts/flex.js.map +1 -1
- package/build/private-apis.js +0 -2
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +13 -14
- package/build/store/actions.js.map +1 -1
- package/build/store/private-actions.js +15 -0
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +104 -7
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +22 -26
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +127 -56
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +4 -3
- package/build/store/utils.js.map +1 -1
- package/build/utils/block-bindings.js +50 -0
- package/build/utils/block-bindings.js.map +1 -1
- package/build/utils/index.js +7 -0
- package/build/utils/index.js.map +1 -1
- package/build-module/autocompleters/link.js +2 -1
- package/build-module/autocompleters/link.js.map +1 -1
- package/build-module/components/block-actions/index.js +1 -13
- package/build-module/components/block-actions/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +57 -76
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block.js +5 -19
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/index.js +5 -8
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +3 -11
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-zoom-out-mode-exit.js +9 -12
- package/build-module/components/block-list/use-block-props/use-zoom-out-mode-exit.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +5 -3
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-list/zoom-out-separator.js +14 -6
- package/build-module/components/block-list/zoom-out-separator.js.map +1 -1
- package/build-module/components/block-navigation/dropdown.js +2 -4
- package/build-module/components/block-navigation/dropdown.js.map +1 -1
- package/build-module/components/block-parent-selector/index.js +13 -10
- package/build-module/components/block-parent-selector/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.js +10 -20
- package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build-module/components/block-patterns-paging/index.js +11 -13
- package/build-module/components/block-patterns-paging/index.js.map +1 -1
- package/build-module/components/block-quick-navigation/index.js +2 -4
- package/build-module/components/block-quick-navigation/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +79 -76
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +2 -7
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-switcher/index.js +17 -14
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +17 -20
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-toolbar/use-has-block-toolbar.js +3 -5
- package/build-module/components/block-toolbar/use-has-block-toolbar.js.map +1 -1
- package/build-module/components/block-tools/index.js +8 -11
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +1 -4
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/use-show-block-tools.js +2 -5
- package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-mode-inserter-button.js +1 -12
- package/build-module/components/block-tools/zoom-out-mode-inserter-button.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-mode-inserters.js +14 -17
- package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-toolbar.js +2 -12
- package/build-module/components/block-tools/zoom-out-toolbar.js.map +1 -1
- package/build-module/components/block-variation-picker/index.js +2 -4
- package/build-module/components/block-variation-picker/index.js.map +1 -1
- package/build-module/components/block-variation-transforms/index.js +3 -4
- package/build-module/components/block-variation-transforms/index.js.map +1 -1
- package/build-module/components/button-block-appender/index.js +2 -4
- package/build-module/components/button-block-appender/index.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +2 -4
- package/build-module/components/colors-gradients/dropdown.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +1 -1
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +2 -4
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +1 -1
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/filters-panel.js +2 -4
- package/build-module/components/global-styles/filters-panel.js.map +1 -1
- package/build-module/components/global-styles/shadow-panel-components.js +25 -30
- package/build-module/components/global-styles/shadow-panel-components.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +1 -9
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.js +1 -1
- package/build-module/components/inserter/block-types-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-block-types-state.js +27 -8
- package/build-module/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build-module/components/inserter/hooks/use-insertion-point.js +22 -12
- package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build-module/components/inserter/hooks/use-patterns-state.js +23 -10
- package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-preview.js +35 -13
- package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build-module/components/inserter/menu.js +2 -2
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/mobile-tab-navigation.js +6 -6
- package/build-module/components/inserter/mobile-tab-navigation.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +4 -4
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/index.js +12 -9
- package/build-module/components/inspector-controls-tabs/index.js.map +1 -1
- package/build-module/components/inspector-popover-header/index.js +4 -8
- package/build-module/components/inspector-popover-header/index.js.map +1 -1
- package/build-module/components/link-control/index.js +5 -10
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/settings-drawer.js +2 -4
- package/build-module/components/link-control/settings-drawer.js.map +1 -1
- package/build-module/components/list-view/block-contents.js +1 -25
- package/build-module/components/list-view/block-contents.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +2 -5
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +30 -44
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +4 -8
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/skip-to-selected-block/index.js +2 -4
- package/build-module/components/skip-to-selected-block/index.js.map +1 -1
- package/build-module/components/tool-selector/index.js +13 -12
- package/build-module/components/tool-selector/index.js.map +1 -1
- package/build-module/components/url-input/button.js +15 -17
- package/build-module/components/url-input/button.js.map +1 -1
- package/build-module/components/url-input/index.js +2 -4
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-block-commands/index.js +1 -62
- package/build-module/components/use-block-commands/index.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +3 -26
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/hooks/block-bindings.js +6 -13
- package/build-module/hooks/block-bindings.js.map +1 -1
- package/build-module/hooks/duotone.js +4 -1
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/layout-child.js +4 -1
- package/build-module/hooks/layout-child.js.map +1 -1
- package/build-module/hooks/position.js +4 -1
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +5 -4
- package/build-module/hooks/use-bindings-attributes.js.map +1 -1
- package/build-module/layouts/flex.js +7 -39
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/private-apis.js +0 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +12 -12
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-actions.js +14 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +98 -7
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +21 -25
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +129 -58
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +3 -2
- package/build-module/store/utils.js.map +1 -1
- package/build-module/utils/block-bindings.js +50 -0
- package/build-module/utils/block-bindings.js.map +1 -1
- package/build-module/utils/index.js +1 -0
- package/build-module/utils/index.js.map +1 -1
- package/build-style/content-rtl.css +16 -70
- package/build-style/content.css +16 -70
- package/build-style/default-editor-styles-rtl.css +10 -1
- package/build-style/default-editor-styles.css +10 -1
- package/build-style/style-rtl.css +51 -149
- package/build-style/style.css +51 -149
- package/package.json +32 -32
- package/src/autocompleters/link.js +2 -1
- package/src/components/block-actions/index.js +1 -13
- package/src/components/block-draggable/style.scss +2 -2
- package/src/components/block-inspector/index.js +79 -95
- package/src/components/block-inspector/style.scss +2 -0
- package/src/components/block-list/block.js +7 -28
- package/src/components/block-list/content.scss +1 -61
- package/src/components/block-list/index.js +21 -29
- package/src/components/block-list/use-block-props/index.js +3 -10
- package/src/components/block-list/use-block-props/use-zoom-out-mode-exit.js +19 -11
- package/src/components/block-list/use-in-between-inserter.js +5 -2
- package/src/components/block-list/zoom-out-separator.js +24 -8
- package/src/components/block-navigation/dropdown.js +1 -2
- package/src/components/block-parent-selector/index.js +13 -10
- package/src/components/block-pattern-setup/setup-toolbar.js +5 -10
- package/src/components/block-patterns-paging/index.js +8 -7
- package/src/components/block-patterns-paging/style.scss +10 -27
- package/src/components/block-quick-navigation/index.js +1 -2
- package/src/components/block-settings-menu/block-settings-dropdown.js +120 -106
- package/src/components/block-settings-menu-controls/index.js +0 -15
- package/src/components/block-switcher/index.js +37 -30
- package/src/components/block-toolbar/index.js +22 -34
- package/src/components/block-toolbar/style.scss +10 -1
- package/src/components/block-toolbar/use-has-block-toolbar.js +19 -31
- package/src/components/block-tools/index.js +7 -16
- package/src/components/block-tools/insertion-point.js +1 -4
- package/src/components/block-tools/style.scss +3 -88
- package/src/components/block-tools/use-show-block-tools.js +2 -12
- package/src/components/block-tools/zoom-out-mode-inserter-button.js +2 -17
- package/src/components/block-tools/zoom-out-mode-inserters.js +11 -19
- package/src/components/block-tools/zoom-out-toolbar.js +2 -13
- package/src/components/block-variation-picker/index.js +1 -2
- package/src/components/block-variation-transforms/index.js +2 -2
- package/src/components/button-block-appender/content.scss +0 -5
- package/src/components/button-block-appender/index.js +1 -2
- package/src/components/colors-gradients/dropdown.js +1 -5
- package/src/components/font-family/README.md +5 -1
- package/src/components/global-styles/border-panel.js +1 -1
- package/src/components/global-styles/color-panel.js +1 -5
- package/src/components/global-styles/dimensions-panel.js +1 -1
- package/src/components/global-styles/filters-panel.js +1 -2
- package/src/components/global-styles/shadow-panel-components.js +28 -33
- package/src/components/global-styles/style.scss +5 -0
- package/src/components/inner-blocks/index.js +1 -16
- package/src/components/inserter/block-types-tab.js +1 -1
- package/src/components/inserter/hooks/use-block-types-state.js +34 -14
- package/src/components/inserter/hooks/use-insertion-point.js +35 -13
- package/src/components/inserter/hooks/use-patterns-state.js +46 -9
- package/src/components/inserter/media-tab/media-preview.js +38 -12
- package/src/components/inserter/menu.js +2 -2
- package/src/components/inserter/mobile-tab-navigation.js +10 -13
- package/src/components/inserter/quick-inserter.js +5 -4
- package/src/components/inserter/style.scss +0 -28
- package/src/components/inspector-controls-tabs/index.js +21 -20
- package/src/components/inspector-controls-tabs/style.scss +2 -6
- package/src/components/inspector-popover-header/index.js +2 -4
- package/src/components/inspector-popover-header/style.scss +0 -13
- package/src/components/link-control/index.js +2 -5
- package/src/components/link-control/settings-drawer.js +1 -2
- package/src/components/list-view/block-contents.js +1 -28
- package/src/components/list-view/block-select-button.js +2 -5
- package/src/components/list-view/style.scss +18 -14
- package/src/components/media-placeholder/content.scss +3 -19
- package/src/components/media-placeholder/index.js +23 -29
- package/src/components/rich-text/index.js +4 -13
- package/src/components/skip-to-selected-block/index.js +1 -2
- package/src/components/skip-to-selected-block/style.scss +0 -9
- package/src/components/tool-selector/index.js +14 -9
- package/src/components/tool-selector/style.scss +5 -0
- package/src/components/url-input/button.js +16 -12
- package/src/components/url-input/index.js +1 -2
- package/src/components/url-input/style.scss +0 -6
- package/src/components/use-block-commands/index.js +0 -58
- package/src/components/writing-flow/use-tab-nav.js +4 -36
- package/src/content.scss +0 -1
- package/src/hooks/block-bindings.js +9 -10
- package/src/hooks/duotone.js +4 -1
- package/src/hooks/layout-child.js +4 -1
- package/src/hooks/position.js +4 -1
- package/src/hooks/use-bindings-attributes.js +66 -63
- package/src/layouts/flex.js +10 -53
- package/src/private-apis.js +0 -2
- package/src/store/actions.js +14 -13
- package/src/store/private-actions.js +14 -0
- package/src/store/private-selectors.js +120 -16
- package/src/store/reducer.js +22 -28
- package/src/store/selectors.js +203 -114
- package/src/store/test/private-actions.js +15 -0
- package/src/store/test/private-selectors.js +34 -0
- package/src/store/test/reducer.js +40 -4
- package/src/store/test/selectors.js +183 -20
- package/src/store/utils.js +4 -2
- package/src/utils/block-bindings.js +49 -0
- package/src/utils/index.js +1 -0
- package/build/components/block-controls/use-has-block-controls.js +0 -43
- package/build/components/block-controls/use-has-block-controls.js.map +0 -1
- package/build/components/block-list/use-block-props/use-nav-mode-exit.js +0 -54
- package/build/components/block-list/use-block-props/use-nav-mode-exit.js.map +0 -1
- package/build/components/block-tools/block-selection-button.js +0 -259
- package/build/components/block-tools/block-selection-button.js.map +0 -1
- package/build/components/block-tools/block-toolbar-breadcrumb.js +0 -57
- package/build/components/block-tools/block-toolbar-breadcrumb.js.map +0 -1
- package/build/components/inserter/tabs.js +0 -78
- package/build/components/inserter/tabs.js.map +0 -1
- package/build-module/components/block-controls/use-has-block-controls.js +0 -34
- package/build-module/components/block-controls/use-has-block-controls.js.map +0 -1
- package/build-module/components/block-list/use-block-props/use-nav-mode-exit.js +0 -48
- package/build-module/components/block-list/use-block-props/use-nav-mode-exit.js.map +0 -1
- package/build-module/components/block-tools/block-selection-button.js +0 -254
- package/build-module/components/block-tools/block-selection-button.js.map +0 -1
- package/build-module/components/block-tools/block-toolbar-breadcrumb.js +0 -49
- package/build-module/components/block-tools/block-toolbar-breadcrumb.js.map +0 -1
- package/build-module/components/inserter/tabs.js +0 -72
- package/build-module/components/inserter/tabs.js.map +0 -1
- package/src/components/block-controls/use-has-block-controls.js +0 -35
- package/src/components/block-list/use-block-props/use-nav-mode-exit.js +0 -46
- package/src/components/block-tools/block-selection-button.js +0 -302
- package/src/components/block-tools/block-toolbar-breadcrumb.js +0 -51
- package/src/components/inner-blocks/content.scss +0 -13
- package/src/components/inserter/tabs.js +0 -78
- package/src/components/inserter/test/block-types-tab.native.js +0 -67
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import clsx from 'clsx';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { dragHandle } from '@wordpress/icons';
|
|
10
|
-
import { Button, Flex, FlexItem } from '@wordpress/components';
|
|
11
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
12
|
-
import { forwardRef, useEffect } from '@wordpress/element';
|
|
13
|
-
import {
|
|
14
|
-
BACKSPACE,
|
|
15
|
-
DELETE,
|
|
16
|
-
UP,
|
|
17
|
-
DOWN,
|
|
18
|
-
LEFT,
|
|
19
|
-
RIGHT,
|
|
20
|
-
TAB,
|
|
21
|
-
ESCAPE,
|
|
22
|
-
ENTER,
|
|
23
|
-
SPACE,
|
|
24
|
-
} from '@wordpress/keycodes';
|
|
25
|
-
import {
|
|
26
|
-
__experimentalGetAccessibleBlockLabel as getAccessibleBlockLabel,
|
|
27
|
-
store as blocksStore,
|
|
28
|
-
} from '@wordpress/blocks';
|
|
29
|
-
import { speak } from '@wordpress/a11y';
|
|
30
|
-
import { focus } from '@wordpress/dom';
|
|
31
|
-
import { __ } from '@wordpress/i18n';
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Internal dependencies
|
|
35
|
-
*/
|
|
36
|
-
import BlockTitle from '../block-title';
|
|
37
|
-
import BlockIcon from '../block-icon';
|
|
38
|
-
import { store as blockEditorStore } from '../../store';
|
|
39
|
-
import BlockDraggable from '../block-draggable';
|
|
40
|
-
import { useBlockElement } from '../block-list/use-block-props/use-block-refs';
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Block selection button component, displaying the label of the block. If the block
|
|
44
|
-
* descends from a root block, a button is displayed enabling the user to select
|
|
45
|
-
* the root block.
|
|
46
|
-
*
|
|
47
|
-
* @param {string} props Component props.
|
|
48
|
-
* @param {string} props.clientId Client ID of block.
|
|
49
|
-
* @param {Object} ref Reference to the component.
|
|
50
|
-
*
|
|
51
|
-
* @return {Component} The component to be rendered.
|
|
52
|
-
*/
|
|
53
|
-
function BlockSelectionButton( { clientId, rootClientId }, ref ) {
|
|
54
|
-
const selected = useSelect(
|
|
55
|
-
( select ) => {
|
|
56
|
-
const {
|
|
57
|
-
getBlock,
|
|
58
|
-
getBlockIndex,
|
|
59
|
-
hasBlockMovingClientId,
|
|
60
|
-
getBlockListSettings,
|
|
61
|
-
__unstableGetEditorMode,
|
|
62
|
-
getNextBlockClientId,
|
|
63
|
-
getPreviousBlockClientId,
|
|
64
|
-
canMoveBlock,
|
|
65
|
-
} = select( blockEditorStore );
|
|
66
|
-
const { getActiveBlockVariation, getBlockType } =
|
|
67
|
-
select( blocksStore );
|
|
68
|
-
const index = getBlockIndex( clientId );
|
|
69
|
-
const { name, attributes } = getBlock( clientId );
|
|
70
|
-
const blockType = getBlockType( name );
|
|
71
|
-
const orientation =
|
|
72
|
-
getBlockListSettings( rootClientId )?.orientation;
|
|
73
|
-
const match = getActiveBlockVariation( name, attributes );
|
|
74
|
-
|
|
75
|
-
return {
|
|
76
|
-
blockMovingMode: hasBlockMovingClientId(),
|
|
77
|
-
editorMode: __unstableGetEditorMode(),
|
|
78
|
-
icon: match?.icon || blockType.icon,
|
|
79
|
-
label: getAccessibleBlockLabel(
|
|
80
|
-
blockType,
|
|
81
|
-
attributes,
|
|
82
|
-
index + 1,
|
|
83
|
-
orientation
|
|
84
|
-
),
|
|
85
|
-
canMove: canMoveBlock( clientId, rootClientId ),
|
|
86
|
-
getNextBlockClientId,
|
|
87
|
-
getPreviousBlockClientId,
|
|
88
|
-
};
|
|
89
|
-
},
|
|
90
|
-
[ clientId, rootClientId ]
|
|
91
|
-
);
|
|
92
|
-
const { label, icon, blockMovingMode, editorMode, canMove } = selected;
|
|
93
|
-
const { setNavigationMode, removeBlock } = useDispatch( blockEditorStore );
|
|
94
|
-
|
|
95
|
-
// Focus the breadcrumb in navigation mode.
|
|
96
|
-
useEffect( () => {
|
|
97
|
-
if ( editorMode === 'navigation' ) {
|
|
98
|
-
ref.current.focus();
|
|
99
|
-
speak( label );
|
|
100
|
-
}
|
|
101
|
-
}, [ label, editorMode ] );
|
|
102
|
-
const blockElement = useBlockElement( clientId );
|
|
103
|
-
|
|
104
|
-
const {
|
|
105
|
-
hasBlockMovingClientId,
|
|
106
|
-
getBlockIndex,
|
|
107
|
-
getBlockRootClientId,
|
|
108
|
-
getClientIdsOfDescendants,
|
|
109
|
-
getSelectedBlockClientId,
|
|
110
|
-
getMultiSelectedBlocksEndClientId,
|
|
111
|
-
getPreviousBlockClientId,
|
|
112
|
-
getNextBlockClientId,
|
|
113
|
-
} = useSelect( blockEditorStore );
|
|
114
|
-
const {
|
|
115
|
-
selectBlock,
|
|
116
|
-
clearSelectedBlock,
|
|
117
|
-
setBlockMovingClientId,
|
|
118
|
-
moveBlockToPosition,
|
|
119
|
-
} = useDispatch( blockEditorStore );
|
|
120
|
-
|
|
121
|
-
function onKeyDown( event ) {
|
|
122
|
-
const { keyCode } = event;
|
|
123
|
-
const isUp = keyCode === UP;
|
|
124
|
-
const isDown = keyCode === DOWN;
|
|
125
|
-
const isLeft = keyCode === LEFT;
|
|
126
|
-
const isRight = keyCode === RIGHT;
|
|
127
|
-
const isTab = keyCode === TAB;
|
|
128
|
-
const isEscape = keyCode === ESCAPE;
|
|
129
|
-
const isEnter = keyCode === ENTER;
|
|
130
|
-
const isSpace = keyCode === SPACE;
|
|
131
|
-
const isShift = event.shiftKey;
|
|
132
|
-
|
|
133
|
-
if ( keyCode === BACKSPACE || keyCode === DELETE ) {
|
|
134
|
-
removeBlock( clientId );
|
|
135
|
-
event.preventDefault();
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const selectedBlockClientId = getSelectedBlockClientId();
|
|
140
|
-
const selectionEndClientId = getMultiSelectedBlocksEndClientId();
|
|
141
|
-
const selectionBeforeEndClientId = getPreviousBlockClientId(
|
|
142
|
-
selectionEndClientId || selectedBlockClientId
|
|
143
|
-
);
|
|
144
|
-
const selectionAfterEndClientId = getNextBlockClientId(
|
|
145
|
-
selectionEndClientId || selectedBlockClientId
|
|
146
|
-
);
|
|
147
|
-
|
|
148
|
-
const navigateUp = ( isTab && isShift ) || isUp;
|
|
149
|
-
const navigateDown = ( isTab && ! isShift ) || isDown;
|
|
150
|
-
// Move out of current nesting level (no effect if at root level).
|
|
151
|
-
const navigateOut = isLeft;
|
|
152
|
-
// Move into next nesting level (no effect if the current block has no innerBlocks).
|
|
153
|
-
const navigateIn = isRight;
|
|
154
|
-
|
|
155
|
-
let focusedBlockUid;
|
|
156
|
-
if ( navigateUp ) {
|
|
157
|
-
focusedBlockUid = selectionBeforeEndClientId;
|
|
158
|
-
} else if ( navigateDown ) {
|
|
159
|
-
focusedBlockUid = selectionAfterEndClientId;
|
|
160
|
-
} else if ( navigateOut ) {
|
|
161
|
-
focusedBlockUid =
|
|
162
|
-
getBlockRootClientId( selectedBlockClientId ) ??
|
|
163
|
-
selectedBlockClientId;
|
|
164
|
-
} else if ( navigateIn ) {
|
|
165
|
-
focusedBlockUid =
|
|
166
|
-
getClientIdsOfDescendants( selectedBlockClientId )[ 0 ] ??
|
|
167
|
-
selectedBlockClientId;
|
|
168
|
-
}
|
|
169
|
-
const startingBlockClientId = hasBlockMovingClientId();
|
|
170
|
-
if ( isEscape && startingBlockClientId && ! event.defaultPrevented ) {
|
|
171
|
-
setBlockMovingClientId( null );
|
|
172
|
-
event.preventDefault();
|
|
173
|
-
}
|
|
174
|
-
if ( ( isEnter || isSpace ) && startingBlockClientId ) {
|
|
175
|
-
const sourceRoot = getBlockRootClientId( startingBlockClientId );
|
|
176
|
-
const destRoot = getBlockRootClientId( selectedBlockClientId );
|
|
177
|
-
const sourceBlockIndex = getBlockIndex( startingBlockClientId );
|
|
178
|
-
let destinationBlockIndex = getBlockIndex( selectedBlockClientId );
|
|
179
|
-
if (
|
|
180
|
-
sourceBlockIndex < destinationBlockIndex &&
|
|
181
|
-
sourceRoot === destRoot
|
|
182
|
-
) {
|
|
183
|
-
destinationBlockIndex -= 1;
|
|
184
|
-
}
|
|
185
|
-
moveBlockToPosition(
|
|
186
|
-
startingBlockClientId,
|
|
187
|
-
sourceRoot,
|
|
188
|
-
destRoot,
|
|
189
|
-
destinationBlockIndex
|
|
190
|
-
);
|
|
191
|
-
selectBlock( startingBlockClientId );
|
|
192
|
-
setBlockMovingClientId( null );
|
|
193
|
-
}
|
|
194
|
-
// Prevent the block from being moved into itself.
|
|
195
|
-
if (
|
|
196
|
-
startingBlockClientId &&
|
|
197
|
-
selectedBlockClientId === startingBlockClientId &&
|
|
198
|
-
navigateIn
|
|
199
|
-
) {
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
if ( navigateDown || navigateUp || navigateOut || navigateIn ) {
|
|
203
|
-
if ( focusedBlockUid ) {
|
|
204
|
-
event.preventDefault();
|
|
205
|
-
selectBlock( focusedBlockUid );
|
|
206
|
-
} else if ( isTab && selectedBlockClientId ) {
|
|
207
|
-
let nextTabbable;
|
|
208
|
-
|
|
209
|
-
if ( navigateDown ) {
|
|
210
|
-
nextTabbable = blockElement;
|
|
211
|
-
do {
|
|
212
|
-
nextTabbable = focus.tabbable.findNext( nextTabbable );
|
|
213
|
-
} while (
|
|
214
|
-
nextTabbable &&
|
|
215
|
-
blockElement.contains( nextTabbable )
|
|
216
|
-
);
|
|
217
|
-
|
|
218
|
-
if ( ! nextTabbable ) {
|
|
219
|
-
nextTabbable =
|
|
220
|
-
blockElement.ownerDocument.defaultView.frameElement;
|
|
221
|
-
nextTabbable = focus.tabbable.findNext( nextTabbable );
|
|
222
|
-
}
|
|
223
|
-
} else {
|
|
224
|
-
nextTabbable = focus.tabbable.findPrevious( blockElement );
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
if ( nextTabbable ) {
|
|
228
|
-
event.preventDefault();
|
|
229
|
-
nextTabbable.focus();
|
|
230
|
-
clearSelectedBlock();
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
const classNames = clsx(
|
|
237
|
-
'block-editor-block-list__block-selection-button',
|
|
238
|
-
{
|
|
239
|
-
'is-block-moving-mode': !! blockMovingMode,
|
|
240
|
-
}
|
|
241
|
-
);
|
|
242
|
-
|
|
243
|
-
const dragHandleLabel = __( 'Drag' );
|
|
244
|
-
const showBlockDraggable = canMove && editorMode === 'navigation';
|
|
245
|
-
|
|
246
|
-
return (
|
|
247
|
-
<div className={ classNames }>
|
|
248
|
-
<Flex
|
|
249
|
-
justify="center"
|
|
250
|
-
className="block-editor-block-list__block-selection-button__content"
|
|
251
|
-
>
|
|
252
|
-
<FlexItem>
|
|
253
|
-
<BlockIcon icon={ icon } showColors />
|
|
254
|
-
</FlexItem>
|
|
255
|
-
{ showBlockDraggable && (
|
|
256
|
-
<FlexItem>
|
|
257
|
-
<BlockDraggable clientIds={ [ clientId ] }>
|
|
258
|
-
{ ( draggableProps ) => (
|
|
259
|
-
<Button
|
|
260
|
-
// TODO: Switch to `true` (40px size) if possible
|
|
261
|
-
__next40pxDefaultSize={ false }
|
|
262
|
-
icon={ dragHandle }
|
|
263
|
-
className="block-selection-button_drag-handle"
|
|
264
|
-
label={ dragHandleLabel }
|
|
265
|
-
// Should not be able to tab to drag handle as this
|
|
266
|
-
// button can only be used with a pointer device.
|
|
267
|
-
tabIndex="-1"
|
|
268
|
-
{ ...draggableProps }
|
|
269
|
-
/>
|
|
270
|
-
) }
|
|
271
|
-
</BlockDraggable>
|
|
272
|
-
</FlexItem>
|
|
273
|
-
) }
|
|
274
|
-
{ editorMode === 'navigation' && (
|
|
275
|
-
<FlexItem>
|
|
276
|
-
<Button
|
|
277
|
-
// TODO: Switch to `true` (40px size) if possible
|
|
278
|
-
__next40pxDefaultSize={ false }
|
|
279
|
-
ref={ ref }
|
|
280
|
-
onClick={
|
|
281
|
-
editorMode === 'navigation'
|
|
282
|
-
? () => setNavigationMode( false )
|
|
283
|
-
: undefined
|
|
284
|
-
}
|
|
285
|
-
onKeyDown={ onKeyDown }
|
|
286
|
-
label={ label }
|
|
287
|
-
showTooltip={ false }
|
|
288
|
-
className="block-selection-button_select-button"
|
|
289
|
-
>
|
|
290
|
-
<BlockTitle
|
|
291
|
-
clientId={ clientId }
|
|
292
|
-
maximumLength={ 35 }
|
|
293
|
-
/>
|
|
294
|
-
</Button>
|
|
295
|
-
</FlexItem>
|
|
296
|
-
) }
|
|
297
|
-
</Flex>
|
|
298
|
-
</div>
|
|
299
|
-
);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
export default forwardRef( BlockSelectionButton );
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import clsx from 'clsx';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { forwardRef } from '@wordpress/element';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Internal dependencies
|
|
13
|
-
*/
|
|
14
|
-
import BlockSelectionButton from './block-selection-button';
|
|
15
|
-
import { PrivateBlockPopover } from '../block-popover';
|
|
16
|
-
import useBlockToolbarPopoverProps from './use-block-toolbar-popover-props';
|
|
17
|
-
import useSelectedBlockToolProps from './use-selected-block-tool-props';
|
|
18
|
-
|
|
19
|
-
function BlockToolbarBreadcrumb( { clientId, __unstableContentRef }, ref ) {
|
|
20
|
-
const {
|
|
21
|
-
capturingClientId,
|
|
22
|
-
isInsertionPointVisible,
|
|
23
|
-
lastClientId,
|
|
24
|
-
rootClientId,
|
|
25
|
-
} = useSelectedBlockToolProps( clientId );
|
|
26
|
-
|
|
27
|
-
const popoverProps = useBlockToolbarPopoverProps( {
|
|
28
|
-
contentElement: __unstableContentRef?.current,
|
|
29
|
-
clientId,
|
|
30
|
-
} );
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<PrivateBlockPopover
|
|
34
|
-
clientId={ capturingClientId || clientId }
|
|
35
|
-
bottomClientId={ lastClientId }
|
|
36
|
-
className={ clsx( 'block-editor-block-list__block-popover', {
|
|
37
|
-
'is-insertion-point-visible': isInsertionPointVisible,
|
|
38
|
-
} ) }
|
|
39
|
-
resize={ false }
|
|
40
|
-
{ ...popoverProps }
|
|
41
|
-
>
|
|
42
|
-
<BlockSelectionButton
|
|
43
|
-
ref={ ref }
|
|
44
|
-
clientId={ clientId }
|
|
45
|
-
rootClientId={ rootClientId }
|
|
46
|
-
/>
|
|
47
|
-
</PrivateBlockPopover>
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export default forwardRef( BlockToolbarBreadcrumb );
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// Add clickable overlay to blocks with nesting.
|
|
2
|
-
// This makes it easy to select all layers of the block.
|
|
3
|
-
.block-editor-block-list__layout.has-overlay {
|
|
4
|
-
&::after {
|
|
5
|
-
content: "";
|
|
6
|
-
position: absolute;
|
|
7
|
-
top: 0;
|
|
8
|
-
right: 0;
|
|
9
|
-
bottom: 0;
|
|
10
|
-
left: 0;
|
|
11
|
-
z-index: z-index(".block-editor-block-list__layout.has-overlay::after");
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import {
|
|
5
|
-
Button,
|
|
6
|
-
privateApis as componentsPrivateApis,
|
|
7
|
-
} from '@wordpress/components';
|
|
8
|
-
import { __ } from '@wordpress/i18n';
|
|
9
|
-
import { forwardRef } from '@wordpress/element';
|
|
10
|
-
import { closeSmall } from '@wordpress/icons';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
|
-
import { unlock } from '../../lock-unlock';
|
|
16
|
-
|
|
17
|
-
const { Tabs } = unlock( componentsPrivateApis );
|
|
18
|
-
|
|
19
|
-
const blocksTab = {
|
|
20
|
-
name: 'blocks',
|
|
21
|
-
/* translators: Blocks tab title in the block inserter. */
|
|
22
|
-
title: __( 'Blocks' ),
|
|
23
|
-
};
|
|
24
|
-
const patternsTab = {
|
|
25
|
-
name: 'patterns',
|
|
26
|
-
/* translators: Theme and Directory Patterns tab title in the block inserter. */
|
|
27
|
-
title: __( 'Patterns' ),
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const mediaTab = {
|
|
31
|
-
name: 'media',
|
|
32
|
-
/* translators: Media tab title in the block inserter. */
|
|
33
|
-
title: __( 'Media' ),
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
function InserterTabs( { onSelect, children, onClose, selectedTab }, ref ) {
|
|
37
|
-
const tabs = [ blocksTab, patternsTab, mediaTab ];
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<div className="block-editor-inserter__tabs" ref={ ref }>
|
|
41
|
-
<Tabs onSelect={ onSelect } selectedTabId={ selectedTab }>
|
|
42
|
-
<div className="block-editor-inserter__tablist-and-close-button">
|
|
43
|
-
<Button
|
|
44
|
-
className="block-editor-inserter__close-button"
|
|
45
|
-
icon={ closeSmall }
|
|
46
|
-
label={ __( 'Close block inserter' ) }
|
|
47
|
-
onClick={ () => onClose() }
|
|
48
|
-
size="small"
|
|
49
|
-
/>
|
|
50
|
-
|
|
51
|
-
<Tabs.TabList className="block-editor-inserter__tablist">
|
|
52
|
-
{ tabs.map( ( tab ) => (
|
|
53
|
-
<Tabs.Tab
|
|
54
|
-
key={ tab.name }
|
|
55
|
-
tabId={ tab.name }
|
|
56
|
-
className="block-editor-inserter__tab"
|
|
57
|
-
>
|
|
58
|
-
{ tab.title }
|
|
59
|
-
</Tabs.Tab>
|
|
60
|
-
) ) }
|
|
61
|
-
</Tabs.TabList>
|
|
62
|
-
</div>
|
|
63
|
-
{ tabs.map( ( tab ) => (
|
|
64
|
-
<Tabs.TabPanel
|
|
65
|
-
key={ tab.name }
|
|
66
|
-
tabId={ tab.name }
|
|
67
|
-
focusable={ false }
|
|
68
|
-
className="block-editor-inserter__tabpanel"
|
|
69
|
-
>
|
|
70
|
-
{ children }
|
|
71
|
-
</Tabs.TabPanel>
|
|
72
|
-
) ) }
|
|
73
|
-
</Tabs>
|
|
74
|
-
</div>
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export default forwardRef( InserterTabs );
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { render } from 'test/helpers';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { useSelect } from '@wordpress/data';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Internal dependencies
|
|
13
|
-
*/
|
|
14
|
-
import items from './fixtures';
|
|
15
|
-
import BlockTypesTab from '../block-types-tab';
|
|
16
|
-
|
|
17
|
-
jest.mock( '../hooks/use-clipboard-block' );
|
|
18
|
-
jest.mock( '@wordpress/data/src/components/use-select' );
|
|
19
|
-
|
|
20
|
-
const selectMock = {
|
|
21
|
-
getCategories: jest.fn().mockReturnValue( [] ),
|
|
22
|
-
getCollections: jest.fn().mockReturnValue( [] ),
|
|
23
|
-
getInserterItems: jest.fn().mockReturnValue( [] ),
|
|
24
|
-
canInsertBlockType: jest.fn(),
|
|
25
|
-
getBlockType: jest.fn(),
|
|
26
|
-
getClipboard: jest.fn(),
|
|
27
|
-
getSettings: jest.fn( () => ( { impressions: {} } ) ),
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
describe( 'BlockTypesTab component', () => {
|
|
31
|
-
beforeEach( () => {
|
|
32
|
-
useSelect.mockImplementation( ( callback ) =>
|
|
33
|
-
callback( () => selectMock )
|
|
34
|
-
);
|
|
35
|
-
} );
|
|
36
|
-
|
|
37
|
-
it( 'renders without crashing', () => {
|
|
38
|
-
const component = render(
|
|
39
|
-
<BlockTypesTab
|
|
40
|
-
rootClientId={ 0 }
|
|
41
|
-
onSelect={ jest.fn() }
|
|
42
|
-
listProps={ { contentContainerStyle: {} } }
|
|
43
|
-
/>
|
|
44
|
-
);
|
|
45
|
-
expect( component ).toBeTruthy();
|
|
46
|
-
} );
|
|
47
|
-
|
|
48
|
-
it( 'shows block items', () => {
|
|
49
|
-
selectMock.getInserterItems.mockReturnValue( items );
|
|
50
|
-
|
|
51
|
-
const blockItems = items.filter(
|
|
52
|
-
( { id, category } ) =>
|
|
53
|
-
category !== 'reusable' && id !== 'core-embed/a-paragraph-embed'
|
|
54
|
-
);
|
|
55
|
-
const component = render(
|
|
56
|
-
<BlockTypesTab
|
|
57
|
-
rootClientId={ 0 }
|
|
58
|
-
onSelect={ jest.fn() }
|
|
59
|
-
listProps={ { contentContainerStyle: {} } }
|
|
60
|
-
/>
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
blockItems.forEach( ( item ) => {
|
|
64
|
-
expect( component.getByText( item.title ) ).toBeTruthy();
|
|
65
|
-
} );
|
|
66
|
-
} );
|
|
67
|
-
} );
|