@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
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
// Use position relative for row animation.
|
|
16
16
|
position: relative;
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
// The background has to be applied to the td, not tr, or border-radius won't work.
|
|
19
|
+
&.is-selected td {
|
|
19
20
|
background: var(--wp-admin-theme-color);
|
|
20
21
|
}
|
|
21
22
|
&.is-selected .block-editor-list-view-block-contents,
|
|
@@ -40,27 +41,53 @@
|
|
|
40
41
|
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) $white;
|
|
41
42
|
}
|
|
42
43
|
|
|
44
|
+
&.is-dragging {
|
|
45
|
+
display: none;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Border radius for corners of the selected item.
|
|
49
|
+
&.is-first-selected td:first-child {
|
|
50
|
+
border-top-left-radius: $radius-block-ui;
|
|
51
|
+
}
|
|
52
|
+
&.is-first-selected td:last-child {
|
|
53
|
+
border-top-right-radius: $radius-block-ui;
|
|
54
|
+
}
|
|
55
|
+
&.is-last-selected td:first-child {
|
|
56
|
+
border-bottom-left-radius: $radius-block-ui;
|
|
57
|
+
}
|
|
58
|
+
&.is-last-selected td:last-child {
|
|
59
|
+
border-bottom-right-radius: $radius-block-ui;
|
|
60
|
+
}
|
|
43
61
|
&.is-branch-selected:not(.is-selected) {
|
|
44
62
|
// Lighten a CSS variable without introducing a new SASS variable
|
|
45
63
|
background:
|
|
46
64
|
linear-gradient(transparentize($white, 0.1), transparentize($white, 0.1)),
|
|
47
65
|
linear-gradient(var(--wp-admin-theme-color), var(--wp-admin-theme-color));
|
|
48
66
|
}
|
|
49
|
-
&.is-branch-selected.is-selected
|
|
50
|
-
border-radius:
|
|
67
|
+
&.is-branch-selected.is-first-selected td:first-child {
|
|
68
|
+
border-top-left-radius: $radius-block-ui;
|
|
69
|
+
}
|
|
70
|
+
&.is-branch-selected.is-first-selected td:last-child {
|
|
71
|
+
border-top-right-radius: $radius-block-ui;
|
|
51
72
|
}
|
|
52
73
|
&[aria-expanded="false"] {
|
|
53
|
-
&.is-branch-selected.is-selected
|
|
54
|
-
border-radius:
|
|
74
|
+
&.is-branch-selected.is-first-selected td:first-child {
|
|
75
|
+
border-top-left-radius: $radius-block-ui;
|
|
76
|
+
}
|
|
77
|
+
&.is-branch-selected.is-first-selected td:last-child {
|
|
78
|
+
border-top-right-radius: $radius-block-ui;
|
|
79
|
+
}
|
|
80
|
+
&.is-branch-selected.is-last-selected td:first-child {
|
|
81
|
+
border-bottom-left-radius: $radius-block-ui;
|
|
82
|
+
}
|
|
83
|
+
&.is-branch-selected.is-last-selected td:last-child {
|
|
84
|
+
border-bottom-right-radius: $radius-block-ui;
|
|
55
85
|
}
|
|
56
86
|
}
|
|
57
|
-
&.is-branch-selected:not(.is-selected)
|
|
87
|
+
&.is-branch-selected:not(.is-selected) td {
|
|
58
88
|
border-radius: 0;
|
|
59
89
|
}
|
|
60
90
|
|
|
61
|
-
&.is-dragging {
|
|
62
|
-
display: none;
|
|
63
|
-
}
|
|
64
91
|
|
|
65
92
|
// List View renders a fixed number of items and relies on each item having a fixed height of 36px.
|
|
66
93
|
// If this value changes, we should also change the itemHeight value set in useFixedWindowList.
|
|
@@ -73,7 +100,7 @@
|
|
|
73
100
|
padding: ($grid-unit-15 * 0.5) $grid-unit-15 ($grid-unit-15 * 0.5) 0;
|
|
74
101
|
text-align: left;
|
|
75
102
|
color: $gray-900;
|
|
76
|
-
border-radius:
|
|
103
|
+
border-radius: $radius-block-ui;
|
|
77
104
|
position: relative;
|
|
78
105
|
white-space: nowrap;
|
|
79
106
|
|
|
@@ -106,7 +133,7 @@
|
|
|
106
133
|
left: 0;
|
|
107
134
|
border-radius: inherit;
|
|
108
135
|
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
109
|
-
z-index:
|
|
136
|
+
z-index: 2;
|
|
110
137
|
pointer-events: none;
|
|
111
138
|
|
|
112
139
|
// Hide focus styles while a user is dragging blocks/files etc.
|
|
@@ -152,17 +179,23 @@
|
|
|
152
179
|
.block-editor-list-view-block__mover-cell {
|
|
153
180
|
line-height: 0;
|
|
154
181
|
width: $button-size;
|
|
155
|
-
opacity: 0;
|
|
156
182
|
vertical-align: middle;
|
|
157
183
|
@include reduce-motion("transition");
|
|
158
184
|
|
|
185
|
+
> * {
|
|
186
|
+
opacity: 0;
|
|
187
|
+
}
|
|
188
|
+
|
|
159
189
|
// Show on hover, visible, and show above to keep the hit area size.
|
|
160
190
|
&:hover,
|
|
161
191
|
&.is-visible {
|
|
162
192
|
position: relative;
|
|
163
193
|
z-index: 1;
|
|
164
|
-
|
|
165
|
-
|
|
194
|
+
|
|
195
|
+
> * {
|
|
196
|
+
opacity: 1;
|
|
197
|
+
@include edit-post__fade-in-animation;
|
|
198
|
+
}
|
|
166
199
|
}
|
|
167
200
|
|
|
168
201
|
&,
|
|
@@ -278,6 +311,15 @@
|
|
|
278
311
|
&.is-selected .block-editor-list-view-block-select-button__anchor {
|
|
279
312
|
background: rgba($black, 0.3);
|
|
280
313
|
}
|
|
314
|
+
|
|
315
|
+
.block-editor-list-view-block-select-button__lock {
|
|
316
|
+
line-height: 0;
|
|
317
|
+
width: 24px;
|
|
318
|
+
min-width: 24px;
|
|
319
|
+
margin-left: auto;
|
|
320
|
+
padding: 0;
|
|
321
|
+
vertical-align: middle;
|
|
322
|
+
}
|
|
281
323
|
}
|
|
282
324
|
|
|
283
325
|
.block-editor-list-view-block-select-button__description,
|
|
@@ -140,6 +140,14 @@ Whether to allow multiple selection of files or not.
|
|
|
140
140
|
- Default: `false`
|
|
141
141
|
- Platform: Web
|
|
142
142
|
|
|
143
|
+
### mediaPreview
|
|
144
|
+
|
|
145
|
+
The component is rendered as a preview in the placeholder.
|
|
146
|
+
|
|
147
|
+
- Type: `Component`
|
|
148
|
+
- Required: No
|
|
149
|
+
- Platform: Web
|
|
150
|
+
|
|
143
151
|
### onError
|
|
144
152
|
|
|
145
153
|
Callback called when an upload error happens.
|
|
@@ -212,6 +212,9 @@ const MediaReplaceFlow = ( {
|
|
|
212
212
|
);
|
|
213
213
|
};
|
|
214
214
|
|
|
215
|
+
/**
|
|
216
|
+
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-replace-flow/README.md
|
|
217
|
+
*/
|
|
215
218
|
export default compose( [
|
|
216
219
|
withDispatch( ( dispatch ) => {
|
|
217
220
|
const { createNotice, removeNotice } = dispatch( noticesStore );
|
|
@@ -5,7 +5,7 @@ import { sprintf, _n } from '@wordpress/i18n';
|
|
|
5
5
|
import { withSelect } from '@wordpress/data';
|
|
6
6
|
import { serialize } from '@wordpress/blocks';
|
|
7
7
|
import { count as wordCount } from '@wordpress/wordcount';
|
|
8
|
-
import {
|
|
8
|
+
import { copy } from '@wordpress/icons';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Internal dependencies
|
|
@@ -18,7 +18,7 @@ function MultiSelectionInspector( { blocks } ) {
|
|
|
18
18
|
|
|
19
19
|
return (
|
|
20
20
|
<div className="block-editor-multi-selection-inspector__card">
|
|
21
|
-
<BlockIcon icon={
|
|
21
|
+
<BlockIcon icon={ copy } showColors />
|
|
22
22
|
<div className="block-editor-multi-selection-inspector__card-content">
|
|
23
23
|
<div className="block-editor-multi-selection-inspector__card-title">
|
|
24
24
|
{ sprintf(
|
|
@@ -45,6 +45,7 @@ import { useFormatTypes } from './use-format-types';
|
|
|
45
45
|
import { useRemoveBrowserShortcuts } from './use-remove-browser-shortcuts';
|
|
46
46
|
import { useShortcuts } from './use-shortcuts';
|
|
47
47
|
import { useInputEvents } from './use-input-events';
|
|
48
|
+
import { useFirefoxCompat } from './use-firefox-compat';
|
|
48
49
|
import FormatEdit from './format-edit';
|
|
49
50
|
import { getMultilineTag, getAllowedFormats } from './utils';
|
|
50
51
|
|
|
@@ -131,6 +132,7 @@ function RichTextWrapper(
|
|
|
131
132
|
if ( originalIsSelected === undefined ) {
|
|
132
133
|
isSelected =
|
|
133
134
|
selectionStart.clientId === clientId &&
|
|
135
|
+
selectionEnd.clientId === clientId &&
|
|
134
136
|
selectionStart.attributeKey === identifier;
|
|
135
137
|
} else if ( originalIsSelected ) {
|
|
136
138
|
isSelected = selectionStart.clientId === clientId;
|
|
@@ -171,7 +173,26 @@ function RichTextWrapper(
|
|
|
171
173
|
|
|
172
174
|
const onSelectionChange = useCallback(
|
|
173
175
|
( start, end ) => {
|
|
174
|
-
|
|
176
|
+
const selection = {};
|
|
177
|
+
const unset = start === undefined && end === undefined;
|
|
178
|
+
|
|
179
|
+
if ( typeof start === 'number' || unset ) {
|
|
180
|
+
selection.start = {
|
|
181
|
+
clientId,
|
|
182
|
+
attributeKey: identifier,
|
|
183
|
+
offset: start,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if ( typeof end === 'number' || unset ) {
|
|
188
|
+
selection.end = {
|
|
189
|
+
clientId,
|
|
190
|
+
attributeKey: identifier,
|
|
191
|
+
offset: end,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
selectionChange( selection );
|
|
175
196
|
},
|
|
176
197
|
[ clientId, identifier ]
|
|
177
198
|
);
|
|
@@ -340,6 +361,7 @@ function RichTextWrapper(
|
|
|
340
361
|
__unstableAllowPrefixTransformations,
|
|
341
362
|
formatTypes,
|
|
342
363
|
onReplace,
|
|
364
|
+
selectionChange,
|
|
343
365
|
} ),
|
|
344
366
|
useRemoveBrowserShortcuts(),
|
|
345
367
|
useShortcuts( keyboardShortcuts ),
|
|
@@ -371,6 +393,7 @@ function RichTextWrapper(
|
|
|
371
393
|
disableLineBreaks,
|
|
372
394
|
onSplitAtEnd,
|
|
373
395
|
} ),
|
|
396
|
+
useFirefoxCompat(),
|
|
374
397
|
anchorRef,
|
|
375
398
|
] ) }
|
|
376
399
|
contentEditable={ true }
|
|
@@ -20,8 +20,12 @@ export function splitValue( {
|
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
// Ensure the value has a selection. This might happen when trying to split
|
|
24
|
+
// an empty value before there was a `selectionchange` event.
|
|
25
|
+
const { start = 0, end = 0 } = value;
|
|
26
|
+
const valueWithEnsuredSelection = { ...value, start, end };
|
|
23
27
|
const blocks = [];
|
|
24
|
-
const [ before, after ] = split(
|
|
28
|
+
const [ before, after ] = split( valueWithEnsuredSelection );
|
|
25
29
|
const hasPastedBlocks = pastedBlocks.length > 0;
|
|
26
30
|
let lastPastedBlockIndex = -1;
|
|
27
31
|
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useRefEffect } from '@wordpress/compose';
|
|
5
|
+
import { useSelect } from '@wordpress/data';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { store as blockEditorStore } from '../../store';
|
|
11
|
+
|
|
12
|
+
export function useFirefoxCompat() {
|
|
13
|
+
const { isMultiSelecting } = useSelect( blockEditorStore );
|
|
14
|
+
return useRefEffect( ( element ) => {
|
|
15
|
+
function onFocus() {
|
|
16
|
+
if ( ! isMultiSelecting() ) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// This is a little hack to work around focus issues with nested
|
|
21
|
+
// editable elements in Firefox. For some reason the editable child
|
|
22
|
+
// element sometimes regains focus, while it should not be focusable
|
|
23
|
+
// and focus should remain on the editable parent element.
|
|
24
|
+
// To do: try to find the cause of the shifting focus.
|
|
25
|
+
const parentEditable = element.parentElement.closest(
|
|
26
|
+
'[contenteditable="true"]'
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
if ( parentEditable ) {
|
|
30
|
+
parentEditable.focus();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
element.addEventListener( 'focus', onFocus );
|
|
35
|
+
return () => {
|
|
36
|
+
element.removeEventListener( 'focus', onFocus );
|
|
37
|
+
};
|
|
38
|
+
}, [] );
|
|
39
|
+
}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { findKey } from 'lodash';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
4
9
|
import { useRef } from '@wordpress/element';
|
|
5
10
|
import { useRefEffect } from '@wordpress/compose';
|
|
6
|
-
import {
|
|
11
|
+
import { insert, toHTMLString } from '@wordpress/rich-text';
|
|
7
12
|
import { getBlockTransforms, findTransform } from '@wordpress/blocks';
|
|
8
13
|
import { useDispatch } from '@wordpress/data';
|
|
9
14
|
|
|
@@ -13,6 +18,37 @@ import { useDispatch } from '@wordpress/data';
|
|
|
13
18
|
import { store as blockEditorStore } from '../../store';
|
|
14
19
|
import { preventEventDiscovery } from './prevent-event-discovery';
|
|
15
20
|
|
|
21
|
+
// A robust way to retain selection position through various
|
|
22
|
+
// transforms is to insert a special character at the position and
|
|
23
|
+
// then recover it.
|
|
24
|
+
const START_OF_SELECTED_AREA = '\u0086';
|
|
25
|
+
|
|
26
|
+
function findSelection( blocks ) {
|
|
27
|
+
let i = blocks.length;
|
|
28
|
+
|
|
29
|
+
while ( i-- ) {
|
|
30
|
+
const attributeKey = findKey(
|
|
31
|
+
blocks[ i ].attributes,
|
|
32
|
+
( v ) =>
|
|
33
|
+
typeof v === 'string' &&
|
|
34
|
+
v.indexOf( START_OF_SELECTED_AREA ) !== -1
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
if ( attributeKey ) {
|
|
38
|
+
blocks[ i ].attributes[ attributeKey ] = blocks[ i ].attributes[
|
|
39
|
+
attributeKey
|
|
40
|
+
].replace( START_OF_SELECTED_AREA, '' );
|
|
41
|
+
return blocks[ i ].clientId;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const nestedSelection = findSelection( blocks[ i ].innerBlocks );
|
|
45
|
+
|
|
46
|
+
if ( nestedSelection ) {
|
|
47
|
+
return nestedSelection;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
16
52
|
export function useInputRules( props ) {
|
|
17
53
|
const {
|
|
18
54
|
__unstableMarkLastChangeAsPersistent,
|
|
@@ -22,7 +58,7 @@ export function useInputRules( props ) {
|
|
|
22
58
|
propsRef.current = props;
|
|
23
59
|
return useRefEffect( ( element ) => {
|
|
24
60
|
function inputRule() {
|
|
25
|
-
const { value, onReplace } = propsRef.current;
|
|
61
|
+
const { value, onReplace, selectionChange } = propsRef.current;
|
|
26
62
|
|
|
27
63
|
if ( ! onReplace ) {
|
|
28
64
|
return;
|
|
@@ -52,10 +88,11 @@ export function useInputRules( props ) {
|
|
|
52
88
|
}
|
|
53
89
|
|
|
54
90
|
const content = toHTMLString( {
|
|
55
|
-
value:
|
|
91
|
+
value: insert( value, START_OF_SELECTED_AREA, 0, start ),
|
|
56
92
|
} );
|
|
57
93
|
const block = transformation.transform( content );
|
|
58
94
|
|
|
95
|
+
selectionChange( findSelection( [ block ] ) );
|
|
59
96
|
onReplace( [ block ] );
|
|
60
97
|
__unstableMarkAutomaticChange();
|
|
61
98
|
}
|
|
@@ -28,6 +28,9 @@ const SkipToSelectedBlock = ( { selectedBlockClientId } ) => {
|
|
|
28
28
|
) : null;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/skip-to-selected-block/README.md
|
|
33
|
+
*/
|
|
31
34
|
export default withSelect( ( select ) => {
|
|
32
35
|
return {
|
|
33
36
|
selectedBlockClientId: select(
|
|
@@ -71,12 +71,13 @@ $input-size: 300px;
|
|
|
71
71
|
.block-editor-url-input .components-spinner {
|
|
72
72
|
display: none;
|
|
73
73
|
@include break-small() {
|
|
74
|
-
display:
|
|
74
|
+
display: grid;
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
.block-editor-url-input__suggestion {
|
|
79
|
-
|
|
79
|
+
min-height: $button-size;
|
|
80
|
+
height: auto;
|
|
80
81
|
color: $gray-700;
|
|
81
82
|
display: block;
|
|
82
83
|
font-size: $default-font-size;
|
|
@@ -18,6 +18,10 @@ import useMultiSelection from './use-multi-selection';
|
|
|
18
18
|
import useTabNav from './use-tab-nav';
|
|
19
19
|
import useArrowNav from './use-arrow-nav';
|
|
20
20
|
import useSelectAll from './use-select-all';
|
|
21
|
+
import useDragSelection from './use-drag-selection';
|
|
22
|
+
import useSelectionObserver from './use-selection-observer';
|
|
23
|
+
import useClickSelection from './use-click-selection';
|
|
24
|
+
import useInput from './use-input';
|
|
21
25
|
import { store as blockEditorStore } from '../../store';
|
|
22
26
|
|
|
23
27
|
export function useWritingFlow() {
|
|
@@ -31,6 +35,10 @@ export function useWritingFlow() {
|
|
|
31
35
|
before,
|
|
32
36
|
useMergeRefs( [
|
|
33
37
|
ref,
|
|
38
|
+
useInput(),
|
|
39
|
+
useDragSelection(),
|
|
40
|
+
useSelectionObserver(),
|
|
41
|
+
useClickSelection(),
|
|
34
42
|
useMultiSelection(),
|
|
35
43
|
useSelectAll(),
|
|
36
44
|
useArrowNav(),
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Writing Flow
|
|
2
|
+
|
|
3
|
+
This hook handles selection across blocks.
|
|
4
|
+
|
|
5
|
+
## Partial multi-block selection
|
|
6
|
+
|
|
7
|
+
Selecting across blocks is possible by temporarily setting the `contentEditable`
|
|
8
|
+
attribute to `true`. This sounds scary, but we prevent all default behaviours
|
|
9
|
+
except for selection, so don't worry. :)
|
|
10
|
+
|
|
11
|
+
* For selection by mouse, we make everything editable when the mouse leaves an
|
|
12
|
+
editable field.
|
|
13
|
+
* For Shift+Click selection, we do it on `mousedown`.
|
|
14
|
+
* For keyboard selection we do it when the selection reaches the edge of an
|
|
15
|
+
editable field.
|
|
16
|
+
|
|
17
|
+
In the future, we should consider using the `contentEditable` attribute for
|
|
18
|
+
arrow key navigation as well.
|
|
19
|
+
|
|
20
|
+
Now that it's possible to select across blocks, we need to sync this state to
|
|
21
|
+
the block editor store. We can do this by listening to the `selectionchange`
|
|
22
|
+
event. In writing flow, we can sync the selected block client ID, but when the
|
|
23
|
+
selection starts or ends in a rich text field, it will be rich text that sync a
|
|
24
|
+
more precise position (the block attribute key and offset in addition to the
|
|
25
|
+
client ID).
|
|
26
|
+
|
|
27
|
+
With the selection state in the block editor store, we can now handle things
|
|
28
|
+
like Backspace, Delete, and Enter.
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
isRTL,
|
|
17
17
|
} from '@wordpress/dom';
|
|
18
18
|
import { UP, DOWN, LEFT, RIGHT } from '@wordpress/keycodes';
|
|
19
|
-
import { useSelect
|
|
19
|
+
import { useSelect } from '@wordpress/data';
|
|
20
20
|
import { useRefEffect } from '@wordpress/compose';
|
|
21
21
|
|
|
22
22
|
/**
|
|
@@ -120,16 +120,12 @@ export function getClosestTabbable(
|
|
|
120
120
|
export default function useArrowNav() {
|
|
121
121
|
const {
|
|
122
122
|
getSelectedBlockClientId,
|
|
123
|
-
getMultiSelectedBlocksStartClientId,
|
|
124
123
|
getMultiSelectedBlocksEndClientId,
|
|
125
124
|
getPreviousBlockClientId,
|
|
126
125
|
getNextBlockClientId,
|
|
127
|
-
getFirstMultiSelectedBlockClientId,
|
|
128
|
-
getLastMultiSelectedBlockClientId,
|
|
129
126
|
getSettings,
|
|
130
127
|
hasMultiSelection,
|
|
131
128
|
} = useSelect( blockEditorStore );
|
|
132
|
-
const { multiSelect, selectBlock } = useDispatch( blockEditorStore );
|
|
133
129
|
return useRefEffect( ( node ) => {
|
|
134
130
|
// Here a DOMRect is stored while moving the caret vertically so
|
|
135
131
|
// vertical position of the start position can be restored. This is to
|
|
@@ -140,44 +136,6 @@ export default function useArrowNav() {
|
|
|
140
136
|
verticalRect = null;
|
|
141
137
|
}
|
|
142
138
|
|
|
143
|
-
function expandSelection( isReverse ) {
|
|
144
|
-
const selectedBlockClientId = getSelectedBlockClientId();
|
|
145
|
-
const selectionStartClientId = getMultiSelectedBlocksStartClientId();
|
|
146
|
-
const selectionEndClientId = getMultiSelectedBlocksEndClientId();
|
|
147
|
-
const selectionBeforeEndClientId = getPreviousBlockClientId(
|
|
148
|
-
selectionEndClientId || selectedBlockClientId
|
|
149
|
-
);
|
|
150
|
-
const selectionAfterEndClientId = getNextBlockClientId(
|
|
151
|
-
selectionEndClientId || selectedBlockClientId
|
|
152
|
-
);
|
|
153
|
-
const nextSelectionEndClientId = isReverse
|
|
154
|
-
? selectionBeforeEndClientId
|
|
155
|
-
: selectionAfterEndClientId;
|
|
156
|
-
|
|
157
|
-
if ( nextSelectionEndClientId ) {
|
|
158
|
-
if ( selectionStartClientId === nextSelectionEndClientId ) {
|
|
159
|
-
selectBlock( nextSelectionEndClientId );
|
|
160
|
-
} else {
|
|
161
|
-
multiSelect(
|
|
162
|
-
selectionStartClientId || selectedBlockClientId,
|
|
163
|
-
nextSelectionEndClientId
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
function moveSelection( isReverse ) {
|
|
170
|
-
const selectedFirstClientId = getFirstMultiSelectedBlockClientId();
|
|
171
|
-
const selectedLastClientId = getLastMultiSelectedBlockClientId();
|
|
172
|
-
const focusedBlockClientId = isReverse
|
|
173
|
-
? selectedFirstClientId
|
|
174
|
-
: selectedLastClientId;
|
|
175
|
-
|
|
176
|
-
if ( focusedBlockClientId ) {
|
|
177
|
-
selectBlock( focusedBlockClientId );
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
139
|
/**
|
|
182
140
|
* Returns true if the given target field is the last in its block which
|
|
183
141
|
* can be considered for tab transition. For example, in a block with
|
|
@@ -218,12 +176,6 @@ export default function useArrowNav() {
|
|
|
218
176
|
const { defaultView } = ownerDocument;
|
|
219
177
|
|
|
220
178
|
if ( hasMultiSelection() ) {
|
|
221
|
-
if ( isNav ) {
|
|
222
|
-
const action = isShift ? expandSelection : moveSelection;
|
|
223
|
-
action( isReverse );
|
|
224
|
-
event.preventDefault();
|
|
225
|
-
}
|
|
226
|
-
|
|
227
179
|
return;
|
|
228
180
|
}
|
|
229
181
|
|
|
@@ -278,10 +230,9 @@ export default function useArrowNav() {
|
|
|
278
230
|
isTabbableEdge( target, isReverse ) &&
|
|
279
231
|
isNavEdge( target, isReverse )
|
|
280
232
|
) {
|
|
281
|
-
|
|
282
|
-
//
|
|
283
|
-
|
|
284
|
-
event.preventDefault();
|
|
233
|
+
node.contentEditable = true;
|
|
234
|
+
// Firefox doesn't automatically move focus.
|
|
235
|
+
node.focus();
|
|
285
236
|
}
|
|
286
237
|
} else if (
|
|
287
238
|
isVertical &&
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
5
|
+
import { useRefEffect } from '@wordpress/compose';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { store as blockEditorStore } from '../../store';
|
|
11
|
+
import { getBlockClientId } from '../../utils/dom';
|
|
12
|
+
|
|
13
|
+
export default function useClickSelection() {
|
|
14
|
+
const { multiSelect, selectBlock } = useDispatch( blockEditorStore );
|
|
15
|
+
const {
|
|
16
|
+
isSelectionEnabled,
|
|
17
|
+
getBlockParents,
|
|
18
|
+
getBlockSelectionStart,
|
|
19
|
+
hasMultiSelection,
|
|
20
|
+
} = useSelect( blockEditorStore );
|
|
21
|
+
return useRefEffect(
|
|
22
|
+
( node ) => {
|
|
23
|
+
function onMouseDown( event ) {
|
|
24
|
+
// The main button.
|
|
25
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
|
|
26
|
+
if ( ! isSelectionEnabled() || event.button !== 0 ) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const startClientId = getBlockSelectionStart();
|
|
31
|
+
const clickedClientId = getBlockClientId( event.target );
|
|
32
|
+
|
|
33
|
+
if ( event.shiftKey ) {
|
|
34
|
+
if ( startClientId !== clickedClientId ) {
|
|
35
|
+
node.contentEditable = true;
|
|
36
|
+
// Firefox doesn't automatically move focus.
|
|
37
|
+
node.focus();
|
|
38
|
+
}
|
|
39
|
+
} else if ( hasMultiSelection() ) {
|
|
40
|
+
// Allow user to escape out of a multi-selection to a
|
|
41
|
+
// singular selection of a block via click. This is handled
|
|
42
|
+
// here since focus handling excludes blocks when there is
|
|
43
|
+
// multiselection, as focus can be incurred by starting a
|
|
44
|
+
// multiselection (focus moved to first block's multi-
|
|
45
|
+
// controls).
|
|
46
|
+
selectBlock( clickedClientId );
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
node.addEventListener( 'mousedown', onMouseDown );
|
|
51
|
+
|
|
52
|
+
return () => {
|
|
53
|
+
node.removeEventListener( 'mousedown', onMouseDown );
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
[
|
|
57
|
+
multiSelect,
|
|
58
|
+
selectBlock,
|
|
59
|
+
isSelectionEnabled,
|
|
60
|
+
getBlockParents,
|
|
61
|
+
getBlockSelectionStart,
|
|
62
|
+
hasMultiSelection,
|
|
63
|
+
]
|
|
64
|
+
);
|
|
65
|
+
}
|