@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
|
@@ -42,7 +42,7 @@ function InlineSelectionToolbar( {
|
|
|
42
42
|
function InlineToolbar( { popoverAnchor } ) {
|
|
43
43
|
return (
|
|
44
44
|
<Popover
|
|
45
|
-
|
|
45
|
+
placement="top"
|
|
46
46
|
focusOnMount={ false }
|
|
47
47
|
anchor={ popoverAnchor }
|
|
48
48
|
className="block-editor-rich-text__inline-format-toolbar"
|
|
@@ -255,7 +255,7 @@ export function usePasteHandler( props ) {
|
|
|
255
255
|
|
|
256
256
|
/**
|
|
257
257
|
* Normalizes a given string of HTML to remove the Windows-specific "Fragment"
|
|
258
|
-
* comments and any
|
|
258
|
+
* comments and any preceding and trailing content.
|
|
259
259
|
*
|
|
260
260
|
* @param {string} html the html to be normalized
|
|
261
261
|
* @return {string} the normalized html
|
|
@@ -16,6 +16,8 @@ export default function AllInputControl( {
|
|
|
16
16
|
spacingSizes,
|
|
17
17
|
type,
|
|
18
18
|
minimumCustomValue,
|
|
19
|
+
onMouseOver,
|
|
20
|
+
onMouseOut,
|
|
19
21
|
} ) {
|
|
20
22
|
const allValue = getAllRawValue( values );
|
|
21
23
|
const hasValues = isValuesDefined( values );
|
|
@@ -35,6 +37,8 @@ export default function AllInputControl( {
|
|
|
35
37
|
isMixed={ isMixed }
|
|
36
38
|
type={ type }
|
|
37
39
|
minimumCustomValue={ minimumCustomValue }
|
|
40
|
+
onMouseOver={ onMouseOver }
|
|
41
|
+
onMouseOut={ onMouseOut }
|
|
38
42
|
/>
|
|
39
43
|
);
|
|
40
44
|
}
|
|
@@ -13,6 +13,8 @@ export default function AxialInputControls( {
|
|
|
13
13
|
spacingSizes,
|
|
14
14
|
type,
|
|
15
15
|
minimumCustomValue,
|
|
16
|
+
onMouseOver,
|
|
17
|
+
onMouseOut,
|
|
16
18
|
} ) {
|
|
17
19
|
const createHandleOnChange = ( side ) => ( next ) => {
|
|
18
20
|
if ( ! onChange ) {
|
|
@@ -54,6 +56,8 @@ export default function AxialInputControls( {
|
|
|
54
56
|
spacingSizes={ spacingSizes }
|
|
55
57
|
type={ type }
|
|
56
58
|
minimumCustomValue={ minimumCustomValue }
|
|
59
|
+
onMouseOver={ onMouseOver }
|
|
60
|
+
onMouseOut={ onMouseOut }
|
|
57
61
|
/>
|
|
58
62
|
);
|
|
59
63
|
} ) }
|
|
@@ -29,6 +29,8 @@ export default function SpacingSizesControl( {
|
|
|
29
29
|
splitOnAxis = false,
|
|
30
30
|
useSelect,
|
|
31
31
|
minimumCustomValue = 0,
|
|
32
|
+
onMouseOver,
|
|
33
|
+
onMouseOut,
|
|
32
34
|
} ) {
|
|
33
35
|
const spacingSizes = [
|
|
34
36
|
{ name: 0, slug: '0', size: 0 },
|
|
@@ -70,6 +72,8 @@ export default function SpacingSizesControl( {
|
|
|
70
72
|
useSelect,
|
|
71
73
|
type: label,
|
|
72
74
|
minimumCustomValue,
|
|
75
|
+
onMouseOver,
|
|
76
|
+
onMouseOut,
|
|
73
77
|
};
|
|
74
78
|
|
|
75
79
|
return (
|
|
@@ -11,6 +11,8 @@ export default function BoxInputControls( {
|
|
|
11
11
|
spacingSizes,
|
|
12
12
|
type,
|
|
13
13
|
minimumCustomValue,
|
|
14
|
+
onMouseOver,
|
|
15
|
+
onMouseOut,
|
|
14
16
|
} ) {
|
|
15
17
|
// Filter sides if custom configuration provided, maintaining default order.
|
|
16
18
|
const filteredSides = sides?.length
|
|
@@ -38,6 +40,8 @@ export default function BoxInputControls( {
|
|
|
38
40
|
spacingSizes={ spacingSizes }
|
|
39
41
|
type={ type }
|
|
40
42
|
minimumCustomValue={ minimumCustomValue }
|
|
43
|
+
onMouseOver={ onMouseOver }
|
|
44
|
+
onMouseOut={ onMouseOut }
|
|
41
45
|
/>
|
|
42
46
|
);
|
|
43
47
|
} ) }
|
|
@@ -34,6 +34,15 @@ import {
|
|
|
34
34
|
isValueSpacingPreset,
|
|
35
35
|
} from './utils';
|
|
36
36
|
|
|
37
|
+
const CUSTOM_VALUE_SETTINGS = {
|
|
38
|
+
px: { max: 300, steps: 1 },
|
|
39
|
+
'%': { max: 100, steps: 1 },
|
|
40
|
+
vw: { max: 100, steps: 1 },
|
|
41
|
+
vh: { max: 100, steps: 1 },
|
|
42
|
+
em: { max: 10, steps: 0.1 },
|
|
43
|
+
rm: { max: 10, steps: 0.1 },
|
|
44
|
+
};
|
|
45
|
+
|
|
37
46
|
export default function SpacingInputControl( {
|
|
38
47
|
spacingSizes,
|
|
39
48
|
value,
|
|
@@ -42,6 +51,8 @@ export default function SpacingInputControl( {
|
|
|
42
51
|
isMixed = false,
|
|
43
52
|
type,
|
|
44
53
|
minimumCustomValue,
|
|
54
|
+
onMouseOver,
|
|
55
|
+
onMouseOut,
|
|
45
56
|
} ) {
|
|
46
57
|
// Treat value as a preset value if the passed in value matches the value of one of the spacingSizes.
|
|
47
58
|
value = getPresetValueFromCustomValue( value, spacingSizes );
|
|
@@ -107,7 +118,7 @@ export default function SpacingInputControl( {
|
|
|
107
118
|
const customTooltipContent = ( newValue ) =>
|
|
108
119
|
value === undefined ? undefined : spacingSizes[ newValue ]?.name;
|
|
109
120
|
|
|
110
|
-
const customRangeValue =
|
|
121
|
+
const customRangeValue = parseFloat( currentValue, 10 );
|
|
111
122
|
|
|
112
123
|
const getNewCustomValue = ( newSize ) => {
|
|
113
124
|
const isNumeric = ! isNaN( parseFloat( newSize ) );
|
|
@@ -209,6 +220,8 @@ export default function SpacingInputControl( {
|
|
|
209
220
|
{ showCustomValueControl && (
|
|
210
221
|
<>
|
|
211
222
|
<UnitControl
|
|
223
|
+
onMouseOver={ onMouseOver }
|
|
224
|
+
onMouseOut={ onMouseOut }
|
|
212
225
|
onChange={ ( newSize ) =>
|
|
213
226
|
onChange( getNewCustomValue( newSize ) )
|
|
214
227
|
}
|
|
@@ -220,13 +233,18 @@ export default function SpacingInputControl( {
|
|
|
220
233
|
label={ ariaLabel }
|
|
221
234
|
hideLabelFromVision={ true }
|
|
222
235
|
className="components-spacing-sizes-control__custom-value-input"
|
|
223
|
-
|
|
236
|
+
size={ '__unstable-large' }
|
|
224
237
|
/>
|
|
225
238
|
|
|
226
239
|
<RangeControl
|
|
240
|
+
onMouseOver={ onMouseOver }
|
|
241
|
+
onMouseOut={ onMouseOut }
|
|
227
242
|
value={ customRangeValue }
|
|
228
243
|
min={ 0 }
|
|
229
|
-
max={
|
|
244
|
+
max={ CUSTOM_VALUE_SETTINGS[ selectedUnit ]?.max ?? 10 }
|
|
245
|
+
step={
|
|
246
|
+
CUSTOM_VALUE_SETTINGS[ selectedUnit ]?.steps ?? 0.1
|
|
247
|
+
}
|
|
230
248
|
withInputField={ false }
|
|
231
249
|
onChange={ handleCustomValueSliderChange }
|
|
232
250
|
className="components-spacing-sizes-control__custom-value-range"
|
|
@@ -235,6 +253,8 @@ export default function SpacingInputControl( {
|
|
|
235
253
|
) }
|
|
236
254
|
{ showRangeControl && ! showCustomValueControl && (
|
|
237
255
|
<RangeControl
|
|
256
|
+
onMouseOver={ onMouseOver }
|
|
257
|
+
onMouseOut={ onMouseOut }
|
|
238
258
|
className="components-spacing-sizes-control__range-control"
|
|
239
259
|
value={ currentValue }
|
|
240
260
|
onChange={ ( newSize ) =>
|
|
@@ -279,6 +299,9 @@ export default function SpacingInputControl( {
|
|
|
279
299
|
label={ ariaLabel }
|
|
280
300
|
hideLabelFromVision={ true }
|
|
281
301
|
__nextUnconstrainedWidth={ true }
|
|
302
|
+
size={ '__unstable-large' }
|
|
303
|
+
onMouseOver={ onMouseOver }
|
|
304
|
+
onMouseOut={ onMouseOut }
|
|
282
305
|
/>
|
|
283
306
|
) }
|
|
284
307
|
</>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
display: grid;
|
|
3
3
|
grid-template-columns: auto 1fr auto;
|
|
4
4
|
align-items: center;
|
|
5
|
-
grid-template-rows:
|
|
5
|
+
grid-template-rows: 16px auto;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
.component-spacing-sizes-control {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
grid-column: 1 / 1;
|
|
28
28
|
justify-content: left;
|
|
29
29
|
height: $grid-unit-20;
|
|
30
|
-
margin-top: $grid-unit-
|
|
30
|
+
margin-top: $grid-unit-20;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
.components-spacing-sizes-control__side-label {
|
|
@@ -37,8 +37,9 @@
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
&.is-unlinked {
|
|
40
|
-
.components-range-control.components-spacing-sizes-control__range-control
|
|
41
|
-
|
|
40
|
+
.components-range-control.components-spacing-sizes-control__range-control,
|
|
41
|
+
.components-spacing-sizes-control__custom-value-input {
|
|
42
|
+
margin-top: $grid-unit-10;
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
|
|
@@ -60,12 +61,7 @@
|
|
|
60
61
|
grid-column: 2 / 2;
|
|
61
62
|
grid-row: 1 / 1;
|
|
62
63
|
justify-self: end;
|
|
63
|
-
|
|
64
|
-
&.is-small.has-icon {
|
|
65
|
-
padding: 0;
|
|
66
|
-
min-width: $icon-size;
|
|
67
|
-
height: $grid-unit-20;
|
|
68
|
-
}
|
|
64
|
+
margin-top: -4px;
|
|
69
65
|
}
|
|
70
66
|
|
|
71
67
|
.component-spacing-sizes-control__linked-button ~ .components-spacing-sizes-control__custom-toggle-all {
|
|
@@ -75,33 +71,44 @@
|
|
|
75
71
|
.components-spacing-sizes-control__custom-toggle-single {
|
|
76
72
|
grid-column: 3 / 3;
|
|
77
73
|
justify-self: end;
|
|
78
|
-
|
|
79
|
-
padding: 0;
|
|
80
|
-
min-width: $icon-size;
|
|
81
|
-
height: $grid-unit-20;
|
|
82
|
-
margin-top: $grid-unit-15;
|
|
83
|
-
}
|
|
74
|
+
margin-top: $grid-unit-15;
|
|
84
75
|
}
|
|
85
76
|
|
|
86
77
|
.component-spacing-sizes-control__linked-button {
|
|
87
78
|
grid-column: 3 / 3;
|
|
88
79
|
grid-row: 1 / 1;
|
|
89
80
|
justify-self: end;
|
|
81
|
+
line-height: 0;
|
|
82
|
+
margin-top: -4px;
|
|
90
83
|
}
|
|
91
84
|
|
|
92
85
|
.components-spacing-sizes-control__custom-value-range {
|
|
93
86
|
grid-column: span 2;
|
|
94
|
-
margin-left: $grid-unit-
|
|
95
|
-
|
|
87
|
+
margin-left: $grid-unit-20;
|
|
88
|
+
margin-top: 8px;
|
|
96
89
|
}
|
|
97
90
|
|
|
98
91
|
.components-spacing-sizes-control__custom-value-input {
|
|
99
92
|
width: 124px;
|
|
93
|
+
margin-top: 8px;
|
|
94
|
+
grid-column: 1;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.components-range-control {
|
|
98
|
+
height: 40px;
|
|
99
|
+
/* Vertically center the RangeControl until it has true 40px height. */
|
|
100
|
+
display: flex;
|
|
101
|
+
align-items: center;
|
|
102
|
+
|
|
103
|
+
> .components-base-control__field {
|
|
104
|
+
/* Fixes RangeControl contents when the outer wrapper is flex */
|
|
105
|
+
flex: 1;
|
|
106
|
+
}
|
|
100
107
|
}
|
|
101
108
|
|
|
102
109
|
.components-spacing-sizes-control__range-control {
|
|
103
110
|
grid-column: span 3;
|
|
104
|
-
|
|
111
|
+
margin-top: 8px;
|
|
105
112
|
}
|
|
106
113
|
|
|
107
114
|
.components-range-control__mark {
|
|
@@ -125,5 +132,6 @@
|
|
|
125
132
|
|
|
126
133
|
.components-spacing-sizes-control__custom-select-control {
|
|
127
134
|
grid-column: span 3;
|
|
135
|
+
margin-top: $grid-unit-10;
|
|
128
136
|
}
|
|
129
137
|
}
|
|
@@ -543,7 +543,7 @@ class URLInput extends Component {
|
|
|
543
543
|
!! suggestions.length
|
|
544
544
|
) {
|
|
545
545
|
return (
|
|
546
|
-
<Popover
|
|
546
|
+
<Popover placement="bottom" focusOnMount={ false }>
|
|
547
547
|
<div
|
|
548
548
|
{ ...suggestionsListProps }
|
|
549
549
|
className={ classnames(
|
|
@@ -8,15 +8,20 @@ import {
|
|
|
8
8
|
__experimentalUseDropZone as useDropZone,
|
|
9
9
|
} from '@wordpress/compose';
|
|
10
10
|
import { isRTL } from '@wordpress/i18n';
|
|
11
|
+
import { isUnmodifiedDefaultBlock as getIsUnmodifiedDefaultBlock } from '@wordpress/blocks';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Internal dependencies
|
|
14
15
|
*/
|
|
15
16
|
import useOnBlockDrop from '../use-on-block-drop';
|
|
16
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
getDistanceToNearestEdge,
|
|
19
|
+
isPointContainedByRect,
|
|
20
|
+
} from '../../utils/math';
|
|
17
21
|
import { store as blockEditorStore } from '../../store';
|
|
18
22
|
|
|
19
23
|
/** @typedef {import('../../utils/math').WPPoint} WPPoint */
|
|
24
|
+
/** @typedef {import('../use-on-block-drop/types').WPDropOperation} WPDropOperation */
|
|
20
25
|
|
|
21
26
|
/**
|
|
22
27
|
* The orientation of a block list.
|
|
@@ -25,16 +30,31 @@ import { store as blockEditorStore } from '../../store';
|
|
|
25
30
|
*/
|
|
26
31
|
|
|
27
32
|
/**
|
|
28
|
-
*
|
|
29
|
-
* at.
|
|
33
|
+
* The insert position when dropping a block.
|
|
30
34
|
*
|
|
31
|
-
* @
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
* @typedef {'before'|'after'} WPInsertPosition
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @typedef {Object} WPBlockData
|
|
40
|
+
* @property {boolean} isUnmodifiedDefaultBlock Is the block unmodified default block.
|
|
41
|
+
* @property {() => DOMRect} getBoundingClientRect Get the bounding client rect of the block.
|
|
42
|
+
* @property {number} blockIndex The index of the block.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Get the drop target position from a given drop point and the orientation.
|
|
34
47
|
*
|
|
35
|
-
* @
|
|
48
|
+
* @param {WPBlockData[]} blocksData The block data list.
|
|
49
|
+
* @param {WPPoint} position The position of the item being dragged.
|
|
50
|
+
* @param {WPBlockListOrientation} orientation The orientation of the block list.
|
|
51
|
+
* @return {[number, WPDropOperation]} The drop target position.
|
|
36
52
|
*/
|
|
37
|
-
export function
|
|
53
|
+
export function getDropTargetPosition(
|
|
54
|
+
blocksData,
|
|
55
|
+
position,
|
|
56
|
+
orientation = 'vertical'
|
|
57
|
+
) {
|
|
38
58
|
const allowedEdges =
|
|
39
59
|
orientation === 'horizontal'
|
|
40
60
|
? [ 'left', 'right' ]
|
|
@@ -42,49 +62,67 @@ export function getNearestBlockIndex( elements, position, orientation ) {
|
|
|
42
62
|
|
|
43
63
|
const isRightToLeft = isRTL();
|
|
44
64
|
|
|
45
|
-
let
|
|
46
|
-
let
|
|
47
|
-
|
|
48
|
-
elements.forEach( ( element, index ) => {
|
|
49
|
-
const rect = element.getBoundingClientRect();
|
|
50
|
-
const [ distance, edge ] = getDistanceToNearestEdge(
|
|
51
|
-
position,
|
|
52
|
-
rect,
|
|
53
|
-
allowedEdges
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
if ( candidateDistance === undefined || distance < candidateDistance ) {
|
|
57
|
-
// If the user is dropping to the trailing edge of the block
|
|
58
|
-
// add 1 to the index to represent dragging after.
|
|
59
|
-
// Take RTL languages into account where the left edge is
|
|
60
|
-
// the trailing edge.
|
|
61
|
-
const isTrailingEdge =
|
|
62
|
-
edge === 'bottom' ||
|
|
63
|
-
( ! isRightToLeft && edge === 'right' ) ||
|
|
64
|
-
( isRightToLeft && edge === 'left' );
|
|
65
|
-
const offset = isTrailingEdge ? 1 : 0;
|
|
66
|
-
|
|
67
|
-
// Update the currently known best candidate.
|
|
68
|
-
candidateDistance = distance;
|
|
69
|
-
candidateIndex = index + offset;
|
|
70
|
-
}
|
|
71
|
-
} );
|
|
65
|
+
let nearestIndex = 0;
|
|
66
|
+
let insertPosition = 'before';
|
|
67
|
+
let minDistance = Infinity;
|
|
72
68
|
|
|
73
|
-
|
|
74
|
-
}
|
|
69
|
+
blocksData.forEach(
|
|
70
|
+
( { isUnmodifiedDefaultBlock, getBoundingClientRect, blockIndex } ) => {
|
|
71
|
+
const rect = getBoundingClientRect();
|
|
75
72
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
73
|
+
let [ distance, edge ] = getDistanceToNearestEdge(
|
|
74
|
+
position,
|
|
75
|
+
rect,
|
|
76
|
+
allowedEdges
|
|
77
|
+
);
|
|
78
|
+
// Prioritize the element if the point is inside of an unmodified default block.
|
|
79
|
+
if (
|
|
80
|
+
isUnmodifiedDefaultBlock &&
|
|
81
|
+
isPointContainedByRect( position, rect )
|
|
82
|
+
) {
|
|
83
|
+
distance = 0;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if ( distance < minDistance ) {
|
|
87
|
+
// Where the dropped block will be inserted on the nearest block.
|
|
88
|
+
insertPosition =
|
|
89
|
+
edge === 'bottom' ||
|
|
90
|
+
( ! isRightToLeft && edge === 'right' ) ||
|
|
91
|
+
( isRightToLeft && edge === 'left' )
|
|
92
|
+
? 'after'
|
|
93
|
+
: 'before';
|
|
94
|
+
|
|
95
|
+
// Update the currently known best candidate.
|
|
96
|
+
minDistance = distance;
|
|
97
|
+
nearestIndex = blockIndex;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
87
100
|
);
|
|
101
|
+
|
|
102
|
+
const adjacentIndex =
|
|
103
|
+
nearestIndex + ( insertPosition === 'after' ? 1 : -1 );
|
|
104
|
+
const isNearestBlockUnmodifiedDefaultBlock =
|
|
105
|
+
!! blocksData[ nearestIndex ]?.isUnmodifiedDefaultBlock;
|
|
106
|
+
const isAdjacentBlockUnmodifiedDefaultBlock =
|
|
107
|
+
!! blocksData[ adjacentIndex ]?.isUnmodifiedDefaultBlock;
|
|
108
|
+
|
|
109
|
+
// If both blocks are not unmodified default blocks then just insert between them.
|
|
110
|
+
if (
|
|
111
|
+
! isNearestBlockUnmodifiedDefaultBlock &&
|
|
112
|
+
! isAdjacentBlockUnmodifiedDefaultBlock
|
|
113
|
+
) {
|
|
114
|
+
// If the user is dropping to the trailing edge of the block
|
|
115
|
+
// add 1 to the index to represent dragging after.
|
|
116
|
+
const insertionIndex =
|
|
117
|
+
insertPosition === 'after' ? nearestIndex + 1 : nearestIndex;
|
|
118
|
+
return [ insertionIndex, 'insert' ];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Otherwise, replace the nearest unmodified default block.
|
|
122
|
+
return [
|
|
123
|
+
isNearestBlockUnmodifiedDefaultBlock ? nearestIndex : adjacentIndex,
|
|
124
|
+
'replace',
|
|
125
|
+
];
|
|
88
126
|
}
|
|
89
127
|
|
|
90
128
|
/**
|
|
@@ -104,7 +142,10 @@ export default function useBlockDropZone( {
|
|
|
104
142
|
// an empty string to represent top-level blocks.
|
|
105
143
|
rootClientId: targetRootClientId = '',
|
|
106
144
|
} = {} ) {
|
|
107
|
-
const [
|
|
145
|
+
const [ dropTarget, setDropTarget ] = useState( {
|
|
146
|
+
index: null,
|
|
147
|
+
operation: 'insert',
|
|
148
|
+
} );
|
|
108
149
|
|
|
109
150
|
const isDisabled = useSelect(
|
|
110
151
|
( select ) => {
|
|
@@ -125,40 +166,58 @@ export default function useBlockDropZone( {
|
|
|
125
166
|
[ targetRootClientId ]
|
|
126
167
|
);
|
|
127
168
|
|
|
128
|
-
const { getBlockListSettings } =
|
|
169
|
+
const { getBlockListSettings, getBlocks, getBlockIndex } =
|
|
170
|
+
useSelect( blockEditorStore );
|
|
129
171
|
const { showInsertionPoint, hideInsertionPoint } =
|
|
130
172
|
useDispatch( blockEditorStore );
|
|
131
173
|
|
|
132
|
-
const onBlockDrop = useOnBlockDrop( targetRootClientId,
|
|
174
|
+
const onBlockDrop = useOnBlockDrop( targetRootClientId, dropTarget.index, {
|
|
175
|
+
operation: dropTarget.operation,
|
|
176
|
+
} );
|
|
133
177
|
const throttled = useThrottle(
|
|
134
|
-
useCallback(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
setTargetBlockIndex( targetIndex === undefined ? 0 : targetIndex );
|
|
146
|
-
|
|
147
|
-
if ( targetIndex !== undefined ) {
|
|
148
|
-
const nextBlock = blockElements[ targetIndex ];
|
|
149
|
-
const previousBlock = blockElements[ targetIndex - 1 ];
|
|
150
|
-
|
|
151
|
-
// Don't show the insertion point when it's near an empty paragraph block.
|
|
152
|
-
if (
|
|
153
|
-
isEmptyParagraph( nextBlock ) ||
|
|
154
|
-
isEmptyParagraph( previousBlock )
|
|
155
|
-
) {
|
|
178
|
+
useCallback(
|
|
179
|
+
( event, ownerDocument ) => {
|
|
180
|
+
const blocks = getBlocks( targetRootClientId );
|
|
181
|
+
|
|
182
|
+
// The block list is empty, don't show the insertion point but still allow dropping.
|
|
183
|
+
if ( blocks.length === 0 ) {
|
|
184
|
+
setDropTarget( {
|
|
185
|
+
index: 0,
|
|
186
|
+
operation: 'insert',
|
|
187
|
+
} );
|
|
156
188
|
return;
|
|
157
189
|
}
|
|
158
190
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
191
|
+
const blocksData = blocks.map( ( block ) => {
|
|
192
|
+
const clientId = block.clientId;
|
|
193
|
+
|
|
194
|
+
return {
|
|
195
|
+
isUnmodifiedDefaultBlock:
|
|
196
|
+
getIsUnmodifiedDefaultBlock( block ),
|
|
197
|
+
getBoundingClientRect: () =>
|
|
198
|
+
ownerDocument
|
|
199
|
+
.getElementById( `block-${ clientId }` )
|
|
200
|
+
.getBoundingClientRect(),
|
|
201
|
+
blockIndex: getBlockIndex( clientId ),
|
|
202
|
+
};
|
|
203
|
+
} );
|
|
204
|
+
|
|
205
|
+
const [ targetIndex, operation ] = getDropTargetPosition(
|
|
206
|
+
blocksData,
|
|
207
|
+
{ x: event.clientX, y: event.clientY },
|
|
208
|
+
getBlockListSettings( targetRootClientId )?.orientation
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
setDropTarget( {
|
|
212
|
+
index: targetIndex,
|
|
213
|
+
operation,
|
|
214
|
+
} );
|
|
215
|
+
showInsertionPoint( targetRootClientId, targetIndex, {
|
|
216
|
+
operation,
|
|
217
|
+
} );
|
|
218
|
+
},
|
|
219
|
+
[ targetRootClientId ]
|
|
220
|
+
),
|
|
162
221
|
200
|
|
163
222
|
);
|
|
164
223
|
|
|
@@ -169,17 +228,15 @@ export default function useBlockDropZone( {
|
|
|
169
228
|
// `currentTarget` is only available while the event is being
|
|
170
229
|
// handled, so get it now and pass it to the thottled function.
|
|
171
230
|
// https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget
|
|
172
|
-
throttled( event, event.currentTarget );
|
|
231
|
+
throttled( event, event.currentTarget.ownerDocument );
|
|
173
232
|
},
|
|
174
233
|
onDragLeave() {
|
|
175
234
|
throttled.cancel();
|
|
176
235
|
hideInsertionPoint();
|
|
177
|
-
setTargetBlockIndex( null );
|
|
178
236
|
},
|
|
179
237
|
onDragEnd() {
|
|
180
238
|
throttled.cancel();
|
|
181
239
|
hideInsertionPoint();
|
|
182
|
-
setTargetBlockIndex( null );
|
|
183
240
|
},
|
|
184
241
|
} );
|
|
185
242
|
}
|