@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,165 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { createElement } from "@wordpress/element";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* External dependencies
|
|
6
|
+
*/
|
|
7
|
+
import classnames from 'classnames';
|
|
8
|
+
/**
|
|
9
|
+
* WordPress dependencies
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { useSelect } from '@wordpress/data';
|
|
13
|
+
import { useCallback, useMemo, createContext } from '@wordpress/element';
|
|
14
|
+
import { Popover } from '@wordpress/components';
|
|
15
|
+
import { isRTL } from '@wordpress/i18n';
|
|
16
|
+
/**
|
|
17
|
+
* Internal dependencies
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { store as blockEditorStore } from '../../store';
|
|
21
|
+
import { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';
|
|
22
|
+
import usePopoverScroll from './use-popover-scroll';
|
|
23
|
+
export const InsertionPointOpenRef = createContext();
|
|
24
|
+
|
|
25
|
+
function BlockPopoverInbetween(_ref) {
|
|
26
|
+
let {
|
|
27
|
+
previousClientId,
|
|
28
|
+
nextClientId,
|
|
29
|
+
children,
|
|
30
|
+
__unstablePopoverSlot,
|
|
31
|
+
__unstableContentRef,
|
|
32
|
+
...props
|
|
33
|
+
} = _ref;
|
|
34
|
+
const {
|
|
35
|
+
orientation,
|
|
36
|
+
rootClientId
|
|
37
|
+
} = useSelect(select => {
|
|
38
|
+
var _getBlockListSettings;
|
|
39
|
+
|
|
40
|
+
const {
|
|
41
|
+
getBlockListSettings,
|
|
42
|
+
getBlockRootClientId
|
|
43
|
+
} = select(blockEditorStore);
|
|
44
|
+
|
|
45
|
+
const _rootClientId = getBlockRootClientId(previousClientId);
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
orientation: ((_getBlockListSettings = getBlockListSettings(_rootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation) || 'vertical',
|
|
49
|
+
rootClientId: _rootClientId
|
|
50
|
+
};
|
|
51
|
+
}, [previousClientId]);
|
|
52
|
+
const previousElement = useBlockElement(previousClientId);
|
|
53
|
+
const nextElement = useBlockElement(nextClientId);
|
|
54
|
+
const isVertical = orientation === 'vertical';
|
|
55
|
+
const style = useMemo(() => {
|
|
56
|
+
if (!previousElement && !nextElement) {
|
|
57
|
+
return {};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const previousRect = previousElement ? previousElement.getBoundingClientRect() : null;
|
|
61
|
+
const nextRect = nextElement ? nextElement.getBoundingClientRect() : null;
|
|
62
|
+
|
|
63
|
+
if (isVertical) {
|
|
64
|
+
return {
|
|
65
|
+
width: previousElement ? previousElement.offsetWidth : nextElement.offsetWidth,
|
|
66
|
+
height: nextRect && previousRect ? nextRect.top - previousRect.bottom : 0
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let width = 0;
|
|
71
|
+
|
|
72
|
+
if (previousRect && nextRect) {
|
|
73
|
+
width = isRTL() ? previousRect.left - nextRect.right : nextRect.left - previousRect.right;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
width,
|
|
78
|
+
height: previousElement ? previousElement.offsetHeight : nextElement.offsetHeight
|
|
79
|
+
};
|
|
80
|
+
}, [previousElement, nextElement, isVertical]);
|
|
81
|
+
const getAnchorRect = useCallback(() => {
|
|
82
|
+
if (!previousElement && !nextElement) {
|
|
83
|
+
return {};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const {
|
|
87
|
+
ownerDocument
|
|
88
|
+
} = previousElement || nextElement;
|
|
89
|
+
const previousRect = previousElement ? previousElement.getBoundingClientRect() : null;
|
|
90
|
+
const nextRect = nextElement ? nextElement.getBoundingClientRect() : null;
|
|
91
|
+
|
|
92
|
+
if (isVertical) {
|
|
93
|
+
if (isRTL()) {
|
|
94
|
+
return {
|
|
95
|
+
top: previousRect ? previousRect.bottom : nextRect.top,
|
|
96
|
+
left: previousRect ? previousRect.right : nextRect.right,
|
|
97
|
+
right: previousRect ? previousRect.left : nextRect.left,
|
|
98
|
+
bottom: nextRect ? nextRect.top : previousRect.bottom,
|
|
99
|
+
ownerDocument
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
top: previousRect ? previousRect.bottom : nextRect.top,
|
|
105
|
+
left: previousRect ? previousRect.left : nextRect.left,
|
|
106
|
+
right: previousRect ? previousRect.right : nextRect.right,
|
|
107
|
+
bottom: nextRect ? nextRect.top : previousRect.bottom,
|
|
108
|
+
ownerDocument
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (isRTL()) {
|
|
113
|
+
return {
|
|
114
|
+
top: previousRect ? previousRect.top : nextRect.top,
|
|
115
|
+
left: previousRect ? previousRect.left : nextRect.right,
|
|
116
|
+
right: nextRect ? nextRect.right : previousRect.left,
|
|
117
|
+
bottom: previousRect ? previousRect.bottom : nextRect.bottom,
|
|
118
|
+
ownerDocument
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return {
|
|
123
|
+
top: previousRect ? previousRect.top : nextRect.top,
|
|
124
|
+
left: previousRect ? previousRect.right : nextRect.left,
|
|
125
|
+
right: nextRect ? nextRect.left : previousRect.right,
|
|
126
|
+
bottom: previousRect ? previousRect.bottom : nextRect.bottom,
|
|
127
|
+
ownerDocument
|
|
128
|
+
};
|
|
129
|
+
}, [previousElement, nextElement]);
|
|
130
|
+
const popoverScrollRef = usePopoverScroll(__unstableContentRef);
|
|
131
|
+
|
|
132
|
+
if (!previousElement || !nextElement) {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
/* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
|
|
136
|
+
// While ideally it would be enough to capture the
|
|
137
|
+
// bubbling focus event from the Inserter, due to the
|
|
138
|
+
// characteristics of click focusing of `button`s in
|
|
139
|
+
// Firefox and Safari, it is not reliable.
|
|
140
|
+
//
|
|
141
|
+
// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
return createElement(Popover, _extends({
|
|
145
|
+
ref: popoverScrollRef,
|
|
146
|
+
noArrow: true,
|
|
147
|
+
animate: false,
|
|
148
|
+
getAnchorRect: getAnchorRect,
|
|
149
|
+
focusOnMount: false // Render in the old slot if needed for backward compatibility,
|
|
150
|
+
// otherwise render in place (not in the the default popover slot).
|
|
151
|
+
,
|
|
152
|
+
__unstableSlotName: __unstablePopoverSlot || null // Forces a remount of the popover when its position changes
|
|
153
|
+
// This makes sure the popover doesn't animate from its previous position.
|
|
154
|
+
,
|
|
155
|
+
key: nextClientId + '--' + rootClientId
|
|
156
|
+
}, props, {
|
|
157
|
+
className: classnames('block-editor-block-popover', props.className)
|
|
158
|
+
}), createElement("div", {
|
|
159
|
+
style: style
|
|
160
|
+
}, children));
|
|
161
|
+
/* eslint-enable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export default BlockPopoverInbetween;
|
|
165
|
+
//# sourceMappingURL=inbetween.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-popover/inbetween.js"],"names":["classnames","useSelect","useCallback","useMemo","createContext","Popover","isRTL","store","blockEditorStore","__unstableUseBlockElement","useBlockElement","usePopoverScroll","InsertionPointOpenRef","BlockPopoverInbetween","previousClientId","nextClientId","children","__unstablePopoverSlot","__unstableContentRef","props","orientation","rootClientId","select","getBlockListSettings","getBlockRootClientId","_rootClientId","previousElement","nextElement","isVertical","style","previousRect","getBoundingClientRect","nextRect","width","offsetWidth","height","top","bottom","left","right","offsetHeight","getAnchorRect","ownerDocument","popoverScrollRef","className"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,WAAT,EAAsBC,OAAtB,EAA+BC,aAA/B,QAAoD,oBAApD;AACA,SAASC,OAAT,QAAwB,uBAAxB;AACA,SAASC,KAAT,QAAsB,iBAAtB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,yBAAyB,IAAIC,eAAtC,QAA6D,8CAA7D;AACA,OAAOC,gBAAP,MAA6B,sBAA7B;AAEA,OAAO,MAAMC,qBAAqB,GAAGR,aAAa,EAA3C;;AAEP,SAASS,qBAAT,OAOI;AAAA,MAP4B;AAC/BC,IAAAA,gBAD+B;AAE/BC,IAAAA,YAF+B;AAG/BC,IAAAA,QAH+B;AAI/BC,IAAAA,qBAJ+B;AAK/BC,IAAAA,oBAL+B;AAM/B,OAAGC;AAN4B,GAO5B;AACH,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA;AAAf,MAAgCpB,SAAS,CAC5CqB,MA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;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SACC,cAAC,OAAD;AACC,IAAA,GAAG,EAAGgB,gBADP;AAEC,IAAA,OAAO,MAFR;AAGC,IAAA,OAAO,EAAG,KAHX;AAIC,IAAA,aAAa,EAAGF,aAJjB;AAKC,IAAA,YAAY,EAAG,KALhB,CAMC;AACA;AAPD;AAQC,IAAA,kBAAkB,EAAGxB,qBAAqB,IAAI,IAR/C,CASC;AACA;AAVD;AAWC,IAAA,GAAG,EAAGF,YAAY,GAAG,IAAf,GAAsBM;AAX7B,KAYMF,KAZN;AAaC,IAAA,SAAS,EAAGnB,UAAU,CACrB,4BADqB,EAErBmB,KAAK,CAACyB,SAFe;AAbvB,MAkBC;AAAK,IAAA,KAAK,EAAGf;AAAb,KAAuBb,QAAvB,CAlBD,CADD;AAsBA;AACA;;AAED,eAAeH,qBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useCallback, useMemo, createContext } from '@wordpress/element';\nimport { Popover } from '@wordpress/components';\nimport { isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\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 BlockPopoverInbetween( {\n\tpreviousClientId,\n\tnextClientId,\n\tchildren,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n\t...props\n} ) {\n\tconst { orientation, rootClientId } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockListSettings, getBlockRootClientId } = select(\n\t\t\t\tblockEditorStore\n\t\t\t);\n\n\t\t\tconst _rootClientId = getBlockRootClientId( previousClientId );\n\t\t\treturn {\n\t\t\t\torientation:\n\t\t\t\t\tgetBlockListSettings( _rootClientId )?.orientation ||\n\t\t\t\t\t'vertical',\n\t\t\t\trootClientId: _rootClientId,\n\t\t\t};\n\t\t},\n\t\t[ previousClientId ]\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, isVertical ] );\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\n\tif ( ! previousElement || ! nextElement ) {\n\t\treturn null;\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\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\t{ ...props }\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-block-popover',\n\t\t\t\tprops.className\n\t\t\t) }\n\t\t>\n\t\t\t<div style={ style }>{ children }</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 BlockPopoverInbetween;\n"]}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { createElement } from "@wordpress/element";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* External dependencies
|
|
6
|
+
*/
|
|
7
|
+
import classnames from 'classnames';
|
|
8
|
+
/**
|
|
9
|
+
* WordPress dependencies
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { Popover } from '@wordpress/components';
|
|
13
|
+
import { getScrollContainer } from '@wordpress/dom';
|
|
14
|
+
/**
|
|
15
|
+
* Internal dependencies
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';
|
|
19
|
+
import usePopoverScroll from './use-popover-scroll';
|
|
20
|
+
export default function BlockPopover(_ref) {
|
|
21
|
+
let {
|
|
22
|
+
clientId,
|
|
23
|
+
bottomClientId,
|
|
24
|
+
children,
|
|
25
|
+
__unstablePopoverSlot,
|
|
26
|
+
__unstableContentRef,
|
|
27
|
+
...props
|
|
28
|
+
} = _ref;
|
|
29
|
+
const selectedElement = useBlockElement(clientId);
|
|
30
|
+
const lastSelectedElement = useBlockElement(bottomClientId !== null && bottomClientId !== void 0 ? bottomClientId : clientId);
|
|
31
|
+
const popoverScrollRef = usePopoverScroll(__unstableContentRef);
|
|
32
|
+
|
|
33
|
+
if (!selectedElement || bottomClientId && !lastSelectedElement) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const anchorRef = {
|
|
38
|
+
top: selectedElement,
|
|
39
|
+
bottom: lastSelectedElement
|
|
40
|
+
};
|
|
41
|
+
const {
|
|
42
|
+
ownerDocument
|
|
43
|
+
} = selectedElement;
|
|
44
|
+
const stickyBoundaryElement = ownerDocument.defaultView.frameElement || getScrollContainer(selectedElement) || ownerDocument.body;
|
|
45
|
+
return createElement(Popover, _extends({
|
|
46
|
+
ref: popoverScrollRef,
|
|
47
|
+
noArrow: true,
|
|
48
|
+
animate: false,
|
|
49
|
+
position: "top right left",
|
|
50
|
+
focusOnMount: false,
|
|
51
|
+
anchorRef: anchorRef,
|
|
52
|
+
__unstableStickyBoundaryElement: stickyBoundaryElement // Render in the old slot if needed for backward compatibility,
|
|
53
|
+
// otherwise render in place (not in the the default popover slot).
|
|
54
|
+
,
|
|
55
|
+
__unstableSlotName: __unstablePopoverSlot || null,
|
|
56
|
+
__unstableBoundaryParent: true // Observe movement for block animations (especially horizontal).
|
|
57
|
+
,
|
|
58
|
+
__unstableObserveElement: selectedElement,
|
|
59
|
+
shouldAnchorIncludePadding: true // Used to safeguard sticky position behavior against cases where it would permanently
|
|
60
|
+
// obscure specific sections of a block.
|
|
61
|
+
,
|
|
62
|
+
__unstableEditorCanvasWrapper: __unstableContentRef === null || __unstableContentRef === void 0 ? void 0 : __unstableContentRef.current
|
|
63
|
+
}, props, {
|
|
64
|
+
className: classnames('block-editor-block-popover', props.className)
|
|
65
|
+
}), children);
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-popover/index.js"],"names":["classnames","Popover","getScrollContainer","__unstableUseBlockElement","useBlockElement","usePopoverScroll","BlockPopover","clientId","bottomClientId","children","__unstablePopoverSlot","__unstableContentRef","props","selectedElement","lastSelectedElement","popoverScrollRef","anchorRef","top","bottom","ownerDocument","stickyBoundaryElement","defaultView","frameElement","body","current","className"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,OAAT,QAAwB,uBAAxB;AACA,SAASC,kBAAT,QAAmC,gBAAnC;AAEA;AACA;AACA;;AACA,SAASC,yBAAyB,IAAIC,eAAtC,QAA6D,8CAA7D;AACA,OAAOC,gBAAP,MAA6B,sBAA7B;AAEA,eAAe,SAASC,YAAT,OAOX;AAAA,MAPkC;AACrCC,IAAAA,QADqC;AAErCC,IAAAA,cAFqC;AAGrCC,IAAAA,QAHqC;AAIrCC,IAAAA,qBAJqC;AAKrCC,IAAAA,oBALqC;AAMrC,OAAGC;AANkC,GAOlC;AACH,QAAMC,eAAe,GAAGT,eAAe,CAAEG,QAAF,CAAvC;AACA,QAAMO,mBAAmB,GAAGV,eAAe,CAAEI,cAAF,aAAEA,cAAF,cAAEA,cAAF,GAAoBD,QAApB,CAA3C;AACA,QAAMQ,gBAAgB,GAAGV,gBAAgB,CAAEM,oBAAF,CAAzC;;AAEA,MAAK,CAAEE,eAAF,IAAuBL,cAAc,IAAI,CAAEM,mBAAhD,EAAwE;AACvE,WAAO,IAAP;AACA;;AAED,QAAME,SAAS,GAAG;AACjBC,IAAAA,GAAG,EAAEJ,eADY;AAEjBK,IAAAA,MAAM,EAAEJ;AAFS,GAAlB;AAKA,QAAM;AAAEK,IAAAA;AAAF,MAAoBN,eAA1B;AACA,QAAMO,qBAAqB,GAC1BD,aAAa,CAACE,WAAd,CAA0BC,YAA1B,IACApB,kBAAkB,CAAEW,eAAF,CADlB,IAEAM,aAAa,CAACI,IAHf;AAKA,SACC,cAAC,OAAD;AACC,IAAA,GAAG,EAAGR,gBADP;AAEC,IAAA,OAAO,MAFR;AAGC,IAAA,OAAO,EAAG,KAHX;AAIC,IAAA,QAAQ,EAAC,gBAJV;AAKC,IAAA,YAAY,EAAG,KALhB;AAMC,IAAA,SAAS,EAAGC,SANb;AAOC,IAAA,+BAA+B,EAAGI,qBAPnC,CAQC;AACA;AATD;AAUC,IAAA,kBAAkB,EAAGV,qBAAqB,IAAI,IAV/C;AAWC,IAAA,wBAAwB,MAXzB,CAYC;AAZD;AAaC,IAAA,wBAAwB,EAAGG,eAb5B;AAcC,IAAA,0BAA0B,MAd3B,CAeC;AACA;AAhBD;AAiBC,IAAA,6BAA6B,EAAGF,oBAAH,aAAGA,oBAAH,uBAAGA,oBAAoB,CAAEa;AAjBvD,KAkBMZ,KAlBN;AAmBC,IAAA,SAAS,EAAGZ,UAAU,CACrB,4BADqB,EAErBY,KAAK,CAACa,SAFe;AAnBvB,MAwBGhB,QAxBH,CADD;AA4BA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Popover } from '@wordpress/components';\nimport { getScrollContainer } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport usePopoverScroll from './use-popover-scroll';\n\nexport default function BlockPopover( {\n\tclientId,\n\tbottomClientId,\n\tchildren,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n\t...props\n} ) {\n\tconst selectedElement = useBlockElement( clientId );\n\tconst lastSelectedElement = useBlockElement( bottomClientId ?? clientId );\n\tconst popoverScrollRef = usePopoverScroll( __unstableContentRef );\n\n\tif ( ! selectedElement || ( bottomClientId && ! lastSelectedElement ) ) {\n\t\treturn null;\n\t}\n\n\tconst anchorRef = {\n\t\ttop: selectedElement,\n\t\tbottom: lastSelectedElement,\n\t};\n\n\tconst { ownerDocument } = selectedElement;\n\tconst stickyBoundaryElement =\n\t\townerDocument.defaultView.frameElement ||\n\t\tgetScrollContainer( selectedElement ) ||\n\t\townerDocument.body;\n\n\treturn (\n\t\t<Popover\n\t\t\tref={ popoverScrollRef }\n\t\t\tnoArrow\n\t\t\tanimate={ false }\n\t\t\tposition=\"top right left\"\n\t\t\tfocusOnMount={ false }\n\t\t\tanchorRef={ anchorRef }\n\t\t\t__unstableStickyBoundaryElement={ stickyBoundaryElement }\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__unstableBoundaryParent\n\t\t\t// Observe movement for block animations (especially horizontal).\n\t\t\t__unstableObserveElement={ selectedElement }\n\t\t\tshouldAnchorIncludePadding\n\t\t\t// Used to safeguard sticky position behavior against cases where it would permanently\n\t\t\t// obscure specific sections of a block.\n\t\t\t__unstableEditorCanvasWrapper={ __unstableContentRef?.current }\n\t\t\t{ ...props }\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-block-popover',\n\t\t\t\tprops.className\n\t\t\t) }\n\t\t>\n\t\t\t{ children }\n\t\t</Popover>\n\t);\n}\n"]}
|
|
@@ -10,7 +10,7 @@ import { useRefEffect } from '@wordpress/compose';
|
|
|
10
10
|
* @param {Object} scrollableRef
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
function usePopoverScroll(scrollableRef) {
|
|
14
14
|
return useRefEffect(node => {
|
|
15
15
|
if (!scrollableRef) {
|
|
16
16
|
return;
|
|
@@ -35,4 +35,6 @@ export function usePopoverScroll(scrollableRef) {
|
|
|
35
35
|
};
|
|
36
36
|
}, [scrollableRef]);
|
|
37
37
|
}
|
|
38
|
+
|
|
39
|
+
export default usePopoverScroll;
|
|
38
40
|
//# sourceMappingURL=use-popover-scroll.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-popover/use-popover-scroll.js"],"names":["useRefEffect","usePopoverScroll","scrollableRef","node","onWheel","event","deltaX","deltaY","current","scrollBy","options","passive","addEventListener","removeEventListener"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAT,QAA6B,oBAA7B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,gBAAT,CAA2BC,aAA3B,EAA2C;AAC1C,SAAOF,YAAY,CAChBG,IAAF,IAAY;AACX,QAAK,CAAED,aAAP,EAAuB;AACtB;AACA;;AAED,aAASE,OAAT,CAAkBC,KAAlB,EAA0B;AACzB,YAAM;AAAEC,QAAAA,MAAF;AAAUC,QAAAA;AAAV,UAAqBF,KAA3B;AACAH,MAAAA,aAAa,CAACM,OAAd,CAAsBC,QAAtB,CAAgCH,MAAhC,EAAwCC,MAAxC;AACA,KARU,CASX;AACA;;;AACA,UAAMG,OAAO,GAAG;AAAEC,MAAAA,OAAO,EAAE;AAAX,KAAhB;AACAR,IAAAA,IAAI,CAACS,gBAAL,CAAuB,OAAvB,EAAgCR,OAAhC,EAAyCM,OAAzC;AACA,WAAO,MAAM;AACZP,MAAAA,IAAI,CAACU,mBAAL,CAA0B,OAA1B,EAAmCT,OAAnC,EAA4CM,OAA5C;AACA,KAFD;AAGA,GAjBiB,EAkBlB,CAAER,aAAF,CAlBkB,CAAnB;AAoBA;;AAED,eAAeD,gBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Allow scrolling \"through\" popovers over the canvas. This is only called for\n * as long as the pointer is over a popover. Do not use React events because it\n * will bubble through portals.\n *\n * @param {Object} scrollableRef\n */\nfunction usePopoverScroll( scrollableRef ) {\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( ! scrollableRef ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfunction onWheel( event ) {\n\t\t\t\tconst { deltaX, deltaY } = event;\n\t\t\t\tscrollableRef.current.scrollBy( deltaX, deltaY );\n\t\t\t}\n\t\t\t// Tell the browser that we do not call event.preventDefault\n\t\t\t// See https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#improving_scrolling_performance_with_passive_listeners\n\t\t\tconst options = { passive: true };\n\t\t\tnode.addEventListener( 'wheel', onWheel, options );\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'wheel', onWheel, options );\n\t\t\t};\n\t\t},\n\t\t[ scrollableRef ]\n\t);\n}\n\nexport default usePopoverScroll;\n"]}
|
|
@@ -22,7 +22,8 @@ const MAX_HEIGHT = 2000;
|
|
|
22
22
|
function AutoBlockPreview(_ref) {
|
|
23
23
|
let {
|
|
24
24
|
viewportWidth,
|
|
25
|
-
__experimentalPadding
|
|
25
|
+
__experimentalPadding,
|
|
26
|
+
__experimentalMinHeight
|
|
26
27
|
} = _ref;
|
|
27
28
|
const [containerResizeListener, {
|
|
28
29
|
width: containerWidth
|
|
@@ -61,7 +62,8 @@ function AutoBlockPreview(_ref) {
|
|
|
61
62
|
style: {
|
|
62
63
|
transform: `scale(${scale})`,
|
|
63
64
|
height: contentHeight * scale,
|
|
64
|
-
maxHeight: contentHeight > MAX_HEIGHT ? MAX_HEIGHT * scale : undefined
|
|
65
|
+
maxHeight: contentHeight > MAX_HEIGHT ? MAX_HEIGHT * scale : undefined,
|
|
66
|
+
minHeight: __experimentalMinHeight
|
|
65
67
|
}
|
|
66
68
|
}, createElement(Iframe, {
|
|
67
69
|
head: createElement(EditorStyles, {
|
|
@@ -90,7 +92,8 @@ function AutoBlockPreview(_ref) {
|
|
|
90
92
|
pointerEvents: 'none',
|
|
91
93
|
// This is a catch-all max-height for patterns.
|
|
92
94
|
// See: https://github.com/WordPress/gutenberg/pull/38175.
|
|
93
|
-
maxHeight: MAX_HEIGHT
|
|
95
|
+
maxHeight: MAX_HEIGHT,
|
|
96
|
+
minHeight: scale < 1 && __experimentalMinHeight ? __experimentalMinHeight / scale : __experimentalMinHeight
|
|
94
97
|
}
|
|
95
98
|
}, contentResizeListener, createElement(MemoizedBlockList, {
|
|
96
99
|
renderAppender: false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-preview/auto.js"],"names":["Disabled","useResizeObserver","pure","useRefEffect","useSelect","useMemo","BlockList","Iframe","EditorStyles","store","MemoizedBlockList","MAX_HEIGHT","AutoBlockPreview","viewportWidth","__experimentalPadding","containerResizeListener","width","containerWidth","contentResizeListener","height","contentHeight","styles","assets","select","settings","getSettings","__unstableResolvedAssets","editorStyles","css","__unstableType","scale","transform","maxHeight","undefined","bodyElement","ownerDocument","documentElement","classList","add","style","position","padding","pointerEvents"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,uBAAzB;AACA,SAASC,iBAAT,EAA4BC,IAA5B,EAAkCC,YAAlC,QAAsD,oBAAtD;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,OAAT,QAAwB,oBAAxB;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,eAAtB;AACA,OAAOC,MAAP,MAAmB,WAAnB;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,SAASC,KAAT,QAAsB,aAAtB,C,CAEA;;AACA,IAAIC,iBAAJ;AAEA,MAAMC,UAAU,GAAG,IAAnB;;AAEA,SAASC,gBAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-preview/auto.js"],"names":["Disabled","useResizeObserver","pure","useRefEffect","useSelect","useMemo","BlockList","Iframe","EditorStyles","store","MemoizedBlockList","MAX_HEIGHT","AutoBlockPreview","viewportWidth","__experimentalPadding","__experimentalMinHeight","containerResizeListener","width","containerWidth","contentResizeListener","height","contentHeight","styles","assets","select","settings","getSettings","__unstableResolvedAssets","editorStyles","css","__unstableType","scale","transform","maxHeight","undefined","minHeight","bodyElement","ownerDocument","documentElement","classList","add","style","position","padding","pointerEvents"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,uBAAzB;AACA,SAASC,iBAAT,EAA4BC,IAA5B,EAAkCC,YAAlC,QAAsD,oBAAtD;AACA,SAASC,SAAT,QAA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AACA;AACAX,MAAAA,SAAS,EAAEtB,UAPJ;AAQPwB,MAAAA,SAAS,EACRJ,KAAK,GAAG,CAAR,IAAahB,uBAAb,GACGA,uBAAuB,GAAGgB,KAD7B,GAEGhB;AAXG;AApBT,KAkCGI,qBAlCH,EAmCC,cAAC,iBAAD;AAAmB,IAAA,cAAc,EAAG;AAApC,IAnCD,CAZD,CAFD,CADD;AAuDA;;AAED,eAAeP,gBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Disabled } from '@wordpress/components';\nimport { useResizeObserver, pure, useRefEffect } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BlockList from '../block-list';\nimport Iframe from '../iframe';\nimport EditorStyles from '../editor-styles';\nimport { store } from '../../store';\n\n// This is used to avoid rendering the block list if the sizes change.\nlet MemoizedBlockList;\n\nconst MAX_HEIGHT = 2000;\n\nfunction AutoBlockPreview( {\n\tviewportWidth,\n\t__experimentalPadding,\n\t__experimentalMinHeight,\n} ) {\n\tconst [\n\t\tcontainerResizeListener,\n\t\t{ width: containerWidth },\n\t] = useResizeObserver();\n\tconst [\n\t\tcontentResizeListener,\n\t\t{ height: contentHeight },\n\t] = useResizeObserver();\n\tconst { styles, assets } = useSelect( ( select ) => {\n\t\tconst settings = select( store ).getSettings();\n\t\treturn {\n\t\t\tstyles: settings.styles,\n\t\t\tassets: settings.__unstableResolvedAssets,\n\t\t};\n\t}, [] );\n\n\t// Avoid scrollbars for pattern previews.\n\tconst editorStyles = useMemo( () => {\n\t\tif ( styles ) {\n\t\t\treturn [\n\t\t\t\t...styles,\n\t\t\t\t{\n\t\t\t\t\tcss: 'body{height:auto;overflow:hidden;}',\n\t\t\t\t\t__unstableType: 'presets',\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\treturn styles;\n\t}, [ styles ] );\n\n\t// Initialize on render instead of module top level, to avoid circular dependency issues.\n\tMemoizedBlockList = MemoizedBlockList || pure( BlockList );\n\n\tconst scale = containerWidth / viewportWidth;\n\n\treturn (\n\t\t<div className=\"block-editor-block-preview__container\">\n\t\t\t{ containerResizeListener }\n\t\t\t<Disabled\n\t\t\t\tclassName=\"block-editor-block-preview__content\"\n\t\t\t\tstyle={ {\n\t\t\t\t\ttransform: `scale(${ scale })`,\n\t\t\t\t\theight: contentHeight * scale,\n\t\t\t\t\tmaxHeight:\n\t\t\t\t\t\tcontentHeight > MAX_HEIGHT\n\t\t\t\t\t\t\t? MAX_HEIGHT * scale\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\tminHeight: __experimentalMinHeight,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<Iframe\n\t\t\t\t\thead={ <EditorStyles styles={ editorStyles } /> }\n\t\t\t\t\tassets={ assets }\n\t\t\t\t\tcontentRef={ useRefEffect( ( bodyElement ) => {\n\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\townerDocument: { documentElement },\n\t\t\t\t\t\t} = bodyElement;\n\t\t\t\t\t\tdocumentElement.classList.add(\n\t\t\t\t\t\t\t'block-editor-block-preview__content-iframe'\n\t\t\t\t\t\t);\n\t\t\t\t\t\tdocumentElement.style.position = 'absolute';\n\t\t\t\t\t\tdocumentElement.style.width = '100%';\n\t\t\t\t\t\tbodyElement.style.padding =\n\t\t\t\t\t\t\t__experimentalPadding + 'px';\n\n\t\t\t\t\t\t// necessary for contentResizeListener to work.\n\t\t\t\t\t\tbodyElement.style.position = 'relative';\n\t\t\t\t\t}, [] ) }\n\t\t\t\t\taria-hidden\n\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\tposition: 'absolute',\n\t\t\t\t\t\twidth: viewportWidth,\n\t\t\t\t\t\theight: contentHeight,\n\t\t\t\t\t\tpointerEvents: 'none',\n\t\t\t\t\t\t// This is a catch-all max-height for patterns.\n\t\t\t\t\t\t// See: https://github.com/WordPress/gutenberg/pull/38175.\n\t\t\t\t\t\tmaxHeight: MAX_HEIGHT,\n\t\t\t\t\t\tminHeight:\n\t\t\t\t\t\t\tscale < 1 && __experimentalMinHeight\n\t\t\t\t\t\t\t\t? __experimentalMinHeight / scale\n\t\t\t\t\t\t\t\t: __experimentalMinHeight,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ contentResizeListener }\n\t\t\t\t\t<MemoizedBlockList renderAppender={ false } />\n\t\t\t\t</Iframe>\n\t\t\t</Disabled>\n\t\t</div>\n\t);\n}\n\nexport default AutoBlockPreview;\n"]}
|
|
@@ -27,7 +27,8 @@ export function BlockPreview(_ref) {
|
|
|
27
27
|
__experimentalPadding = 0,
|
|
28
28
|
viewportWidth = 1200,
|
|
29
29
|
__experimentalLive = false,
|
|
30
|
-
__experimentalOnClick
|
|
30
|
+
__experimentalOnClick,
|
|
31
|
+
__experimentalMinHeight
|
|
31
32
|
} = _ref;
|
|
32
33
|
const originalSettings = useSelect(select => select(blockEditorStore).getSettings(), []);
|
|
33
34
|
const settings = useMemo(() => {
|
|
@@ -49,7 +50,8 @@ export function BlockPreview(_ref) {
|
|
|
49
50
|
onClick: __experimentalOnClick
|
|
50
51
|
}) : createElement(AutoHeightBlockPreview, {
|
|
51
52
|
viewportWidth: viewportWidth,
|
|
52
|
-
__experimentalPadding: __experimentalPadding
|
|
53
|
+
__experimentalPadding: __experimentalPadding,
|
|
54
|
+
__experimentalMinHeight: __experimentalMinHeight
|
|
53
55
|
}));
|
|
54
56
|
}
|
|
55
57
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-preview/index.js"],"names":["castArray","classnames","__experimentalUseDisabled","useDisabled","useMergeRefs","useSelect","memo","useMemo","BlockEditorProvider","LiveBlockPreview","AutoHeightBlockPreview","store","blockEditorStore","BlockListItems","BlockPreview","blocks","__experimentalPadding","viewportWidth","__experimentalLive","__experimentalOnClick","originalSettings","select","getSettings","settings","_settings","__experimentalBlockPatterns","renderedBlocks","length","useBlockPreview","props","__experimentalLayout","disabledRef","ref","children","className"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,QAA1B;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,yBAAyB,IAAIC,WAD9B,EAECC,YAFD,QAGO,oBAHP;AAIA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,IAAT,EAAeC,OAAf,QAA8B,oBAA9B;AAEA;AACA;AACA;;AACA,OAAOC,mBAAP,MAAgC,aAAhC;AACA,OAAOC,gBAAP,MAA6B,QAA7B;AACA,OAAOC,sBAAP,MAAmC,QAAnC;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,cAAT,QAA+B,eAA/B;AAEA,OAAO,SAASC,YAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-preview/index.js"],"names":["castArray","classnames","__experimentalUseDisabled","useDisabled","useMergeRefs","useSelect","memo","useMemo","BlockEditorProvider","LiveBlockPreview","AutoHeightBlockPreview","store","blockEditorStore","BlockListItems","BlockPreview","blocks","__experimentalPadding","viewportWidth","__experimentalLive","__experimentalOnClick","__experimentalMinHeight","originalSettings","select","getSettings","settings","_settings","__experimentalBlockPatterns","renderedBlocks","length","useBlockPreview","props","__experimentalLayout","disabledRef","ref","children","className"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,QAA1B;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,yBAAyB,IAAIC,WAD9B,EAECC,YAFD,QAGO,oBAHP;AAIA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,IAAT,EAAeC,OAAf,QAA8B,oBAA9B;AAEA;AACA;AACA;;AACA,OAAOC,mBAAP,MAAgC,aAAhC;AACA,OAAOC,gBAAP,MAA6B,QAA7B;AACA,OAAOC,sBAAP,MAAmC,QAAnC;AACA,SAASC,KAAK,IAAIC,gBAAlB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import classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalUseDisabled as useDisabled,\n\tuseMergeRefs,\n} from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { memo, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BlockEditorProvider from '../provider';\nimport LiveBlockPreview from './live';\nimport AutoHeightBlockPreview from './auto';\nimport { store as blockEditorStore } from '../../store';\nimport { BlockListItems } from '../block-list';\n\nexport function BlockPreview( {\n\tblocks,\n\t__experimentalPadding = 0,\n\tviewportWidth = 1200,\n\t__experimentalLive = false,\n\t__experimentalOnClick,\n\t__experimentalMinHeight,\n} ) {\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo( () => {\n\t\tconst _settings = { ...originalSettings };\n\t\t_settings.__experimentalBlockPatterns = [];\n\t\treturn _settings;\n\t}, [ originalSettings ] );\n\tconst renderedBlocks = useMemo( () => castArray( blocks ), [ blocks ] );\n\tif ( ! blocks || blocks.length === 0 ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<BlockEditorProvider value={ renderedBlocks } settings={ settings }>\n\t\t\t{ __experimentalLive ? (\n\t\t\t\t<LiveBlockPreview onClick={ __experimentalOnClick } />\n\t\t\t) : (\n\t\t\t\t<AutoHeightBlockPreview\n\t\t\t\t\tviewportWidth={ viewportWidth }\n\t\t\t\t\t__experimentalPadding={ __experimentalPadding }\n\t\t\t\t\t__experimentalMinHeight={ __experimentalMinHeight }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</BlockEditorProvider>\n\t);\n}\n\n/**\n * BlockPreview renders a preview of a block or array of blocks.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-preview/README.md\n *\n * @param {Object} preview options for how the preview should be shown\n * @param {Array|Object} preview.blocks A block instance (object) or an array of blocks to be previewed.\n * @param {number} preview.viewportWidth Width of the preview container in pixels. Controls at what size the blocks will be rendered inside the preview. Default: 700.\n *\n * @return {WPComponent} The component to be rendered.\n */\nexport default memo( BlockPreview );\n\n/**\n * This hook is used to lightly mark an element as a block preview wrapper\n * element. Call this hook and pass the returned props to the element to mark as\n * a block preview wrapper, automatically rendering inner blocks as children. If\n * you define a ref for the element, it is important to pass the ref to this\n * hook, which the hook in turn will pass to the component through the props it\n * returns. Optionally, you can also pass any other props through this hook, and\n * they will be merged and returned.\n *\n * @param {Object} options Preview options.\n * @param {WPBlock[]} options.blocks Block objects.\n * @param {Object} options.props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options.__experimentalLayout Layout settings to be used in the preview.\n *\n */\nexport function useBlockPreview( {\n\tblocks,\n\tprops = {},\n\t__experimentalLayout,\n} ) {\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst disabledRef = useDisabled();\n\tconst ref = useMergeRefs( [ props.ref, disabledRef ] );\n\tconst settings = useMemo(\n\t\t() => ( { ...originalSettings, __experimentalBlockPatterns: [] } ),\n\t\t[ originalSettings ]\n\t);\n\tconst renderedBlocks = useMemo( () => castArray( blocks ), [ blocks ] );\n\n\tconst children = (\n\t\t<BlockEditorProvider value={ renderedBlocks } settings={ settings }>\n\t\t\t<BlockListItems\n\t\t\t\trenderAppender={ false }\n\t\t\t\t__experimentalLayout={ __experimentalLayout }\n\t\t\t/>\n\t\t</BlockEditorProvider>\n\t);\n\n\treturn {\n\t\t...props,\n\t\tref,\n\t\tclassName: classnames(\n\t\t\tprops.className,\n\t\t\t'block-editor-block-preview__live-content',\n\t\t\t'components-disabled'\n\t\t),\n\t\tchildren: blocks?.length ? children : null,\n\t};\n}\n"]}
|
|
@@ -11,7 +11,6 @@ import classnames from 'classnames';
|
|
|
11
11
|
|
|
12
12
|
import { useState, useLayoutEffect } from '@wordpress/element';
|
|
13
13
|
import { useViewportMatch } from '@wordpress/compose';
|
|
14
|
-
import { ENTER, SPACE } from '@wordpress/keycodes';
|
|
15
14
|
import { Button, __experimentalText as Text, Slot, Fill } from '@wordpress/components';
|
|
16
15
|
/**
|
|
17
16
|
* Internal dependencies
|
|
@@ -113,15 +112,8 @@ function BlockStyles(_ref3) {
|
|
|
113
112
|
onFocus: () => styleItemHandler(style),
|
|
114
113
|
onMouseLeave: () => styleItemHandler(null),
|
|
115
114
|
onBlur: () => styleItemHandler(null),
|
|
116
|
-
onKeyDown: event => {
|
|
117
|
-
if (ENTER === event.keyCode || SPACE === event.keyCode) {
|
|
118
|
-
event.preventDefault();
|
|
119
|
-
onSelectStylePreview(style);
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
115
|
onClick: () => onSelectStylePreview(style),
|
|
123
|
-
|
|
124
|
-
tabIndex: "0"
|
|
116
|
+
"aria-current": activeStyle.name === style.name
|
|
125
117
|
}, createElement(Text, {
|
|
126
118
|
as: "span",
|
|
127
119
|
limit: 12,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-styles/index.js"],"names":["noop","debounce","classnames","useState","useLayoutEffect","useViewportMatch","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-styles/index.js"],"names":["noop","debounce","classnames","useState","useLayoutEffect","useViewportMatch","Button","__experimentalText","Text","Slot","Fill","BlockStylesPreviewPanel","useStylesForBlocks","BlockStylesPreviewPanelSlot","scope","BlockStylesPreviewPanelFill","children","props","DEFAULT_POSITION_TOP","BlockStyles","clientId","onSwitch","onHoverClassName","onSelect","stylesToRender","activeStyle","genericPreviewBlock","className","previewClassName","hoveredStyle","setHoveredStyle","containerScrollTop","setContainerScrollTop","isMobileViewport","scrollContainer","document","querySelector","scrollTop","length","debouncedSetHoveredStyle","onSelectStylePreview","style","cancel","styleItemHandler","item","name","map","buttonText","label","top"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,EAAeC,QAAf,QAA+B,QAA/B;AACA,OAAOC,UAAP,MAAuB,YA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tCF,CADD;AAuDA;;AAEDV,WAAW,CAACV,IAAZ,GAAmBI,2BAAnB;AACA,eAAeM,WAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { noop, debounce } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useLayoutEffect } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\nimport {\n\tButton,\n\t__experimentalText as Text,\n\tSlot,\n\tFill,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport BlockStylesPreviewPanel from './preview-panel';\nimport useStylesForBlocks from './use-styles-for-block';\n\nfunction BlockStylesPreviewPanelSlot( { scope } ) {\n\treturn <Slot name={ `BlockStylesPreviewPanel/${ scope }` } />;\n}\n\nfunction BlockStylesPreviewPanelFill( { children, scope, ...props } ) {\n\treturn (\n\t\t<Fill name={ `BlockStylesPreviewPanel/${ scope }` }>\n\t\t\t<div { ...props }>{ children }</div>\n\t\t</Fill>\n\t);\n}\n\n// Top position (in px) of the Block Styles container\n// relative to the editor pane.\n// The value is the equivalent of the container's right position.\nconst DEFAULT_POSITION_TOP = 16;\n\n// Block Styles component for the Settings Sidebar.\nfunction BlockStyles( {\n\tclientId,\n\tonSwitch = noop,\n\tonHoverClassName = noop,\n\tscope,\n} ) {\n\tconst {\n\t\tonSelect,\n\t\tstylesToRender,\n\t\tactiveStyle,\n\t\tgenericPreviewBlock,\n\t\tclassName: previewClassName,\n\t} = useStylesForBlocks( {\n\t\tclientId,\n\t\tonSwitch,\n\t} );\n\tconst [ hoveredStyle, setHoveredStyle ] = useState( null );\n\tconst [ containerScrollTop, setContainerScrollTop ] = useState( 0 );\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\n\tuseLayoutEffect( () => {\n\t\tconst scrollContainer = document.querySelector(\n\t\t\t'.interface-interface-skeleton__content'\n\t\t);\n\t\tconst scrollTop = scrollContainer?.scrollTop || 0;\n\t\tsetContainerScrollTop( scrollTop + DEFAULT_POSITION_TOP );\n\t}, [ hoveredStyle ] );\n\n\tif ( ! stylesToRender || stylesToRender.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst debouncedSetHoveredStyle = debounce( setHoveredStyle, 250 );\n\n\tconst onSelectStylePreview = ( style ) => {\n\t\tonSelect( style );\n\t\tonHoverClassName( null );\n\t\tsetHoveredStyle( null );\n\t\tdebouncedSetHoveredStyle.cancel();\n\t};\n\n\tconst styleItemHandler = ( item ) => {\n\t\tif ( hoveredStyle === item ) {\n\t\t\tdebouncedSetHoveredStyle.cancel();\n\t\t\treturn;\n\t\t}\n\t\tdebouncedSetHoveredStyle( item );\n\t\tonHoverClassName( item?.name ?? null );\n\t};\n\n\treturn (\n\t\t<div className=\"block-editor-block-styles\">\n\t\t\t<div className=\"block-editor-block-styles__variants\">\n\t\t\t\t{ stylesToRender.map( ( style ) => {\n\t\t\t\t\tconst buttonText = style.label || style.name;\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-block-styles__item',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'is-active':\n\t\t\t\t\t\t\t\t\t\tactiveStyle.name === style.name,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tkey={ style.name }\n\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\tlabel={ buttonText }\n\t\t\t\t\t\t\tonMouseEnter={ () => styleItemHandler( style ) }\n\t\t\t\t\t\t\tonFocus={ () => styleItemHandler( style ) }\n\t\t\t\t\t\t\tonMouseLeave={ () => styleItemHandler( null ) }\n\t\t\t\t\t\t\tonBlur={ () => styleItemHandler( null ) }\n\t\t\t\t\t\t\tonClick={ () => onSelectStylePreview( style ) }\n\t\t\t\t\t\t\taria-current={ activeStyle.name === style.name }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\tas=\"span\"\n\t\t\t\t\t\t\t\tlimit={ 12 }\n\t\t\t\t\t\t\t\tellipsizeMode=\"tail\"\n\t\t\t\t\t\t\t\tclassName=\"block-editor-block-styles__item-text\"\n\t\t\t\t\t\t\t\ttruncate\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ buttonText }\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</div>\n\t\t\t{ hoveredStyle && ! isMobileViewport && (\n\t\t\t\t<BlockStylesPreviewPanelFill\n\t\t\t\t\tscope={ scope }\n\t\t\t\t\tclassName=\"block-editor-block-styles__preview-panel\"\n\t\t\t\t\tstyle={ { top: containerScrollTop } }\n\t\t\t\t\tonMouseLeave={ () => styleItemHandler( null ) }\n\t\t\t\t>\n\t\t\t\t\t<BlockStylesPreviewPanel\n\t\t\t\t\t\tactiveStyle={ activeStyle }\n\t\t\t\t\t\tclassName={ previewClassName }\n\t\t\t\t\t\tgenericPreviewBlock={ genericPreviewBlock }\n\t\t\t\t\t\tstyle={ hoveredStyle }\n\t\t\t\t\t/>\n\t\t\t\t</BlockStylesPreviewPanelFill>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nBlockStyles.Slot = BlockStylesPreviewPanelSlot;\nexport default BlockStyles;\n"]}
|
|
@@ -107,10 +107,15 @@ export const BlockSwitcherDropdownMenu = _ref => {
|
|
|
107
107
|
disabled: true,
|
|
108
108
|
className: "block-editor-block-switcher__no-switcher-icon",
|
|
109
109
|
title: blockTitle,
|
|
110
|
-
icon: createElement(BlockIcon, {
|
|
110
|
+
icon: createElement(Fragment, null, createElement(BlockIcon, {
|
|
111
111
|
icon: icon,
|
|
112
112
|
showColors: true
|
|
113
|
-
})
|
|
113
|
+
}), (isReusable || isTemplate) && createElement("span", {
|
|
114
|
+
className: "block-editor-block-switcher__toggle-text"
|
|
115
|
+
}, createElement(BlockTitle, {
|
|
116
|
+
clientId: clientIds,
|
|
117
|
+
maximumLength: 35
|
|
118
|
+
})))
|
|
114
119
|
}));
|
|
115
120
|
}
|
|
116
121
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-switcher/index.js"],"names":["castArray","uniq","__","_n","sprintf","DropdownMenu","ToolbarButton","ToolbarGroup","ToolbarItem","switchToBlockType","store","blocksStore","isReusableBlock","isTemplatePart","useSelect","useDispatch","copy","blockEditorStore","useBlockDisplayInformation","BlockIcon","BlockTitle","BlockTransformationsMenu","BlockStylesMenu","PatternTransformationsMenu","BlockSwitcherDropdownMenu","clientIds","blocks","replaceBlocks","blockInformation","clientId","possibleBlockTransformations","canRemove","hasBlockStyles","icon","blockTitle","patterns","select","getBlockRootClientId","getBlockTransformItems","__experimentalGetPatternTransformItems","getBlockStyles","getBlockType","canRemoveBlocks","rootClientId","name","firstBlockName","_isSingleBlockSelected","length","styles","_icon","isSelectionOfSameType","map","title","isReusable","isTemplate","onBlockTransform","onPatternTransform","transformedBlocks","hasPossibleBlockTransformations","hasPatternTransformation","blockSwitcherLabel","blockSwitcherDescription","showDropDown","toggleProps","position","isAlternate","className","describedBy","orientation","onClose","BlockSwitcher","getBlocksByClientId","some","block"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,IAApB,QAAgC,QAAhC;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,QAAgC,iBAAhC;AACA,SACCC,YADD,EAECC,aAFD,EAGCC,YAHD,EAICC,WAJD,QAKO,uBALP;AAMA,SACCC,iBADD,EAECC,KAAK,IAAIC,WAFV,EAGCC,eAHD,EAICC,cAJD,QAKO,mBALP;AAMA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,IAAT,QAAqB,kBAArB;AAEA;AACA;AACA;;AACA,SAASN,KAAK,IAAIO,gBAAlB,QAA0C,aAA1C;AACA,OAAOC,0BAAP,MAAuC,kCAAvC;AACA,OAA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AAFZ,MA7BF,CAFA;AAAA,GA/BH,CAFF,CADD,CADD;AA+EA,CAvLM;AAyLP,OAAO,MAAMC,aAAa,GAAG,SAAqB;AAAA,MAAnB;AAAE7C,IAAAA;AAAF,GAAmB;AACjD,QAAMC,MAAM,GAAGZ,SAAS,CACrBsB,MAAF,IACCA,MAAM,CAAEnB,gBAAF,CAAN,CAA2BsD,mBAA3B,CAAgD9C,SAAhD,CAFsB,EAGvB,CAAEA,SAAF,CAHuB,CAAxB;;AAMA,MAAK,CAAEC,MAAM,CAACqB,MAAT,IAAmBrB,MAAM,CAAC8C,IAAP,CAAeC,KAAF,IAAa,CAAEA,KAA5B,CAAxB,EAA8D;AAC7D,WAAO,IAAP;AACA;;AAED,SACC,cAAC,yBAAD;AAA2B,IAAA,SAAS,EAAGhD,SAAvC;AAAmD,IAAA,MAAM,EAAGC;AAA5D,IADD;AAGA,CAdM;AAgBP,eAAe4C,aAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { castArray, uniq } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tDropdownMenu,\n\tToolbarButton,\n\tToolbarGroup,\n\tToolbarItem,\n} from '@wordpress/components';\nimport {\n\tswitchToBlockType,\n\tstore as blocksStore,\n\tisReusableBlock,\n\tisTemplatePart,\n} from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { copy } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport BlockIcon from '../block-icon';\nimport BlockTitle from '../block-title';\nimport BlockTransformationsMenu from './block-transformations-menu';\nimport BlockStylesMenu from './block-styles-menu';\nimport PatternTransformationsMenu from './pattern-transformations-menu';\n\nexport const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => {\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst blockInformation = useBlockDisplayInformation( blocks[ 0 ].clientId );\n\tconst {\n\t\tpossibleBlockTransformations,\n\t\tcanRemove,\n\t\thasBlockStyles,\n\t\ticon,\n\t\tblockTitle,\n\t\tpatterns,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockTransformItems,\n\t\t\t\t__experimentalGetPatternTransformItems,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getBlockStyles, getBlockType } = select( blocksStore );\n\t\t\tconst { canRemoveBlocks } = select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId(\n\t\t\t\tcastArray( clientIds )[ 0 ]\n\t\t\t);\n\t\t\tconst [ { name: firstBlockName } ] = blocks;\n\t\t\tconst _isSingleBlockSelected = blocks.length === 1;\n\t\t\tconst styles =\n\t\t\t\t_isSingleBlockSelected && getBlockStyles( firstBlockName );\n\t\t\tlet _icon;\n\t\t\tif ( _isSingleBlockSelected ) {\n\t\t\t\t_icon = blockInformation?.icon; // Take into account active block variations.\n\t\t\t} else {\n\t\t\t\tconst isSelectionOfSameType =\n\t\t\t\t\tuniq( blocks.map( ( { name } ) => name ) ).length === 1;\n\t\t\t\t// When selection consists of blocks of multiple types, display an\n\t\t\t\t// appropriate icon to communicate the non-uniformity.\n\t\t\t\t_icon = isSelectionOfSameType\n\t\t\t\t\t? getBlockType( firstBlockName )?.icon\n\t\t\t\t\t: copy;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tpossibleBlockTransformations: getBlockTransformItems(\n\t\t\t\t\tblocks,\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t\tcanRemove: canRemoveBlocks( clientIds, rootClientId ),\n\t\t\t\thasBlockStyles: !! styles?.length,\n\t\t\t\ticon: _icon,\n\t\t\t\tblockTitle: getBlockType( firstBlockName )?.title,\n\t\t\t\tpatterns: __experimentalGetPatternTransformItems(\n\t\t\t\t\tblocks,\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ clientIds, blocks, blockInformation?.icon ]\n\t);\n\n\tconst isReusable = blocks.length === 1 && isReusableBlock( blocks[ 0 ] );\n\tconst isTemplate = blocks.length === 1 && isTemplatePart( blocks[ 0 ] );\n\n\t// Simple block tranformation based on the `Block Transforms` API.\n\tconst onBlockTransform = ( name ) =>\n\t\treplaceBlocks( clientIds, switchToBlockType( blocks, name ) );\n\t// Pattern transformation through the `Patterns` API.\n\tconst onPatternTransform = ( transformedBlocks ) =>\n\t\treplaceBlocks( clientIds, transformedBlocks );\n\tconst hasPossibleBlockTransformations =\n\t\t!! possibleBlockTransformations.length && canRemove;\n\tconst hasPatternTransformation = !! patterns?.length && canRemove;\n\tif ( ! hasBlockStyles && ! hasPossibleBlockTransformations ) {\n\t\treturn (\n\t\t\t<ToolbarGroup>\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tdisabled\n\t\t\t\t\tclassName=\"block-editor-block-switcher__no-switcher-icon\"\n\t\t\t\t\ttitle={ blockTitle }\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } showColors /> }\n\t\t\t\t/>\n\t\t\t</ToolbarGroup>\n\t\t);\n\t}\n\n\tconst blockSwitcherLabel = blockTitle;\n\n\tconst blockSwitcherDescription =\n\t\t1 === blocks.length\n\t\t\t? sprintf(\n\t\t\t\t\t/* translators: %s: block title. */\n\t\t\t\t\t__( '%s: Change block type or style' ),\n\t\t\t\t\tblockTitle\n\t\t\t )\n\t\t\t: sprintf(\n\t\t\t\t\t/* translators: %d: number of blocks. */\n\t\t\t\t\t_n(\n\t\t\t\t\t\t'Change type of %d block',\n\t\t\t\t\t\t'Change type of %d blocks',\n\t\t\t\t\t\tblocks.length\n\t\t\t\t\t),\n\t\t\t\t\tblocks.length\n\t\t\t );\n\n\tconst showDropDown =\n\t\thasBlockStyles ||\n\t\thasPossibleBlockTransformations ||\n\t\thasPatternTransformation;\n\treturn (\n\t\t<ToolbarGroup>\n\t\t\t<ToolbarItem>\n\t\t\t\t{ ( toggleProps ) => (\n\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\tclassName=\"block-editor-block-switcher\"\n\t\t\t\t\t\tlabel={ blockSwitcherLabel }\n\t\t\t\t\t\tpopoverProps={ {\n\t\t\t\t\t\t\tposition: 'bottom right',\n\t\t\t\t\t\t\tisAlternate: true,\n\t\t\t\t\t\t\tclassName: 'block-editor-block-switcher__popover',\n\t\t\t\t\t\t} }\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<BlockIcon\n\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-switcher__toggle\"\n\t\t\t\t\t\t\t\t\tshowColors\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{ ( isReusable || isTemplate ) && (\n\t\t\t\t\t\t\t\t\t<span className=\"block-editor-block-switcher__toggle-text\">\n\t\t\t\t\t\t\t\t\t\t<BlockTitle\n\t\t\t\t\t\t\t\t\t\t\tclientId={ clientIds }\n\t\t\t\t\t\t\t\t\t\t\tmaximumLength={ 35 }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\tdescribedBy: blockSwitcherDescription,\n\t\t\t\t\t\t\t...toggleProps,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tmenuProps={ { orientation: 'both' } }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ( { onClose } ) =>\n\t\t\t\t\t\t\tshowDropDown && (\n\t\t\t\t\t\t\t\t<div className=\"block-editor-block-switcher__container\">\n\t\t\t\t\t\t\t\t\t{ hasPatternTransformation && (\n\t\t\t\t\t\t\t\t\t\t<PatternTransformationsMenu\n\t\t\t\t\t\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\t\t\t\t\t\tpatterns={ patterns }\n\t\t\t\t\t\t\t\t\t\t\tonSelect={ (\n\t\t\t\t\t\t\t\t\t\t\t\ttransformedBlocks\n\t\t\t\t\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\t\t\t\t\tonPatternTransform(\n\t\t\t\t\t\t\t\t\t\t\t\t\ttransformedBlocks\n\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ hasPossibleBlockTransformations && (\n\t\t\t\t\t\t\t\t\t\t<BlockTransformationsMenu\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-switcher__transforms__menugroup\"\n\t\t\t\t\t\t\t\t\t\t\tpossibleBlockTransformations={\n\t\t\t\t\t\t\t\t\t\t\t\tpossibleBlockTransformations\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\t\t\t\t\t\tonSelect={ ( name ) => {\n\t\t\t\t\t\t\t\t\t\t\t\tonBlockTransform( name );\n\t\t\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ hasBlockStyles && (\n\t\t\t\t\t\t\t\t\t\t<BlockStylesMenu\n\t\t\t\t\t\t\t\t\t\t\thoveredBlock={ blocks[ 0 ] }\n\t\t\t\t\t\t\t\t\t\t\tonSwitch={ onClose }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t</DropdownMenu>\n\t\t\t\t) }\n\t\t\t</ToolbarItem>\n\t\t</ToolbarGroup>\n\t);\n};\n\nexport const BlockSwitcher = ( { clientIds } ) => {\n\tconst blocks = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getBlocksByClientId( clientIds ),\n\t\t[ clientIds ]\n\t);\n\n\tif ( ! blocks.length || blocks.some( ( block ) => ! block ) ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockSwitcherDropdownMenu clientIds={ clientIds } blocks={ blocks } />\n\t);\n};\n\nexport default BlockSwitcher;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-switcher/index.js"],"names":["castArray","uniq","__","_n","sprintf","DropdownMenu","ToolbarButton","ToolbarGroup","ToolbarItem","switchToBlockType","store","blocksStore","isReusableBlock","isTemplatePart","useSelect","useDispatch","copy","blockEditorStore","useBlockDisplayInformation","BlockIcon","BlockTitle","BlockTransformationsMenu","BlockStylesMenu","PatternTransformationsMenu","BlockSwitcherDropdownMenu","clientIds","blocks","replaceBlocks","blockInformation","clientId","possibleBlockTransformations","canRemove","hasBlockStyles","icon","blockTitle","patterns","select","getBlockRootClientId","getBlockTransformItems","__experimentalGetPatternTransformItems","getBlockStyles","getBlockType","canRemoveBlocks","rootClientId","name","firstBlockName","_isSingleBlockSelected","length","styles","_icon","isSelectionOfSameType","map","title","isReusable","isTemplate","onBlockTransform","onPatternTransform","transformedBlocks","hasPossibleBlockTransformations","hasPatternTransformation","blockSwitcherLabel","blockSwitcherDescription","showDropDown","toggleProps","position","isAlternate","className","describedBy","orientation","onClose","BlockSwitcher","getBlocksByClientId","some","block"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,IAApB,QAAgC,QAAhC;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,QAAgC,iBAAhC;AACA,SACCC,YADD,EAECC,aAFD,EAGCC,YAHD,EAICC,WAJD,QAKO,uBALP;AAMA,SACCC,iBADD,EAECC,KAAK,IAAIC,WAFV,EAGCC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AAAA,OAAO;AACP;AAVF,MAFF,EAeGX,+BAA+B,IAChC,cAAC,wBAAD;AACC,MAAA,SAAS,EAAC,oDADX;AAEC,MAAA,4BAA4B,EAC3B5B,4BAHF;AAKC,MAAA,MAAM,EAAGJ,MALV;AAMC,MAAA,QAAQ,EAAKkB,IAAF,IAAY;AACtBW,QAAAA,gBAAgB,CAAEX,IAAF,CAAhB;AACAyB,QAAAA,OAAO;AACP;AATF,MAhBF,EA4BGrC,cAAc,IACf,cAAC,eAAD;AACC,MAAA,YAAY,EAAGN,MAAM,CAAE,CAAF,CADtB;AAEC,MAAA,QAAQ,EAAG2C;AAFZ,MA7BF,CAFA;AAAA,GA/BH,CAFF,CADD,CADD;AA+EA,CAnMM;AAqMP,OAAO,MAAMC,aAAa,GAAG,SAAqB;AAAA,MAAnB;AAAE7C,IAAAA;AAAF,GAAmB;AACjD,QAAMC,MAAM,GAAGZ,SAAS,CACrBsB,MAAF,IACCA,MAAM,CAAEnB,gBAAF,CAAN,CAA2BsD,mBAA3B,CAAgD9C,SAAhD,CAFsB,EAGvB,CAAEA,SAAF,CAHuB,CAAxB;;AAMA,MAAK,CAAEC,MAAM,CAACqB,MAAT,IAAmBrB,MAAM,CAAC8C,IAAP,CAAeC,KAAF,IAAa,CAAEA,KAA5B,CAAxB,EAA8D;AAC7D,WAAO,IAAP;AACA;;AAED,SACC,cAAC,yBAAD;AAA2B,IAAA,SAAS,EAAGhD,SAAvC;AAAmD,IAAA,MAAM,EAAGC;AAA5D,IADD;AAGA,CAdM;AAgBP,eAAe4C,aAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { castArray, uniq } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tDropdownMenu,\n\tToolbarButton,\n\tToolbarGroup,\n\tToolbarItem,\n} from '@wordpress/components';\nimport {\n\tswitchToBlockType,\n\tstore as blocksStore,\n\tisReusableBlock,\n\tisTemplatePart,\n} from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { copy } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport BlockIcon from '../block-icon';\nimport BlockTitle from '../block-title';\nimport BlockTransformationsMenu from './block-transformations-menu';\nimport BlockStylesMenu from './block-styles-menu';\nimport PatternTransformationsMenu from './pattern-transformations-menu';\n\nexport const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => {\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst blockInformation = useBlockDisplayInformation( blocks[ 0 ].clientId );\n\tconst {\n\t\tpossibleBlockTransformations,\n\t\tcanRemove,\n\t\thasBlockStyles,\n\t\ticon,\n\t\tblockTitle,\n\t\tpatterns,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockTransformItems,\n\t\t\t\t__experimentalGetPatternTransformItems,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getBlockStyles, getBlockType } = select( blocksStore );\n\t\t\tconst { canRemoveBlocks } = select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId(\n\t\t\t\tcastArray( clientIds )[ 0 ]\n\t\t\t);\n\t\t\tconst [ { name: firstBlockName } ] = blocks;\n\t\t\tconst _isSingleBlockSelected = blocks.length === 1;\n\t\t\tconst styles =\n\t\t\t\t_isSingleBlockSelected && getBlockStyles( firstBlockName );\n\t\t\tlet _icon;\n\t\t\tif ( _isSingleBlockSelected ) {\n\t\t\t\t_icon = blockInformation?.icon; // Take into account active block variations.\n\t\t\t} else {\n\t\t\t\tconst isSelectionOfSameType =\n\t\t\t\t\tuniq( blocks.map( ( { name } ) => name ) ).length === 1;\n\t\t\t\t// When selection consists of blocks of multiple types, display an\n\t\t\t\t// appropriate icon to communicate the non-uniformity.\n\t\t\t\t_icon = isSelectionOfSameType\n\t\t\t\t\t? getBlockType( firstBlockName )?.icon\n\t\t\t\t\t: copy;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tpossibleBlockTransformations: getBlockTransformItems(\n\t\t\t\t\tblocks,\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t\tcanRemove: canRemoveBlocks( clientIds, rootClientId ),\n\t\t\t\thasBlockStyles: !! styles?.length,\n\t\t\t\ticon: _icon,\n\t\t\t\tblockTitle: getBlockType( firstBlockName )?.title,\n\t\t\t\tpatterns: __experimentalGetPatternTransformItems(\n\t\t\t\t\tblocks,\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ clientIds, blocks, blockInformation?.icon ]\n\t);\n\n\tconst isReusable = blocks.length === 1 && isReusableBlock( blocks[ 0 ] );\n\tconst isTemplate = blocks.length === 1 && isTemplatePart( blocks[ 0 ] );\n\n\t// Simple block tranformation based on the `Block Transforms` API.\n\tconst onBlockTransform = ( name ) =>\n\t\treplaceBlocks( clientIds, switchToBlockType( blocks, name ) );\n\t// Pattern transformation through the `Patterns` API.\n\tconst onPatternTransform = ( transformedBlocks ) =>\n\t\treplaceBlocks( clientIds, transformedBlocks );\n\tconst hasPossibleBlockTransformations =\n\t\t!! possibleBlockTransformations.length && canRemove;\n\tconst hasPatternTransformation = !! patterns?.length && canRemove;\n\tif ( ! hasBlockStyles && ! hasPossibleBlockTransformations ) {\n\t\treturn (\n\t\t\t<ToolbarGroup>\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tdisabled\n\t\t\t\t\tclassName=\"block-editor-block-switcher__no-switcher-icon\"\n\t\t\t\t\ttitle={ blockTitle }\n\t\t\t\t\ticon={\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<BlockIcon icon={ icon } showColors />\n\t\t\t\t\t\t\t{ ( isReusable || isTemplate ) && (\n\t\t\t\t\t\t\t\t<span className=\"block-editor-block-switcher__toggle-text\">\n\t\t\t\t\t\t\t\t\t<BlockTitle\n\t\t\t\t\t\t\t\t\t\tclientId={ clientIds }\n\t\t\t\t\t\t\t\t\t\tmaximumLength={ 35 }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</>\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</ToolbarGroup>\n\t\t);\n\t}\n\n\tconst blockSwitcherLabel = blockTitle;\n\n\tconst blockSwitcherDescription =\n\t\t1 === blocks.length\n\t\t\t? sprintf(\n\t\t\t\t\t/* translators: %s: block title. */\n\t\t\t\t\t__( '%s: Change block type or style' ),\n\t\t\t\t\tblockTitle\n\t\t\t )\n\t\t\t: sprintf(\n\t\t\t\t\t/* translators: %d: number of blocks. */\n\t\t\t\t\t_n(\n\t\t\t\t\t\t'Change type of %d block',\n\t\t\t\t\t\t'Change type of %d blocks',\n\t\t\t\t\t\tblocks.length\n\t\t\t\t\t),\n\t\t\t\t\tblocks.length\n\t\t\t );\n\n\tconst showDropDown =\n\t\thasBlockStyles ||\n\t\thasPossibleBlockTransformations ||\n\t\thasPatternTransformation;\n\treturn (\n\t\t<ToolbarGroup>\n\t\t\t<ToolbarItem>\n\t\t\t\t{ ( toggleProps ) => (\n\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\tclassName=\"block-editor-block-switcher\"\n\t\t\t\t\t\tlabel={ blockSwitcherLabel }\n\t\t\t\t\t\tpopoverProps={ {\n\t\t\t\t\t\t\tposition: 'bottom right',\n\t\t\t\t\t\t\tisAlternate: true,\n\t\t\t\t\t\t\tclassName: 'block-editor-block-switcher__popover',\n\t\t\t\t\t\t} }\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<BlockIcon\n\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-switcher__toggle\"\n\t\t\t\t\t\t\t\t\tshowColors\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{ ( isReusable || isTemplate ) && (\n\t\t\t\t\t\t\t\t\t<span className=\"block-editor-block-switcher__toggle-text\">\n\t\t\t\t\t\t\t\t\t\t<BlockTitle\n\t\t\t\t\t\t\t\t\t\t\tclientId={ clientIds }\n\t\t\t\t\t\t\t\t\t\t\tmaximumLength={ 35 }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\tdescribedBy: blockSwitcherDescription,\n\t\t\t\t\t\t\t...toggleProps,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tmenuProps={ { orientation: 'both' } }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ( { onClose } ) =>\n\t\t\t\t\t\t\tshowDropDown && (\n\t\t\t\t\t\t\t\t<div className=\"block-editor-block-switcher__container\">\n\t\t\t\t\t\t\t\t\t{ hasPatternTransformation && (\n\t\t\t\t\t\t\t\t\t\t<PatternTransformationsMenu\n\t\t\t\t\t\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\t\t\t\t\t\tpatterns={ patterns }\n\t\t\t\t\t\t\t\t\t\t\tonSelect={ (\n\t\t\t\t\t\t\t\t\t\t\t\ttransformedBlocks\n\t\t\t\t\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\t\t\t\t\tonPatternTransform(\n\t\t\t\t\t\t\t\t\t\t\t\t\ttransformedBlocks\n\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ hasPossibleBlockTransformations && (\n\t\t\t\t\t\t\t\t\t\t<BlockTransformationsMenu\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-switcher__transforms__menugroup\"\n\t\t\t\t\t\t\t\t\t\t\tpossibleBlockTransformations={\n\t\t\t\t\t\t\t\t\t\t\t\tpossibleBlockTransformations\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\t\t\t\t\t\tonSelect={ ( name ) => {\n\t\t\t\t\t\t\t\t\t\t\t\tonBlockTransform( name );\n\t\t\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ hasBlockStyles && (\n\t\t\t\t\t\t\t\t\t\t<BlockStylesMenu\n\t\t\t\t\t\t\t\t\t\t\thoveredBlock={ blocks[ 0 ] }\n\t\t\t\t\t\t\t\t\t\t\tonSwitch={ onClose }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t</DropdownMenu>\n\t\t\t\t) }\n\t\t\t</ToolbarItem>\n\t\t</ToolbarGroup>\n\t);\n};\n\nexport const BlockSwitcher = ( { clientIds } ) => {\n\tconst blocks = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getBlocksByClientId( clientIds ),\n\t\t[ clientIds ]\n\t);\n\n\tif ( ! blocks.length || blocks.some( ( block ) => ! block ) ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockSwitcherDropdownMenu clientIds={ clientIds } blocks={ blocks } />\n\t);\n};\n\nexport default BlockSwitcher;\n"]}
|
|
@@ -11,7 +11,7 @@ import deprecated from '@wordpress/deprecated';
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import InsertionPoint, { InsertionPointOpenRef } from './insertion-point';
|
|
14
|
-
import BlockPopover from './block-popover';
|
|
14
|
+
import BlockPopover from './selected-block-popover';
|
|
15
15
|
export default function BlockToolsBackCompat(_ref) {
|
|
16
16
|
let {
|
|
17
17
|
children
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/back-compat.js"],"names":["useContext","Disabled","deprecated","InsertionPoint","InsertionPointOpenRef","BlockPopover","BlockToolsBackCompat","children","openRef","isDisabled","Context","alternative","since"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,UAAT,QAA2B,oBAA3B;AACA,SAASC,QAAT,QAAyB,uBAAzB;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,IAAyBC,qBAAzB,QAAsD,mBAAtD;AACA,OAAOC,YAAP,MAAyB,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/back-compat.js"],"names":["useContext","Disabled","deprecated","InsertionPoint","InsertionPointOpenRef","BlockPopover","BlockToolsBackCompat","children","openRef","isDisabled","Context","alternative","since"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,UAAT,QAA2B,oBAA3B;AACA,SAASC,QAAT,QAAyB,uBAAzB;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,IAAyBC,qBAAzB,QAAsD,mBAAtD;AACA,OAAOC,YAAP,MAAyB,0BAAzB;AAEA,eAAe,SAASC,oBAAT,OAA8C;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AAC5D,QAAMC,OAAO,GAAGR,UAAU,CAAEI,qBAAF,CAA1B;AACA,QAAMK,UAAU,GAAGT,UAAU,CAAEC,QAAQ,CAACS,OAAX,CAA7B,CAF4D,CAI5D;;AACA,MAAKF,OAAO,IAAIC,UAAhB,EAA6B;AAC5B,WAAOF,QAAP;AACA;;AAEDL,EAAAA,UAAU,CAAE,iDAAF,EAAqD;AAC9DS,IAAAA,WAAW,EAAE,2BADiD;AAE9DC,IAAAA,KAAK,EAAE;AAFuD,GAArD,CAAV;AAKA,SACC,cAAC,cAAD;AAAgB,IAAA,qBAAqB,EAAC;AAAtC,KACC,cAAC,YAAD;AAAc,IAAA,qBAAqB,EAAC;AAApC,IADD,EAEGL,QAFH,CADD;AAMA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\nimport { Disabled } from '@wordpress/components';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport InsertionPoint, { InsertionPointOpenRef } from './insertion-point';\nimport BlockPopover from './selected-block-popover';\n\nexport default function BlockToolsBackCompat( { children } ) {\n\tconst openRef = useContext( InsertionPointOpenRef );\n\tconst isDisabled = useContext( Disabled.Context );\n\n\t// If context is set, `BlockTools` is a parent component.\n\tif ( openRef || isDisabled ) {\n\t\treturn children;\n\t}\n\n\tdeprecated( 'wp.components.Popover.Slot name=\"block-toolbar\"', {\n\t\talternative: 'wp.blockEditor.BlockTools',\n\t\tsince: '5.8',\n\t} );\n\n\treturn (\n\t\t<InsertionPoint __unstablePopoverSlot=\"block-toolbar\">\n\t\t\t<BlockPopover __unstablePopoverSlot=\"block-toolbar\" />\n\t\t\t{ children }\n\t\t</InsertionPoint>\n\t);\n}\n"]}
|