@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
|
@@ -9,18 +9,16 @@ import classnames from 'classnames';
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
12
|
+
import { useRef, createContext, useContext } from '@wordpress/element';
|
|
13
|
+
import { __unstableMotion as motion } from '@wordpress/components';
|
|
14
14
|
import { useReducedMotion } from '@wordpress/compose';
|
|
15
|
-
import { isRTL } from '@wordpress/i18n';
|
|
16
15
|
/**
|
|
17
16
|
* Internal dependencies
|
|
18
17
|
*/
|
|
19
18
|
|
|
20
19
|
import Inserter from '../inserter';
|
|
21
20
|
import { store as blockEditorStore } from '../../store';
|
|
22
|
-
import
|
|
23
|
-
import { usePopoverScroll } from './use-popover-scroll';
|
|
21
|
+
import BlockPopoverInbetween from '../block-popover/inbetween';
|
|
24
22
|
export const InsertionPointOpenRef = createContext();
|
|
25
23
|
|
|
26
24
|
function InsertionPointPopover(_ref) {
|
|
@@ -77,87 +75,8 @@ function InsertionPointPopover(_ref) {
|
|
|
77
75
|
isInserterShown: insertionPoint === null || insertionPoint === void 0 ? void 0 : insertionPoint.__unstableWithInserter
|
|
78
76
|
};
|
|
79
77
|
}, []);
|
|
80
|
-
const previousElement = useBlockElement(previousClientId);
|
|
81
|
-
const nextElement = useBlockElement(nextClientId);
|
|
82
78
|
const isVertical = orientation === 'vertical';
|
|
83
|
-
const style = useMemo(() => {
|
|
84
|
-
if (!previousElement && !nextElement) {
|
|
85
|
-
return {};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const previousRect = previousElement ? previousElement.getBoundingClientRect() : null;
|
|
89
|
-
const nextRect = nextElement ? nextElement.getBoundingClientRect() : null;
|
|
90
|
-
|
|
91
|
-
if (isVertical) {
|
|
92
|
-
return {
|
|
93
|
-
width: previousElement ? previousElement.offsetWidth : nextElement.offsetWidth,
|
|
94
|
-
height: nextRect && previousRect ? nextRect.top - previousRect.bottom : 0
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
let width = 0;
|
|
99
|
-
|
|
100
|
-
if (previousRect && nextRect) {
|
|
101
|
-
width = isRTL() ? previousRect.left - nextRect.right : nextRect.left - previousRect.right;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return {
|
|
105
|
-
width,
|
|
106
|
-
height: previousElement ? previousElement.offsetHeight : nextElement.offsetHeight
|
|
107
|
-
};
|
|
108
|
-
}, [previousElement, nextElement]);
|
|
109
|
-
const getAnchorRect = useCallback(() => {
|
|
110
|
-
if (!previousElement && !nextElement) {
|
|
111
|
-
return {};
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const {
|
|
115
|
-
ownerDocument
|
|
116
|
-
} = previousElement || nextElement;
|
|
117
|
-
const previousRect = previousElement ? previousElement.getBoundingClientRect() : null;
|
|
118
|
-
const nextRect = nextElement ? nextElement.getBoundingClientRect() : null;
|
|
119
|
-
|
|
120
|
-
if (isVertical) {
|
|
121
|
-
if (isRTL()) {
|
|
122
|
-
return {
|
|
123
|
-
top: previousRect ? previousRect.bottom : nextRect.top,
|
|
124
|
-
left: previousRect ? previousRect.right : nextRect.right,
|
|
125
|
-
right: previousRect ? previousRect.left : nextRect.left,
|
|
126
|
-
bottom: nextRect ? nextRect.top : previousRect.bottom,
|
|
127
|
-
ownerDocument
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return {
|
|
132
|
-
top: previousRect ? previousRect.bottom : nextRect.top,
|
|
133
|
-
left: previousRect ? previousRect.left : nextRect.left,
|
|
134
|
-
right: previousRect ? previousRect.right : nextRect.right,
|
|
135
|
-
bottom: nextRect ? nextRect.top : previousRect.bottom,
|
|
136
|
-
ownerDocument
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (isRTL()) {
|
|
141
|
-
return {
|
|
142
|
-
top: previousRect ? previousRect.top : nextRect.top,
|
|
143
|
-
left: previousRect ? previousRect.left : nextRect.right,
|
|
144
|
-
right: nextRect ? nextRect.right : previousRect.left,
|
|
145
|
-
bottom: previousRect ? previousRect.bottom : nextRect.bottom,
|
|
146
|
-
ownerDocument
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return {
|
|
151
|
-
top: previousRect ? previousRect.top : nextRect.top,
|
|
152
|
-
left: previousRect ? previousRect.right : nextRect.left,
|
|
153
|
-
right: nextRect ? nextRect.left : previousRect.right,
|
|
154
|
-
bottom: previousRect ? previousRect.bottom : nextRect.bottom,
|
|
155
|
-
ownerDocument
|
|
156
|
-
};
|
|
157
|
-
}, [previousElement, nextElement]);
|
|
158
|
-
const popoverScrollRef = usePopoverScroll(__unstableContentRef);
|
|
159
79
|
const disableMotion = useReducedMotion();
|
|
160
|
-
const className = classnames('block-editor-block-list__insertion-point', 'is-' + orientation);
|
|
161
80
|
|
|
162
81
|
function onClick(event) {
|
|
163
82
|
if (event.target === ref.current && nextClientId) {
|
|
@@ -179,11 +98,8 @@ function InsertionPointPopover(_ref) {
|
|
|
179
98
|
if (event.target === ref.current && !openRef.current) {
|
|
180
99
|
hideInsertionPoint();
|
|
181
100
|
}
|
|
182
|
-
} //
|
|
183
|
-
// previous and a next element.
|
|
184
|
-
|
|
101
|
+
} // Define animation variants for the line element.
|
|
185
102
|
|
|
186
|
-
const showInsertionPointInserter = previousElement && nextElement && isInserterShown; // Define animation variants for the line element.
|
|
187
103
|
|
|
188
104
|
const horizontalLine = {
|
|
189
105
|
start: {
|
|
@@ -236,7 +152,7 @@ function InsertionPointPopover(_ref) {
|
|
|
236
152
|
opacity: 1,
|
|
237
153
|
borderRadius: '2px',
|
|
238
154
|
transition: {
|
|
239
|
-
delay:
|
|
155
|
+
delay: isInserterShown ? 0.4 : 0
|
|
240
156
|
}
|
|
241
157
|
},
|
|
242
158
|
hover: { ...(!isVertical ? horizontalLine.hover : verticalLine.hover),
|
|
@@ -258,27 +174,12 @@ function InsertionPointPopover(_ref) {
|
|
|
258
174
|
}
|
|
259
175
|
}
|
|
260
176
|
};
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
|
|
268
|
-
|
|
269
|
-
return createElement(Popover, {
|
|
270
|
-
ref: popoverScrollRef,
|
|
271
|
-
noArrow: true,
|
|
272
|
-
animate: false,
|
|
273
|
-
getAnchorRect: getAnchorRect,
|
|
274
|
-
focusOnMount: false,
|
|
275
|
-
className: "block-editor-block-list__insertion-point-popover" // Render in the old slot if needed for backward compatibility,
|
|
276
|
-
// otherwise render in place (not in the the default popover slot).
|
|
277
|
-
,
|
|
278
|
-
__unstableSlotName: __unstablePopoverSlot || null // Forces a remount of the popover when its position changes
|
|
279
|
-
// This makes sure the popover doesn't animate from its previous position.
|
|
280
|
-
,
|
|
281
|
-
key: nextClientId + '--' + rootClientId
|
|
177
|
+
const className = classnames('block-editor-block-list__insertion-point', 'is-' + orientation);
|
|
178
|
+
return createElement(BlockPopoverInbetween, {
|
|
179
|
+
previousClientId: previousClientId,
|
|
180
|
+
nextClientId: nextClientId,
|
|
181
|
+
__unstablePopoverSlot: __unstablePopoverSlot,
|
|
182
|
+
__unstableContentRef: __unstableContentRef
|
|
282
183
|
}, createElement(motion.div, {
|
|
283
184
|
layout: !disableMotion,
|
|
284
185
|
initial: disableMotion ? 'rest' : 'start',
|
|
@@ -291,14 +192,13 @@ function InsertionPointPopover(_ref) {
|
|
|
291
192
|
onClick: onClick,
|
|
292
193
|
onFocus: onFocus,
|
|
293
194
|
className: classnames(className, {
|
|
294
|
-
'is-with-inserter':
|
|
195
|
+
'is-with-inserter': isInserterShown
|
|
295
196
|
}),
|
|
296
|
-
onHoverEnd: maybeHideInserterPoint
|
|
297
|
-
style: style
|
|
197
|
+
onHoverEnd: maybeHideInserterPoint
|
|
298
198
|
}, createElement(motion.div, {
|
|
299
199
|
variants: lineVariants,
|
|
300
200
|
className: "block-editor-block-list__insertion-point-indicator"
|
|
301
|
-
}),
|
|
201
|
+
}), isInserterShown && createElement(motion.div, {
|
|
302
202
|
variants: inserterVariants,
|
|
303
203
|
className: classnames('block-editor-block-list__insertion-point-inserter')
|
|
304
204
|
}, createElement(Inserter, {
|
|
@@ -313,23 +213,18 @@ function InsertionPointPopover(_ref) {
|
|
|
313
213
|
openRef.current = false;
|
|
314
214
|
}
|
|
315
215
|
}))));
|
|
316
|
-
/* eslint-enable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
|
|
317
216
|
}
|
|
318
217
|
|
|
319
218
|
export default function InsertionPoint(_ref2) {
|
|
320
219
|
let {
|
|
321
220
|
children,
|
|
322
|
-
|
|
323
|
-
__unstableContentRef
|
|
221
|
+
...props
|
|
324
222
|
} = _ref2;
|
|
325
223
|
const isVisible = useSelect(select => {
|
|
326
224
|
return select(blockEditorStore).isBlockInsertionPointVisible();
|
|
327
225
|
}, []);
|
|
328
226
|
return createElement(InsertionPointOpenRef.Provider, {
|
|
329
227
|
value: useRef(false)
|
|
330
|
-
}, isVisible && createElement(InsertionPointPopover,
|
|
331
|
-
__unstablePopoverSlot: __unstablePopoverSlot,
|
|
332
|
-
__unstableContentRef: __unstableContentRef
|
|
333
|
-
}), children);
|
|
228
|
+
}, isVisible && createElement(InsertionPointPopover, props), children);
|
|
334
229
|
}
|
|
335
230
|
//# sourceMappingURL=insertion-point.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/insertion-point.js"],"names":["classnames","useSelect","useDispatch","useCallback","useRef","useMemo","createContext","useContext","Popover","__unstableMotion","motion","useReducedMotion","isRTL","Inserter","store","blockEditorStore","__unstableUseBlockElement","useBlockElement","usePopoverScroll","InsertionPointOpenRef","InsertionPointPopover","__unstablePopoverSlot","__unstableContentRef","selectBlock","hideInsertionPoint","openRef","ref","orientation","previousClientId","nextClientId","rootClientId","isInserterShown","select","getBlockOrder","getBlockListSettings","getBlockInsertionPoint","isBlockBeingDragged","getPreviousBlockClientId","getNextBlockClientId","insertionPoint","order","length","_previousClientId","index","_nextClientId","__unstableWithInserter","previousElement","nextElement","isVertical","style","previousRect","getBoundingClientRect","nextRect","width","offsetWidth","height","top","bottom","left","right","offsetHeight","getAnchorRect","ownerDocument","popoverScrollRef","disableMotion","className","onClick","event","target","current","onFocus","maybeHideInserterPoint","showInsertionPointInserter","horizontalLine","start","x","rest","hover","verticalLine","y","lineVariants","opacity","borderRadius","transition","delay","inserterVariants","scale","isOpen","InsertionPoint","children","isVisible","isBlockInsertionPointVisible"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SACCC,WADD,EAECC,MAFD,EAGCC,OAHD,EAICC,aAJD,EAKCC,UALD,QAMO,oBANP;AAOA,SAASC,OAAT,EAAkBC,gBAAgB,IAAIC,MAAtC,QAAoD,uBAApD;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,KAAT,QAAsB,iBAAtB;AAEA;AACA;AACA;;AACA,OAAOC,QAAP,MAAqB,aAArB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,yBAAyB,IAAIC,eAAtC,QAA6D,8CAA7D;AACA,SAASC,gBAAT,QAAiC,sBAAjC;AAEA,OAAO,MAAMC,qBAAqB,GAAGb,aAAa,EAA3C;;AAEP,SAASc,qBAAT,OAGI;AAAA,MAH4B;AAC/BC,IAAAA,qBAD+B;AAE/BC,IAAAA;AAF+B,GAG5B;AACH,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA;AAAf,MAAsCtB,WAAW,CAAEa,gBAAF,CAAvD;AACA,QAAMU,OAAO,GAAGlB,UAAU,CAAEY,qBAAF,CAA1B;AACA,QAAMO,GAAG,GAAGtB,MAAM,EAAlB;AACA,QAAM;AACL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AAR,GAAkBkB,MAAlB;AACA,KAPF;AAQC,IAAA,eAAe,EAAG,MAAM;AACvB9D,MAAAA,OAAO,CAAC4C,OAAR,GAAkB,KAAlB;AACA;AAVF,IAND,CAtBF,CAdD,CADD;AA4DA;AACA;;AAED,eAAe,SAASmB,cAAT,QAIX;AAAA,MAJoC;AACvCC,IAAAA,QADuC;AAEvCpE,IAAAA,qBAFuC;AAGvCC,IAAAA;AAHuC,GAIpC;AACH,QAAMoE,SAAS,GAAGzF,SAAS,CAAI+B,MAAF,IAAc;AAC1C,WAAOA,MAAM,CAAEjB,gBAAF,CAAN,CAA2B4E,4BAA3B,EAAP;AACA,GAF0B,EAExB,EAFwB,CAA3B;AAIA,SACC,cAAC,qBAAD,CAAuB,QAAvB;AAAgC,IAAA,KAAK,EAAGvF,MAAM,CAAE,KAAF;AAA9C,KACGsF,SAAS,IACV,cAAC,qBAAD;AACC,IAAA,qBAAqB,EAAGrE,qBADzB;AAEC,IAAA,oBAAoB,EAAGC;AAFxB,IAFF,EAOGmE,QAPH,CADD;AAWA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseCallback,\n\tuseRef,\n\tuseMemo,\n\tcreateContext,\n\tuseContext,\n} from '@wordpress/element';\nimport { Popover, __unstableMotion as motion } from '@wordpress/components';\nimport { useReducedMotion } from '@wordpress/compose';\nimport { isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport Inserter from '../inserter';\nimport { store as blockEditorStore } from '../../store';\nimport { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport { usePopoverScroll } from './use-popover-scroll';\n\nexport const InsertionPointOpenRef = createContext();\n\nfunction InsertionPointPopover( {\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst { selectBlock, hideInsertionPoint } = useDispatch( blockEditorStore );\n\tconst openRef = useContext( InsertionPointOpenRef );\n\tconst ref = useRef();\n\tconst {\n\t\torientation,\n\t\tpreviousClientId,\n\t\tnextClientId,\n\t\trootClientId,\n\t\tisInserterShown,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetBlockOrder,\n\t\t\tgetBlockListSettings,\n\t\t\tgetBlockInsertionPoint,\n\t\t\tisBlockBeingDragged,\n\t\t\tgetPreviousBlockClientId,\n\t\t\tgetNextBlockClientId,\n\t\t} = select( blockEditorStore );\n\t\tconst insertionPoint = getBlockInsertionPoint();\n\t\tconst order = getBlockOrder( insertionPoint.rootClientId );\n\n\t\tif ( ! order.length ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tlet _previousClientId = order[ insertionPoint.index - 1 ];\n\t\tlet _nextClientId = order[ insertionPoint.index ];\n\n\t\twhile ( isBlockBeingDragged( _previousClientId ) ) {\n\t\t\t_previousClientId = getPreviousBlockClientId( _previousClientId );\n\t\t}\n\n\t\twhile ( isBlockBeingDragged( _nextClientId ) ) {\n\t\t\t_nextClientId = getNextBlockClientId( _nextClientId );\n\t\t}\n\n\t\treturn {\n\t\t\tpreviousClientId: _previousClientId,\n\t\t\tnextClientId: _nextClientId,\n\t\t\torientation:\n\t\t\t\tgetBlockListSettings( insertionPoint.rootClientId )\n\t\t\t\t\t?.orientation || 'vertical',\n\t\t\trootClientId: insertionPoint.rootClientId,\n\t\t\tisInserterShown: insertionPoint?.__unstableWithInserter,\n\t\t};\n\t}, [] );\n\tconst previousElement = useBlockElement( previousClientId );\n\tconst nextElement = useBlockElement( nextClientId );\n\tconst isVertical = orientation === 'vertical';\n\tconst style = useMemo( () => {\n\t\tif ( ! previousElement && ! nextElement ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst previousRect = previousElement\n\t\t\t? previousElement.getBoundingClientRect()\n\t\t\t: null;\n\t\tconst nextRect = nextElement\n\t\t\t? nextElement.getBoundingClientRect()\n\t\t\t: null;\n\n\t\tif ( isVertical ) {\n\t\t\treturn {\n\t\t\t\twidth: previousElement\n\t\t\t\t\t? previousElement.offsetWidth\n\t\t\t\t\t: nextElement.offsetWidth,\n\t\t\t\theight:\n\t\t\t\t\tnextRect && previousRect\n\t\t\t\t\t\t? nextRect.top - previousRect.bottom\n\t\t\t\t\t\t: 0,\n\t\t\t};\n\t\t}\n\n\t\tlet width = 0;\n\t\tif ( previousRect && nextRect ) {\n\t\t\twidth = isRTL()\n\t\t\t\t? previousRect.left - nextRect.right\n\t\t\t\t: nextRect.left - previousRect.right;\n\t\t}\n\n\t\treturn {\n\t\t\twidth,\n\t\t\theight: previousElement\n\t\t\t\t? previousElement.offsetHeight\n\t\t\t\t: nextElement.offsetHeight,\n\t\t};\n\t}, [ previousElement, nextElement ] );\n\n\tconst getAnchorRect = useCallback( () => {\n\t\tif ( ! previousElement && ! nextElement ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst { ownerDocument } = previousElement || nextElement;\n\n\t\tconst previousRect = previousElement\n\t\t\t? previousElement.getBoundingClientRect()\n\t\t\t: null;\n\t\tconst nextRect = nextElement\n\t\t\t? nextElement.getBoundingClientRect()\n\t\t\t: null;\n\n\t\tif ( isVertical ) {\n\t\t\tif ( isRTL() ) {\n\t\t\t\treturn {\n\t\t\t\t\ttop: previousRect ? previousRect.bottom : nextRect.top,\n\t\t\t\t\tleft: previousRect ? previousRect.right : nextRect.right,\n\t\t\t\t\tright: previousRect ? previousRect.left : nextRect.left,\n\t\t\t\t\tbottom: nextRect ? nextRect.top : previousRect.bottom,\n\t\t\t\t\townerDocument,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\ttop: previousRect ? previousRect.bottom : nextRect.top,\n\t\t\t\tleft: previousRect ? previousRect.left : nextRect.left,\n\t\t\t\tright: previousRect ? previousRect.right : nextRect.right,\n\t\t\t\tbottom: nextRect ? nextRect.top : previousRect.bottom,\n\t\t\t\townerDocument,\n\t\t\t};\n\t\t}\n\n\t\tif ( isRTL() ) {\n\t\t\treturn {\n\t\t\t\ttop: previousRect ? previousRect.top : nextRect.top,\n\t\t\t\tleft: previousRect ? previousRect.left : nextRect.right,\n\t\t\t\tright: nextRect ? nextRect.right : previousRect.left,\n\t\t\t\tbottom: previousRect ? previousRect.bottom : nextRect.bottom,\n\t\t\t\townerDocument,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\ttop: previousRect ? previousRect.top : nextRect.top,\n\t\t\tleft: previousRect ? previousRect.right : nextRect.left,\n\t\t\tright: nextRect ? nextRect.left : previousRect.right,\n\t\t\tbottom: previousRect ? previousRect.bottom : nextRect.bottom,\n\t\t\townerDocument,\n\t\t};\n\t}, [ previousElement, nextElement ] );\n\n\tconst popoverScrollRef = usePopoverScroll( __unstableContentRef );\n\tconst disableMotion = useReducedMotion();\n\n\tconst className = classnames(\n\t\t'block-editor-block-list__insertion-point',\n\t\t'is-' + orientation\n\t);\n\n\tfunction onClick( event ) {\n\t\tif ( event.target === ref.current && nextClientId ) {\n\t\t\tselectBlock( nextClientId, -1 );\n\t\t}\n\t}\n\n\tfunction onFocus( event ) {\n\t\t// Only handle click on the wrapper specifically, and not an event\n\t\t// bubbled from the inserter itself.\n\t\tif ( event.target !== ref.current ) {\n\t\t\topenRef.current = true;\n\t\t}\n\t}\n\n\tfunction maybeHideInserterPoint( event ) {\n\t\t// Only hide the inserter if it's triggered on the wrapper,\n\t\t// and the inserter is not open.\n\t\tif ( event.target === ref.current && ! openRef.current ) {\n\t\t\thideInsertionPoint();\n\t\t}\n\t}\n\n\t// Only show the in-between inserter between blocks, so when there's a\n\t// previous and a next element.\n\tconst showInsertionPointInserter =\n\t\tpreviousElement && nextElement && isInserterShown;\n\n\t// Define animation variants for the line element.\n\tconst horizontalLine = {\n\t\tstart: {\n\t\t\twidth: 0,\n\t\t\ttop: '50%',\n\t\t\tbottom: '50%',\n\t\t\tx: 0,\n\t\t},\n\t\trest: {\n\t\t\twidth: 4,\n\t\t\ttop: 0,\n\t\t\tbottom: 0,\n\t\t\tx: -2,\n\t\t},\n\t\thover: {\n\t\t\twidth: 4,\n\t\t\ttop: 0,\n\t\t\tbottom: 0,\n\t\t\tx: -2,\n\t\t},\n\t};\n\tconst verticalLine = {\n\t\tstart: {\n\t\t\theight: 0,\n\t\t\tleft: '50%',\n\t\t\tright: '50%',\n\t\t\ty: 0,\n\t\t},\n\t\trest: {\n\t\t\theight: 4,\n\t\t\tleft: 0,\n\t\t\tright: 0,\n\t\t\ty: -2,\n\t\t},\n\t\thover: {\n\t\t\theight: 4,\n\t\t\tleft: 0,\n\t\t\tright: 0,\n\t\t\ty: -2,\n\t\t},\n\t};\n\tconst lineVariants = {\n\t\t// Initial position starts from the center and invisible.\n\t\tstart: {\n\t\t\t...( ! isVertical ? horizontalLine.start : verticalLine.start ),\n\t\t\topacity: 0,\n\t\t},\n\t\t// The line expands to fill the container. If the inserter is visible it\n\t\t// is delayed so it appears orchestrated.\n\t\trest: {\n\t\t\t...( ! isVertical ? horizontalLine.rest : verticalLine.rest ),\n\t\t\topacity: 1,\n\t\t\tborderRadius: '2px',\n\t\t\ttransition: { delay: showInsertionPointInserter ? 0.4 : 0 },\n\t\t},\n\t\thover: {\n\t\t\t...( ! isVertical ? horizontalLine.hover : verticalLine.hover ),\n\t\t\topacity: 1,\n\t\t\tborderRadius: '2px',\n\t\t\ttransition: { delay: 0.4 },\n\t\t},\n\t};\n\n\tconst inserterVariants = {\n\t\tstart: {\n\t\t\tscale: disableMotion ? 1 : 0,\n\t\t},\n\t\trest: {\n\t\t\tscale: 1,\n\t\t\ttransition: { delay: 0.2 },\n\t\t},\n\t};\n\n\t/* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */\n\t// While ideally it would be enough to capture the\n\t// bubbling focus event from the Inserter, due to the\n\t// characteristics of click focusing of `button`s in\n\t// Firefox and Safari, it is not reliable.\n\t//\n\t// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus\n\treturn (\n\t\t<Popover\n\t\t\tref={ popoverScrollRef }\n\t\t\tnoArrow\n\t\t\tanimate={ false }\n\t\t\tgetAnchorRect={ getAnchorRect }\n\t\t\tfocusOnMount={ false }\n\t\t\tclassName=\"block-editor-block-list__insertion-point-popover\"\n\t\t\t// Render in the old slot if needed for backward compatibility,\n\t\t\t// otherwise render in place (not in the the default popover slot).\n\t\t\t__unstableSlotName={ __unstablePopoverSlot || null }\n\t\t\t// Forces a remount of the popover when its position changes\n\t\t\t// This makes sure the popover doesn't animate from its previous position.\n\t\t\tkey={ nextClientId + '--' + rootClientId }\n\t\t>\n\t\t\t<motion.div\n\t\t\t\tlayout={ ! disableMotion }\n\t\t\t\tinitial={ disableMotion ? 'rest' : 'start' }\n\t\t\t\tanimate=\"rest\"\n\t\t\t\twhileHover=\"hover\"\n\t\t\t\twhileTap=\"pressed\"\n\t\t\t\texit=\"start\"\n\t\t\t\tref={ ref }\n\t\t\t\ttabIndex={ -1 }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tonFocus={ onFocus }\n\t\t\t\tclassName={ classnames( className, {\n\t\t\t\t\t'is-with-inserter': showInsertionPointInserter,\n\t\t\t\t} ) }\n\t\t\t\tonHoverEnd={ maybeHideInserterPoint }\n\t\t\t\tstyle={ style }\n\t\t\t>\n\t\t\t\t<motion.div\n\t\t\t\t\tvariants={ lineVariants }\n\t\t\t\t\tclassName=\"block-editor-block-list__insertion-point-indicator\"\n\t\t\t\t/>\n\t\t\t\t{ showInsertionPointInserter && (\n\t\t\t\t\t<motion.div\n\t\t\t\t\t\tvariants={ inserterVariants }\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'block-editor-block-list__insertion-point-inserter'\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Inserter\n\t\t\t\t\t\t\tposition=\"bottom center\"\n\t\t\t\t\t\t\tclientId={ nextClientId }\n\t\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t\t__experimentalIsQuick\n\t\t\t\t\t\t\tonToggle={ ( isOpen ) => {\n\t\t\t\t\t\t\t\topenRef.current = isOpen;\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonSelectOrClose={ () => {\n\t\t\t\t\t\t\t\topenRef.current = false;\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</motion.div>\n\t\t\t\t) }\n\t\t\t</motion.div>\n\t\t</Popover>\n\t);\n\t/* eslint-enable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */\n}\n\nexport default function InsertionPoint( {\n\tchildren,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst isVisible = useSelect( ( select ) => {\n\t\treturn select( blockEditorStore ).isBlockInsertionPointVisible();\n\t}, [] );\n\n\treturn (\n\t\t<InsertionPointOpenRef.Provider value={ useRef( false ) }>\n\t\t\t{ isVisible && (\n\t\t\t\t<InsertionPointPopover\n\t\t\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ children }\n\t\t</InsertionPointOpenRef.Provider>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/insertion-point.js"],"names":["classnames","useSelect","useDispatch","useRef","createContext","useContext","__unstableMotion","motion","useReducedMotion","Inserter","store","blockEditorStore","BlockPopoverInbetween","InsertionPointOpenRef","InsertionPointPopover","__unstablePopoverSlot","__unstableContentRef","selectBlock","hideInsertionPoint","openRef","ref","orientation","previousClientId","nextClientId","rootClientId","isInserterShown","select","getBlockOrder","getBlockListSettings","getBlockInsertionPoint","isBlockBeingDragged","getPreviousBlockClientId","getNextBlockClientId","insertionPoint","order","length","_previousClientId","index","_nextClientId","__unstableWithInserter","isVertical","disableMotion","onClick","event","target","current","onFocus","maybeHideInserterPoint","horizontalLine","start","width","top","bottom","x","rest","hover","verticalLine","height","left","right","y","lineVariants","opacity","borderRadius","transition","delay","inserterVariants","scale","className","isOpen","InsertionPoint","children","props","isVisible","isBlockInsertionPointVisible"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,MAAT,EAAiBC,aAAjB,EAAgCC,UAAhC,QAAkD,oBAAlD;AACA,SAASC,gBAAgB,IAAIC,MAA7B,QAA2C,uBAA3C;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AAEA;AACA;AACA;;AACA,OAAOC,QAAP,MAAqB,aAArB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AAEA,OAAO,MAAMC,qBAAqB,GAAGT,aAAa,EAA3C;;AAEP,SAASU,qBAAT,OAGI;AAAA,MAH4B;AAC/BC,IAAAA,qBAD+B;AAE/BC,IAAAA;AAF+B,GAG5B;AACH,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA;AAAf,MAAsChB,WAAW,CAAES,gBAAF,CAAvD;AACA,QAAMQ,OAAO,GAAGd,UAAU,CAAEQ,qBAAF,CAA1B;AACA,QAAMO,GAAG,GAAGjB,MAAM,EAAlB;AACA,QAAM;AACLkB,IAAAA,WADK;AAELC,IAAAA,gBAFK;AAGLC,IAAAA,YAHK;AAILC,IAAAA,YAJK;AAKLC,IAAAA;AALK,MAMFxB,SAAS,CAAIyB,MAAF,IAAc;AAAA;;AAC5B,UAAM;AACLC,MAAAA,aADK;AAELC,MAAAA,oBAFK;AAGLC,MAAAA,sBAHK;AAILC,MAAAA,mBAJK;AAKLC,MAAAA,wBALK;AAMLC,MAAAA;AANK,QAOFN,MAAM,CAAEf,gBAAF,CAPV;AAQA,UAAMsB,cAAc,GAAGJ,sBAAsB,EAA7C;AACA,UAAMK,KAAK,GAAGP,aAAa,CAAEM,cAAc,CAACT,YAAjB,CAA3B;;AAEA,QAAK,CAAEU,KAAK,C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AAOA,MAAM,CAAEf,gBAAF,CAAN,CAA2B+D,4BAA3B,EAAP;AACA,GAF0B,EAExB,EAFwB,CAA3B;AAIA,SACC,cAAC,qBAAD,CAAuB,QAAvB;AAAgC,IAAA,KAAK,EAAGvE,MAAM,CAAE,KAAF;AAA9C,KACGsE,SAAS,IAAI,cAAC,qBAAD,EAA4BD,KAA5B,CADhB,EAEGD,QAFH,CADD;AAMA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRef, createContext, useContext } from '@wordpress/element';\nimport { __unstableMotion as motion } from '@wordpress/components';\nimport { useReducedMotion } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport Inserter from '../inserter';\nimport { store as blockEditorStore } from '../../store';\nimport BlockPopoverInbetween from '../block-popover/inbetween';\n\nexport const InsertionPointOpenRef = createContext();\n\nfunction InsertionPointPopover( {\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst { selectBlock, hideInsertionPoint } = useDispatch( blockEditorStore );\n\tconst openRef = useContext( InsertionPointOpenRef );\n\tconst ref = useRef();\n\tconst {\n\t\torientation,\n\t\tpreviousClientId,\n\t\tnextClientId,\n\t\trootClientId,\n\t\tisInserterShown,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetBlockOrder,\n\t\t\tgetBlockListSettings,\n\t\t\tgetBlockInsertionPoint,\n\t\t\tisBlockBeingDragged,\n\t\t\tgetPreviousBlockClientId,\n\t\t\tgetNextBlockClientId,\n\t\t} = select( blockEditorStore );\n\t\tconst insertionPoint = getBlockInsertionPoint();\n\t\tconst order = getBlockOrder( insertionPoint.rootClientId );\n\n\t\tif ( ! order.length ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tlet _previousClientId = order[ insertionPoint.index - 1 ];\n\t\tlet _nextClientId = order[ insertionPoint.index ];\n\n\t\twhile ( isBlockBeingDragged( _previousClientId ) ) {\n\t\t\t_previousClientId = getPreviousBlockClientId( _previousClientId );\n\t\t}\n\n\t\twhile ( isBlockBeingDragged( _nextClientId ) ) {\n\t\t\t_nextClientId = getNextBlockClientId( _nextClientId );\n\t\t}\n\n\t\treturn {\n\t\t\tpreviousClientId: _previousClientId,\n\t\t\tnextClientId: _nextClientId,\n\t\t\torientation:\n\t\t\t\tgetBlockListSettings( insertionPoint.rootClientId )\n\t\t\t\t\t?.orientation || 'vertical',\n\t\t\trootClientId: insertionPoint.rootClientId,\n\t\t\tisInserterShown: insertionPoint?.__unstableWithInserter,\n\t\t};\n\t}, [] );\n\tconst isVertical = orientation === 'vertical';\n\n\tconst disableMotion = useReducedMotion();\n\n\tfunction onClick( event ) {\n\t\tif ( event.target === ref.current && nextClientId ) {\n\t\t\tselectBlock( nextClientId, -1 );\n\t\t}\n\t}\n\n\tfunction onFocus( event ) {\n\t\t// Only handle click on the wrapper specifically, and not an event\n\t\t// bubbled from the inserter itself.\n\t\tif ( event.target !== ref.current ) {\n\t\t\topenRef.current = true;\n\t\t}\n\t}\n\n\tfunction maybeHideInserterPoint( event ) {\n\t\t// Only hide the inserter if it's triggered on the wrapper,\n\t\t// and the inserter is not open.\n\t\tif ( event.target === ref.current && ! openRef.current ) {\n\t\t\thideInsertionPoint();\n\t\t}\n\t}\n\n\t// Define animation variants for the line element.\n\tconst horizontalLine = {\n\t\tstart: {\n\t\t\twidth: 0,\n\t\t\ttop: '50%',\n\t\t\tbottom: '50%',\n\t\t\tx: 0,\n\t\t},\n\t\trest: {\n\t\t\twidth: 4,\n\t\t\ttop: 0,\n\t\t\tbottom: 0,\n\t\t\tx: -2,\n\t\t},\n\t\thover: {\n\t\t\twidth: 4,\n\t\t\ttop: 0,\n\t\t\tbottom: 0,\n\t\t\tx: -2,\n\t\t},\n\t};\n\tconst verticalLine = {\n\t\tstart: {\n\t\t\theight: 0,\n\t\t\tleft: '50%',\n\t\t\tright: '50%',\n\t\t\ty: 0,\n\t\t},\n\t\trest: {\n\t\t\theight: 4,\n\t\t\tleft: 0,\n\t\t\tright: 0,\n\t\t\ty: -2,\n\t\t},\n\t\thover: {\n\t\t\theight: 4,\n\t\t\tleft: 0,\n\t\t\tright: 0,\n\t\t\ty: -2,\n\t\t},\n\t};\n\tconst lineVariants = {\n\t\t// Initial position starts from the center and invisible.\n\t\tstart: {\n\t\t\t...( ! isVertical ? horizontalLine.start : verticalLine.start ),\n\t\t\topacity: 0,\n\t\t},\n\t\t// The line expands to fill the container. If the inserter is visible it\n\t\t// is delayed so it appears orchestrated.\n\t\trest: {\n\t\t\t...( ! isVertical ? horizontalLine.rest : verticalLine.rest ),\n\t\t\topacity: 1,\n\t\t\tborderRadius: '2px',\n\t\t\ttransition: { delay: isInserterShown ? 0.4 : 0 },\n\t\t},\n\t\thover: {\n\t\t\t...( ! isVertical ? horizontalLine.hover : verticalLine.hover ),\n\t\t\topacity: 1,\n\t\t\tborderRadius: '2px',\n\t\t\ttransition: { delay: 0.4 },\n\t\t},\n\t};\n\n\tconst inserterVariants = {\n\t\tstart: {\n\t\t\tscale: disableMotion ? 1 : 0,\n\t\t},\n\t\trest: {\n\t\t\tscale: 1,\n\t\t\ttransition: { delay: 0.2 },\n\t\t},\n\t};\n\n\tconst className = classnames(\n\t\t'block-editor-block-list__insertion-point',\n\t\t'is-' + orientation\n\t);\n\n\treturn (\n\t\t<BlockPopoverInbetween\n\t\t\tpreviousClientId={ previousClientId }\n\t\t\tnextClientId={ nextClientId }\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t>\n\t\t\t<motion.div\n\t\t\t\tlayout={ ! disableMotion }\n\t\t\t\tinitial={ disableMotion ? 'rest' : 'start' }\n\t\t\t\tanimate=\"rest\"\n\t\t\t\twhileHover=\"hover\"\n\t\t\t\twhileTap=\"pressed\"\n\t\t\t\texit=\"start\"\n\t\t\t\tref={ ref }\n\t\t\t\ttabIndex={ -1 }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tonFocus={ onFocus }\n\t\t\t\tclassName={ classnames( className, {\n\t\t\t\t\t'is-with-inserter': isInserterShown,\n\t\t\t\t} ) }\n\t\t\t\tonHoverEnd={ maybeHideInserterPoint }\n\t\t\t>\n\t\t\t\t<motion.div\n\t\t\t\t\tvariants={ lineVariants }\n\t\t\t\t\tclassName=\"block-editor-block-list__insertion-point-indicator\"\n\t\t\t\t/>\n\t\t\t\t{ isInserterShown && (\n\t\t\t\t\t<motion.div\n\t\t\t\t\t\tvariants={ inserterVariants }\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'block-editor-block-list__insertion-point-inserter'\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Inserter\n\t\t\t\t\t\t\tposition=\"bottom center\"\n\t\t\t\t\t\t\tclientId={ nextClientId }\n\t\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t\t__experimentalIsQuick\n\t\t\t\t\t\t\tonToggle={ ( isOpen ) => {\n\t\t\t\t\t\t\t\topenRef.current = isOpen;\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonSelectOrClose={ () => {\n\t\t\t\t\t\t\t\topenRef.current = false;\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</motion.div>\n\t\t\t\t) }\n\t\t\t</motion.div>\n\t\t</BlockPopoverInbetween>\n\t);\n}\n\nexport default function InsertionPoint( { children, ...props } ) {\n\tconst isVisible = useSelect( ( select ) => {\n\t\treturn select( blockEditorStore ).isBlockInsertionPointVisible();\n\t}, [] );\n\n\treturn (\n\t\t<InsertionPointOpenRef.Provider value={ useRef( false ) }>\n\t\t\t{ isVisible && <InsertionPointPopover { ...props } /> }\n\t\t\t{ children }\n\t\t</InsertionPointOpenRef.Provider>\n\t);\n}\n"]}
|
|
@@ -11,11 +11,9 @@ import classnames from 'classnames';
|
|
|
11
11
|
|
|
12
12
|
import { useState, useRef, useEffect } from '@wordpress/element';
|
|
13
13
|
import { isUnmodifiedDefaultBlock } from '@wordpress/blocks';
|
|
14
|
-
import { Popover } from '@wordpress/components';
|
|
15
14
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
16
15
|
import { useShortcut } from '@wordpress/keyboard-shortcuts';
|
|
17
16
|
import { useViewportMatch } from '@wordpress/compose';
|
|
18
|
-
import { getScrollContainer } from '@wordpress/dom';
|
|
19
17
|
/**
|
|
20
18
|
* Internal dependencies
|
|
21
19
|
*/
|
|
@@ -24,8 +22,7 @@ import BlockSelectionButton from './block-selection-button';
|
|
|
24
22
|
import BlockContextualToolbar from './block-contextual-toolbar';
|
|
25
23
|
import Inserter from '../inserter';
|
|
26
24
|
import { store as blockEditorStore } from '../../store';
|
|
27
|
-
import
|
|
28
|
-
import { usePopoverScroll } from './use-popover-scroll';
|
|
25
|
+
import BlockPopover from '../block-popover';
|
|
29
26
|
|
|
30
27
|
function selector(select) {
|
|
31
28
|
const {
|
|
@@ -33,7 +30,6 @@ function selector(select) {
|
|
|
33
30
|
isMultiSelecting,
|
|
34
31
|
hasMultiSelection,
|
|
35
32
|
isTyping,
|
|
36
|
-
isCaretWithinFormattedText,
|
|
37
33
|
getSettings,
|
|
38
34
|
getLastMultiSelectedBlockClientId
|
|
39
35
|
} = select(blockEditorStore);
|
|
@@ -41,18 +37,15 @@ function selector(select) {
|
|
|
41
37
|
isNavigationMode: isNavigationMode(),
|
|
42
38
|
isMultiSelecting: isMultiSelecting(),
|
|
43
39
|
isTyping: isTyping(),
|
|
44
|
-
isCaretWithinFormattedText: isCaretWithinFormattedText(),
|
|
45
|
-
hasMultiSelection: hasMultiSelection(),
|
|
46
40
|
hasFixedToolbar: getSettings().hasFixedToolbar,
|
|
47
|
-
lastClientId: getLastMultiSelectedBlockClientId()
|
|
41
|
+
lastClientId: hasMultiSelection() ? getLastMultiSelectedBlockClientId() : null
|
|
48
42
|
};
|
|
49
43
|
}
|
|
50
44
|
|
|
51
|
-
function
|
|
45
|
+
function SelectedBlockPopover(_ref) {
|
|
52
46
|
let {
|
|
53
47
|
clientId,
|
|
54
48
|
rootClientId,
|
|
55
|
-
isValid,
|
|
56
49
|
isEmptyDefaultBlock,
|
|
57
50
|
capturingClientId,
|
|
58
51
|
__unstablePopoverSlot,
|
|
@@ -62,8 +55,6 @@ function BlockPopover(_ref) {
|
|
|
62
55
|
isNavigationMode,
|
|
63
56
|
isMultiSelecting,
|
|
64
57
|
isTyping,
|
|
65
|
-
isCaretWithinFormattedText,
|
|
66
|
-
hasMultiSelection,
|
|
67
58
|
hasFixedToolbar,
|
|
68
59
|
lastClientId
|
|
69
60
|
} = useSelect(selector, []);
|
|
@@ -83,108 +74,49 @@ function BlockPopover(_ref) {
|
|
|
83
74
|
return order[insertionPoint.index] === clientId;
|
|
84
75
|
}, [clientId]);
|
|
85
76
|
const isLargeViewport = useViewportMatch('medium');
|
|
86
|
-
const
|
|
77
|
+
const isToolbarForced = useRef(false);
|
|
87
78
|
const [isInserterShown, setIsInserterShown] = useState(false);
|
|
88
79
|
const {
|
|
89
80
|
stopTyping
|
|
90
|
-
} = useDispatch(blockEditorStore);
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const showEmptyBlockSideInserter = !isTyping && !isNavigationMode && isEmptyDefaultBlock && isValid;
|
|
81
|
+
} = useDispatch(blockEditorStore);
|
|
82
|
+
const showEmptyBlockSideInserter = !isTyping && !isNavigationMode && isEmptyDefaultBlock;
|
|
94
83
|
const shouldShowBreadcrumb = isNavigationMode;
|
|
95
|
-
const shouldShowContextualToolbar = !isNavigationMode && !hasFixedToolbar && isLargeViewport && !
|
|
84
|
+
const shouldShowContextualToolbar = !isNavigationMode && !hasFixedToolbar && isLargeViewport && !isMultiSelecting && !showEmptyBlockSideInserter && !isTyping;
|
|
96
85
|
const canFocusHiddenToolbar = !isNavigationMode && !shouldShowContextualToolbar && !hasFixedToolbar && !isEmptyDefaultBlock;
|
|
97
86
|
useShortcut('core/block-editor/focus-toolbar', () => {
|
|
98
|
-
|
|
87
|
+
isToolbarForced.current = true;
|
|
99
88
|
stopTyping(true);
|
|
100
89
|
}, {
|
|
101
90
|
isDisabled: !canFocusHiddenToolbar
|
|
102
91
|
});
|
|
103
92
|
useEffect(() => {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
}, [shouldShowContextualToolbar]); // Stores the active toolbar item index so the block toolbar can return focus
|
|
93
|
+
isToolbarForced.current = false;
|
|
94
|
+
}); // Stores the active toolbar item index so the block toolbar can return focus
|
|
108
95
|
// to it when re-mounting.
|
|
109
96
|
|
|
110
97
|
const initialToolbarItemIndexRef = useRef();
|
|
111
|
-
const selectedElement = useBlockElement(clientId);
|
|
112
|
-
const lastSelectedElement = useBlockElement(lastClientId);
|
|
113
|
-
const capturingElement = useBlockElement(capturingClientId);
|
|
114
|
-
const popoverScrollRef = usePopoverScroll(__unstableContentRef);
|
|
115
|
-
|
|
116
|
-
if (!shouldShowBreadcrumb && !shouldShowContextualToolbar && !isToolbarForced && !showEmptyBlockSideInserter) {
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
98
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
if (!node) {
|
|
99
|
+
if (!shouldShowBreadcrumb && !shouldShowContextualToolbar) {
|
|
123
100
|
return null;
|
|
124
101
|
}
|
|
125
102
|
|
|
126
|
-
if (capturingClientId) {
|
|
127
|
-
node = capturingElement;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
let anchorRef = node;
|
|
131
|
-
|
|
132
|
-
if (hasMultiSelection) {
|
|
133
|
-
// Wait to render the popover until the bottom reference is available
|
|
134
|
-
// as well.
|
|
135
|
-
if (!lastSelectedElement) {
|
|
136
|
-
return null;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
anchorRef = {
|
|
140
|
-
top: node,
|
|
141
|
-
bottom: lastSelectedElement
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
|
|
145
103
|
function onFocus() {
|
|
146
104
|
setIsInserterShown(true);
|
|
147
105
|
}
|
|
148
106
|
|
|
149
107
|
function onBlur() {
|
|
150
108
|
setIsInserterShown(false);
|
|
151
|
-
}
|
|
152
|
-
// left corner. For the side inserter, pop out towards the left, and
|
|
153
|
-
// position in the right corner.
|
|
154
|
-
// To do: refactor `Popover` to make this prop clearer.
|
|
155
|
-
|
|
109
|
+
}
|
|
156
110
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
} = node;
|
|
161
|
-
const stickyBoundaryElement = showEmptyBlockSideInserter ? undefined : // The sticky boundary element should be the boundary at which the
|
|
162
|
-
// the block toolbar becomes sticky when the block scolls out of view.
|
|
163
|
-
// In case of an iframe, this should be the iframe boundary, otherwise
|
|
164
|
-
// the scroll container.
|
|
165
|
-
ownerDocument.defaultView.frameElement || getScrollContainer(node) || ownerDocument.body;
|
|
166
|
-
return createElement(Popover, {
|
|
167
|
-
ref: popoverScrollRef,
|
|
168
|
-
noArrow: true,
|
|
169
|
-
animate: false,
|
|
170
|
-
position: popoverPosition,
|
|
171
|
-
focusOnMount: false,
|
|
172
|
-
anchorRef: anchorRef,
|
|
111
|
+
return createElement(BlockPopover, {
|
|
112
|
+
clientId: capturingClientId || clientId,
|
|
113
|
+
bottomClientId: lastClientId,
|
|
173
114
|
className: classnames('block-editor-block-list__block-popover', {
|
|
174
115
|
'is-insertion-point-visible': isInsertionPointVisible
|
|
175
116
|
}),
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
__unstableSlotName: __unstablePopoverSlot || null,
|
|
180
|
-
__unstableBoundaryParent: true // Observe movement for block animations (especially horizontal).
|
|
181
|
-
,
|
|
182
|
-
__unstableObserveElement: node,
|
|
183
|
-
shouldAnchorIncludePadding: true // Used to safeguard sticky position behavior against cases where it would permanently
|
|
184
|
-
// obscure specific sections of a block.
|
|
185
|
-
,
|
|
186
|
-
__unstableEditorCanvasWrapper: __unstableContentRef === null || __unstableContentRef === void 0 ? void 0 : __unstableContentRef.current
|
|
187
|
-
}, (shouldShowContextualToolbar || isToolbarForced) && createElement("div", {
|
|
117
|
+
__unstablePopoverSlot: __unstablePopoverSlot,
|
|
118
|
+
__unstableContentRef: __unstableContentRef
|
|
119
|
+
}, shouldShowContextualToolbar && createElement("div", {
|
|
188
120
|
onFocus: onFocus,
|
|
189
121
|
onBlur: onBlur // While ideally it would be enough to capture the
|
|
190
122
|
// bubbling focus event from the Inserter, due to the
|
|
@@ -201,10 +133,10 @@ function BlockPopover(_ref) {
|
|
|
201
133
|
clientId: clientId,
|
|
202
134
|
rootClientId: rootClientId,
|
|
203
135
|
__experimentalIsQuick: true
|
|
204
|
-
})),
|
|
136
|
+
})), shouldShowContextualToolbar && createElement(BlockContextualToolbar // If the toolbar is being shown because of being forced
|
|
205
137
|
// it should focus the toolbar right after the mount.
|
|
206
138
|
, {
|
|
207
|
-
focusOnMount: isToolbarForced,
|
|
139
|
+
focusOnMount: isToolbarForced.current,
|
|
208
140
|
__experimentalInitialIndex: initialToolbarItemIndexRef.current,
|
|
209
141
|
__experimentalOnIndexChange: index => {
|
|
210
142
|
initialToolbarItemIndexRef.current = index;
|
|
@@ -214,16 +146,8 @@ function BlockPopover(_ref) {
|
|
|
214
146
|
key: clientId
|
|
215
147
|
}), shouldShowBreadcrumb && createElement(BlockSelectionButton, {
|
|
216
148
|
clientId: clientId,
|
|
217
|
-
rootClientId: rootClientId
|
|
218
|
-
|
|
219
|
-
}), showEmptyBlockSideInserter && createElement("div", {
|
|
220
|
-
className: "block-editor-block-list__empty-block-inserter"
|
|
221
|
-
}, createElement(Inserter, {
|
|
222
|
-
position: "bottom right",
|
|
223
|
-
rootClientId: rootClientId,
|
|
224
|
-
clientId: clientId,
|
|
225
|
-
__experimentalIsQuick: true
|
|
226
|
-
})));
|
|
149
|
+
rootClientId: rootClientId
|
|
150
|
+
}));
|
|
227
151
|
}
|
|
228
152
|
|
|
229
153
|
function wrapperSelector(select) {
|
|
@@ -243,8 +167,7 @@ function wrapperSelector(select) {
|
|
|
243
167
|
|
|
244
168
|
const {
|
|
245
169
|
name,
|
|
246
|
-
attributes = {}
|
|
247
|
-
isValid
|
|
170
|
+
attributes = {}
|
|
248
171
|
} = getBlock(clientId) || {};
|
|
249
172
|
const blockParentsClientIds = getBlockParents(clientId); // Get Block List Settings for all ancestors of the current Block clientId.
|
|
250
173
|
|
|
@@ -260,7 +183,6 @@ function wrapperSelector(select) {
|
|
|
260
183
|
clientId,
|
|
261
184
|
rootClientId: getBlockRootClientId(clientId),
|
|
262
185
|
name,
|
|
263
|
-
isValid,
|
|
264
186
|
isEmptyDefaultBlock: name && isUnmodifiedDefaultBlock({
|
|
265
187
|
name,
|
|
266
188
|
attributes
|
|
@@ -284,7 +206,6 @@ export default function WrappedBlockPopover(_ref2) {
|
|
|
284
206
|
clientId,
|
|
285
207
|
rootClientId,
|
|
286
208
|
name,
|
|
287
|
-
isValid,
|
|
288
209
|
isEmptyDefaultBlock,
|
|
289
210
|
capturingClientId
|
|
290
211
|
} = selected;
|
|
@@ -293,14 +214,13 @@ export default function WrappedBlockPopover(_ref2) {
|
|
|
293
214
|
return null;
|
|
294
215
|
}
|
|
295
216
|
|
|
296
|
-
return createElement(
|
|
217
|
+
return createElement(SelectedBlockPopover, {
|
|
297
218
|
clientId: clientId,
|
|
298
219
|
rootClientId: rootClientId,
|
|
299
|
-
isValid: isValid,
|
|
300
220
|
isEmptyDefaultBlock: isEmptyDefaultBlock,
|
|
301
221
|
capturingClientId: capturingClientId,
|
|
302
222
|
__unstablePopoverSlot: __unstablePopoverSlot,
|
|
303
223
|
__unstableContentRef: __unstableContentRef
|
|
304
224
|
});
|
|
305
225
|
}
|
|
306
|
-
//# sourceMappingURL=block-popover.js.map
|
|
226
|
+
//# sourceMappingURL=selected-block-popover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/selected-block-popover.js"],"names":["find","classnames","useState","useRef","useEffect","isUnmodifiedDefaultBlock","useDispatch","useSelect","useShortcut","useViewportMatch","BlockSelectionButton","BlockContextualToolbar","Inserter","store","blockEditorStore","BlockPopover","selector","select","isNavigationMode","isMultiSelecting","hasMultiSelection","isTyping","getSettings","getLastMultiSelectedBlockClientId","hasFixedToolbar","lastClientId","SelectedBlockPopover","clientId","rootClientId","isEmptyDefaultBlock","capturingClientId","__unstablePopoverSlot","__unstableContentRef","isInsertionPointVisible","isBlockInsertionPointVisible","getBlockInsertionPoint","getBlockOrder","insertionPoint","order","index","isLargeViewport","isToolbarForced","isInserterShown","setIsInserterShown","stopTyping","showEmptyBlockSideInserter","shouldShowBreadcrumb","shouldShowContextualToolbar","canFocusHiddenToolbar","current","isDisabled","initialToolbarItemIndexRef","onFocus","onBlur","wrapperSelector","getSelectedBlockClientId","getFirstMultiSelectedBlockClientId","getBlockRootClientId","getBlock","getBlockParents","__experimentalGetBlockListSettingsForBlocks","name","attributes","blockParentsClientIds","parentBlockListSettings","parentClientId","__experimentalCaptureToolbars","WrappedBlockPopover","selected"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,QAArB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,QAAT,EAAmBC,MAAnB,EAA2BC,SAA3B,QAA4C,oBAA5C;AACA,SAASC,wBAAT,QAAyC,mBAAzC;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,WAAT,QAA4B,+BAA5B;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AAEA;AACA;AACA;;AACA,OAAOC,oBAAP,MAAiC,0BAAjC;AACA,OAAOC,sBAAP,MAAmC,4BAAnC;AACA,OAAOC,QAAP,MAAqB,aAArB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,OAAOC,YAAP,MAAyB,kBAAzB;;AAEA,SAASC,QAAT,CAAmBC,MAAnB,EAA4B;AAC3B,QAAM;AACLC,IAAAA,gBADK;AAELC,IAAA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A,YAAY,EAAGC,YAFhB;AAGC,IAAA,mBAAmB,EAAGC,mBAHvB;AAIC,IAAA,iBAAiB,EAAGC,iBAJrB;AAKC,IAAA,qBAAqB,EAAGC,qBALzB;AAMC,IAAA,oBAAoB,EAAGC;AANxB,IADD;AAUA","sourcesContent":["/**\n * External dependencies\n */\nimport { find } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useRef, useEffect } from '@wordpress/element';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BlockSelectionButton from './block-selection-button';\nimport BlockContextualToolbar from './block-contextual-toolbar';\nimport Inserter from '../inserter';\nimport { store as blockEditorStore } from '../../store';\nimport BlockPopover from '../block-popover';\n\nfunction selector( select ) {\n\tconst {\n\t\tisNavigationMode,\n\t\tisMultiSelecting,\n\t\thasMultiSelection,\n\t\tisTyping,\n\t\tgetSettings,\n\t\tgetLastMultiSelectedBlockClientId,\n\t} = select( blockEditorStore );\n\treturn {\n\t\tisNavigationMode: isNavigationMode(),\n\t\tisMultiSelecting: isMultiSelecting(),\n\t\tisTyping: isTyping(),\n\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\tlastClientId: hasMultiSelection()\n\t\t\t? getLastMultiSelectedBlockClientId()\n\t\t\t: null,\n\t};\n}\n\nfunction SelectedBlockPopover( {\n\tclientId,\n\trootClientId,\n\tisEmptyDefaultBlock,\n\tcapturingClientId,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst {\n\t\tisNavigationMode,\n\t\tisMultiSelecting,\n\t\tisTyping,\n\t\thasFixedToolbar,\n\t\tlastClientId,\n\t} = useSelect( selector, [] );\n\tconst isInsertionPointVisible = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisBlockInsertionPointVisible,\n\t\t\t\tgetBlockInsertionPoint,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tif ( ! isBlockInsertionPointVisible() ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst insertionPoint = getBlockInsertionPoint();\n\t\t\tconst order = getBlockOrder( insertionPoint.rootClientId );\n\t\t\treturn order[ insertionPoint.index ] === clientId;\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isToolbarForced = useRef( false );\n\tconst [ isInserterShown, setIsInserterShown ] = useState( false );\n\tconst { stopTyping } = useDispatch( blockEditorStore );\n\n\tconst showEmptyBlockSideInserter =\n\t\t! isTyping && ! isNavigationMode && isEmptyDefaultBlock;\n\tconst shouldShowBreadcrumb = isNavigationMode;\n\tconst shouldShowContextualToolbar =\n\t\t! isNavigationMode &&\n\t\t! hasFixedToolbar &&\n\t\tisLargeViewport &&\n\t\t! isMultiSelecting &&\n\t\t! showEmptyBlockSideInserter &&\n\t\t! isTyping;\n\tconst canFocusHiddenToolbar =\n\t\t! isNavigationMode &&\n\t\t! shouldShowContextualToolbar &&\n\t\t! hasFixedToolbar &&\n\t\t! isEmptyDefaultBlock;\n\n\tuseShortcut(\n\t\t'core/block-editor/focus-toolbar',\n\t\t() => {\n\t\t\tisToolbarForced.current = true;\n\t\t\tstopTyping( true );\n\t\t},\n\t\t{\n\t\t\tisDisabled: ! canFocusHiddenToolbar,\n\t\t}\n\t);\n\n\tuseEffect( () => {\n\t\tisToolbarForced.current = false;\n\t} );\n\n\t// Stores the active toolbar item index so the block toolbar can return focus\n\t// to it when re-mounting.\n\tconst initialToolbarItemIndexRef = useRef();\n\n\tif ( ! shouldShowBreadcrumb && ! shouldShowContextualToolbar ) {\n\t\treturn null;\n\t}\n\n\tfunction onFocus() {\n\t\tsetIsInserterShown( true );\n\t}\n\n\tfunction onBlur() {\n\t\tsetIsInserterShown( false );\n\t}\n\n\treturn (\n\t\t<BlockPopover\n\t\t\tclientId={ capturingClientId || clientId }\n\t\t\tbottomClientId={ lastClientId }\n\t\t\tclassName={ classnames( 'block-editor-block-list__block-popover', {\n\t\t\t\t'is-insertion-point-visible': isInsertionPointVisible,\n\t\t\t} ) }\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t>\n\t\t\t{ shouldShowContextualToolbar && (\n\t\t\t\t<div\n\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\tonBlur={ onBlur }\n\t\t\t\t\t// While ideally it would be enough to capture the\n\t\t\t\t\t// bubbling focus event from the Inserter, due to the\n\t\t\t\t\t// characteristics of click focusing of `button`s in\n\t\t\t\t\t// Firefox and Safari, it is not reliable.\n\t\t\t\t\t//\n\t\t\t\t\t// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus\n\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'block-editor-block-list__block-popover-inserter',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'is-visible': isInserterShown,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t<Inserter\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t__experimentalIsQuick\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ shouldShowContextualToolbar && (\n\t\t\t\t<BlockContextualToolbar\n\t\t\t\t\t// If the toolbar is being shown because of being forced\n\t\t\t\t\t// it should focus the toolbar right after the mount.\n\t\t\t\t\tfocusOnMount={ isToolbarForced.current }\n\t\t\t\t\t__experimentalInitialIndex={\n\t\t\t\t\t\tinitialToolbarItemIndexRef.current\n\t\t\t\t\t}\n\t\t\t\t\t__experimentalOnIndexChange={ ( index ) => {\n\t\t\t\t\t\tinitialToolbarItemIndexRef.current = index;\n\t\t\t\t\t} }\n\t\t\t\t\t// Resets the index whenever the active block changes so\n\t\t\t\t\t// this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169\n\t\t\t\t\tkey={ clientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ shouldShowBreadcrumb && (\n\t\t\t\t<BlockSelectionButton\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</BlockPopover>\n\t);\n}\n\nfunction wrapperSelector( select ) {\n\tconst {\n\t\tgetSelectedBlockClientId,\n\t\tgetFirstMultiSelectedBlockClientId,\n\t\tgetBlockRootClientId,\n\t\tgetBlock,\n\t\tgetBlockParents,\n\t\t__experimentalGetBlockListSettingsForBlocks,\n\t} = select( blockEditorStore );\n\n\tconst clientId =\n\t\tgetSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();\n\n\tif ( ! clientId ) {\n\t\treturn;\n\t}\n\n\tconst { name, attributes = {} } = getBlock( clientId ) || {};\n\tconst blockParentsClientIds = getBlockParents( clientId );\n\n\t// Get Block List Settings for all ancestors of the current Block clientId.\n\tconst parentBlockListSettings = __experimentalGetBlockListSettingsForBlocks(\n\t\tblockParentsClientIds\n\t);\n\n\t// Get the clientId of the topmost parent with the capture toolbars setting.\n\tconst capturingClientId = find(\n\t\tblockParentsClientIds,\n\t\t( parentClientId ) =>\n\t\t\tparentBlockListSettings[ parentClientId ]\n\t\t\t\t?.__experimentalCaptureToolbars\n\t);\n\n\treturn {\n\t\tclientId,\n\t\trootClientId: getBlockRootClientId( clientId ),\n\t\tname,\n\t\tisEmptyDefaultBlock:\n\t\t\tname && isUnmodifiedDefaultBlock( { name, attributes } ),\n\t\tcapturingClientId,\n\t};\n}\n\nexport default function WrappedBlockPopover( {\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst selected = useSelect( wrapperSelector, [] );\n\n\tif ( ! selected ) {\n\t\treturn null;\n\t}\n\n\tconst {\n\t\tclientId,\n\t\trootClientId,\n\t\tname,\n\t\tisEmptyDefaultBlock,\n\t\tcapturingClientId,\n\t} = selected;\n\n\tif ( ! name ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<SelectedBlockPopover\n\t\t\tclientId={ clientId }\n\t\t\trootClientId={ rootClientId }\n\t\t\tisEmptyDefaultBlock={ isEmptyDefaultBlock }\n\t\t\tcapturingClientId={ capturingClientId }\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -6,6 +6,7 @@ import { createElement } from "@wordpress/element";
|
|
|
6
6
|
import { ToolbarButton, Dropdown, ToolbarGroup, SVG, Path } from '@wordpress/components';
|
|
7
7
|
import { __ } from '@wordpress/i18n';
|
|
8
8
|
import { DOWN } from '@wordpress/keycodes';
|
|
9
|
+
import deprecated from '@wordpress/deprecated';
|
|
9
10
|
|
|
10
11
|
const ColorSelectorSVGIcon = () => createElement(SVG, {
|
|
11
12
|
xmlns: "https://www.w3.org/2000/svg",
|
|
@@ -80,6 +81,11 @@ const BlockColorsStyleSelector = _ref4 => {
|
|
|
80
81
|
children,
|
|
81
82
|
...other
|
|
82
83
|
} = _ref4;
|
|
84
|
+
deprecated(`wp.blockEditor.BlockColorsStyleSelector`, {
|
|
85
|
+
alternative: 'block supports API',
|
|
86
|
+
since: '6.1',
|
|
87
|
+
version: '6.3'
|
|
88
|
+
});
|
|
83
89
|
return createElement(Dropdown, {
|
|
84
90
|
position: "bottom right",
|
|
85
91
|
className: "block-library-colors-selector",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/color-style-selector/index.js"],"names":["ToolbarButton","Dropdown","ToolbarGroup","SVG","Path","__","DOWN","ColorSelectorSVGIcon","ColorSelectorIcon","style","className","renderToggleComponent","TextColor","BackgroundColor","onToggle","isOpen","openOnArrowDown","event","keyCode","preventDefault","BlockColorsStyleSelector","children","other"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,aADD,EAECC,QAFD,EAGCC,YAHD,EAICC,GAJD,EAKCC,IALD,QAMO,uBANP;AAOA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,IAAT,QAAqB,qBAArB;;AAEA,MAAMC,oBAAoB,GAAG,MAC5B,cAAC,GAAD;AAAK,EAAA,KAAK,EAAC,6BAAX;AAAyC,EAAA,OAAO,EAAC;AAAjD,GACC,cAAC,IAAD;AAAM,EAAA,CAAC,EAAC;AAAR,EADD,CADD;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAMC,iBAAiB,GAAG,QAA4B;AAAA,MAA1B;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,GAA0B;AACrD,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AACC,IAAA,SAAS,EAAI,GAAGA,SAAW,iDAD5B;AAEC,IAAA,KAAK,EAAGD;AAFT,KAIC,cAAC,oBAAD,OAJD,CADD,CADD;AAUA,CAXD;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAME,qBAAqB,GAAG;AAAA,MAAE;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,GAAF;AAAA,SAAsC,SAG7D;AAAA,QAH+D;AACrEC,MAAAA,QADqE;AAErEC,MAAAA;AAFqE,KAG/D;;AACN,UAAMC,eAAe,GAAKC,KAAF,IAAa;AACpC,UAAK,CAAEF,MAAF,IAAYE,KAAK,CAACC,OAAN,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/color-style-selector/index.js"],"names":["ToolbarButton","Dropdown","ToolbarGroup","SVG","Path","__","DOWN","deprecated","ColorSelectorSVGIcon","ColorSelectorIcon","style","className","renderToggleComponent","TextColor","BackgroundColor","onToggle","isOpen","openOnArrowDown","event","keyCode","preventDefault","BlockColorsStyleSelector","children","other","alternative","since","version"],"mappings":";;AA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AGE,eAJb;AAKC,MAAA,IAAI,EACH,cAAC,eAAD,QACC,cAAC,SAAD,QACC,cAAC,iBAAD,OADD,CADD;AANF,MADD,CADD;AAiBA,GA5B6B;AAAA,CAA9B;;AA8BA,MAAMI,wBAAwB,GAAG,SAA8B;AAAA,MAA5B;AAAEC,IAAAA,QAAF;AAAY,OAAGC;AAAf,GAA4B;AAC9DhB,EAAAA,UAAU,CAAG,yCAAH,EAA6C;AACtDiB,IAAAA,WAAW,EAAE,oBADyC;AAEtDC,IAAAA,KAAK,EAAE,KAF+C;AAGtDC,IAAAA,OAAO,EAAE;AAH6C,GAA7C,CAAV;AAMA,SACC,cAAC,QAAD;AACC,IAAA,QAAQ,EAAC,cADV;AAEC,IAAA,SAAS,EAAC,+BAFX;AAGC,IAAA,gBAAgB,EAAC,wCAHlB;AAIC,IAAA,YAAY,EAAGd,qBAAqB,CAAEW,KAAF,CAJrC;AAKC,IAAA,aAAa,EAAG,MAAMD;AALvB,IADD;AASA,CAhBD;;AAkBA,eAAeD,wBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tToolbarButton,\n\tDropdown,\n\tToolbarGroup,\n\tSVG,\n\tPath,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { DOWN } from '@wordpress/keycodes';\nimport deprecated from '@wordpress/deprecated';\n\nconst ColorSelectorSVGIcon = () => (\n\t<SVG xmlns=\"https://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\">\n\t\t<Path d=\"M7.434 5l3.18 9.16H8.538l-.692-2.184H4.628l-.705 2.184H2L5.18 5h2.254zm-1.13 1.904h-.115l-1.148 3.593H7.44L6.304 6.904zM14.348 7.006c1.853 0 2.9.876 2.9 2.374v4.78h-1.79v-.914h-.114c-.362.64-1.123 1.022-2.031 1.022-1.346 0-2.292-.826-2.292-2.108 0-1.27.972-2.006 2.71-2.107l1.696-.102V9.38c0-.584-.42-.914-1.18-.914-.667 0-1.112.228-1.264.647h-1.701c.12-1.295 1.307-2.107 3.066-2.107zm1.079 4.1l-1.416.09c-.793.056-1.18.342-1.18.844 0 .52.45.837 1.091.837.857 0 1.505-.545 1.505-1.256v-.515z\" />\n\t</SVG>\n);\n\n/**\n * Color Selector Icon component.\n *\n * @param {Object} props Component properties.\n * @param {Object} props.style Style object.\n * @param {string} props.className Class name for component.\n *\n * @return {*} React Icon component.\n */\nconst ColorSelectorIcon = ( { style, className } ) => {\n\treturn (\n\t\t<div className=\"block-library-colors-selector__icon-container\">\n\t\t\t<div\n\t\t\t\tclassName={ `${ className } block-library-colors-selector__state-selection` }\n\t\t\t\tstyle={ style }\n\t\t\t>\n\t\t\t\t<ColorSelectorSVGIcon />\n\t\t\t</div>\n\t\t</div>\n\t);\n};\n\n/**\n * Renders the Colors Selector Toolbar with the icon button.\n *\n * @param {Object} props Component properties.\n * @param {Object} props.TextColor Text color component that wraps icon.\n * @param {Object} props.BackgroundColor Background color component that wraps icon.\n *\n * @return {*} React toggle button component.\n */\nconst renderToggleComponent = ( { TextColor, BackgroundColor } ) => ( {\n\tonToggle,\n\tisOpen,\n} ) => {\n\tconst openOnArrowDown = ( event ) => {\n\t\tif ( ! isOpen && event.keyCode === DOWN ) {\n\t\t\tevent.preventDefault();\n\t\t\tonToggle();\n\t\t}\n\t};\n\n\treturn (\n\t\t<ToolbarGroup>\n\t\t\t<ToolbarButton\n\t\t\t\tclassName=\"components-toolbar__control block-library-colors-selector__toggle\"\n\t\t\t\tlabel={ __( 'Open Colors Selector' ) }\n\t\t\t\tonClick={ onToggle }\n\t\t\t\tonKeyDown={ openOnArrowDown }\n\t\t\t\ticon={\n\t\t\t\t\t<BackgroundColor>\n\t\t\t\t\t\t<TextColor>\n\t\t\t\t\t\t\t<ColorSelectorIcon />\n\t\t\t\t\t\t</TextColor>\n\t\t\t\t\t</BackgroundColor>\n\t\t\t\t}\n\t\t\t/>\n\t\t</ToolbarGroup>\n\t);\n};\n\nconst BlockColorsStyleSelector = ( { children, ...other } ) => {\n\tdeprecated( `wp.blockEditor.BlockColorsStyleSelector`, {\n\t\talternative: 'block supports API',\n\t\tsince: '6.1',\n\t\tversion: '6.3',\n\t} );\n\n\treturn (\n\t\t<Dropdown\n\t\t\tposition=\"bottom right\"\n\t\t\tclassName=\"block-library-colors-selector\"\n\t\t\tcontentClassName=\"block-library-colors-selector__popover\"\n\t\t\trenderToggle={ renderToggleComponent( other ) }\n\t\t\trenderContent={ () => children }\n\t\t/>\n\t);\n};\n\nexport default BlockColorsStyleSelector;\n"]}
|