@wordpress/block-editor 10.2.0 → 10.4.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 +18 -0
- package/README.md +41 -0
- package/build/components/alignment-control/ui.js +1 -1
- package/build/components/alignment-control/ui.js.map +1 -1
- package/build/components/block-alignment-control/constants.js +1 -1
- package/build/components/block-alignment-control/constants.js.map +1 -1
- package/build/components/block-alignment-matrix-control/index.js +1 -1
- package/build/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build/components/block-compare/index.js +1 -3
- package/build/components/block-compare/index.js.map +1 -1
- package/build/components/block-draggable/draggable-chip.js +4 -2
- package/build/components/block-draggable/draggable-chip.js.map +1 -1
- package/build/components/block-edit/index.js +4 -2
- package/build/components/block-edit/index.js.map +1 -1
- package/build/components/block-inspector/index.js +4 -4
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block-list-compact.native.js +1 -0
- package/build/components/block-list/block-list-compact.native.js.map +1 -1
- package/build/components/block-list/block.js +75 -15
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +79 -12
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +7 -23
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-lock/modal.js +9 -6
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-parent-selector/index.js +3 -3
- package/build/components/block-parent-selector/index.js.map +1 -1
- package/build/components/block-patterns-list/index.js +5 -4
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-popover/drop-zone.js +85 -0
- package/build/components/block-popover/drop-zone.js.map +1 -0
- package/build/components/block-popover/inbetween.js +2 -1
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +4 -2
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-preview/auto.js +2 -2
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-preview/index.js +8 -13
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-preview/live.js +3 -7
- package/build/components/block-preview/live.js.map +1 -1
- package/build/components/block-selection-clearer/index.js +9 -1
- package/build/components/block-selection-clearer/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +19 -19
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/index.js +18 -42
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-switcher/index.js +2 -8
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-switcher/preview-block-popover.js +1 -1
- package/build/components/block-switcher/preview-block-popover.js.map +1 -1
- package/build/components/block-toolbar/index.js +4 -4
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/back-compat.js +2 -1
- package/build/components/block-tools/back-compat.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +56 -16
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +15 -3
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/block-vertical-alignment-control/ui.js +1 -1
- package/build/components/block-vertical-alignment-control/ui.js.map +1 -1
- package/build/components/border-radius-control/all-input-control.js +2 -1
- package/build/components/border-radius-control/all-input-control.js.map +1 -1
- package/build/components/border-radius-control/index.js +2 -1
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/border-radius-control/input-controls.js +2 -1
- package/build/components/border-radius-control/input-controls.js.map +1 -1
- package/build/components/colors-gradients/control.js +1 -1
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.js +2 -2
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build/components/duotone-control/index.js +1 -1
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +256 -0
- package/build/components/font-sizes/fluid-utils.js.map +1 -0
- package/build/components/font-sizes/index.js +8 -0
- package/build/components/font-sizes/index.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +1 -1
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/iframe/index.js +1 -1
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/constants.js +1 -1
- package/build/components/image-editor/constants.js.map +1 -1
- package/build/components/index.js +0 -9
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +6 -2
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/use-inner-block-template-sync.js +3 -2
- package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +151 -78
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-insertion-point.js +2 -7
- package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build/components/inserter/menu.js +14 -3
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/search-items.js +23 -2
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/inserter-draggable-blocks/index.js +4 -2
- package/build/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build/components/line-height-control/index.js +2 -1
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +2 -1
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js +1 -14
- package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build/components/media-replace-flow/index.js +1 -1
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/preview-options/index.js +2 -3
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/rich-text/format-toolbar/index.js +1 -1
- package/build/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build/components/rich-text/format-toolbar-container.js +1 -1
- package/build/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +1 -1
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/spacing-sizes-control/all-input-control.js +6 -2
- package/build/components/spacing-sizes-control/all-input-control.js.map +1 -1
- package/build/components/spacing-sizes-control/axial-input-controls.js +6 -2
- package/build/components/spacing-sizes-control/axial-input-controls.js.map +1 -1
- package/build/components/spacing-sizes-control/index.js +6 -2
- package/build/components/spacing-sizes-control/index.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls.js +6 -2
- package/build/components/spacing-sizes-control/input-controls.js.map +1 -1
- package/build/components/spacing-sizes-control/spacing-input-control.js +45 -8
- package/build/components/spacing-sizes-control/spacing-input-control.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/use-block-drop-zone/index.js +98 -57
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-on-block-drop/index.js +12 -12
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/use-on-block-drop/types.js +6 -0
- package/build/components/use-on-block-drop/types.js.map +1 -0
- package/build/hooks/align.js +1 -3
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/align.native.js +1 -7
- package/build/hooks/align.native.js.map +1 -1
- package/build/hooks/border.js +1 -0
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/dimensions.js +32 -4
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/font-size.js +61 -0
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/layout.js +4 -3
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/margin.js +24 -17
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +20 -12
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/style.js +126 -4
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/use-typography-props.js +17 -3
- package/build/hooks/use-typography-props.js.map +1 -1
- package/build/hooks/utils.js +8 -7
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/constrained.js +0 -1
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/flex.js +1 -1
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +63 -45
- package/build/store/actions.js.map +1 -1
- package/build/store/array.js +1 -7
- package/build/store/array.js.map +1 -1
- package/build/store/defaults.js +3 -0
- package/build/store/defaults.js.map +1 -1
- package/build/store/reducer.js +31 -15
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +46 -29
- package/build/store/selectors.js.map +1 -1
- package/build/utils/math.js +14 -0
- package/build/utils/math.js.map +1 -1
- package/build/utils/pre-parse-patterns.js +19 -2
- package/build/utils/pre-parse-patterns.js.map +1 -1
- package/build-module/components/alignment-control/ui.js +1 -1
- package/build-module/components/alignment-control/ui.js.map +1 -1
- package/build-module/components/block-alignment-control/constants.js +1 -1
- package/build-module/components/block-alignment-control/constants.js.map +1 -1
- package/build-module/components/block-alignment-matrix-control/index.js +1 -1
- package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build-module/components/block-compare/index.js +2 -3
- package/build-module/components/block-compare/index.js.map +1 -1
- package/build-module/components/block-draggable/draggable-chip.js +7 -3
- package/build-module/components/block-draggable/draggable-chip.js.map +1 -1
- package/build-module/components/block-edit/index.js +4 -2
- package/build-module/components/block-edit/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +4 -4
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block-list-compact.native.js +1 -0
- package/build-module/components/block-list/block-list-compact.native.js.map +1 -1
- package/build-module/components/block-list/block.js +75 -15
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +80 -13
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +8 -24
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-lock/modal.js +10 -8
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-parent-selector/index.js +3 -3
- package/build-module/components/block-parent-selector/index.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +5 -4
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-popover/drop-zone.js +70 -0
- package/build-module/components/block-popover/drop-zone.js.map +1 -0
- package/build-module/components/block-popover/inbetween.js +2 -1
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +4 -2
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +1 -1
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-preview/index.js +8 -12
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-preview/live.js +3 -6
- package/build-module/components/block-preview/live.js.map +1 -1
- package/build-module/components/block-selection-clearer/index.js +9 -1
- package/build-module/components/block-selection-clearer/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +20 -19
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/index.js +19 -44
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-switcher/index.js +2 -7
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-switcher/preview-block-popover.js +1 -1
- package/build-module/components/block-switcher/preview-block-popover.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +4 -4
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/back-compat.js +2 -1
- package/build-module/components/block-tools/back-compat.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +54 -16
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +15 -3
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/block-vertical-alignment-control/ui.js +1 -1
- package/build-module/components/block-vertical-alignment-control/ui.js.map +1 -1
- package/build-module/components/border-radius-control/all-input-control.js +2 -1
- package/build-module/components/border-radius-control/all-input-control.js.map +1 -1
- package/build-module/components/border-radius-control/index.js +2 -1
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/border-radius-control/input-controls.js +2 -1
- package/build-module/components/border-radius-control/input-controls.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +2 -2
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +3 -3
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/duotone-control/index.js +1 -1
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +245 -0
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -0
- package/build-module/components/font-sizes/index.js +1 -0
- package/build-module/components/font-sizes/index.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +2 -2
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/iframe/index.js +1 -1
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/constants.js +1 -1
- package/build-module/components/image-editor/constants.js.map +1 -1
- package/build-module/components/index.js +0 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +6 -2
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js +3 -2
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +148 -81
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-insertion-point.js +2 -6
- package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build-module/components/inserter/menu.js +10 -3
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/search-items.js +23 -3
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/inserter-draggable-blocks/index.js +4 -2
- package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build-module/components/line-height-control/index.js +2 -1
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +2 -1
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js +1 -14
- package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +1 -1
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/preview-options/index.js +2 -3
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar/index.js +1 -1
- package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +1 -1
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/spacing-sizes-control/all-input-control.js +6 -2
- package/build-module/components/spacing-sizes-control/all-input-control.js.map +1 -1
- package/build-module/components/spacing-sizes-control/axial-input-controls.js +6 -2
- package/build-module/components/spacing-sizes-control/axial-input-controls.js.map +1 -1
- package/build-module/components/spacing-sizes-control/index.js +6 -2
- package/build-module/components/spacing-sizes-control/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls.js +6 -2
- package/build-module/components/spacing-sizes-control/input-controls.js.map +1 -1
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +44 -8
- package/build-module/components/spacing-sizes-control/spacing-input-control.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/use-block-drop-zone/index.js +98 -58
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.js +12 -12
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/types.js +2 -0
- package/build-module/components/use-on-block-drop/types.js.map +1 -0
- package/build-module/hooks/align.js +1 -2
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/align.native.js +1 -6
- package/build-module/hooks/align.native.js.map +1 -1
- package/build-module/hooks/border.js +1 -0
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/dimensions.js +32 -4
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/font-size.js +60 -1
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/layout.js +5 -4
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/margin.js +25 -18
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +21 -13
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/style.js +124 -3
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/use-typography-props.js +17 -4
- package/build-module/hooks/use-typography-props.js.map +1 -1
- package/build-module/hooks/utils.js +8 -8
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/constrained.js +0 -1
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/flex.js +1 -1
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +59 -42
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/array.js +1 -6
- package/build-module/store/array.js.map +1 -1
- package/build-module/store/defaults.js +3 -0
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/reducer.js +32 -16
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +47 -30
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/math.js +12 -0
- package/build-module/utils/math.js.map +1 -1
- package/build-module/utils/pre-parse-patterns.js +19 -2
- package/build-module/utils/pre-parse-patterns.js.map +1 -1
- package/build-style/style-rtl.css +292 -206
- package/build-style/style.css +288 -202
- package/package.json +29 -28
- package/src/components/alignment-control/ui.js +1 -1
- package/src/components/block-alignment-control/constants.js +1 -1
- package/src/components/block-alignment-matrix-control/index.js +1 -1
- package/src/components/block-breadcrumb/test/__snapshots__/index.js.snap +13 -11
- package/src/components/block-breadcrumb/test/index.js +2 -2
- package/src/components/block-compare/index.js +3 -2
- package/src/components/block-draggable/draggable-chip.js +4 -2
- package/src/components/block-edit/index.js +2 -1
- package/src/components/block-inspector/index.js +8 -7
- package/src/components/block-list/block-list-compact.native.js +1 -0
- package/src/components/block-list/block.js +113 -7
- package/src/components/block-list/block.native.js +123 -9
- package/src/components/block-list/style.scss +93 -126
- package/src/components/block-list/use-in-between-inserter.js +8 -19
- package/src/components/block-lock/modal.js +12 -7
- package/src/components/block-mover/stories/index.js +1 -1
- package/src/components/block-mover/style.scss +35 -1
- package/src/components/block-parent-selector/index.js +3 -3
- package/src/components/block-patterns-list/index.js +9 -5
- package/src/components/block-patterns-list/style.scss +7 -3
- package/src/components/block-popover/README.md +8 -0
- package/src/components/block-popover/drop-zone.js +63 -0
- package/src/components/block-popover/inbetween.js +1 -0
- package/src/components/block-popover/index.js +3 -1
- package/src/components/block-popover/style.scss +17 -5
- package/src/components/block-preview/auto.js +1 -1
- package/src/components/block-preview/index.js +15 -11
- package/src/components/block-preview/live.js +2 -7
- package/src/components/block-preview/test/index.js +1 -7
- package/src/components/block-selection-clearer/index.js +7 -2
- package/src/components/block-selection-clearer/test/index.js +118 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +29 -18
- package/src/components/block-settings-menu/test/block-mode-toggle.js +17 -17
- package/src/components/block-styles/index.js +26 -49
- package/src/components/block-switcher/index.js +2 -7
- package/src/components/block-switcher/preview-block-popover.js +1 -1
- package/src/components/block-switcher/test/index.js +2 -2
- package/src/components/block-toolbar/index.js +4 -6
- package/src/components/block-toolbar/style.scss +38 -14
- package/src/components/block-tools/back-compat.js +1 -0
- package/src/components/block-tools/insertion-point.js +49 -15
- package/src/components/block-tools/selected-block-popover.js +14 -1
- package/src/components/block-variation-picker/README.md +1 -1
- package/src/components/block-vertical-alignment-control/ui.js +1 -1
- package/src/components/border-radius-control/all-input-control.js +1 -0
- package/src/components/border-radius-control/index.js +1 -0
- package/src/components/border-radius-control/input-controls.js +1 -0
- package/src/components/border-radius-control/style.scss +15 -24
- package/src/components/button-block-appender/style.scss +4 -2
- package/src/components/color-palette/test/__snapshots__/control.js.snap +86 -104
- package/src/components/color-palette/test/control.js +11 -15
- package/src/components/colors-gradients/control.js +2 -2
- package/src/components/colors-gradients/panel-color-gradient-settings.js +3 -4
- package/src/components/colors-gradients/test/control.js +49 -77
- package/src/components/duotone-control/index.js +1 -1
- package/src/components/font-sizes/fluid-utils.js +296 -0
- package/src/components/font-sizes/index.js +1 -0
- package/src/components/font-sizes/test/fluid-utils.js +168 -0
- package/src/components/font-sizes/with-font-sizes.js +2 -3
- package/src/components/iframe/index.js +1 -1
- package/src/components/image-editor/constants.js +1 -1
- package/src/components/image-size-control/test/index.js +47 -60
- package/src/components/index.js +0 -1
- package/src/components/inner-blocks/index.js +5 -1
- package/src/components/inner-blocks/test/index.js +4 -0
- package/src/components/inner-blocks/use-inner-block-template-sync.js +3 -2
- package/src/components/inserter/block-patterns-tab.js +232 -98
- package/src/components/inserter/hooks/use-insertion-point.js +3 -11
- package/src/components/inserter/menu.js +15 -2
- package/src/components/inserter/search-items.js +23 -3
- package/src/components/inserter/style.scss +94 -9
- package/src/components/inserter/test/reusable-blocks-tab.js +6 -6
- package/src/components/inserter/test/search-items.js +6 -0
- package/src/components/inserter-draggable-blocks/index.js +12 -2
- package/src/components/inserter-list-item/style.scss +22 -1
- package/src/components/letter-spacing-control/README.md +55 -0
- package/src/components/line-height-control/index.js +1 -0
- package/src/components/link-control/README.md +3 -3
- package/src/components/link-control/test/index.js +1 -1
- package/src/components/list-view/drop-indicator.js +1 -0
- package/src/components/list-view/style.scss +1 -36
- package/src/components/list-view/use-list-view-drop-zone.js +4 -18
- package/src/components/media-replace-flow/index.js +1 -1
- package/src/components/media-replace-flow/test/index.js +69 -51
- package/src/components/panel-color-settings/test/index.js +4 -4
- package/src/components/preview-options/index.js +2 -2
- package/src/components/preview-options/style.scss +1 -1
- package/src/components/provider/test/use-block-sync.js +131 -165
- package/src/components/responsive-block-control/test/index.js +4 -4
- package/src/components/rich-text/format-toolbar/index.js +1 -1
- package/src/components/rich-text/format-toolbar-container.js +1 -1
- package/src/components/rich-text/use-paste-handler.js +1 -1
- package/src/components/spacing-sizes-control/all-input-control.js +4 -0
- package/src/components/spacing-sizes-control/axial-input-controls.js +4 -0
- package/src/components/spacing-sizes-control/index.js +4 -0
- package/src/components/spacing-sizes-control/input-controls.js +4 -0
- package/src/components/spacing-sizes-control/spacing-input-control.js +26 -3
- package/src/components/spacing-sizes-control/style.scss +27 -19
- package/src/components/url-input/index.js +1 -1
- package/src/components/use-block-drop-zone/index.js +136 -79
- package/src/components/use-block-drop-zone/test/index.js +333 -81
- package/src/components/use-on-block-drop/index.js +11 -12
- package/src/components/use-on-block-drop/types.ts +1 -0
- package/src/hooks/align.js +3 -2
- package/src/hooks/align.native.js +5 -8
- package/src/hooks/border.js +1 -0
- package/src/hooks/dimensions.js +32 -5
- package/src/hooks/font-size.js +76 -0
- package/src/hooks/layout.js +7 -9
- package/src/hooks/margin.js +20 -14
- package/src/hooks/padding.js +20 -16
- package/src/hooks/style.js +122 -3
- package/src/hooks/test/align.js +96 -72
- package/src/hooks/test/style.js +206 -1
- package/src/hooks/test/use-typography-props.js +22 -0
- package/src/hooks/use-typography-props.js +18 -3
- package/src/hooks/utils.js +10 -7
- package/src/layouts/constrained.js +0 -1
- package/src/layouts/flex.js +1 -1
- package/src/store/actions.js +24 -12
- package/src/store/array.js +1 -6
- package/src/store/defaults.js +3 -0
- package/src/store/reducer.js +31 -24
- package/src/store/selectors.js +28 -21
- package/src/store/test/actions.js +0 -9
- package/src/store/test/selectors.js +1 -1
- package/src/utils/math.js +17 -0
- package/src/utils/pre-parse-patterns.js +12 -7
- package/build/components/inserter/pattern-panel.js +0 -87
- package/build/components/inserter/pattern-panel.js.map +0 -1
- package/build-module/components/inserter/pattern-panel.js +0 -74
- package/build-module/components/inserter/pattern-panel.js.map +0 -1
- package/src/components/inserter/pattern-panel.js +0 -93
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-editor",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.4.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": "^7.
|
|
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": "^1.
|
|
58
|
-
"@wordpress/token-list": "^2.
|
|
59
|
-
"@wordpress/url": "^3.
|
|
60
|
-
"@wordpress/warning": "^2.
|
|
61
|
-
"@wordpress/wordcount": "^3.
|
|
36
|
+
"@wordpress/a11y": "^3.21.0",
|
|
37
|
+
"@wordpress/api-fetch": "^6.18.0",
|
|
38
|
+
"@wordpress/blob": "^3.21.0",
|
|
39
|
+
"@wordpress/blocks": "^11.20.0",
|
|
40
|
+
"@wordpress/components": "^22.0.0",
|
|
41
|
+
"@wordpress/compose": "^5.19.0",
|
|
42
|
+
"@wordpress/data": "^7.5.0",
|
|
43
|
+
"@wordpress/date": "^4.21.0",
|
|
44
|
+
"@wordpress/deprecated": "^3.21.0",
|
|
45
|
+
"@wordpress/dom": "^3.21.0",
|
|
46
|
+
"@wordpress/element": "^4.19.0",
|
|
47
|
+
"@wordpress/hooks": "^3.21.0",
|
|
48
|
+
"@wordpress/html-entities": "^3.21.0",
|
|
49
|
+
"@wordpress/i18n": "^4.21.0",
|
|
50
|
+
"@wordpress/icons": "^9.12.0",
|
|
51
|
+
"@wordpress/is-shallow-equal": "^4.21.0",
|
|
52
|
+
"@wordpress/keyboard-shortcuts": "^3.19.0",
|
|
53
|
+
"@wordpress/keycodes": "^3.21.0",
|
|
54
|
+
"@wordpress/notices": "^3.21.0",
|
|
55
|
+
"@wordpress/rich-text": "^5.19.0",
|
|
56
|
+
"@wordpress/shortcode": "^3.21.0",
|
|
57
|
+
"@wordpress/style-engine": "^1.4.0",
|
|
58
|
+
"@wordpress/token-list": "^2.21.0",
|
|
59
|
+
"@wordpress/url": "^3.22.0",
|
|
60
|
+
"@wordpress/warning": "^2.21.0",
|
|
61
|
+
"@wordpress/wordcount": "^3.21.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",
|
|
@@ -78,5 +79,5 @@
|
|
|
78
79
|
"publishConfig": {
|
|
79
80
|
"access": "public"
|
|
80
81
|
},
|
|
81
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "511f4cc1f0138641bc4394bc1cf36e833109c791"
|
|
82
83
|
}
|
|
@@ -24,7 +24,7 @@ function BlockAlignmentMatrixControl( props ) {
|
|
|
24
24
|
return (
|
|
25
25
|
<Dropdown
|
|
26
26
|
position="bottom right"
|
|
27
|
-
popoverProps={ {
|
|
27
|
+
popoverProps={ { variant: 'toolbar' } }
|
|
28
28
|
renderToggle={ ( { onToggle, isOpen } ) => {
|
|
29
29
|
const openOnArrowDown = ( event ) => {
|
|
30
30
|
if ( ! isOpen && event.keyCode === DOWN ) {
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`BlockBreadcrumb should render correctly 1`] = `
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
<li
|
|
10
|
-
aria-current="true"
|
|
11
|
-
class="block-editor-block-breadcrumb__current"
|
|
4
|
+
<div>
|
|
5
|
+
<ul
|
|
6
|
+
aria-label="Block breadcrumb"
|
|
7
|
+
class="block-editor-block-breadcrumb"
|
|
8
|
+
role="list"
|
|
12
9
|
>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
<li
|
|
11
|
+
aria-current="true"
|
|
12
|
+
class="block-editor-block-breadcrumb__current"
|
|
13
|
+
>
|
|
14
|
+
Document
|
|
15
|
+
</li>
|
|
16
|
+
</ul>
|
|
17
|
+
</div>
|
|
16
18
|
`;
|
|
@@ -12,7 +12,7 @@ describe( 'BlockBreadcrumb', () => {
|
|
|
12
12
|
it( 'should render correctly', () => {
|
|
13
13
|
const { container } = render( <BlockBreadcrumb /> );
|
|
14
14
|
|
|
15
|
-
expect( container
|
|
15
|
+
expect( container ).toMatchSnapshot();
|
|
16
16
|
} );
|
|
17
17
|
|
|
18
18
|
describe( 'Root label text', () => {
|
|
@@ -30,7 +30,7 @@ describe( 'BlockBreadcrumb', () => {
|
|
|
30
30
|
const rootLabelText = screen.getByText( 'Tuhinga' );
|
|
31
31
|
const rootLabelTextDefault = screen.queryByText( 'Document' );
|
|
32
32
|
|
|
33
|
-
expect( rootLabelTextDefault ).
|
|
33
|
+
expect( rootLabelTextDefault ).not.toBeInTheDocument();
|
|
34
34
|
expect( rootLabelText ).toBeInTheDocument();
|
|
35
35
|
} );
|
|
36
36
|
} );
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import classnames from 'classnames';
|
|
5
|
-
import { castArray } from 'lodash';
|
|
6
5
|
// diff doesn't tree-shake correctly, so we import from the individual
|
|
7
6
|
// module here, to avoid including too much of the library
|
|
8
7
|
import { diffChars } from 'diff/lib/diff/character';
|
|
@@ -44,7 +43,9 @@ function BlockCompare( {
|
|
|
44
43
|
|
|
45
44
|
function getConvertedContent( convertedBlock ) {
|
|
46
45
|
// The convertor may return an array of items or a single item.
|
|
47
|
-
const newBlocks =
|
|
46
|
+
const newBlocks = Array.isArray( convertedBlock )
|
|
47
|
+
? convertedBlock
|
|
48
|
+
: [ convertedBlock ];
|
|
48
49
|
|
|
49
50
|
// Get converted block details.
|
|
50
51
|
const newContent = newBlocks.map( ( item ) =>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { _n, sprintf } from '@wordpress/i18n';
|
|
4
|
+
import { __, _n, sprintf } from '@wordpress/i18n';
|
|
5
5
|
import { Flex, FlexItem } from '@wordpress/components';
|
|
6
6
|
import { dragHandle } from '@wordpress/icons';
|
|
7
7
|
|
|
@@ -10,7 +10,8 @@ import { dragHandle } from '@wordpress/icons';
|
|
|
10
10
|
*/
|
|
11
11
|
import BlockIcon from '../block-icon';
|
|
12
12
|
|
|
13
|
-
export default function BlockDraggableChip( { count, icon } ) {
|
|
13
|
+
export default function BlockDraggableChip( { count, icon, isPattern } ) {
|
|
14
|
+
const patternLabel = isPattern && __( 'Pattern' );
|
|
14
15
|
return (
|
|
15
16
|
<div className="block-editor-block-draggable-chip-wrapper">
|
|
16
17
|
<div
|
|
@@ -25,6 +26,7 @@ export default function BlockDraggableChip( { count, icon } ) {
|
|
|
25
26
|
{ icon ? (
|
|
26
27
|
<BlockIcon icon={ icon } />
|
|
27
28
|
) : (
|
|
29
|
+
patternLabel ||
|
|
28
30
|
sprintf(
|
|
29
31
|
/* translators: %d: Number of blocks. */
|
|
30
32
|
_n( '%d block', '%d blocks', count ),
|
|
@@ -20,11 +20,12 @@ import { BlockEditContextProvider, useBlockEditContext } from './context';
|
|
|
20
20
|
export { useBlockEditContext };
|
|
21
21
|
|
|
22
22
|
export default function BlockEdit( props ) {
|
|
23
|
-
const { name, isSelected, clientId } = props;
|
|
23
|
+
const { name, isSelected, clientId, __unstableLayoutClassNames } = props;
|
|
24
24
|
const context = {
|
|
25
25
|
name,
|
|
26
26
|
isSelected,
|
|
27
27
|
clientId,
|
|
28
|
+
__unstableLayoutClassNames,
|
|
28
29
|
};
|
|
29
30
|
return (
|
|
30
31
|
<BlockEditContextProvider
|
|
@@ -40,6 +40,7 @@ function useContentBlocks( blockTypes, block ) {
|
|
|
40
40
|
const contenBlocksObjectAux = useMemo( () => {
|
|
41
41
|
return blockTypes.reduce( ( result, blockType ) => {
|
|
42
42
|
if (
|
|
43
|
+
blockType.name !== 'core/list-item' &&
|
|
43
44
|
Object.entries( blockType.attributes ).some(
|
|
44
45
|
( [ , { __experimentalRole } ] ) =>
|
|
45
46
|
__experimentalRole === 'content'
|
|
@@ -143,6 +144,7 @@ const BlockInspector = ( { showNoBlockSelectedMessage = true } ) => {
|
|
|
143
144
|
getSelectedBlockCount,
|
|
144
145
|
getBlockName,
|
|
145
146
|
__unstableGetContentLockingParent,
|
|
147
|
+
getTemplateLock,
|
|
146
148
|
} = select( blockEditorStore );
|
|
147
149
|
|
|
148
150
|
const _selectedBlockClientId = getSelectedBlockClientId();
|
|
@@ -156,9 +158,11 @@ const BlockInspector = ( { showNoBlockSelectedMessage = true } ) => {
|
|
|
156
158
|
selectedBlockClientId: _selectedBlockClientId,
|
|
157
159
|
selectedBlockName: _selectedBlockName,
|
|
158
160
|
blockType: _blockType,
|
|
159
|
-
topLevelLockedBlock:
|
|
160
|
-
_selectedBlockClientId
|
|
161
|
-
|
|
161
|
+
topLevelLockedBlock:
|
|
162
|
+
__unstableGetContentLockingParent( _selectedBlockClientId ) ||
|
|
163
|
+
( getTemplateLock( _selectedBlockClientId ) === 'contentOnly'
|
|
164
|
+
? _selectedBlockClientId
|
|
165
|
+
: undefined ),
|
|
162
166
|
};
|
|
163
167
|
}, [] );
|
|
164
168
|
|
|
@@ -241,10 +245,7 @@ const BlockInspectorSingleBlock = ( { clientId, blockName } ) => {
|
|
|
241
245
|
{ hasBlockStyles && (
|
|
242
246
|
<div>
|
|
243
247
|
<PanelBody title={ __( 'Styles' ) }>
|
|
244
|
-
<BlockStyles
|
|
245
|
-
scope="core/block-inspector"
|
|
246
|
-
clientId={ clientId }
|
|
247
|
-
/>
|
|
248
|
+
<BlockStyles clientId={ clientId } />
|
|
248
249
|
{ hasBlockSupport(
|
|
249
250
|
blockName,
|
|
250
251
|
'defaultStylePicker',
|
|
@@ -50,6 +50,7 @@ function BlockListCompact( props ) {
|
|
|
50
50
|
{ blockClientIds.map( ( currentClientId ) => (
|
|
51
51
|
<BlockListBlock
|
|
52
52
|
clientId={ currentClientId }
|
|
53
|
+
rootClientId={ rootClientId }
|
|
53
54
|
key={ currentClientId }
|
|
54
55
|
marginHorizontal={ marginHorizontal }
|
|
55
56
|
marginVertical={ marginVertical }
|
|
@@ -84,6 +84,7 @@ function BlockListBlock( {
|
|
|
84
84
|
isSelected,
|
|
85
85
|
isSelectionEnabled,
|
|
86
86
|
className,
|
|
87
|
+
__unstableLayoutClassNames: layoutClassNames,
|
|
87
88
|
name,
|
|
88
89
|
isValid,
|
|
89
90
|
attributes,
|
|
@@ -146,6 +147,7 @@ function BlockListBlock( {
|
|
|
146
147
|
clientId={ clientId }
|
|
147
148
|
isSelectionEnabled={ isSelectionEnabled }
|
|
148
149
|
toggleSelection={ toggleSelection }
|
|
150
|
+
__unstableLayoutClassNames={ layoutClassNames }
|
|
149
151
|
/>
|
|
150
152
|
);
|
|
151
153
|
|
|
@@ -296,7 +298,7 @@ const applyWithSelect = withSelect( ( select, { clientId, rootClientId } ) => {
|
|
|
296
298
|
};
|
|
297
299
|
} );
|
|
298
300
|
|
|
299
|
-
const applyWithDispatch = withDispatch( ( dispatch, ownProps,
|
|
301
|
+
const applyWithDispatch = withDispatch( ( dispatch, ownProps, registry ) => {
|
|
300
302
|
const {
|
|
301
303
|
updateBlockAttributes,
|
|
302
304
|
insertBlocks,
|
|
@@ -304,6 +306,9 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, { select } ) => {
|
|
|
304
306
|
replaceBlocks,
|
|
305
307
|
toggleSelection,
|
|
306
308
|
__unstableMarkLastChangeAsPersistent,
|
|
309
|
+
moveBlocksToPosition,
|
|
310
|
+
removeBlock,
|
|
311
|
+
selectBlock,
|
|
307
312
|
} = dispatch( blockEditorStore );
|
|
308
313
|
|
|
309
314
|
// Do not add new properties here, use `useDispatch` instead to avoid
|
|
@@ -311,7 +316,7 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, { select } ) => {
|
|
|
311
316
|
return {
|
|
312
317
|
setAttributes( newAttributes ) {
|
|
313
318
|
const { getMultiSelectedBlockClientIds } =
|
|
314
|
-
select( blockEditorStore );
|
|
319
|
+
registry.select( blockEditorStore );
|
|
315
320
|
const multiSelectedBlockClientIds =
|
|
316
321
|
getMultiSelectedBlockClientIds();
|
|
317
322
|
const { clientId } = ownProps;
|
|
@@ -327,26 +332,124 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, { select } ) => {
|
|
|
327
332
|
},
|
|
328
333
|
onInsertBlocksAfter( blocks ) {
|
|
329
334
|
const { clientId, rootClientId } = ownProps;
|
|
330
|
-
const { getBlockIndex } = select( blockEditorStore );
|
|
335
|
+
const { getBlockIndex } = registry.select( blockEditorStore );
|
|
331
336
|
const index = getBlockIndex( clientId );
|
|
332
337
|
insertBlocks( blocks, index + 1, rootClientId );
|
|
333
338
|
},
|
|
334
339
|
onMerge( forward ) {
|
|
335
340
|
const { clientId, rootClientId } = ownProps;
|
|
336
|
-
const {
|
|
337
|
-
|
|
341
|
+
const {
|
|
342
|
+
getPreviousBlockClientId,
|
|
343
|
+
getNextBlockClientId,
|
|
344
|
+
getBlock,
|
|
345
|
+
getBlockAttributes,
|
|
346
|
+
getBlockName,
|
|
347
|
+
getBlockOrder,
|
|
348
|
+
} = registry.select( blockEditorStore );
|
|
338
349
|
|
|
350
|
+
// For `Delete` or forward merge, we should do the exact same thing
|
|
351
|
+
// as `Backspace`, but from the other block.
|
|
339
352
|
if ( forward ) {
|
|
353
|
+
if ( rootClientId ) {
|
|
354
|
+
const nextRootClientId =
|
|
355
|
+
getNextBlockClientId( rootClientId );
|
|
356
|
+
|
|
357
|
+
if ( nextRootClientId ) {
|
|
358
|
+
// If there is a block that follows with the same parent
|
|
359
|
+
// block name and the same attributes, merge the inner
|
|
360
|
+
// blocks.
|
|
361
|
+
if (
|
|
362
|
+
getBlockName( rootClientId ) ===
|
|
363
|
+
getBlockName( nextRootClientId )
|
|
364
|
+
) {
|
|
365
|
+
const rootAttributes =
|
|
366
|
+
getBlockAttributes( rootClientId );
|
|
367
|
+
const previousRootAttributes =
|
|
368
|
+
getBlockAttributes( nextRootClientId );
|
|
369
|
+
|
|
370
|
+
if (
|
|
371
|
+
Object.keys( rootAttributes ).every(
|
|
372
|
+
( key ) =>
|
|
373
|
+
rootAttributes[ key ] ===
|
|
374
|
+
previousRootAttributes[ key ]
|
|
375
|
+
)
|
|
376
|
+
) {
|
|
377
|
+
registry.batch( () => {
|
|
378
|
+
moveBlocksToPosition(
|
|
379
|
+
getBlockOrder( nextRootClientId ),
|
|
380
|
+
nextRootClientId,
|
|
381
|
+
rootClientId
|
|
382
|
+
);
|
|
383
|
+
removeBlock( nextRootClientId, false );
|
|
384
|
+
} );
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
} else {
|
|
388
|
+
mergeBlocks( rootClientId, nextRootClientId );
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
340
394
|
const nextBlockClientId = getNextBlockClientId( clientId );
|
|
341
|
-
|
|
395
|
+
|
|
396
|
+
if ( ! nextBlockClientId ) {
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// Check if it's possibile to "unwrap" the following block
|
|
401
|
+
// before trying to merge.
|
|
402
|
+
const replacement = switchToBlockType(
|
|
403
|
+
getBlock( nextBlockClientId ),
|
|
404
|
+
'*'
|
|
405
|
+
);
|
|
406
|
+
|
|
407
|
+
if ( replacement && replacement.length ) {
|
|
408
|
+
replaceBlocks( nextBlockClientId, replacement );
|
|
409
|
+
} else {
|
|
342
410
|
mergeBlocks( clientId, nextBlockClientId );
|
|
343
411
|
}
|
|
344
412
|
} else {
|
|
345
413
|
const previousBlockClientId =
|
|
346
414
|
getPreviousBlockClientId( clientId );
|
|
415
|
+
|
|
347
416
|
if ( previousBlockClientId ) {
|
|
348
417
|
mergeBlocks( previousBlockClientId, clientId );
|
|
349
418
|
} else if ( rootClientId ) {
|
|
419
|
+
const previousRootClientId =
|
|
420
|
+
getPreviousBlockClientId( rootClientId );
|
|
421
|
+
|
|
422
|
+
// If there is a preceding block with the same parent block
|
|
423
|
+
// name and the same attributes, merge the inner blocks.
|
|
424
|
+
if (
|
|
425
|
+
previousRootClientId &&
|
|
426
|
+
getBlockName( rootClientId ) ===
|
|
427
|
+
getBlockName( previousRootClientId )
|
|
428
|
+
) {
|
|
429
|
+
const rootAttributes =
|
|
430
|
+
getBlockAttributes( rootClientId );
|
|
431
|
+
const previousRootAttributes =
|
|
432
|
+
getBlockAttributes( previousRootClientId );
|
|
433
|
+
|
|
434
|
+
if (
|
|
435
|
+
Object.keys( rootAttributes ).every(
|
|
436
|
+
( key ) =>
|
|
437
|
+
rootAttributes[ key ] ===
|
|
438
|
+
previousRootAttributes[ key ]
|
|
439
|
+
)
|
|
440
|
+
) {
|
|
441
|
+
registry.batch( () => {
|
|
442
|
+
moveBlocksToPosition(
|
|
443
|
+
getBlockOrder( rootClientId ),
|
|
444
|
+
rootClientId,
|
|
445
|
+
previousRootClientId
|
|
446
|
+
);
|
|
447
|
+
removeBlock( rootClientId, false );
|
|
448
|
+
} );
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
350
453
|
// Attempt to "unwrap" the block contents when there's no
|
|
351
454
|
// preceding block to merge with.
|
|
352
455
|
const replacement = switchToBlockType(
|
|
@@ -354,7 +457,10 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, { select } ) => {
|
|
|
354
457
|
'*'
|
|
355
458
|
);
|
|
356
459
|
if ( replacement && replacement.length ) {
|
|
357
|
-
|
|
460
|
+
registry.batch( () => {
|
|
461
|
+
replaceBlocks( rootClientId, replacement );
|
|
462
|
+
selectBlock( replacement[ 0 ].clientId, 0 );
|
|
463
|
+
} );
|
|
358
464
|
}
|
|
359
465
|
}
|
|
360
466
|
}
|
|
@@ -20,6 +20,7 @@ import { compose, withPreferredColorScheme } from '@wordpress/compose';
|
|
|
20
20
|
import {
|
|
21
21
|
getBlockType,
|
|
22
22
|
__experimentalGetAccessibleBlockLabel as getAccessibleBlockLabel,
|
|
23
|
+
switchToBlockType,
|
|
23
24
|
} from '@wordpress/blocks';
|
|
24
25
|
import { useSetting } from '@wordpress/block-editor';
|
|
25
26
|
|
|
@@ -41,7 +42,7 @@ function BlockForType( {
|
|
|
41
42
|
getBlockWidth,
|
|
42
43
|
insertBlocksAfter,
|
|
43
44
|
isSelected,
|
|
44
|
-
|
|
45
|
+
onMerge,
|
|
45
46
|
name,
|
|
46
47
|
onBlockFocus,
|
|
47
48
|
onChange,
|
|
@@ -87,7 +88,7 @@ function BlockForType( {
|
|
|
87
88
|
onFocus={ onBlockFocus }
|
|
88
89
|
onReplace={ onReplace }
|
|
89
90
|
insertBlocksAfter={ insertBlocksAfter }
|
|
90
|
-
mergeBlocks={
|
|
91
|
+
mergeBlocks={ onMerge }
|
|
91
92
|
// Block level styles.
|
|
92
93
|
wrapperProps={ wrapperProps }
|
|
93
94
|
// Inherited styles merged with block level styles.
|
|
@@ -407,31 +408,144 @@ export default compose( [
|
|
|
407
408
|
),
|
|
408
409
|
};
|
|
409
410
|
} ),
|
|
410
|
-
withDispatch( ( dispatch, ownProps,
|
|
411
|
+
withDispatch( ( dispatch, ownProps, registry ) => {
|
|
411
412
|
const {
|
|
412
413
|
insertBlocks,
|
|
413
414
|
mergeBlocks,
|
|
414
415
|
replaceBlocks,
|
|
415
416
|
selectBlock,
|
|
416
417
|
updateBlockAttributes,
|
|
418
|
+
moveBlocksToPosition,
|
|
419
|
+
removeBlock,
|
|
417
420
|
} = dispatch( blockEditorStore );
|
|
418
421
|
|
|
419
422
|
return {
|
|
420
|
-
|
|
421
|
-
const { clientId } = ownProps;
|
|
422
|
-
const {
|
|
423
|
-
|
|
424
|
-
|
|
423
|
+
onMerge( forward ) {
|
|
424
|
+
const { clientId, rootClientId } = ownProps;
|
|
425
|
+
const {
|
|
426
|
+
getPreviousBlockClientId,
|
|
427
|
+
getNextBlockClientId,
|
|
428
|
+
getBlock,
|
|
429
|
+
getBlockAttributes,
|
|
430
|
+
getBlockName,
|
|
431
|
+
getBlockOrder,
|
|
432
|
+
} = registry.select( blockEditorStore );
|
|
433
|
+
|
|
434
|
+
// For `Delete` or forward merge, we should do the exact same thing
|
|
435
|
+
// as `Backspace`, but from the other block.
|
|
425
436
|
if ( forward ) {
|
|
437
|
+
if ( rootClientId ) {
|
|
438
|
+
const nextRootClientId =
|
|
439
|
+
getNextBlockClientId( rootClientId );
|
|
440
|
+
|
|
441
|
+
if ( nextRootClientId ) {
|
|
442
|
+
// If there is a block that follows with the same parent
|
|
443
|
+
// block name and the same attributes, merge the inner
|
|
444
|
+
// blocks.
|
|
445
|
+
if (
|
|
446
|
+
getBlockName( rootClientId ) ===
|
|
447
|
+
getBlockName( nextRootClientId )
|
|
448
|
+
) {
|
|
449
|
+
const rootAttributes =
|
|
450
|
+
getBlockAttributes( rootClientId );
|
|
451
|
+
const previousRootAttributes =
|
|
452
|
+
getBlockAttributes( nextRootClientId );
|
|
453
|
+
|
|
454
|
+
if (
|
|
455
|
+
Object.keys( rootAttributes ).every(
|
|
456
|
+
( key ) =>
|
|
457
|
+
rootAttributes[ key ] ===
|
|
458
|
+
previousRootAttributes[ key ]
|
|
459
|
+
)
|
|
460
|
+
) {
|
|
461
|
+
registry.batch( () => {
|
|
462
|
+
moveBlocksToPosition(
|
|
463
|
+
getBlockOrder( nextRootClientId ),
|
|
464
|
+
nextRootClientId,
|
|
465
|
+
rootClientId
|
|
466
|
+
);
|
|
467
|
+
removeBlock( nextRootClientId, false );
|
|
468
|
+
} );
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
} else {
|
|
472
|
+
mergeBlocks( rootClientId, nextRootClientId );
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
426
478
|
const nextBlockClientId = getNextBlockClientId( clientId );
|
|
427
|
-
|
|
479
|
+
|
|
480
|
+
if ( ! nextBlockClientId ) {
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// Check if it's possibile to "unwrap" the following block
|
|
485
|
+
// before trying to merge.
|
|
486
|
+
const replacement = switchToBlockType(
|
|
487
|
+
getBlock( nextBlockClientId ),
|
|
488
|
+
'*'
|
|
489
|
+
);
|
|
490
|
+
|
|
491
|
+
if ( replacement && replacement.length ) {
|
|
492
|
+
replaceBlocks( nextBlockClientId, replacement );
|
|
493
|
+
} else {
|
|
428
494
|
mergeBlocks( clientId, nextBlockClientId );
|
|
429
495
|
}
|
|
430
496
|
} else {
|
|
431
497
|
const previousBlockClientId =
|
|
432
498
|
getPreviousBlockClientId( clientId );
|
|
499
|
+
|
|
433
500
|
if ( previousBlockClientId ) {
|
|
434
501
|
mergeBlocks( previousBlockClientId, clientId );
|
|
502
|
+
} else if ( rootClientId ) {
|
|
503
|
+
const previousRootClientId =
|
|
504
|
+
getPreviousBlockClientId( rootClientId );
|
|
505
|
+
|
|
506
|
+
// If there is a preceding block with the same parent block
|
|
507
|
+
// name and the same attributes, merge the inner blocks.
|
|
508
|
+
if (
|
|
509
|
+
previousRootClientId &&
|
|
510
|
+
getBlockName( rootClientId ) ===
|
|
511
|
+
getBlockName( previousRootClientId )
|
|
512
|
+
) {
|
|
513
|
+
const rootAttributes =
|
|
514
|
+
getBlockAttributes( rootClientId );
|
|
515
|
+
const previousRootAttributes =
|
|
516
|
+
getBlockAttributes( previousRootClientId );
|
|
517
|
+
|
|
518
|
+
if (
|
|
519
|
+
Object.keys( rootAttributes ).every(
|
|
520
|
+
( key ) =>
|
|
521
|
+
rootAttributes[ key ] ===
|
|
522
|
+
previousRootAttributes[ key ]
|
|
523
|
+
)
|
|
524
|
+
) {
|
|
525
|
+
registry.batch( () => {
|
|
526
|
+
moveBlocksToPosition(
|
|
527
|
+
getBlockOrder( rootClientId ),
|
|
528
|
+
rootClientId,
|
|
529
|
+
previousRootClientId
|
|
530
|
+
);
|
|
531
|
+
removeBlock( rootClientId, false );
|
|
532
|
+
} );
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
// Attempt to "unwrap" the block contents when there's no
|
|
538
|
+
// preceding block to merge with.
|
|
539
|
+
const replacement = switchToBlockType(
|
|
540
|
+
getBlock( rootClientId ),
|
|
541
|
+
'*'
|
|
542
|
+
);
|
|
543
|
+
if ( replacement && replacement.length ) {
|
|
544
|
+
registry.batch( () => {
|
|
545
|
+
replaceBlocks( rootClientId, replacement );
|
|
546
|
+
selectBlock( replacement[ 0 ].clientId, 0 );
|
|
547
|
+
} );
|
|
548
|
+
}
|
|
435
549
|
}
|
|
436
550
|
}
|
|
437
551
|
},
|