@wordpress/block-editor 12.17.0 → 12.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +32 -0
- package/build/components/block-draggable/index.js +11 -3
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-edit/context.js +3 -1
- package/build/components/block-edit/context.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-editing-mode/index.js +6 -3
- package/build/components/block-editing-mode/index.js.map +1 -1
- package/build/components/block-inspector/index.js +5 -2
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block.js +4 -3
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +9 -5
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.js +30 -4
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-list/private-block-context.js +1 -1
- package/build/components/block-list/private-block-context.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +1 -1
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-lock/toolbar.js +8 -2
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-popover/inbetween.js +15 -3
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-preview/auto.js +1 -1
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-removal-warning-modal/index.js +3 -2
- package/build/components/block-removal-warning-modal/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +2 -4
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-switcher/block-transformations-menu.js +12 -1
- package/build/components/block-switcher/block-transformations-menu.js.map +1 -1
- package/build/components/block-switcher/index.js +119 -90
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +10 -3
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +7 -1
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/global-styles/border-panel.js +5 -14
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/effects-panel.js +7 -1
- package/build/components/global-styles/effects-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +3 -2
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +31 -14
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/iframe/get-compatibility-styles.js +99 -0
- package/build/components/iframe/get-compatibility-styles.js.map +1 -0
- package/build/components/iframe/index.js +2 -3
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/index.js +16 -2
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +16 -2
- package/build/components/index.native.js.map +1 -1
- package/build/components/inspector-controls/groups.js +2 -0
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.js +3 -0
- package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +3 -2
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build/components/link-control/link-preview.js +30 -26
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/link-control/search-input.js +1 -9
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/list-view/block-contents.js +3 -1
- package/build/components/list-view/block-contents.js.map +1 -1
- package/build/components/list-view/block.js +10 -1
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +29 -8
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +100 -32
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/list-view/index.js +52 -4
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/leaf.js +2 -2
- package/build/components/list-view/leaf.js.map +1 -1
- package/build/components/list-view/use-list-view-block-indexes.js +30 -0
- package/build/components/list-view/use-list-view-block-indexes.js.map +1 -0
- package/build/components/list-view/use-list-view-drop-zone.js +56 -5
- package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build/components/list-view/utils.js +92 -0
- package/build/components/list-view/utils.js.map +1 -1
- package/build/components/provider/index.js +1 -1
- package/build/components/provider/index.js.map +1 -1
- package/build/components/recursion-provider/index.js +21 -0
- package/build/components/recursion-provider/index.js.map +1 -1
- package/build/components/rich-text/index.js +30 -6
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/native/index.native.js +9 -9
- package/build/components/rich-text/native/index.native.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +30 -7
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-on-block-drop/index.js +50 -8
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/hooks/block-hooks.js +5 -14
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/hooks/content-lock-ui.js +17 -42
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/effects.js +66 -0
- package/build/hooks/effects.js.map +1 -0
- package/build/hooks/index.js +15 -2
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/index.native.js +13 -0
- package/build/hooks/index.native.js.map +1 -1
- package/build/hooks/style.js +6 -2
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/supports.js +2 -1
- package/build/hooks/supports.js.map +1 -1
- package/build/hooks/typography.native.js +2 -2
- package/build/hooks/typography.native.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +115 -0
- package/build/hooks/use-bindings-attributes.js.map +1 -0
- package/build/hooks/use-shadow-props.js +46 -0
- package/build/hooks/use-shadow-props.js.map +1 -0
- package/build/hooks/utils.js +11 -7
- package/build/hooks/utils.js.map +1 -1
- package/build/index.js +14 -0
- package/build/index.js.map +1 -1
- package/build/store/actions.js +10 -6
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +2 -0
- package/build/store/index.js.map +1 -1
- package/build/store/private-actions.js +37 -0
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +60 -9
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +44 -3
- package/build/store/reducer.js.map +1 -1
- package/build/store/resolvers.js +27 -0
- package/build/store/resolvers.js.map +1 -0
- package/build/store/selectors.js +94 -56
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +5 -26
- package/build/store/utils.js.map +1 -1
- package/build/utils/index.js +0 -16
- package/build/utils/index.js.map +1 -1
- package/build/utils/math.js +13 -0
- package/build/utils/math.js.map +1 -1
- package/build/utils/object.js +17 -0
- package/build/utils/object.js.map +1 -1
- package/build/utils/transform-styles/index.js +37 -27
- package/build/utils/transform-styles/index.js.map +1 -1
- package/build-module/components/block-draggable/index.js +11 -3
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-edit/context.js +1 -0
- package/build-module/components/block-edit/context.js.map +1 -1
- package/build-module/components/block-edit/index.js +5 -3
- package/build-module/components/block-edit/index.js.map +1 -1
- package/build-module/components/block-editing-mode/index.js +7 -4
- package/build-module/components/block-editing-mode/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +5 -2
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block.js +6 -5
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +11 -7
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.js +31 -5
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-list/private-block-context.js +1 -1
- package/build-module/components/block-list/private-block-context.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +8 -2
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +15 -3
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-preview/auto.js +3 -3
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-removal-warning-modal/index.js +3 -2
- package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -4
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-switcher/block-transformations-menu.js +12 -1
- package/build-module/components/block-switcher/block-transformations-menu.js.map +1 -1
- package/build-module/components/block-switcher/index.js +116 -86
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +10 -3
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +7 -1
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +5 -14
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/effects-panel.js +7 -1
- package/build-module/components/global-styles/effects-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +3 -2
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +32 -15
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/iframe/get-compatibility-styles.js +93 -0
- package/build-module/components/iframe/get-compatibility-styles.js.map +1 -0
- package/build-module/components/iframe/index.js +2 -3
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/index.js +1 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +1 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +2 -0
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.js +3 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +3 -2
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +32 -28
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/link-control/search-input.js +1 -8
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/list-view/block-contents.js +3 -1
- package/build-module/components/list-view/block-contents.js.map +1 -1
- package/build-module/components/list-view/block.js +10 -1
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +30 -9
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +99 -32
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/list-view/index.js +54 -6
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/leaf.js +2 -2
- package/build-module/components/list-view/leaf.js.map +1 -1
- package/build-module/components/list-view/use-list-view-block-indexes.js +23 -0
- package/build-module/components/list-view/use-list-view-block-indexes.js.map +1 -0
- package/build-module/components/list-view/use-list-view-drop-zone.js +58 -7
- package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/list-view/utils.js +91 -0
- package/build-module/components/list-view/utils.js.map +1 -1
- package/build-module/components/provider/index.js +1 -1
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/recursion-provider/index.js +17 -0
- package/build-module/components/recursion-provider/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +30 -6
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/native/index.native.js +9 -9
- package/build-module/components/rich-text/native/index.native.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +31 -8
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.js +51 -9
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/hooks/block-hooks.js +5 -14
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +19 -43
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/effects.js +51 -0
- package/build-module/hooks/effects.js.map +1 -0
- package/build-module/hooks/index.js +3 -2
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/index.native.js +1 -0
- package/build-module/hooks/index.native.js.map +1 -1
- package/build-module/hooks/style.js +6 -2
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/supports.js +2 -1
- package/build-module/hooks/supports.js.map +1 -1
- package/build-module/hooks/typography.native.js +2 -2
- package/build-module/hooks/typography.native.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +112 -0
- package/build-module/hooks/use-bindings-attributes.js.map +1 -0
- package/build-module/hooks/use-shadow-props.js +39 -0
- package/build-module/hooks/use-shadow-props.js.map +1 -0
- package/build-module/hooks/utils.js +13 -9
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +10 -6
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +2 -0
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-actions.js +35 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +53 -8
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +43 -3
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/resolvers.js +20 -0
- package/build-module/store/resolvers.js.map +1 -0
- package/build-module/store/selectors.js +89 -52
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +3 -23
- package/build-module/store/utils.js.map +1 -1
- package/build-module/utils/index.js +0 -1
- package/build-module/utils/index.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/object.js +16 -0
- package/build-module/utils/object.js.map +1 -1
- package/build-module/utils/transform-styles/index.js +36 -27
- package/build-module/utils/transform-styles/index.js.map +1 -1
- package/build-style/content-rtl.css +33 -16
- package/build-style/content.css +33 -16
- package/build-style/default-editor-styles-rtl.css +1 -1
- package/build-style/default-editor-styles.css +1 -1
- package/build-style/style-rtl.css +169 -114
- package/build-style/style.css +169 -114
- package/package.json +31 -31
- package/src/components/block-canvas/style.scss +8 -1
- package/src/components/block-draggable/index.js +16 -5
- package/src/components/block-edit/context.js +1 -0
- package/src/components/block-edit/index.js +4 -0
- package/src/components/block-editing-mode/index.js +12 -7
- package/src/components/block-inspector/index.js +5 -2
- package/src/components/block-list/block.js +5 -4
- package/src/components/block-list/block.native.js +13 -3
- package/src/components/block-list/content.scss +34 -5
- package/src/components/block-list/index.js +52 -16
- package/src/components/block-list/private-block-context.js +1 -1
- package/src/components/block-list/use-in-between-inserter.js +1 -2
- package/src/components/block-lock/toolbar.js +10 -2
- package/src/components/block-popover/inbetween.js +22 -2
- package/src/components/block-preview/auto.js +3 -3
- package/src/components/block-removal-warning-modal/index.js +3 -2
- package/src/components/block-settings-menu/block-settings-dropdown.js +2 -7
- package/src/components/block-switcher/block-transformations-menu.js +18 -1
- package/src/components/block-switcher/index.js +133 -111
- package/src/components/block-switcher/style.scss +6 -4
- package/src/components/block-switcher/test/index.js +113 -230
- package/src/components/block-toolbar/style.scss +22 -18
- package/src/components/block-tools/insertion-point.js +15 -2
- package/src/components/block-tools/style.scss +8 -7
- package/src/components/font-sizes/fluid-utils.js +8 -2
- package/src/components/font-sizes/test/fluid-utils.js +9 -0
- package/src/components/global-styles/border-panel.js +7 -17
- package/src/components/global-styles/effects-panel.js +16 -1
- package/src/components/global-styles/hooks.js +2 -0
- package/src/components/global-styles/typography-panel.js +45 -13
- package/src/components/iframe/get-compatibility-styles.js +120 -0
- package/src/components/iframe/index.js +2 -3
- package/src/components/index.js +4 -2
- package/src/components/index.native.js +4 -2
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/styles-tab.js +1 -0
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +2 -0
- package/src/components/link-control/link-preview.js +31 -55
- package/src/components/link-control/search-input.js +1 -9
- package/src/components/link-control/style.scss +31 -85
- package/src/components/link-control/test/index.js +2 -1
- package/src/components/list-view/block-contents.js +5 -1
- package/src/components/list-view/block.js +9 -0
- package/src/components/list-view/branch.js +30 -10
- package/src/components/list-view/drop-indicator.js +139 -46
- package/src/components/list-view/index.js +74 -3
- package/src/components/list-view/leaf.js +2 -2
- package/src/components/list-view/style.scss +102 -13
- package/src/components/list-view/test/use-list-view-drop-zone.js +4 -0
- package/src/components/list-view/test/utils.js +218 -1
- package/src/components/list-view/use-list-view-block-indexes.js +29 -0
- package/src/components/list-view/use-list-view-drop-zone.js +78 -6
- package/src/components/list-view/utils.js +116 -0
- package/src/components/provider/index.js +3 -1
- package/src/components/recursion-provider/README.md +2 -2
- package/src/components/recursion-provider/index.js +17 -0
- package/src/components/rich-text/index.js +48 -10
- package/src/components/rich-text/native/index.native.js +10 -10
- package/src/components/use-block-drop-zone/index.js +60 -19
- package/src/components/use-block-drop-zone/test/index.js +32 -61
- package/src/components/use-on-block-drop/index.js +92 -11
- package/src/hooks/block-hooks.js +5 -17
- package/src/hooks/content-lock-ui.js +15 -55
- package/src/hooks/effects.js +57 -0
- package/src/hooks/index.js +2 -2
- package/src/hooks/index.native.js +1 -0
- package/src/hooks/style.js +8 -0
- package/src/hooks/supports.js +2 -0
- package/src/hooks/test/effects.js +39 -0
- package/src/hooks/typography.native.js +2 -2
- package/src/hooks/use-bindings-attributes.js +148 -0
- package/src/hooks/use-shadow-props.js +37 -0
- package/src/hooks/utils.js +26 -10
- package/src/index.js +2 -0
- package/src/store/actions.js +9 -4
- package/src/store/index.js +2 -0
- package/src/store/private-actions.js +32 -0
- package/src/store/private-selectors.js +78 -21
- package/src/store/reducer.js +49 -2
- package/src/store/resolvers.js +17 -0
- package/src/store/selectors.js +169 -161
- package/src/store/test/registry-selectors.js +431 -0
- package/src/store/test/selectors.js +14 -400
- package/src/store/utils.js +10 -33
- package/src/style.scss +0 -1
- package/src/utils/index.js +0 -1
- package/src/utils/math.js +12 -0
- package/src/utils/object.js +16 -0
- package/src/utils/transform-styles/index.js +52 -37
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/iframe/use-compatibility-styles.js +0 -100
- package/build/components/iframe/use-compatibility-styles.js.map +0 -1
- package/build/hooks/custom-fields.js +0 -106
- package/build/hooks/custom-fields.js.map +0 -1
- package/build/utils/block-variation-transforms.js +0 -42
- package/build/utils/block-variation-transforms.js.map +0 -1
- package/build-module/components/iframe/use-compatibility-styles.js +0 -94
- package/build-module/components/iframe/use-compatibility-styles.js.map +0 -1
- package/build-module/hooks/custom-fields.js +0 -99
- package/build-module/hooks/custom-fields.js.map +0 -1
- package/build-module/utils/block-variation-transforms.js +0 -35
- package/build-module/utils/block-variation-transforms.js.map +0 -1
- package/src/components/block-switcher/test/__snapshots__/index.js.snap +0 -116
- package/src/components/contrast-checker/style.scss +0 -3
- package/src/components/iframe/use-compatibility-styles.js +0 -122
- package/src/hooks/custom-fields.js +0 -115
- package/src/utils/block-variation-transforms.js +0 -38
- package/src/utils/test/block-variation-transforms.js +0 -94
|
@@ -43,7 +43,10 @@ import AriaReferencedText from './aria-referenced-text';
|
|
|
43
43
|
|
|
44
44
|
function ListViewBlock( {
|
|
45
45
|
block: { clientId },
|
|
46
|
+
displacement,
|
|
47
|
+
isAfterDraggedBlocks,
|
|
46
48
|
isDragged,
|
|
49
|
+
isNesting,
|
|
47
50
|
isSelected,
|
|
48
51
|
isBranchSelected,
|
|
49
52
|
selectBlock,
|
|
@@ -270,6 +273,11 @@ function ListViewBlock( {
|
|
|
270
273
|
'has-single-cell': ! showBlockActions,
|
|
271
274
|
'is-synced': blockInformation?.isSynced,
|
|
272
275
|
'is-draggable': canMove,
|
|
276
|
+
'is-displacement-normal': displacement === 'normal',
|
|
277
|
+
'is-displacement-up': displacement === 'up',
|
|
278
|
+
'is-displacement-down': displacement === 'down',
|
|
279
|
+
'is-after-dragged-blocks': isAfterDraggedBlocks,
|
|
280
|
+
'is-nesting': isNesting,
|
|
273
281
|
} );
|
|
274
282
|
|
|
275
283
|
// Only include all selected blocks if the currently clicked on block
|
|
@@ -296,6 +304,7 @@ function ListViewBlock( {
|
|
|
296
304
|
return (
|
|
297
305
|
<ListViewLeaf
|
|
298
306
|
className={ classes }
|
|
307
|
+
isDragged={ isDragged }
|
|
299
308
|
onKeyDown={ onKeyDown }
|
|
300
309
|
onMouseEnter={ onMouseEnter }
|
|
301
310
|
onMouseLeave={ onMouseLeave }
|
|
@@ -14,7 +14,7 @@ import { AsyncModeProvider, useSelect } from '@wordpress/data';
|
|
|
14
14
|
import { Appender } from './appender';
|
|
15
15
|
import ListViewBlock from './block';
|
|
16
16
|
import { useListViewContext } from './context';
|
|
17
|
-
import { isClientIdSelected } from './utils';
|
|
17
|
+
import { getDragDisplacementValues, isClientIdSelected } from './utils';
|
|
18
18
|
import { store as blockEditorStore } from '../../store';
|
|
19
19
|
import useBlockDisplayInformation from '../use-block-display-information';
|
|
20
20
|
|
|
@@ -91,7 +91,6 @@ function ListViewBranch( props ) {
|
|
|
91
91
|
selectedClientIds,
|
|
92
92
|
level = 1,
|
|
93
93
|
path = '',
|
|
94
|
-
isBranchDragged = false,
|
|
95
94
|
isBranchSelected = false,
|
|
96
95
|
listPosition = 0,
|
|
97
96
|
fixedListWindow,
|
|
@@ -115,7 +114,14 @@ function ListViewBranch( props ) {
|
|
|
115
114
|
[ parentId ]
|
|
116
115
|
);
|
|
117
116
|
|
|
118
|
-
const {
|
|
117
|
+
const {
|
|
118
|
+
blockDropPosition,
|
|
119
|
+
blockDropTargetIndex,
|
|
120
|
+
firstDraggedBlockIndex,
|
|
121
|
+
blockIndexes,
|
|
122
|
+
expandedState,
|
|
123
|
+
draggedClientIds,
|
|
124
|
+
} = useListViewContext();
|
|
119
125
|
|
|
120
126
|
if ( ! canParentExpand ) {
|
|
121
127
|
return null;
|
|
@@ -143,6 +149,21 @@ function ListViewBranch( props ) {
|
|
|
143
149
|
);
|
|
144
150
|
}
|
|
145
151
|
|
|
152
|
+
const isDragged = !! draggedClientIds?.includes( clientId );
|
|
153
|
+
|
|
154
|
+
// Determine the displacement of the block while dragging. This
|
|
155
|
+
// works out whether the current block should be displaced up or
|
|
156
|
+
// down, relative to the dragged blocks and the drop target.
|
|
157
|
+
const { displacement, isAfterDraggedBlocks, isNesting } =
|
|
158
|
+
getDragDisplacementValues( {
|
|
159
|
+
blockIndexes,
|
|
160
|
+
blockDropTargetIndex,
|
|
161
|
+
blockDropPosition,
|
|
162
|
+
clientId,
|
|
163
|
+
firstDraggedBlockIndex,
|
|
164
|
+
isDragged,
|
|
165
|
+
} );
|
|
166
|
+
|
|
146
167
|
const { itemInView } = fixedListWindow;
|
|
147
168
|
const blockInView = itemInView( nextPosition );
|
|
148
169
|
|
|
@@ -158,8 +179,6 @@ function ListViewBranch( props ) {
|
|
|
158
179
|
? expandedState[ clientId ] ?? isExpanded
|
|
159
180
|
: undefined;
|
|
160
181
|
|
|
161
|
-
const isDragged = !! draggedClientIds?.includes( clientId );
|
|
162
|
-
|
|
163
182
|
// Make updates to the selected or dragged blocks synchronous,
|
|
164
183
|
// but asynchronous for any other block.
|
|
165
184
|
const isSelected = isClientIdSelected(
|
|
@@ -178,7 +197,6 @@ function ListViewBranch( props ) {
|
|
|
178
197
|
const showBlock =
|
|
179
198
|
isDragged ||
|
|
180
199
|
blockInView ||
|
|
181
|
-
isBranchDragged ||
|
|
182
200
|
( isSelected && clientId === selectedClientIds[ 0 ] );
|
|
183
201
|
return (
|
|
184
202
|
<AsyncModeProvider key={ clientId } value={ ! isSelected }>
|
|
@@ -188,17 +206,20 @@ function ListViewBranch( props ) {
|
|
|
188
206
|
selectBlock={ selectBlock }
|
|
189
207
|
isSelected={ isSelected }
|
|
190
208
|
isBranchSelected={ isSelectedBranch }
|
|
191
|
-
isDragged={ isDragged
|
|
209
|
+
isDragged={ isDragged }
|
|
192
210
|
level={ level }
|
|
193
211
|
position={ position }
|
|
194
212
|
rowCount={ rowCount }
|
|
195
213
|
siblingBlockCount={ blockCount }
|
|
196
214
|
showBlockMovers={ showBlockMovers }
|
|
197
215
|
path={ updatedPath }
|
|
198
|
-
isExpanded={ shouldExpand }
|
|
216
|
+
isExpanded={ isDragged ? false : shouldExpand }
|
|
199
217
|
listPosition={ nextPosition }
|
|
200
218
|
selectedClientIds={ selectedClientIds }
|
|
201
219
|
isSyncedBranch={ syncedBranch }
|
|
220
|
+
displacement={ displacement }
|
|
221
|
+
isAfterDraggedBlocks={ isAfterDraggedBlocks }
|
|
222
|
+
isNesting={ isNesting }
|
|
202
223
|
/>
|
|
203
224
|
) }
|
|
204
225
|
{ ! showBlock && (
|
|
@@ -206,7 +227,7 @@ function ListViewBranch( props ) {
|
|
|
206
227
|
<td className="block-editor-list-view-placeholder" />
|
|
207
228
|
</tr>
|
|
208
229
|
) }
|
|
209
|
-
{ hasNestedBlocks && shouldExpand && (
|
|
230
|
+
{ hasNestedBlocks && shouldExpand && ! isDragged && (
|
|
210
231
|
<ListViewBranch
|
|
211
232
|
parentId={ clientId }
|
|
212
233
|
blocks={ innerBlocks }
|
|
@@ -217,7 +238,6 @@ function ListViewBranch( props ) {
|
|
|
217
238
|
listPosition={ nextPosition + 1 }
|
|
218
239
|
fixedListWindow={ fixedListWindow }
|
|
219
240
|
isBranchSelected={ isSelectedBranch }
|
|
220
|
-
isBranchDragged={ isDragged || isBranchDragged }
|
|
221
241
|
selectedClientIds={ selectedClientIds }
|
|
222
242
|
isExpanded={ isExpanded }
|
|
223
243
|
isSyncedBranch={ syncedBranch }
|
|
@@ -1,15 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
4
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
__experimentalHStack as HStack,
|
|
11
|
+
__experimentalTruncate as Truncate,
|
|
12
|
+
Popover,
|
|
13
|
+
} from '@wordpress/components';
|
|
14
|
+
|
|
5
15
|
import { getScrollContainer } from '@wordpress/dom';
|
|
6
16
|
import { useCallback, useMemo } from '@wordpress/element';
|
|
7
17
|
import { isRTL } from '@wordpress/i18n';
|
|
8
18
|
|
|
9
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Internal dependencies
|
|
21
|
+
*/
|
|
22
|
+
import BlockIcon from '../block-icon';
|
|
23
|
+
import useBlockDisplayInformation from '../use-block-display-information';
|
|
24
|
+
import useBlockDisplayTitle from '../block-title/use-block-display-title';
|
|
25
|
+
import ListViewExpander from './expander';
|
|
26
|
+
|
|
27
|
+
export default function ListViewDropIndicatorPreview( {
|
|
28
|
+
draggedBlockClientId,
|
|
10
29
|
listViewRef,
|
|
11
30
|
blockDropTarget,
|
|
12
31
|
} ) {
|
|
32
|
+
const blockInformation = useBlockDisplayInformation( draggedBlockClientId );
|
|
33
|
+
const blockTitle = useBlockDisplayTitle( {
|
|
34
|
+
clientId: draggedBlockClientId,
|
|
35
|
+
context: 'list-view',
|
|
36
|
+
} );
|
|
37
|
+
|
|
13
38
|
const { rootClientId, clientId, dropPosition } = blockDropTarget || {};
|
|
14
39
|
|
|
15
40
|
const [ rootBlockElement, blockElement ] = useMemo( () => {
|
|
@@ -35,7 +60,7 @@ export default function ListViewDropIndicator( {
|
|
|
35
60
|
: undefined;
|
|
36
61
|
|
|
37
62
|
return [ _rootBlockElement, _blockElement ];
|
|
38
|
-
}, [ rootClientId, clientId ] );
|
|
63
|
+
}, [ listViewRef, rootClientId, clientId ] );
|
|
39
64
|
|
|
40
65
|
// The targetElement is the element that the drop indicator will appear
|
|
41
66
|
// before or after. When dropping into an empty block list, blockElement
|
|
@@ -44,27 +69,6 @@ export default function ListViewDropIndicator( {
|
|
|
44
69
|
|
|
45
70
|
const rtl = isRTL();
|
|
46
71
|
|
|
47
|
-
const getDropIndicatorIndent = useCallback(
|
|
48
|
-
( targetElementRect ) => {
|
|
49
|
-
if ( ! rootBlockElement ) {
|
|
50
|
-
return 0;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Calculate the indent using the block icon of the root block.
|
|
54
|
-
// Using a classname selector here might be flaky and could be
|
|
55
|
-
// improved.
|
|
56
|
-
const rootBlockIconElement = rootBlockElement.querySelector(
|
|
57
|
-
'.block-editor-block-icon'
|
|
58
|
-
);
|
|
59
|
-
const rootBlockIconRect =
|
|
60
|
-
rootBlockIconElement.getBoundingClientRect();
|
|
61
|
-
return rtl
|
|
62
|
-
? targetElementRect.right - rootBlockIconRect.left
|
|
63
|
-
: rootBlockIconRect.right - targetElementRect.left;
|
|
64
|
-
},
|
|
65
|
-
[ rootBlockElement, rtl ]
|
|
66
|
-
);
|
|
67
|
-
|
|
68
72
|
const getDropIndicatorWidth = useCallback(
|
|
69
73
|
( targetElementRect, indent ) => {
|
|
70
74
|
if ( ! targetElement ) {
|
|
@@ -143,12 +147,69 @@ export default function ListViewDropIndicator( {
|
|
|
143
147
|
}
|
|
144
148
|
|
|
145
149
|
const targetElementRect = targetElement.getBoundingClientRect();
|
|
146
|
-
const indent = getDropIndicatorIndent( targetElementRect );
|
|
147
150
|
|
|
148
151
|
return {
|
|
149
|
-
width: getDropIndicatorWidth( targetElementRect,
|
|
152
|
+
width: getDropIndicatorWidth( targetElementRect, 0 ),
|
|
150
153
|
};
|
|
151
|
-
}, [
|
|
154
|
+
}, [ getDropIndicatorWidth, targetElement ] );
|
|
155
|
+
|
|
156
|
+
const horizontalScrollOffsetStyle = useMemo( () => {
|
|
157
|
+
if ( ! targetElement ) {
|
|
158
|
+
return {};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const scrollContainer = getScrollContainer( targetElement );
|
|
162
|
+
const ownerDocument = targetElement.ownerDocument;
|
|
163
|
+
const windowScroll =
|
|
164
|
+
scrollContainer === ownerDocument.body ||
|
|
165
|
+
scrollContainer === ownerDocument.documentElement;
|
|
166
|
+
|
|
167
|
+
if ( scrollContainer && ! windowScroll ) {
|
|
168
|
+
const scrollContainerRect = scrollContainer.getBoundingClientRect();
|
|
169
|
+
const targetElementRect = targetElement.getBoundingClientRect();
|
|
170
|
+
|
|
171
|
+
const distanceBetweenContainerAndTarget = rtl
|
|
172
|
+
? scrollContainerRect.right - targetElementRect.right
|
|
173
|
+
: targetElementRect.left - scrollContainerRect.left;
|
|
174
|
+
|
|
175
|
+
if ( ! rtl && scrollContainerRect.left > targetElementRect.left ) {
|
|
176
|
+
return {
|
|
177
|
+
transform: `translateX( ${ distanceBetweenContainerAndTarget }px )`,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if ( rtl && scrollContainerRect.right < targetElementRect.right ) {
|
|
182
|
+
return {
|
|
183
|
+
transform: `translateX( ${
|
|
184
|
+
distanceBetweenContainerAndTarget * -1
|
|
185
|
+
}px )`,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return {};
|
|
191
|
+
}, [ rtl, targetElement ] );
|
|
192
|
+
|
|
193
|
+
const ariaLevel = useMemo( () => {
|
|
194
|
+
if ( ! rootBlockElement ) {
|
|
195
|
+
return 1;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const _ariaLevel = parseInt(
|
|
199
|
+
rootBlockElement.getAttribute( 'aria-level' ),
|
|
200
|
+
10
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
return _ariaLevel ? _ariaLevel + 1 : 1;
|
|
204
|
+
}, [ rootBlockElement ] );
|
|
205
|
+
|
|
206
|
+
const hasAdjacentSelectedBranch = useMemo( () => {
|
|
207
|
+
if ( ! targetElement ) {
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return targetElement.classList.contains( 'is-branch-selected' );
|
|
212
|
+
}, [ targetElement ] );
|
|
152
213
|
|
|
153
214
|
const popoverAnchor = useMemo( () => {
|
|
154
215
|
const isValidDropPosition =
|
|
@@ -163,16 +224,15 @@ export default function ListViewDropIndicator( {
|
|
|
163
224
|
contextElement: targetElement,
|
|
164
225
|
getBoundingClientRect() {
|
|
165
226
|
const rect = targetElement.getBoundingClientRect();
|
|
166
|
-
const indent = getDropIndicatorIndent( rect );
|
|
167
227
|
// In RTL languages, the drop indicator should be positioned
|
|
168
228
|
// to the left of the target element, with the width of the
|
|
169
229
|
// indicator determining the indent at the right edge of the
|
|
170
230
|
// target element. In LTR languages, the drop indicator should
|
|
171
231
|
// end at the right edge of the target element, with the indent
|
|
172
232
|
// added to the position of the left edge of the target element.
|
|
173
|
-
let left = rtl ? rect.left : rect.left + indent;
|
|
233
|
+
// let left = rtl ? rect.left : rect.left + indent;
|
|
234
|
+
let left = rect.left;
|
|
174
235
|
let top = 0;
|
|
175
|
-
let bottom = 0;
|
|
176
236
|
|
|
177
237
|
// In deeply nested lists, where a scrollbar is present,
|
|
178
238
|
// the width of the drop indicator should be the width of
|
|
@@ -212,27 +272,19 @@ export default function ListViewDropIndicator( {
|
|
|
212
272
|
}
|
|
213
273
|
|
|
214
274
|
if ( dropPosition === 'top' ) {
|
|
215
|
-
top = rect.top;
|
|
216
|
-
bottom = rect.top;
|
|
275
|
+
top = rect.top - rect.height * 2;
|
|
217
276
|
} else {
|
|
218
277
|
// `dropPosition` is either `bottom` or `inside`
|
|
219
|
-
top = rect.
|
|
220
|
-
bottom = rect.bottom;
|
|
278
|
+
top = rect.top;
|
|
221
279
|
}
|
|
222
280
|
|
|
223
|
-
const width = getDropIndicatorWidth( rect,
|
|
224
|
-
const height =
|
|
281
|
+
const width = getDropIndicatorWidth( rect, 0 );
|
|
282
|
+
const height = rect.height;
|
|
225
283
|
|
|
226
284
|
return new window.DOMRect( left, top, width, height );
|
|
227
285
|
},
|
|
228
286
|
};
|
|
229
|
-
}, [
|
|
230
|
-
targetElement,
|
|
231
|
-
dropPosition,
|
|
232
|
-
getDropIndicatorIndent,
|
|
233
|
-
getDropIndicatorWidth,
|
|
234
|
-
rtl,
|
|
235
|
-
] );
|
|
287
|
+
}, [ targetElement, dropPosition, getDropIndicatorWidth, rtl ] );
|
|
236
288
|
|
|
237
289
|
if ( ! targetElement ) {
|
|
238
290
|
return null;
|
|
@@ -243,13 +295,54 @@ export default function ListViewDropIndicator( {
|
|
|
243
295
|
animate={ false }
|
|
244
296
|
anchor={ popoverAnchor }
|
|
245
297
|
focusOnMount={ false }
|
|
246
|
-
className="block-editor-list-view-drop-indicator"
|
|
298
|
+
className="block-editor-list-view-drop-indicator--preview"
|
|
247
299
|
variant="unstyled"
|
|
300
|
+
flip={ false }
|
|
301
|
+
resize={ true }
|
|
248
302
|
>
|
|
249
303
|
<div
|
|
250
304
|
style={ style }
|
|
251
|
-
className=
|
|
252
|
-
|
|
305
|
+
className={ classnames(
|
|
306
|
+
'block-editor-list-view-drop-indicator__line',
|
|
307
|
+
{
|
|
308
|
+
'block-editor-list-view-drop-indicator__line--darker':
|
|
309
|
+
hasAdjacentSelectedBranch,
|
|
310
|
+
}
|
|
311
|
+
) }
|
|
312
|
+
>
|
|
313
|
+
<div
|
|
314
|
+
className="block-editor-list-view-leaf"
|
|
315
|
+
aria-level={ ariaLevel }
|
|
316
|
+
>
|
|
317
|
+
<div
|
|
318
|
+
className={ classnames(
|
|
319
|
+
'block-editor-list-view-block-select-button',
|
|
320
|
+
'block-editor-list-view-block-contents'
|
|
321
|
+
) }
|
|
322
|
+
style={ horizontalScrollOffsetStyle }
|
|
323
|
+
>
|
|
324
|
+
<ListViewExpander onClick={ () => {} } />
|
|
325
|
+
<BlockIcon
|
|
326
|
+
icon={ blockInformation?.icon }
|
|
327
|
+
showColors
|
|
328
|
+
context="list-view"
|
|
329
|
+
/>
|
|
330
|
+
<HStack
|
|
331
|
+
alignment="center"
|
|
332
|
+
className="block-editor-list-view-block-select-button__label-wrapper"
|
|
333
|
+
justify="flex-start"
|
|
334
|
+
spacing={ 1 }
|
|
335
|
+
>
|
|
336
|
+
<span className="block-editor-list-view-block-select-button__title">
|
|
337
|
+
<Truncate ellipsizeMode="auto">
|
|
338
|
+
{ blockTitle }
|
|
339
|
+
</Truncate>
|
|
340
|
+
</span>
|
|
341
|
+
</HStack>
|
|
342
|
+
</div>
|
|
343
|
+
<div className="block-editor-list-view-block__menu-cell"></div>
|
|
344
|
+
</div>
|
|
345
|
+
</div>
|
|
253
346
|
</Popover>
|
|
254
347
|
);
|
|
255
348
|
}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
@@ -28,8 +33,9 @@ import { __ } from '@wordpress/i18n';
|
|
|
28
33
|
*/
|
|
29
34
|
import ListViewBranch from './branch';
|
|
30
35
|
import { ListViewContext } from './context';
|
|
31
|
-
import
|
|
36
|
+
import ListViewDropIndicatorPreview from './drop-indicator';
|
|
32
37
|
import useBlockSelection from './use-block-selection';
|
|
38
|
+
import useListViewBlockIndexes from './use-list-view-block-indexes';
|
|
33
39
|
import useListViewClientIds from './use-list-view-client-ids';
|
|
34
40
|
import useListViewDropZone from './use-list-view-drop-zone';
|
|
35
41
|
import useListViewExpandSelectedItem from './use-list-view-expand-selected-item';
|
|
@@ -105,6 +111,7 @@ function ListViewComponent(
|
|
|
105
111
|
const instanceId = useInstanceId( ListViewComponent );
|
|
106
112
|
const { clientIdsTree, draggedClientIds, selectedClientIds } =
|
|
107
113
|
useListViewClientIds( { blocks, rootClientId } );
|
|
114
|
+
const blockIndexes = useListViewBlockIndexes( clientIdsTree );
|
|
108
115
|
|
|
109
116
|
const { getBlock } = useSelect( blockEditorStore );
|
|
110
117
|
const { visibleBlockCount, shouldShowInnerBlocks } = useSelect(
|
|
@@ -132,6 +139,8 @@ function ListViewComponent(
|
|
|
132
139
|
|
|
133
140
|
const { ref: dropZoneRef, target: blockDropTarget } = useListViewDropZone( {
|
|
134
141
|
dropZoneElement,
|
|
142
|
+
expandedState,
|
|
143
|
+
setExpandedState,
|
|
135
144
|
} );
|
|
136
145
|
const elementRef = useRef();
|
|
137
146
|
const treeGridRef = useMergeRefs( [ elementRef, dropZoneRef, ref ] );
|
|
@@ -210,11 +219,55 @@ function ListViewComponent(
|
|
|
210
219
|
[ updateBlockSelection ]
|
|
211
220
|
);
|
|
212
221
|
|
|
222
|
+
const firstDraggedBlockClientId = draggedClientIds?.[ 0 ];
|
|
223
|
+
|
|
224
|
+
// Convert a blockDropTarget into indexes relative to the blocks in the list view.
|
|
225
|
+
// These values are used to determine which blocks should be displaced to make room
|
|
226
|
+
// for the drop indicator. See `ListViewBranch` and `getDragDisplacementValues`.
|
|
227
|
+
const { blockDropTargetIndex, blockDropPosition, firstDraggedBlockIndex } =
|
|
228
|
+
useMemo( () => {
|
|
229
|
+
let _blockDropTargetIndex, _firstDraggedBlockIndex;
|
|
230
|
+
|
|
231
|
+
if ( blockDropTarget?.clientId ) {
|
|
232
|
+
const foundBlockIndex =
|
|
233
|
+
blockIndexes[ blockDropTarget.clientId ];
|
|
234
|
+
// If dragging below or inside the block, treat the drop target as the next block.
|
|
235
|
+
_blockDropTargetIndex =
|
|
236
|
+
foundBlockIndex === undefined ||
|
|
237
|
+
blockDropTarget?.dropPosition === 'top'
|
|
238
|
+
? foundBlockIndex
|
|
239
|
+
: foundBlockIndex + 1;
|
|
240
|
+
} else if ( blockDropTarget === null ) {
|
|
241
|
+
// A `null` value is used to indicate that the user is dragging outside of the list view.
|
|
242
|
+
_blockDropTargetIndex = null;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if ( firstDraggedBlockClientId ) {
|
|
246
|
+
const foundBlockIndex =
|
|
247
|
+
blockIndexes[ firstDraggedBlockClientId ];
|
|
248
|
+
_firstDraggedBlockIndex =
|
|
249
|
+
foundBlockIndex === undefined ||
|
|
250
|
+
blockDropTarget?.dropPosition === 'top'
|
|
251
|
+
? foundBlockIndex
|
|
252
|
+
: foundBlockIndex + 1;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return {
|
|
256
|
+
blockDropTargetIndex: _blockDropTargetIndex,
|
|
257
|
+
blockDropPosition: blockDropTarget?.dropPosition,
|
|
258
|
+
firstDraggedBlockIndex: _firstDraggedBlockIndex,
|
|
259
|
+
};
|
|
260
|
+
}, [ blockDropTarget, blockIndexes, firstDraggedBlockClientId ] );
|
|
261
|
+
|
|
213
262
|
const contextValue = useMemo(
|
|
214
263
|
() => ( {
|
|
264
|
+
blockDropPosition,
|
|
265
|
+
blockDropTargetIndex,
|
|
266
|
+
blockIndexes,
|
|
215
267
|
draggedClientIds,
|
|
216
268
|
expandedState,
|
|
217
269
|
expand,
|
|
270
|
+
firstDraggedBlockIndex,
|
|
218
271
|
collapse,
|
|
219
272
|
BlockSettingsMenu,
|
|
220
273
|
listViewInstanceId: instanceId,
|
|
@@ -225,9 +278,13 @@ function ListViewComponent(
|
|
|
225
278
|
rootClientId,
|
|
226
279
|
} ),
|
|
227
280
|
[
|
|
281
|
+
blockDropPosition,
|
|
282
|
+
blockDropTargetIndex,
|
|
283
|
+
blockIndexes,
|
|
228
284
|
draggedClientIds,
|
|
229
285
|
expandedState,
|
|
230
286
|
expand,
|
|
287
|
+
firstDraggedBlockIndex,
|
|
231
288
|
collapse,
|
|
232
289
|
BlockSettingsMenu,
|
|
233
290
|
instanceId,
|
|
@@ -267,7 +324,8 @@ function ListViewComponent(
|
|
|
267
324
|
|
|
268
325
|
return (
|
|
269
326
|
<AsyncModeProvider value={ true }>
|
|
270
|
-
<
|
|
327
|
+
<ListViewDropIndicatorPreview
|
|
328
|
+
draggedBlockClientId={ firstDraggedBlockClientId }
|
|
271
329
|
listViewRef={ elementRef }
|
|
272
330
|
blockDropTarget={ blockDropTarget }
|
|
273
331
|
/>
|
|
@@ -278,7 +336,11 @@ function ListViewComponent(
|
|
|
278
336
|
) }
|
|
279
337
|
<TreeGrid
|
|
280
338
|
id={ id }
|
|
281
|
-
className=
|
|
339
|
+
className={ classnames( 'block-editor-list-view-tree', {
|
|
340
|
+
'is-dragging':
|
|
341
|
+
draggedClientIds?.length > 0 &&
|
|
342
|
+
blockDropTargetIndex !== undefined,
|
|
343
|
+
} ) }
|
|
282
344
|
aria-label={ __( 'Block navigation structure' ) }
|
|
283
345
|
ref={ treeGridRef }
|
|
284
346
|
onCollapseRow={ collapseRow }
|
|
@@ -286,6 +348,15 @@ function ListViewComponent(
|
|
|
286
348
|
onFocusRow={ focusRow }
|
|
287
349
|
applicationAriaLabel={ __( 'Block navigation structure' ) }
|
|
288
350
|
aria-describedby={ describedById }
|
|
351
|
+
style={ {
|
|
352
|
+
'--wp-admin--list-view-dragged-items-height':
|
|
353
|
+
draggedClientIds?.length
|
|
354
|
+
? `${
|
|
355
|
+
BLOCK_LIST_ITEM_HEIGHT *
|
|
356
|
+
( draggedClientIds.length - 1 )
|
|
357
|
+
}px`
|
|
358
|
+
: null,
|
|
359
|
+
} }
|
|
289
360
|
>
|
|
290
361
|
<ListViewContext.Provider value={ contextValue }>
|
|
291
362
|
<ListViewBranch
|
|
@@ -21,6 +21,7 @@ const AnimatedTreeGridRow = animated( TreeGridRow );
|
|
|
21
21
|
const ListViewLeaf = forwardRef(
|
|
22
22
|
(
|
|
23
23
|
{
|
|
24
|
+
isDragged,
|
|
24
25
|
isSelected,
|
|
25
26
|
position,
|
|
26
27
|
level,
|
|
@@ -33,8 +34,7 @@ const ListViewLeaf = forwardRef(
|
|
|
33
34
|
ref
|
|
34
35
|
) => {
|
|
35
36
|
const animationRef = useMovingAnimation( {
|
|
36
|
-
|
|
37
|
-
adjustScrolling: false,
|
|
37
|
+
clientId: props[ 'data-block' ],
|
|
38
38
|
enableAnimation: true,
|
|
39
39
|
triggerAnimationOnChange: path,
|
|
40
40
|
} );
|