@wordpress/block-editor 12.6.0 → 12.7.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/README.md +2 -2
- package/build/autocompleters/block.js +6 -2
- package/build/autocompleters/block.js.map +1 -1
- package/build/components/block-editing-mode/index.js +1 -1
- package/build/components/block-editing-mode/index.js.map +1 -1
- package/build/components/block-list/block.js +4 -2
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/index.js +2 -4
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-parent-selector/index.js +6 -21
- package/build/components/block-parent-selector/index.js.map +1 -1
- package/build/components/block-preview/auto.js +6 -1
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +3 -17
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-toolbar/index.js +4 -34
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-toolbar/utils.js +56 -51
- package/build/components/block-toolbar/utils.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +4 -2
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/block-variation-picker/index.native.js +10 -20
- package/build/components/block-variation-picker/index.native.js.map +1 -1
- package/build/components/editor-styles/index.js +2 -2
- package/build/components/editor-styles/index.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +11 -11
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/global-styles/behaviors-panel.js +66 -0
- package/build/components/global-styles/behaviors-panel.js.map +1 -0
- package/build/components/global-styles/hooks.js +118 -4
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +20 -0
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-utils.js +4 -4
- package/build/components/global-styles/typography-utils.js.map +1 -1
- package/build/components/global-styles/utils.js +1 -1
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/inserter/hooks/use-block-types-state.js +6 -2
- package/build/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build/components/inserter/hooks/use-debounced-input.js +5 -7
- package/build/components/inserter/hooks/use-debounced-input.js.map +1 -1
- package/build/components/inserter/hooks/use-patterns-state.js +3 -2
- package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.js +3 -2
- package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build/components/inserter-list-item/index.js +1 -1
- package/build/components/inserter-list-item/index.js.map +1 -1
- package/build/components/link-control/index.js +47 -6
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/link-preview.js +3 -3
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js +6 -1
- package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build/components/media-replace-flow/index.native.js +15 -3
- package/build/components/media-replace-flow/index.native.js.map +1 -1
- package/build/components/rich-text/format-edit.js +57 -28
- package/build/components/rich-text/format-edit.js.map +1 -1
- package/build/components/rich-text/get-rich-text-values.js +11 -18
- package/build/components/rich-text/get-rich-text-values.js.map +1 -1
- package/build/components/spacing-sizes-control/utils.js +2 -2
- package/build/components/spacing-sizes-control/utils.js.map +1 -1
- package/build/hooks/behaviors.js +5 -12
- package/build/hooks/behaviors.js.map +1 -1
- package/build/hooks/border.js +2 -1
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/style.js +11 -2
- package/build/hooks/style.js.map +1 -1
- package/build/private-apis.js +4 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +2 -3
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +4 -71
- package/build/store/selectors.js.map +1 -1
- package/build-module/autocompleters/block.js +7 -3
- package/build-module/autocompleters/block.js.map +1 -1
- package/build-module/components/block-editing-mode/index.js +1 -1
- package/build-module/components/block-editing-mode/index.js.map +1 -1
- package/build-module/components/block-list/block.js +4 -2
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/index.js +2 -3
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-parent-selector/index.js +7 -22
- package/build-module/components/block-parent-selector/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +6 -1
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +4 -18
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +6 -36
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-toolbar/utils.js +54 -49
- package/build-module/components/block-toolbar/utils.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +4 -2
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/block-variation-picker/index.native.js +13 -23
- package/build-module/components/block-variation-picker/index.native.js.map +1 -1
- package/build-module/components/editor-styles/index.js +2 -2
- package/build-module/components/editor-styles/index.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +11 -11
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/global-styles/behaviors-panel.js +57 -0
- package/build-module/components/global-styles/behaviors-panel.js.map +1 -0
- package/build-module/components/global-styles/hooks.js +115 -5
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +2 -1
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/typography-utils.js +4 -4
- package/build-module/components/global-styles/typography-utils.js.map +1 -1
- package/build-module/components/global-styles/utils.js +1 -1
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/inserter/hooks/use-block-types-state.js +7 -3
- package/build-module/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build-module/components/inserter/hooks/use-debounced-input.js +5 -7
- package/build-module/components/inserter/hooks/use-debounced-input.js.map +1 -1
- package/build-module/components/inserter/hooks/use-patterns-state.js +3 -2
- package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.js +3 -2
- package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build-module/components/inserter-list-item/index.js +1 -1
- package/build-module/components/inserter-list-item/index.js.map +1 -1
- package/build-module/components/link-control/index.js +45 -6
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +3 -3
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js +6 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/media-replace-flow/index.native.js +15 -3
- package/build-module/components/media-replace-flow/index.native.js.map +1 -1
- package/build-module/components/rich-text/format-edit.js +51 -26
- package/build-module/components/rich-text/format-edit.js.map +1 -1
- package/build-module/components/rich-text/get-rich-text-values.js +13 -18
- package/build-module/components/rich-text/get-rich-text-values.js.map +1 -1
- package/build-module/components/spacing-sizes-control/utils.js +2 -2
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
- package/build-module/hooks/behaviors.js +5 -12
- package/build-module/hooks/behaviors.js.map +1 -1
- package/build-module/hooks/border.js +2 -1
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/style.js +11 -2
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/private-apis.js +3 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +2 -3
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +4 -69
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +18 -5
- package/build-style/style.css +18 -5
- package/package.json +31 -31
- package/src/autocompleters/block.js +21 -6
- package/src/components/block-draggable/test/index.native.js +2 -3
- package/src/components/block-editing-mode/index.js +1 -1
- package/src/components/block-list/block.js +6 -1
- package/src/components/block-list/index.js +3 -6
- package/src/components/block-list/test/block-invalid-warning.native.js +8 -1
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +24 -0
- package/src/components/block-parent-selector/index.js +30 -42
- package/src/components/block-preview/auto.js +8 -1
- package/src/components/block-preview/style.scss +2 -1
- package/src/components/block-settings-menu/block-settings-dropdown.js +4 -13
- package/src/components/block-toolbar/index.js +36 -63
- package/src/components/block-toolbar/utils.js +57 -45
- package/src/components/block-tools/block-contextual-toolbar.js +43 -35
- package/src/components/block-tools/style.scss +17 -5
- package/src/components/block-variation-picker/index.native.js +52 -72
- package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
- package/src/components/editor-styles/index.js +2 -2
- package/src/components/font-sizes/fluid-utils.js +17 -17
- package/src/components/font-sizes/test/fluid-utils.js +6 -6
- package/src/components/global-styles/behaviors-panel.js +71 -0
- package/src/components/global-styles/hooks.js +114 -5
- package/src/components/global-styles/index.js +3 -0
- package/src/components/global-styles/test/typography-utils.js +6 -6
- package/src/components/global-styles/typography-utils.js +4 -4
- package/src/components/global-styles/utils.js +2 -1
- package/src/components/inserter/hooks/use-block-types-state.js +15 -6
- package/src/components/inserter/hooks/use-debounced-input.js +8 -7
- package/src/components/inserter/hooks/use-patterns-state.js +2 -1
- package/src/components/inserter/reusable-blocks-tab.js +4 -1
- package/src/components/inserter-list-item/index.js +3 -1
- package/src/components/link-control/README.md +12 -3
- package/src/components/link-control/index.js +43 -6
- package/src/components/link-control/link-preview.js +6 -4
- package/src/components/link-control/style.scss +3 -2
- package/src/components/link-control/test/index.js +2 -1
- package/src/components/list-view/use-list-view-drop-zone.js +5 -1
- package/src/components/media-replace-flow/index.native.js +12 -3
- package/src/components/media-upload/test/index.native.js +1 -0
- package/src/components/rich-text/format-edit.js +62 -38
- package/src/components/rich-text/get-rich-text-values.js +22 -28
- package/src/components/spacing-sizes-control/test/utils.js +9 -1
- package/src/components/spacing-sizes-control/utils.js +2 -2
- package/src/hooks/behaviors.js +10 -16
- package/src/hooks/border.js +2 -1
- package/src/hooks/style.js +7 -3
- package/src/private-apis.js +2 -0
- package/src/store/actions.js +22 -28
- package/src/store/selectors.js +3 -80
- package/src/store/test/selectors.js +7 -6
|
@@ -6,7 +6,7 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { useSelect
|
|
9
|
+
import { useSelect } from '@wordpress/data';
|
|
10
10
|
import { useRef } from '@wordpress/element';
|
|
11
11
|
import { useViewportMatch } from '@wordpress/compose';
|
|
12
12
|
import {
|
|
@@ -29,76 +29,52 @@ import BlockSettingsMenu from '../block-settings-menu';
|
|
|
29
29
|
import { BlockLockToolbar } from '../block-lock';
|
|
30
30
|
import { BlockGroupToolbar } from '../convert-to-group-buttons';
|
|
31
31
|
import BlockEditVisuallyButton from '../block-edit-visually-button';
|
|
32
|
-
import {
|
|
32
|
+
import { useShowHoveredOrFocusedGestures } from './utils';
|
|
33
33
|
import { store as blockEditorStore } from '../../store';
|
|
34
34
|
import __unstableBlockNameContext from './block-name-context';
|
|
35
35
|
import { unlock } from '../../lock-unlock';
|
|
36
36
|
|
|
37
37
|
const BlockToolbar = ( { hideDragHandle } ) => {
|
|
38
|
-
const {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
selectedBlockClientId
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
isDistractionFree: settings.isDistractionFree,
|
|
69
|
-
rootClientId: blockRootClientId,
|
|
70
|
-
isValid: selectedBlockClientIds.every( ( id ) =>
|
|
71
|
-
isBlockValid( id )
|
|
72
|
-
),
|
|
73
|
-
isVisual: selectedBlockClientIds.every(
|
|
74
|
-
( id ) => getBlockMode( id ) === 'visual'
|
|
75
|
-
),
|
|
76
|
-
blockEditingMode: getBlockEditingMode( selectedBlockClientId ),
|
|
77
|
-
};
|
|
78
|
-
}, [] );
|
|
38
|
+
const { blockClientIds, blockType, isValid, isVisual, blockEditingMode } =
|
|
39
|
+
useSelect( ( select ) => {
|
|
40
|
+
const {
|
|
41
|
+
getBlockName,
|
|
42
|
+
getBlockMode,
|
|
43
|
+
getSelectedBlockClientIds,
|
|
44
|
+
isBlockValid,
|
|
45
|
+
getBlockRootClientId,
|
|
46
|
+
getBlockEditingMode,
|
|
47
|
+
} = unlock( select( blockEditorStore ) );
|
|
48
|
+
const selectedBlockClientIds = getSelectedBlockClientIds();
|
|
49
|
+
const selectedBlockClientId = selectedBlockClientIds[ 0 ];
|
|
50
|
+
const blockRootClientId = getBlockRootClientId(
|
|
51
|
+
selectedBlockClientId
|
|
52
|
+
);
|
|
53
|
+
return {
|
|
54
|
+
blockClientIds: selectedBlockClientIds,
|
|
55
|
+
blockType:
|
|
56
|
+
selectedBlockClientId &&
|
|
57
|
+
getBlockType( getBlockName( selectedBlockClientId ) ),
|
|
58
|
+
rootClientId: blockRootClientId,
|
|
59
|
+
isValid: selectedBlockClientIds.every( ( id ) =>
|
|
60
|
+
isBlockValid( id )
|
|
61
|
+
),
|
|
62
|
+
isVisual: selectedBlockClientIds.every(
|
|
63
|
+
( id ) => getBlockMode( id ) === 'visual'
|
|
64
|
+
),
|
|
65
|
+
blockEditingMode: getBlockEditingMode( selectedBlockClientId ),
|
|
66
|
+
};
|
|
67
|
+
}, [] );
|
|
79
68
|
|
|
80
69
|
const toolbarWrapperRef = useRef( null );
|
|
81
70
|
|
|
82
71
|
// Handles highlighting the current block outline on hover or focus of the
|
|
83
72
|
// block type toolbar area.
|
|
84
|
-
const { toggleBlockHighlight } = useDispatch( blockEditorStore );
|
|
85
73
|
const nodeRef = useRef();
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
onChange( isFocused ) {
|
|
90
|
-
if ( isFocused && isDistractionFree ) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
toggleBlockHighlight( getSelectedBlockClientId(), isFocused );
|
|
94
|
-
},
|
|
95
|
-
}
|
|
96
|
-
);
|
|
74
|
+
const showHoveredOrFocusedGestures = useShowHoveredOrFocusedGestures( {
|
|
75
|
+
ref: nodeRef,
|
|
76
|
+
} );
|
|
97
77
|
|
|
98
|
-
// Account for the cases where the block toolbar is rendered within the
|
|
99
|
-
// header area and not contextually to the block.
|
|
100
|
-
const displayHeaderToolbar =
|
|
101
|
-
useViewportMatch( 'medium', '<' ) || hasFixedToolbar;
|
|
102
78
|
const isLargeViewport = ! useViewportMatch( 'medium', '<' );
|
|
103
79
|
|
|
104
80
|
if ( blockType ) {
|
|
@@ -107,8 +83,6 @@ const BlockToolbar = ( { hideDragHandle } ) => {
|
|
|
107
83
|
}
|
|
108
84
|
}
|
|
109
85
|
|
|
110
|
-
const shouldShowMovers = displayHeaderToolbar || showMovers;
|
|
111
|
-
|
|
112
86
|
if ( blockClientIds.length === 0 ) {
|
|
113
87
|
return null;
|
|
114
88
|
}
|
|
@@ -119,7 +93,6 @@ const BlockToolbar = ( { hideDragHandle } ) => {
|
|
|
119
93
|
isReusableBlock( blockType ) || isTemplatePart( blockType );
|
|
120
94
|
|
|
121
95
|
const classes = classnames( 'block-editor-block-toolbar', {
|
|
122
|
-
'is-showing-movers': shouldShowMovers,
|
|
123
96
|
'is-synced': isSynced,
|
|
124
97
|
} );
|
|
125
98
|
|
|
@@ -130,7 +103,7 @@ const BlockToolbar = ( { hideDragHandle } ) => {
|
|
|
130
103
|
blockEditingMode === 'default' && <BlockParentSelector /> }
|
|
131
104
|
{ ( shouldShowVisualToolbar || isMultiToolbar ) &&
|
|
132
105
|
blockEditingMode === 'default' && (
|
|
133
|
-
<div ref={ nodeRef } { ...
|
|
106
|
+
<div ref={ nodeRef } { ...showHoveredOrFocusedGestures }>
|
|
134
107
|
<ToolbarGroup className="block-editor-block-toolbar__block-controls">
|
|
135
108
|
<BlockSwitcher clientIds={ blockClientIds } />
|
|
136
109
|
{ ! isMultiToolbar && (
|
|
@@ -1,43 +1,57 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
4
5
|
import { useState, useRef, useEffect } from '@wordpress/element';
|
|
5
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { store as blockEditorStore } from '../../store';
|
|
11
|
+
|
|
6
12
|
const { clearTimeout, setTimeout } = window;
|
|
7
|
-
const noop = () => {};
|
|
8
13
|
const DEBOUNCE_TIMEOUT = 200;
|
|
9
14
|
|
|
10
15
|
/**
|
|
11
|
-
* Hook that creates
|
|
16
|
+
* Hook that creates debounced callbacks when the node is hovered or focused.
|
|
12
17
|
*
|
|
13
|
-
* @param {Object}
|
|
14
|
-
* @param {Object}
|
|
15
|
-
* @param {boolean}
|
|
16
|
-
* @param {number}
|
|
17
|
-
* @param {
|
|
18
|
+
* @param {Object} props Component props.
|
|
19
|
+
* @param {Object} props.ref Element reference.
|
|
20
|
+
* @param {boolean} props.isFocused Whether the component has current focus.
|
|
21
|
+
* @param {number} props.highlightParent Whether to highlight the parent block. It defaults in highlighting the selected block.
|
|
22
|
+
* @param {number} [props.debounceTimeout=250] Debounce timeout in milliseconds.
|
|
18
23
|
*/
|
|
19
|
-
|
|
24
|
+
function useDebouncedShowGestures( {
|
|
20
25
|
ref,
|
|
21
26
|
isFocused,
|
|
27
|
+
highlightParent,
|
|
22
28
|
debounceTimeout = DEBOUNCE_TIMEOUT,
|
|
23
|
-
onChange = noop,
|
|
24
29
|
} ) {
|
|
25
|
-
const
|
|
30
|
+
const { getSelectedBlockClientId, getBlockRootClientId } =
|
|
31
|
+
useSelect( blockEditorStore );
|
|
32
|
+
const { toggleBlockHighlight } = useDispatch( blockEditorStore );
|
|
26
33
|
const timeoutRef = useRef();
|
|
27
|
-
|
|
34
|
+
const isDistractionFree = useSelect(
|
|
35
|
+
( select ) =>
|
|
36
|
+
select( blockEditorStore ).getSettings().isDistractionFree,
|
|
37
|
+
[]
|
|
38
|
+
);
|
|
28
39
|
const handleOnChange = ( nextIsFocused ) => {
|
|
29
|
-
if (
|
|
30
|
-
|
|
40
|
+
if ( nextIsFocused && isDistractionFree ) {
|
|
41
|
+
return;
|
|
31
42
|
}
|
|
32
|
-
|
|
33
|
-
|
|
43
|
+
const selectedBlockClientId = getSelectedBlockClientId();
|
|
44
|
+
const clientId = highlightParent
|
|
45
|
+
? getBlockRootClientId( selectedBlockClientId )
|
|
46
|
+
: selectedBlockClientId;
|
|
47
|
+
toggleBlockHighlight( clientId, nextIsFocused );
|
|
34
48
|
};
|
|
35
49
|
|
|
36
50
|
const getIsHovered = () => {
|
|
37
51
|
return ref?.current && ref.current.matches( ':hover' );
|
|
38
52
|
};
|
|
39
53
|
|
|
40
|
-
const
|
|
54
|
+
const shouldHideGestures = () => {
|
|
41
55
|
const isHovered = getIsHovered();
|
|
42
56
|
return ! isFocused && ! isHovered;
|
|
43
57
|
};
|
|
@@ -50,19 +64,16 @@ export function useDebouncedShowMovers( {
|
|
|
50
64
|
}
|
|
51
65
|
};
|
|
52
66
|
|
|
53
|
-
const
|
|
67
|
+
const debouncedShowGestures = ( event ) => {
|
|
54
68
|
if ( event ) {
|
|
55
69
|
event.stopPropagation();
|
|
56
70
|
}
|
|
57
71
|
|
|
58
72
|
clearTimeoutRef();
|
|
59
|
-
|
|
60
|
-
if ( ! showMovers ) {
|
|
61
|
-
handleOnChange( true );
|
|
62
|
-
}
|
|
73
|
+
handleOnChange( true );
|
|
63
74
|
};
|
|
64
75
|
|
|
65
|
-
const
|
|
76
|
+
const debouncedHideGestures = ( event ) => {
|
|
66
77
|
if ( event ) {
|
|
67
78
|
event.stopPropagation();
|
|
68
79
|
}
|
|
@@ -70,7 +81,7 @@ export function useDebouncedShowMovers( {
|
|
|
70
81
|
clearTimeoutRef();
|
|
71
82
|
|
|
72
83
|
timeoutRef.current = setTimeout( () => {
|
|
73
|
-
if (
|
|
84
|
+
if ( shouldHideGestures() ) {
|
|
74
85
|
handleOnChange( false );
|
|
75
86
|
}
|
|
76
87
|
}, debounceTimeout );
|
|
@@ -90,29 +101,33 @@ export function useDebouncedShowMovers( {
|
|
|
90
101
|
);
|
|
91
102
|
|
|
92
103
|
return {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
debouncedHideMovers,
|
|
104
|
+
debouncedShowGestures,
|
|
105
|
+
debouncedHideGestures,
|
|
96
106
|
};
|
|
97
107
|
}
|
|
98
108
|
|
|
99
109
|
/**
|
|
100
|
-
* Hook that provides
|
|
101
|
-
* that interact with the
|
|
110
|
+
* Hook that provides gesture events for DOM elements
|
|
111
|
+
* that interact with the isFocused state.
|
|
102
112
|
*
|
|
103
|
-
* @param {Object}
|
|
104
|
-
* @param {Object}
|
|
105
|
-
* @param {number}
|
|
106
|
-
* @param {
|
|
113
|
+
* @param {Object} props Component props.
|
|
114
|
+
* @param {Object} props.ref Element reference.
|
|
115
|
+
* @param {number} [props.highlightParent=false] Whether to highlight the parent block. It defaults to highlighting the selected block.
|
|
116
|
+
* @param {number} [props.debounceTimeout=250] Debounce timeout in milliseconds.
|
|
107
117
|
*/
|
|
108
|
-
export function
|
|
118
|
+
export function useShowHoveredOrFocusedGestures( {
|
|
109
119
|
ref,
|
|
120
|
+
highlightParent = false,
|
|
110
121
|
debounceTimeout = DEBOUNCE_TIMEOUT,
|
|
111
|
-
onChange = noop,
|
|
112
122
|
} ) {
|
|
113
123
|
const [ isFocused, setIsFocused ] = useState( false );
|
|
114
|
-
const {
|
|
115
|
-
|
|
124
|
+
const { debouncedShowGestures, debouncedHideGestures } =
|
|
125
|
+
useDebouncedShowGestures( {
|
|
126
|
+
ref,
|
|
127
|
+
debounceTimeout,
|
|
128
|
+
isFocused,
|
|
129
|
+
highlightParent,
|
|
130
|
+
} );
|
|
116
131
|
|
|
117
132
|
const registerRef = useRef( false );
|
|
118
133
|
|
|
@@ -129,14 +144,14 @@ export function useShowMoversGestures( {
|
|
|
129
144
|
const handleOnFocus = () => {
|
|
130
145
|
if ( isFocusedWithin() ) {
|
|
131
146
|
setIsFocused( true );
|
|
132
|
-
|
|
147
|
+
debouncedShowGestures();
|
|
133
148
|
}
|
|
134
149
|
};
|
|
135
150
|
|
|
136
151
|
const handleOnBlur = () => {
|
|
137
152
|
if ( ! isFocusedWithin() ) {
|
|
138
153
|
setIsFocused( false );
|
|
139
|
-
|
|
154
|
+
debouncedHideGestures();
|
|
140
155
|
}
|
|
141
156
|
};
|
|
142
157
|
|
|
@@ -160,15 +175,12 @@ export function useShowMoversGestures( {
|
|
|
160
175
|
ref,
|
|
161
176
|
registerRef,
|
|
162
177
|
setIsFocused,
|
|
163
|
-
|
|
164
|
-
|
|
178
|
+
debouncedShowGestures,
|
|
179
|
+
debouncedHideGestures,
|
|
165
180
|
] );
|
|
166
181
|
|
|
167
182
|
return {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
onMouseMove: debouncedShowMovers,
|
|
171
|
-
onMouseLeave: debouncedHideMovers,
|
|
172
|
-
},
|
|
183
|
+
onMouseMove: debouncedShowGestures,
|
|
184
|
+
onMouseLeave: debouncedHideGestures,
|
|
173
185
|
};
|
|
174
186
|
}
|
|
@@ -32,48 +32,56 @@ function BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {
|
|
|
32
32
|
const toolbarButtonRef = useRef();
|
|
33
33
|
|
|
34
34
|
const isLargeViewport = useViewportMatch( 'medium' );
|
|
35
|
-
const {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
35
|
+
const {
|
|
36
|
+
blockType,
|
|
37
|
+
hasParents,
|
|
38
|
+
showParentSelector,
|
|
39
|
+
selectedBlockClientId,
|
|
40
|
+
isContentOnly,
|
|
41
|
+
} = useSelect( ( select ) => {
|
|
42
|
+
const {
|
|
43
|
+
getBlockName,
|
|
44
|
+
getBlockParents,
|
|
45
|
+
getSelectedBlockClientIds,
|
|
46
|
+
getBlockEditingMode,
|
|
47
|
+
} = unlock( select( blockEditorStore ) );
|
|
48
|
+
const { getBlockType } = select( blocksStore );
|
|
49
|
+
const selectedBlockClientIds = getSelectedBlockClientIds();
|
|
50
|
+
const _selectedBlockClientId = selectedBlockClientIds[ 0 ];
|
|
51
|
+
const parents = getBlockParents( _selectedBlockClientId );
|
|
52
|
+
const firstParentClientId = parents[ parents.length - 1 ];
|
|
53
|
+
const parentBlockName = getBlockName( firstParentClientId );
|
|
54
|
+
const parentBlockType = getBlockType( parentBlockName );
|
|
50
55
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
56
|
+
return {
|
|
57
|
+
selectedBlockClientId: _selectedBlockClientId,
|
|
58
|
+
blockType:
|
|
59
|
+
_selectedBlockClientId &&
|
|
60
|
+
getBlockType( getBlockName( _selectedBlockClientId ) ),
|
|
61
|
+
hasParents: parents.length,
|
|
62
|
+
isContentOnly:
|
|
63
|
+
getBlockEditingMode( _selectedBlockClientId ) === 'contentOnly',
|
|
64
|
+
showParentSelector:
|
|
65
|
+
parentBlockType &&
|
|
66
|
+
getBlockEditingMode( firstParentClientId ) === 'default' &&
|
|
67
|
+
hasBlockSupport(
|
|
68
|
+
parentBlockType,
|
|
69
|
+
'__experimentalParentSelector',
|
|
70
|
+
true
|
|
71
|
+
) &&
|
|
72
|
+
selectedBlockClientIds.length <= 1 &&
|
|
73
|
+
getBlockEditingMode( _selectedBlockClientId ) === 'default',
|
|
74
|
+
};
|
|
75
|
+
}, [] );
|
|
69
76
|
|
|
70
77
|
useEffect( () => {
|
|
71
78
|
setIsCollapsed( false );
|
|
72
79
|
}, [ selectedBlockClientId ] );
|
|
73
80
|
|
|
74
81
|
if (
|
|
75
|
-
|
|
76
|
-
|
|
82
|
+
isContentOnly ||
|
|
83
|
+
( blockType &&
|
|
84
|
+
! hasBlockSupport( blockType, '__experimentalToolbar', true ) )
|
|
77
85
|
) {
|
|
78
86
|
return null;
|
|
79
87
|
}
|
|
@@ -125,9 +125,18 @@
|
|
|
125
125
|
display: none;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
// Add a scrim to the right of the collapsed button.
|
|
129
|
+
&.is-collapsed::after {
|
|
130
|
+
content: "";
|
|
131
|
+
position: absolute;
|
|
132
|
+
left: 100%;
|
|
133
|
+
width: $grid-unit-60;
|
|
134
|
+
height: 100%;
|
|
135
|
+
background: linear-gradient(to right, $white, transparent);
|
|
136
|
+
}
|
|
137
|
+
|
|
128
138
|
// on desktop and tablet viewports the toolbar is fixed
|
|
129
139
|
// on top of interface header
|
|
130
|
-
|
|
131
140
|
@include break-medium() {
|
|
132
141
|
&.is-fixed {
|
|
133
142
|
|
|
@@ -157,7 +166,7 @@
|
|
|
157
166
|
}
|
|
158
167
|
}
|
|
159
168
|
|
|
160
|
-
& > .block-editor-block-toolbar
|
|
169
|
+
& > .block-editor-block-toolbar {
|
|
161
170
|
flex-grow: initial;
|
|
162
171
|
width: initial;
|
|
163
172
|
|
|
@@ -308,7 +317,7 @@
|
|
|
308
317
|
}
|
|
309
318
|
}
|
|
310
319
|
|
|
311
|
-
// on tablet
|
|
320
|
+
// on tablet viewports the toolbar is fixed
|
|
312
321
|
// on top of interface header and covers the whole header
|
|
313
322
|
// except for the inserter on the left
|
|
314
323
|
@include break-medium() {
|
|
@@ -322,12 +331,15 @@
|
|
|
322
331
|
// for the block inserter the publish button
|
|
323
332
|
@include break-large() {
|
|
324
333
|
&.is-fixed {
|
|
334
|
+
width: auto;
|
|
335
|
+
}
|
|
336
|
+
.is-fullscreen-mode &.is-fixed {
|
|
337
|
+
// in full screen mode we need to account for
|
|
325
338
|
// the combined with of the tools at the right of the header and the margin left
|
|
326
339
|
// of the toolbar which includes four buttons
|
|
327
|
-
width: calc(100% -
|
|
340
|
+
width: calc(100% - 280px - #{4 * $grid-unit-80});
|
|
328
341
|
}
|
|
329
342
|
}
|
|
330
|
-
|
|
331
343
|
}
|
|
332
344
|
|
|
333
345
|
/**
|
|
@@ -12,12 +12,9 @@ import {
|
|
|
12
12
|
/**
|
|
13
13
|
* WordPress dependencies
|
|
14
14
|
*/
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
createBlocksFromInnerBlocksTemplate,
|
|
19
|
-
store as blocksStore,
|
|
20
|
-
} from '@wordpress/blocks';
|
|
15
|
+
import { useDispatch } from '@wordpress/data';
|
|
16
|
+
import { usePreferredColorSchemeStyle } from '@wordpress/compose';
|
|
17
|
+
import { createBlocksFromInnerBlocksTemplate } from '@wordpress/blocks';
|
|
21
18
|
import { __ } from '@wordpress/i18n';
|
|
22
19
|
import {
|
|
23
20
|
PanelBody,
|
|
@@ -26,7 +23,6 @@ import {
|
|
|
26
23
|
InserterButton,
|
|
27
24
|
} from '@wordpress/components';
|
|
28
25
|
import { Icon, close } from '@wordpress/icons';
|
|
29
|
-
import { useMemo } from '@wordpress/element';
|
|
30
26
|
|
|
31
27
|
/**
|
|
32
28
|
* Internal dependencies
|
|
@@ -45,28 +41,25 @@ function BlockVariationPicker( { isVisible, onClose, clientId, variations } ) {
|
|
|
45
41
|
styles.cancelButtonDark
|
|
46
42
|
);
|
|
47
43
|
|
|
48
|
-
const leftButton =
|
|
49
|
-
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
</TouchableWithoutFeedback>
|
|
68
|
-
),
|
|
69
|
-
[ onClose, cancelButtonStyle ]
|
|
44
|
+
const leftButton = (
|
|
45
|
+
<TouchableWithoutFeedback onPress={ onClose } hitSlop={ hitSlop }>
|
|
46
|
+
<View>
|
|
47
|
+
{ isIOS ? (
|
|
48
|
+
<Text
|
|
49
|
+
style={ cancelButtonStyle }
|
|
50
|
+
maxFontSizeMultiplier={ 2 }
|
|
51
|
+
>
|
|
52
|
+
{ __( 'Cancel' ) }
|
|
53
|
+
</Text>
|
|
54
|
+
) : (
|
|
55
|
+
<Icon
|
|
56
|
+
icon={ close }
|
|
57
|
+
size={ 24 }
|
|
58
|
+
style={ styles.closeIcon }
|
|
59
|
+
/>
|
|
60
|
+
) }
|
|
61
|
+
</View>
|
|
62
|
+
</TouchableWithoutFeedback>
|
|
70
63
|
);
|
|
71
64
|
|
|
72
65
|
const onVariationSelect = ( variation ) => {
|
|
@@ -77,51 +70,38 @@ function BlockVariationPicker( { isVisible, onClose, clientId, variations } ) {
|
|
|
77
70
|
onClose();
|
|
78
71
|
};
|
|
79
72
|
|
|
80
|
-
return
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
73
|
+
return (
|
|
74
|
+
<BottomSheet
|
|
75
|
+
isVisible={ isVisible }
|
|
76
|
+
onClose={ onClose }
|
|
77
|
+
title={ __( 'Select a layout' ) }
|
|
78
|
+
contentStyle={ styles.contentStyle }
|
|
79
|
+
leftButton={ leftButton }
|
|
80
|
+
testID="block-variation-modal"
|
|
81
|
+
>
|
|
82
|
+
<ScrollView
|
|
83
|
+
horizontal
|
|
84
|
+
showsHorizontalScrollIndicator={ false }
|
|
85
|
+
contentContainerStyle={ styles.contentContainerStyle }
|
|
86
|
+
style={ styles.containerStyle }
|
|
89
87
|
>
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
>
|
|
96
|
-
{ variations.map( ( v ) => {
|
|
97
|
-
return (
|
|
98
|
-
<InserterButton
|
|
99
|
-
item={ v }
|
|
100
|
-
key={ v.name }
|
|
101
|
-
onSelect={ () => onVariationSelect( v ) }
|
|
102
|
-
/>
|
|
103
|
-
);
|
|
104
|
-
} ) }
|
|
105
|
-
</ScrollView>
|
|
106
|
-
<PanelBody>
|
|
107
|
-
<FooterMessageControl
|
|
108
|
-
label={ __(
|
|
109
|
-
'Note: Column layout may vary between themes and screen sizes'
|
|
110
|
-
) }
|
|
88
|
+
{ variations.map( ( v ) => (
|
|
89
|
+
<InserterButton
|
|
90
|
+
item={ v }
|
|
91
|
+
key={ v.name }
|
|
92
|
+
onSelect={ () => onVariationSelect( v ) }
|
|
111
93
|
/>
|
|
112
|
-
|
|
113
|
-
</
|
|
114
|
-
|
|
115
|
-
|
|
94
|
+
) ) }
|
|
95
|
+
</ScrollView>
|
|
96
|
+
<PanelBody>
|
|
97
|
+
<FooterMessageControl
|
|
98
|
+
label={ __(
|
|
99
|
+
'Note: Column layout may vary between themes and screen sizes'
|
|
100
|
+
) }
|
|
101
|
+
/>
|
|
102
|
+
</PanelBody>
|
|
103
|
+
</BottomSheet>
|
|
116
104
|
);
|
|
117
105
|
}
|
|
118
106
|
|
|
119
|
-
export default
|
|
120
|
-
withSelect( ( select, {} ) => {
|
|
121
|
-
const { getBlockVariations } = select( blocksStore );
|
|
122
|
-
|
|
123
|
-
return {
|
|
124
|
-
date: getBlockVariations( 'core/columns', 'block' ),
|
|
125
|
-
};
|
|
126
|
-
} )
|
|
127
|
-
)( BlockVariationPicker );
|
|
107
|
+
export default BlockVariationPicker;
|
|
@@ -172,7 +172,7 @@ exports[`ColorPaletteControl matches the snapshot 1`] = `
|
|
|
172
172
|
<button
|
|
173
173
|
aria-expanded="false"
|
|
174
174
|
aria-haspopup="true"
|
|
175
|
-
aria-label="Custom color picker. The currently selected color is called "red" and has a value of "
|
|
175
|
+
aria-label="Custom color picker. The currently selected color is called "red" and has a value of "#f00"."
|
|
176
176
|
class="components-color-palette__custom-color-button"
|
|
177
177
|
style="background: rgb(255, 0, 0);"
|
|
178
178
|
/>
|
|
@@ -43,13 +43,13 @@ function useDarkThemeBodyClassName( styles ) {
|
|
|
43
43
|
body.appendChild( tempCanvas );
|
|
44
44
|
|
|
45
45
|
backgroundColor = defaultView
|
|
46
|
-
|
|
46
|
+
?.getComputedStyle( tempCanvas, null )
|
|
47
47
|
.getPropertyValue( 'background-color' );
|
|
48
48
|
|
|
49
49
|
body.removeChild( tempCanvas );
|
|
50
50
|
} else {
|
|
51
51
|
backgroundColor = defaultView
|
|
52
|
-
|
|
52
|
+
?.getComputedStyle( canvas, null )
|
|
53
53
|
.getPropertyValue( 'background-color' );
|
|
54
54
|
}
|
|
55
55
|
const colordBackgroundColor = colord( backgroundColor );
|