@wordpress/block-editor 8.3.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 +4 -0
- package/README.md +56 -18
- 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/block-html.js +4 -1
- package/build/components/block-list/block-html.js.map +1 -1
- package/build/components/block-list/block.js +4 -1
- package/build/components/block-list/block.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 +22 -6
- 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 +32 -0
- package/build/components/block-lock/index.js.map +1 -0
- package/build/components/block-lock/menu-item.js +67 -0
- package/build/components/block-lock/menu-item.js.map +1 -0
- package/build/components/block-lock/modal.js +134 -0
- package/build/components/block-lock/modal.js.map +1 -0
- package/build/components/block-lock/toolbar.js +78 -0
- package/build/components/block-lock/toolbar.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-settings-menu/block-settings-dropdown.js +75 -10
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +19 -9
- package/build/components/block-settings-menu-controls/index.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 +8 -6
- 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 +24 -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/border-radius-control/index.js +0 -1
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/border-radius-control/utils.js +1 -1
- package/build/components/border-radius-control/utils.js.map +1 -1
- package/build/components/colors-gradients/control.js +3 -1
- package/build/components/colors-gradients/control.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/date-format-picker/index.js +132 -0
- package/build/components/date-format-picker/index.js.map +1 -0
- 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 +27 -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 +15 -6
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +24 -23
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +38 -13
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +16 -13
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/index.js +7 -1
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/use-block-selection.js +9 -2
- package/build/components/list-view/use-block-selection.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 +27 -5
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +13 -9
- package/build/components/rich-text/index.native.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/url-popover/image-url-input-ui.js +11 -27
- package/build/components/url-popover/image-url-input-ui.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/anchor.js +7 -6
- package/build/hooks/anchor.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 +77 -5
- 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 +82 -15
- package/build/layouts/flex.js.map +1 -1
- package/build/layouts/flow.js +22 -13
- 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 -1
- 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 +171 -21
- 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/block-html.js +5 -2
- package/build-module/components/block-list/block-html.js.map +1 -1
- package/build-module/components/block-list/block.js +5 -2
- package/build-module/components/block-list/block.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 +22 -6
- 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 +4 -0
- package/build-module/components/block-lock/index.js.map +1 -0
- package/build-module/components/block-lock/menu-item.js +53 -0
- package/build-module/components/block-lock/menu-item.js.map +1 -0
- package/build-module/components/block-lock/modal.js +119 -0
- package/build-module/components/block-lock/modal.js.map +1 -0
- package/build-module/components/block-lock/toolbar.js +63 -0
- package/build-module/components/block-lock/toolbar.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-settings-menu/block-settings-dropdown.js +75 -12
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +18 -9
- package/build-module/components/block-settings-menu-controls/index.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 +8 -6
- 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 +19 -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/border-radius-control/index.js +0 -1
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/border-radius-control/utils.js +1 -1
- package/build-module/components/border-radius-control/utils.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +3 -1
- package/build-module/components/colors-gradients/control.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/date-format-picker/index.js +122 -0
- package/build-module/components/date-format-picker/index.js.map +1 -0
- 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 +3 -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 +14 -5
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +24 -23
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +36 -13
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +16 -13
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/index.js +7 -1
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js +10 -3
- package/build-module/components/list-view/use-block-selection.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 +26 -5
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +13 -9
- package/build-module/components/rich-text/index.native.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/url-popover/image-url-input-ui.js +12 -28
- package/build-module/components/url-popover/image-url-input-ui.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/anchor.js +7 -6
- package/build-module/hooks/anchor.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 +75 -7
- 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 +81 -16
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/layouts/flow.js +20 -13
- 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 -1
- 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 +162 -20
- 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 +214 -24
- package/build-style/style.css +214 -24
- package/build-types/utils/dom.d.ts.map +1 -1
- package/package.json +28 -27
- 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/block-html.js +8 -4
- package/src/components/block-list/block.js +5 -1
- 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 +27 -6
- 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 +3 -0
- package/src/components/block-lock/menu-item.js +59 -0
- package/src/components/block-lock/modal.js +170 -0
- package/src/components/block-lock/style.scss +70 -0
- package/src/components/block-lock/toolbar.js +68 -0
- 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 +109 -9
- package/src/components/block-settings-menu-controls/index.js +33 -12
- 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/README.md +6 -1
- package/src/components/block-title/index.js +2 -2
- package/src/components/block-title/test/index.js +43 -1
- package/src/components/block-title/use-block-display-title.js +10 -7
- 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 +24 -2
- package/src/components/block-toolbar/style.scss +10 -0
- package/src/components/block-tools/index.js +0 -19
- package/src/components/block-tools/style.scss +27 -0
- 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/border-radius-control/index.js +0 -1
- package/src/components/border-radius-control/test/utils.js +4 -0
- package/src/components/border-radius-control/utils.js +2 -1
- package/src/components/button-block-appender/style.scss +5 -1
- package/src/components/color-palette/test/__snapshots__/control.js.snap +70 -4
- package/src/components/colors-gradients/control.js +1 -1
- package/src/components/colors-gradients/style.scss +6 -0
- 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/date-format-picker/README.md +58 -0
- package/src/components/date-format-picker/index.js +161 -0
- package/src/components/date-format-picker/style.scss +31 -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 +3 -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 +11 -6
- package/src/components/link-control/README.md +1 -1
- package/src/components/list-view/block-select-button.js +21 -30
- package/src/components/list-view/block.js +55 -13
- package/src/components/list-view/branch.js +37 -15
- package/src/components/list-view/index.js +6 -0
- package/src/components/list-view/style.scss +56 -14
- package/src/components/list-view/use-block-selection.js +15 -2
- 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 +25 -2
- package/src/components/rich-text/index.native.js +24 -8
- 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/url-popover/image-url-input-ui.js +16 -29
- 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/anchor.js +8 -6
- 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 +91 -12
- package/src/hooks/layout.js +11 -1
- package/src/hooks/style.js +40 -4
- package/src/hooks/test/gap.js +66 -0
- 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 +93 -6
- package/src/layouts/flow.js +28 -12
- package/src/store/actions.js +349 -32
- package/src/store/defaults.js +7 -1
- package/src/store/reducer.js +25 -10
- package/src/store/selectors.js +207 -25
- package/src/store/test/selectors.js +305 -5
- package/src/style.scss +2 -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
|
@@ -6,12 +6,17 @@ import { castArray, flow, noop } from 'lodash';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import { getBlockType, serialize } from '@wordpress/blocks';
|
|
10
10
|
import { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';
|
|
11
|
-
import { useSelect } from '@wordpress/data';
|
|
11
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
12
12
|
import { moreVertical } from '@wordpress/icons';
|
|
13
|
-
import {
|
|
14
|
-
|
|
13
|
+
import {
|
|
14
|
+
Children,
|
|
15
|
+
cloneElement,
|
|
16
|
+
useCallback,
|
|
17
|
+
useRef,
|
|
18
|
+
} from '@wordpress/element';
|
|
19
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
15
20
|
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
|
16
21
|
import { useCopyToClipboard } from '@wordpress/compose';
|
|
17
22
|
|
|
@@ -19,12 +24,14 @@ import { useCopyToClipboard } from '@wordpress/compose';
|
|
|
19
24
|
* Internal dependencies
|
|
20
25
|
*/
|
|
21
26
|
import BlockActions from '../block-actions';
|
|
27
|
+
import BlockIcon from '../block-icon';
|
|
22
28
|
import BlockModeToggle from './block-mode-toggle';
|
|
23
29
|
import BlockHTMLConvertButton from './block-html-convert-button';
|
|
24
30
|
import __unstableBlockSettingsMenuFirstItem from './block-settings-menu-first-item';
|
|
25
31
|
import BlockSettingsMenuControls from '../block-settings-menu-controls';
|
|
26
32
|
import { store as blockEditorStore } from '../../store';
|
|
27
33
|
import useBlockDisplayTitle from '../block-title/use-block-display-title';
|
|
34
|
+
import { useShowMoversGestures } from '../block-toolbar/utils';
|
|
28
35
|
|
|
29
36
|
const POPOVER_PROPS = {
|
|
30
37
|
className: 'block-editor-block-settings-menu__popover',
|
|
@@ -46,11 +53,40 @@ export function BlockSettingsDropdown( {
|
|
|
46
53
|
const blockClientIds = castArray( clientIds );
|
|
47
54
|
const count = blockClientIds.length;
|
|
48
55
|
const firstBlockClientId = blockClientIds[ 0 ];
|
|
49
|
-
const {
|
|
56
|
+
const {
|
|
57
|
+
firstParentClientId,
|
|
58
|
+
hasReducedUI,
|
|
59
|
+
onlyBlock,
|
|
60
|
+
parentBlockType,
|
|
61
|
+
previousBlockClientId,
|
|
62
|
+
nextBlockClientId,
|
|
63
|
+
selectedBlockClientIds,
|
|
64
|
+
} = useSelect(
|
|
50
65
|
( select ) => {
|
|
51
|
-
const {
|
|
66
|
+
const {
|
|
67
|
+
getBlockCount,
|
|
68
|
+
getBlockName,
|
|
69
|
+
getBlockParents,
|
|
70
|
+
getPreviousBlockClientId,
|
|
71
|
+
getNextBlockClientId,
|
|
72
|
+
getSelectedBlockClientIds,
|
|
73
|
+
getSettings,
|
|
74
|
+
} = select( blockEditorStore );
|
|
75
|
+
|
|
76
|
+
const parents = getBlockParents( firstBlockClientId );
|
|
77
|
+
const _firstParentClientId = parents[ parents.length - 1 ];
|
|
78
|
+
const parentBlockName = getBlockName( _firstParentClientId );
|
|
79
|
+
|
|
52
80
|
return {
|
|
81
|
+
firstParentClientId: _firstParentClientId,
|
|
82
|
+
hasReducedUI: getSettings().hasReducedUI,
|
|
53
83
|
onlyBlock: 1 === getBlockCount(),
|
|
84
|
+
parentBlockType: getBlockType( parentBlockName ),
|
|
85
|
+
previousBlockClientId: getPreviousBlockClientId(
|
|
86
|
+
firstBlockClientId
|
|
87
|
+
),
|
|
88
|
+
nextBlockClientId: getNextBlockClientId( firstBlockClientId ),
|
|
89
|
+
selectedBlockClientIds: getSelectedBlockClientIds(),
|
|
54
90
|
};
|
|
55
91
|
},
|
|
56
92
|
[ firstBlockClientId ]
|
|
@@ -72,7 +108,11 @@ export function BlockSettingsDropdown( {
|
|
|
72
108
|
};
|
|
73
109
|
}, [] );
|
|
74
110
|
|
|
75
|
-
const
|
|
111
|
+
const { selectBlock, toggleBlockHighlight } = useDispatch(
|
|
112
|
+
blockEditorStore
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
const updateSelectionAfterDuplicate = useCallback(
|
|
76
116
|
__experimentalSelectBlock
|
|
77
117
|
? async ( clientIdsPromise ) => {
|
|
78
118
|
const ids = await clientIdsPromise;
|
|
@@ -86,6 +126,33 @@ export function BlockSettingsDropdown( {
|
|
|
86
126
|
|
|
87
127
|
const blockTitle = useBlockDisplayTitle( firstBlockClientId, 25 );
|
|
88
128
|
|
|
129
|
+
const updateSelectionAfterRemove = useCallback(
|
|
130
|
+
__experimentalSelectBlock
|
|
131
|
+
? () => {
|
|
132
|
+
const blockToSelect =
|
|
133
|
+
previousBlockClientId || nextBlockClientId;
|
|
134
|
+
|
|
135
|
+
if (
|
|
136
|
+
blockToSelect &&
|
|
137
|
+
// From the block options dropdown, it's possible to remove a block that is not selected,
|
|
138
|
+
// in this case, it's not necessary to update the selection since the selected block wasn't removed.
|
|
139
|
+
selectedBlockClientIds.includes( firstBlockClientId ) &&
|
|
140
|
+
// Don't update selection when next/prev block also is in the selection ( and gets removed ),
|
|
141
|
+
// In case someone selects all blocks and removes them at once.
|
|
142
|
+
! selectedBlockClientIds.includes( blockToSelect )
|
|
143
|
+
) {
|
|
144
|
+
__experimentalSelectBlock( blockToSelect );
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
: noop,
|
|
148
|
+
[
|
|
149
|
+
__experimentalSelectBlock,
|
|
150
|
+
previousBlockClientId,
|
|
151
|
+
nextBlockClientId,
|
|
152
|
+
selectedBlockClientIds,
|
|
153
|
+
]
|
|
154
|
+
);
|
|
155
|
+
|
|
89
156
|
const label = sprintf(
|
|
90
157
|
/* translators: %s: block name */
|
|
91
158
|
__( 'Remove %s' ),
|
|
@@ -93,6 +160,19 @@ export function BlockSettingsDropdown( {
|
|
|
93
160
|
);
|
|
94
161
|
const removeBlockLabel = count === 1 ? label : __( 'Remove blocks' );
|
|
95
162
|
|
|
163
|
+
// Allows highlighting the parent block outline when focusing or hovering
|
|
164
|
+
// the parent block selector within the child.
|
|
165
|
+
const selectParentButtonRef = useRef();
|
|
166
|
+
const { gestures: showParentOutlineGestures } = useShowMoversGestures( {
|
|
167
|
+
ref: selectParentButtonRef,
|
|
168
|
+
onChange( isFocused ) {
|
|
169
|
+
if ( isFocused && hasReducedUI ) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
toggleBlockHighlight( firstParentClientId, isFocused );
|
|
173
|
+
},
|
|
174
|
+
} );
|
|
175
|
+
|
|
96
176
|
return (
|
|
97
177
|
<BlockActions
|
|
98
178
|
clientIds={ clientIds }
|
|
@@ -125,6 +205,26 @@ export function BlockSettingsDropdown( {
|
|
|
125
205
|
<__unstableBlockSettingsMenuFirstItem.Slot
|
|
126
206
|
fillProps={ { onClose } }
|
|
127
207
|
/>
|
|
208
|
+
{ firstParentClientId !== undefined && (
|
|
209
|
+
<MenuItem
|
|
210
|
+
{ ...showParentOutlineGestures }
|
|
211
|
+
ref={ selectParentButtonRef }
|
|
212
|
+
icon={
|
|
213
|
+
<BlockIcon
|
|
214
|
+
icon={ parentBlockType.icon }
|
|
215
|
+
/>
|
|
216
|
+
}
|
|
217
|
+
onClick={ () =>
|
|
218
|
+
selectBlock( firstParentClientId )
|
|
219
|
+
}
|
|
220
|
+
>
|
|
221
|
+
{ sprintf(
|
|
222
|
+
/* translators: %s: Name of the block's parent. */
|
|
223
|
+
__( 'Select parent block (%s)' ),
|
|
224
|
+
parentBlockType.title
|
|
225
|
+
) }
|
|
226
|
+
</MenuItem>
|
|
227
|
+
) }
|
|
128
228
|
{ count === 1 && (
|
|
129
229
|
<BlockHTMLConvertButton
|
|
130
230
|
clientId={ firstBlockClientId }
|
|
@@ -139,7 +239,7 @@ export function BlockSettingsDropdown( {
|
|
|
139
239
|
onClick={ flow(
|
|
140
240
|
onClose,
|
|
141
241
|
onDuplicate,
|
|
142
|
-
|
|
242
|
+
updateSelectionAfterDuplicate
|
|
143
243
|
) }
|
|
144
244
|
shortcut={ shortcuts.duplicate }
|
|
145
245
|
>
|
|
@@ -197,7 +297,7 @@ export function BlockSettingsDropdown( {
|
|
|
197
297
|
onClick={ flow(
|
|
198
298
|
onClose,
|
|
199
299
|
onRemove,
|
|
200
|
-
|
|
300
|
+
updateSelectionAfterRemove
|
|
201
301
|
) }
|
|
202
302
|
shortcut={ shortcuts.remove }
|
|
203
303
|
>
|
|
@@ -20,16 +20,19 @@ import {
|
|
|
20
20
|
useConvertToGroupButtonProps,
|
|
21
21
|
ConvertToGroupButton,
|
|
22
22
|
} from '../convert-to-group-buttons';
|
|
23
|
+
import { BlockLockMenuItem } from '../block-lock';
|
|
23
24
|
import { store as blockEditorStore } from '../../store';
|
|
24
25
|
|
|
25
26
|
const { Fill, Slot } = createSlotFill( 'BlockSettingsMenuControls' );
|
|
26
27
|
|
|
27
28
|
const BlockSettingsMenuControlsSlot = ( { fillProps, clientIds = null } ) => {
|
|
28
|
-
const { selectedBlocks, selectedClientIds } = useSelect(
|
|
29
|
+
const { selectedBlocks, selectedClientIds, canRemove } = useSelect(
|
|
29
30
|
( select ) => {
|
|
30
|
-
const {
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
const {
|
|
32
|
+
getBlocksByClientId,
|
|
33
|
+
getSelectedBlockClientIds,
|
|
34
|
+
canRemoveBlocks,
|
|
35
|
+
} = select( blockEditorStore );
|
|
33
36
|
const ids =
|
|
34
37
|
clientIds !== null ? clientIds : getSelectedBlockClientIds();
|
|
35
38
|
return {
|
|
@@ -38,30 +41,48 @@ const BlockSettingsMenuControlsSlot = ( { fillProps, clientIds = null } ) => {
|
|
|
38
41
|
( block ) => block.name
|
|
39
42
|
),
|
|
40
43
|
selectedClientIds: ids,
|
|
44
|
+
canRemove: canRemoveBlocks( ids ),
|
|
41
45
|
};
|
|
42
46
|
},
|
|
43
47
|
[ clientIds ]
|
|
44
48
|
);
|
|
45
49
|
|
|
50
|
+
const showLockButton = selectedClientIds.length === 1;
|
|
51
|
+
|
|
46
52
|
// Check if current selection of blocks is Groupable or Ungroupable
|
|
47
53
|
// and pass this props down to ConvertToGroupButton.
|
|
48
54
|
const convertToGroupButtonProps = useConvertToGroupButtonProps();
|
|
49
55
|
const { isGroupable, isUngroupable } = convertToGroupButtonProps;
|
|
50
|
-
const showConvertToGroupButton =
|
|
56
|
+
const showConvertToGroupButton =
|
|
57
|
+
( isGroupable || isUngroupable ) && canRemove;
|
|
58
|
+
|
|
51
59
|
return (
|
|
52
60
|
<Slot fillProps={ { ...fillProps, selectedBlocks, selectedClientIds } }>
|
|
53
61
|
{ ( fills ) => {
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
62
|
+
if (
|
|
63
|
+
! fills?.length > 0 &&
|
|
64
|
+
! showConvertToGroupButton &&
|
|
65
|
+
! showLockButton
|
|
66
|
+
) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<MenuGroup>
|
|
72
|
+
{ showLockButton && (
|
|
73
|
+
<BlockLockMenuItem
|
|
74
|
+
clientId={ selectedClientIds[ 0 ] }
|
|
75
|
+
/>
|
|
76
|
+
) }
|
|
77
|
+
{ fills }
|
|
78
|
+
{ showConvertToGroupButton && (
|
|
58
79
|
<ConvertToGroupButton
|
|
59
80
|
{ ...convertToGroupButtonProps }
|
|
60
81
|
onClose={ fillProps?.onClose }
|
|
61
82
|
/>
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
83
|
+
) }
|
|
84
|
+
</MenuGroup>
|
|
85
|
+
);
|
|
65
86
|
} }
|
|
66
87
|
</Slot>
|
|
67
88
|
);
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
isTemplatePart,
|
|
21
21
|
} from '@wordpress/blocks';
|
|
22
22
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
23
|
-
import {
|
|
23
|
+
import { copy } from '@wordpress/icons';
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Internal dependencies
|
|
@@ -69,7 +69,7 @@ export const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => {
|
|
|
69
69
|
// appropriate icon to communicate the non-uniformity.
|
|
70
70
|
_icon = isSelectionOfSameType
|
|
71
71
|
? getBlockType( firstBlockName )?.icon
|
|
72
|
-
:
|
|
72
|
+
: copy;
|
|
73
73
|
}
|
|
74
74
|
return {
|
|
75
75
|
possibleBlockTransformations: getBlockTransformItems(
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
.block-editor-block-switcher {
|
|
2
2
|
position: relative;
|
|
3
|
+
padding: 0 ($grid-unit-15 * 0.5);
|
|
4
|
+
|
|
5
|
+
// @todo: override toolbar group inherited paddings from components/block-tools/style.scss.
|
|
6
|
+
// This is best fixed by making the mover control area a proper single toolbar group.
|
|
7
|
+
// It needs specificity due to style inherited from .components-accessible-toolbar .components-button.has-icon.has-icon.
|
|
8
|
+
.components-button.components-dropdown-menu__toggle.has-icon.has-icon {
|
|
9
|
+
min-width: $button-size;
|
|
10
|
+
}
|
|
3
11
|
}
|
|
4
12
|
|
|
5
13
|
// Show an indicator triangle.
|
|
@@ -8,7 +16,6 @@
|
|
|
8
16
|
position: relative;
|
|
9
17
|
}
|
|
10
18
|
|
|
11
|
-
|
|
12
19
|
.components-button.block-editor-block-switcher__toggle,
|
|
13
20
|
.components-button.block-editor-block-switcher__no-switcher-icon {
|
|
14
21
|
margin: 0;
|
|
@@ -10,7 +10,7 @@ import { useSelect } from '@wordpress/data';
|
|
|
10
10
|
import { registerBlockType, unregisterBlockType } from '@wordpress/blocks';
|
|
11
11
|
import { DOWN } from '@wordpress/keycodes';
|
|
12
12
|
import { Button } from '@wordpress/components';
|
|
13
|
-
import {
|
|
13
|
+
import { copy } from '@wordpress/icons';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Internal dependencies
|
|
@@ -131,7 +131,7 @@ describe( 'BlockSwitcherDropdownMenu', () => {
|
|
|
131
131
|
test( 'should render disabled block switcher with multi block of different types when no transforms', () => {
|
|
132
132
|
useSelect.mockImplementation( () => ( {
|
|
133
133
|
possibleBlockTransformations: [],
|
|
134
|
-
icon:
|
|
134
|
+
icon: copy,
|
|
135
135
|
} ) );
|
|
136
136
|
const wrapper = shallow(
|
|
137
137
|
<BlockSwitcherDropdownMenu
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# Block Title
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Block Title component renders a block's configured title as a string.
|
|
4
|
+
|
|
5
|
+
It prioritizes contextual titles such as block variation and reusable block labels when returning a value. If none is found, it will return the display title specified in the block's metadata.
|
|
6
|
+
|
|
7
|
+
The component will be empty if a title cannot be determined.
|
|
8
|
+
|
|
4
9
|
|
|
5
10
|
## Usage
|
|
6
11
|
|
|
@@ -14,8 +14,8 @@ import useBlockDisplayTitle from './use-block-display-title';
|
|
|
14
14
|
* <BlockTitle clientId="afd1cb17-2c08-4e7a-91be-007ba7ddc3a1" maximumLength={ 17 }/>
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
|
-
* @param {Object}
|
|
18
|
-
* @param {string}
|
|
17
|
+
* @param {Object} props
|
|
18
|
+
* @param {string} props.clientId Client ID of block.
|
|
19
19
|
* @param {number|undefined} props.maximumLength The maximum length that the block title string may be before truncated.
|
|
20
20
|
*
|
|
21
21
|
* @return {JSX.Element} Block title.
|
|
@@ -26,6 +26,9 @@ jest.mock( '@wordpress/blocks', () => {
|
|
|
26
26
|
case 'name-with-label':
|
|
27
27
|
return { title: 'Block With Label' };
|
|
28
28
|
|
|
29
|
+
case 'name-with-custom-label':
|
|
30
|
+
return { title: 'Block With Custom Label' };
|
|
31
|
+
|
|
29
32
|
case 'name-with-long-label':
|
|
30
33
|
return { title: 'Block With Long Label' };
|
|
31
34
|
}
|
|
@@ -38,6 +41,9 @@ jest.mock( '@wordpress/blocks', () => {
|
|
|
38
41
|
case 'Block With Long Label':
|
|
39
42
|
return 'This is a longer label than typical for blocks to have.';
|
|
40
43
|
|
|
44
|
+
case 'Block With Custom Label':
|
|
45
|
+
return 'A Custom Label like a Block Variation Label';
|
|
46
|
+
|
|
41
47
|
default:
|
|
42
48
|
return title;
|
|
43
49
|
}
|
|
@@ -61,7 +67,7 @@ jest.mock( '@wordpress/data/src/components/use-select', () => {
|
|
|
61
67
|
} );
|
|
62
68
|
|
|
63
69
|
describe( 'BlockTitle', () => {
|
|
64
|
-
it( 'renders nothing if name is
|
|
70
|
+
it( 'renders nothing if name is falsey', () => {
|
|
65
71
|
useSelect.mockImplementation( () => ( {
|
|
66
72
|
name: null,
|
|
67
73
|
attributes: null,
|
|
@@ -106,6 +112,42 @@ describe( 'BlockTitle', () => {
|
|
|
106
112
|
expect( wrapper.text() ).toBe( 'Test Label' );
|
|
107
113
|
} );
|
|
108
114
|
|
|
115
|
+
it( 'should prioritize reusable block title over title', () => {
|
|
116
|
+
useSelect.mockImplementation( () => ( {
|
|
117
|
+
name: 'name-with-label',
|
|
118
|
+
reusableBlockTitle: 'Reuse me!',
|
|
119
|
+
attributes: null,
|
|
120
|
+
} ) );
|
|
121
|
+
|
|
122
|
+
const wrapper = shallow( <BlockTitle clientId="id-name-with-label" /> );
|
|
123
|
+
|
|
124
|
+
expect( wrapper.text() ).toBe( 'Reuse me!' );
|
|
125
|
+
} );
|
|
126
|
+
|
|
127
|
+
it( 'should prioritize block label over title', () => {
|
|
128
|
+
useSelect.mockImplementation( () => ( {
|
|
129
|
+
name: 'name-with-custom-label',
|
|
130
|
+
attributes: null,
|
|
131
|
+
} ) );
|
|
132
|
+
|
|
133
|
+
const wrapper = shallow( <BlockTitle clientId="id-name-with-label" /> );
|
|
134
|
+
|
|
135
|
+
expect( wrapper.text() ).toBe(
|
|
136
|
+
'A Custom Label like a Block Variation Label'
|
|
137
|
+
);
|
|
138
|
+
} );
|
|
139
|
+
|
|
140
|
+
it( 'should default to block information title if no reusable title or block name is available', () => {
|
|
141
|
+
useSelect.mockImplementation( () => ( {
|
|
142
|
+
name: 'some-rando-name',
|
|
143
|
+
attributes: null,
|
|
144
|
+
} ) );
|
|
145
|
+
|
|
146
|
+
const wrapper = shallow( <BlockTitle clientId="id-name-with-label" /> );
|
|
147
|
+
|
|
148
|
+
expect( wrapper.text() ).toBe( 'Block With Label' );
|
|
149
|
+
} );
|
|
150
|
+
|
|
109
151
|
it( 'truncates the label with custom truncate length', () => {
|
|
110
152
|
useSelect.mockImplementation( () => ( {
|
|
111
153
|
name: 'name-with-long-label',
|
|
@@ -29,7 +29,7 @@ import { store as blockEditorStore } from '../../store';
|
|
|
29
29
|
* useBlockDisplayTitle( 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1', 17 );
|
|
30
30
|
* ```
|
|
31
31
|
*
|
|
32
|
-
* @param {string}
|
|
32
|
+
* @param {string} clientId Client ID of block.
|
|
33
33
|
* @param {number|undefined} maximumLength The maximum length that the block title string may be before truncated.
|
|
34
34
|
* @return {?string} Block title.
|
|
35
35
|
*/
|
|
@@ -70,14 +70,17 @@ export default function useBlockDisplayTitle( clientId, maximumLength ) {
|
|
|
70
70
|
const blockLabel = blockType
|
|
71
71
|
? getBlockLabel( blockType, attributes )
|
|
72
72
|
: null;
|
|
73
|
+
|
|
73
74
|
const label = reusableBlockTitle || blockLabel;
|
|
74
75
|
// Label will fallback to the title if no label is defined for the current
|
|
75
|
-
// label context. If the label is defined we prioritize it over
|
|
76
|
+
// label context. If the label is defined we prioritize it over a
|
|
76
77
|
// possible block variation title match.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
const blockTitle =
|
|
79
|
+
label && label !== blockType.title ? label : blockInformation.title;
|
|
80
|
+
|
|
81
|
+
if ( maximumLength && maximumLength > 0 ) {
|
|
82
|
+
return truncate( blockTitle, { length: maximumLength } );
|
|
81
83
|
}
|
|
82
|
-
|
|
84
|
+
|
|
85
|
+
return blockTitle;
|
|
83
86
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { createSlotFill } from '@wordpress/components';
|
|
5
|
+
|
|
6
|
+
const { Fill: __unstableBlockToolbarLastItem, Slot } = createSlotFill(
|
|
7
|
+
'__unstableBlockToolbarLastItem'
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
__unstableBlockToolbarLastItem.Slot = Slot;
|
|
11
|
+
|
|
12
|
+
export default __unstableBlockToolbarLastItem;
|
|
@@ -19,11 +19,15 @@ import BlockMover from '../block-mover';
|
|
|
19
19
|
import BlockParentSelector from '../block-parent-selector';
|
|
20
20
|
import BlockSwitcher from '../block-switcher';
|
|
21
21
|
import BlockControls from '../block-controls';
|
|
22
|
+
import __unstableBlockToolbarLastItem from './block-toolbar-last-item';
|
|
22
23
|
import BlockSettingsMenu from '../block-settings-menu';
|
|
24
|
+
import { BlockLockToolbar } from '../block-lock';
|
|
25
|
+
import { BlockGroupToolbar } from '../convert-to-group-buttons';
|
|
23
26
|
import { useShowMoversGestures } from './utils';
|
|
24
27
|
import { store as blockEditorStore } from '../../store';
|
|
28
|
+
import __unstableBlockNameContext from './block-name-context';
|
|
25
29
|
|
|
26
|
-
|
|
30
|
+
const BlockToolbar = ( { hideDragHandle } ) => {
|
|
27
31
|
const {
|
|
28
32
|
blockClientIds,
|
|
29
33
|
blockClientId,
|
|
@@ -114,6 +118,11 @@ export default function BlockToolbar( { hideDragHandle } ) {
|
|
|
114
118
|
{ ( shouldShowVisualToolbar || isMultiToolbar ) && (
|
|
115
119
|
<ToolbarGroup className="block-editor-block-toolbar__block-controls">
|
|
116
120
|
<BlockSwitcher clientIds={ blockClientIds } />
|
|
121
|
+
{ ! isMultiToolbar && (
|
|
122
|
+
<BlockLockToolbar
|
|
123
|
+
clientId={ blockClientIds[ 0 ] }
|
|
124
|
+
/>
|
|
125
|
+
) }
|
|
117
126
|
<BlockMover
|
|
118
127
|
clientIds={ blockClientIds }
|
|
119
128
|
hideDragHandle={ hideDragHandle || hasReducedUI }
|
|
@@ -121,6 +130,9 @@ export default function BlockToolbar( { hideDragHandle } ) {
|
|
|
121
130
|
</ToolbarGroup>
|
|
122
131
|
) }
|
|
123
132
|
</div>
|
|
133
|
+
{ shouldShowVisualToolbar && isMultiToolbar && (
|
|
134
|
+
<BlockGroupToolbar />
|
|
135
|
+
) }
|
|
124
136
|
{ shouldShowVisualToolbar && (
|
|
125
137
|
<>
|
|
126
138
|
<BlockControls.Slot
|
|
@@ -140,9 +152,19 @@ export default function BlockToolbar( { hideDragHandle } ) {
|
|
|
140
152
|
group="other"
|
|
141
153
|
className="block-editor-block-toolbar__slot"
|
|
142
154
|
/>
|
|
155
|
+
<__unstableBlockNameContext.Provider
|
|
156
|
+
value={ blockType?.name }
|
|
157
|
+
>
|
|
158
|
+
<__unstableBlockToolbarLastItem.Slot />
|
|
159
|
+
</__unstableBlockNameContext.Provider>
|
|
143
160
|
</>
|
|
144
161
|
) }
|
|
145
162
|
<BlockSettingsMenu clientIds={ blockClientIds } />
|
|
146
163
|
</div>
|
|
147
164
|
);
|
|
148
|
-
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-toolbar/README.md
|
|
169
|
+
*/
|
|
170
|
+
export default BlockToolbar;
|
|
@@ -91,6 +91,16 @@
|
|
|
91
91
|
.block-editor-block-mover {
|
|
92
92
|
margin-left: -$grid-unit-15 * 0.5;
|
|
93
93
|
}
|
|
94
|
+
|
|
95
|
+
.block-editor-block-lock-toolbar {
|
|
96
|
+
margin-left: -$grid-unit-15 * 0.5 !important;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// @todo: override toolbar group inherited paddings from components/block-tools/style.scss.
|
|
100
|
+
// This is best fixed by making the mover control area a proper single toolbar group.
|
|
101
|
+
.components-toolbar-group {
|
|
102
|
+
padding: 0;
|
|
103
|
+
}
|
|
94
104
|
}
|
|
95
105
|
|
|
96
106
|
.block-editor-block-toolbar,
|
|
@@ -92,25 +92,6 @@ export default function BlockTools( {
|
|
|
92
92
|
event.preventDefault();
|
|
93
93
|
insertBeforeBlock( first( clientIds ) );
|
|
94
94
|
}
|
|
95
|
-
} else if (
|
|
96
|
-
isMatch( 'core/block-editor/delete-multi-selection', event )
|
|
97
|
-
) {
|
|
98
|
-
/**
|
|
99
|
-
* Check if the target element is a text area, input or
|
|
100
|
-
* event.defaultPrevented and return early. In all these
|
|
101
|
-
* cases backspace could be handled elsewhere.
|
|
102
|
-
*/
|
|
103
|
-
if (
|
|
104
|
-
[ 'INPUT', 'TEXTAREA' ].includes( event.target.nodeName ) ||
|
|
105
|
-
event.defaultPrevented
|
|
106
|
-
) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
const clientIds = getSelectedBlockClientIds();
|
|
110
|
-
if ( clientIds.length > 1 ) {
|
|
111
|
-
event.preventDefault();
|
|
112
|
-
removeBlocks( clientIds );
|
|
113
|
-
}
|
|
114
95
|
} else if ( isMatch( 'core/block-editor/unselect', event ) ) {
|
|
115
96
|
const clientIds = getSelectedBlockClientIds();
|
|
116
97
|
if ( clientIds.length > 1 ) {
|
|
@@ -307,3 +307,30 @@
|
|
|
307
307
|
.is-dragging-components-draggable .components-tooltip {
|
|
308
308
|
display: none;
|
|
309
309
|
}
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
// Size multiple sequential buttons to be optically balanced.
|
|
313
|
+
// Icons are 36px, as set by a 24px icon and 12px padding.
|
|
314
|
+
.block-editor-block-toolbar > .components-toolbar > .block-editor-block-toolbar__slot, // When a plugin adds to a slot, the segment has a `components-toolbar` class.
|
|
315
|
+
.block-editor-block-toolbar > .block-editor-block-toolbar__slot > .components-toolbar, // The nesting order is sometimes reversed.
|
|
316
|
+
.block-editor-block-toolbar > .block-editor-block-toolbar__slot > .components-dropdown, // Targets unique markup for the "Replace" button.
|
|
317
|
+
.block-editor-block-toolbar .components-toolbar-group {
|
|
318
|
+
padding-left: $grid-unit-15 * 0.5; // 6px.
|
|
319
|
+
padding-right: $grid-unit-15 * 0.5;
|
|
320
|
+
|
|
321
|
+
.components-button,
|
|
322
|
+
.components-button.has-icon.has-icon {
|
|
323
|
+
min-width: $block-toolbar-height - $grid-unit-15;
|
|
324
|
+
padding-left: $grid-unit-15 * 0.5; // 6px.
|
|
325
|
+
padding-right: $grid-unit-15 * 0.5;
|
|
326
|
+
|
|
327
|
+
svg {
|
|
328
|
+
min-width: $button-size-small; // This is the optimal icon size, and we size the whole button after this.
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
&::before {
|
|
332
|
+
left: 2px;
|
|
333
|
+
right: 2px;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|