@wordpress/block-editor 12.12.2-next.f8d8eceb.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 +3 -1
- 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/resizable-box-popover/index.js +1 -1
- package/build/components/resizable-box-popover/index.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 +14 -22
- 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/resizable-box-popover/index.js +1 -1
- package/build-module/components/resizable-box-popover/index.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 +15 -23
- 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/resizable-box-popover/index.js +1 -1
- 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 +29 -38
- 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
|
@@ -4,16 +4,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.default =
|
|
7
|
+
exports.default = BlockContextualToolbar;
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
10
|
var _i18n = require("@wordpress/i18n");
|
|
11
|
-
var _element = require("@wordpress/element");
|
|
12
11
|
var _blocks = require("@wordpress/blocks");
|
|
13
12
|
var _data = require("@wordpress/data");
|
|
14
|
-
var _components = require("@wordpress/components");
|
|
15
|
-
var _icons = require("@wordpress/icons");
|
|
16
|
-
var _compose = require("@wordpress/compose");
|
|
17
13
|
var _navigableToolbar = _interopRequireDefault(require("../navigable-toolbar"));
|
|
18
14
|
var _blockToolbar = _interopRequireDefault(require("../block-toolbar"));
|
|
19
15
|
var _store = require("../../store");
|
|
@@ -35,10 +31,6 @@ function BlockContextualToolbar({
|
|
|
35
31
|
isFixed,
|
|
36
32
|
...props
|
|
37
33
|
}) {
|
|
38
|
-
// When the toolbar is fixed it can be collapsed
|
|
39
|
-
const [isCollapsed, setIsCollapsed] = (0, _element.useState)(false);
|
|
40
|
-
const toolbarButtonRef = (0, _element.useRef)();
|
|
41
|
-
const isLargeViewport = (0, _compose.useViewportMatch)('medium');
|
|
42
34
|
const {
|
|
43
35
|
blockType,
|
|
44
36
|
blockEditingMode,
|
|
@@ -69,60 +61,7 @@ function BlockContextualToolbar({
|
|
|
69
61
|
showParentSelector: parentBlockType && getBlockEditingMode(firstParentClientId) === 'default' && (0, _blocks.hasBlockSupport)(parentBlockType, '__experimentalParentSelector', true) && selectedBlockClientIds.length <= 1 && getBlockEditingMode(_selectedBlockClientId) === 'default'
|
|
70
62
|
};
|
|
71
63
|
}, []);
|
|
72
|
-
(0,
|
|
73
|
-
setIsCollapsed(false);
|
|
74
|
-
}, [selectedBlockClientId]);
|
|
75
|
-
const isLargerThanTabletViewport = (0, _compose.useViewportMatch)('large', '>=');
|
|
76
|
-
const isFullscreen = document.body.classList.contains('is-fullscreen-mode');
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* The following code is a workaround to fix the width of the toolbar
|
|
80
|
-
* it should be removed when the toolbar will be rendered inline
|
|
81
|
-
* FIXME: remove this layout effect when the toolbar is no longer
|
|
82
|
-
* absolutely positioned
|
|
83
|
-
*/
|
|
84
|
-
(0, _element.useLayoutEffect)(() => {
|
|
85
|
-
// don't do anything if not fixed toolbar
|
|
86
|
-
if (!isFixed) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
const blockToolbar = document.querySelector('.block-editor-block-contextual-toolbar');
|
|
90
|
-
if (!blockToolbar) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
if (!blockType) {
|
|
94
|
-
blockToolbar.style.width = 'initial';
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
if (!isLargerThanTabletViewport) {
|
|
98
|
-
// set the width of the toolbar to auto
|
|
99
|
-
blockToolbar.style = {};
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
if (isCollapsed) {
|
|
103
|
-
// set the width of the toolbar to auto
|
|
104
|
-
blockToolbar.style.width = 'auto';
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// get the width of the pinned items in the post editor or widget editor
|
|
109
|
-
const pinnedItems = document.querySelector('.edit-post-header__settings, .edit-widgets-header__actions');
|
|
110
|
-
// get the width of the left header in the site editor
|
|
111
|
-
const leftHeader = document.querySelector('.edit-site-header-edit-mode__end');
|
|
112
|
-
const computedToolbarStyle = window.getComputedStyle(blockToolbar);
|
|
113
|
-
const computedPinnedItemsStyle = pinnedItems ? window.getComputedStyle(pinnedItems) : false;
|
|
114
|
-
const computedLeftHeaderStyle = leftHeader ? window.getComputedStyle(leftHeader) : false;
|
|
115
|
-
const marginLeft = parseFloat(computedToolbarStyle.marginLeft);
|
|
116
|
-
const pinnedItemsWidth = computedPinnedItemsStyle ? parseFloat(computedPinnedItemsStyle.width) : 0;
|
|
117
|
-
const leftHeaderWidth = computedLeftHeaderStyle ? parseFloat(computedLeftHeaderStyle.width) : 0;
|
|
118
|
-
|
|
119
|
-
// set the new witdth of the toolbar
|
|
120
|
-
blockToolbar.style.width = `calc(100% - ${leftHeaderWidth + pinnedItemsWidth + marginLeft + (pinnedItems || leftHeader ? 2 : 0) + (
|
|
121
|
-
// Prevents button focus border from being cut off
|
|
122
|
-
isFullscreen ? 0 : 160) // the width of the admin sidebar expanded
|
|
123
|
-
}px)`;
|
|
124
|
-
}, [isFixed, isLargerThanTabletViewport, isCollapsed, isFullscreen, blockType]);
|
|
125
|
-
const isToolbarEnabled = !blockType || (0, _blocks.hasBlockSupport)(blockType, '__experimentalToolbar', true);
|
|
64
|
+
const isToolbarEnabled = blockType && (0, _blocks.hasBlockSupport)(blockType, '__experimentalToolbar', true);
|
|
126
65
|
const hasAnyBlockControls = (0, _useHasBlockControls.useHasAnyBlockControls)();
|
|
127
66
|
if (!isToolbarEnabled || blockEditingMode !== 'default' && !hasAnyBlockControls) {
|
|
128
67
|
return null;
|
|
@@ -131,31 +70,22 @@ function BlockContextualToolbar({
|
|
|
131
70
|
// Shifts the toolbar to make room for the parent block selector.
|
|
132
71
|
const classes = (0, _classnames.default)('block-editor-block-contextual-toolbar', {
|
|
133
72
|
'has-parent': hasParents && showParentSelector,
|
|
134
|
-
'is-fixed': isFixed
|
|
135
|
-
'is-collapsed': isCollapsed
|
|
73
|
+
'is-fixed': isFixed
|
|
136
74
|
});
|
|
137
75
|
return (0, _react.createElement)(_navigableToolbar.default, {
|
|
138
76
|
focusOnMount: focusOnMount,
|
|
77
|
+
focusEditorOnEscape: true,
|
|
139
78
|
className: classes
|
|
140
79
|
/* translators: accessibility text for the block toolbar */,
|
|
141
80
|
"aria-label": (0, _i18n.__)('Block tools'),
|
|
142
|
-
variant: isFixed ? 'unstyled' : undefined
|
|
81
|
+
variant: isFixed ? 'unstyled' : undefined
|
|
82
|
+
// Resets the index whenever the active block changes so
|
|
83
|
+
// this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169
|
|
84
|
+
,
|
|
85
|
+
key: selectedBlockClientId,
|
|
143
86
|
...props
|
|
144
|
-
},
|
|
87
|
+
}, (0, _react.createElement)(_blockToolbar.default, {
|
|
145
88
|
hideDragHandle: isFixed
|
|
146
|
-
})
|
|
147
|
-
className: isCollapsed ? 'block-editor-block-toolbar__group-expand-fixed-toolbar' : 'block-editor-block-toolbar__group-collapse-fixed-toolbar'
|
|
148
|
-
}, (0, _react.createElement)(_components.ToolbarItem, {
|
|
149
|
-
as: _components.ToolbarButton,
|
|
150
|
-
ref: toolbarButtonRef,
|
|
151
|
-
icon: isCollapsed ? _icons.next : _icons.previous,
|
|
152
|
-
onClick: () => {
|
|
153
|
-
setIsCollapsed(collapsed => !collapsed);
|
|
154
|
-
toolbarButtonRef.current.focus();
|
|
155
|
-
},
|
|
156
|
-
label: isCollapsed ? (0, _i18n.__)('Show block tools') : (0, _i18n.__)('Hide block tools')
|
|
157
|
-
})));
|
|
89
|
+
}));
|
|
158
90
|
}
|
|
159
|
-
var _default = BlockContextualToolbar;
|
|
160
|
-
exports.default = _default;
|
|
161
91
|
//# sourceMappingURL=block-contextual-toolbar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_classnames","_interopRequireDefault","require","_i18n","_element","_blocks","_data","_components","_icons","_compose","_navigableToolbar","_blockToolbar","_store","_useHasBlockControls","BlockContextualToolbar","focusOnMount","isFixed","props","isCollapsed","setIsCollapsed","useState","toolbarButtonRef","useRef","isLargeViewport","useViewportMatch","blockType","blockEditingMode","hasParents","showParentSelector","selectedBlockClientId","useSelect","select","getBlockName","getBlockParents","getSelectedBlockClientIds","getBlockEditingMode","blockEditorStore","getBlockType","blocksStore","selectedBlockClientIds","_selectedBlockClientId","parents","firstParentClientId","length","parentBlockName","parentBlockType","hasBlockSupport","useEffect","isLargerThanTabletViewport","isFullscreen","document","body","classList","contains","useLayoutEffect","blockToolbar","querySelector","style","width","pinnedItems","leftHeader","computedToolbarStyle","window","getComputedStyle","computedPinnedItemsStyle","computedLeftHeaderStyle","marginLeft","parseFloat","pinnedItemsWidth","leftHeaderWidth","isToolbarEnabled","hasAnyBlockControls","useHasAnyBlockControls","classes","classnames","_react","createElement","default","className","__","variant","undefined","hideDragHandle","ToolbarGroup","ToolbarItem","as","ToolbarButton","ref","icon","next","previous","onClick","collapsed","current","focus","label","_default","exports"],"sources":["@wordpress/block-editor/src/components/block-tools/block-contextual-toolbar.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseLayoutEffect,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { hasBlockSupport, store as blocksStore } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tToolbarItem,\n\tToolbarButton,\n\tToolbarGroup,\n} from '@wordpress/components';\nimport { next, previous } from '@wordpress/icons';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport NavigableToolbar from '../navigable-toolbar';\nimport BlockToolbar from '../block-toolbar';\nimport { store as blockEditorStore } from '../../store';\nimport { useHasAnyBlockControls } from '../block-controls/use-has-block-controls';\n\nfunction BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {\n\t// When the toolbar is fixed it can be collapsed\n\tconst [ isCollapsed, setIsCollapsed ] = useState( false );\n\tconst toolbarButtonRef = useRef();\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst {\n\t\tblockType,\n\t\tblockEditingMode,\n\t\thasParents,\n\t\tshowParentSelector,\n\t\tselectedBlockClientId,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetBlockName,\n\t\t\tgetBlockParents,\n\t\t\tgetSelectedBlockClientIds,\n\t\t\tgetBlockEditingMode,\n\t\t} = select( blockEditorStore );\n\t\tconst { getBlockType } = select( blocksStore );\n\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\t\tconst _selectedBlockClientId = selectedBlockClientIds[ 0 ];\n\t\tconst parents = getBlockParents( _selectedBlockClientId );\n\t\tconst firstParentClientId = parents[ parents.length - 1 ];\n\t\tconst parentBlockName = getBlockName( firstParentClientId );\n\t\tconst parentBlockType = getBlockType( parentBlockName );\n\n\t\treturn {\n\t\t\tselectedBlockClientId: _selectedBlockClientId,\n\t\t\tblockType:\n\t\t\t\t_selectedBlockClientId &&\n\t\t\t\tgetBlockType( getBlockName( _selectedBlockClientId ) ),\n\t\t\tblockEditingMode: getBlockEditingMode( _selectedBlockClientId ),\n\t\t\thasParents: parents.length,\n\t\t\tshowParentSelector:\n\t\t\t\tparentBlockType &&\n\t\t\t\tgetBlockEditingMode( firstParentClientId ) === 'default' &&\n\t\t\t\thasBlockSupport(\n\t\t\t\t\tparentBlockType,\n\t\t\t\t\t'__experimentalParentSelector',\n\t\t\t\t\ttrue\n\t\t\t\t) &&\n\t\t\t\tselectedBlockClientIds.length <= 1 &&\n\t\t\t\tgetBlockEditingMode( _selectedBlockClientId ) === 'default',\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tsetIsCollapsed( false );\n\t}, [ selectedBlockClientId ] );\n\n\tconst isLargerThanTabletViewport = useViewportMatch( 'large', '>=' );\n\tconst isFullscreen =\n\t\tdocument.body.classList.contains( 'is-fullscreen-mode' );\n\n\t/**\n\t * The following code is a workaround to fix the width of the toolbar\n\t * it should be removed when the toolbar will be rendered inline\n\t * FIXME: remove this layout effect when the toolbar is no longer\n\t * \t\t\t\tabsolutely positioned\n\t */\n\tuseLayoutEffect( () => {\n\t\t// don't do anything if not fixed toolbar\n\t\tif ( ! isFixed ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst blockToolbar = document.querySelector(\n\t\t\t'.block-editor-block-contextual-toolbar'\n\t\t);\n\n\t\tif ( ! blockToolbar ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! blockType ) {\n\t\t\tblockToolbar.style.width = 'initial';\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! isLargerThanTabletViewport ) {\n\t\t\t// set the width of the toolbar to auto\n\t\t\tblockToolbar.style = {};\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isCollapsed ) {\n\t\t\t// set the width of the toolbar to auto\n\t\t\tblockToolbar.style.width = 'auto';\n\t\t\treturn;\n\t\t}\n\n\t\t// get the width of the pinned items in the post editor or widget editor\n\t\tconst pinnedItems = document.querySelector(\n\t\t\t'.edit-post-header__settings, .edit-widgets-header__actions'\n\t\t);\n\t\t// get the width of the left header in the site editor\n\t\tconst leftHeader = document.querySelector(\n\t\t\t'.edit-site-header-edit-mode__end'\n\t\t);\n\n\t\tconst computedToolbarStyle = window.getComputedStyle( blockToolbar );\n\t\tconst computedPinnedItemsStyle = pinnedItems\n\t\t\t? window.getComputedStyle( pinnedItems )\n\t\t\t: false;\n\t\tconst computedLeftHeaderStyle = leftHeader\n\t\t\t? window.getComputedStyle( leftHeader )\n\t\t\t: false;\n\n\t\tconst marginLeft = parseFloat( computedToolbarStyle.marginLeft );\n\t\tconst pinnedItemsWidth = computedPinnedItemsStyle\n\t\t\t? parseFloat( computedPinnedItemsStyle.width )\n\t\t\t: 0;\n\t\tconst leftHeaderWidth = computedLeftHeaderStyle\n\t\t\t? parseFloat( computedLeftHeaderStyle.width )\n\t\t\t: 0;\n\n\t\t// set the new witdth of the toolbar\n\t\tblockToolbar.style.width = `calc(100% - ${\n\t\t\tleftHeaderWidth +\n\t\t\tpinnedItemsWidth +\n\t\t\tmarginLeft +\n\t\t\t( pinnedItems || leftHeader ? 2 : 0 ) + // Prevents button focus border from being cut off\n\t\t\t( isFullscreen ? 0 : 160 ) // the width of the admin sidebar expanded\n\t\t}px)`;\n\t}, [\n\t\tisFixed,\n\t\tisLargerThanTabletViewport,\n\t\tisCollapsed,\n\t\tisFullscreen,\n\t\tblockType,\n\t] );\n\n\tconst isToolbarEnabled =\n\t\t! blockType ||\n\t\thasBlockSupport( blockType, '__experimentalToolbar', true );\n\tconst hasAnyBlockControls = useHasAnyBlockControls();\n\tif (\n\t\t! isToolbarEnabled ||\n\t\t( blockEditingMode !== 'default' && ! hasAnyBlockControls )\n\t) {\n\t\treturn null;\n\t}\n\n\t// Shifts the toolbar to make room for the parent block selector.\n\tconst classes = classnames( 'block-editor-block-contextual-toolbar', {\n\t\t'has-parent': hasParents && showParentSelector,\n\t\t'is-fixed': isFixed,\n\t\t'is-collapsed': isCollapsed,\n\t} );\n\n\treturn (\n\t\t<NavigableToolbar\n\t\t\tfocusOnMount={ focusOnMount }\n\t\t\tclassName={ classes }\n\t\t\t/* translators: accessibility text for the block toolbar */\n\t\t\taria-label={ __( 'Block tools' ) }\n\t\t\tvariant={ isFixed ? 'unstyled' : undefined }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ ! isCollapsed && <BlockToolbar hideDragHandle={ isFixed } /> }\n\t\t\t{ isFixed && isLargeViewport && blockType && (\n\t\t\t\t<ToolbarGroup\n\t\t\t\t\tclassName={\n\t\t\t\t\t\tisCollapsed\n\t\t\t\t\t\t\t? 'block-editor-block-toolbar__group-expand-fixed-toolbar'\n\t\t\t\t\t\t\t: 'block-editor-block-toolbar__group-collapse-fixed-toolbar'\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\tas={ ToolbarButton }\n\t\t\t\t\t\tref={ toolbarButtonRef }\n\t\t\t\t\t\ticon={ isCollapsed ? next : previous }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetIsCollapsed( ( collapsed ) => ! collapsed );\n\t\t\t\t\t\t\ttoolbarButtonRef.current.focus();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\tisCollapsed\n\t\t\t\t\t\t\t\t? __( 'Show block tools' )\n\t\t\t\t\t\t\t\t: __( 'Hide block tools' )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t) }\n\t\t</NavigableToolbar>\n\t);\n}\n\nexport default BlockContextualToolbar;\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAMA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AAKA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AAKA,IAAAQ,iBAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,aAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AACA,IAAAW,oBAAA,GAAAX,OAAA;AA/BA;AACA;AACA;;AAGA;AACA;AACA;;AAkBA;AACA;AACA;;AAMA,SAASY,sBAAsBA,CAAE;EAAEC,YAAY;EAAEC,OAAO;EAAE,GAAGC;AAAM,CAAC,EAAG;EACtE;EACA,MAAM,CAAEC,WAAW,EAAEC,cAAc,CAAE,GAAG,IAAAC,iBAAQ,EAAE,KAAM,CAAC;EACzD,MAAMC,gBAAgB,GAAG,IAAAC,eAAM,EAAC,CAAC;EAEjC,MAAMC,eAAe,GAAG,IAAAC,yBAAgB,EAA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5DA,OAAO,IAAIO,eAAe,IAAIE,SAAS,IACxC,IAAAkD,MAAA,CAAAC,aAAA,EAACrE,WAAA,CAAA4E,YAAY;IACZL,SAAS,EACR5D,WAAW,GACR,wDAAwD,GACxD;EACH,GAED,IAAAyD,MAAA,CAAAC,aAAA,EAACrE,WAAA,CAAA6E,WAAW;IACXC,EAAE,EAAGC,yBAAe;IACpBC,GAAG,EAAGlE,gBAAkB;IACxBmE,IAAI,EAAGtE,WAAW,GAAGuE,WAAI,GAAGC,eAAU;IACtCC,OAAO,EAAGA,CAAA,KAAM;MACfxE,cAAc,CAAIyE,SAAS,IAAM,CAAEA,SAAU,CAAC;MAC9CvE,gBAAgB,CAACwE,OAAO,CAACC,KAAK,CAAC,CAAC;IACjC,CAAG;IACHC,KAAK,EACJ7E,WAAW,GACR,IAAA6D,QAAE,EAAE,kBAAmB,CAAC,GACxB,IAAAA,QAAE,EAAE,kBAAmB;EAC1B,CACD,CACY,CAEE,CAAC;AAErB;AAAC,IAAAiB,QAAA,GAEclF,sBAAsB;AAAAmF,OAAA,CAAApB,OAAA,GAAAmB,QAAA"}
|
|
1
|
+
{"version":3,"names":["_classnames","_interopRequireDefault","require","_i18n","_blocks","_data","_navigableToolbar","_blockToolbar","_store","_useHasBlockControls","BlockContextualToolbar","focusOnMount","isFixed","props","blockType","blockEditingMode","hasParents","showParentSelector","selectedBlockClientId","useSelect","select","getBlockName","getBlockParents","getSelectedBlockClientIds","getBlockEditingMode","blockEditorStore","getBlockType","blocksStore","selectedBlockClientIds","_selectedBlockClientId","parents","firstParentClientId","length","parentBlockName","parentBlockType","hasBlockSupport","isToolbarEnabled","hasAnyBlockControls","useHasAnyBlockControls","classes","classnames","_react","createElement","default","focusEditorOnEscape","className","__","variant","undefined","key","hideDragHandle"],"sources":["@wordpress/block-editor/src/components/block-tools/block-contextual-toolbar.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport, store as blocksStore } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport NavigableToolbar from '../navigable-toolbar';\nimport BlockToolbar from '../block-toolbar';\nimport { store as blockEditorStore } from '../../store';\nimport { useHasAnyBlockControls } from '../block-controls/use-has-block-controls';\n\nexport default function BlockContextualToolbar( {\n\tfocusOnMount,\n\tisFixed,\n\t...props\n} ) {\n\tconst {\n\t\tblockType,\n\t\tblockEditingMode,\n\t\thasParents,\n\t\tshowParentSelector,\n\t\tselectedBlockClientId,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetBlockName,\n\t\t\tgetBlockParents,\n\t\t\tgetSelectedBlockClientIds,\n\t\t\tgetBlockEditingMode,\n\t\t} = select( blockEditorStore );\n\t\tconst { getBlockType } = select( blocksStore );\n\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\t\tconst _selectedBlockClientId = selectedBlockClientIds[ 0 ];\n\t\tconst parents = getBlockParents( _selectedBlockClientId );\n\t\tconst firstParentClientId = parents[ parents.length - 1 ];\n\t\tconst parentBlockName = getBlockName( firstParentClientId );\n\t\tconst parentBlockType = getBlockType( parentBlockName );\n\n\t\treturn {\n\t\t\tselectedBlockClientId: _selectedBlockClientId,\n\t\t\tblockType:\n\t\t\t\t_selectedBlockClientId &&\n\t\t\t\tgetBlockType( getBlockName( _selectedBlockClientId ) ),\n\t\t\tblockEditingMode: getBlockEditingMode( _selectedBlockClientId ),\n\t\t\thasParents: parents.length,\n\t\t\tshowParentSelector:\n\t\t\t\tparentBlockType &&\n\t\t\t\tgetBlockEditingMode( firstParentClientId ) === 'default' &&\n\t\t\t\thasBlockSupport(\n\t\t\t\t\tparentBlockType,\n\t\t\t\t\t'__experimentalParentSelector',\n\t\t\t\t\ttrue\n\t\t\t\t) &&\n\t\t\t\tselectedBlockClientIds.length <= 1 &&\n\t\t\t\tgetBlockEditingMode( _selectedBlockClientId ) === 'default',\n\t\t};\n\t}, [] );\n\n\tconst isToolbarEnabled =\n\t\tblockType &&\n\t\thasBlockSupport( blockType, '__experimentalToolbar', true );\n\tconst hasAnyBlockControls = useHasAnyBlockControls();\n\tif (\n\t\t! isToolbarEnabled ||\n\t\t( blockEditingMode !== 'default' && ! hasAnyBlockControls )\n\t) {\n\t\treturn null;\n\t}\n\n\t// Shifts the toolbar to make room for the parent block selector.\n\tconst classes = classnames( 'block-editor-block-contextual-toolbar', {\n\t\t'has-parent': hasParents && showParentSelector,\n\t\t'is-fixed': isFixed,\n\t} );\n\n\treturn (\n\t\t<NavigableToolbar\n\t\t\tfocusOnMount={ focusOnMount }\n\t\t\tfocusEditorOnEscape\n\t\t\tclassName={ classes }\n\t\t\t/* translators: accessibility text for the block toolbar */\n\t\t\taria-label={ __( 'Block tools' ) }\n\t\t\tvariant={ isFixed ? 'unstyled' : undefined }\n\t\t\t// Resets the index whenever the active block changes so\n\t\t\t// this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169\n\t\t\tkey={ selectedBlockClientId }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t<BlockToolbar hideDragHandle={ isFixed } />\n\t\t</NavigableToolbar>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAKA,IAAAI,iBAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,aAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,oBAAA,GAAAP,OAAA;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AAMe,SAASQ,sBAAsBA,CAAE;EAC/CC,YAAY;EACZC,OAAO;EACP,GAAGC;AACJ,CAAC,EAAG;EACH,MAAM;IACLC,SAAS;IAC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,IAAAC,2CAAsB,EAAC,CAAC;EACpD,IACC,CAAEF,gBAAgB,IAChBrB,gBAAgB,KAAK,SAAS,IAAI,CAAEsB,mBAAqB,EAC1D;IACD,OAAO,IAAI;EACZ;;EAEA;EACA,MAAME,OAAO,GAAG,IAAAC,mBAAU,EAAE,uCAAuC,EAAE;IACpE,YAAY,EAAExB,UAAU,IAAIC,kBAAkB;IAC9C,UAAU,EAAEL;EACb,CAAE,CAAC;EAEH,OACC,IAAA6B,MAAA,CAAAC,aAAA,EAACpC,iBAAA,CAAAqC,OAAgB;IAChBhC,YAAY,EAAGA,YAAc;IAC7BiC,mBAAmB;IACnBC,SAAS,EAAGN;IACZ;IACA,cAAa,IAAAO,QAAE,EAAE,aAAc,CAAG;IAClCC,OAAO,EAAGnC,OAAO,GAAG,UAAU,GAAGoC;IACjC;IACA;IAAA;IACAC,GAAG,EAAG/B,qBAAuB;IAAA,GACxBL;EAAK,GAEV,IAAA4B,MAAA,CAAAC,aAAA,EAACnC,aAAA,CAAAoC,OAAY;IAACO,cAAc,EAAGtC;EAAS,CAAE,CACzB,CAAC;AAErB"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = EmptyBlockInserter;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
+
var _blockPopover = _interopRequireDefault(require("../block-popover"));
|
|
11
|
+
var _useBlockToolbarPopoverProps = _interopRequireDefault(require("./use-block-toolbar-popover-props"));
|
|
12
|
+
var _inserter = _interopRequireDefault(require("../inserter"));
|
|
13
|
+
var _useSelectedBlockToolProps = _interopRequireDefault(require("./use-selected-block-tool-props"));
|
|
14
|
+
/**
|
|
15
|
+
* External dependencies
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Internal dependencies
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
function EmptyBlockInserter({
|
|
23
|
+
clientId,
|
|
24
|
+
__unstableContentRef
|
|
25
|
+
}) {
|
|
26
|
+
const {
|
|
27
|
+
capturingClientId,
|
|
28
|
+
isInsertionPointVisible,
|
|
29
|
+
lastClientId,
|
|
30
|
+
rootClientId
|
|
31
|
+
} = (0, _useSelectedBlockToolProps.default)(clientId);
|
|
32
|
+
const popoverProps = (0, _useBlockToolbarPopoverProps.default)({
|
|
33
|
+
contentElement: __unstableContentRef?.current,
|
|
34
|
+
clientId
|
|
35
|
+
});
|
|
36
|
+
return (0, _react.createElement)(_blockPopover.default, {
|
|
37
|
+
clientId: capturingClientId || clientId,
|
|
38
|
+
__unstableCoverTarget: true,
|
|
39
|
+
bottomClientId: lastClientId,
|
|
40
|
+
className: (0, _classnames.default)('block-editor-block-list__block-side-inserter-popover', {
|
|
41
|
+
'is-insertion-point-visible': isInsertionPointVisible
|
|
42
|
+
}),
|
|
43
|
+
__unstableContentRef: __unstableContentRef,
|
|
44
|
+
resize: false,
|
|
45
|
+
shift: false,
|
|
46
|
+
...popoverProps
|
|
47
|
+
}, (0, _react.createElement)("div", {
|
|
48
|
+
className: "block-editor-block-list__empty-block-inserter"
|
|
49
|
+
}, (0, _react.createElement)(_inserter.default, {
|
|
50
|
+
position: "bottom right",
|
|
51
|
+
rootClientId: rootClientId,
|
|
52
|
+
clientId: clientId,
|
|
53
|
+
__experimentalIsQuick: true
|
|
54
|
+
})));
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=empty-block-inserter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_classnames","_interopRequireDefault","require","_blockPopover","_useBlockToolbarPopoverProps","_inserter","_useSelectedBlockToolProps","EmptyBlockInserter","clientId","__unstableContentRef","capturingClientId","isInsertionPointVisible","lastClientId","rootClientId","useSelectedBlockToolProps","popoverProps","useBlockToolbarPopoverProps","contentElement","current","_react","createElement","default","__unstableCoverTarget","bottomClientId","className","classnames","resize","shift","position","__experimentalIsQuick"],"sources":["@wordpress/block-editor/src/components/block-tools/empty-block-inserter.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * Internal dependencies\n */\nimport BlockPopover from '../block-popover';\nimport useBlockToolbarPopoverProps from './use-block-toolbar-popover-props';\nimport Inserter from '../inserter';\nimport useSelectedBlockToolProps from './use-selected-block-tool-props';\n\nexport default function EmptyBlockInserter( {\n\tclientId,\n\t__unstableContentRef,\n} ) {\n\tconst {\n\t\tcapturingClientId,\n\t\tisInsertionPointVisible,\n\t\tlastClientId,\n\t\trootClientId,\n\t} = useSelectedBlockToolProps( clientId );\n\n\tconst popoverProps = useBlockToolbarPopoverProps( {\n\t\tcontentElement: __unstableContentRef?.current,\n\t\tclientId,\n\t} );\n\n\treturn (\n\t\t<BlockPopover\n\t\t\tclientId={ capturingClientId || clientId }\n\t\t\t__unstableCoverTarget\n\t\t\tbottomClientId={ lastClientId }\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-block-list__block-side-inserter-popover',\n\t\t\t\t{\n\t\t\t\t\t'is-insertion-point-visible': isInsertionPointVisible,\n\t\t\t\t}\n\t\t\t) }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\tresize={ false }\n\t\t\tshift={ false }\n\t\t\t{ ...popoverProps }\n\t\t>\n\t\t\t<div className=\"block-editor-block-list__empty-block-inserter\">\n\t\t\t\t<Inserter\n\t\t\t\t\tposition=\"bottom right\"\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t__experimentalIsQuick\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</BlockPopover>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,aAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,4BAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,SAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,0BAAA,GAAAL,sBAAA,CAAAC,OAAA;AAXA;AACA;AACA;;AAGA;AACA;AACA;;AAMe,SAASK,kBAAkBA,CAAE;EAC3CC,QAAQ;EACRC;AACD,CAAC,EAAG;EACH,MAAM;IACLC,iBAAiB;IACjBC,uBAAuB;IACvBC,YAAY;IACZC;EACD,CAAC,GAAG,IAAAC,kCAAyB,EAAEN,QAAS,CAAC;EAEzC,MAAMO,YAAY,GAAG,IAAAC,oCAA2B,EAAE;IACjDC,cAAc,EAAER,oBAAoB,EAAES,OAAO;IAC7CV;EACD,CAAE,CAAC;EAEH,OACC,IAAAW,MAAA,CAAAC,aAAA,EAACjB,aAAA,CAAAkB,OAAY;IACZb,QAAQ,EAAGE,iBAAiB,IAAIF,QAAU;IAC1Cc,qBAAqB;IACrBC,cAAc,EAAGX,YAAc;IAC/BY,SAAS,EAAG,IAAAC,mBAAU,EACrB,sDAAsD,EACtD;MACC,4BAA4B,EAAEd;IAC/B,CACD,CAAG;IACHF,oBAAoB,EAAGA,oBAAsB;IAC7CiB,MAAM,EAAG,KAAO;IAChBC,KAAK,EAAG,KAAO;IAAA,GACVZ;EAAY,GAEjB,IAAAI,MAAA,CAAAC,aAAA;IAAKI,SAAS,EAAC;EAA+C,GAC7D,IAAAL,MAAA,CAAAC,aAAA,EAACf,SAAA,CAAAgB,OAAQ;IACRO,QAAQ,EAAC,cAAc;IACvBf,YAAY,EAAGA,YAAc;IAC7BL,QAAQ,EAAGA,QAAU;IACrBqB,qBAAqB;EAAA,CACrB,CACG,CACQ,CAAC;AAEjB"}
|
|
@@ -11,8 +11,10 @@ var _compose = require("@wordpress/compose");
|
|
|
11
11
|
var _components = require("@wordpress/components");
|
|
12
12
|
var _keyboardShortcuts = require("@wordpress/keyboard-shortcuts");
|
|
13
13
|
var _element = require("@wordpress/element");
|
|
14
|
+
var _blocks = require("@wordpress/blocks");
|
|
15
|
+
var _emptyBlockInserter = _interopRequireDefault(require("./empty-block-inserter"));
|
|
14
16
|
var _insertionPoint = _interopRequireWildcard(require("./insertion-point"));
|
|
15
|
-
var
|
|
17
|
+
var _selectedBlockTools = _interopRequireDefault(require("./selected-block-tools"));
|
|
16
18
|
var _store = require("../../store");
|
|
17
19
|
var _blockContextualToolbar = _interopRequireDefault(require("./block-contextual-toolbar"));
|
|
18
20
|
var _usePopoverScroll = _interopRequireDefault(require("../block-popover/use-popover-scroll"));
|
|
@@ -29,14 +31,28 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
29
31
|
|
|
30
32
|
function selector(select) {
|
|
31
33
|
const {
|
|
32
|
-
|
|
34
|
+
getSelectedBlockClientId,
|
|
35
|
+
getFirstMultiSelectedBlockClientId,
|
|
36
|
+
getBlock,
|
|
33
37
|
getSettings,
|
|
38
|
+
__unstableGetEditorMode,
|
|
34
39
|
isTyping
|
|
35
40
|
} = select(_store.store);
|
|
41
|
+
const clientId = getSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();
|
|
42
|
+
const {
|
|
43
|
+
name = '',
|
|
44
|
+
attributes = {}
|
|
45
|
+
} = getBlock(clientId) || {};
|
|
36
46
|
return {
|
|
37
|
-
|
|
47
|
+
clientId,
|
|
38
48
|
hasFixedToolbar: getSettings().hasFixedToolbar,
|
|
39
|
-
|
|
49
|
+
hasSelectedBlock: clientId && name,
|
|
50
|
+
isTyping: isTyping(),
|
|
51
|
+
isZoomOutMode: __unstableGetEditorMode() === 'zoom-out',
|
|
52
|
+
showEmptyBlockSideInserter: clientId && !isTyping() && __unstableGetEditorMode() === 'edit' && (0, _blocks.isUnmodifiedDefaultBlock)({
|
|
53
|
+
name,
|
|
54
|
+
attributes
|
|
55
|
+
})
|
|
40
56
|
};
|
|
41
57
|
}
|
|
42
58
|
|
|
@@ -56,9 +72,12 @@ function BlockTools({
|
|
|
56
72
|
}) {
|
|
57
73
|
const isLargeViewport = (0, _compose.useViewportMatch)('medium');
|
|
58
74
|
const {
|
|
75
|
+
clientId,
|
|
59
76
|
hasFixedToolbar,
|
|
77
|
+
hasSelectedBlock,
|
|
78
|
+
isTyping,
|
|
60
79
|
isZoomOutMode,
|
|
61
|
-
|
|
80
|
+
showEmptyBlockSideInserter
|
|
62
81
|
} = (0, _data.useSelect)(selector, []);
|
|
63
82
|
const isMatch = (0, _keyboardShortcuts.__unstableUseShortcutEventMatch)();
|
|
64
83
|
const {
|
|
@@ -116,6 +135,14 @@ function BlockTools({
|
|
|
116
135
|
insertBeforeBlock(clientIds[0]);
|
|
117
136
|
}
|
|
118
137
|
} else if (isMatch('core/block-editor/unselect', event)) {
|
|
138
|
+
if (event.target.closest('[role=toolbar]')) {
|
|
139
|
+
// This shouldn't be necessary, but we have a combination of a few things all combining to create a situation where:
|
|
140
|
+
// - 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
|
|
141
|
+
// - Since we can't use the React tree, we use the DOM tree which _should_ handle the event bubbling correctly from a `createPortal` element.
|
|
142
|
+
// - This bubbles via the React tree, which hits this `unselect` escape keypress before the block toolbar DOM event listener has access to it.
|
|
143
|
+
// 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.
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
119
146
|
const clientIds = getSelectedBlockClientIds();
|
|
120
147
|
if (clientIds.length) {
|
|
121
148
|
event.preventDefault();
|
|
@@ -135,6 +162,12 @@ function BlockTools({
|
|
|
135
162
|
}
|
|
136
163
|
const blockToolbarRef = (0, _usePopoverScroll.default)(__unstableContentRef);
|
|
137
164
|
const blockToolbarAfterRef = (0, _usePopoverScroll.default)(__unstableContentRef);
|
|
165
|
+
|
|
166
|
+
// Conditions for fixed toolbar
|
|
167
|
+
// 1. Not zoom out mode
|
|
168
|
+
// 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.
|
|
169
|
+
// 3. Fixed toolbar is enabled
|
|
170
|
+
const isTopToolbar = !isZoomOutMode && hasFixedToolbar && isLargeViewport;
|
|
138
171
|
return (
|
|
139
172
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
140
173
|
(0, _react.createElement)("div", {
|
|
@@ -144,11 +177,17 @@ function BlockTools({
|
|
|
144
177
|
value: (0, _element.useRef)(false)
|
|
145
178
|
}, !isTyping && (0, _react.createElement)(_insertionPoint.default, {
|
|
146
179
|
__unstableContentRef: __unstableContentRef
|
|
147
|
-
}), !
|
|
180
|
+
}), !isLargeViewport &&
|
|
181
|
+
// Small viewports always get a fixed toolbar
|
|
182
|
+
(0, _react.createElement)(_blockContextualToolbar.default, {
|
|
148
183
|
isFixed: true
|
|
149
|
-
}), (0, _react.createElement)(
|
|
150
|
-
__unstableContentRef: __unstableContentRef
|
|
151
|
-
|
|
184
|
+
}), showEmptyBlockSideInserter && (0, _react.createElement)(_emptyBlockInserter.default, {
|
|
185
|
+
__unstableContentRef: __unstableContentRef,
|
|
186
|
+
clientId: clientId
|
|
187
|
+
}), !showEmptyBlockSideInserter && hasSelectedBlock && (0, _react.createElement)(_selectedBlockTools.default, {
|
|
188
|
+
__unstableContentRef: __unstableContentRef,
|
|
189
|
+
clientId: clientId
|
|
190
|
+
}), !isTopToolbar && (0, _react.createElement)(_components.Popover.Slot, {
|
|
152
191
|
name: "block-toolbar",
|
|
153
192
|
ref: blockToolbarRef
|
|
154
193
|
}), children, (0, _react.createElement)(_components.Popover.Slot, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_compose","_components","_keyboardShortcuts","_element","_insertionPoint","_interopRequireWildcard","_selectedBlockPopover","_interopRequireDefault","_store","_blockContextualToolbar","_usePopoverScroll","_zoomOutModeInserters","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","selector","select","__unstableGetEditorMode","getSettings","isTyping","blockEditorStore","isZoomOutMode","hasFixedToolbar","BlockTools","children","__unstableContentRef","props","isLargeViewport","useViewportMatch","useSelect","isMatch","useShortcutEventMatch","getSelectedBlockClientIds","getBlockRootClientId","duplicateBlocks","removeBlocks","insertAfterBlock","insertBeforeBlock","clearSelectedBlock","selectBlock","moveBlocksUp","moveBlocksDown","useDispatch","onKeyDown","event","defaultPrevented","clientIds","length","preventDefault","rootClientId","target","ownerDocument","defaultView","getSelection","removeAllRanges","current","focus","blockToolbarRef","usePopoverScroll","blockToolbarAfterRef","_react","createElement","InsertionPointOpenRef","Provider","value","useRef","isFixed","Popover","Slot","name","ref"],"sources":["@wordpress/block-editor/src/components/block-tools/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { Popover } from '@wordpress/components';\nimport { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tInsertionPointOpenRef,\n\tdefault as InsertionPoint,\n} from './insertion-point';\nimport SelectedBlockPopover from './selected-block-popover';\nimport { store as blockEditorStore } from '../../store';\nimport BlockContextualToolbar from './block-contextual-toolbar';\nimport usePopoverScroll from '../block-popover/use-popover-scroll';\nimport ZoomOutModeInserters from './zoom-out-mode-inserters';\n\nfunction selector( select ) {\n\tconst { __unstableGetEditorMode, getSettings, isTyping } =\n\t\tselect( blockEditorStore );\n\n\treturn {\n\t\tisZoomOutMode: __unstableGetEditorMode() === 'zoom-out',\n\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\tisTyping: isTyping(),\n\t};\n}\n\n/**\n * Renders block tools (the block toolbar, select/navigation mode toolbar, the\n * insertion point and a slot for the inline rich text toolbar). Must be wrapped\n * around the block content and editor styles wrapper or iframe.\n *\n * @param {Object} $0 Props.\n * @param {Object} $0.children The block content and style container.\n * @param {Object} $0.__unstableContentRef Ref holding the content scroll container.\n */\nexport default function BlockTools( {\n\tchildren,\n\t__unstableContentRef,\n\t...props\n} ) {\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst { hasFixedToolbar, isZoomOutMode, isTyping } = useSelect(\n\t\tselector,\n\t\t[]\n\t);\n\tconst isMatch = useShortcutEventMatch();\n\tconst { getSelectedBlockClientIds, getBlockRootClientId } =\n\t\tuseSelect( blockEditorStore );\n\tconst {\n\t\tduplicateBlocks,\n\t\tremoveBlocks,\n\t\tinsertAfterBlock,\n\t\tinsertBeforeBlock,\n\t\tclearSelectedBlock,\n\t\tselectBlock,\n\t\tmoveBlocksUp,\n\t\tmoveBlocksDown,\n\t} = useDispatch( blockEditorStore );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.defaultPrevented ) return;\n\n\t\tif ( isMatch( 'core/block-editor/move-up', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\t\tmoveBlocksUp( clientIds, rootClientId );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/move-down', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\t\tmoveBlocksDown( clientIds, rootClientId );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/duplicate', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tduplicateBlocks( clientIds );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/remove', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tremoveBlocks( clientIds );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-after', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tinsertAfterBlock( clientIds[ clientIds.length - 1 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-before', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tinsertBeforeBlock( clientIds[ 0 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/unselect', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\n\t\t\t\t// If there is more than one block selected, select the first\n\t\t\t\t// block so that focus is directed back to the beginning of the selection.\n\t\t\t\t// In effect, to the user this feels like deselecting the multi-selection.\n\t\t\t\tif ( clientIds.length > 1 ) {\n\t\t\t\t\tselectBlock( clientIds[ 0 ] );\n\t\t\t\t} else {\n\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t}\n\t\t\t\tevent.target.ownerDocument.defaultView\n\t\t\t\t\t.getSelection()\n\t\t\t\t\t.removeAllRanges();\n\t\t\t\t__unstableContentRef?.current.focus();\n\t\t\t}\n\t\t}\n\t}\n\n\tconst blockToolbarRef = usePopoverScroll( __unstableContentRef );\n\tconst blockToolbarAfterRef = usePopoverScroll( __unstableContentRef );\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div { ...props } onKeyDown={ onKeyDown }>\n\t\t\t<InsertionPointOpenRef.Provider value={ useRef( false ) }>\n\t\t\t\t{ ! isTyping && (\n\t\t\t\t\t<InsertionPoint\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ ! isZoomOutMode &&\n\t\t\t\t\t( hasFixedToolbar || ! isLargeViewport ) && (\n\t\t\t\t\t\t<BlockContextualToolbar isFixed />\n\t\t\t\t\t) }\n\t\t\t\t{ /* Even if the toolbar is fixed, the block popover is still\n\t\t\t\t\tneeded for navigation and zoom-out mode. */ }\n\t\t\t\t<SelectedBlockPopover\n\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t/>\n\t\t\t\t{ /* Used for the inline rich text toolbar. */ }\n\t\t\t\t<Popover.Slot name=\"block-toolbar\" ref={ blockToolbarRef } />\n\t\t\t\t{ children }\n\t\t\t\t{ /* Used for inline rich text popovers. */ }\n\t\t\t\t<Popover.Slot\n\t\t\t\t\tname=\"__unstable-block-tools-after\"\n\t\t\t\t\tref={ blockToolbarAfterRef }\n\t\t\t\t/>\n\t\t\t\t{ isZoomOutMode && (\n\t\t\t\t\t<ZoomOutModeInserters\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InsertionPointOpenRef.Provider>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAKA,IAAAK,eAAA,GAAAC,uBAAA,CAAAN,OAAA;AAIA,IAAAO,qBAAA,GAAAC,sBAAA,CAAAR,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,uBAAA,GAAAF,sBAAA,CAAAR,OAAA;AACA,IAAAW,iBAAA,GAAAH,sBAAA,CAAAR,OAAA;AACA,IAAAY,qBAAA,GAAAJ,sBAAA,CAAAR,OAAA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,EAAC1E,qBAAA,CAAAa,OAAoB;MACpByB,oBAAoB,EAAGA;IAAsB,CAC7C,CAAC,EAEF,IAAAmC,MAAA,CAAAC,aAAA,EAAC/E,WAAA,CAAAqF,OAAO,CAACC,IAAI;MAACC,IAAI,EAAC,eAAe;MAACC,GAAG,EAAGb;IAAiB,CAAE,CAAC,EAC3DjC,QAAQ,EAEV,IAAAoC,MAAA,CAAAC,aAAA,EAAC/E,WAAA,CAAAqF,OAAO,CAACC,IAAI;MACZC,IAAI,EAAC,8BAA8B;MACnCC,GAAG,EAAGX;IAAsB,CAC5B,CAAC,EACAtC,aAAa,IACd,IAAAuC,MAAA,CAAAC,aAAA,EAACrE,qBAAA,CAAAQ,OAAoB;MACpByB,oBAAoB,EAAGA;IAAsB,CAC7C,CAE6B,CAC5B;EAAC;AAER"}
|
|
1
|
+
{"version":3,"names":["_data","require","_compose","_components","_keyboardShortcuts","_element","_blocks","_emptyBlockInserter","_interopRequireDefault","_insertionPoint","_interopRequireWildcard","_selectedBlockTools","_store","_blockContextualToolbar","_usePopoverScroll","_zoomOutModeInserters","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","selector","select","getSelectedBlockClientId","getFirstMultiSelectedBlockClientId","getBlock","getSettings","__unstableGetEditorMode","isTyping","blockEditorStore","clientId","name","attributes","hasFixedToolbar","hasSelectedBlock","isZoomOutMode","showEmptyBlockSideInserter","isUnmodifiedDefaultBlock","BlockTools","children","__unstableContentRef","props","isLargeViewport","useViewportMatch","useSelect","isMatch","useShortcutEventMatch","getSelectedBlockClientIds","getBlockRootClientId","duplicateBlocks","removeBlocks","insertAfterBlock","insertBeforeBlock","clearSelectedBlock","selectBlock","moveBlocksUp","moveBlocksDown","useDispatch","onKeyDown","event","defaultPrevented","clientIds","length","preventDefault","rootClientId","target","closest","ownerDocument","defaultView","getSelection","removeAllRanges","current","focus","blockToolbarRef","usePopoverScroll","blockToolbarAfterRef","isTopToolbar","_react","createElement","InsertionPointOpenRef","Provider","value","useRef","isFixed","Popover","Slot","ref"],"sources":["@wordpress/block-editor/src/components/block-tools/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { Popover } from '@wordpress/components';\nimport { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';\nimport { useRef } from '@wordpress/element';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport EmptyBlockInserter from './empty-block-inserter';\nimport {\n\tInsertionPointOpenRef,\n\tdefault as InsertionPoint,\n} from './insertion-point';\nimport SelectedBlockTools from './selected-block-tools';\nimport { store as blockEditorStore } from '../../store';\nimport BlockContextualToolbar from './block-contextual-toolbar';\nimport usePopoverScroll from '../block-popover/use-popover-scroll';\nimport ZoomOutModeInserters from './zoom-out-mode-inserters';\n\nfunction selector( select ) {\n\tconst {\n\t\tgetSelectedBlockClientId,\n\t\tgetFirstMultiSelectedBlockClientId,\n\t\tgetBlock,\n\t\tgetSettings,\n\t\t__unstableGetEditorMode,\n\t\tisTyping,\n\t} = select( blockEditorStore );\n\n\tconst clientId =\n\t\tgetSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();\n\n\tconst { name = '', attributes = {} } = getBlock( clientId ) || {};\n\n\treturn {\n\t\tclientId,\n\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\thasSelectedBlock: clientId && name,\n\t\tisTyping: isTyping(),\n\t\tisZoomOutMode: __unstableGetEditorMode() === 'zoom-out',\n\t\tshowEmptyBlockSideInserter:\n\t\t\tclientId &&\n\t\t\t! isTyping() &&\n\t\t\t__unstableGetEditorMode() === 'edit' &&\n\t\t\tisUnmodifiedDefaultBlock( { name, attributes } ),\n\t};\n}\n\n/**\n * Renders block tools (the block toolbar, select/navigation mode toolbar, the\n * insertion point and a slot for the inline rich text toolbar). Must be wrapped\n * around the block content and editor styles wrapper or iframe.\n *\n * @param {Object} $0 Props.\n * @param {Object} $0.children The block content and style container.\n * @param {Object} $0.__unstableContentRef Ref holding the content scroll container.\n */\nexport default function BlockTools( {\n\tchildren,\n\t__unstableContentRef,\n\t...props\n} ) {\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst {\n\t\tclientId,\n\t\thasFixedToolbar,\n\t\thasSelectedBlock,\n\t\tisTyping,\n\t\tisZoomOutMode,\n\t\tshowEmptyBlockSideInserter,\n\t} = useSelect( selector, [] );\n\tconst isMatch = useShortcutEventMatch();\n\tconst { getSelectedBlockClientIds, getBlockRootClientId } =\n\t\tuseSelect( blockEditorStore );\n\tconst {\n\t\tduplicateBlocks,\n\t\tremoveBlocks,\n\t\tinsertAfterBlock,\n\t\tinsertBeforeBlock,\n\t\tclearSelectedBlock,\n\t\tselectBlock,\n\t\tmoveBlocksUp,\n\t\tmoveBlocksDown,\n\t} = useDispatch( blockEditorStore );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.defaultPrevented ) return;\n\n\t\tif ( isMatch( 'core/block-editor/move-up', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\t\tmoveBlocksUp( clientIds, rootClientId );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/move-down', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\t\tmoveBlocksDown( clientIds, rootClientId );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/duplicate', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tduplicateBlocks( clientIds );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/remove', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tremoveBlocks( clientIds );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-after', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tinsertAfterBlock( clientIds[ clientIds.length - 1 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-before', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tinsertBeforeBlock( clientIds[ 0 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/unselect', event ) ) {\n\t\t\tif ( event.target.closest( '[role=toolbar]' ) ) {\n\t\t\t\t// This shouldn't be necessary, but we have a combination of a few things all combining to create a situation where:\n\t\t\t\t// - 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\n\t\t\t\t// - Since we can't use the React tree, we use the DOM tree which _should_ handle the event bubbling correctly from a `createPortal` element.\n\t\t\t\t// - This bubbles via the React tree, which hits this `unselect` escape keypress before the block toolbar DOM event listener has access to it.\n\t\t\t\t// 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.\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\n\t\t\t\t// If there is more than one block selected, select the first\n\t\t\t\t// block so that focus is directed back to the beginning of the selection.\n\t\t\t\t// In effect, to the user this feels like deselecting the multi-selection.\n\t\t\t\tif ( clientIds.length > 1 ) {\n\t\t\t\t\tselectBlock( clientIds[ 0 ] );\n\t\t\t\t} else {\n\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t}\n\t\t\t\tevent.target.ownerDocument.defaultView\n\t\t\t\t\t.getSelection()\n\t\t\t\t\t.removeAllRanges();\n\t\t\t\t__unstableContentRef?.current.focus();\n\t\t\t}\n\t\t}\n\t}\n\n\tconst blockToolbarRef = usePopoverScroll( __unstableContentRef );\n\tconst blockToolbarAfterRef = usePopoverScroll( __unstableContentRef );\n\n\t// Conditions for fixed toolbar\n\t// 1. Not zoom out mode\n\t// 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.\n\t// 3. Fixed toolbar is enabled\n\tconst isTopToolbar = ! isZoomOutMode && hasFixedToolbar && isLargeViewport;\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div { ...props } onKeyDown={ onKeyDown }>\n\t\t\t<InsertionPointOpenRef.Provider value={ useRef( false ) }>\n\t\t\t\t{ ! isTyping && (\n\t\t\t\t\t<InsertionPoint\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ /* If there is no slot available, such as in the standalone block editor, render within the editor */ }\n\n\t\t\t\t{ ! isLargeViewport && ( // Small viewports always get a fixed toolbar\n\t\t\t\t\t<BlockContextualToolbar isFixed />\n\t\t\t\t) }\n\n\t\t\t\t{ showEmptyBlockSideInserter && (\n\t\t\t\t\t<EmptyBlockInserter\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ /* Even if the toolbar is fixed, the block popover is still\n\t\t\t\t\tneeded for navigation and zoom-out mode. */ }\n\t\t\t\t{ ! showEmptyBlockSideInserter && hasSelectedBlock && (\n\t\t\t\t\t<SelectedBlockTools\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ /* Used for the inline rich text toolbar. */ }\n\t\t\t\t{ ! isTopToolbar && (\n\t\t\t\t\t<Popover.Slot\n\t\t\t\t\t\tname=\"block-toolbar\"\n\t\t\t\t\t\tref={ blockToolbarRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ children }\n\t\t\t\t{ /* Used for inline rich text popovers. */ }\n\t\t\t\t<Popover.Slot\n\t\t\t\t\tname=\"__unstable-block-tools-after\"\n\t\t\t\t\tref={ blockToolbarAfterRef }\n\t\t\t\t/>\n\t\t\t\t{ isZoomOutMode && (\n\t\t\t\t\t<ZoomOutModeInserters\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InsertionPointOpenRef.Provider>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAKA,IAAAM,mBAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,eAAA,GAAAC,uBAAA,CAAAT,OAAA;AAIA,IAAAU,mBAAA,GAAAH,sBAAA,CAAAP,OAAA;AACA,IAAAW,MAAA,GAAAX,OAAA;AACA,IAAAY,uBAAA,GAAAL,sBAAA,CAAAP,OAAA;AACA,IAAAa,iBAAA,GAAAN,sBAAA,CAAAP,OAAA;AACA,IAAAc,qBAAA,GAAAP,sBAAA,CAAAP,OAAA;AAA6D,SAAAe,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QA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0C,MAAA,CAAAC,aAAA,EAAChF,qBAAA,CAAAQ,OAAoB;MACpBkC,oBAAoB,EAAGA;IAAsB,CAC7C,CAE6B,CAC5B;EAAC;AAER"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = SelectedBlockTools;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
+
var _element = require("@wordpress/element");
|
|
11
|
+
var _data = require("@wordpress/data");
|
|
12
|
+
var _keyboardShortcuts = require("@wordpress/keyboard-shortcuts");
|
|
13
|
+
var _blockSelectionButton = _interopRequireDefault(require("./block-selection-button"));
|
|
14
|
+
var _blockContextualToolbar = _interopRequireDefault(require("./block-contextual-toolbar"));
|
|
15
|
+
var _store = require("../../store");
|
|
16
|
+
var _blockPopover = _interopRequireDefault(require("../block-popover"));
|
|
17
|
+
var _useBlockToolbarPopoverProps = _interopRequireDefault(require("./use-block-toolbar-popover-props"));
|
|
18
|
+
var _useSelectedBlockToolProps = _interopRequireDefault(require("./use-selected-block-tool-props"));
|
|
19
|
+
var _useShouldContextualToolbarShow = require("../../utils/use-should-contextual-toolbar-show");
|
|
20
|
+
/**
|
|
21
|
+
* External dependencies
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* WordPress dependencies
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Internal dependencies
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
function SelectedBlockTools({
|
|
33
|
+
clientId,
|
|
34
|
+
showEmptyBlockSideInserter,
|
|
35
|
+
__unstableContentRef
|
|
36
|
+
}) {
|
|
37
|
+
const {
|
|
38
|
+
capturingClientId,
|
|
39
|
+
isInsertionPointVisible,
|
|
40
|
+
lastClientId,
|
|
41
|
+
rootClientId
|
|
42
|
+
} = (0, _useSelectedBlockToolProps.default)(clientId);
|
|
43
|
+
const {
|
|
44
|
+
shouldShowBreadcrumb
|
|
45
|
+
} = (0, _data.useSelect)(select => {
|
|
46
|
+
const {
|
|
47
|
+
hasMultiSelection,
|
|
48
|
+
__unstableGetEditorMode
|
|
49
|
+
} = select(_store.store);
|
|
50
|
+
const editorMode = __unstableGetEditorMode();
|
|
51
|
+
return {
|
|
52
|
+
shouldShowBreadcrumb: !hasMultiSelection() && (editorMode === 'navigation' || editorMode === 'zoom-out')
|
|
53
|
+
};
|
|
54
|
+
}, []);
|
|
55
|
+
const isToolbarForced = (0, _element.useRef)(false);
|
|
56
|
+
const {
|
|
57
|
+
shouldShowContextualToolbar,
|
|
58
|
+
canFocusHiddenToolbar
|
|
59
|
+
} = (0, _useShouldContextualToolbarShow.useShouldContextualToolbarShow)();
|
|
60
|
+
const {
|
|
61
|
+
stopTyping
|
|
62
|
+
} = (0, _data.useDispatch)(_store.store);
|
|
63
|
+
(0, _keyboardShortcuts.useShortcut)('core/block-editor/focus-toolbar', () => {
|
|
64
|
+
isToolbarForced.current = true;
|
|
65
|
+
stopTyping(true);
|
|
66
|
+
}, {
|
|
67
|
+
isDisabled: !canFocusHiddenToolbar
|
|
68
|
+
});
|
|
69
|
+
(0, _element.useEffect)(() => {
|
|
70
|
+
isToolbarForced.current = false;
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Stores the active toolbar item index so the block toolbar can return focus
|
|
74
|
+
// to it when re-mounting.
|
|
75
|
+
const initialToolbarItemIndexRef = (0, _element.useRef)();
|
|
76
|
+
(0, _element.useEffect)(() => {
|
|
77
|
+
// Resets the index whenever the active block changes so this is not
|
|
78
|
+
// persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169
|
|
79
|
+
initialToolbarItemIndexRef.current = undefined;
|
|
80
|
+
}, [clientId]);
|
|
81
|
+
const popoverProps = (0, _useBlockToolbarPopoverProps.default)({
|
|
82
|
+
contentElement: __unstableContentRef?.current,
|
|
83
|
+
clientId
|
|
84
|
+
});
|
|
85
|
+
if (showEmptyBlockSideInserter) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
if (shouldShowBreadcrumb || shouldShowContextualToolbar) {
|
|
89
|
+
return (0, _react.createElement)(_blockPopover.default, {
|
|
90
|
+
clientId: capturingClientId || clientId,
|
|
91
|
+
bottomClientId: lastClientId,
|
|
92
|
+
className: (0, _classnames.default)('block-editor-block-list__block-popover', {
|
|
93
|
+
'is-insertion-point-visible': isInsertionPointVisible
|
|
94
|
+
}),
|
|
95
|
+
resize: false,
|
|
96
|
+
...popoverProps
|
|
97
|
+
}, shouldShowContextualToolbar && (0, _react.createElement)(_blockContextualToolbar.default
|
|
98
|
+
// If the toolbar is being shown because of being forced
|
|
99
|
+
// it should focus the toolbar right after the mount.
|
|
100
|
+
, {
|
|
101
|
+
focusOnMount: isToolbarForced.current,
|
|
102
|
+
__experimentalInitialIndex: initialToolbarItemIndexRef.current,
|
|
103
|
+
__experimentalOnIndexChange: index => {
|
|
104
|
+
initialToolbarItemIndexRef.current = index;
|
|
105
|
+
}
|
|
106
|
+
}), shouldShowBreadcrumb && (0, _react.createElement)(_blockSelectionButton.default, {
|
|
107
|
+
clientId: clientId,
|
|
108
|
+
rootClientId: rootClientId
|
|
109
|
+
}));
|
|
110
|
+
}
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=selected-block-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_classnames","_interopRequireDefault","require","_element","_data","_keyboardShortcuts","_blockSelectionButton","_blockContextualToolbar","_store","_blockPopover","_useBlockToolbarPopoverProps","_useSelectedBlockToolProps","_useShouldContextualToolbarShow","SelectedBlockTools","clientId","showEmptyBlockSideInserter","__unstableContentRef","capturingClientId","isInsertionPointVisible","lastClientId","rootClientId","useSelectedBlockToolProps","shouldShowBreadcrumb","useSelect","select","hasMultiSelection","__unstableGetEditorMode","blockEditorStore","editorMode","isToolbarForced","useRef","shouldShowContextualToolbar","canFocusHiddenToolbar","useShouldContextualToolbarShow","stopTyping","useDispatch","useShortcut","current","isDisabled","useEffect","initialToolbarItemIndexRef","undefined","popoverProps","useBlockToolbarPopoverProps","contentElement","_react","createElement","default","bottomClientId","className","classnames","resize","focusOnMount","__experimentalInitialIndex","__experimentalOnIndexChange","index"],"sources":["@wordpress/block-editor/src/components/block-tools/selected-block-tools.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\n\n/**\n * Internal dependencies\n */\nimport BlockSelectionButton from './block-selection-button';\nimport BlockContextualToolbar from './block-contextual-toolbar';\nimport { store as blockEditorStore } from '../../store';\nimport BlockPopover from '../block-popover';\nimport useBlockToolbarPopoverProps from './use-block-toolbar-popover-props';\nimport useSelectedBlockToolProps from './use-selected-block-tool-props';\nimport { useShouldContextualToolbarShow } from '../../utils/use-should-contextual-toolbar-show';\n\nexport default function SelectedBlockTools( {\n\tclientId,\n\tshowEmptyBlockSideInserter,\n\t__unstableContentRef,\n} ) {\n\tconst {\n\t\tcapturingClientId,\n\t\tisInsertionPointVisible,\n\t\tlastClientId,\n\t\trootClientId,\n\t} = useSelectedBlockToolProps( clientId );\n\n\tconst { shouldShowBreadcrumb } = useSelect( ( select ) => {\n\t\tconst { hasMultiSelection, __unstableGetEditorMode } =\n\t\t\tselect( blockEditorStore );\n\n\t\tconst editorMode = __unstableGetEditorMode();\n\n\t\treturn {\n\t\t\tshouldShowBreadcrumb:\n\t\t\t\t! hasMultiSelection() &&\n\t\t\t\t( editorMode === 'navigation' || editorMode === 'zoom-out' ),\n\t\t};\n\t}, [] );\n\n\tconst isToolbarForced = useRef( false );\n\tconst { shouldShowContextualToolbar, canFocusHiddenToolbar } =\n\t\tuseShouldContextualToolbarShow();\n\n\tconst { stopTyping } = useDispatch( blockEditorStore );\n\n\tuseShortcut(\n\t\t'core/block-editor/focus-toolbar',\n\t\t() => {\n\t\t\tisToolbarForced.current = true;\n\t\t\tstopTyping( true );\n\t\t},\n\t\t{\n\t\t\tisDisabled: ! canFocusHiddenToolbar,\n\t\t}\n\t);\n\n\tuseEffect( () => {\n\t\tisToolbarForced.current = false;\n\t} );\n\n\t// Stores the active toolbar item index so the block toolbar can return focus\n\t// to it when re-mounting.\n\tconst initialToolbarItemIndexRef = useRef();\n\n\tuseEffect( () => {\n\t\t// Resets the index whenever the active block changes so this is not\n\t\t// persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169\n\t\tinitialToolbarItemIndexRef.current = undefined;\n\t}, [ clientId ] );\n\n\tconst popoverProps = useBlockToolbarPopoverProps( {\n\t\tcontentElement: __unstableContentRef?.current,\n\t\tclientId,\n\t} );\n\n\tif ( showEmptyBlockSideInserter ) {\n\t\treturn null;\n\t}\n\n\tif ( shouldShowBreadcrumb || shouldShowContextualToolbar ) {\n\t\treturn (\n\t\t\t<BlockPopover\n\t\t\t\tclientId={ capturingClientId || clientId }\n\t\t\t\tbottomClientId={ lastClientId }\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-block-list__block-popover',\n\t\t\t\t\t{\n\t\t\t\t\t\t'is-insertion-point-visible': isInsertionPointVisible,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t\tresize={ false }\n\t\t\t\t{ ...popoverProps }\n\t\t\t>\n\t\t\t\t{ shouldShowContextualToolbar && (\n\t\t\t\t\t<BlockContextualToolbar\n\t\t\t\t\t\t// If the toolbar is being shown because of being forced\n\t\t\t\t\t\t// it should focus the toolbar right after the mount.\n\t\t\t\t\t\tfocusOnMount={ isToolbarForced.current }\n\t\t\t\t\t\t__experimentalInitialIndex={\n\t\t\t\t\t\t\tinitialToolbarItemIndexRef.current\n\t\t\t\t\t\t}\n\t\t\t\t\t\t__experimentalOnIndexChange={ ( index ) => {\n\t\t\t\t\t\t\tinitialToolbarItemIndexRef.current = index;\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ shouldShowBreadcrumb && (\n\t\t\t\t\t<BlockSelectionButton\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</BlockPopover>\n\t\t);\n\t}\n\n\treturn null;\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAH,OAAA;AAKA,IAAAI,qBAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,uBAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,aAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,4BAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,0BAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,+BAAA,GAAAV,OAAA;AArBA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AASe,SAASW,kBAAkBA,CAAE;EAC3CC,QAAQ;EACRC,0BAA0B;EAC1BC;AACD,CAAC,EAAG;EACH,MAAM;IACLC,iBAAiB;IACjBC,uBAAuB;IACvBC,YAAY;IACZC;EACD,CAAC,GAAG,IAAAC,kCAAyB,EAAEP,QAAS,CAAC;EAEzC,MAAM;IAAEQ;EAAqB,CAAC,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IACzD,MAAM;MAAEC,iBAAiB;MAAEC;IAAwB,CAAC,GACnDF,MAAM,CAAEG,YAAiB,CA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AC/B8B,SAAS,EAAG,IAAAC,mBAAU,EACrB,wCAAwC,EACxC;QACC,4BAA4B,EAAEhC;MAC/B,CACD,CAAG;MACHiC,MAAM,EAAG,KAAO;MAAA,GACXT;IAAY,GAEfX,2BAA2B,IAC5B,IAAAc,MAAA,CAAAC,aAAA,EAACvC,uBAAA,CAAAwC;IACA;IACA;IAAA;MACAK,YAAY,EAAGvB,eAAe,CAACQ,OAAS;MACxCgB,0BAA0B,EACzBb,0BAA0B,CAACH,OAC3B;MACDiB,2BAA2B,EAAKC,KAAK,IAAM;QAC1Cf,0BAA0B,CAACH,OAAO,GAAGkB,KAAK;MAC3C;IAAG,CACH,CACD,EACCjC,oBAAoB,IACrB,IAAAuB,MAAA,CAAAC,aAAA,EAACxC,qBAAA,CAAAyC,OAAoB;MACpBjC,QAAQ,EAAGA,QAAU;MACrBM,YAAY,EAAGA;IAAc,CAC7B,CAEW,CAAC;EAEjB;EAEA,OAAO,IAAI;AACZ"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useSelectedBlockToolProps;
|
|
7
|
+
var _data = require("@wordpress/data");
|
|
8
|
+
var _store = require("../../store");
|
|
9
|
+
/**
|
|
10
|
+
* WordPress dependencies
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Internal dependencies
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Returns props for the selected block tools and empty block inserter.
|
|
19
|
+
*
|
|
20
|
+
* @param {string} clientId Selected block client ID.
|
|
21
|
+
*/
|
|
22
|
+
function useSelectedBlockToolProps(clientId) {
|
|
23
|
+
const selectedBlockProps = (0, _data.useSelect)(select => {
|
|
24
|
+
const {
|
|
25
|
+
getBlockRootClientId,
|
|
26
|
+
getBlockParents,
|
|
27
|
+
__experimentalGetBlockListSettingsForBlocks,
|
|
28
|
+
isBlockInsertionPointVisible,
|
|
29
|
+
getBlockInsertionPoint,
|
|
30
|
+
getBlockOrder,
|
|
31
|
+
hasMultiSelection,
|
|
32
|
+
getLastMultiSelectedBlockClientId
|
|
33
|
+
} = select(_store.store);
|
|
34
|
+
const blockParentsClientIds = getBlockParents(clientId);
|
|
35
|
+
|
|
36
|
+
// Get Block List Settings for all ancestors of the current Block clientId.
|
|
37
|
+
const parentBlockListSettings = __experimentalGetBlockListSettingsForBlocks(blockParentsClientIds);
|
|
38
|
+
|
|
39
|
+
// Get the clientId of the topmost parent with the capture toolbars setting.
|
|
40
|
+
const capturingClientId = blockParentsClientIds.find(parentClientId => parentBlockListSettings[parentClientId]?.__experimentalCaptureToolbars);
|
|
41
|
+
let isInsertionPointVisible = false;
|
|
42
|
+
if (isBlockInsertionPointVisible()) {
|
|
43
|
+
const insertionPoint = getBlockInsertionPoint();
|
|
44
|
+
const order = getBlockOrder(insertionPoint.rootClientId);
|
|
45
|
+
isInsertionPointVisible = order[insertionPoint.index] === clientId;
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
capturingClientId,
|
|
49
|
+
isInsertionPointVisible,
|
|
50
|
+
lastClientId: hasMultiSelection() ? getLastMultiSelectedBlockClientId() : null,
|
|
51
|
+
rootClientId: getBlockRootClientId(clientId)
|
|
52
|
+
};
|
|
53
|
+
}, [clientId]);
|
|
54
|
+
return selectedBlockProps;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=use-selected-block-tool-props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_data","require","_store","useSelectedBlockToolProps","clientId","selectedBlockProps","useSelect","select","getBlockRootClientId","getBlockParents","__experimentalGetBlockListSettingsForBlocks","isBlockInsertionPointVisible","getBlockInsertionPoint","getBlockOrder","hasMultiSelection","getLastMultiSelectedBlockClientId","blockEditorStore","blockParentsClientIds","parentBlockListSettings","capturingClientId","find","parentClientId","__experimentalCaptureToolbars","isInsertionPointVisible","insertionPoint","order","rootClientId","index","lastClientId"],"sources":["@wordpress/block-editor/src/components/block-tools/use-selected-block-tool-props.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Returns props for the selected block tools and empty block inserter.\n *\n * @param {string} clientId Selected block client ID.\n */\nexport default function useSelectedBlockToolProps( clientId ) {\n\tconst selectedBlockProps = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockParents,\n\t\t\t\t__experimentalGetBlockListSettingsForBlocks,\n\t\t\t\tisBlockInsertionPointVisible,\n\t\t\t\tgetBlockInsertionPoint,\n\t\t\t\tgetBlockOrder,\n\t\t\t\thasMultiSelection,\n\t\t\t\tgetLastMultiSelectedBlockClientId,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst blockParentsClientIds = getBlockParents( clientId );\n\n\t\t\t// Get Block List Settings for all ancestors of the current Block clientId.\n\t\t\tconst parentBlockListSettings =\n\t\t\t\t__experimentalGetBlockListSettingsForBlocks(\n\t\t\t\t\tblockParentsClientIds\n\t\t\t\t);\n\n\t\t\t// Get the clientId of the topmost parent with the capture toolbars setting.\n\t\t\tconst capturingClientId = blockParentsClientIds.find(\n\t\t\t\t( parentClientId ) =>\n\t\t\t\t\tparentBlockListSettings[ parentClientId ]\n\t\t\t\t\t\t?.__experimentalCaptureToolbars\n\t\t\t);\n\n\t\t\tlet isInsertionPointVisible = false;\n\t\t\tif ( isBlockInsertionPointVisible() ) {\n\t\t\t\tconst insertionPoint = getBlockInsertionPoint();\n\t\t\t\tconst order = getBlockOrder( insertionPoint.rootClientId );\n\t\t\t\tisInsertionPointVisible =\n\t\t\t\t\torder[ insertionPoint.index ] === clientId;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tcapturingClientId,\n\t\t\t\tisInsertionPointVisible,\n\t\t\t\tlastClientId: hasMultiSelection()\n\t\t\t\t\t? getLastMultiSelectedBlockClientId()\n\t\t\t\t\t: null,\n\t\t\t\trootClientId: getBlockRootClientId( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\treturn selectedBlockProps;\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACe,SAASE,yBAAyBA,CAAEC,QAAQ,EAAG;EAC7D,MAAMC,kBAAkB,GAAG,IAAAC,eAAS,EACjCC,MAAM,IAAM;IACb,MAAM;MACLC,oBAAoB;MACpBC,eAAe;MACfC,2CAA2C;MAC3CC,4BAA4B;MAC5BC,sBAAsB;MACtBC,aAAa;MACbC,iBAAiB;MACjBC;IACD,CAAC,GAAGR,MAAM,CAAES,YAAiB,CAAC;IAE9B,MAAMC,qBAAqB,GAAGR,eAAe,CAAEL,QAAS,CAAC;;IAEzD;IACA,MAAMc,uBAAuB,GAC5BR,2CAA2C,CAC1CO,qBACD,CAAC;;IAEF;IACA,MAAME,iBAAiB,GAAGF,qBAAqB,CAACG,IAAI,CACjDC,cAAc,IACfH,uBAAuB,CAAEG,cAAc,CAAE,EACtCC,6BACL,CAAC;IAED,IAAIC,uBAAuB,GAAG,KAAK;IACnC,IAAKZ,4BAA4B,CAAC,CAAC,EAAG;MACrC,MAAMa,cAAc,GAAGZ,sBAAsB,CAAC,CAAC;MAC/C,MAAMa,KAAK,GAAGZ,aAAa,CAAEW,cAAc,CAACE,YAAa,CAAC;MAC1DH,uBAAuB,GACtBE,KAAK,CAAED,cAAc,CAACG,KAAK,CAAE,KAAKvB,QAAQ;IAC5C;IAEA,OAAO;MACNe,iBAAiB;MACjBI,uBAAuB;MACvBK,YAAY,EAAEd,iBAAiB,CAAC,CAAC,GAC9BC,iCAAiC,CAAC,CAAC,GACnC,IAAI;MAC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