@wordpress/block-editor 9.6.0 → 9.8.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/build/components/block-alignment-control/use-available-alignments.js +1 -1
- package/build/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build/components/block-edit-visually-button/index.js +46 -0
- package/build/components/block-edit-visually-button/index.js.map +1 -0
- package/build/components/block-list/block.js +12 -2
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/index.native.js +1 -1
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-popover/inbetween.js +5 -3
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +10 -4
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-settings-menu/index.js +2 -6
- package/build/components/block-settings-menu/index.js.map +1 -1
- package/build/components/block-styles/index.js +3 -6
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-switcher/index.js +10 -16
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-toolbar/index.js +5 -1
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +10 -2
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js +126 -0
- package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -0
- package/build/components/block-types-list/index.js +1 -1
- package/build/components/block-types-list/index.js.map +1 -1
- package/build/components/border-radius-control/all-input-control.js +31 -3
- package/build/components/border-radius-control/all-input-control.js.map +1 -1
- package/build/components/border-radius-control/index.js +23 -7
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/border-radius-control/input-controls.js +21 -6
- package/build/components/border-radius-control/input-controls.js.map +1 -1
- package/build/components/border-radius-control/utils.js +13 -16
- package/build/components/border-radius-control/utils.js.map +1 -1
- package/build/components/colors/utils.js +6 -2
- package/build/components/colors/utils.js.map +1 -1
- package/build/components/colors/with-colors.js +17 -4
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/colors-gradients/control.js +7 -4
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +5 -2
- package/build/components/colors-gradients/dropdown.js.map +1 -1
- package/build/components/copy-handler/index.js +6 -0
- package/build/components/copy-handler/index.js.map +1 -1
- package/build/components/date-format-picker/index.js +2 -7
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/duotone/components.js +5 -5
- package/build/components/duotone/components.js.map +1 -1
- package/build/components/font-appearance-control/index.js +10 -4
- package/build/components/font-appearance-control/index.js.map +1 -1
- package/build/components/font-family/index.js +1 -1
- package/build/components/font-family/index.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +17 -4
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/image-size-control/index.js +3 -1
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/index.js +22 -6
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +11 -4
- package/build/components/index.native.js.map +1 -1
- package/build/components/inserter/index.native.js +8 -3
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/search-items.js +22 -4
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/inserter-list-item/index.js +2 -19
- package/build/components/inserter-list-item/index.js.map +1 -1
- package/build/components/letter-spacing-control/index.js +6 -3
- package/build/components/letter-spacing-control/index.js.map +1 -1
- package/build/components/line-height-control/index.js +6 -3
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/link-control/is-url-like.js +1 -7
- package/build/components/link-control/is-url-like.js.map +1 -1
- package/build/components/link-control/link-preview.js +0 -1
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/link-control/use-search-handler.js +1 -7
- package/build/components/link-control/use-search-handler.js.map +1 -1
- package/build/components/list-view/block-select-button.js +5 -2
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/expander.js +3 -1
- package/build/components/list-view/expander.js.map +1 -1
- package/build/components/list-view/use-block-selection.js +1 -7
- package/build/components/list-view/use-block-selection.js.map +1 -1
- package/build/components/media-upload/index.native.js +8 -3
- package/build/components/media-upload/index.native.js.map +1 -1
- package/build/components/preview-options/index.js +2 -2
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/{use-no-recursive-renders → recursion-provider}/index.js +40 -18
- package/build/components/recursion-provider/index.js.map +1 -0
- package/build/components/rich-text/index.js +6 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +3 -1
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/use-before-input-rules.js +110 -0
- package/build/components/rich-text/use-before-input-rules.js.map +1 -0
- package/build/components/rich-text/use-enter.js +0 -4
- package/build/components/rich-text/use-enter.js.map +1 -1
- package/build/components/rich-text/use-format-types.js +8 -11
- package/build/components/rich-text/use-format-types.js.map +1 -1
- package/build/components/spacing-sizes-control/all-input-control.js +53 -0
- package/build/components/spacing-sizes-control/all-input-control.js.map +1 -0
- package/build/components/spacing-sizes-control/axial-input-controls.js +69 -0
- package/build/components/spacing-sizes-control/axial-input-controls.js.map +1 -0
- package/build/components/spacing-sizes-control/index.js +100 -0
- package/build/components/spacing-sizes-control/index.js.map +1 -0
- package/build/components/spacing-sizes-control/input-controls.js +52 -0
- package/build/components/spacing-sizes-control/input-controls.js.map +1 -0
- package/build/components/spacing-sizes-control/linked-button.js +38 -0
- package/build/components/spacing-sizes-control/linked-button.js.map +1 -0
- package/build/components/spacing-sizes-control/spacing-input-control.js +208 -0
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -0
- package/build/components/spacing-sizes-control/utils.js +202 -0
- package/build/components/spacing-sizes-control/utils.js.map +1 -0
- package/build/components/text-decoration-control/index.js +3 -1
- package/build/components/text-decoration-control/index.js.map +1 -1
- package/build/components/text-transform-control/index.js +3 -1
- package/build/components/text-transform-control/index.js.map +1 -1
- package/build/components/url-input/index.js +1 -1
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/url-popover/image-url-input-ui.js +4 -1
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build/components/writing-flow/use-arrow-nav.js +4 -25
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/components/writing-flow/use-drag-selection.js +9 -2
- package/build/components/writing-flow/use-drag-selection.js.map +1 -1
- package/build/components/writing-flow/use-multi-selection.js +4 -2
- package/build/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build/components/writing-flow/use-select-all.js +3 -1
- package/build/components/writing-flow/use-select-all.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js +10 -2
- package/build/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build/hooks/border-radius.js +2 -7
- package/build/hooks/border-radius.js.map +1 -1
- package/build/hooks/border.js +2 -2
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +4 -1
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/dimensions.js +15 -0
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +4 -4
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/gap.js +6 -4
- package/build/hooks/gap.js.map +1 -1
- package/build/hooks/generated-class-name.js +1 -7
- package/build/hooks/generated-class-name.js.map +1 -1
- package/build/hooks/layout.js +29 -14
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/margin.js +28 -12
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +19 -8
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/style.js +4 -50
- package/build/hooks/style.js.map +1 -1
- package/build/layouts/constrained.js +215 -0
- package/build/layouts/constrained.js.map +1 -0
- package/build/layouts/flex.js +1 -1
- package/build/layouts/flex.js.map +1 -1
- package/build/layouts/flow.js +7 -151
- package/build/layouts/flow.js.map +1 -1
- package/build/layouts/index.js +3 -1
- package/build/layouts/index.js.map +1 -1
- package/build/layouts/utils.js +43 -0
- package/build/layouts/utils.js.map +1 -1
- package/build/store/actions.js +25 -3
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +4 -6
- package/build/store/selectors.js.map +1 -1
- package/build/utils/block-variation-transforms.js +15 -9
- package/build/utils/block-variation-transforms.js.map +1 -1
- package/build/utils/pasting.js +9 -1
- package/build/utils/pasting.js.map +1 -1
- package/build-module/components/block-alignment-control/use-available-alignments.js +1 -1
- package/build-module/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build-module/components/block-edit-visually-button/index.js +35 -0
- package/build-module/components/block-edit-visually-button/index.js.map +1 -0
- package/build-module/components/block-list/block.js +13 -3
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/index.native.js +1 -1
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +5 -3
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +8 -4
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-settings-menu/index.js +3 -6
- package/build-module/components/block-settings-menu/index.js.map +1 -1
- package/build-module/components/block-styles/index.js +4 -7
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-switcher/index.js +10 -16
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +4 -1
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +8 -2
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js +114 -0
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -0
- package/build-module/components/block-types-list/index.js +1 -1
- package/build-module/components/block-types-list/index.js.map +1 -1
- package/build-module/components/border-radius-control/all-input-control.js +32 -4
- package/build-module/components/border-radius-control/all-input-control.js.map +1 -1
- package/build-module/components/border-radius-control/index.js +24 -8
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/border-radius-control/input-controls.js +22 -7
- package/build-module/components/border-radius-control/input-controls.js.map +1 -1
- package/build-module/components/border-radius-control/utils.js +13 -16
- package/build-module/components/border-radius-control/utils.js.map +1 -1
- package/build-module/components/colors/utils.js +7 -3
- package/build-module/components/colors/utils.js.map +1 -1
- package/build-module/components/colors/with-colors.js +16 -3
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +7 -4
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +5 -2
- package/build-module/components/colors-gradients/dropdown.js.map +1 -1
- package/build-module/components/copy-handler/index.js +7 -1
- package/build-module/components/copy-handler/index.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +2 -6
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/duotone/components.js +5 -5
- package/build-module/components/duotone/components.js.map +1 -1
- package/build-module/components/font-appearance-control/index.js +7 -4
- package/build-module/components/font-appearance-control/index.js.map +1 -1
- package/build-module/components/font-family/index.js +1 -1
- package/build-module/components/font-family/index.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +16 -3
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/image-size-control/index.js +3 -1
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/index.js +2 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +1 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inserter/index.native.js +9 -2
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/search-items.js +19 -5
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/inserter-list-item/index.js +1 -17
- package/build-module/components/inserter-list-item/index.js.map +1 -1
- package/build-module/components/letter-spacing-control/index.js +5 -3
- package/build-module/components/letter-spacing-control/index.js.map +1 -1
- package/build-module/components/line-height-control/index.js +5 -3
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/link-control/is-url-like.js +1 -6
- package/build-module/components/link-control/is-url-like.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +0 -1
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/link-control/use-search-handler.js +1 -6
- package/build-module/components/link-control/use-search-handler.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +5 -2
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/expander.js +3 -2
- package/build-module/components/list-view/expander.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js +1 -6
- package/build-module/components/list-view/use-block-selection.js.map +1 -1
- package/build-module/components/media-upload/index.native.js +9 -2
- package/build-module/components/media-upload/index.native.js.map +1 -1
- package/build-module/components/preview-options/index.js +2 -2
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/{use-no-recursive-renders → recursion-provider}/index.js +39 -19
- package/build-module/components/recursion-provider/index.js.map +1 -0
- package/build-module/components/rich-text/index.js +5 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +3 -1
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-before-input-rules.js +96 -0
- package/build-module/components/rich-text/use-before-input-rules.js.map +1 -0
- package/build-module/components/rich-text/use-enter.js +0 -4
- package/build-module/components/rich-text/use-enter.js.map +1 -1
- package/build-module/components/rich-text/use-format-types.js +8 -10
- package/build-module/components/rich-text/use-format-types.js.map +1 -1
- package/build-module/components/spacing-sizes-control/all-input-control.js +41 -0
- package/build-module/components/spacing-sizes-control/all-input-control.js.map +1 -0
- package/build-module/components/spacing-sizes-control/axial-input-controls.js +57 -0
- package/build-module/components/spacing-sizes-control/axial-input-controls.js.map +1 -0
- package/build-module/components/spacing-sizes-control/index.js +83 -0
- package/build-module/components/spacing-sizes-control/index.js.map +1 -0
- package/build-module/components/spacing-sizes-control/input-controls.js +41 -0
- package/build-module/components/spacing-sizes-control/input-controls.js.map +1 -0
- package/build-module/components/spacing-sizes-control/linked-button.js +28 -0
- package/build-module/components/spacing-sizes-control/linked-button.js.map +1 -0
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +192 -0
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -0
- package/build-module/components/spacing-sizes-control/utils.js +174 -0
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -0
- package/build-module/components/text-decoration-control/index.js +4 -2
- package/build-module/components/text-decoration-control/index.js.map +1 -1
- package/build-module/components/text-transform-control/index.js +4 -2
- package/build-module/components/text-transform-control/index.js.map +1 -1
- package/build-module/components/url-input/index.js +1 -1
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js +4 -1
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/writing-flow/use-arrow-nav.js +5 -26
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/components/writing-flow/use-drag-selection.js +9 -2
- package/build-module/components/writing-flow/use-drag-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-multi-selection.js +4 -2
- package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-select-all.js +3 -1
- package/build-module/components/writing-flow/use-select-all.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js +10 -2
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build-module/hooks/border-radius.js +2 -7
- package/build-module/hooks/border-radius.js.map +1 -1
- package/build-module/hooks/border.js +2 -2
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +4 -1
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/dimensions.js +13 -0
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +4 -4
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/gap.js +3 -2
- package/build-module/hooks/gap.js.map +1 -1
- package/build-module/hooks/generated-class-name.js +1 -6
- package/build-module/hooks/generated-class-name.js.map +1 -1
- package/build-module/hooks/layout.js +29 -14
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/margin.js +26 -12
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +17 -8
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/style.js +7 -53
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/layouts/constrained.js +197 -0
- package/build-module/layouts/constrained.js.map +1 -0
- package/build-module/layouts/flex.js +1 -1
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/layouts/flow.js +8 -145
- package/build-module/layouts/flow.js.map +1 -1
- package/build-module/layouts/index.js +2 -1
- package/build-module/layouts/index.js.map +1 -1
- package/build-module/layouts/utils.js +40 -0
- package/build-module/layouts/utils.js.map +1 -1
- package/build-module/store/actions.js +25 -3
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +5 -7
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/block-variation-transforms.js +14 -7
- package/build-module/utils/block-variation-transforms.js.map +1 -1
- package/build-module/utils/pasting.js +9 -1
- package/build-module/utils/pasting.js.map +1 -1
- package/build-style/style-rtl.css +154 -27
- package/build-style/style.css +154 -27
- package/package.json +30 -28
- package/src/components/block-alignment-control/use-available-alignments.js +1 -1
- package/src/components/block-edit-visually-button/index.js +39 -0
- package/src/components/block-list/block.js +13 -2
- package/src/components/block-list/index.native.js +1 -1
- package/src/components/block-popover/inbetween.js +5 -1
- package/src/components/block-popover/index.js +22 -13
- package/src/components/block-popover/style.scss +25 -2
- package/src/components/block-settings-menu/index.js +11 -15
- package/src/components/block-styles/index.js +4 -7
- package/src/components/block-styles/style.scss +10 -0
- package/src/components/block-switcher/index.js +9 -13
- package/src/components/block-switcher/test/index.js +1 -0
- package/src/components/block-toolbar/index.js +2 -0
- package/src/components/block-tools/selected-block-popover.js +7 -0
- package/src/components/block-tools/use-block-toolbar-popover-props.js +123 -0
- package/src/components/block-types-list/index.js +1 -1
- package/src/components/border-radius-control/all-input-control.js +41 -4
- package/src/components/border-radius-control/index.js +29 -6
- package/src/components/border-radius-control/input-controls.js +40 -13
- package/src/components/border-radius-control/test/utils.js +22 -60
- package/src/components/border-radius-control/utils.js +12 -16
- package/src/components/color-palette/test/__snapshots__/control.js.snap +93 -77
- package/src/components/colors/utils.js +5 -2
- package/src/components/colors/with-colors.js +11 -1
- package/src/components/colors-gradients/control.js +12 -8
- package/src/components/colors-gradients/dropdown.js +7 -2
- package/src/components/colors-gradients/style.scss +27 -5
- package/src/components/colors-gradients/test/control.js +3 -3
- package/src/components/copy-handler/index.js +18 -0
- package/src/components/date-format-picker/index.js +12 -14
- package/src/components/date-format-picker/style.scss +0 -4
- package/src/components/duotone/components.js +5 -5
- package/src/components/duotone-control/style.scss +0 -4
- package/src/components/font-appearance-control/index.js +3 -0
- package/src/components/font-appearance-control/style.scss +0 -2
- package/src/components/font-family/index.js +1 -1
- package/src/components/font-sizes/with-font-sizes.js +11 -1
- package/src/components/image-size-control/README.md +7 -0
- package/src/components/image-size-control/index.js +2 -0
- package/src/components/index.js +5 -1
- package/src/components/index.native.js +4 -1
- package/src/components/inserter/index.native.js +7 -2
- package/src/components/inserter/search-items.js +17 -5
- package/src/components/inserter-list-item/index.js +1 -17
- package/src/components/letter-spacing-control/index.js +2 -0
- package/src/components/line-height-control/index.js +2 -0
- package/src/components/link-control/is-url-like.js +1 -6
- package/src/components/link-control/link-preview.js +0 -1
- package/src/components/link-control/test/index.js +540 -893
- package/src/components/link-control/use-search-handler.js +1 -6
- package/src/components/list-view/block-select-button.js +7 -2
- package/src/components/list-view/expander.js +4 -2
- package/src/components/list-view/style.scss +11 -4
- package/src/components/list-view/use-block-selection.js +2 -8
- package/src/components/media-replace-flow/style.scss +1 -0
- package/src/components/media-upload/index.native.js +7 -3
- package/src/components/preview-options/index.js +2 -2
- package/src/components/{use-no-recursive-renders → recursion-provider}/index.js +39 -28
- package/src/components/{use-no-recursive-renders/test/use-no-recursive-renders.js → recursion-provider/test/index.js} +5 -6
- package/src/components/rich-text/README.md +13 -1
- package/src/components/rich-text/index.js +2 -0
- package/src/components/rich-text/index.native.js +2 -0
- package/src/components/rich-text/use-before-input-rules.js +91 -0
- package/src/components/rich-text/use-enter.js +0 -3
- package/src/components/rich-text/use-format-types.js +6 -6
- package/src/components/spacing-sizes-control/all-input-control.js +40 -0
- package/src/components/spacing-sizes-control/axial-input-controls.js +62 -0
- package/src/components/spacing-sizes-control/index.js +91 -0
- package/src/components/spacing-sizes-control/input-controls.js +46 -0
- package/src/components/spacing-sizes-control/linked-button.js +25 -0
- package/src/components/spacing-sizes-control/spacing-input-control.js +280 -0
- package/src/components/spacing-sizes-control/style.scss +122 -0
- package/src/components/spacing-sizes-control/test/utils.js +156 -0
- package/src/components/spacing-sizes-control/utils.js +195 -0
- package/src/components/text-decoration-control/index.js +4 -2
- package/src/components/text-transform-control/index.js +4 -2
- package/src/components/url-input/index.js +1 -1
- package/src/components/url-input/style.scss +2 -2
- package/src/components/url-popover/image-url-input-ui.js +3 -0
- package/src/components/url-popover/style.scss +0 -3
- package/src/components/writing-flow/use-arrow-nav.js +4 -33
- package/src/components/writing-flow/use-drag-selection.js +7 -1
- package/src/components/writing-flow/use-multi-selection.js +4 -1
- package/src/components/writing-flow/use-select-all.js +2 -1
- package/src/components/writing-flow/use-selection-observer.js +10 -2
- package/src/hooks/border-radius.js +2 -6
- package/src/hooks/border.js +2 -2
- package/src/hooks/color.js +13 -3
- package/src/hooks/dimensions.js +15 -0
- package/src/hooks/duotone.js +4 -4
- package/src/hooks/gap.js +7 -2
- package/src/hooks/generated-class-name.js +6 -9
- package/src/hooks/layout.js +53 -16
- package/src/hooks/margin.js +49 -17
- package/src/hooks/padding.js +41 -14
- package/src/hooks/style.js +5 -56
- package/src/hooks/test/gap.js +22 -0
- package/src/hooks/typography.scss +0 -1
- package/src/layouts/constrained.js +217 -0
- package/src/layouts/flex.js +1 -1
- package/src/layouts/flow.js +6 -164
- package/src/layouts/index.js +2 -1
- package/src/layouts/test/constrained.js +21 -0
- package/src/layouts/utils.js +34 -0
- package/src/store/actions.js +32 -4
- package/src/store/selectors.js +5 -4
- package/src/style.scss +1 -0
- package/src/utils/block-variation-transforms.js +13 -6
- package/src/utils/pasting.js +10 -1
- package/src/utils/test/block-variation-transforms.js +24 -0
- package/src/utils/test/pasting.js +10 -0
- package/build/components/block-settings-menu/block-edit-visually-button.js +0 -70
- package/build/components/block-settings-menu/block-edit-visually-button.js.map +0 -1
- package/build/components/use-no-recursive-renders/index.js.map +0 -1
- package/build-module/components/block-settings-menu/block-edit-visually-button.js +0 -56
- package/build-module/components/block-settings-menu/block-edit-visually-button.js.map +0 -1
- package/build-module/components/use-no-recursive-renders/index.js.map +0 -1
- package/src/components/block-settings-menu/block-edit-visually-button.js +0 -52
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-editor",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.8.0",
|
|
4
4
|
"description": "Generic block editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -33,32 +33,33 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/runtime": "^7.16.0",
|
|
35
35
|
"@react-spring/web": "^9.4.5",
|
|
36
|
-
"@wordpress/a11y": "^3.
|
|
37
|
-
"@wordpress/api-fetch": "^6.
|
|
38
|
-
"@wordpress/blob": "^3.
|
|
39
|
-
"@wordpress/blocks": "^11.
|
|
40
|
-
"@wordpress/components": "^
|
|
41
|
-
"@wordpress/compose": "^5.
|
|
42
|
-
"@wordpress/data": "^
|
|
43
|
-
"@wordpress/date": "^4.
|
|
44
|
-
"@wordpress/deprecated": "^3.
|
|
45
|
-
"@wordpress/dom": "^3.
|
|
46
|
-
"@wordpress/element": "^4.
|
|
47
|
-
"@wordpress/hooks": "^3.
|
|
48
|
-
"@wordpress/html-entities": "^3.
|
|
49
|
-
"@wordpress/i18n": "^4.
|
|
50
|
-
"@wordpress/icons": "^9.
|
|
51
|
-
"@wordpress/is-shallow-equal": "^4.
|
|
52
|
-
"@wordpress/keyboard-shortcuts": "^3.
|
|
53
|
-
"@wordpress/keycodes": "^3.
|
|
54
|
-
"@wordpress/notices": "^3.
|
|
55
|
-
"@wordpress/rich-text": "^5.
|
|
56
|
-
"@wordpress/shortcode": "^3.
|
|
57
|
-
"@wordpress/style-engine": "^0.
|
|
58
|
-
"@wordpress/token-list": "^2.
|
|
59
|
-
"@wordpress/url": "^3.
|
|
60
|
-
"@wordpress/warning": "^2.
|
|
61
|
-
"@wordpress/wordcount": "^3.
|
|
36
|
+
"@wordpress/a11y": "^3.16.0",
|
|
37
|
+
"@wordpress/api-fetch": "^6.13.0",
|
|
38
|
+
"@wordpress/blob": "^3.16.0",
|
|
39
|
+
"@wordpress/blocks": "^11.15.0",
|
|
40
|
+
"@wordpress/components": "^20.0.0",
|
|
41
|
+
"@wordpress/compose": "^5.14.0",
|
|
42
|
+
"@wordpress/data": "^7.0.0",
|
|
43
|
+
"@wordpress/date": "^4.16.0",
|
|
44
|
+
"@wordpress/deprecated": "^3.16.0",
|
|
45
|
+
"@wordpress/dom": "^3.16.0",
|
|
46
|
+
"@wordpress/element": "^4.14.0",
|
|
47
|
+
"@wordpress/hooks": "^3.16.0",
|
|
48
|
+
"@wordpress/html-entities": "^3.16.0",
|
|
49
|
+
"@wordpress/i18n": "^4.16.0",
|
|
50
|
+
"@wordpress/icons": "^9.7.0",
|
|
51
|
+
"@wordpress/is-shallow-equal": "^4.16.0",
|
|
52
|
+
"@wordpress/keyboard-shortcuts": "^3.14.0",
|
|
53
|
+
"@wordpress/keycodes": "^3.16.0",
|
|
54
|
+
"@wordpress/notices": "^3.16.0",
|
|
55
|
+
"@wordpress/rich-text": "^5.14.0",
|
|
56
|
+
"@wordpress/shortcode": "^3.16.0",
|
|
57
|
+
"@wordpress/style-engine": "^0.15.0",
|
|
58
|
+
"@wordpress/token-list": "^2.16.0",
|
|
59
|
+
"@wordpress/url": "^3.17.0",
|
|
60
|
+
"@wordpress/warning": "^2.16.0",
|
|
61
|
+
"@wordpress/wordcount": "^3.16.0",
|
|
62
|
+
"change-case": "^4.1.2",
|
|
62
63
|
"classnames": "^2.3.1",
|
|
63
64
|
"colord": "^2.7.0",
|
|
64
65
|
"diff": "^4.0.2",
|
|
@@ -68,6 +69,7 @@
|
|
|
68
69
|
"react-autosize-textarea": "^7.1.0",
|
|
69
70
|
"react-easy-crop": "^3.0.0",
|
|
70
71
|
"rememo": "^4.0.0",
|
|
72
|
+
"remove-accents": "^0.4.2",
|
|
71
73
|
"traverse": "^0.6.6"
|
|
72
74
|
},
|
|
73
75
|
"peerDependencies": {
|
|
@@ -77,5 +79,5 @@
|
|
|
77
79
|
"publishConfig": {
|
|
78
80
|
"access": "public"
|
|
79
81
|
},
|
|
80
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "171b87c7465b93e685e081c5f57f153507363c95"
|
|
81
83
|
}
|
|
@@ -46,7 +46,7 @@ export default function useAvailableAlignments( controls = DEFAULT_CONTROLS ) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
// Starting here, it's the fallback for themes not supporting the layout config.
|
|
49
|
-
if ( layoutType.name !== 'default' ) {
|
|
49
|
+
if ( layoutType.name !== 'default' && layoutType.name !== 'constrained' ) {
|
|
50
50
|
return [];
|
|
51
51
|
}
|
|
52
52
|
const { alignments: availableAlignments = DEFAULT_CONTROLS } = layout;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { ToolbarButton, ToolbarGroup } from '@wordpress/components';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
6
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import { store as blockEditorStore } from '../../store';
|
|
12
|
+
|
|
13
|
+
export default function BlockEditVisuallyButton( { clientIds } ) {
|
|
14
|
+
// Edit visually only works for single block selection.
|
|
15
|
+
const clientId = clientIds.length === 1 ? clientIds[ 0 ] : undefined;
|
|
16
|
+
const canEditVisually = useSelect(
|
|
17
|
+
( select ) =>
|
|
18
|
+
!! clientId &&
|
|
19
|
+
select( blockEditorStore ).getBlockMode( clientId ) === 'html',
|
|
20
|
+
[ clientId ]
|
|
21
|
+
);
|
|
22
|
+
const { toggleBlockMode } = useDispatch( blockEditorStore );
|
|
23
|
+
|
|
24
|
+
if ( ! canEditVisually ) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<ToolbarGroup>
|
|
30
|
+
<ToolbarButton
|
|
31
|
+
onClick={ () => {
|
|
32
|
+
toggleBlockMode( clientId );
|
|
33
|
+
} }
|
|
34
|
+
>
|
|
35
|
+
{ __( 'Edit visually' ) }
|
|
36
|
+
</ToolbarButton>
|
|
37
|
+
</ToolbarGroup>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
getSaveContent,
|
|
19
19
|
isUnmodifiedDefaultBlock,
|
|
20
20
|
serializeRawBlock,
|
|
21
|
+
switchToBlockType,
|
|
21
22
|
} from '@wordpress/blocks';
|
|
22
23
|
import { withFilters } from '@wordpress/components';
|
|
23
24
|
import {
|
|
@@ -291,8 +292,8 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, { select } ) => {
|
|
|
291
292
|
insertBlocks( blocks, index + 1, rootClientId );
|
|
292
293
|
},
|
|
293
294
|
onMerge( forward ) {
|
|
294
|
-
const { clientId } = ownProps;
|
|
295
|
-
const { getPreviousBlockClientId, getNextBlockClientId } =
|
|
295
|
+
const { clientId, rootClientId } = ownProps;
|
|
296
|
+
const { getPreviousBlockClientId, getNextBlockClientId, getBlock } =
|
|
296
297
|
select( blockEditorStore );
|
|
297
298
|
|
|
298
299
|
if ( forward ) {
|
|
@@ -305,6 +306,16 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, { select } ) => {
|
|
|
305
306
|
getPreviousBlockClientId( clientId );
|
|
306
307
|
if ( previousBlockClientId ) {
|
|
307
308
|
mergeBlocks( previousBlockClientId, clientId );
|
|
309
|
+
} else if ( rootClientId ) {
|
|
310
|
+
// Attempt to "unwrap" the block contents when there's no
|
|
311
|
+
// preceding block to merge with.
|
|
312
|
+
const replacement = switchToBlockType(
|
|
313
|
+
getBlock( rootClientId ),
|
|
314
|
+
'*'
|
|
315
|
+
);
|
|
316
|
+
if ( replacement && replacement.length ) {
|
|
317
|
+
replaceBlocks( rootClientId, replacement, 0 );
|
|
318
|
+
}
|
|
308
319
|
}
|
|
309
320
|
}
|
|
310
321
|
},
|
|
@@ -154,7 +154,10 @@ function BlockPopoverInbetween( {
|
|
|
154
154
|
|
|
155
155
|
const popoverScrollRef = usePopoverScroll( __unstableContentRef );
|
|
156
156
|
|
|
157
|
-
|
|
157
|
+
// If there's either a previous or a next element, show the inbetween popover.
|
|
158
|
+
// Note that drag and drop uses the inbetween popover to show the drop indicator
|
|
159
|
+
// before the first block and after the last block.
|
|
160
|
+
if ( ( ! previousElement && ! nextElement ) || ! isVisible ) {
|
|
158
161
|
return null;
|
|
159
162
|
}
|
|
160
163
|
|
|
@@ -180,6 +183,7 @@ function BlockPopoverInbetween( {
|
|
|
180
183
|
{ ...props }
|
|
181
184
|
className={ classnames(
|
|
182
185
|
'block-editor-block-popover',
|
|
186
|
+
'block-editor-block-popover__inbetween',
|
|
183
187
|
props.className
|
|
184
188
|
) }
|
|
185
189
|
__unstableForcePosition
|
|
@@ -6,8 +6,9 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
+
import { useMergeRefs } from '@wordpress/compose';
|
|
9
10
|
import { Popover } from '@wordpress/components';
|
|
10
|
-
import { useMemo } from '@wordpress/element';
|
|
11
|
+
import { forwardRef, useMemo } from '@wordpress/element';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Internal dependencies
|
|
@@ -15,19 +16,25 @@ import { useMemo } from '@wordpress/element';
|
|
|
15
16
|
import { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';
|
|
16
17
|
import usePopoverScroll from './use-popover-scroll';
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
function BlockPopover(
|
|
20
|
+
{
|
|
21
|
+
clientId,
|
|
22
|
+
bottomClientId,
|
|
23
|
+
children,
|
|
24
|
+
__unstableRefreshSize,
|
|
25
|
+
__unstableCoverTarget = false,
|
|
26
|
+
__unstablePopoverSlot,
|
|
27
|
+
__unstableContentRef,
|
|
28
|
+
...props
|
|
29
|
+
},
|
|
30
|
+
ref
|
|
31
|
+
) {
|
|
28
32
|
const selectedElement = useBlockElement( clientId );
|
|
29
33
|
const lastSelectedElement = useBlockElement( bottomClientId ?? clientId );
|
|
30
|
-
const
|
|
34
|
+
const mergedRefs = useMergeRefs( [
|
|
35
|
+
ref,
|
|
36
|
+
usePopoverScroll( __unstableContentRef ),
|
|
37
|
+
] );
|
|
31
38
|
const style = useMemo( () => {
|
|
32
39
|
if ( ! selectedElement || lastSelectedElement !== selectedElement ) {
|
|
33
40
|
return {};
|
|
@@ -51,7 +58,7 @@ export default function BlockPopover( {
|
|
|
51
58
|
|
|
52
59
|
return (
|
|
53
60
|
<Popover
|
|
54
|
-
ref={
|
|
61
|
+
ref={ mergedRefs }
|
|
55
62
|
animate={ false }
|
|
56
63
|
position="top right left"
|
|
57
64
|
focusOnMount={ false }
|
|
@@ -74,3 +81,5 @@ export default function BlockPopover( {
|
|
|
74
81
|
</Popover>
|
|
75
82
|
);
|
|
76
83
|
}
|
|
84
|
+
|
|
85
|
+
export default forwardRef( BlockPopover );
|
|
@@ -18,11 +18,34 @@
|
|
|
18
18
|
|
|
19
19
|
// Allow clicking through the toolbar holder.
|
|
20
20
|
pointer-events: none;
|
|
21
|
+
}
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
// Enable pointer events for the toolbar's content.
|
|
24
|
+
&:not(.block-editor-block-popover__inbetween) .components-popover__content {
|
|
25
|
+
* {
|
|
24
26
|
pointer-events: all;
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
30
|
|
|
31
|
+
.components-popover.block-editor-block-popover__inbetween {
|
|
32
|
+
// Disable pointer events for dragging and dropping.
|
|
33
|
+
// Without this the insertion point interferes with the
|
|
34
|
+
// drop zone.
|
|
35
|
+
pointer-events: none;
|
|
36
|
+
|
|
37
|
+
* {
|
|
38
|
+
pointer-events: none;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Re-enable pointer events when the inbetween inserter has a '+' button.
|
|
42
|
+
//
|
|
43
|
+
// Needs specificity, do not simplify.
|
|
44
|
+
.is-with-inserter {
|
|
45
|
+
pointer-events: all;
|
|
46
|
+
|
|
47
|
+
* {
|
|
48
|
+
pointer-events: all;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -7,24 +7,20 @@ import { ToolbarGroup, ToolbarItem } from '@wordpress/components';
|
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
9
|
import BlockSettingsDropdown from './block-settings-dropdown';
|
|
10
|
-
import BlockEditVisuallyButton from './block-edit-visually-button';
|
|
11
10
|
|
|
12
11
|
export function BlockSettingsMenu( { clientIds, ...props } ) {
|
|
13
12
|
return (
|
|
14
|
-
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
</ToolbarItem>
|
|
26
|
-
</ToolbarGroup>
|
|
27
|
-
</>
|
|
13
|
+
<ToolbarGroup>
|
|
14
|
+
<ToolbarItem>
|
|
15
|
+
{ ( toggleProps ) => (
|
|
16
|
+
<BlockSettingsDropdown
|
|
17
|
+
clientIds={ clientIds }
|
|
18
|
+
toggleProps={ toggleProps }
|
|
19
|
+
{ ...props }
|
|
20
|
+
/>
|
|
21
|
+
) }
|
|
22
|
+
</ToolbarItem>
|
|
23
|
+
</ToolbarGroup>
|
|
28
24
|
);
|
|
29
25
|
}
|
|
30
26
|
|
|
@@ -11,7 +11,7 @@ import { useState, useLayoutEffect } from '@wordpress/element';
|
|
|
11
11
|
import { useViewportMatch } from '@wordpress/compose';
|
|
12
12
|
import {
|
|
13
13
|
Button,
|
|
14
|
-
|
|
14
|
+
__experimentalTruncate as Truncate,
|
|
15
15
|
Slot,
|
|
16
16
|
Fill,
|
|
17
17
|
} from '@wordpress/components';
|
|
@@ -117,15 +117,12 @@ function BlockStyles( {
|
|
|
117
117
|
onClick={ () => onSelectStylePreview( style ) }
|
|
118
118
|
aria-current={ activeStyle.name === style.name }
|
|
119
119
|
>
|
|
120
|
-
<
|
|
121
|
-
|
|
122
|
-
limit={ 12 }
|
|
123
|
-
ellipsizeMode="tail"
|
|
120
|
+
<Truncate
|
|
121
|
+
numberOfLines={ 1 }
|
|
124
122
|
className="block-editor-block-styles__item-text"
|
|
125
|
-
truncate
|
|
126
123
|
>
|
|
127
124
|
{ buttonText }
|
|
128
|
-
</
|
|
125
|
+
</Truncate>
|
|
129
126
|
</Button>
|
|
130
127
|
);
|
|
131
128
|
} ) }
|
|
@@ -64,6 +64,16 @@
|
|
|
64
64
|
box-shadow: inset 0 0 0 1px $white, 0 0 0 2px var(--wp-admin-theme-color);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
+
|
|
68
|
+
.block-editor-block-styles__item-text {
|
|
69
|
+
word-break: break-all;
|
|
70
|
+
// The Button component is white-space: nowrap, and that won't work with line-clamp.
|
|
71
|
+
white-space: normal;
|
|
72
|
+
|
|
73
|
+
// Without this, the ellipsis can sometimes be partially hidden by the Button padding.
|
|
74
|
+
text-align: start;
|
|
75
|
+
text-align-last: center;
|
|
76
|
+
}
|
|
67
77
|
}
|
|
68
78
|
|
|
69
79
|
// To prevent overflow in the preview container,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { castArray
|
|
4
|
+
import { castArray } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -28,10 +28,10 @@ import { copy } from '@wordpress/icons';
|
|
|
28
28
|
import { store as blockEditorStore } from '../../store';
|
|
29
29
|
import useBlockDisplayInformation from '../use-block-display-information';
|
|
30
30
|
import BlockIcon from '../block-icon';
|
|
31
|
-
import BlockTitle from '../block-title';
|
|
32
31
|
import BlockTransformationsMenu from './block-transformations-menu';
|
|
33
32
|
import BlockStylesMenu from './block-styles-menu';
|
|
34
33
|
import PatternTransformationsMenu from './pattern-transformations-menu';
|
|
34
|
+
import useBlockDisplayTitle from '../block-title/use-block-display-title';
|
|
35
35
|
|
|
36
36
|
export const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => {
|
|
37
37
|
const { replaceBlocks } = useDispatch( blockEditorStore );
|
|
@@ -41,7 +41,6 @@ export const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => {
|
|
|
41
41
|
canRemove,
|
|
42
42
|
hasBlockStyles,
|
|
43
43
|
icon,
|
|
44
|
-
blockTitle,
|
|
45
44
|
patterns,
|
|
46
45
|
} = useSelect(
|
|
47
46
|
( select ) => {
|
|
@@ -64,7 +63,7 @@ export const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => {
|
|
|
64
63
|
_icon = blockInformation?.icon; // Take into account active block variations.
|
|
65
64
|
} else {
|
|
66
65
|
const isSelectionOfSameType =
|
|
67
|
-
|
|
66
|
+
new Set( blocks.map( ( { name } ) => name ) ).size === 1;
|
|
68
67
|
// When selection consists of blocks of multiple types, display an
|
|
69
68
|
// appropriate icon to communicate the non-uniformity.
|
|
70
69
|
_icon = isSelectionOfSameType
|
|
@@ -79,7 +78,6 @@ export const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => {
|
|
|
79
78
|
canRemove: canRemoveBlocks( clientIds, rootClientId ),
|
|
80
79
|
hasBlockStyles: !! styles?.length,
|
|
81
80
|
icon: _icon,
|
|
82
|
-
blockTitle: getBlockType( firstBlockName )?.title,
|
|
83
81
|
patterns: __experimentalGetPatternTransformItems(
|
|
84
82
|
blocks,
|
|
85
83
|
rootClientId
|
|
@@ -89,6 +87,10 @@ export const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => {
|
|
|
89
87
|
[ clientIds, blocks, blockInformation?.icon ]
|
|
90
88
|
);
|
|
91
89
|
|
|
90
|
+
const blockTitle = useBlockDisplayTitle( {
|
|
91
|
+
clientId: Array.isArray( clientIds ) ? clientIds[ 0 ] : clientIds,
|
|
92
|
+
maximumLength: 35,
|
|
93
|
+
} );
|
|
92
94
|
const isReusable = blocks.length === 1 && isReusableBlock( blocks[ 0 ] );
|
|
93
95
|
const isTemplate = blocks.length === 1 && isTemplatePart( blocks[ 0 ] );
|
|
94
96
|
|
|
@@ -119,10 +121,7 @@ export const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => {
|
|
|
119
121
|
<BlockIcon icon={ icon } showColors />
|
|
120
122
|
{ ( isReusable || isTemplate ) && (
|
|
121
123
|
<span className="block-editor-block-switcher__toggle-text">
|
|
122
|
-
|
|
123
|
-
clientId={ clientIds }
|
|
124
|
-
maximumLength={ 35 }
|
|
125
|
-
/>
|
|
124
|
+
{ blockTitle }
|
|
126
125
|
</span>
|
|
127
126
|
) }
|
|
128
127
|
</>
|
|
@@ -176,10 +175,7 @@ export const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => {
|
|
|
176
175
|
/>
|
|
177
176
|
{ ( isReusable || isTemplate ) && (
|
|
178
177
|
<span className="block-editor-block-switcher__toggle-text">
|
|
179
|
-
|
|
180
|
-
clientId={ clientIds }
|
|
181
|
-
maximumLength={ 35 }
|
|
182
|
-
/>
|
|
178
|
+
{ blockTitle }
|
|
183
179
|
</span>
|
|
184
180
|
) }
|
|
185
181
|
</>
|
|
@@ -18,6 +18,7 @@ import { copy } from '@wordpress/icons';
|
|
|
18
18
|
import { BlockSwitcher, BlockSwitcherDropdownMenu } from '../';
|
|
19
19
|
|
|
20
20
|
jest.mock( '@wordpress/data/src/components/use-select', () => jest.fn() );
|
|
21
|
+
jest.mock( '../../block-title/use-block-display-title', () => jest.fn() );
|
|
21
22
|
|
|
22
23
|
describe( 'BlockSwitcher', () => {
|
|
23
24
|
test( 'should not render block switcher without blocks', () => {
|
|
@@ -23,6 +23,7 @@ import __unstableBlockToolbarLastItem from './block-toolbar-last-item';
|
|
|
23
23
|
import BlockSettingsMenu from '../block-settings-menu';
|
|
24
24
|
import { BlockLockToolbar } from '../block-lock';
|
|
25
25
|
import { BlockGroupToolbar } from '../convert-to-group-buttons';
|
|
26
|
+
import BlockEditVisuallyButton from '../block-edit-visually-button';
|
|
26
27
|
import { useShowMoversGestures } from './utils';
|
|
27
28
|
import { store as blockEditorStore } from '../../store';
|
|
28
29
|
import __unstableBlockNameContext from './block-name-context';
|
|
@@ -159,6 +160,7 @@ const BlockToolbar = ( { hideDragHandle } ) => {
|
|
|
159
160
|
</__unstableBlockNameContext.Provider>
|
|
160
161
|
</>
|
|
161
162
|
) }
|
|
163
|
+
<BlockEditVisuallyButton clientIds={ blockClientIds } />
|
|
162
164
|
<BlockSettingsMenu clientIds={ blockClientIds } />
|
|
163
165
|
</div>
|
|
164
166
|
);
|
|
@@ -20,6 +20,7 @@ import BlockSelectionButton from './block-selection-button';
|
|
|
20
20
|
import BlockContextualToolbar from './block-contextual-toolbar';
|
|
21
21
|
import { store as blockEditorStore } from '../../store';
|
|
22
22
|
import BlockPopover from '../block-popover';
|
|
23
|
+
import useBlockToolbarPopoverProps from './use-block-toolbar-popover-props';
|
|
23
24
|
|
|
24
25
|
function selector( select ) {
|
|
25
26
|
const {
|
|
@@ -113,6 +114,11 @@ function SelectedBlockPopover( {
|
|
|
113
114
|
// to it when re-mounting.
|
|
114
115
|
const initialToolbarItemIndexRef = useRef();
|
|
115
116
|
|
|
117
|
+
const popoverProps = useBlockToolbarPopoverProps( {
|
|
118
|
+
contentElement: __unstableContentRef?.current,
|
|
119
|
+
clientId,
|
|
120
|
+
} );
|
|
121
|
+
|
|
116
122
|
if ( ! shouldShowBreadcrumb && ! shouldShowContextualToolbar ) {
|
|
117
123
|
return null;
|
|
118
124
|
}
|
|
@@ -126,6 +132,7 @@ function SelectedBlockPopover( {
|
|
|
126
132
|
} ) }
|
|
127
133
|
__unstablePopoverSlot={ __unstablePopoverSlot }
|
|
128
134
|
__unstableContentRef={ __unstableContentRef }
|
|
135
|
+
{ ...popoverProps }
|
|
129
136
|
>
|
|
130
137
|
{ shouldShowContextualToolbar && (
|
|
131
138
|
<BlockContextualToolbar
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useRefEffect } from '@wordpress/compose';
|
|
5
|
+
import { useSelect } from '@wordpress/data';
|
|
6
|
+
import { useCallback, useLayoutEffect, useState } from '@wordpress/element';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import { store as blockEditorStore } from '../../store';
|
|
12
|
+
import { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';
|
|
13
|
+
|
|
14
|
+
// By default the toolbar sets the `shift` prop. If the user scrolls the page
|
|
15
|
+
// down the toolbar will stay on screen by adopting a sticky position at the
|
|
16
|
+
// top of the viewport.
|
|
17
|
+
const DEFAULT_PROPS = { __unstableForcePosition: true, __unstableShift: true };
|
|
18
|
+
|
|
19
|
+
// When there isn't enough height between the top of the block and the editor
|
|
20
|
+
// canvas, the `shift` prop is set to `false`, as it will cause the block to be
|
|
21
|
+
// obscured. The `flip` behavior is enabled (by setting `forcePosition` to
|
|
22
|
+
// `false`), which positions the toolbar below the block.
|
|
23
|
+
const RESTRICTED_HEIGHT_PROPS = {
|
|
24
|
+
__unstableForcePosition: false,
|
|
25
|
+
__unstableShift: false,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Get the popover props for the block toolbar, determined by the space at the top of the canvas and the toolbar height.
|
|
30
|
+
*
|
|
31
|
+
* @param {Element} contentElement The DOM element that represents the editor content or canvas.
|
|
32
|
+
* @param {Element} selectedBlockElement The outer DOM element of the first selected block.
|
|
33
|
+
* @param {number} toolbarHeight The height of the toolbar in pixels.
|
|
34
|
+
*
|
|
35
|
+
* @return {Object} The popover props used to determine the position of the toolbar.
|
|
36
|
+
*/
|
|
37
|
+
function getProps( contentElement, selectedBlockElement, toolbarHeight ) {
|
|
38
|
+
if ( ! contentElement || ! selectedBlockElement ) {
|
|
39
|
+
return DEFAULT_PROPS;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const blockRect = selectedBlockElement.getBoundingClientRect();
|
|
43
|
+
const contentRect = contentElement.getBoundingClientRect();
|
|
44
|
+
|
|
45
|
+
if ( blockRect.top - contentRect.top > toolbarHeight ) {
|
|
46
|
+
return DEFAULT_PROPS;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return RESTRICTED_HEIGHT_PROPS;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Determines the desired popover positioning behavior, returning a set of appropriate props.
|
|
54
|
+
*
|
|
55
|
+
* @param {Object} elements
|
|
56
|
+
* @param {Element} elements.contentElement The DOM element that represents the editor content or canvas.
|
|
57
|
+
* @param {string} elements.clientId The clientId of the first selected block.
|
|
58
|
+
*
|
|
59
|
+
* @return {Object} The popover props used to determine the position of the toolbar.
|
|
60
|
+
*/
|
|
61
|
+
export default function useBlockToolbarPopoverProps( {
|
|
62
|
+
contentElement,
|
|
63
|
+
clientId,
|
|
64
|
+
} ) {
|
|
65
|
+
const selectedBlockElement = useBlockElement( clientId );
|
|
66
|
+
const [ toolbarHeight, setToolbarHeight ] = useState( 0 );
|
|
67
|
+
const [ props, setProps ] = useState( () =>
|
|
68
|
+
getProps( contentElement, selectedBlockElement, toolbarHeight )
|
|
69
|
+
);
|
|
70
|
+
const blockIndex = useSelect(
|
|
71
|
+
( select ) => select( blockEditorStore ).getBlockIndex( clientId ),
|
|
72
|
+
[ clientId ]
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
const popoverRef = useRefEffect( ( popoverNode ) => {
|
|
76
|
+
setToolbarHeight( popoverNode.offsetHeight );
|
|
77
|
+
}, [] );
|
|
78
|
+
|
|
79
|
+
const updateProps = useCallback(
|
|
80
|
+
() =>
|
|
81
|
+
setProps(
|
|
82
|
+
getProps( contentElement, selectedBlockElement, toolbarHeight )
|
|
83
|
+
),
|
|
84
|
+
[ contentElement, selectedBlockElement, toolbarHeight ]
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
// Update props when the block is moved. This also ensures the props are
|
|
88
|
+
// correct on initial mount, and when the selected block or content element
|
|
89
|
+
// changes (since the callback ref will update).
|
|
90
|
+
useLayoutEffect( updateProps, [ blockIndex, updateProps ] );
|
|
91
|
+
|
|
92
|
+
// Update props when the viewport is resized or the block is resized.
|
|
93
|
+
useLayoutEffect( () => {
|
|
94
|
+
if ( ! contentElement || ! selectedBlockElement ) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Update the toolbar props on viewport resize.
|
|
99
|
+
const contentView = contentElement?.ownerDocument?.defaultView;
|
|
100
|
+
contentView?.addEventHandler?.( 'resize', updateProps );
|
|
101
|
+
|
|
102
|
+
// Update the toolbar props on block resize.
|
|
103
|
+
let resizeObserver;
|
|
104
|
+
const blockView = selectedBlockElement?.ownerDocument?.defaultView;
|
|
105
|
+
if ( blockView.ResizeObserver ) {
|
|
106
|
+
resizeObserver = new blockView.ResizeObserver( updateProps );
|
|
107
|
+
resizeObserver.observe( selectedBlockElement );
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return () => {
|
|
111
|
+
contentView?.removeEventHandler?.( 'resize', updateProps );
|
|
112
|
+
|
|
113
|
+
if ( resizeObserver ) {
|
|
114
|
+
resizeObserver.disconnect();
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
}, [ updateProps, contentElement, selectedBlockElement ] );
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
...props,
|
|
121
|
+
ref: popoverRef,
|
|
122
|
+
};
|
|
123
|
+
}
|