@wordpress/block-editor 8.5.0 → 8.6.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 +2 -0
- package/build/components/block-alignment-control/ui.js +1 -1
- package/build/components/block-alignment-control/ui.js.map +1 -1
- 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-lock/index.js +8 -0
- package/build/components/block-lock/index.js.map +1 -1
- package/build/components/block-lock/menu-item.js +5 -20
- package/build/components/block-lock/menu-item.js.map +1 -1
- package/build/components/block-lock/modal.js +33 -12
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-lock/toolbar.js +7 -20
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-lock/use-block-lock.js +50 -0
- package/build/components/block-lock/use-block-lock.js.map +1 -0
- 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-pattern-setup/index.js +37 -22
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-pattern-setup/setup-toolbar.js +1 -1
- package/build/components/block-pattern-setup/setup-toolbar.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 +82 -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-preview/auto.js +6 -3
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-preview/index.js +4 -2
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-styles/index.js +1 -10
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-switcher/index.js +7 -2
- package/build/components/block-switcher/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/copy-handler/index.js +44 -9
- package/build/components/copy-handler/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/inserter/index.native.js +30 -8
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/link-control/index.js +6 -7
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +4 -10
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +13 -2
- package/build/components/list-view/block.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/use-block-display-information/index.js +3 -1
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/hooks/border.js +468 -44
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/duotone.js +66 -16
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/index.js +8 -2
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/use-border-props.js +22 -32
- package/build/hooks/use-border-props.js.map +1 -1
- package/build/index.js +7 -0
- package/build/index.js.map +1 -1
- package/build/store/actions.js +36 -31
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +0 -26
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +131 -6
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +27 -0
- package/build/store/utils.js.map +1 -0
- package/build-module/components/block-alignment-control/ui.js +2 -2
- package/build-module/components/block-alignment-control/ui.js.map +1 -1
- 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-lock/index.js +1 -0
- package/build-module/components/block-lock/index.js.map +1 -1
- package/build-module/components/block-lock/menu-item.js +4 -18
- package/build-module/components/block-lock/menu-item.js.map +1 -1
- package/build-module/components/block-lock/modal.js +31 -12
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +6 -18
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-lock/use-block-lock.js +41 -0
- package/build-module/components/block-lock/use-block-lock.js.map +1 -0
- 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-pattern-setup/index.js +39 -24
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.js +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.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 +67 -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-preview/auto.js +6 -3
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-preview/index.js +4 -2
- package/build-module/components/block-preview/index.js.map +1 -1
- 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-switcher/index.js +7 -2
- package/build-module/components/block-switcher/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/copy-handler/index.js +44 -9
- package/build-module/components/copy-handler/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/inserter/index.native.js +31 -10
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/link-control/index.js +6 -7
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +4 -9
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +13 -2
- package/build-module/components/list-view/block.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/use-block-display-information/index.js +3 -1
- package/build-module/components/use-block-display-information/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/duotone.js +63 -16
- package/build-module/hooks/duotone.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/use-border-props.js +21 -30
- package/build-module/hooks/use-border-props.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +19 -16
- package/build-module/store/actions.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 +120 -5
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +20 -0
- package/build-module/store/utils.js.map +1 -0
- package/build-style/style-rtl.css +145 -272
- package/build-style/style.css +145 -272
- package/package.json +28 -28
- package/src/components/block-alignment-control/ui.js +2 -2
- package/src/components/block-content-overlay/index.js +19 -2
- package/src/components/block-list/block.native.js +2 -0
- package/src/components/block-lock/index.js +1 -0
- package/src/components/block-lock/menu-item.js +3 -23
- package/src/components/block-lock/modal.js +37 -13
- package/src/components/block-lock/style.scss +1 -2
- package/src/components/block-lock/toolbar.js +4 -21
- package/src/components/block-lock/use-block-lock.js +45 -0
- 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-pattern-setup/index.js +84 -59
- package/src/components/block-pattern-setup/setup-toolbar.js +3 -1
- package/src/components/block-pattern-setup/style.scss +32 -26
- 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 +73 -0
- package/src/components/block-popover/style.scss +24 -0
- package/src/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
- package/src/components/block-preview/auto.js +10 -1
- package/src/components/block-preview/index.js +2 -0
- package/src/components/block-styles/index.js +1 -12
- package/src/components/block-switcher/index.js +13 -1
- package/src/components/block-switcher/style.scss +4 -4
- package/src/components/block-switcher/test/__snapshots__/index.js.snap +15 -13
- 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/copy-handler/index.js +52 -10
- 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/inserter/index.native.js +60 -25
- package/src/components/inserter/style.native.scss +24 -3
- package/src/components/link-control/index.js +5 -5
- package/src/components/list-view/block-select-button.js +2 -10
- package/src/components/list-view/block.js +16 -7
- 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/use-block-display-information/index.js +2 -0
- package/src/hooks/border.js +438 -72
- package/src/hooks/border.scss +48 -0
- package/src/hooks/duotone.js +98 -62
- package/src/hooks/index.js +2 -1
- package/src/hooks/use-border-props.js +15 -32
- package/src/index.js +1 -0
- package/src/store/actions.js +19 -15
- package/src/store/reducer.js +0 -21
- package/src/store/selectors.js +160 -5
- package/src/store/test/actions.js +0 -18
- package/src/store/test/reducer.js +0 -19
- package/src/store/test/selectors.js +0 -19
- package/src/store/utils.js +19 -0
- package/src/style.scss +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/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/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/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,73 @@
|
|
|
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
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';
|
|
16
|
+
import usePopoverScroll from './use-popover-scroll';
|
|
17
|
+
|
|
18
|
+
export default function BlockPopover( {
|
|
19
|
+
clientId,
|
|
20
|
+
bottomClientId,
|
|
21
|
+
children,
|
|
22
|
+
__unstablePopoverSlot,
|
|
23
|
+
__unstableContentRef,
|
|
24
|
+
...props
|
|
25
|
+
} ) {
|
|
26
|
+
const selectedElement = useBlockElement( clientId );
|
|
27
|
+
const lastSelectedElement = useBlockElement( bottomClientId ?? clientId );
|
|
28
|
+
const popoverScrollRef = usePopoverScroll( __unstableContentRef );
|
|
29
|
+
|
|
30
|
+
if ( ! selectedElement || ( bottomClientId && ! lastSelectedElement ) ) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const anchorRef = {
|
|
35
|
+
top: selectedElement,
|
|
36
|
+
bottom: lastSelectedElement,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const { ownerDocument } = selectedElement;
|
|
40
|
+
const stickyBoundaryElement =
|
|
41
|
+
ownerDocument.defaultView.frameElement ||
|
|
42
|
+
getScrollContainer( selectedElement ) ||
|
|
43
|
+
ownerDocument.body;
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Popover
|
|
47
|
+
ref={ popoverScrollRef }
|
|
48
|
+
noArrow
|
|
49
|
+
animate={ false }
|
|
50
|
+
position="top right left"
|
|
51
|
+
focusOnMount={ false }
|
|
52
|
+
anchorRef={ anchorRef }
|
|
53
|
+
__unstableStickyBoundaryElement={ stickyBoundaryElement }
|
|
54
|
+
// Render in the old slot if needed for backward compatibility,
|
|
55
|
+
// otherwise render in place (not in the the default popover slot).
|
|
56
|
+
__unstableSlotName={ __unstablePopoverSlot || null }
|
|
57
|
+
__unstableBoundaryParent
|
|
58
|
+
// Observe movement for block animations (especially horizontal).
|
|
59
|
+
__unstableObserveElement={ selectedElement }
|
|
60
|
+
shouldAnchorIncludePadding
|
|
61
|
+
// Used to safeguard sticky position behavior against cases where it would permanently
|
|
62
|
+
// obscure specific sections of a block.
|
|
63
|
+
__unstableEditorCanvasWrapper={ __unstableContentRef?.current }
|
|
64
|
+
{ ...props }
|
|
65
|
+
className={ classnames(
|
|
66
|
+
'block-editor-block-popover',
|
|
67
|
+
props.className
|
|
68
|
+
) }
|
|
69
|
+
>
|
|
70
|
+
{ children }
|
|
71
|
+
</Popover>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
.components-popover.block-editor-block-popover {
|
|
3
|
+
z-index: z-index(".block-editor-block-popover");
|
|
4
|
+
position: absolute;
|
|
5
|
+
|
|
6
|
+
.components-popover__content {
|
|
7
|
+
margin: 0 !important;
|
|
8
|
+
min-width: auto;
|
|
9
|
+
width: max-content;
|
|
10
|
+
background: none;
|
|
11
|
+
border: none;
|
|
12
|
+
box-shadow: none;
|
|
13
|
+
overflow-y: visible;
|
|
14
|
+
|
|
15
|
+
// Allow clicking through the toolbar holder.
|
|
16
|
+
pointer-events: none;
|
|
17
|
+
|
|
18
|
+
// Position the block toolbar.
|
|
19
|
+
> * {
|
|
20
|
+
pointer-events: all;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
@@ -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;
|
|
@@ -19,7 +19,11 @@ let MemoizedBlockList;
|
|
|
19
19
|
|
|
20
20
|
const MAX_HEIGHT = 2000;
|
|
21
21
|
|
|
22
|
-
function AutoBlockPreview( {
|
|
22
|
+
function AutoBlockPreview( {
|
|
23
|
+
viewportWidth,
|
|
24
|
+
__experimentalPadding,
|
|
25
|
+
__experimentalMinHeight,
|
|
26
|
+
} ) {
|
|
23
27
|
const [
|
|
24
28
|
containerResizeListener,
|
|
25
29
|
{ width: containerWidth },
|
|
@@ -68,6 +72,7 @@ function AutoBlockPreview( { viewportWidth, __experimentalPadding } ) {
|
|
|
68
72
|
contentHeight > MAX_HEIGHT
|
|
69
73
|
? MAX_HEIGHT * scale
|
|
70
74
|
: undefined,
|
|
75
|
+
minHeight: __experimentalMinHeight,
|
|
71
76
|
} }
|
|
72
77
|
>
|
|
73
78
|
<Iframe
|
|
@@ -98,6 +103,10 @@ function AutoBlockPreview( { viewportWidth, __experimentalPadding } ) {
|
|
|
98
103
|
// This is a catch-all max-height for patterns.
|
|
99
104
|
// See: https://github.com/WordPress/gutenberg/pull/38175.
|
|
100
105
|
maxHeight: MAX_HEIGHT,
|
|
106
|
+
minHeight:
|
|
107
|
+
scale < 1 && __experimentalMinHeight
|
|
108
|
+
? __experimentalMinHeight / scale
|
|
109
|
+
: __experimentalMinHeight,
|
|
101
110
|
} }
|
|
102
111
|
>
|
|
103
112
|
{ contentResizeListener }
|
|
@@ -29,6 +29,7 @@ export function BlockPreview( {
|
|
|
29
29
|
viewportWidth = 1200,
|
|
30
30
|
__experimentalLive = false,
|
|
31
31
|
__experimentalOnClick,
|
|
32
|
+
__experimentalMinHeight,
|
|
32
33
|
} ) {
|
|
33
34
|
const originalSettings = useSelect(
|
|
34
35
|
( select ) => select( blockEditorStore ).getSettings(),
|
|
@@ -51,6 +52,7 @@ export function BlockPreview( {
|
|
|
51
52
|
<AutoHeightBlockPreview
|
|
52
53
|
viewportWidth={ viewportWidth }
|
|
53
54
|
__experimentalPadding={ __experimentalPadding }
|
|
55
|
+
__experimentalMinHeight={ __experimentalMinHeight }
|
|
54
56
|
/>
|
|
55
57
|
) }
|
|
56
58
|
</BlockEditorProvider>
|
|
@@ -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"
|
|
@@ -108,7 +108,19 @@ export const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => {
|
|
|
108
108
|
disabled
|
|
109
109
|
className="block-editor-block-switcher__no-switcher-icon"
|
|
110
110
|
title={ blockTitle }
|
|
111
|
-
icon={
|
|
111
|
+
icon={
|
|
112
|
+
<>
|
|
113
|
+
<BlockIcon icon={ icon } showColors />
|
|
114
|
+
{ ( isReusable || isTemplate ) && (
|
|
115
|
+
<span className="block-editor-block-switcher__toggle-text">
|
|
116
|
+
<BlockTitle
|
|
117
|
+
clientId={ clientIds }
|
|
118
|
+
maximumLength={ 35 }
|
|
119
|
+
/>
|
|
120
|
+
</span>
|
|
121
|
+
) }
|
|
122
|
+
</>
|
|
123
|
+
}
|
|
112
124
|
/>
|
|
113
125
|
</ToolbarGroup>
|
|
114
126
|
);
|
|
@@ -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.
|
|
@@ -46,11 +45,12 @@
|
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
.components-button.block-editor-block-switcher__no-switcher-icon {
|
|
49
|
-
|
|
48
|
+
display: flex;
|
|
50
49
|
|
|
51
|
-
.block-editor-
|
|
50
|
+
.block-editor-block-icon {
|
|
52
51
|
margin-right: auto;
|
|
53
52
|
margin-left: auto;
|
|
53
|
+
min-width: $icon-size !important;
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -172,7 +172,7 @@
|
|
|
172
172
|
// The block switcher in the contextual toolbar should be bigger.
|
|
173
173
|
.block-editor-block-contextual-toolbar {
|
|
174
174
|
.components-button.block-editor-block-switcher__no-switcher-icon {
|
|
175
|
-
width: $
|
|
175
|
+
min-width: $button-size;
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
.components-button.block-editor-block-switcher__no-switcher-icon,
|
|
@@ -6,19 +6,21 @@ exports[`BlockSwitcherDropdownMenu should render disabled block switcher with mu
|
|
|
6
6
|
className="block-editor-block-switcher__no-switcher-icon"
|
|
7
7
|
disabled={true}
|
|
8
8
|
icon={
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
9
|
+
<React.Fragment>
|
|
10
|
+
<Memo(BlockIcon)
|
|
11
|
+
icon={
|
|
12
|
+
<SVG
|
|
13
|
+
viewBox="0 0 24 24"
|
|
14
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
15
|
+
>
|
|
16
|
+
<Path
|
|
17
|
+
d="M20.2 8v11c0 .7-.6 1.2-1.2 1.2H6v1.5h13c1.5 0 2.7-1.2 2.7-2.8V8zM18 16.4V4.6c0-.9-.7-1.6-1.6-1.6H4.6C3.7 3 3 3.7 3 4.6v11.8c0 .9.7 1.6 1.6 1.6h11.8c.9 0 1.6-.7 1.6-1.6zm-13.5 0V4.6c0-.1.1-.1.1-.1h11.8c.1 0 .1.1.1.1v11.8c0 .1-.1.1-.1.1H4.6l-.1-.1z"
|
|
18
|
+
/>
|
|
19
|
+
</SVG>
|
|
20
|
+
}
|
|
21
|
+
showColors={true}
|
|
22
|
+
/>
|
|
23
|
+
</React.Fragment>
|
|
22
24
|
}
|
|
23
25
|
/>
|
|
24
26
|
</ToolbarGroup>
|
|
@@ -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"
|