@wordpress/block-editor 8.4.0 → 8.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/README.md +56 -19
- package/build/components/alignment-control/index.js +13 -6
- package/build/components/alignment-control/index.js.map +1 -1
- package/build/components/block-alignment-control/index.js +13 -6
- package/build/components/block-alignment-control/index.js.map +1 -1
- package/build/components/block-draggable/index.js +2 -3
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-icon/index.js +4 -0
- package/build/components/block-icon/index.js.map +1 -1
- package/build/components/block-inspector/index.js +6 -1
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +1 -6
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-focus-first-element.js +14 -17
- package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build/components/block-list/use-block-props/use-focus-handler.js +7 -1
- package/build/components/block-list/use-block-props/use-focus-handler.js.map +1 -1
- package/build/components/block-list-appender/index.js +6 -1
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-lock/menu-item.js +9 -0
- package/build/components/block-lock/menu-item.js.map +1 -1
- package/build/components/block-lock/modal.js +4 -13
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-lock/toolbar.js +11 -3
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-mover/index.js +4 -0
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +50 -5
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-switcher/index.js +1 -1
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-title/index.js +2 -2
- package/build/components/block-title/index.js.map +1 -1
- package/build/components/block-title/use-block-display-title.js +1 -1
- package/build/components/block-title/use-block-display-title.js.map +1 -1
- package/build/components/block-toolbar/block-name-context.js +17 -0
- package/build/components/block-toolbar/block-name-context.js.map +1 -0
- package/build/components/block-toolbar/block-toolbar-last-item.js +20 -0
- package/build/components/block-toolbar/block-toolbar-last-item.js.map +1 -0
- package/build/components/block-toolbar/index.js +20 -5
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/index.js +0 -16
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-variation-transforms/index.js +92 -47
- package/build/components/block-variation-transforms/index.js.map +1 -1
- package/build/components/block-vertical-alignment-control/index.js +13 -6
- package/build/components/block-vertical-alignment-control/index.js.map +1 -1
- package/build/components/contrast-checker/index.js +4 -0
- package/build/components/contrast-checker/index.js.map +1 -1
- package/build/components/convert-to-group-buttons/index.js +8 -0
- package/build/components/convert-to-group-buttons/index.js.map +1 -1
- package/build/components/convert-to-group-buttons/toolbar.js +105 -0
- package/build/components/convert-to-group-buttons/toolbar.js.map +1 -0
- package/build/components/copy-handler/index.js +4 -0
- package/build/components/copy-handler/index.js.map +1 -1
- package/build/components/font-sizes/font-size-picker.js +4 -0
- package/build/components/font-sizes/font-size-picker.js.map +1 -1
- package/build/components/iframe/index.js +6 -9
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/index.js +18 -0
- package/build/components/index.js.map +1 -1
- package/build/components/justify-content-control/index.js +13 -6
- package/build/components/justify-content-control/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +1 -1
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/line-height-control/index.js +10 -3
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +25 -6
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +5 -1
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +1 -1
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/media-replace-flow/index.js +4 -0
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/multi-selection-inspector/index.js +1 -1
- package/build/components/multi-selection-inspector/index.js.map +1 -1
- package/build/components/rich-text/index.js +26 -4
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/split-value.js +12 -2
- package/build/components/rich-text/split-value.js.map +1 -1
- package/build/components/rich-text/use-firefox-compat.js +49 -0
- package/build/components/rich-text/use-firefox-compat.js.map +1 -0
- package/build/components/rich-text/use-input-rules.js +34 -2
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/components/skip-to-selected-block/index.js +4 -0
- package/build/components/skip-to-selected-block/index.js.map +1 -1
- package/build/components/writing-flow/index.js +9 -1
- package/build/components/writing-flow/index.js.map +1 -1
- package/build/components/writing-flow/use-arrow-nav.js +3 -44
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/components/writing-flow/use-click-selection.js +68 -0
- package/build/components/writing-flow/use-click-selection.js.map +1 -0
- package/build/components/writing-flow/use-drag-selection.js +134 -0
- package/build/components/writing-flow/use-drag-selection.js.map +1 -0
- package/build/components/writing-flow/use-input.js +116 -0
- package/build/components/writing-flow/use-input.js.map +1 -0
- package/build/components/writing-flow/use-multi-selection.js +18 -38
- package/build/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js +161 -0
- package/build/components/writing-flow/use-selection-observer.js.map +1 -0
- package/build/components/writing-flow/use-tab-nav.js +1 -8
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/hooks/border-color.js +3 -3
- package/build/hooks/border-color.js.map +1 -1
- package/build/hooks/border.js +0 -14
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +20 -17
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/font-family.js +5 -1
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/font-size.js +4 -2
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/gap.js +23 -16
- package/build/hooks/gap.js.map +1 -1
- package/build/hooks/layout.js +7 -2
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/style.js +34 -3
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/utils.js +29 -0
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/flex.js +76 -12
- package/build/layouts/flex.js.map +1 -1
- package/build/layouts/flow.js +9 -4
- package/build/layouts/flow.js.map +1 -1
- package/build/store/actions.js +297 -51
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +5 -2
- package/build/store/defaults.js.map +1 -1
- package/build/store/reducer.js +25 -13
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +142 -18
- package/build/store/selectors.js.map +1 -1
- package/build/utils/dom.js +2 -1
- package/build/utils/dom.js.map +1 -1
- package/build-module/components/alignment-control/index.js +12 -4
- package/build-module/components/alignment-control/index.js.map +1 -1
- package/build-module/components/block-alignment-control/index.js +12 -4
- package/build-module/components/block-alignment-control/index.js.map +1 -1
- package/build-module/components/block-draggable/index.js +2 -3
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-icon/index.js +4 -0
- package/build-module/components/block-icon/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +6 -1
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +1 -4
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js +15 -17
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-focus-handler.js +7 -1
- package/build-module/components/block-list/use-block-props/use-focus-handler.js.map +1 -1
- package/build-module/components/block-list-appender/index.js +6 -1
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-lock/menu-item.js +9 -0
- package/build-module/components/block-lock/menu-item.js.map +1 -1
- package/build-module/components/block-lock/modal.js +5 -14
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +11 -3
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-mover/index.js +4 -0
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +50 -7
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-switcher/index.js +2 -2
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-title/index.js +2 -2
- package/build-module/components/block-title/index.js.map +1 -1
- package/build-module/components/block-title/use-block-display-title.js +1 -1
- package/build-module/components/block-title/use-block-display-title.js.map +1 -1
- package/build-module/components/block-toolbar/block-name-context.js +9 -0
- package/build-module/components/block-toolbar/block-name-context.js.map +1 -0
- package/build-module/components/block-toolbar/block-toolbar-last-item.js +11 -0
- package/build-module/components/block-toolbar/block-toolbar-last-item.js.map +1 -0
- package/build-module/components/block-toolbar/index.js +16 -4
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/index.js +0 -16
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-variation-transforms/index.js +95 -49
- package/build-module/components/block-variation-transforms/index.js.map +1 -1
- package/build-module/components/block-vertical-alignment-control/index.js +12 -4
- package/build-module/components/block-vertical-alignment-control/index.js.map +1 -1
- package/build-module/components/contrast-checker/index.js +4 -0
- package/build-module/components/contrast-checker/index.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/index.js +2 -1
- package/build-module/components/convert-to-group-buttons/index.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/toolbar.js +90 -0
- package/build-module/components/convert-to-group-buttons/toolbar.js.map +1 -0
- package/build-module/components/copy-handler/index.js +4 -0
- package/build-module/components/copy-handler/index.js.map +1 -1
- package/build-module/components/font-sizes/font-size-picker.js +4 -0
- package/build-module/components/font-sizes/font-size-picker.js.map +1 -1
- package/build-module/components/iframe/index.js +6 -9
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/index.js +2 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/justify-content-control/index.js +12 -4
- package/build-module/components/justify-content-control/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -1
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/line-height-control/index.js +9 -2
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +22 -6
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +5 -1
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +1 -1
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +4 -0
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/multi-selection-inspector/index.js +2 -2
- package/build-module/components/multi-selection-inspector/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +25 -4
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/split-value.js +12 -2
- package/build-module/components/rich-text/split-value.js.map +1 -1
- package/build-module/components/rich-text/use-firefox-compat.js +39 -0
- package/build-module/components/rich-text/use-firefox-compat.js.map +1 -0
- package/build-module/components/rich-text/use-input-rules.js +35 -4
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/components/skip-to-selected-block/index.js +4 -0
- package/build-module/components/skip-to-selected-block/index.js.map +1 -1
- package/build-module/components/writing-flow/index.js +5 -1
- package/build-module/components/writing-flow/index.js.map +1 -1
- package/build-module/components/writing-flow/use-arrow-nav.js +4 -45
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/components/writing-flow/use-click-selection.js +57 -0
- package/build-module/components/writing-flow/use-click-selection.js.map +1 -0
- package/build-module/components/writing-flow/use-drag-selection.js +124 -0
- package/build-module/components/writing-flow/use-drag-selection.js.map +1 -0
- package/build-module/components/writing-flow/use-input.js +104 -0
- package/build-module/components/writing-flow/use-input.js.map +1 -0
- package/build-module/components/writing-flow/use-multi-selection.js +18 -37
- package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js +150 -0
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -0
- package/build-module/components/writing-flow/use-tab-nav.js +1 -9
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/hooks/border-color.js +5 -5
- package/build-module/hooks/border-color.js.map +1 -1
- package/build-module/hooks/border.js +0 -12
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +19 -18
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/font-family.js +3 -1
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/font-size.js +4 -3
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/gap.js +22 -15
- package/build-module/hooks/gap.js.map +1 -1
- package/build-module/hooks/layout.js +7 -2
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/style.js +33 -3
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/utils.js +26 -0
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/flex.js +76 -13
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/layouts/flow.js +9 -5
- package/build-module/layouts/flow.js.map +1 -1
- package/build-module/store/actions.js +286 -49
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +5 -2
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/reducer.js +25 -13
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +138 -19
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/dom.js +2 -1
- package/build-module/utils/dom.js.map +1 -1
- package/build-style/style-rtl.css +107 -74
- package/build-style/style.css +107 -74
- package/build-types/utils/dom.d.ts.map +1 -1
- package/package.json +28 -28
- package/src/components/alignment-control/index.js +9 -4
- package/src/components/block-alignment-control/index.js +9 -4
- package/src/components/block-draggable/index.js +2 -5
- package/src/components/block-icon/index.js +3 -0
- package/src/components/block-inspector/index.js +4 -0
- package/src/components/block-list/style.scss +4 -5
- package/src/components/block-list/use-block-props/index.js +0 -5
- package/src/components/block-list/use-block-props/use-focus-first-element.js +19 -26
- package/src/components/block-list/use-block-props/use-focus-handler.js +8 -0
- package/src/components/block-list-appender/index.js +5 -0
- package/src/components/block-lock/menu-item.js +8 -1
- package/src/components/block-lock/modal.js +18 -13
- package/src/components/block-lock/style.scss +6 -3
- package/src/components/block-lock/toolbar.js +12 -2
- package/src/components/block-mover/index.js +3 -0
- package/src/components/block-mover/style.scss +4 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +62 -4
- package/src/components/block-switcher/index.js +2 -2
- package/src/components/block-switcher/style.scss +8 -1
- package/src/components/block-switcher/test/index.js +2 -2
- package/src/components/block-title/index.js +2 -2
- package/src/components/block-title/use-block-display-title.js +1 -1
- package/src/components/block-toolbar/block-name-context.js +8 -0
- package/src/components/block-toolbar/block-toolbar-last-item.js +12 -0
- package/src/components/block-toolbar/index.js +18 -2
- package/src/components/block-toolbar/style.scss +6 -0
- package/src/components/block-tools/index.js +0 -19
- package/src/components/block-tools/style.scss +3 -5
- package/src/components/block-variation-transforms/index.js +105 -36
- package/src/components/block-variation-transforms/style.scss +1 -1
- package/src/components/block-vertical-alignment-control/index.js +9 -4
- package/src/components/button-block-appender/style.scss +5 -1
- package/src/components/contrast-checker/index.js +3 -0
- package/src/components/convert-to-group-buttons/index.js +6 -1
- package/src/components/convert-to-group-buttons/toolbar.js +87 -0
- package/src/components/copy-handler/index.js +3 -0
- package/src/components/font-sizes/font-size-picker.js +3 -0
- package/src/components/iframe/index.js +5 -7
- package/src/components/index.js +2 -0
- package/src/components/justify-content-control/index.js +9 -4
- package/src/components/keyboard-shortcuts/index.js +1 -1
- package/src/components/line-height-control/index.js +8 -3
- package/src/components/list-view/block-select-button.js +21 -3
- package/src/components/list-view/block.js +8 -1
- package/src/components/list-view/branch.js +1 -1
- package/src/components/list-view/style.scss +56 -14
- package/src/components/media-placeholder/README.md +8 -0
- package/src/components/media-replace-flow/index.js +3 -0
- package/src/components/multi-selection-inspector/index.js +2 -2
- package/src/components/rich-text/index.js +24 -1
- package/src/components/rich-text/split-value.js +5 -1
- package/src/components/rich-text/use-firefox-compat.js +39 -0
- package/src/components/rich-text/use-input-rules.js +40 -3
- package/src/components/skip-to-selected-block/index.js +3 -0
- package/src/components/url-input/style.scss +3 -2
- package/src/components/writing-flow/index.js +8 -0
- package/src/components/writing-flow/readme.md +28 -0
- package/src/components/writing-flow/use-arrow-nav.js +4 -53
- package/src/components/writing-flow/use-click-selection.js +65 -0
- package/src/components/writing-flow/use-drag-selection.js +126 -0
- package/src/components/writing-flow/use-input.js +112 -0
- package/src/components/writing-flow/use-multi-selection.js +13 -36
- package/src/components/writing-flow/use-selection-observer.js +153 -0
- package/src/components/writing-flow/use-tab-nav.js +1 -11
- package/src/hooks/border-color.js +5 -5
- package/src/hooks/border.js +0 -13
- package/src/hooks/color.js +51 -24
- package/src/hooks/font-family.js +5 -2
- package/src/hooks/font-size.js +10 -7
- package/src/hooks/gap.js +25 -17
- package/src/hooks/layout.js +11 -1
- package/src/hooks/style.js +40 -4
- package/src/hooks/test/gap.js +25 -1
- package/src/hooks/test/style.js +94 -0
- package/src/hooks/test/utils.js +1 -1
- package/src/hooks/utils.js +26 -0
- package/src/layouts/flex.js +89 -5
- package/src/layouts/flow.js +15 -4
- package/src/store/actions.js +349 -32
- package/src/store/defaults.js +7 -2
- package/src/store/reducer.js +25 -10
- package/src/store/selectors.js +181 -24
- package/src/store/test/selectors.js +242 -5
- package/src/utils/dom.js +2 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/block-list/use-block-props/use-multi-selection.js +0 -205
- package/build/components/block-list/use-block-props/use-multi-selection.js.map +0 -1
- package/build/components/block-list/use-block-props/use-scroll-into-view.js +0 -77
- package/build/components/block-list/use-block-props/use-scroll-into-view.js.map +0 -1
- package/build-module/components/block-list/use-block-props/use-multi-selection.js +0 -192
- package/build-module/components/block-list/use-block-props/use-multi-selection.js.map +0 -1
- package/build-module/components/block-list/use-block-props/use-scroll-into-view.js +0 -63
- package/build-module/components/block-list/use-block-props/use-scroll-into-view.js.map +0 -1
- package/src/components/block-list/use-block-props/use-multi-selection.js +0 -227
- package/src/components/block-list/use-block-props/use-scroll-into-view.js +0 -73
|
@@ -7,7 +7,12 @@ import { first, last } from 'lodash';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { useEffect, useRef } from '@wordpress/element';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
focus,
|
|
12
|
+
isFormElement,
|
|
13
|
+
isTextField,
|
|
14
|
+
placeCaretAtHorizontalEdge,
|
|
15
|
+
} from '@wordpress/dom';
|
|
11
16
|
import { useSelect } from '@wordpress/data';
|
|
12
17
|
|
|
13
18
|
/**
|
|
@@ -15,7 +20,6 @@ import { useSelect } from '@wordpress/data';
|
|
|
15
20
|
*/
|
|
16
21
|
import { isInsideRootBlock } from '../../../utils/dom';
|
|
17
22
|
import { store as blockEditorStore } from '../../../store';
|
|
18
|
-
import { setContentEditableWrapper } from './use-multi-selection';
|
|
19
23
|
|
|
20
24
|
/** @typedef {import('@wordpress/element').RefObject} RefObject */
|
|
21
25
|
|
|
@@ -32,7 +36,6 @@ function useInitialPosition( clientId ) {
|
|
|
32
36
|
( select ) => {
|
|
33
37
|
const {
|
|
34
38
|
getSelectedBlocksInitialCaretPosition,
|
|
35
|
-
isMultiSelecting,
|
|
36
39
|
isNavigationMode,
|
|
37
40
|
isBlockSelected,
|
|
38
41
|
} = select( blockEditorStore );
|
|
@@ -41,7 +44,7 @@ function useInitialPosition( clientId ) {
|
|
|
41
44
|
return;
|
|
42
45
|
}
|
|
43
46
|
|
|
44
|
-
if (
|
|
47
|
+
if ( isNavigationMode() ) {
|
|
45
48
|
return;
|
|
46
49
|
}
|
|
47
50
|
|
|
@@ -52,16 +55,6 @@ function useInitialPosition( clientId ) {
|
|
|
52
55
|
);
|
|
53
56
|
}
|
|
54
57
|
|
|
55
|
-
function isFormElement( element ) {
|
|
56
|
-
const { tagName } = element;
|
|
57
|
-
return (
|
|
58
|
-
tagName === 'INPUT' ||
|
|
59
|
-
tagName === 'BUTTON' ||
|
|
60
|
-
tagName === 'SELECT' ||
|
|
61
|
-
tagName === 'TEXTAREA'
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
58
|
/**
|
|
66
59
|
* Transitions focus to the block or inner tabbable when the block becomes
|
|
67
60
|
* selected and an initial position is set.
|
|
@@ -73,8 +66,14 @@ function isFormElement( element ) {
|
|
|
73
66
|
export function useFocusFirstElement( clientId ) {
|
|
74
67
|
const ref = useRef();
|
|
75
68
|
const initialPosition = useInitialPosition( clientId );
|
|
69
|
+
const { isBlockSelected, isMultiSelecting } = useSelect( blockEditorStore );
|
|
76
70
|
|
|
77
71
|
useEffect( () => {
|
|
72
|
+
// Check if the block is still selected at the time this effect runs.
|
|
73
|
+
if ( ! isBlockSelected( clientId ) || isMultiSelecting() ) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
78
77
|
if ( initialPosition === undefined || initialPosition === null ) {
|
|
79
78
|
return;
|
|
80
79
|
}
|
|
@@ -107,27 +106,21 @@ export function useFocusFirstElement( clientId ) {
|
|
|
107
106
|
}
|
|
108
107
|
|
|
109
108
|
// Check to see if element is focussable before a generic caret insert.
|
|
110
|
-
if ( !
|
|
111
|
-
const focusElement = focus.tabbable.findNext(
|
|
112
|
-
// Make sure focusElement is valid,
|
|
113
|
-
// Ensure is not block inserter trigger, don't want to focus that in the event of the group block which doesn't contain any other focussable elements.
|
|
109
|
+
if ( ! ref.current.getAttribute( 'contenteditable' ) ) {
|
|
110
|
+
const focusElement = focus.tabbable.findNext( ref.current );
|
|
111
|
+
// Make sure focusElement is valid, contained in the same block, and a form field.
|
|
114
112
|
if (
|
|
115
113
|
focusElement &&
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
! focusElement.classList.contains(
|
|
119
|
-
'block-editor-button-block-appender'
|
|
120
|
-
)
|
|
114
|
+
isInsideRootBlock( ref.current, focusElement ) &&
|
|
115
|
+
isFormElement( focusElement )
|
|
121
116
|
) {
|
|
122
117
|
focusElement.focus();
|
|
123
118
|
return;
|
|
124
119
|
}
|
|
125
120
|
}
|
|
126
121
|
|
|
127
|
-
setContentEditableWrapper( ref.current, false );
|
|
128
|
-
|
|
129
122
|
placeCaretAtHorizontalEdge( target, isReverse );
|
|
130
|
-
}, [ initialPosition ] );
|
|
123
|
+
}, [ initialPosition, clientId ] );
|
|
131
124
|
|
|
132
125
|
return ref;
|
|
133
126
|
}
|
|
@@ -30,6 +30,14 @@ export function useFocusHandler( clientId ) {
|
|
|
30
30
|
* @param {FocusEvent} event Focus event.
|
|
31
31
|
*/
|
|
32
32
|
function onFocus( event ) {
|
|
33
|
+
// When the whole editor is editable, let writing flow handle
|
|
34
|
+
// selection.
|
|
35
|
+
if (
|
|
36
|
+
node.parentElement.closest( '[contenteditable="true"]' )
|
|
37
|
+
) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
33
41
|
// Check synchronously because a non-selected block might be
|
|
34
42
|
// getting data through `useSelect` asynchronously.
|
|
35
43
|
if ( isBlockSelected( clientId ) ) {
|
|
@@ -73,6 +73,11 @@ function BlockListAppender( {
|
|
|
73
73
|
'block-list-appender wp-block',
|
|
74
74
|
className
|
|
75
75
|
) }
|
|
76
|
+
// Needed in case the whole editor is content editable (for multi
|
|
77
|
+
// selection). It fixes an edge case where ArrowDown and ArrowRight
|
|
78
|
+
// should collapse the selection to the end of that selection and
|
|
79
|
+
// not into the appender.
|
|
80
|
+
contentEditable={ false }
|
|
76
81
|
// The appender exists to let you add the first Paragraph before
|
|
77
82
|
// any is inserted. To that end, this appender should visually be
|
|
78
83
|
// presented as a block. That means theme CSS should style it as if
|
|
@@ -14,16 +14,19 @@ import BlockLockModal from './modal';
|
|
|
14
14
|
import { store as blockEditorStore } from '../../store';
|
|
15
15
|
|
|
16
16
|
export default function BlockLockMenuItem( { clientId } ) {
|
|
17
|
-
const { isLocked } = useSelect(
|
|
17
|
+
const { canLockBlock, isLocked } = useSelect(
|
|
18
18
|
( select ) => {
|
|
19
19
|
const {
|
|
20
20
|
canMoveBlock,
|
|
21
21
|
canRemoveBlock,
|
|
22
|
+
canLockBlockType,
|
|
23
|
+
getBlockName,
|
|
22
24
|
getBlockRootClientId,
|
|
23
25
|
} = select( blockEditorStore );
|
|
24
26
|
const rootClientId = getBlockRootClientId( clientId );
|
|
25
27
|
|
|
26
28
|
return {
|
|
29
|
+
canLockBlock: canLockBlockType( getBlockName( clientId ) ),
|
|
27
30
|
isLocked:
|
|
28
31
|
! canMoveBlock( clientId, rootClientId ) ||
|
|
29
32
|
! canRemoveBlock( clientId, rootClientId ),
|
|
@@ -37,6 +40,10 @@ export default function BlockLockMenuItem( { clientId } ) {
|
|
|
37
40
|
false
|
|
38
41
|
);
|
|
39
42
|
|
|
43
|
+
if ( ! canLockBlock ) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
|
|
40
47
|
const label = isLocked ? __( 'Unlock' ) : __( 'Lock' );
|
|
41
48
|
|
|
42
49
|
return (
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
Icon,
|
|
12
12
|
Modal,
|
|
13
13
|
} from '@wordpress/components';
|
|
14
|
-
import {
|
|
14
|
+
import { lock as lockIcon, unlock as unlockIcon } from '@wordpress/icons';
|
|
15
15
|
import { useInstanceId } from '@wordpress/compose';
|
|
16
16
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
17
17
|
|
|
@@ -54,15 +54,8 @@ export default function BlockLockModal( { clientId, onClose } ) {
|
|
|
54
54
|
}, [ canMove, canRemove ] );
|
|
55
55
|
|
|
56
56
|
const isAllChecked = Object.values( lock ).every( Boolean );
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if ( isAllChecked ) {
|
|
60
|
-
ariaChecked = 'true';
|
|
61
|
-
} else if ( Object.values( lock ).some( Boolean ) ) {
|
|
62
|
-
ariaChecked = 'mixed';
|
|
63
|
-
} else {
|
|
64
|
-
ariaChecked = 'false';
|
|
65
|
-
}
|
|
57
|
+
const isIndeterminate =
|
|
58
|
+
Object.values( lock ).some( Boolean ) && ! isAllChecked;
|
|
66
59
|
|
|
67
60
|
return (
|
|
68
61
|
<Modal
|
|
@@ -98,7 +91,7 @@ export default function BlockLockModal( { clientId, onClose } ) {
|
|
|
98
91
|
<span id={ instanceId }>{ __( 'Lock all' ) }</span>
|
|
99
92
|
}
|
|
100
93
|
checked={ isAllChecked }
|
|
101
|
-
|
|
94
|
+
indeterminate={ isIndeterminate }
|
|
102
95
|
onChange={ ( newValue ) =>
|
|
103
96
|
setLock( {
|
|
104
97
|
move: newValue,
|
|
@@ -112,7 +105,13 @@ export default function BlockLockModal( { clientId, onClose } ) {
|
|
|
112
105
|
label={
|
|
113
106
|
<>
|
|
114
107
|
{ __( 'Disable movement' ) }
|
|
115
|
-
<Icon
|
|
108
|
+
<Icon
|
|
109
|
+
icon={
|
|
110
|
+
lock.move
|
|
111
|
+
? lockIcon
|
|
112
|
+
: unlockIcon
|
|
113
|
+
}
|
|
114
|
+
/>
|
|
116
115
|
</>
|
|
117
116
|
}
|
|
118
117
|
checked={ lock.move }
|
|
@@ -129,7 +128,13 @@ export default function BlockLockModal( { clientId, onClose } ) {
|
|
|
129
128
|
label={
|
|
130
129
|
<>
|
|
131
130
|
{ __( 'Prevent removal' ) }
|
|
132
|
-
<Icon
|
|
131
|
+
<Icon
|
|
132
|
+
icon={
|
|
133
|
+
lock.remove
|
|
134
|
+
? lockIcon
|
|
135
|
+
: unlockIcon
|
|
136
|
+
}
|
|
137
|
+
/>
|
|
133
138
|
</>
|
|
134
139
|
}
|
|
135
140
|
checked={ lock.remove }
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
.block-editor-block-lock-modal__options-title {
|
|
16
|
-
border-bottom: 1px solid $gray-300;
|
|
17
16
|
padding: $grid-unit-15 0;
|
|
18
17
|
|
|
19
18
|
.components-checkbox-control__label {
|
|
@@ -27,9 +26,8 @@
|
|
|
27
26
|
}
|
|
28
27
|
}
|
|
29
28
|
.block-editor-block-lock-modal__checklist-item {
|
|
30
|
-
border-bottom: 1px solid $gray-300;
|
|
31
29
|
margin-bottom: 0;
|
|
32
|
-
padding: $grid-unit-15 0 $grid-unit-15 $grid-unit-
|
|
30
|
+
padding: $grid-unit-15 0 $grid-unit-15 $grid-unit-40;
|
|
33
31
|
|
|
34
32
|
.components-base-control__field {
|
|
35
33
|
align-items: center;
|
|
@@ -48,6 +46,11 @@
|
|
|
48
46
|
fill: $gray-900;
|
|
49
47
|
}
|
|
50
48
|
}
|
|
49
|
+
|
|
50
|
+
&:hover {
|
|
51
|
+
background-color: $gray-100;
|
|
52
|
+
border-radius: $radius-block-ui;
|
|
53
|
+
}
|
|
51
54
|
}
|
|
52
55
|
|
|
53
56
|
.block-editor-block-lock-modal__actions {
|
|
@@ -16,13 +16,19 @@ import { store as blockEditorStore } from '../../store';
|
|
|
16
16
|
|
|
17
17
|
export default function BlockLockToolbar( { clientId } ) {
|
|
18
18
|
const blockInformation = useBlockDisplayInformation( clientId );
|
|
19
|
-
const { canMove, canRemove } = useSelect(
|
|
19
|
+
const { canMove, canRemove, canLockBlock } = useSelect(
|
|
20
20
|
( select ) => {
|
|
21
|
-
const {
|
|
21
|
+
const {
|
|
22
|
+
canMoveBlock,
|
|
23
|
+
canRemoveBlock,
|
|
24
|
+
canLockBlockType,
|
|
25
|
+
getBlockName,
|
|
26
|
+
} = select( blockEditorStore );
|
|
22
27
|
|
|
23
28
|
return {
|
|
24
29
|
canMove: canMoveBlock( clientId ),
|
|
25
30
|
canRemove: canRemoveBlock( clientId ),
|
|
31
|
+
canLockBlock: canLockBlockType( getBlockName( clientId ) ),
|
|
26
32
|
};
|
|
27
33
|
},
|
|
28
34
|
[ clientId ]
|
|
@@ -33,6 +39,10 @@ export default function BlockLockToolbar( { clientId } ) {
|
|
|
33
39
|
false
|
|
34
40
|
);
|
|
35
41
|
|
|
42
|
+
if ( ! canLockBlock ) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
36
46
|
if ( canMove && canRemove ) {
|
|
37
47
|
return null;
|
|
38
48
|
}
|
|
@@ -22,6 +22,10 @@
|
|
|
22
22
|
@include break-small() {
|
|
23
23
|
flex-direction: column;
|
|
24
24
|
}
|
|
25
|
+
|
|
26
|
+
// @todo: override toolbar group inherited paddings from components/block-tools/style.scss.
|
|
27
|
+
// This is best fixed by making the mover control area a proper single toolbar group.
|
|
28
|
+
padding: 0;
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
&.is-horizontal .block-editor-block-mover__move-button-container,
|
|
@@ -6,12 +6,17 @@ import { castArray, flow, noop } from 'lodash';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import { getBlockType, serialize } from '@wordpress/blocks';
|
|
10
10
|
import { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';
|
|
11
|
-
import { useSelect } from '@wordpress/data';
|
|
11
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
12
12
|
import { moreVertical } from '@wordpress/icons';
|
|
13
|
-
import {
|
|
14
|
-
|
|
13
|
+
import {
|
|
14
|
+
Children,
|
|
15
|
+
cloneElement,
|
|
16
|
+
useCallback,
|
|
17
|
+
useRef,
|
|
18
|
+
} from '@wordpress/element';
|
|
19
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
15
20
|
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
|
16
21
|
import { useCopyToClipboard } from '@wordpress/compose';
|
|
17
22
|
|
|
@@ -19,12 +24,14 @@ import { useCopyToClipboard } from '@wordpress/compose';
|
|
|
19
24
|
* Internal dependencies
|
|
20
25
|
*/
|
|
21
26
|
import BlockActions from '../block-actions';
|
|
27
|
+
import BlockIcon from '../block-icon';
|
|
22
28
|
import BlockModeToggle from './block-mode-toggle';
|
|
23
29
|
import BlockHTMLConvertButton from './block-html-convert-button';
|
|
24
30
|
import __unstableBlockSettingsMenuFirstItem from './block-settings-menu-first-item';
|
|
25
31
|
import BlockSettingsMenuControls from '../block-settings-menu-controls';
|
|
26
32
|
import { store as blockEditorStore } from '../../store';
|
|
27
33
|
import useBlockDisplayTitle from '../block-title/use-block-display-title';
|
|
34
|
+
import { useShowMoversGestures } from '../block-toolbar/utils';
|
|
28
35
|
|
|
29
36
|
const POPOVER_PROPS = {
|
|
30
37
|
className: 'block-editor-block-settings-menu__popover',
|
|
@@ -47,7 +54,10 @@ export function BlockSettingsDropdown( {
|
|
|
47
54
|
const count = blockClientIds.length;
|
|
48
55
|
const firstBlockClientId = blockClientIds[ 0 ];
|
|
49
56
|
const {
|
|
57
|
+
firstParentClientId,
|
|
58
|
+
hasReducedUI,
|
|
50
59
|
onlyBlock,
|
|
60
|
+
parentBlockType,
|
|
51
61
|
previousBlockClientId,
|
|
52
62
|
nextBlockClientId,
|
|
53
63
|
selectedBlockClientIds,
|
|
@@ -55,12 +65,23 @@ export function BlockSettingsDropdown( {
|
|
|
55
65
|
( select ) => {
|
|
56
66
|
const {
|
|
57
67
|
getBlockCount,
|
|
68
|
+
getBlockName,
|
|
69
|
+
getBlockParents,
|
|
58
70
|
getPreviousBlockClientId,
|
|
59
71
|
getNextBlockClientId,
|
|
60
72
|
getSelectedBlockClientIds,
|
|
73
|
+
getSettings,
|
|
61
74
|
} = select( blockEditorStore );
|
|
75
|
+
|
|
76
|
+
const parents = getBlockParents( firstBlockClientId );
|
|
77
|
+
const _firstParentClientId = parents[ parents.length - 1 ];
|
|
78
|
+
const parentBlockName = getBlockName( _firstParentClientId );
|
|
79
|
+
|
|
62
80
|
return {
|
|
81
|
+
firstParentClientId: _firstParentClientId,
|
|
82
|
+
hasReducedUI: getSettings().hasReducedUI,
|
|
63
83
|
onlyBlock: 1 === getBlockCount(),
|
|
84
|
+
parentBlockType: getBlockType( parentBlockName ),
|
|
64
85
|
previousBlockClientId: getPreviousBlockClientId(
|
|
65
86
|
firstBlockClientId
|
|
66
87
|
),
|
|
@@ -87,6 +108,10 @@ export function BlockSettingsDropdown( {
|
|
|
87
108
|
};
|
|
88
109
|
}, [] );
|
|
89
110
|
|
|
111
|
+
const { selectBlock, toggleBlockHighlight } = useDispatch(
|
|
112
|
+
blockEditorStore
|
|
113
|
+
);
|
|
114
|
+
|
|
90
115
|
const updateSelectionAfterDuplicate = useCallback(
|
|
91
116
|
__experimentalSelectBlock
|
|
92
117
|
? async ( clientIdsPromise ) => {
|
|
@@ -135,6 +160,19 @@ export function BlockSettingsDropdown( {
|
|
|
135
160
|
);
|
|
136
161
|
const removeBlockLabel = count === 1 ? label : __( 'Remove blocks' );
|
|
137
162
|
|
|
163
|
+
// Allows highlighting the parent block outline when focusing or hovering
|
|
164
|
+
// the parent block selector within the child.
|
|
165
|
+
const selectParentButtonRef = useRef();
|
|
166
|
+
const { gestures: showParentOutlineGestures } = useShowMoversGestures( {
|
|
167
|
+
ref: selectParentButtonRef,
|
|
168
|
+
onChange( isFocused ) {
|
|
169
|
+
if ( isFocused && hasReducedUI ) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
toggleBlockHighlight( firstParentClientId, isFocused );
|
|
173
|
+
},
|
|
174
|
+
} );
|
|
175
|
+
|
|
138
176
|
return (
|
|
139
177
|
<BlockActions
|
|
140
178
|
clientIds={ clientIds }
|
|
@@ -167,6 +205,26 @@ export function BlockSettingsDropdown( {
|
|
|
167
205
|
<__unstableBlockSettingsMenuFirstItem.Slot
|
|
168
206
|
fillProps={ { onClose } }
|
|
169
207
|
/>
|
|
208
|
+
{ firstParentClientId !== undefined && (
|
|
209
|
+
<MenuItem
|
|
210
|
+
{ ...showParentOutlineGestures }
|
|
211
|
+
ref={ selectParentButtonRef }
|
|
212
|
+
icon={
|
|
213
|
+
<BlockIcon
|
|
214
|
+
icon={ parentBlockType.icon }
|
|
215
|
+
/>
|
|
216
|
+
}
|
|
217
|
+
onClick={ () =>
|
|
218
|
+
selectBlock( firstParentClientId )
|
|
219
|
+
}
|
|
220
|
+
>
|
|
221
|
+
{ sprintf(
|
|
222
|
+
/* translators: %s: Name of the block's parent. */
|
|
223
|
+
__( 'Select parent block (%s)' ),
|
|
224
|
+
parentBlockType.title
|
|
225
|
+
) }
|
|
226
|
+
</MenuItem>
|
|
227
|
+
) }
|
|
170
228
|
{ count === 1 && (
|
|
171
229
|
<BlockHTMLConvertButton
|
|
172
230
|
clientId={ firstBlockClientId }
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
isTemplatePart,
|
|
21
21
|
} from '@wordpress/blocks';
|
|
22
22
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
23
|
-
import {
|
|
23
|
+
import { copy } from '@wordpress/icons';
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Internal dependencies
|
|
@@ -69,7 +69,7 @@ export const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => {
|
|
|
69
69
|
// appropriate icon to communicate the non-uniformity.
|
|
70
70
|
_icon = isSelectionOfSameType
|
|
71
71
|
? getBlockType( firstBlockName )?.icon
|
|
72
|
-
:
|
|
72
|
+
: copy;
|
|
73
73
|
}
|
|
74
74
|
return {
|
|
75
75
|
possibleBlockTransformations: getBlockTransformItems(
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
.block-editor-block-switcher {
|
|
2
2
|
position: relative;
|
|
3
|
+
padding: 0 ($grid-unit-15 * 0.5);
|
|
4
|
+
|
|
5
|
+
// @todo: override toolbar group inherited paddings from components/block-tools/style.scss.
|
|
6
|
+
// This is best fixed by making the mover control area a proper single toolbar group.
|
|
7
|
+
// It needs specificity due to style inherited from .components-accessible-toolbar .components-button.has-icon.has-icon.
|
|
8
|
+
.components-button.components-dropdown-menu__toggle.has-icon.has-icon {
|
|
9
|
+
min-width: $button-size;
|
|
10
|
+
}
|
|
3
11
|
}
|
|
4
12
|
|
|
5
13
|
// Show an indicator triangle.
|
|
@@ -8,7 +16,6 @@
|
|
|
8
16
|
position: relative;
|
|
9
17
|
}
|
|
10
18
|
|
|
11
|
-
|
|
12
19
|
.components-button.block-editor-block-switcher__toggle,
|
|
13
20
|
.components-button.block-editor-block-switcher__no-switcher-icon {
|
|
14
21
|
margin: 0;
|
|
@@ -10,7 +10,7 @@ import { useSelect } from '@wordpress/data';
|
|
|
10
10
|
import { registerBlockType, unregisterBlockType } from '@wordpress/blocks';
|
|
11
11
|
import { DOWN } from '@wordpress/keycodes';
|
|
12
12
|
import { Button } from '@wordpress/components';
|
|
13
|
-
import {
|
|
13
|
+
import { copy } from '@wordpress/icons';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Internal dependencies
|
|
@@ -131,7 +131,7 @@ describe( 'BlockSwitcherDropdownMenu', () => {
|
|
|
131
131
|
test( 'should render disabled block switcher with multi block of different types when no transforms', () => {
|
|
132
132
|
useSelect.mockImplementation( () => ( {
|
|
133
133
|
possibleBlockTransformations: [],
|
|
134
|
-
icon:
|
|
134
|
+
icon: copy,
|
|
135
135
|
} ) );
|
|
136
136
|
const wrapper = shallow(
|
|
137
137
|
<BlockSwitcherDropdownMenu
|
|
@@ -14,8 +14,8 @@ import useBlockDisplayTitle from './use-block-display-title';
|
|
|
14
14
|
* <BlockTitle clientId="afd1cb17-2c08-4e7a-91be-007ba7ddc3a1" maximumLength={ 17 }/>
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
|
-
* @param {Object}
|
|
18
|
-
* @param {string}
|
|
17
|
+
* @param {Object} props
|
|
18
|
+
* @param {string} props.clientId Client ID of block.
|
|
19
19
|
* @param {number|undefined} props.maximumLength The maximum length that the block title string may be before truncated.
|
|
20
20
|
*
|
|
21
21
|
* @return {JSX.Element} Block title.
|
|
@@ -29,7 +29,7 @@ import { store as blockEditorStore } from '../../store';
|
|
|
29
29
|
* useBlockDisplayTitle( 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1', 17 );
|
|
30
30
|
* ```
|
|
31
31
|
*
|
|
32
|
-
* @param {string}
|
|
32
|
+
* @param {string} clientId Client ID of block.
|
|
33
33
|
* @param {number|undefined} maximumLength The maximum length that the block title string may be before truncated.
|
|
34
34
|
* @return {?string} Block title.
|
|
35
35
|
*/
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { createSlotFill } from '@wordpress/components';
|
|
5
|
+
|
|
6
|
+
const { Fill: __unstableBlockToolbarLastItem, Slot } = createSlotFill(
|
|
7
|
+
'__unstableBlockToolbarLastItem'
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
__unstableBlockToolbarLastItem.Slot = Slot;
|
|
11
|
+
|
|
12
|
+
export default __unstableBlockToolbarLastItem;
|
|
@@ -19,12 +19,15 @@ import BlockMover from '../block-mover';
|
|
|
19
19
|
import BlockParentSelector from '../block-parent-selector';
|
|
20
20
|
import BlockSwitcher from '../block-switcher';
|
|
21
21
|
import BlockControls from '../block-controls';
|
|
22
|
+
import __unstableBlockToolbarLastItem from './block-toolbar-last-item';
|
|
22
23
|
import BlockSettingsMenu from '../block-settings-menu';
|
|
23
24
|
import { BlockLockToolbar } from '../block-lock';
|
|
25
|
+
import { BlockGroupToolbar } from '../convert-to-group-buttons';
|
|
24
26
|
import { useShowMoversGestures } from './utils';
|
|
25
27
|
import { store as blockEditorStore } from '../../store';
|
|
28
|
+
import __unstableBlockNameContext from './block-name-context';
|
|
26
29
|
|
|
27
|
-
|
|
30
|
+
const BlockToolbar = ( { hideDragHandle } ) => {
|
|
28
31
|
const {
|
|
29
32
|
blockClientIds,
|
|
30
33
|
blockClientId,
|
|
@@ -127,6 +130,9 @@ export default function BlockToolbar( { hideDragHandle } ) {
|
|
|
127
130
|
</ToolbarGroup>
|
|
128
131
|
) }
|
|
129
132
|
</div>
|
|
133
|
+
{ shouldShowVisualToolbar && isMultiToolbar && (
|
|
134
|
+
<BlockGroupToolbar />
|
|
135
|
+
) }
|
|
130
136
|
{ shouldShowVisualToolbar && (
|
|
131
137
|
<>
|
|
132
138
|
<BlockControls.Slot
|
|
@@ -146,9 +152,19 @@ export default function BlockToolbar( { hideDragHandle } ) {
|
|
|
146
152
|
group="other"
|
|
147
153
|
className="block-editor-block-toolbar__slot"
|
|
148
154
|
/>
|
|
155
|
+
<__unstableBlockNameContext.Provider
|
|
156
|
+
value={ blockType?.name }
|
|
157
|
+
>
|
|
158
|
+
<__unstableBlockToolbarLastItem.Slot />
|
|
159
|
+
</__unstableBlockNameContext.Provider>
|
|
149
160
|
</>
|
|
150
161
|
) }
|
|
151
162
|
<BlockSettingsMenu clientIds={ blockClientIds } />
|
|
152
163
|
</div>
|
|
153
164
|
);
|
|
154
|
-
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-toolbar/README.md
|
|
169
|
+
*/
|
|
170
|
+
export default BlockToolbar;
|
|
@@ -95,6 +95,12 @@
|
|
|
95
95
|
.block-editor-block-lock-toolbar {
|
|
96
96
|
margin-left: -$grid-unit-15 * 0.5 !important;
|
|
97
97
|
}
|
|
98
|
+
|
|
99
|
+
// @todo: override toolbar group inherited paddings from components/block-tools/style.scss.
|
|
100
|
+
// This is best fixed by making the mover control area a proper single toolbar group.
|
|
101
|
+
.components-toolbar-group {
|
|
102
|
+
padding: 0;
|
|
103
|
+
}
|
|
98
104
|
}
|
|
99
105
|
|
|
100
106
|
.block-editor-block-toolbar,
|
|
@@ -92,25 +92,6 @@ export default function BlockTools( {
|
|
|
92
92
|
event.preventDefault();
|
|
93
93
|
insertBeforeBlock( first( clientIds ) );
|
|
94
94
|
}
|
|
95
|
-
} else if (
|
|
96
|
-
isMatch( 'core/block-editor/delete-multi-selection', event )
|
|
97
|
-
) {
|
|
98
|
-
/**
|
|
99
|
-
* Check if the target element is a text area, input or
|
|
100
|
-
* event.defaultPrevented and return early. In all these
|
|
101
|
-
* cases backspace could be handled elsewhere.
|
|
102
|
-
*/
|
|
103
|
-
if (
|
|
104
|
-
[ 'INPUT', 'TEXTAREA' ].includes( event.target.nodeName ) ||
|
|
105
|
-
event.defaultPrevented
|
|
106
|
-
) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
const clientIds = getSelectedBlockClientIds();
|
|
110
|
-
if ( clientIds.length > 1 ) {
|
|
111
|
-
event.preventDefault();
|
|
112
|
-
removeBlocks( clientIds );
|
|
113
|
-
}
|
|
114
95
|
} else if ( isMatch( 'core/block-editor/unselect', event ) ) {
|
|
115
96
|
const clientIds = getSelectedBlockClientIds();
|
|
116
97
|
if ( clientIds.length > 1 ) {
|
|
@@ -312,16 +312,14 @@
|
|
|
312
312
|
// Size multiple sequential buttons to be optically balanced.
|
|
313
313
|
// Icons are 36px, as set by a 24px icon and 12px padding.
|
|
314
314
|
.block-editor-block-toolbar > .components-toolbar > .block-editor-block-toolbar__slot, // When a plugin adds to a slot, the segment has a `components-toolbar` class.
|
|
315
|
-
.block-editor-block-toolbar > .components-toolbar-group > .block-editor-block-toolbar__slot, // When no plugin adds to slots, the segment has a `components-toolbar-group` class.
|
|
316
315
|
.block-editor-block-toolbar > .block-editor-block-toolbar__slot > .components-toolbar, // The nesting order is sometimes reversed.
|
|
317
316
|
.block-editor-block-toolbar > .block-editor-block-toolbar__slot > .components-dropdown, // Targets unique markup for the "Replace" button.
|
|
318
|
-
.block-editor-block-toolbar .
|
|
317
|
+
.block-editor-block-toolbar .components-toolbar-group {
|
|
319
318
|
padding-left: $grid-unit-15 * 0.5; // 6px.
|
|
320
319
|
padding-right: $grid-unit-15 * 0.5;
|
|
321
320
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
> .components-dropdown .components-button {
|
|
321
|
+
.components-button,
|
|
322
|
+
.components-button.has-icon.has-icon {
|
|
325
323
|
min-width: $block-toolbar-height - $grid-unit-15;
|
|
326
324
|
padding-left: $grid-unit-15 * 0.5; // 6px.
|
|
327
325
|
padding-right: $grid-unit-15 * 0.5;
|