@wordpress/block-editor 12.16.1-next.79a6196f.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 +6 -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-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/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 +14 -0
- 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 +7 -6
- 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/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-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/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 +2 -0
- 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 +9 -8
- 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/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-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/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 -0
- 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 +10 -6
- 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/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/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/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/utils/block-variation-transforms.js +0 -38
- package/src/utils/test/block-variation-transforms.js +0 -94
|
@@ -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
|
} );
|
|
@@ -9,11 +9,22 @@
|
|
|
9
9
|
margin: (-$grid-unit-15) (-$grid-unit-15 * 0.5) 0;
|
|
10
10
|
width: calc(100% + #{ $grid-unit-15 });
|
|
11
11
|
}
|
|
12
|
+
|
|
13
|
+
// Without setting `pointer-events: none`, when dragging over list view items,
|
|
14
|
+
// Safari calls onDropZoneLeave causing flickering in the position of the drop indicator.
|
|
15
|
+
// https://bugs.webkit.org/show_bug.cgi?id=66547
|
|
16
|
+
// See: https://github.com/WordPress/gutenberg/pull/56625
|
|
17
|
+
&.is-dragging tbody {
|
|
18
|
+
pointer-events: none;
|
|
19
|
+
}
|
|
12
20
|
}
|
|
13
21
|
|
|
14
22
|
.block-editor-list-view-leaf {
|
|
15
23
|
// Use position relative for row animation.
|
|
16
24
|
position: relative;
|
|
25
|
+
// Set the initial translate position to ensure the UI in Safari doesn't jump
|
|
26
|
+
// when rows later receive the is-displacement-up or is-displacement-down class.
|
|
27
|
+
transform: translateY(0);
|
|
17
28
|
|
|
18
29
|
&.is-draggable,
|
|
19
30
|
&.is-draggable .block-editor-list-view-block-contents {
|
|
@@ -128,6 +139,66 @@
|
|
|
128
139
|
border-radius: 0;
|
|
129
140
|
}
|
|
130
141
|
|
|
142
|
+
// List view items will be displaced up or down relative to their original position
|
|
143
|
+
// when a user is dragging a block within the list view. This creates a space for a
|
|
144
|
+
// visual indicator of where the block will be placed when dropped. The `normal` state
|
|
145
|
+
// is used to allow rows to smoothly transition back into their original position,
|
|
146
|
+
// without attaching the transition to the list view leaf itself. This prevents rows
|
|
147
|
+
// from animating too much once the user has dropped the block.
|
|
148
|
+
&.is-displacement-normal {
|
|
149
|
+
transition: transform 0.2s;
|
|
150
|
+
transform: translateY(0);
|
|
151
|
+
@include reduce-motion("transition");
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
&.is-displacement-up {
|
|
155
|
+
transition: transform 0.2s;
|
|
156
|
+
transform: translateY(-36px);
|
|
157
|
+
@include reduce-motion("transition");
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
&.is-displacement-down {
|
|
161
|
+
transition: transform 0.2s;
|
|
162
|
+
transform: translateY(36px);
|
|
163
|
+
@include reduce-motion("transition");
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Collapse multi-selections down into a single row space while dragging. The following
|
|
167
|
+
// rules ensure that during a multi-selection, the space for additional blocks is factored in
|
|
168
|
+
// when displacing up and down. The result is that there should only ever be a single row's
|
|
169
|
+
// worth of space for the visual indicator of where a block will be placed when dropped.
|
|
170
|
+
&.is-after-dragged-blocks {
|
|
171
|
+
transition: transform 0.2s;
|
|
172
|
+
transform: translateY(calc(var(--wp-admin--list-view-dragged-items-height, 36px) * -1));
|
|
173
|
+
@include reduce-motion("transition");
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
&.is-after-dragged-blocks.is-displacement-up {
|
|
177
|
+
transition: transform 0.2s;
|
|
178
|
+
transform: translateY(calc(-36px + var(--wp-admin--list-view-dragged-items-height, 36px) * -1));
|
|
179
|
+
@include reduce-motion("transition");
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
&.is-after-dragged-blocks.is-displacement-down {
|
|
183
|
+
transition: transform 0.2s;
|
|
184
|
+
transform: translateY(calc(36px + var(--wp-admin--list-view-dragged-items-height, 36px) * -1));
|
|
185
|
+
@include reduce-motion("transition");
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// To ensure displaced rows behave correctly, ensure that blocks that are currently being dragged
|
|
189
|
+
// are visually hidden. The below rules are used in favor of `display: none` to ensure that
|
|
190
|
+
// there is no flicker when a user begins to drag a block.
|
|
191
|
+
&.is-dragging {
|
|
192
|
+
opacity: 0;
|
|
193
|
+
// The row's left position is set to 0 to ensure that the animation
|
|
194
|
+
// when dropping a block animates from the correct position.
|
|
195
|
+
left: 0;
|
|
196
|
+
// Ensure the dragged element does not otherwise affect dropping to
|
|
197
|
+
// other positions.
|
|
198
|
+
pointer-events: none;
|
|
199
|
+
z-index: -9999;
|
|
200
|
+
}
|
|
201
|
+
|
|
131
202
|
// List View renders a fixed number of items and relies on each item having a fixed height of 36px.
|
|
132
203
|
// If this value changes, we should also change the itemHeight value set in useFixedWindowList.
|
|
133
204
|
// See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.
|
|
@@ -159,6 +230,7 @@
|
|
|
159
230
|
}
|
|
160
231
|
}
|
|
161
232
|
|
|
233
|
+
&.is-nesting .block-editor-list-view-block-contents,
|
|
162
234
|
.block-editor-list-view-block-contents:focus {
|
|
163
235
|
box-shadow: none;
|
|
164
236
|
|
|
@@ -173,11 +245,6 @@
|
|
|
173
245
|
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
174
246
|
z-index: 2;
|
|
175
247
|
pointer-events: none;
|
|
176
|
-
|
|
177
|
-
// Hide focus styles while a user is dragging blocks/files etc.
|
|
178
|
-
.is-dragging-components-draggable & {
|
|
179
|
-
box-shadow: none;
|
|
180
|
-
}
|
|
181
248
|
}
|
|
182
249
|
}
|
|
183
250
|
|
|
@@ -186,14 +253,10 @@
|
|
|
186
253
|
right: 0;
|
|
187
254
|
}
|
|
188
255
|
|
|
256
|
+
&.is-nesting .block-editor-list-view__menu,
|
|
189
257
|
.block-editor-list-view-block__menu:focus {
|
|
190
258
|
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
191
259
|
z-index: 1;
|
|
192
|
-
|
|
193
|
-
// Hide focus styles while a user is dragging blocks/files etc.
|
|
194
|
-
.is-dragging-components-draggable & {
|
|
195
|
-
box-shadow: none;
|
|
196
|
-
}
|
|
197
260
|
}
|
|
198
261
|
|
|
199
262
|
&.is-visible .block-editor-list-view-block-contents {
|
|
@@ -370,6 +433,14 @@
|
|
|
370
433
|
}
|
|
371
434
|
}
|
|
372
435
|
|
|
436
|
+
// First level of indentation is aria-level 2, max indent is 8.
|
|
437
|
+
// Indent is a full icon size, plus 4px which optically aligns child icons to the text label above.
|
|
438
|
+
$block-navigation-max-indent: 8;
|
|
439
|
+
|
|
440
|
+
.block-editor-list-view-draggable-chip {
|
|
441
|
+
opacity: 0.8;
|
|
442
|
+
}
|
|
443
|
+
|
|
373
444
|
.block-editor-list-view-block__contents-cell,
|
|
374
445
|
.block-editor-list-view-appender__cell {
|
|
375
446
|
.block-editor-list-view-block__contents-container,
|
|
@@ -386,9 +457,6 @@
|
|
|
386
457
|
cursor: pointer;
|
|
387
458
|
}
|
|
388
459
|
|
|
389
|
-
// First level of indentation is aria-level 2, max indent is 8.
|
|
390
|
-
// Indent is a full icon size, plus 4px which optically aligns child icons to the text label above.
|
|
391
|
-
$block-navigation-max-indent: 8;
|
|
392
460
|
.block-editor-list-view-leaf[aria-level] .block-editor-list-view__expander {
|
|
393
461
|
margin-left: ( $icon-size ) * $block-navigation-max-indent + 4 * ( $block-navigation-max-indent - 1 );
|
|
394
462
|
}
|
|
@@ -443,6 +511,27 @@ $block-navigation-max-indent: 8;
|
|
|
443
511
|
}
|
|
444
512
|
}
|
|
445
513
|
|
|
514
|
+
.block-editor-list-view-drop-indicator--preview {
|
|
515
|
+
pointer-events: none;
|
|
516
|
+
|
|
517
|
+
// If the drop indicator's popover ever extends to the edge of the screen,
|
|
518
|
+
// avoid any scrollbars by hiding the overflow.
|
|
519
|
+
.components-popover__content {
|
|
520
|
+
overflow: hidden !important;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
.block-editor-list-view-drop-indicator__line {
|
|
524
|
+
background: rgba(var(--wp-admin-theme-color--rgb), 0.04);
|
|
525
|
+
height: 36px;
|
|
526
|
+
border-radius: 4px;
|
|
527
|
+
overflow: hidden;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
.block-editor-list-view-drop-indicator__line--darker {
|
|
531
|
+
background: rgba(var(--wp-admin-theme-color--rgb), 0.09);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
446
535
|
.block-editor-list-view-placeholder {
|
|
447
536
|
padding: 0;
|
|
448
537
|
margin: 0;
|