@wordpress/block-editor 11.7.0 → 12.0.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 +8 -0
- package/README.md +56 -57
- package/build/components/block-info-slot-fill/index.js +47 -0
- package/build/components/block-info-slot-fill/index.js.map +1 -0
- package/build/components/block-inspector/index.js +4 -2
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/index.native.js +11 -21
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +3 -1
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-popover/inbetween.js +2 -9
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +1 -10
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-toolbar/index.js +2 -1
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +83 -9
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +11 -28
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/caption/index.native.js +0 -1
- package/build/components/caption/index.native.js.map +1 -1
- package/build/components/date-format-picker/index.js +1 -1
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/editor-styles/index.js +4 -3
- package/build/components/editor-styles/index.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +21 -14
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/global-styles/border-panel.js +15 -59
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.js +12 -12
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.native.js +174 -0
- package/build/components/global-styles/color-panel.native.js.map +1 -0
- package/build/components/global-styles/dimensions-panel.js +21 -20
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/effects-panel.js +244 -0
- package/build/components/global-styles/effects-panel.js.map +1 -0
- package/build/components/global-styles/filters-panel.js +215 -0
- package/build/components/global-styles/filters-panel.js.map +1 -0
- package/build/components/global-styles/get-block-css-selector.js +1 -12
- package/build/components/global-styles/get-block-css-selector.js.map +1 -1
- package/build/components/global-styles/hooks.js +7 -0
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +28 -0
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +9 -9
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +100 -82
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/iframe/index.js +1 -1
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-size-control/use-dimension-handler.js +5 -3
- package/build/components/image-size-control/use-dimension-handler.js.map +1 -1
- package/build/components/index.js +23 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +4 -2
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/block-types-tab.js +12 -7
- package/build/components/inserter/block-types-tab.js.map +1 -1
- package/build/components/inserter/index.js +2 -1
- package/build/components/inserter/index.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 +2 -0
- package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build/components/inspector-controls-tabs/utils.js +5 -3
- package/build/components/inspector-controls-tabs/utils.js.map +1 -1
- package/build/components/list-view/block-select-button.js +7 -2
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +13 -21
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +37 -10
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/list-view/index.js +31 -7
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/leaf.js +2 -1
- package/build/components/list-view/leaf.js.map +1 -1
- package/build/components/list-view/use-block-selection.js +1 -1
- package/build/components/list-view/use-block-selection.js.map +1 -1
- package/build/components/list-view/use-list-view-client-ids.js +7 -3
- package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js +8 -2
- package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build/components/media-replace-flow/index.js +5 -5
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +12 -4
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/off-canvas-editor/appender.js +2 -7
- package/build/components/off-canvas-editor/appender.js.map +1 -1
- package/build/components/off-canvas-editor/block-contents.js +6 -1
- package/build/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build/components/off-canvas-editor/index.js +17 -14
- package/build/components/off-canvas-editor/index.js.map +1 -1
- package/build/components/resizable-box-popover/index.js +38 -0
- package/build/components/resizable-box-popover/index.js.map +1 -0
- package/build/components/rich-text/index.js +0 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +7 -11
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/spacing-sizes-control/spacing-input-control.js +8 -0
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build/hooks/anchor.js +1 -1
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/border.js +1 -1
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/duotone.js +121 -70
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/margin.js +27 -17
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +19 -9
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/utils.js +22 -7
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/utils.js +3 -2
- package/build/layouts/utils.js.map +1 -1
- package/build/private-apis.js +13 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +8 -1
- package/build/store/actions.js.map +1 -1
- package/build/utils/object.js +6 -6
- package/build/utils/object.js.map +1 -1
- package/build/utils/transform-styles/index.js +2 -2
- package/build/utils/transform-styles/index.js.map +1 -1
- package/build/utils/use-should-contextual-toolbar-show.js +68 -0
- package/build/utils/use-should-contextual-toolbar-show.js.map +1 -0
- package/build-module/components/block-info-slot-fill/index.js +34 -0
- package/build-module/components/block-info-slot-fill/index.js.map +1 -0
- package/build-module/components/block-inspector/index.js +3 -2
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/index.native.js +11 -19
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +2 -1
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +2 -9
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +1 -9
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +2 -1
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +79 -9
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +10 -27
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/caption/index.native.js +0 -1
- package/build-module/components/caption/index.native.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +1 -1
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/editor-styles/index.js +4 -3
- package/build-module/components/editor-styles/index.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +21 -14
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +15 -59
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +13 -13
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.native.js +150 -0
- package/build-module/components/global-styles/color-panel.native.js.map +1 -0
- package/build-module/components/global-styles/dimensions-panel.js +22 -21
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/effects-panel.js +228 -0
- package/build-module/components/global-styles/effects-panel.js.map +1 -0
- package/build-module/components/global-styles/filters-panel.js +201 -0
- package/build-module/components/global-styles/filters-panel.js.map +1 -0
- package/build-module/components/global-styles/get-block-css-selector.js +1 -12
- package/build-module/components/global-styles/get-block-css-selector.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +7 -0
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +2 -0
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +10 -10
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +101 -83
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/iframe/index.js +1 -1
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-size-control/use-dimension-handler.js +5 -3
- package/build-module/components/image-size-control/use-dimension-handler.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +5 -2
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.js +12 -6
- package/build-module/components/inserter/block-types-tab.js.map +1 -1
- package/build-module/components/inserter/index.js +2 -1
- package/build-module/components/inserter/index.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 +2 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/utils.js +4 -3
- package/build-module/components/inspector-controls-tabs/utils.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +7 -2
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +15 -22
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +36 -10
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/list-view/index.js +31 -8
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/leaf.js +2 -1
- package/build-module/components/list-view/leaf.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js +1 -1
- package/build-module/components/list-view/use-block-selection.js.map +1 -1
- package/build-module/components/list-view/use-list-view-client-ids.js +7 -3
- package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js +8 -4
- package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +5 -5
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +12 -4
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/appender.js +1 -5
- package/build-module/components/off-canvas-editor/appender.js.map +1 -1
- package/build-module/components/off-canvas-editor/block-contents.js +5 -1
- package/build-module/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build-module/components/off-canvas-editor/index.js +17 -14
- package/build-module/components/off-canvas-editor/index.js.map +1 -1
- package/build-module/components/resizable-box-popover/index.js +26 -0
- package/build-module/components/resizable-box-popover/index.js.map +1 -0
- package/build-module/components/rich-text/index.js +0 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +7 -10
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +7 -0
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build-module/hooks/anchor.js +1 -1
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/border.js +1 -1
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/duotone.js +118 -71
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/margin.js +29 -18
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +21 -10
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/utils.js +24 -9
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/utils.js +3 -2
- package/build-module/layouts/utils.js.map +1 -1
- package/build-module/private-apis.js +9 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +8 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/utils/object.js +5 -5
- package/build-module/utils/object.js.map +1 -1
- package/build-module/utils/transform-styles/index.js +2 -2
- package/build-module/utils/transform-styles/index.js.map +1 -1
- package/build-module/utils/use-should-contextual-toolbar-show.js +56 -0
- package/build-module/utils/use-should-contextual-toolbar-show.js.map +1 -0
- package/build-style/content-rtl.css +9 -6
- package/build-style/content.css +9 -6
- package/build-style/style-rtl.css +272 -54
- package/build-style/style.css +272 -54
- package/package.json +32 -32
- package/src/components/block-info-slot-fill/index.js +24 -0
- package/src/components/block-inspector/index.js +3 -0
- package/src/components/block-inspector/style.scss +6 -4
- package/src/components/block-list/content.scss +16 -15
- package/src/components/block-list/index.native.js +19 -38
- package/src/components/block-list/use-in-between-inserter.js +4 -1
- package/src/components/block-mobile-toolbar/test/block-actions-menu.native.js +9 -9
- package/src/components/block-mover/style.scss +10 -4
- package/src/components/block-mover/test/index.native.js +4 -4
- package/src/components/block-popover/inbetween.js +2 -13
- package/src/components/block-settings-menu/block-settings-dropdown.js +2 -12
- package/src/components/block-toolbar/index.js +4 -3
- package/src/components/block-toolbar/style.scss +56 -33
- package/src/components/block-tools/block-contextual-toolbar.js +94 -11
- package/src/components/block-tools/selected-block-popover.js +11 -44
- package/src/components/block-tools/style.scss +157 -3
- package/src/components/caption/index.native.js +0 -1
- package/src/components/date-format-picker/index.js +1 -1
- package/src/components/editor-styles/index.js +9 -5
- package/src/components/font-sizes/fluid-utils.js +31 -14
- package/src/components/font-sizes/test/fluid-utils.js +5 -16
- package/src/components/global-styles/README.md +129 -16
- package/src/components/global-styles/border-panel.js +13 -61
- package/src/components/global-styles/color-panel.js +13 -13
- package/src/components/global-styles/color-panel.native.js +207 -0
- package/src/components/global-styles/dimensions-panel.js +47 -20
- package/src/components/global-styles/effects-panel.js +228 -0
- package/src/components/global-styles/filters-panel.js +230 -0
- package/src/components/global-styles/get-block-css-selector.js +0 -11
- package/src/components/global-styles/hooks.js +10 -0
- package/src/components/global-styles/index.js +2 -0
- package/src/components/global-styles/style.scss +43 -0
- package/src/components/global-styles/test/typography-utils.js +63 -22
- package/src/components/global-styles/test/use-global-styles-output.js +130 -8
- package/src/components/global-styles/typography-panel.js +37 -11
- package/src/components/global-styles/use-global-styles-output.js +88 -72
- package/src/components/iframe/index.js +1 -1
- package/src/components/image-size-control/use-dimension-handler.js +4 -3
- package/src/components/index.js +5 -1
- package/src/components/inserter/block-patterns-tab.js +3 -1
- package/src/components/inserter/block-types-tab.js +9 -6
- package/src/components/inserter/index.js +1 -1
- 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/utils.js +4 -3
- package/src/components/list-view/README.md +2 -0
- package/src/components/list-view/block-select-button.js +6 -1
- package/src/components/list-view/block.js +24 -31
- package/src/components/list-view/drop-indicator.js +67 -22
- package/src/components/list-view/index.js +26 -3
- package/src/components/list-view/leaf.js +1 -0
- package/src/components/list-view/style.scss +18 -4
- package/src/components/list-view/test/use-list-view-drop-zone.js +188 -0
- package/src/components/list-view/use-block-selection.js +1 -1
- package/src/components/list-view/use-list-view-client-ids.js +5 -3
- package/src/components/list-view/use-list-view-drop-zone.js +9 -3
- package/src/components/media-replace-flow/README.md +3 -2
- package/src/components/media-replace-flow/index.js +4 -5
- package/src/components/navigable-toolbar/index.js +12 -3
- package/src/components/off-canvas-editor/appender.js +1 -4
- package/src/components/off-canvas-editor/block-contents.js +4 -0
- package/src/components/off-canvas-editor/index.js +15 -11
- package/src/components/resizable-box-popover/index.js +27 -0
- package/src/components/rich-text/index.js +0 -1
- package/src/components/rich-text/index.native.js +2 -5
- package/src/components/spacing-sizes-control/spacing-input-control.js +10 -0
- package/src/components/spacing-sizes-control/style.scss +7 -7
- package/src/components/url-popover/test/__snapshots__/index.js.snap +3 -3
- package/src/hooks/anchor.js +1 -1
- package/src/hooks/border.js +1 -1
- package/src/hooks/duotone.js +162 -99
- package/src/hooks/margin.js +31 -26
- package/src/hooks/padding.js +24 -18
- package/src/hooks/test/anchor.js +113 -0
- package/src/hooks/test/color.js +0 -9
- package/src/hooks/test/use-typography-props.js +2 -2
- package/src/hooks/test/utils.js +20 -101
- package/src/hooks/utils.js +23 -6
- package/src/layouts/utils.js +2 -2
- package/src/private-apis.js +8 -0
- package/src/store/actions.js +8 -1
- package/src/style.scss +1 -0
- package/src/utils/object.js +5 -5
- package/src/utils/test/object.js +53 -15
- package/src/utils/transform-styles/index.js +2 -2
- package/src/utils/use-should-contextual-toolbar-show.js +75 -0
- package/tsconfig.json +1 -0
- package/build/components/rich-text/use-native-props.js +0 -11
- package/build/components/rich-text/use-native-props.js.map +0 -1
- package/build/components/rich-text/use-native-props.native.js +0 -24
- package/build/components/rich-text/use-native-props.native.js.map +0 -1
- package/build/hooks/color-panel.native.js +0 -77
- package/build/hooks/color-panel.native.js.map +0 -1
- package/build-module/components/rich-text/use-native-props.js +0 -4
- package/build-module/components/rich-text/use-native-props.js.map +0 -1
- package/build-module/components/rich-text/use-native-props.native.js +0 -15
- package/build-module/components/rich-text/use-native-props.native.js.map +0 -1
- package/build-module/hooks/color-panel.native.js +0 -62
- package/build-module/hooks/color-panel.native.js.map +0 -1
- package/src/components/rich-text/use-native-props.js +0 -3
- package/src/components/rich-text/use-native-props.native.js +0 -17
- package/src/hooks/color-panel.native.js +0 -63
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { Popover } from '@wordpress/components';
|
|
5
|
+
import { getScrollContainer } from '@wordpress/dom';
|
|
5
6
|
import { useCallback, useMemo } from '@wordpress/element';
|
|
6
7
|
|
|
7
8
|
export default function ListViewDropIndicator( {
|
|
@@ -40,33 +41,74 @@ export default function ListViewDropIndicator( {
|
|
|
40
41
|
// is undefined, so the indicator will appear after the rootBlockElement.
|
|
41
42
|
const targetElement = blockElement || rootBlockElement;
|
|
42
43
|
|
|
43
|
-
const getDropIndicatorIndent = useCallback(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
const getDropIndicatorIndent = useCallback(
|
|
45
|
+
( targetElementRect ) => {
|
|
46
|
+
if ( ! rootBlockElement ) {
|
|
47
|
+
return 0;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Calculate the indent using the block icon of the root block.
|
|
51
|
+
// Using a classname selector here might be flaky and could be
|
|
52
|
+
// improved.
|
|
53
|
+
const rootBlockIconElement = rootBlockElement.querySelector(
|
|
54
|
+
'.block-editor-block-icon'
|
|
55
|
+
);
|
|
56
|
+
const rootBlockIconRect =
|
|
57
|
+
rootBlockIconElement.getBoundingClientRect();
|
|
58
|
+
return rootBlockIconRect.right - targetElementRect.left;
|
|
59
|
+
},
|
|
60
|
+
[ rootBlockElement ]
|
|
61
|
+
);
|
|
47
62
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
const getDropIndicatorWidth = useCallback(
|
|
64
|
+
( targetElementRect, indent ) => {
|
|
65
|
+
if ( ! targetElement ) {
|
|
66
|
+
return 0;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Default to assuming that the width of the drop indicator
|
|
70
|
+
// should be the same as the target element.
|
|
71
|
+
let width = targetElement.offsetWidth;
|
|
72
|
+
|
|
73
|
+
// In deeply nested lists, where a scrollbar is present,
|
|
74
|
+
// the width of the drop indicator should be the width of
|
|
75
|
+
// the scroll container, minus the distance from the left
|
|
76
|
+
// edge of the scroll container to the left edge of the
|
|
77
|
+
// target element.
|
|
78
|
+
const scrollContainer = getScrollContainer(
|
|
79
|
+
targetElement,
|
|
80
|
+
'horizontal'
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
if ( scrollContainer ) {
|
|
84
|
+
const scrollContainerRect =
|
|
85
|
+
scrollContainer.getBoundingClientRect();
|
|
86
|
+
|
|
87
|
+
if ( scrollContainer.clientWidth < width ) {
|
|
88
|
+
width =
|
|
89
|
+
scrollContainer.clientWidth -
|
|
90
|
+
( targetElementRect.left - scrollContainerRect.left );
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Subtract the indent from the final width of the indicator.
|
|
95
|
+
return width - indent;
|
|
96
|
+
},
|
|
97
|
+
[ targetElement ]
|
|
98
|
+
);
|
|
58
99
|
|
|
59
100
|
const style = useMemo( () => {
|
|
60
101
|
if ( ! targetElement ) {
|
|
61
102
|
return {};
|
|
62
103
|
}
|
|
63
104
|
|
|
64
|
-
const
|
|
105
|
+
const targetElementRect = targetElement.getBoundingClientRect();
|
|
106
|
+
const indent = getDropIndicatorIndent( targetElementRect );
|
|
65
107
|
|
|
66
108
|
return {
|
|
67
|
-
width:
|
|
109
|
+
width: getDropIndicatorWidth( targetElementRect, indent ),
|
|
68
110
|
};
|
|
69
|
-
}, [ getDropIndicatorIndent, targetElement ] );
|
|
111
|
+
}, [ getDropIndicatorIndent, getDropIndicatorWidth, targetElement ] );
|
|
70
112
|
|
|
71
113
|
const popoverAnchor = useMemo( () => {
|
|
72
114
|
const isValidDropPosition =
|
|
@@ -81,10 +123,8 @@ export default function ListViewDropIndicator( {
|
|
|
81
123
|
ownerDocument: targetElement.ownerDocument,
|
|
82
124
|
getBoundingClientRect() {
|
|
83
125
|
const rect = targetElement.getBoundingClientRect();
|
|
84
|
-
const indent = getDropIndicatorIndent();
|
|
85
|
-
|
|
126
|
+
const indent = getDropIndicatorIndent( rect );
|
|
86
127
|
const left = rect.left + indent;
|
|
87
|
-
const right = rect.right;
|
|
88
128
|
let top = 0;
|
|
89
129
|
let bottom = 0;
|
|
90
130
|
|
|
@@ -97,13 +137,18 @@ export default function ListViewDropIndicator( {
|
|
|
97
137
|
bottom = rect.bottom;
|
|
98
138
|
}
|
|
99
139
|
|
|
100
|
-
const width =
|
|
140
|
+
const width = getDropIndicatorWidth( rect, indent );
|
|
101
141
|
const height = bottom - top;
|
|
102
142
|
|
|
103
143
|
return new window.DOMRect( left, top, width, height );
|
|
104
144
|
},
|
|
105
145
|
};
|
|
106
|
-
}, [
|
|
146
|
+
}, [
|
|
147
|
+
targetElement,
|
|
148
|
+
dropPosition,
|
|
149
|
+
getDropIndicatorIndent,
|
|
150
|
+
getDropIndicatorWidth,
|
|
151
|
+
] );
|
|
107
152
|
|
|
108
153
|
if ( ! targetElement ) {
|
|
109
154
|
return null;
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import {
|
|
5
|
+
useInstanceId,
|
|
5
6
|
useMergeRefs,
|
|
6
7
|
__experimentalUseFixedWindowList as useFixedWindowList,
|
|
7
8
|
} from '@wordpress/compose';
|
|
8
9
|
import { __experimentalTreeGrid as TreeGrid } from '@wordpress/components';
|
|
9
10
|
import { AsyncModeProvider, useSelect } from '@wordpress/data';
|
|
11
|
+
import deprecated from '@wordpress/deprecated';
|
|
10
12
|
import {
|
|
11
13
|
useCallback,
|
|
12
14
|
useEffect,
|
|
@@ -56,11 +58,13 @@ export const BLOCK_LIST_ITEM_HEIGHT = 36;
|
|
|
56
58
|
*
|
|
57
59
|
* @param {Object} props Components props.
|
|
58
60
|
* @param {string} props.id An HTML element id for the root element of ListView.
|
|
59
|
-
* @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy.
|
|
61
|
+
* @param {Array} props.blocks _deprecated_ Custom subset of block client IDs to be used instead of the default hierarchy.
|
|
60
62
|
* @param {?boolean} props.showBlockMovers Flag to enable block movers. Defaults to `false`.
|
|
61
63
|
* @param {?boolean} props.isExpanded Flag to determine whether nested levels are expanded by default. Defaults to `false`.
|
|
62
64
|
* @param {?boolean} props.showAppender Flag to show or hide the block appender. Defaults to `false`.
|
|
63
65
|
* @param {?ComponentType} props.blockSettingsMenu Optional more menu substitution. Defaults to the standard `BlockSettingsDropdown` component.
|
|
66
|
+
* @param {string} props.rootClientId The client id of the root block from which we determine the blocks to show in the list.
|
|
67
|
+
* @param {string} props.description Optional accessible description for the tree grid component.
|
|
64
68
|
* @param {Ref} ref Forwarded ref
|
|
65
69
|
*/
|
|
66
70
|
function ListViewComponent(
|
|
@@ -71,11 +75,25 @@ function ListViewComponent(
|
|
|
71
75
|
isExpanded = false,
|
|
72
76
|
showAppender = false,
|
|
73
77
|
blockSettingsMenu: BlockSettingsMenu = BlockSettingsDropdown,
|
|
78
|
+
rootClientId,
|
|
79
|
+
description,
|
|
74
80
|
},
|
|
75
81
|
ref
|
|
76
82
|
) {
|
|
83
|
+
// This can be removed once we no longer need to support the blocks prop.
|
|
84
|
+
if ( blocks ) {
|
|
85
|
+
deprecated(
|
|
86
|
+
'`blocks` property in `wp.blockEditor.__experimentalListView`',
|
|
87
|
+
{
|
|
88
|
+
since: '6.3',
|
|
89
|
+
alternative: '`rootClientId` property',
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const instanceId = useInstanceId( ListViewComponent );
|
|
77
95
|
const { clientIdsTree, draggedClientIds, selectedClientIds } =
|
|
78
|
-
useListViewClientIds( blocks );
|
|
96
|
+
useListViewClientIds( { blocks, rootClientId } );
|
|
79
97
|
|
|
80
98
|
const { visibleBlockCount, shouldShowInnerBlocks } = useSelect(
|
|
81
99
|
( select ) => {
|
|
@@ -184,14 +202,15 @@ function ListViewComponent(
|
|
|
184
202
|
expand,
|
|
185
203
|
collapse,
|
|
186
204
|
BlockSettingsMenu,
|
|
205
|
+
listViewInstanceId: instanceId,
|
|
187
206
|
} ),
|
|
188
207
|
[
|
|
189
|
-
isMounted.current,
|
|
190
208
|
draggedClientIds,
|
|
191
209
|
expandedState,
|
|
192
210
|
expand,
|
|
193
211
|
collapse,
|
|
194
212
|
BlockSettingsMenu,
|
|
213
|
+
instanceId,
|
|
195
214
|
]
|
|
196
215
|
);
|
|
197
216
|
|
|
@@ -215,10 +234,13 @@ function ListViewComponent(
|
|
|
215
234
|
onExpandRow={ expandRow }
|
|
216
235
|
onFocusRow={ focusRow }
|
|
217
236
|
applicationAriaLabel={ __( 'Block navigation structure' ) }
|
|
237
|
+
// eslint-disable-next-line jsx-a11y/aria-props
|
|
238
|
+
aria-description={ description }
|
|
218
239
|
>
|
|
219
240
|
<ListViewContext.Provider value={ contextValue }>
|
|
220
241
|
<ListViewBranch
|
|
221
242
|
blocks={ clientIdsTree }
|
|
243
|
+
parentId={ rootClientId }
|
|
222
244
|
selectBlock={ selectEditorBlock }
|
|
223
245
|
showBlockMovers={ showBlockMovers }
|
|
224
246
|
fixedListWindow={ fixedListWindow }
|
|
@@ -241,6 +263,7 @@ export default forwardRef( ( props, ref ) => {
|
|
|
241
263
|
{ ...props }
|
|
242
264
|
showAppender={ false }
|
|
243
265
|
blockSettingsMenu={ BlockSettingsDropdown }
|
|
266
|
+
rootClientId={ null }
|
|
244
267
|
/>
|
|
245
268
|
);
|
|
246
269
|
} );
|
|
@@ -15,6 +15,18 @@
|
|
|
15
15
|
// Use position relative for row animation.
|
|
16
16
|
position: relative;
|
|
17
17
|
|
|
18
|
+
.components-button {
|
|
19
|
+
// When a row is expanded, retain the dark color.
|
|
20
|
+
&[aria-expanded="true"] {
|
|
21
|
+
color: $gray-900;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Ensure that on hover, the admin color is still used.
|
|
25
|
+
&:hover {
|
|
26
|
+
color: var(--wp-admin-theme-color);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
18
30
|
// The background has to be applied to the td, not tr, or border-radius won't work.
|
|
19
31
|
&.is-selected td {
|
|
20
32
|
background: var(--wp-admin-theme-color);
|
|
@@ -93,7 +105,7 @@
|
|
|
93
105
|
&.is-branch-selected.is-first-selected td:last-child {
|
|
94
106
|
border-top-right-radius: $radius-block-ui;
|
|
95
107
|
}
|
|
96
|
-
&[
|
|
108
|
+
&[data-expanded="false"] {
|
|
97
109
|
&.is-branch-selected.is-first-selected td:first-child {
|
|
98
110
|
border-top-left-radius: $radius-block-ui;
|
|
99
111
|
}
|
|
@@ -380,7 +392,7 @@ $block-navigation-max-indent: 8;
|
|
|
380
392
|
}
|
|
381
393
|
|
|
382
394
|
// Point downwards when open.
|
|
383
|
-
.block-editor-list-view-leaf[
|
|
395
|
+
.block-editor-list-view-leaf[data-expanded="true"] .block-editor-list-view__expander svg {
|
|
384
396
|
visibility: visible;
|
|
385
397
|
transition: transform 0.2s ease;
|
|
386
398
|
transform: rotate(90deg);
|
|
@@ -388,7 +400,7 @@ $block-navigation-max-indent: 8;
|
|
|
388
400
|
}
|
|
389
401
|
|
|
390
402
|
// Point rightwards when closed
|
|
391
|
-
.block-editor-list-view-leaf[
|
|
403
|
+
.block-editor-list-view-leaf[data-expanded="false"] .block-editor-list-view__expander svg {
|
|
392
404
|
visibility: visible;
|
|
393
405
|
transform: rotate(0deg);
|
|
394
406
|
transition: transform 0.2s ease;
|
|
@@ -400,7 +412,9 @@ $block-navigation-max-indent: 8;
|
|
|
400
412
|
|
|
401
413
|
.block-editor-list-view-drop-indicator__line {
|
|
402
414
|
background: var(--wp-admin-theme-color);
|
|
403
|
-
height:
|
|
415
|
+
height: 6px;
|
|
416
|
+
border: 1px solid $white;
|
|
417
|
+
border-radius: 4px;
|
|
404
418
|
}
|
|
405
419
|
}
|
|
406
420
|
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { getListViewDropTarget } from '../use-list-view-drop-zone';
|
|
5
|
+
|
|
6
|
+
describe( 'getListViewDropTarget', () => {
|
|
7
|
+
const blocksData = [
|
|
8
|
+
{
|
|
9
|
+
blockIndex: 0,
|
|
10
|
+
canInsertDraggedBlocksAsChild: true,
|
|
11
|
+
canInsertDraggedBlocksAsSibling: true,
|
|
12
|
+
clientId: 'block-1',
|
|
13
|
+
element: {
|
|
14
|
+
getBoundingClientRect: () => ( {
|
|
15
|
+
top: 50,
|
|
16
|
+
bottom: 100,
|
|
17
|
+
left: 10,
|
|
18
|
+
right: 100,
|
|
19
|
+
x: 10,
|
|
20
|
+
y: 50,
|
|
21
|
+
width: 90,
|
|
22
|
+
height: 50,
|
|
23
|
+
} ),
|
|
24
|
+
},
|
|
25
|
+
innerBlockCount: 1,
|
|
26
|
+
isDraggedBlock: false,
|
|
27
|
+
isExpanded: true,
|
|
28
|
+
rootClientId: '',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
blockIndex: 0,
|
|
32
|
+
canInsertDraggedBlocksAsChild: true,
|
|
33
|
+
canInsertDraggedBlocksAsSibling: true,
|
|
34
|
+
clientId: 'block-2',
|
|
35
|
+
element: {
|
|
36
|
+
getBoundingClientRect: () => ( {
|
|
37
|
+
top: 100,
|
|
38
|
+
bottom: 150,
|
|
39
|
+
left: 10,
|
|
40
|
+
right: 100,
|
|
41
|
+
x: 10,
|
|
42
|
+
y: 100,
|
|
43
|
+
width: 90,
|
|
44
|
+
height: 50,
|
|
45
|
+
} ),
|
|
46
|
+
},
|
|
47
|
+
innerBlockCount: 0,
|
|
48
|
+
isDraggedBlock: false,
|
|
49
|
+
isExpanded: false,
|
|
50
|
+
rootClientId: 'block-1',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
blockIndex: 1,
|
|
54
|
+
canInsertDraggedBlocksAsChild: true,
|
|
55
|
+
canInsertDraggedBlocksAsSibling: true,
|
|
56
|
+
clientId: 'block-3',
|
|
57
|
+
element: {
|
|
58
|
+
getBoundingClientRect: () => ( {
|
|
59
|
+
top: 150,
|
|
60
|
+
bottom: 150,
|
|
61
|
+
left: 10,
|
|
62
|
+
right: 100,
|
|
63
|
+
x: 10,
|
|
64
|
+
y: 150,
|
|
65
|
+
width: 90,
|
|
66
|
+
height: 50,
|
|
67
|
+
} ),
|
|
68
|
+
},
|
|
69
|
+
innerBlockCount: 0,
|
|
70
|
+
isDraggedBlock: false,
|
|
71
|
+
isExpanded: false,
|
|
72
|
+
rootClientId: '',
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
|
|
76
|
+
it( 'should return the correct target when dragging a block over the top half of the first block', () => {
|
|
77
|
+
const position = { x: 50, y: 70 };
|
|
78
|
+
const target = getListViewDropTarget( blocksData, position );
|
|
79
|
+
|
|
80
|
+
expect( target ).toEqual( {
|
|
81
|
+
blockIndex: 0,
|
|
82
|
+
clientId: 'block-1',
|
|
83
|
+
dropPosition: 'top',
|
|
84
|
+
rootClientId: '',
|
|
85
|
+
} );
|
|
86
|
+
} );
|
|
87
|
+
|
|
88
|
+
it( 'should nest when dragging a block over the bottom half of an expanded block', () => {
|
|
89
|
+
const position = { x: 50, y: 90 };
|
|
90
|
+
const target = getListViewDropTarget( blocksData, position );
|
|
91
|
+
|
|
92
|
+
expect( target ).toEqual( {
|
|
93
|
+
blockIndex: 0,
|
|
94
|
+
dropPosition: 'inside',
|
|
95
|
+
rootClientId: 'block-1',
|
|
96
|
+
} );
|
|
97
|
+
} );
|
|
98
|
+
|
|
99
|
+
it( 'should nest when dragging a block over the right side and bottom half of a collapsed block with children', () => {
|
|
100
|
+
const position = { x: 70, y: 90 };
|
|
101
|
+
|
|
102
|
+
const collapsedBlockData = [ ...blocksData ];
|
|
103
|
+
|
|
104
|
+
// Set the first block to be collapsed.
|
|
105
|
+
collapsedBlockData[ 0 ] = {
|
|
106
|
+
...collapsedBlockData[ 0 ],
|
|
107
|
+
isExpanded: false,
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// Hide the first block's children.
|
|
111
|
+
collapsedBlockData.splice( 1, 1 );
|
|
112
|
+
|
|
113
|
+
const target = getListViewDropTarget( collapsedBlockData, position );
|
|
114
|
+
|
|
115
|
+
expect( target ).toEqual( {
|
|
116
|
+
blockIndex: 0,
|
|
117
|
+
dropPosition: 'inside',
|
|
118
|
+
rootClientId: 'block-1',
|
|
119
|
+
} );
|
|
120
|
+
} );
|
|
121
|
+
|
|
122
|
+
it( 'should drag below when dragging a block over the left side and bottom half of a collapsed block with children', () => {
|
|
123
|
+
const position = { x: 30, y: 90 };
|
|
124
|
+
|
|
125
|
+
const collapsedBlockData = [ ...blocksData ];
|
|
126
|
+
|
|
127
|
+
// Set the first block to be collapsed.
|
|
128
|
+
collapsedBlockData[ 0 ] = {
|
|
129
|
+
...collapsedBlockData[ 0 ],
|
|
130
|
+
isExpanded: false,
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
// Hide the first block's children.
|
|
134
|
+
collapsedBlockData.splice( 1, 1 );
|
|
135
|
+
|
|
136
|
+
const target = getListViewDropTarget( collapsedBlockData, position );
|
|
137
|
+
|
|
138
|
+
expect( target ).toEqual( {
|
|
139
|
+
blockIndex: 1,
|
|
140
|
+
clientId: 'block-1',
|
|
141
|
+
dropPosition: 'bottom',
|
|
142
|
+
rootClientId: '',
|
|
143
|
+
} );
|
|
144
|
+
} );
|
|
145
|
+
|
|
146
|
+
it( 'should drag below when attempting to nest but the dragged block is not allowed as a child', () => {
|
|
147
|
+
const position = { x: 70, y: 90 };
|
|
148
|
+
|
|
149
|
+
const childNotAllowedBlockData = [ ...blocksData ];
|
|
150
|
+
|
|
151
|
+
// Set the first block to not be allowed as a child.
|
|
152
|
+
childNotAllowedBlockData[ 0 ] = {
|
|
153
|
+
...childNotAllowedBlockData[ 0 ],
|
|
154
|
+
canInsertDraggedBlocksAsChild: false,
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const target = getListViewDropTarget(
|
|
158
|
+
childNotAllowedBlockData,
|
|
159
|
+
position
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
expect( target ).toEqual( {
|
|
163
|
+
blockIndex: 1,
|
|
164
|
+
clientId: 'block-1',
|
|
165
|
+
dropPosition: 'bottom',
|
|
166
|
+
rootClientId: '',
|
|
167
|
+
} );
|
|
168
|
+
} );
|
|
169
|
+
|
|
170
|
+
it( 'should return undefined when the dragged block cannot be inserted as a sibling', () => {
|
|
171
|
+
const position = { x: 50, y: 70 };
|
|
172
|
+
|
|
173
|
+
const siblingNotAllowedBlockData = [ ...blocksData ];
|
|
174
|
+
|
|
175
|
+
// Set the first block to not be allowed as a sibling.
|
|
176
|
+
siblingNotAllowedBlockData[ 0 ] = {
|
|
177
|
+
...siblingNotAllowedBlockData[ 0 ],
|
|
178
|
+
canInsertDraggedBlocksAsSibling: false,
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const target = getListViewDropTarget(
|
|
182
|
+
siblingNotAllowedBlockData,
|
|
183
|
+
position
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
expect( target ).toBeUndefined();
|
|
187
|
+
} );
|
|
188
|
+
} );
|
|
@@ -9,7 +9,7 @@ import { useSelect } from '@wordpress/data';
|
|
|
9
9
|
*/
|
|
10
10
|
import { store as blockEditorStore } from '../../store';
|
|
11
11
|
|
|
12
|
-
export default function useListViewClientIds( blocks ) {
|
|
12
|
+
export default function useListViewClientIds( { blocks, rootClientId } ) {
|
|
13
13
|
return useSelect(
|
|
14
14
|
( select ) => {
|
|
15
15
|
const {
|
|
@@ -21,9 +21,11 @@ export default function useListViewClientIds( blocks ) {
|
|
|
21
21
|
return {
|
|
22
22
|
selectedClientIds: getSelectedBlockClientIds(),
|
|
23
23
|
draggedClientIds: getDraggedBlockClientIds(),
|
|
24
|
-
clientIdsTree: blocks
|
|
24
|
+
clientIdsTree: blocks
|
|
25
|
+
? blocks
|
|
26
|
+
: __unstableGetClientIdsTree( rootClientId ),
|
|
25
27
|
};
|
|
26
28
|
},
|
|
27
|
-
[ blocks ]
|
|
29
|
+
[ blocks, rootClientId ]
|
|
28
30
|
);
|
|
29
31
|
}
|
|
@@ -36,6 +36,7 @@ import { store as blockEditorStore } from '../../store';
|
|
|
36
36
|
* @property {Element} element The DOM element representing the block.
|
|
37
37
|
* @property {number} innerBlockCount The number of inner blocks the block has.
|
|
38
38
|
* @property {boolean} isDraggedBlock Whether the block is currently being dragged.
|
|
39
|
+
* @property {boolean} isExpanded Whether the block is expanded in the UI.
|
|
39
40
|
* @property {boolean} canInsertDraggedBlocksAsSibling Whether the dragged block can be a sibling of this block.
|
|
40
41
|
* @property {boolean} canInsertDraggedBlocksAsChild Whether the dragged block can be a child of this block.
|
|
41
42
|
*/
|
|
@@ -78,7 +79,7 @@ const ALLOWED_DROP_EDGES = [ 'top', 'bottom' ];
|
|
|
78
79
|
*
|
|
79
80
|
* @return {WPListViewDropZoneTarget | undefined} An object containing data about the drop target.
|
|
80
81
|
*/
|
|
81
|
-
function getListViewDropTarget( blocksData, position ) {
|
|
82
|
+
export function getListViewDropTarget( blocksData, position ) {
|
|
82
83
|
let candidateEdge;
|
|
83
84
|
let candidateBlockData;
|
|
84
85
|
let candidateDistance;
|
|
@@ -146,12 +147,15 @@ function getListViewDropTarget( blocksData, position ) {
|
|
|
146
147
|
|
|
147
148
|
// If the user is dragging towards the bottom of the block check whether
|
|
148
149
|
// they might be trying to nest the block as a child.
|
|
149
|
-
// If the block already has inner blocks, this should
|
|
150
|
+
// If the block already has inner blocks, and is expanded, this should be treated
|
|
150
151
|
// as nesting since the next block in the tree will be the first child.
|
|
152
|
+
// However, if the block is collapsed, dragging beneath the block should
|
|
153
|
+
// still be allowed, as the next visible block in the tree will be a sibling.
|
|
151
154
|
if (
|
|
152
155
|
isDraggingBelow &&
|
|
153
156
|
candidateBlockData.canInsertDraggedBlocksAsChild &&
|
|
154
|
-
( candidateBlockData.innerBlockCount > 0
|
|
157
|
+
( ( candidateBlockData.innerBlockCount > 0 &&
|
|
158
|
+
candidateBlockData.isExpanded ) ||
|
|
155
159
|
isNestingGesture( position, candidateRect ) )
|
|
156
160
|
) {
|
|
157
161
|
return {
|
|
@@ -208,10 +212,12 @@ export default function useListViewDropZone() {
|
|
|
208
212
|
|
|
209
213
|
const blocksData = blockElements.map( ( blockElement ) => {
|
|
210
214
|
const clientId = blockElement.dataset.block;
|
|
215
|
+
const isExpanded = blockElement.dataset.expanded === 'true';
|
|
211
216
|
const rootClientId = getBlockRootClientId( clientId );
|
|
212
217
|
|
|
213
218
|
return {
|
|
214
219
|
clientId,
|
|
220
|
+
isExpanded,
|
|
215
221
|
rootClientId,
|
|
216
222
|
blockIndex: getBlockIndex( clientId ),
|
|
217
223
|
element: blockElement,
|
|
@@ -65,10 +65,11 @@ Callback called when an upload error happens and receives an error message as an
|
|
|
65
65
|
|
|
66
66
|
### name
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
A `string` value will be used as the label of the replace button. It can also accept `Phrasing content` elements(ex. `span`).
|
|
69
69
|
|
|
70
|
-
- Type: `string`
|
|
70
|
+
- Type: `string|Element`
|
|
71
71
|
- Required: No
|
|
72
|
+
- Default: `Replace`
|
|
72
73
|
|
|
73
74
|
### createNotice
|
|
74
75
|
|
|
@@ -59,6 +59,9 @@ const MediaReplaceFlow = ( {
|
|
|
59
59
|
multiple = false,
|
|
60
60
|
addToGallery,
|
|
61
61
|
handleUpload = true,
|
|
62
|
+
popoverProps = {
|
|
63
|
+
variant: 'toolbar',
|
|
64
|
+
},
|
|
62
65
|
} ) => {
|
|
63
66
|
const mediaUpload = useSelect( ( select ) => {
|
|
64
67
|
return select( blockEditorStore ).getSettings().mediaUpload;
|
|
@@ -136,13 +139,9 @@ const MediaReplaceFlow = ( {
|
|
|
136
139
|
|
|
137
140
|
const gallery = multiple && onlyAllowsImages();
|
|
138
141
|
|
|
139
|
-
const POPOVER_PROPS = {
|
|
140
|
-
variant: 'toolbar',
|
|
141
|
-
};
|
|
142
|
-
|
|
143
142
|
return (
|
|
144
143
|
<Dropdown
|
|
145
|
-
popoverProps={
|
|
144
|
+
popoverProps={ popoverProps }
|
|
146
145
|
contentClassName="block-editor-media-replace-flow__options"
|
|
147
146
|
renderToggle={ ( { isOpen, onToggle } ) => (
|
|
148
147
|
<ToolbarButton
|
|
@@ -93,7 +93,8 @@ function useToolbarFocus(
|
|
|
93
93
|
focusOnMount,
|
|
94
94
|
isAccessibleToolbar,
|
|
95
95
|
defaultIndex,
|
|
96
|
-
onIndexChange
|
|
96
|
+
onIndexChange,
|
|
97
|
+
shouldUseKeyboardFocusShortcut
|
|
97
98
|
) {
|
|
98
99
|
// Make sure we don't use modified versions of this prop.
|
|
99
100
|
const [ initialFocusOnMount ] = useState( focusOnMount );
|
|
@@ -103,8 +104,14 @@ function useToolbarFocus(
|
|
|
103
104
|
focusFirstTabbableIn( ref.current );
|
|
104
105
|
}, [] );
|
|
105
106
|
|
|
107
|
+
const focusToolbarViaShortcut = () => {
|
|
108
|
+
if ( shouldUseKeyboardFocusShortcut ) {
|
|
109
|
+
focusToolbar();
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
106
113
|
// Focus on toolbar when pressing alt+F10 when the toolbar is visible.
|
|
107
|
-
useShortcut( 'core/block-editor/focus-toolbar',
|
|
114
|
+
useShortcut( 'core/block-editor/focus-toolbar', focusToolbarViaShortcut );
|
|
108
115
|
|
|
109
116
|
useEffect( () => {
|
|
110
117
|
if ( initialFocusOnMount ) {
|
|
@@ -147,6 +154,7 @@ function useToolbarFocus(
|
|
|
147
154
|
function NavigableToolbar( {
|
|
148
155
|
children,
|
|
149
156
|
focusOnMount,
|
|
157
|
+
shouldUseKeyboardFocusShortcut = true,
|
|
150
158
|
__experimentalInitialIndex: initialIndex,
|
|
151
159
|
__experimentalOnIndexChange: onIndexChange,
|
|
152
160
|
...props
|
|
@@ -159,7 +167,8 @@ function NavigableToolbar( {
|
|
|
159
167
|
focusOnMount,
|
|
160
168
|
isAccessibleToolbar,
|
|
161
169
|
initialIndex,
|
|
162
|
-
onIndexChange
|
|
170
|
+
onIndexChange,
|
|
171
|
+
shouldUseKeyboardFocusShortcut
|
|
163
172
|
);
|
|
164
173
|
|
|
165
174
|
if ( isAccessibleToolbar ) {
|
|
@@ -17,9 +17,7 @@ import { __, sprintf } from '@wordpress/i18n';
|
|
|
17
17
|
*/
|
|
18
18
|
import { store as blockEditorStore } from '../../store';
|
|
19
19
|
import useBlockDisplayTitle from '../block-title/use-block-display-title';
|
|
20
|
-
|
|
21
|
-
import { unlock } from '../../lock-unlock';
|
|
22
|
-
import { privateApis as blockEditorPrivateApis } from '../../private-apis';
|
|
20
|
+
import { ComposedPrivateInserter as PrivateInserter } from '../inserter';
|
|
23
21
|
|
|
24
22
|
const prioritizedInserterBlocks = [
|
|
25
23
|
'core/navigation-link/page',
|
|
@@ -86,7 +84,6 @@ export const Appender = forwardRef(
|
|
|
86
84
|
if ( hideInserter ) {
|
|
87
85
|
return null;
|
|
88
86
|
}
|
|
89
|
-
const { PrivateInserter } = unlock( blockEditorPrivateApis );
|
|
90
87
|
const descriptionId = `off-canvas-editor-appender__${ instanceId }`;
|
|
91
88
|
const description = sprintf(
|
|
92
89
|
/* translators: 1: The name of the block. 2: The numerical position of the block. 3: The level of nesting for the block. */
|
|
@@ -19,6 +19,7 @@ import { store as blockEditorStore } from '../../store';
|
|
|
19
19
|
import { updateAttributes } from './update-attributes';
|
|
20
20
|
import { LinkUI } from './link-ui';
|
|
21
21
|
import { useInsertedBlock } from './use-inserted-block';
|
|
22
|
+
import { useListViewContext } from './context';
|
|
22
23
|
|
|
23
24
|
const BLOCKS_WITH_LINK_UI_SUPPORT = [
|
|
24
25
|
'core/navigation-link',
|
|
@@ -90,6 +91,8 @@ const ListViewBlockContents = forwardRef(
|
|
|
90
91
|
hasExistingLinkValue,
|
|
91
92
|
] );
|
|
92
93
|
|
|
94
|
+
const { renderAdditionalBlockUI } = useListViewContext();
|
|
95
|
+
|
|
93
96
|
const isBlockMoveTarget =
|
|
94
97
|
blockMovingClientId && selectedBlockInBlockEditor === clientId;
|
|
95
98
|
|
|
@@ -107,6 +110,7 @@ const ListViewBlockContents = forwardRef(
|
|
|
107
110
|
|
|
108
111
|
return (
|
|
109
112
|
<>
|
|
113
|
+
{ renderAdditionalBlockUI && renderAdditionalBlockUI( block ) }
|
|
110
114
|
{ isLinkUIOpen && (
|
|
111
115
|
<LinkUI
|
|
112
116
|
clientId={ lastInsertedBlockClientId }
|