@wordpress/block-editor 8.5.4 → 9.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 +9 -0
- package/README.md +4 -2
- package/build/components/block-alignment-control/constants.js +48 -0
- package/build/components/block-alignment-control/constants.js.map +1 -0
- package/build/components/block-alignment-control/ui.js +9 -40
- package/build/components/block-alignment-control/ui.js.map +1 -1
- package/build/components/block-alignment-control/ui.native.js +92 -0
- package/build/components/block-alignment-control/ui.native.js.map +1 -0
- package/build/components/block-content-overlay/index.js +13 -4
- package/build/components/block-content-overlay/index.js.map +1 -1
- package/build/components/block-list/block.native.js +3 -1
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/use-block-props/use-block-class-names.js +1 -7
- package/build/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build/components/block-lock/modal.js +34 -4
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-lock/toolbar.js +2 -1
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-lock/use-block-lock.js +4 -1
- package/build/components/block-lock/use-block-lock.js.map +1 -1
- package/build/components/block-mover/button.js +4 -4
- package/build/components/block-mover/button.js.map +1 -1
- package/build/components/block-mover/index.js +39 -65
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-navigation/dropdown.js +11 -5
- package/build/components/block-navigation/dropdown.js.map +1 -1
- package/build/components/block-popover/inbetween.js +183 -0
- package/build/components/block-popover/inbetween.js.map +1 -0
- package/build/components/block-popover/index.js +97 -0
- package/build/components/block-popover/index.js.map +1 -0
- package/build/components/{block-tools → block-popover}/use-popover-scroll.js +4 -1
- package/build/components/block-popover/use-popover-scroll.js.map +1 -0
- package/build/components/block-styles/index.js +1 -10
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-tools/back-compat.js +2 -2
- package/build/components/block-tools/back-compat.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +4 -2
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/index.js +5 -5
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +14 -121
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -108
- package/build/components/block-tools/selected-block-popover.js.map +1 -0
- package/build/components/color-style-selector/index.js +9 -0
- package/build/components/color-style-selector/index.js.map +1 -1
- package/build/components/duotone-control/index.js +5 -1
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/index.js +0 -9
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/index.native.js +30 -8
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/list-view/block.js +15 -15
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +9 -13
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/context.js +1 -4
- package/build/components/list-view/context.js.map +1 -1
- package/build/components/list-view/index.js +15 -32
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/rich-text/index.js +0 -5
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +0 -4
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/url-input/index.js +7 -3
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-block-display-information/index.js +3 -1
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/components/use-setting/index.js +42 -18
- package/build/components/use-setting/index.js.map +1 -1
- package/build/hooks/border.js +468 -44
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/dimensions.js +2 -2
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/index.js +3 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/margin.js +64 -12
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +60 -12
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/settings.js +32 -0
- package/build/hooks/settings.js.map +1 -0
- package/build/hooks/use-border-props.js +22 -32
- package/build/hooks/use-border-props.js.map +1 -1
- package/build/store/actions.js +14 -2
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +0 -1
- package/build/store/defaults.js.map +1 -1
- package/build/store/reducer.js +0 -26
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +47 -15
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-alignment-control/constants.js +36 -0
- package/build-module/components/block-alignment-control/constants.js.map +1 -0
- package/build-module/components/block-alignment-control/ui.js +4 -35
- package/build-module/components/block-alignment-control/ui.js.map +1 -1
- package/build-module/components/block-alignment-control/ui.native.js +78 -0
- package/build-module/components/block-alignment-control/ui.native.js.map +1 -0
- package/build-module/components/block-content-overlay/index.js +13 -4
- package/build-module/components/block-content-overlay/index.js.map +1 -1
- package/build-module/components/block-list/block.native.js +3 -1
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-block-class-names.js +1 -7
- package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build-module/components/block-lock/modal.js +34 -5
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +2 -1
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-lock/use-block-lock.js +4 -1
- package/build-module/components/block-lock/use-block-lock.js.map +1 -1
- package/build-module/components/block-mover/button.js +5 -5
- package/build-module/components/block-mover/button.js.map +1 -1
- package/build-module/components/block-mover/index.js +38 -63
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-navigation/dropdown.js +10 -5
- package/build-module/components/block-navigation/dropdown.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +165 -0
- package/build-module/components/block-popover/inbetween.js.map +1 -0
- package/build-module/components/block-popover/index.js +83 -0
- package/build-module/components/block-popover/index.js.map +1 -0
- package/build-module/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
- package/build-module/components/block-popover/use-popover-scroll.js.map +1 -0
- package/build-module/components/block-styles/index.js +1 -9
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-tools/back-compat.js +1 -1
- package/build-module/components/block-tools/back-compat.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +3 -2
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/index.js +3 -3
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +16 -121
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -105
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -0
- package/build-module/components/color-style-selector/index.js +6 -0
- package/build-module/components/color-style-selector/index.js.map +1 -1
- package/build-module/components/duotone-control/index.js +4 -1
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/index.js +0 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +31 -10
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/list-view/block.js +15 -16
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +9 -13
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/context.js +1 -4
- package/build-module/components/list-view/context.js.map +1 -1
- package/build-module/components/list-view/index.js +15 -31
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +0 -4
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +0 -4
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/url-input/index.js +7 -3
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +3 -1
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/components/use-setting/index.js +43 -19
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/hooks/border.js +458 -44
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/dimensions.js +5 -5
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/index.js +2 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/margin.js +61 -13
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +57 -13
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/settings.js +29 -0
- package/build-module/hooks/settings.js.map +1 -0
- package/build-module/hooks/use-border-props.js +21 -30
- package/build-module/hooks/use-border-props.js.map +1 -1
- package/build-module/store/actions.js +14 -2
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +0 -1
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/reducer.js +0 -24
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +44 -15
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +128 -276
- package/build-style/style.css +128 -276
- package/package.json +28 -28
- package/src/components/block-alignment-control/constants.js +45 -0
- package/src/components/block-alignment-control/ui.js +69 -109
- package/src/components/block-alignment-control/ui.native.js +86 -0
- package/src/components/block-content-overlay/index.js +19 -2
- package/src/components/block-list/block.native.js +2 -0
- package/src/components/block-list/style.scss +7 -18
- package/src/components/block-list/use-block-props/use-block-class-names.js +1 -11
- package/src/components/block-lock/modal.js +42 -3
- package/src/components/block-lock/toolbar.js +2 -2
- package/src/components/block-lock/use-block-lock.js +4 -1
- package/src/components/block-mover/button.js +5 -7
- package/src/components/block-mover/index.js +37 -60
- package/src/components/block-mover/stories/index.js +110 -0
- package/src/components/block-mover/style.scss +48 -138
- package/src/components/block-navigation/dropdown.js +12 -8
- package/src/components/block-popover/README.md +41 -0
- package/src/components/block-popover/inbetween.js +180 -0
- package/src/components/block-popover/index.js +90 -0
- package/src/components/block-popover/style.scss +27 -0
- package/src/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
- package/src/components/block-styles/index.js +1 -12
- package/src/components/block-switcher/style.scss +0 -4
- package/src/components/block-toolbar/style.scss +0 -12
- package/src/components/block-tools/back-compat.js +1 -1
- package/src/components/block-tools/block-selection-button.js +3 -1
- package/src/components/block-tools/index.js +6 -4
- package/src/components/block-tools/insertion-point.js +19 -152
- package/src/components/block-tools/{block-popover.js → selected-block-popover.js} +24 -116
- package/src/components/block-tools/style.scss +11 -123
- package/src/components/border-radius-control/style.scss +5 -2
- package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
- package/src/components/color-style-selector/index.js +18 -9
- package/src/components/default-block-appender/style.scss +1 -2
- package/src/components/duotone-control/index.js +8 -1
- package/src/components/gradients/README.md +29 -0
- package/src/components/image-size-control/README.md +1 -1
- package/src/components/index.js +0 -1
- package/src/components/inserter/index.native.js +60 -25
- package/src/components/inserter/style.native.scss +25 -3
- package/src/components/list-view/block.js +24 -34
- package/src/components/list-view/branch.js +10 -20
- package/src/components/list-view/context.js +1 -4
- package/src/components/list-view/index.js +11 -41
- package/src/components/navigable-toolbar/README.md +16 -0
- package/src/components/rich-text/index.js +0 -2
- package/src/components/rich-text/index.native.js +0 -4
- package/src/components/url-input/index.js +6 -3
- package/src/components/use-block-display-information/index.js +2 -0
- package/src/components/use-setting/index.js +57 -21
- package/src/hooks/border.js +438 -72
- package/src/hooks/border.scss +48 -0
- package/src/hooks/dimensions.js +44 -38
- package/src/hooks/index.js +2 -1
- package/src/hooks/margin.js +64 -15
- package/src/hooks/padding.js +60 -15
- package/src/hooks/padding.scss +12 -0
- package/src/hooks/settings.js +32 -0
- package/src/hooks/test/settings.js +48 -0
- package/src/hooks/use-border-props.js +15 -32
- package/src/store/actions.js +14 -2
- package/src/store/defaults.js +0 -1
- package/src/store/reducer.js +0 -21
- package/src/store/selectors.js +46 -15
- package/src/store/test/actions.js +0 -18
- package/src/store/test/reducer.js +0 -19
- package/src/store/test/selectors.js +17 -19
- package/src/style.scss +2 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/block-mobile-toolbar/index.js +0 -42
- package/build/components/block-mobile-toolbar/index.js.map +0 -1
- package/build/components/block-tools/block-popover.js.map +0 -1
- package/build/components/block-tools/use-popover-scroll.js.map +0 -1
- package/build/components/border-style-control/index.js +0 -60
- package/build/components/border-style-control/index.js.map +0 -1
- package/build/components/list-view/appender.js +0 -93
- package/build/components/list-view/appender.js.map +0 -1
- package/build/components/list-view/list-item.js +0 -62
- package/build/components/list-view/list-item.js.map +0 -1
- package/build/components/rich-text/use-caret-in-format.js +0 -43
- package/build/components/rich-text/use-caret-in-format.js.map +0 -1
- package/build/hooks/border-color.js +0 -302
- package/build/hooks/border-color.js.map +0 -1
- package/build/hooks/border-style.js +0 -96
- package/build/hooks/border-style.js.map +0 -1
- package/build/hooks/border-width.js +0 -162
- package/build/hooks/border-width.js.map +0 -1
- package/build-module/components/block-mobile-toolbar/index.js +0 -31
- package/build-module/components/block-mobile-toolbar/index.js.map +0 -1
- package/build-module/components/block-tools/block-popover.js.map +0 -1
- package/build-module/components/block-tools/use-popover-scroll.js.map +0 -1
- package/build-module/components/border-style-control/index.js +0 -50
- package/build-module/components/border-style-control/index.js.map +0 -1
- package/build-module/components/list-view/appender.js +0 -76
- package/build-module/components/list-view/appender.js.map +0 -1
- package/build-module/components/list-view/list-item.js +0 -47
- package/build-module/components/list-view/list-item.js.map +0 -1
- package/build-module/components/rich-text/use-caret-in-format.js +0 -33
- package/build-module/components/rich-text/use-caret-in-format.js.map +0 -1
- package/build-module/hooks/border-color.js +0 -276
- package/build-module/hooks/border-color.js.map +0 -1
- package/build-module/hooks/border-style.js +0 -78
- package/build-module/hooks/border-style.js.map +0 -1
- package/build-module/hooks/border-width.js +0 -143
- package/build-module/hooks/border-width.js.map +0 -1
- package/src/components/block-mobile-toolbar/index.js +0 -24
- package/src/components/block-mobile-toolbar/style.scss +0 -29
- package/src/components/border-style-control/index.js +0 -47
- package/src/components/border-style-control/style.scss +0 -18
- package/src/components/list-view/appender.js +0 -82
- package/src/components/list-view/list-item.js +0 -59
- package/src/components/rich-text/use-caret-in-format.js +0 -28
- package/src/hooks/border-color.js +0 -315
- package/src/hooks/border-style.js +0 -64
- package/src/hooks/border-width.js +0 -139
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { useSelect } from '@wordpress/data';
|
|
10
|
+
import { useCallback, useMemo, createContext } from '@wordpress/element';
|
|
11
|
+
import { Popover } from '@wordpress/components';
|
|
12
|
+
import { isRTL } from '@wordpress/i18n';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Internal dependencies
|
|
16
|
+
*/
|
|
17
|
+
import { store as blockEditorStore } from '../../store';
|
|
18
|
+
import { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';
|
|
19
|
+
import usePopoverScroll from './use-popover-scroll';
|
|
20
|
+
|
|
21
|
+
export const InsertionPointOpenRef = createContext();
|
|
22
|
+
|
|
23
|
+
function BlockPopoverInbetween( {
|
|
24
|
+
previousClientId,
|
|
25
|
+
nextClientId,
|
|
26
|
+
children,
|
|
27
|
+
__unstablePopoverSlot,
|
|
28
|
+
__unstableContentRef,
|
|
29
|
+
...props
|
|
30
|
+
} ) {
|
|
31
|
+
const { orientation, rootClientId } = useSelect(
|
|
32
|
+
( select ) => {
|
|
33
|
+
const { getBlockListSettings, getBlockRootClientId } = select(
|
|
34
|
+
blockEditorStore
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
const _rootClientId = getBlockRootClientId( previousClientId );
|
|
38
|
+
return {
|
|
39
|
+
orientation:
|
|
40
|
+
getBlockListSettings( _rootClientId )?.orientation ||
|
|
41
|
+
'vertical',
|
|
42
|
+
rootClientId: _rootClientId,
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
[ previousClientId ]
|
|
46
|
+
);
|
|
47
|
+
const previousElement = useBlockElement( previousClientId );
|
|
48
|
+
const nextElement = useBlockElement( nextClientId );
|
|
49
|
+
const isVertical = orientation === 'vertical';
|
|
50
|
+
const style = useMemo( () => {
|
|
51
|
+
if ( ! previousElement && ! nextElement ) {
|
|
52
|
+
return {};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const previousRect = previousElement
|
|
56
|
+
? previousElement.getBoundingClientRect()
|
|
57
|
+
: null;
|
|
58
|
+
const nextRect = nextElement
|
|
59
|
+
? nextElement.getBoundingClientRect()
|
|
60
|
+
: null;
|
|
61
|
+
|
|
62
|
+
if ( isVertical ) {
|
|
63
|
+
return {
|
|
64
|
+
width: previousElement
|
|
65
|
+
? previousElement.offsetWidth
|
|
66
|
+
: nextElement.offsetWidth,
|
|
67
|
+
height:
|
|
68
|
+
nextRect && previousRect
|
|
69
|
+
? nextRect.top - previousRect.bottom
|
|
70
|
+
: 0,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
let width = 0;
|
|
75
|
+
if ( previousRect && nextRect ) {
|
|
76
|
+
width = isRTL()
|
|
77
|
+
? previousRect.left - nextRect.right
|
|
78
|
+
: nextRect.left - previousRect.right;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
width,
|
|
83
|
+
height: previousElement
|
|
84
|
+
? previousElement.offsetHeight
|
|
85
|
+
: nextElement.offsetHeight,
|
|
86
|
+
};
|
|
87
|
+
}, [ previousElement, nextElement, isVertical ] );
|
|
88
|
+
|
|
89
|
+
const getAnchorRect = useCallback( () => {
|
|
90
|
+
if ( ! previousElement && ! nextElement ) {
|
|
91
|
+
return {};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const { ownerDocument } = previousElement || nextElement;
|
|
95
|
+
|
|
96
|
+
const previousRect = previousElement
|
|
97
|
+
? previousElement.getBoundingClientRect()
|
|
98
|
+
: null;
|
|
99
|
+
const nextRect = nextElement
|
|
100
|
+
? nextElement.getBoundingClientRect()
|
|
101
|
+
: null;
|
|
102
|
+
|
|
103
|
+
if ( isVertical ) {
|
|
104
|
+
if ( isRTL() ) {
|
|
105
|
+
return {
|
|
106
|
+
top: previousRect ? previousRect.bottom : nextRect.top,
|
|
107
|
+
left: previousRect ? previousRect.right : nextRect.right,
|
|
108
|
+
right: previousRect ? previousRect.left : nextRect.left,
|
|
109
|
+
bottom: nextRect ? nextRect.top : previousRect.bottom,
|
|
110
|
+
ownerDocument,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return {
|
|
115
|
+
top: previousRect ? previousRect.bottom : nextRect.top,
|
|
116
|
+
left: previousRect ? previousRect.left : nextRect.left,
|
|
117
|
+
right: previousRect ? previousRect.right : nextRect.right,
|
|
118
|
+
bottom: nextRect ? nextRect.top : previousRect.bottom,
|
|
119
|
+
ownerDocument,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if ( isRTL() ) {
|
|
124
|
+
return {
|
|
125
|
+
top: previousRect ? previousRect.top : nextRect.top,
|
|
126
|
+
left: previousRect ? previousRect.left : nextRect.right,
|
|
127
|
+
right: nextRect ? nextRect.right : previousRect.left,
|
|
128
|
+
bottom: previousRect ? previousRect.bottom : nextRect.bottom,
|
|
129
|
+
ownerDocument,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return {
|
|
134
|
+
top: previousRect ? previousRect.top : nextRect.top,
|
|
135
|
+
left: previousRect ? previousRect.right : nextRect.left,
|
|
136
|
+
right: nextRect ? nextRect.left : previousRect.right,
|
|
137
|
+
bottom: previousRect ? previousRect.bottom : nextRect.bottom,
|
|
138
|
+
ownerDocument,
|
|
139
|
+
};
|
|
140
|
+
}, [ previousElement, nextElement ] );
|
|
141
|
+
|
|
142
|
+
const popoverScrollRef = usePopoverScroll( __unstableContentRef );
|
|
143
|
+
|
|
144
|
+
if ( ! previousElement || ! nextElement ) {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
|
|
149
|
+
// While ideally it would be enough to capture the
|
|
150
|
+
// bubbling focus event from the Inserter, due to the
|
|
151
|
+
// characteristics of click focusing of `button`s in
|
|
152
|
+
// Firefox and Safari, it is not reliable.
|
|
153
|
+
//
|
|
154
|
+
// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
|
|
155
|
+
return (
|
|
156
|
+
<Popover
|
|
157
|
+
ref={ popoverScrollRef }
|
|
158
|
+
noArrow
|
|
159
|
+
animate={ false }
|
|
160
|
+
getAnchorRect={ getAnchorRect }
|
|
161
|
+
focusOnMount={ false }
|
|
162
|
+
// Render in the old slot if needed for backward compatibility,
|
|
163
|
+
// otherwise render in place (not in the the default popover slot).
|
|
164
|
+
__unstableSlotName={ __unstablePopoverSlot || null }
|
|
165
|
+
// Forces a remount of the popover when its position changes
|
|
166
|
+
// This makes sure the popover doesn't animate from its previous position.
|
|
167
|
+
key={ nextClientId + '--' + rootClientId }
|
|
168
|
+
{ ...props }
|
|
169
|
+
className={ classnames(
|
|
170
|
+
'block-editor-block-popover',
|
|
171
|
+
props.className
|
|
172
|
+
) }
|
|
173
|
+
>
|
|
174
|
+
<div style={ style }>{ children }</div>
|
|
175
|
+
</Popover>
|
|
176
|
+
);
|
|
177
|
+
/* eslint-enable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export default BlockPopoverInbetween;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { Popover } from '@wordpress/components';
|
|
10
|
+
import { getScrollContainer } from '@wordpress/dom';
|
|
11
|
+
import { useMemo } from '@wordpress/element';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Internal dependencies
|
|
15
|
+
*/
|
|
16
|
+
import { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';
|
|
17
|
+
import usePopoverScroll from './use-popover-scroll';
|
|
18
|
+
|
|
19
|
+
export default function BlockPopover( {
|
|
20
|
+
clientId,
|
|
21
|
+
bottomClientId,
|
|
22
|
+
children,
|
|
23
|
+
__unstableRefreshSize,
|
|
24
|
+
__unstableCoverTarget = false,
|
|
25
|
+
__unstablePopoverSlot,
|
|
26
|
+
__unstableContentRef,
|
|
27
|
+
...props
|
|
28
|
+
} ) {
|
|
29
|
+
const selectedElement = useBlockElement( clientId );
|
|
30
|
+
const lastSelectedElement = useBlockElement( bottomClientId ?? clientId );
|
|
31
|
+
const popoverScrollRef = usePopoverScroll( __unstableContentRef );
|
|
32
|
+
const style = useMemo( () => {
|
|
33
|
+
if ( ! selectedElement || lastSelectedElement !== selectedElement ) {
|
|
34
|
+
return {};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
position: 'absolute',
|
|
39
|
+
width: selectedElement.offsetWidth,
|
|
40
|
+
height: selectedElement.offsetHeight,
|
|
41
|
+
};
|
|
42
|
+
}, [ selectedElement, lastSelectedElement, __unstableRefreshSize ] );
|
|
43
|
+
|
|
44
|
+
if ( ! selectedElement || ( bottomClientId && ! lastSelectedElement ) ) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const anchorRef = {
|
|
49
|
+
top: selectedElement,
|
|
50
|
+
bottom: lastSelectedElement,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const { ownerDocument } = selectedElement;
|
|
54
|
+
const stickyBoundaryElement =
|
|
55
|
+
ownerDocument.defaultView.frameElement ||
|
|
56
|
+
getScrollContainer( selectedElement ) ||
|
|
57
|
+
ownerDocument.body;
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<Popover
|
|
61
|
+
ref={ popoverScrollRef }
|
|
62
|
+
noArrow
|
|
63
|
+
animate={ false }
|
|
64
|
+
position="top right left"
|
|
65
|
+
focusOnMount={ false }
|
|
66
|
+
anchorRef={ anchorRef }
|
|
67
|
+
__unstableStickyBoundaryElement={
|
|
68
|
+
__unstableCoverTarget ? undefined : stickyBoundaryElement
|
|
69
|
+
}
|
|
70
|
+
// Render in the old slot if needed for backward compatibility,
|
|
71
|
+
// otherwise render in place (not in the the default popover slot).
|
|
72
|
+
__unstableSlotName={ __unstablePopoverSlot || null }
|
|
73
|
+
__unstableBoundaryParent
|
|
74
|
+
// Observe movement for block animations (especially horizontal).
|
|
75
|
+
__unstableObserveElement={ selectedElement }
|
|
76
|
+
// Used to safeguard sticky position behavior against cases where it would permanently
|
|
77
|
+
// obscure specific sections of a block.
|
|
78
|
+
__unstableEditorCanvasWrapper={ __unstableContentRef?.current }
|
|
79
|
+
__unstableForcePosition={ __unstableCoverTarget }
|
|
80
|
+
{ ...props }
|
|
81
|
+
className={ classnames(
|
|
82
|
+
'block-editor-block-popover',
|
|
83
|
+
props.className
|
|
84
|
+
) }
|
|
85
|
+
>
|
|
86
|
+
{ __unstableCoverTarget && <div style={ style }>{ children }</div> }
|
|
87
|
+
{ ! __unstableCoverTarget && children }
|
|
88
|
+
</Popover>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
|
|
2
|
+
.components-popover.block-editor-block-popover {
|
|
3
|
+
z-index: z-index(".block-editor-block-popover");
|
|
4
|
+
position: absolute;
|
|
5
|
+
// Shouldn't be needed but it looks
|
|
6
|
+
// like the popover is impacted by the block gap margin.
|
|
7
|
+
margin: 0 !important;
|
|
8
|
+
|
|
9
|
+
.components-popover__content {
|
|
10
|
+
margin: 0 !important;
|
|
11
|
+
min-width: auto;
|
|
12
|
+
width: max-content;
|
|
13
|
+
background: none;
|
|
14
|
+
border: none;
|
|
15
|
+
box-shadow: none;
|
|
16
|
+
overflow-y: visible;
|
|
17
|
+
|
|
18
|
+
// Allow clicking through the toolbar holder.
|
|
19
|
+
pointer-events: none;
|
|
20
|
+
|
|
21
|
+
// Position the block toolbar.
|
|
22
|
+
> * {
|
|
23
|
+
pointer-events: all;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
@@ -10,7 +10,7 @@ import { useRefEffect } from '@wordpress/compose';
|
|
|
10
10
|
*
|
|
11
11
|
* @param {Object} scrollableRef
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
function usePopoverScroll( scrollableRef ) {
|
|
14
14
|
return useRefEffect(
|
|
15
15
|
( node ) => {
|
|
16
16
|
if ( ! scrollableRef ) {
|
|
@@ -32,3 +32,5 @@ export function usePopoverScroll( scrollableRef ) {
|
|
|
32
32
|
[ scrollableRef ]
|
|
33
33
|
);
|
|
34
34
|
}
|
|
35
|
+
|
|
36
|
+
export default usePopoverScroll;
|
|
@@ -9,7 +9,6 @@ import classnames from 'classnames';
|
|
|
9
9
|
*/
|
|
10
10
|
import { useState, useLayoutEffect } from '@wordpress/element';
|
|
11
11
|
import { useViewportMatch } from '@wordpress/compose';
|
|
12
|
-
import { ENTER, SPACE } from '@wordpress/keycodes';
|
|
13
12
|
import {
|
|
14
13
|
Button,
|
|
15
14
|
__experimentalText as Text,
|
|
@@ -113,18 +112,8 @@ function BlockStyles( {
|
|
|
113
112
|
onFocus={ () => styleItemHandler( style ) }
|
|
114
113
|
onMouseLeave={ () => styleItemHandler( null ) }
|
|
115
114
|
onBlur={ () => styleItemHandler( null ) }
|
|
116
|
-
onKeyDown={ ( event ) => {
|
|
117
|
-
if (
|
|
118
|
-
ENTER === event.keyCode ||
|
|
119
|
-
SPACE === event.keyCode
|
|
120
|
-
) {
|
|
121
|
-
event.preventDefault();
|
|
122
|
-
onSelectStylePreview( style );
|
|
123
|
-
}
|
|
124
|
-
} }
|
|
125
115
|
onClick={ () => onSelectStylePreview( style ) }
|
|
126
|
-
|
|
127
|
-
tabIndex="0"
|
|
116
|
+
aria-current={ activeStyle.name === style.name }
|
|
128
117
|
>
|
|
129
118
|
<Text
|
|
130
119
|
as="span"
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
.block-editor-block-switcher {
|
|
2
2
|
position: relative;
|
|
3
|
-
padding: 0 ($grid-unit-15 * 0.5);
|
|
4
3
|
|
|
5
4
|
// @todo: override toolbar group inherited paddings from components/block-tools/style.scss.
|
|
6
5
|
// This is best fixed by making the mover control area a proper single toolbar group.
|
|
@@ -47,9 +46,6 @@
|
|
|
47
46
|
|
|
48
47
|
.components-button.block-editor-block-switcher__no-switcher-icon {
|
|
49
48
|
display: flex;
|
|
50
|
-
// The `!important` is used to vastly simplify the overriding of an inherited selector.
|
|
51
|
-
// Can be removed if we refactor .block-editor-block-toolbar .components-toolbar-group .components-button.has-icon.has-icon
|
|
52
|
-
padding: ($grid-unit-15 * 0.5) $grid-unit-15 !important;
|
|
53
49
|
|
|
54
50
|
.block-editor-block-icon {
|
|
55
51
|
margin-right: auto;
|
|
@@ -71,10 +71,6 @@
|
|
|
71
71
|
|
|
72
72
|
// Block controls.
|
|
73
73
|
.block-editor-block-toolbar__block-controls {
|
|
74
|
-
// The !important modifier should be removed when https://github.com/WordPress/gutenberg/issues/24898 refactors the spacing grid.
|
|
75
|
-
height: auto !important;
|
|
76
|
-
padding: 0 !important;
|
|
77
|
-
|
|
78
74
|
// Switcher.
|
|
79
75
|
.block-editor-block-switcher .components-dropdown-menu__toggle,
|
|
80
76
|
.block-editor-block-switcher__no-switcher-icon {
|
|
@@ -84,14 +80,6 @@
|
|
|
84
80
|
}
|
|
85
81
|
}
|
|
86
82
|
|
|
87
|
-
// Match the parent selector button.
|
|
88
|
-
margin-left: -$border-width;
|
|
89
|
-
|
|
90
|
-
// Compensate for width of block switcher.
|
|
91
|
-
.block-editor-block-mover {
|
|
92
|
-
margin-left: -$grid-unit-15 * 0.5;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
83
|
.block-editor-block-lock-toolbar {
|
|
96
84
|
margin-left: -$grid-unit-15 * 0.5 !important;
|
|
97
85
|
}
|
|
@@ -9,7 +9,7 @@ import deprecated from '@wordpress/deprecated';
|
|
|
9
9
|
* Internal dependencies
|
|
10
10
|
*/
|
|
11
11
|
import InsertionPoint, { InsertionPointOpenRef } from './insertion-point';
|
|
12
|
-
import BlockPopover from './block-popover';
|
|
12
|
+
import BlockPopover from './selected-block-popover';
|
|
13
13
|
|
|
14
14
|
export default function BlockToolsBackCompat( { children } ) {
|
|
15
15
|
const openRef = useContext( InsertionPointOpenRef );
|
|
@@ -38,6 +38,7 @@ import BlockIcon from '../block-icon';
|
|
|
38
38
|
import { store as blockEditorStore } from '../../store';
|
|
39
39
|
import BlockDraggable from '../block-draggable';
|
|
40
40
|
import useBlockDisplayInformation from '../use-block-display-information';
|
|
41
|
+
import { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';
|
|
41
42
|
|
|
42
43
|
/**
|
|
43
44
|
* Block selection button component, displaying the label of the block. If the block
|
|
@@ -49,7 +50,7 @@ import useBlockDisplayInformation from '../use-block-display-information';
|
|
|
49
50
|
*
|
|
50
51
|
* @return {WPComponent} The component to be rendered.
|
|
51
52
|
*/
|
|
52
|
-
function BlockSelectionButton( { clientId, rootClientId
|
|
53
|
+
function BlockSelectionButton( { clientId, rootClientId } ) {
|
|
53
54
|
const blockInformation = useBlockDisplayInformation( clientId );
|
|
54
55
|
const selected = useSelect(
|
|
55
56
|
( select ) => {
|
|
@@ -90,6 +91,7 @@ function BlockSelectionButton( { clientId, rootClientId, blockElement } ) {
|
|
|
90
91
|
|
|
91
92
|
speak( label );
|
|
92
93
|
}, [ label ] );
|
|
94
|
+
const blockElement = useBlockElement( clientId );
|
|
93
95
|
|
|
94
96
|
const {
|
|
95
97
|
hasBlockMovingClientId,
|
|
@@ -15,10 +15,10 @@ import { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordp
|
|
|
15
15
|
* Internal dependencies
|
|
16
16
|
*/
|
|
17
17
|
import InsertionPoint from './insertion-point';
|
|
18
|
-
import
|
|
18
|
+
import SelectedBlockPopover from './selected-block-popover';
|
|
19
19
|
import { store as blockEditorStore } from '../../store';
|
|
20
20
|
import BlockContextualToolbar from './block-contextual-toolbar';
|
|
21
|
-
import
|
|
21
|
+
import usePopoverScroll from '../block-popover/use-popover-scroll';
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Renders block tools (the block toolbar, select/navigation mode toolbar, the
|
|
@@ -112,8 +112,10 @@ export default function BlockTools( {
|
|
|
112
112
|
<BlockContextualToolbar isFixed />
|
|
113
113
|
) }
|
|
114
114
|
{ /* Even if the toolbar is fixed, the block popover is still
|
|
115
|
-
|
|
116
|
-
<
|
|
115
|
+
needed for navigation and exploded mode. */ }
|
|
116
|
+
<SelectedBlockPopover
|
|
117
|
+
__unstableContentRef={ __unstableContentRef }
|
|
118
|
+
/>
|
|
117
119
|
{ /* Used for the inline rich text toolbar. */ }
|
|
118
120
|
<Popover.Slot
|
|
119
121
|
name="block-toolbar"
|
|
@@ -7,24 +7,16 @@ import classnames from 'classnames';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
useRef,
|
|
13
|
-
useMemo,
|
|
14
|
-
createContext,
|
|
15
|
-
useContext,
|
|
16
|
-
} from '@wordpress/element';
|
|
17
|
-
import { Popover, __unstableMotion as motion } from '@wordpress/components';
|
|
10
|
+
import { useRef, createContext, useContext } from '@wordpress/element';
|
|
11
|
+
import { __unstableMotion as motion } from '@wordpress/components';
|
|
18
12
|
import { useReducedMotion } from '@wordpress/compose';
|
|
19
|
-
import { isRTL } from '@wordpress/i18n';
|
|
20
13
|
|
|
21
14
|
/**
|
|
22
15
|
* Internal dependencies
|
|
23
16
|
*/
|
|
24
17
|
import Inserter from '../inserter';
|
|
25
18
|
import { store as blockEditorStore } from '../../store';
|
|
26
|
-
import
|
|
27
|
-
import { usePopoverScroll } from './use-popover-scroll';
|
|
19
|
+
import BlockPopoverInbetween from '../block-popover/inbetween';
|
|
28
20
|
|
|
29
21
|
export const InsertionPointOpenRef = createContext();
|
|
30
22
|
|
|
@@ -78,109 +70,10 @@ function InsertionPointPopover( {
|
|
|
78
70
|
isInserterShown: insertionPoint?.__unstableWithInserter,
|
|
79
71
|
};
|
|
80
72
|
}, [] );
|
|
81
|
-
const previousElement = useBlockElement( previousClientId );
|
|
82
|
-
const nextElement = useBlockElement( nextClientId );
|
|
83
73
|
const isVertical = orientation === 'vertical';
|
|
84
|
-
const style = useMemo( () => {
|
|
85
|
-
if ( ! previousElement && ! nextElement ) {
|
|
86
|
-
return {};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const previousRect = previousElement
|
|
90
|
-
? previousElement.getBoundingClientRect()
|
|
91
|
-
: null;
|
|
92
|
-
const nextRect = nextElement
|
|
93
|
-
? nextElement.getBoundingClientRect()
|
|
94
|
-
: null;
|
|
95
|
-
|
|
96
|
-
if ( isVertical ) {
|
|
97
|
-
return {
|
|
98
|
-
width: previousElement
|
|
99
|
-
? previousElement.offsetWidth
|
|
100
|
-
: nextElement.offsetWidth,
|
|
101
|
-
height:
|
|
102
|
-
nextRect && previousRect
|
|
103
|
-
? nextRect.top - previousRect.bottom
|
|
104
|
-
: 0,
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
let width = 0;
|
|
109
|
-
if ( previousRect && nextRect ) {
|
|
110
|
-
width = isRTL()
|
|
111
|
-
? previousRect.left - nextRect.right
|
|
112
|
-
: nextRect.left - previousRect.right;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return {
|
|
116
|
-
width,
|
|
117
|
-
height: previousElement
|
|
118
|
-
? previousElement.offsetHeight
|
|
119
|
-
: nextElement.offsetHeight,
|
|
120
|
-
};
|
|
121
|
-
}, [ previousElement, nextElement ] );
|
|
122
|
-
|
|
123
|
-
const getAnchorRect = useCallback( () => {
|
|
124
|
-
if ( ! previousElement && ! nextElement ) {
|
|
125
|
-
return {};
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const { ownerDocument } = previousElement || nextElement;
|
|
129
|
-
|
|
130
|
-
const previousRect = previousElement
|
|
131
|
-
? previousElement.getBoundingClientRect()
|
|
132
|
-
: null;
|
|
133
|
-
const nextRect = nextElement
|
|
134
|
-
? nextElement.getBoundingClientRect()
|
|
135
|
-
: null;
|
|
136
|
-
|
|
137
|
-
if ( isVertical ) {
|
|
138
|
-
if ( isRTL() ) {
|
|
139
|
-
return {
|
|
140
|
-
top: previousRect ? previousRect.bottom : nextRect.top,
|
|
141
|
-
left: previousRect ? previousRect.right : nextRect.right,
|
|
142
|
-
right: previousRect ? previousRect.left : nextRect.left,
|
|
143
|
-
bottom: nextRect ? nextRect.top : previousRect.bottom,
|
|
144
|
-
ownerDocument,
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return {
|
|
149
|
-
top: previousRect ? previousRect.bottom : nextRect.top,
|
|
150
|
-
left: previousRect ? previousRect.left : nextRect.left,
|
|
151
|
-
right: previousRect ? previousRect.right : nextRect.right,
|
|
152
|
-
bottom: nextRect ? nextRect.top : previousRect.bottom,
|
|
153
|
-
ownerDocument,
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
if ( isRTL() ) {
|
|
158
|
-
return {
|
|
159
|
-
top: previousRect ? previousRect.top : nextRect.top,
|
|
160
|
-
left: previousRect ? previousRect.left : nextRect.right,
|
|
161
|
-
right: nextRect ? nextRect.right : previousRect.left,
|
|
162
|
-
bottom: previousRect ? previousRect.bottom : nextRect.bottom,
|
|
163
|
-
ownerDocument,
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
74
|
|
|
167
|
-
return {
|
|
168
|
-
top: previousRect ? previousRect.top : nextRect.top,
|
|
169
|
-
left: previousRect ? previousRect.right : nextRect.left,
|
|
170
|
-
right: nextRect ? nextRect.left : previousRect.right,
|
|
171
|
-
bottom: previousRect ? previousRect.bottom : nextRect.bottom,
|
|
172
|
-
ownerDocument,
|
|
173
|
-
};
|
|
174
|
-
}, [ previousElement, nextElement ] );
|
|
175
|
-
|
|
176
|
-
const popoverScrollRef = usePopoverScroll( __unstableContentRef );
|
|
177
75
|
const disableMotion = useReducedMotion();
|
|
178
76
|
|
|
179
|
-
const className = classnames(
|
|
180
|
-
'block-editor-block-list__insertion-point',
|
|
181
|
-
'is-' + orientation
|
|
182
|
-
);
|
|
183
|
-
|
|
184
77
|
function onClick( event ) {
|
|
185
78
|
if ( event.target === ref.current && nextClientId ) {
|
|
186
79
|
selectBlock( nextClientId, -1 );
|
|
@@ -203,11 +96,6 @@ function InsertionPointPopover( {
|
|
|
203
96
|
}
|
|
204
97
|
}
|
|
205
98
|
|
|
206
|
-
// Only show the in-between inserter between blocks, so when there's a
|
|
207
|
-
// previous and a next element.
|
|
208
|
-
const showInsertionPointInserter =
|
|
209
|
-
previousElement && nextElement && isInserterShown;
|
|
210
|
-
|
|
211
99
|
// Define animation variants for the line element.
|
|
212
100
|
const horizontalLine = {
|
|
213
101
|
start: {
|
|
@@ -261,7 +149,7 @@ function InsertionPointPopover( {
|
|
|
261
149
|
...( ! isVertical ? horizontalLine.rest : verticalLine.rest ),
|
|
262
150
|
opacity: 1,
|
|
263
151
|
borderRadius: '2px',
|
|
264
|
-
transition: { delay:
|
|
152
|
+
transition: { delay: isInserterShown ? 0.4 : 0 },
|
|
265
153
|
},
|
|
266
154
|
hover: {
|
|
267
155
|
...( ! isVertical ? horizontalLine.hover : verticalLine.hover ),
|
|
@@ -281,27 +169,17 @@ function InsertionPointPopover( {
|
|
|
281
169
|
},
|
|
282
170
|
};
|
|
283
171
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
//
|
|
290
|
-
// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
|
|
172
|
+
const className = classnames(
|
|
173
|
+
'block-editor-block-list__insertion-point',
|
|
174
|
+
'is-' + orientation
|
|
175
|
+
);
|
|
176
|
+
|
|
291
177
|
return (
|
|
292
|
-
<
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
focusOnMount={ false }
|
|
298
|
-
className="block-editor-block-list__insertion-point-popover"
|
|
299
|
-
// Render in the old slot if needed for backward compatibility,
|
|
300
|
-
// otherwise render in place (not in the the default popover slot).
|
|
301
|
-
__unstableSlotName={ __unstablePopoverSlot || null }
|
|
302
|
-
// Forces a remount of the popover when its position changes
|
|
303
|
-
// This makes sure the popover doesn't animate from its previous position.
|
|
304
|
-
key={ nextClientId + '--' + rootClientId }
|
|
178
|
+
<BlockPopoverInbetween
|
|
179
|
+
previousClientId={ previousClientId }
|
|
180
|
+
nextClientId={ nextClientId }
|
|
181
|
+
__unstablePopoverSlot={ __unstablePopoverSlot }
|
|
182
|
+
__unstableContentRef={ __unstableContentRef }
|
|
305
183
|
>
|
|
306
184
|
<motion.div
|
|
307
185
|
layout={ ! disableMotion }
|
|
@@ -315,16 +193,15 @@ function InsertionPointPopover( {
|
|
|
315
193
|
onClick={ onClick }
|
|
316
194
|
onFocus={ onFocus }
|
|
317
195
|
className={ classnames( className, {
|
|
318
|
-
'is-with-inserter':
|
|
196
|
+
'is-with-inserter': isInserterShown,
|
|
319
197
|
} ) }
|
|
320
198
|
onHoverEnd={ maybeHideInserterPoint }
|
|
321
|
-
style={ style }
|
|
322
199
|
>
|
|
323
200
|
<motion.div
|
|
324
201
|
variants={ lineVariants }
|
|
325
202
|
className="block-editor-block-list__insertion-point-indicator"
|
|
326
203
|
/>
|
|
327
|
-
{
|
|
204
|
+
{ isInserterShown && (
|
|
328
205
|
<motion.div
|
|
329
206
|
variants={ inserterVariants }
|
|
330
207
|
className={ classnames(
|
|
@@ -346,28 +223,18 @@ function InsertionPointPopover( {
|
|
|
346
223
|
</motion.div>
|
|
347
224
|
) }
|
|
348
225
|
</motion.div>
|
|
349
|
-
</
|
|
226
|
+
</BlockPopoverInbetween>
|
|
350
227
|
);
|
|
351
|
-
/* eslint-enable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
|
|
352
228
|
}
|
|
353
229
|
|
|
354
|
-
export default function InsertionPoint( {
|
|
355
|
-
children,
|
|
356
|
-
__unstablePopoverSlot,
|
|
357
|
-
__unstableContentRef,
|
|
358
|
-
} ) {
|
|
230
|
+
export default function InsertionPoint( { children, ...props } ) {
|
|
359
231
|
const isVisible = useSelect( ( select ) => {
|
|
360
232
|
return select( blockEditorStore ).isBlockInsertionPointVisible();
|
|
361
233
|
}, [] );
|
|
362
234
|
|
|
363
235
|
return (
|
|
364
236
|
<InsertionPointOpenRef.Provider value={ useRef( false ) }>
|
|
365
|
-
{ isVisible &&
|
|
366
|
-
<InsertionPointPopover
|
|
367
|
-
__unstablePopoverSlot={ __unstablePopoverSlot }
|
|
368
|
-
__unstableContentRef={ __unstableContentRef }
|
|
369
|
-
/>
|
|
370
|
-
) }
|
|
237
|
+
{ isVisible && <InsertionPointPopover { ...props } /> }
|
|
371
238
|
{ children }
|
|
372
239
|
</InsertionPointOpenRef.Provider>
|
|
373
240
|
);
|