@wordpress/block-editor 8.4.0 → 8.5.2
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-alignment-control/ui.js +1 -1
- package/build/components/block-alignment-control/ui.js.map +1 -1
- package/build/components/block-content-overlay/index.js +13 -4
- package/build/components/block-content-overlay/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/index.js +8 -0
- package/build/components/block-lock/index.js.map +1 -1
- package/build/components/block-lock/menu-item.js +9 -15
- package/build/components/block-lock/menu-item.js.map +1 -1
- package/build/components/block-lock/modal.js +35 -23
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-lock/toolbar.js +11 -16
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-lock/use-block-lock.js +50 -0
- package/build/components/block-lock/use-block-lock.js.map +1 -0
- package/build/components/block-mover/index.js +4 -0
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +37 -22
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-pattern-setup/setup-toolbar.js +1 -1
- package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build/components/block-preview/auto.js +6 -3
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-preview/index.js +4 -2
- package/build/components/block-preview/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 +8 -3
- 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 +48 -9
- 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/link-control/index.js +6 -7
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +19 -6
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +18 -3
- 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 +290 -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 +264 -21
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +27 -0
- package/build/store/utils.js.map +1 -0
- 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-alignment-control/ui.js +2 -2
- package/build-module/components/block-alignment-control/ui.js.map +1 -1
- package/build-module/components/block-content-overlay/index.js +13 -4
- package/build-module/components/block-content-overlay/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/index.js +1 -0
- package/build-module/components/block-lock/index.js.map +1 -1
- package/build-module/components/block-lock/menu-item.js +8 -13
- package/build-module/components/block-lock/menu-item.js.map +1 -1
- package/build-module/components/block-lock/modal.js +34 -24
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +10 -14
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-lock/use-block-lock.js +41 -0
- package/build-module/components/block-lock/use-block-lock.js.map +1 -0
- 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-pattern-setup/index.js +39 -24
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.js +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build-module/components/block-preview/auto.js +6 -3
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-preview/index.js +4 -2
- package/build-module/components/block-preview/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 +9 -4
- 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 +48 -9
- 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/link-control/index.js +6 -7
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +17 -6
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +18 -3
- 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 +277 -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 +250 -21
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +20 -0
- package/build-module/store/utils.js.map +1 -0
- package/build-module/utils/dom.js +2 -1
- package/build-module/utils/dom.js.map +1 -1
- package/build-style/style-rtl.css +142 -101
- package/build-style/style.css +142 -101
- 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-alignment-control/ui.js +2 -2
- package/src/components/block-content-overlay/index.js +19 -2
- 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/index.js +1 -0
- package/src/components/block-lock/menu-item.js +6 -19
- package/src/components/block-lock/modal.js +52 -23
- package/src/components/block-lock/style.scss +7 -5
- package/src/components/block-lock/toolbar.js +7 -14
- package/src/components/block-lock/use-block-lock.js +45 -0
- package/src/components/block-mover/index.js +3 -0
- package/src/components/block-mover/style.scss +4 -0
- package/src/components/block-pattern-setup/index.js +84 -59
- package/src/components/block-pattern-setup/setup-toolbar.js +3 -1
- package/src/components/block-pattern-setup/style.scss +32 -26
- package/src/components/block-preview/auto.js +10 -1
- package/src/components/block-preview/index.js +2 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +62 -4
- package/src/components/block-switcher/index.js +15 -3
- package/src/components/block-switcher/style.scss +15 -4
- package/src/components/block-switcher/test/__snapshots__/index.js.snap +15 -13
- 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 +55 -10
- 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/link-control/index.js +5 -5
- package/src/components/list-view/block-select-button.js +13 -3
- package/src/components/list-view/block.js +24 -8
- 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 +341 -32
- package/src/store/defaults.js +7 -2
- package/src/store/reducer.js +25 -10
- package/src/store/selectors.js +329 -26
- package/src/store/test/selectors.js +242 -5
- package/src/store/utils.js +19 -0
- 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
|
@@ -148,6 +148,10 @@ function LinkControl( {
|
|
|
148
148
|
|
|
149
149
|
const currentInputIsEmpty = ! currentInputValue?.trim()?.length;
|
|
150
150
|
|
|
151
|
+
const { createPage, isCreatingPage, errorMessage } = useCreatePage(
|
|
152
|
+
createSuggestion
|
|
153
|
+
);
|
|
154
|
+
|
|
151
155
|
useEffect( () => {
|
|
152
156
|
if (
|
|
153
157
|
forceIsEditingLink !== undefined &&
|
|
@@ -185,7 +189,7 @@ function LinkControl( {
|
|
|
185
189
|
nextFocusTarget.focus();
|
|
186
190
|
|
|
187
191
|
isEndingEditWithFocus.current = false;
|
|
188
|
-
}, [ isEditingLink ] );
|
|
192
|
+
}, [ isEditingLink, isCreatingPage ] );
|
|
189
193
|
|
|
190
194
|
useEffect( () => {
|
|
191
195
|
/**
|
|
@@ -217,10 +221,6 @@ function LinkControl( {
|
|
|
217
221
|
setIsEditingLink( false );
|
|
218
222
|
}
|
|
219
223
|
|
|
220
|
-
const { createPage, isCreatingPage, errorMessage } = useCreatePage(
|
|
221
|
-
createSuggestion
|
|
222
|
-
);
|
|
223
|
-
|
|
224
224
|
const handleSelectSuggestion = ( updatedValue ) => {
|
|
225
225
|
onChange( {
|
|
226
226
|
...updatedValue,
|
|
@@ -8,6 +8,8 @@ import classnames from 'classnames';
|
|
|
8
8
|
*/
|
|
9
9
|
import { Button } from '@wordpress/components';
|
|
10
10
|
import { forwardRef } from '@wordpress/element';
|
|
11
|
+
import { Icon, lock } from '@wordpress/icons';
|
|
12
|
+
import { SPACE, ENTER } from '@wordpress/keycodes';
|
|
11
13
|
|
|
12
14
|
/**
|
|
13
15
|
* Internal dependencies
|
|
@@ -16,7 +18,7 @@ import BlockIcon from '../block-icon';
|
|
|
16
18
|
import useBlockDisplayInformation from '../use-block-display-information';
|
|
17
19
|
import BlockTitle from '../block-title';
|
|
18
20
|
import ListViewExpander from './expander';
|
|
19
|
-
import {
|
|
21
|
+
import { useBlockLock } from '../block-lock';
|
|
20
22
|
|
|
21
23
|
function ListViewBlockSelectButton(
|
|
22
24
|
{
|
|
@@ -33,6 +35,7 @@ function ListViewBlockSelectButton(
|
|
|
33
35
|
ref
|
|
34
36
|
) {
|
|
35
37
|
const blockInformation = useBlockDisplayInformation( clientId );
|
|
38
|
+
const { isLocked } = useBlockLock( clientId );
|
|
36
39
|
|
|
37
40
|
// The `href` attribute triggers the browser's native HTML drag operations.
|
|
38
41
|
// When the link is dragged, the element's outerHTML is set in DataTransfer object as text/html.
|
|
@@ -40,7 +43,7 @@ function ListViewBlockSelectButton(
|
|
|
40
43
|
// inside the `useOnBlockDrop` hook.
|
|
41
44
|
const onDragStartHandler = ( event ) => {
|
|
42
45
|
event.dataTransfer.clearData();
|
|
43
|
-
onDragStart( event );
|
|
46
|
+
onDragStart?.( event );
|
|
44
47
|
};
|
|
45
48
|
|
|
46
49
|
function onKeyDownHandler( event ) {
|
|
@@ -69,12 +72,19 @@ function ListViewBlockSelectButton(
|
|
|
69
72
|
>
|
|
70
73
|
<ListViewExpander onClick={ onToggleExpanded } />
|
|
71
74
|
<BlockIcon icon={ blockInformation?.icon } showColors />
|
|
72
|
-
<
|
|
75
|
+
<span className="block-editor-list-view-block-select-button__title">
|
|
76
|
+
<BlockTitle clientId={ clientId } maximumLength={ 35 } />
|
|
77
|
+
</span>
|
|
73
78
|
{ blockInformation?.anchor && (
|
|
74
79
|
<span className="block-editor-list-view-block-select-button__anchor">
|
|
75
80
|
{ blockInformation.anchor }
|
|
76
81
|
</span>
|
|
77
82
|
) }
|
|
83
|
+
{ isLocked && (
|
|
84
|
+
<span className="block-editor-list-view-block-select-button__lock">
|
|
85
|
+
<Icon icon={ lock } />
|
|
86
|
+
</span>
|
|
87
|
+
) }
|
|
78
88
|
</Button>
|
|
79
89
|
</>
|
|
80
90
|
);
|
|
@@ -36,6 +36,7 @@ import { useListViewContext } from './context';
|
|
|
36
36
|
import { getBlockPositionDescription } from './utils';
|
|
37
37
|
import { store as blockEditorStore } from '../../store';
|
|
38
38
|
import useBlockDisplayInformation from '../use-block-display-information';
|
|
39
|
+
import { useBlockLock } from '../block-lock';
|
|
39
40
|
|
|
40
41
|
function ListViewBlock( {
|
|
41
42
|
block,
|
|
@@ -56,10 +57,16 @@ function ListViewBlock( {
|
|
|
56
57
|
const cellRef = useRef( null );
|
|
57
58
|
const [ isHovered, setIsHovered ] = useState( false );
|
|
58
59
|
const { clientId } = block;
|
|
60
|
+
const isFirstSelectedBlock =
|
|
61
|
+
isSelected && selectedClientIds[ 0 ] === clientId;
|
|
62
|
+
const isLastSelectedBlock =
|
|
63
|
+
isSelected &&
|
|
64
|
+
selectedClientIds[ selectedClientIds.length - 1 ] === clientId;
|
|
59
65
|
|
|
60
66
|
const { toggleBlockHighlight } = useDispatch( blockEditorStore );
|
|
61
67
|
|
|
62
68
|
const blockInformation = useBlockDisplayInformation( clientId );
|
|
69
|
+
const { isLocked } = useBlockLock( clientId );
|
|
63
70
|
const instanceId = useInstanceId( ListViewBlock );
|
|
64
71
|
const descriptionId = `list-view-block-select-button__${ instanceId }`;
|
|
65
72
|
const blockPositionDescription = getBlockPositionDescription(
|
|
@@ -68,13 +75,20 @@ function ListViewBlock( {
|
|
|
68
75
|
level
|
|
69
76
|
);
|
|
70
77
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
+
let blockAriaLabel = __( 'Link' );
|
|
79
|
+
if ( blockInformation ) {
|
|
80
|
+
blockAriaLabel = isLocked
|
|
81
|
+
? sprintf(
|
|
82
|
+
// translators: %s: The title of the block. This string indicates a link to select the locked block.
|
|
83
|
+
__( '%s link (locked)' ),
|
|
84
|
+
blockInformation.title
|
|
85
|
+
)
|
|
86
|
+
: sprintf(
|
|
87
|
+
// translators: %s: The title of the block. This string indicates a link to select the block.
|
|
88
|
+
__( '%s link' ),
|
|
89
|
+
blockInformation.title
|
|
90
|
+
);
|
|
91
|
+
}
|
|
78
92
|
|
|
79
93
|
const settingsAriaLabel = blockInformation
|
|
80
94
|
? sprintf(
|
|
@@ -102,7 +116,7 @@ function ListViewBlock( {
|
|
|
102
116
|
|
|
103
117
|
const listViewBlockSettingsClassName = classnames(
|
|
104
118
|
'block-editor-list-view-block__menu-cell',
|
|
105
|
-
{ 'is-visible': isHovered ||
|
|
119
|
+
{ 'is-visible': isHovered || isFirstSelectedBlock }
|
|
106
120
|
);
|
|
107
121
|
|
|
108
122
|
// If ListView has experimental features related to the Persistent List View,
|
|
@@ -177,6 +191,8 @@ function ListViewBlock( {
|
|
|
177
191
|
|
|
178
192
|
const classes = classnames( {
|
|
179
193
|
'is-selected': isSelected,
|
|
194
|
+
'is-first-selected': isFirstSelectedBlock,
|
|
195
|
+
'is-last-selected': isLastSelectedBlock,
|
|
180
196
|
'is-branch-selected':
|
|
181
197
|
withExperimentalPersistentListViewFeatures && isBranchSelected,
|
|
182
198
|
'is-dragging': isDragged,
|
|
@@ -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.
|