@wordpress/block-editor 11.7.0 → 11.8.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 +42 -55
- package/build/components/block-list/block.native.js +4 -3
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.native.js +11 -21
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +3 -1
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-popover/inbetween.js +2 -9
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +1 -10
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/caption/index.native.js +0 -1
- package/build/components/caption/index.native.js.map +1 -1
- package/build/components/date-format-picker/index.js +1 -1
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/global-styles/border-panel.js +15 -29
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +15 -14
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/effects-panel.js +244 -0
- package/build/components/global-styles/effects-panel.js.map +1 -0
- package/build/components/global-styles/filters-panel.js +151 -0
- package/build/components/global-styles/filters-panel.js.map +1 -0
- package/build/components/global-styles/get-block-css-selector.js +1 -12
- package/build/components/global-styles/get-block-css-selector.js.map +1 -1
- package/build/components/global-styles/hooks.js +7 -0
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +28 -0
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +15 -7
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/iframe/index.js +1 -1
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-size-control/use-dimension-handler.js +5 -3
- package/build/components/image-size-control/use-dimension-handler.js.map +1 -1
- package/build/components/index.js +16 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +4 -2
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inspector-controls-tabs/utils.js +5 -3
- package/build/components/inspector-controls-tabs/utils.js.map +1 -1
- package/build/components/list-view/block.js +1 -0
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/index.js +22 -4
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/use-list-view-client-ids.js +7 -3
- package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js +8 -2
- package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build/components/off-canvas-editor/block-contents.js +6 -1
- package/build/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build/components/off-canvas-editor/index.js +17 -14
- package/build/components/off-canvas-editor/index.js.map +1 -1
- package/build/components/resizable-box-popover/index.js +38 -0
- package/build/components/resizable-box-popover/index.js.map +1 -0
- package/build/components/rich-text/index.js +0 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +7 -11
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/spacing-sizes-control/spacing-input-control.js +8 -0
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build/hooks/anchor.js +1 -1
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/border.js +1 -1
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/duotone.js +92 -66
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/margin.js +27 -17
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +19 -9
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/utils.js +7 -4
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/utils.js +3 -2
- package/build/layouts/utils.js.map +1 -1
- package/build/private-apis.js +4 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +1 -1
- package/build/store/actions.js.map +1 -1
- package/build/utils/object.js +1 -1
- package/build/utils/object.js.map +1 -1
- package/build-module/components/block-list/block.native.js +4 -3
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.native.js +11 -19
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +2 -1
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +2 -9
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +1 -9
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/caption/index.native.js +0 -1
- package/build-module/components/caption/index.native.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +1 -1
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +15 -29
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +15 -14
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/effects-panel.js +228 -0
- package/build-module/components/global-styles/effects-panel.js.map +1 -0
- package/build-module/components/global-styles/filters-panel.js +139 -0
- package/build-module/components/global-styles/filters-panel.js.map +1 -0
- package/build-module/components/global-styles/get-block-css-selector.js +1 -12
- package/build-module/components/global-styles/get-block-css-selector.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +7 -0
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +2 -0
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +16 -8
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/iframe/index.js +1 -1
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-size-control/use-dimension-handler.js +5 -3
- package/build-module/components/image-size-control/use-dimension-handler.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +5 -2
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/utils.js +4 -3
- package/build-module/components/inspector-controls-tabs/utils.js.map +1 -1
- package/build-module/components/list-view/block.js +1 -0
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/index.js +21 -4
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/use-list-view-client-ids.js +7 -3
- package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js +8 -4
- package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/off-canvas-editor/block-contents.js +5 -1
- package/build-module/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build-module/components/off-canvas-editor/index.js +17 -14
- package/build-module/components/off-canvas-editor/index.js.map +1 -1
- package/build-module/components/resizable-box-popover/index.js +26 -0
- package/build-module/components/resizable-box-popover/index.js.map +1 -0
- package/build-module/components/rich-text/index.js +0 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +7 -10
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +7 -0
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build-module/hooks/anchor.js +1 -1
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/border.js +1 -1
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/duotone.js +90 -66
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/margin.js +29 -18
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +21 -10
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/utils.js +8 -5
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/utils.js +3 -2
- package/build-module/layouts/utils.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 +1 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/utils/object.js +1 -1
- package/build-module/utils/object.js.map +1 -1
- package/build-style/style-rtl.css +51 -10
- package/build-style/style.css +51 -10
- package/package.json +31 -31
- package/src/components/block-inspector/style.scss +6 -4
- package/src/components/block-list/block.native.js +3 -2
- package/src/components/block-list/index.native.js +19 -38
- package/src/components/block-list/use-in-between-inserter.js +4 -1
- package/src/components/block-popover/inbetween.js +2 -13
- package/src/components/block-settings-menu/block-settings-dropdown.js +2 -12
- package/src/components/caption/index.native.js +0 -1
- package/src/components/date-format-picker/index.js +1 -1
- package/src/components/global-styles/README.md +129 -16
- package/src/components/global-styles/border-panel.js +13 -32
- package/src/components/global-styles/dimensions-panel.js +30 -13
- package/src/components/global-styles/effects-panel.js +228 -0
- package/src/components/global-styles/filters-panel.js +157 -0
- package/src/components/global-styles/get-block-css-selector.js +0 -11
- package/src/components/global-styles/hooks.js +10 -0
- package/src/components/global-styles/index.js +2 -0
- package/src/components/global-styles/style.scss +42 -0
- package/src/components/global-styles/test/use-global-styles-output.js +4 -4
- package/src/components/global-styles/use-global-styles-output.js +27 -11
- package/src/components/iframe/index.js +1 -1
- package/src/components/image-size-control/use-dimension-handler.js +4 -3
- package/src/components/index.js +4 -1
- package/src/components/inserter/block-patterns-tab.js +3 -1
- package/src/components/inspector-controls-tabs/utils.js +4 -3
- package/src/components/list-view/README.md +2 -0
- package/src/components/list-view/block.js +1 -0
- package/src/components/list-view/index.js +18 -2
- package/src/components/list-view/style.scss +3 -1
- package/src/components/list-view/test/use-list-view-drop-zone.js +188 -0
- package/src/components/list-view/use-list-view-client-ids.js +5 -3
- package/src/components/list-view/use-list-view-drop-zone.js +9 -3
- package/src/components/off-canvas-editor/block-contents.js +4 -0
- package/src/components/off-canvas-editor/index.js +15 -11
- package/src/components/resizable-box-popover/index.js +27 -0
- package/src/components/rich-text/index.js +0 -1
- package/src/components/rich-text/index.native.js +2 -5
- package/src/components/spacing-sizes-control/spacing-input-control.js +10 -0
- package/src/components/spacing-sizes-control/style.scss +7 -7
- package/src/hooks/anchor.js +1 -1
- package/src/hooks/border.js +1 -1
- package/src/hooks/duotone.js +116 -74
- package/src/hooks/margin.js +31 -26
- package/src/hooks/padding.js +24 -18
- package/src/hooks/utils.js +4 -4
- package/src/layouts/utils.js +2 -2
- package/src/private-apis.js +2 -0
- package/src/store/actions.js +1 -1
- package/src/style.scss +1 -0
- package/src/utils/object.js +1 -1
- package/src/utils/test/object.js +38 -0
- package/build/components/rich-text/use-native-props.js +0 -11
- package/build/components/rich-text/use-native-props.js.map +0 -1
- package/build/components/rich-text/use-native-props.native.js +0 -24
- package/build/components/rich-text/use-native-props.native.js.map +0 -1
- package/build-module/components/rich-text/use-native-props.js +0 -4
- package/build-module/components/rich-text/use-native-props.js.map +0 -1
- package/build-module/components/rich-text/use-native-props.native.js +0 -15
- package/build-module/components/rich-text/use-native-props.native.js.map +0 -1
- package/src/components/rich-text/use-native-props.js +0 -3
- package/src/components/rich-text/use-native-props.native.js +0 -17
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { getListViewDropTarget } from '../use-list-view-drop-zone';
|
|
5
|
+
|
|
6
|
+
describe( 'getListViewDropTarget', () => {
|
|
7
|
+
const blocksData = [
|
|
8
|
+
{
|
|
9
|
+
blockIndex: 0,
|
|
10
|
+
canInsertDraggedBlocksAsChild: true,
|
|
11
|
+
canInsertDraggedBlocksAsSibling: true,
|
|
12
|
+
clientId: 'block-1',
|
|
13
|
+
element: {
|
|
14
|
+
getBoundingClientRect: () => ( {
|
|
15
|
+
top: 50,
|
|
16
|
+
bottom: 100,
|
|
17
|
+
left: 10,
|
|
18
|
+
right: 100,
|
|
19
|
+
x: 10,
|
|
20
|
+
y: 50,
|
|
21
|
+
width: 90,
|
|
22
|
+
height: 50,
|
|
23
|
+
} ),
|
|
24
|
+
},
|
|
25
|
+
innerBlockCount: 1,
|
|
26
|
+
isDraggedBlock: false,
|
|
27
|
+
isExpanded: true,
|
|
28
|
+
rootClientId: '',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
blockIndex: 0,
|
|
32
|
+
canInsertDraggedBlocksAsChild: true,
|
|
33
|
+
canInsertDraggedBlocksAsSibling: true,
|
|
34
|
+
clientId: 'block-2',
|
|
35
|
+
element: {
|
|
36
|
+
getBoundingClientRect: () => ( {
|
|
37
|
+
top: 100,
|
|
38
|
+
bottom: 150,
|
|
39
|
+
left: 10,
|
|
40
|
+
right: 100,
|
|
41
|
+
x: 10,
|
|
42
|
+
y: 100,
|
|
43
|
+
width: 90,
|
|
44
|
+
height: 50,
|
|
45
|
+
} ),
|
|
46
|
+
},
|
|
47
|
+
innerBlockCount: 0,
|
|
48
|
+
isDraggedBlock: false,
|
|
49
|
+
isExpanded: false,
|
|
50
|
+
rootClientId: 'block-1',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
blockIndex: 1,
|
|
54
|
+
canInsertDraggedBlocksAsChild: true,
|
|
55
|
+
canInsertDraggedBlocksAsSibling: true,
|
|
56
|
+
clientId: 'block-3',
|
|
57
|
+
element: {
|
|
58
|
+
getBoundingClientRect: () => ( {
|
|
59
|
+
top: 150,
|
|
60
|
+
bottom: 150,
|
|
61
|
+
left: 10,
|
|
62
|
+
right: 100,
|
|
63
|
+
x: 10,
|
|
64
|
+
y: 150,
|
|
65
|
+
width: 90,
|
|
66
|
+
height: 50,
|
|
67
|
+
} ),
|
|
68
|
+
},
|
|
69
|
+
innerBlockCount: 0,
|
|
70
|
+
isDraggedBlock: false,
|
|
71
|
+
isExpanded: false,
|
|
72
|
+
rootClientId: '',
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
|
|
76
|
+
it( 'should return the correct target when dragging a block over the top half of the first block', () => {
|
|
77
|
+
const position = { x: 50, y: 70 };
|
|
78
|
+
const target = getListViewDropTarget( blocksData, position );
|
|
79
|
+
|
|
80
|
+
expect( target ).toEqual( {
|
|
81
|
+
blockIndex: 0,
|
|
82
|
+
clientId: 'block-1',
|
|
83
|
+
dropPosition: 'top',
|
|
84
|
+
rootClientId: '',
|
|
85
|
+
} );
|
|
86
|
+
} );
|
|
87
|
+
|
|
88
|
+
it( 'should nest when dragging a block over the bottom half of an expanded block', () => {
|
|
89
|
+
const position = { x: 50, y: 90 };
|
|
90
|
+
const target = getListViewDropTarget( blocksData, position );
|
|
91
|
+
|
|
92
|
+
expect( target ).toEqual( {
|
|
93
|
+
blockIndex: 0,
|
|
94
|
+
dropPosition: 'inside',
|
|
95
|
+
rootClientId: 'block-1',
|
|
96
|
+
} );
|
|
97
|
+
} );
|
|
98
|
+
|
|
99
|
+
it( 'should nest when dragging a block over the right side and bottom half of a collapsed block with children', () => {
|
|
100
|
+
const position = { x: 70, y: 90 };
|
|
101
|
+
|
|
102
|
+
const collapsedBlockData = [ ...blocksData ];
|
|
103
|
+
|
|
104
|
+
// Set the first block to be collapsed.
|
|
105
|
+
collapsedBlockData[ 0 ] = {
|
|
106
|
+
...collapsedBlockData[ 0 ],
|
|
107
|
+
isExpanded: false,
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// Hide the first block's children.
|
|
111
|
+
collapsedBlockData.splice( 1, 1 );
|
|
112
|
+
|
|
113
|
+
const target = getListViewDropTarget( collapsedBlockData, position );
|
|
114
|
+
|
|
115
|
+
expect( target ).toEqual( {
|
|
116
|
+
blockIndex: 0,
|
|
117
|
+
dropPosition: 'inside',
|
|
118
|
+
rootClientId: 'block-1',
|
|
119
|
+
} );
|
|
120
|
+
} );
|
|
121
|
+
|
|
122
|
+
it( 'should drag below when dragging a block over the left side and bottom half of a collapsed block with children', () => {
|
|
123
|
+
const position = { x: 30, y: 90 };
|
|
124
|
+
|
|
125
|
+
const collapsedBlockData = [ ...blocksData ];
|
|
126
|
+
|
|
127
|
+
// Set the first block to be collapsed.
|
|
128
|
+
collapsedBlockData[ 0 ] = {
|
|
129
|
+
...collapsedBlockData[ 0 ],
|
|
130
|
+
isExpanded: false,
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
// Hide the first block's children.
|
|
134
|
+
collapsedBlockData.splice( 1, 1 );
|
|
135
|
+
|
|
136
|
+
const target = getListViewDropTarget( collapsedBlockData, position );
|
|
137
|
+
|
|
138
|
+
expect( target ).toEqual( {
|
|
139
|
+
blockIndex: 1,
|
|
140
|
+
clientId: 'block-1',
|
|
141
|
+
dropPosition: 'bottom',
|
|
142
|
+
rootClientId: '',
|
|
143
|
+
} );
|
|
144
|
+
} );
|
|
145
|
+
|
|
146
|
+
it( 'should drag below when attempting to nest but the dragged block is not allowed as a child', () => {
|
|
147
|
+
const position = { x: 70, y: 90 };
|
|
148
|
+
|
|
149
|
+
const childNotAllowedBlockData = [ ...blocksData ];
|
|
150
|
+
|
|
151
|
+
// Set the first block to not be allowed as a child.
|
|
152
|
+
childNotAllowedBlockData[ 0 ] = {
|
|
153
|
+
...childNotAllowedBlockData[ 0 ],
|
|
154
|
+
canInsertDraggedBlocksAsChild: false,
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const target = getListViewDropTarget(
|
|
158
|
+
childNotAllowedBlockData,
|
|
159
|
+
position
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
expect( target ).toEqual( {
|
|
163
|
+
blockIndex: 1,
|
|
164
|
+
clientId: 'block-1',
|
|
165
|
+
dropPosition: 'bottom',
|
|
166
|
+
rootClientId: '',
|
|
167
|
+
} );
|
|
168
|
+
} );
|
|
169
|
+
|
|
170
|
+
it( 'should return undefined when the dragged block cannot be inserted as a sibling', () => {
|
|
171
|
+
const position = { x: 50, y: 70 };
|
|
172
|
+
|
|
173
|
+
const siblingNotAllowedBlockData = [ ...blocksData ];
|
|
174
|
+
|
|
175
|
+
// Set the first block to not be allowed as a sibling.
|
|
176
|
+
siblingNotAllowedBlockData[ 0 ] = {
|
|
177
|
+
...siblingNotAllowedBlockData[ 0 ],
|
|
178
|
+
canInsertDraggedBlocksAsSibling: false,
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const target = getListViewDropTarget(
|
|
182
|
+
siblingNotAllowedBlockData,
|
|
183
|
+
position
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
expect( target ).toBeUndefined();
|
|
187
|
+
} );
|
|
188
|
+
} );
|
|
@@ -9,7 +9,7 @@ import { useSelect } from '@wordpress/data';
|
|
|
9
9
|
*/
|
|
10
10
|
import { store as blockEditorStore } from '../../store';
|
|
11
11
|
|
|
12
|
-
export default function useListViewClientIds( blocks ) {
|
|
12
|
+
export default function useListViewClientIds( { blocks, rootClientId } ) {
|
|
13
13
|
return useSelect(
|
|
14
14
|
( select ) => {
|
|
15
15
|
const {
|
|
@@ -21,9 +21,11 @@ export default function useListViewClientIds( blocks ) {
|
|
|
21
21
|
return {
|
|
22
22
|
selectedClientIds: getSelectedBlockClientIds(),
|
|
23
23
|
draggedClientIds: getDraggedBlockClientIds(),
|
|
24
|
-
clientIdsTree: blocks
|
|
24
|
+
clientIdsTree: blocks
|
|
25
|
+
? blocks
|
|
26
|
+
: __unstableGetClientIdsTree( rootClientId ),
|
|
25
27
|
};
|
|
26
28
|
},
|
|
27
|
-
[ blocks ]
|
|
29
|
+
[ blocks, rootClientId ]
|
|
28
30
|
);
|
|
29
31
|
}
|
|
@@ -36,6 +36,7 @@ import { store as blockEditorStore } from '../../store';
|
|
|
36
36
|
* @property {Element} element The DOM element representing the block.
|
|
37
37
|
* @property {number} innerBlockCount The number of inner blocks the block has.
|
|
38
38
|
* @property {boolean} isDraggedBlock Whether the block is currently being dragged.
|
|
39
|
+
* @property {boolean} isExpanded Whether the block is expanded in the UI.
|
|
39
40
|
* @property {boolean} canInsertDraggedBlocksAsSibling Whether the dragged block can be a sibling of this block.
|
|
40
41
|
* @property {boolean} canInsertDraggedBlocksAsChild Whether the dragged block can be a child of this block.
|
|
41
42
|
*/
|
|
@@ -78,7 +79,7 @@ const ALLOWED_DROP_EDGES = [ 'top', 'bottom' ];
|
|
|
78
79
|
*
|
|
79
80
|
* @return {WPListViewDropZoneTarget | undefined} An object containing data about the drop target.
|
|
80
81
|
*/
|
|
81
|
-
function getListViewDropTarget( blocksData, position ) {
|
|
82
|
+
export function getListViewDropTarget( blocksData, position ) {
|
|
82
83
|
let candidateEdge;
|
|
83
84
|
let candidateBlockData;
|
|
84
85
|
let candidateDistance;
|
|
@@ -146,12 +147,15 @@ function getListViewDropTarget( blocksData, position ) {
|
|
|
146
147
|
|
|
147
148
|
// If the user is dragging towards the bottom of the block check whether
|
|
148
149
|
// they might be trying to nest the block as a child.
|
|
149
|
-
// If the block already has inner blocks, this should
|
|
150
|
+
// If the block already has inner blocks, and is expanded, this should be treated
|
|
150
151
|
// as nesting since the next block in the tree will be the first child.
|
|
152
|
+
// However, if the block is collapsed, dragging beneath the block should
|
|
153
|
+
// still be allowed, as the next visible block in the tree will be a sibling.
|
|
151
154
|
if (
|
|
152
155
|
isDraggingBelow &&
|
|
153
156
|
candidateBlockData.canInsertDraggedBlocksAsChild &&
|
|
154
|
-
( candidateBlockData.innerBlockCount > 0
|
|
157
|
+
( ( candidateBlockData.innerBlockCount > 0 &&
|
|
158
|
+
candidateBlockData.isExpanded ) ||
|
|
155
159
|
isNestingGesture( position, candidateRect ) )
|
|
156
160
|
) {
|
|
157
161
|
return {
|
|
@@ -208,10 +212,12 @@ export default function useListViewDropZone() {
|
|
|
208
212
|
|
|
209
213
|
const blocksData = blockElements.map( ( blockElement ) => {
|
|
210
214
|
const clientId = blockElement.dataset.block;
|
|
215
|
+
const isExpanded = blockElement.dataset.expanded === 'true';
|
|
211
216
|
const rootClientId = getBlockRootClientId( clientId );
|
|
212
217
|
|
|
213
218
|
return {
|
|
214
219
|
clientId,
|
|
220
|
+
isExpanded,
|
|
215
221
|
rootClientId,
|
|
216
222
|
blockIndex: getBlockIndex( clientId ),
|
|
217
223
|
element: blockElement,
|
|
@@ -19,6 +19,7 @@ import { store as blockEditorStore } from '../../store';
|
|
|
19
19
|
import { updateAttributes } from './update-attributes';
|
|
20
20
|
import { LinkUI } from './link-ui';
|
|
21
21
|
import { useInsertedBlock } from './use-inserted-block';
|
|
22
|
+
import { useListViewContext } from './context';
|
|
22
23
|
|
|
23
24
|
const BLOCKS_WITH_LINK_UI_SUPPORT = [
|
|
24
25
|
'core/navigation-link',
|
|
@@ -90,6 +91,8 @@ const ListViewBlockContents = forwardRef(
|
|
|
90
91
|
hasExistingLinkValue,
|
|
91
92
|
] );
|
|
92
93
|
|
|
94
|
+
const { renderAdditionalBlockUI } = useListViewContext();
|
|
95
|
+
|
|
93
96
|
const isBlockMoveTarget =
|
|
94
97
|
blockMovingClientId && selectedBlockInBlockEditor === clientId;
|
|
95
98
|
|
|
@@ -107,6 +110,7 @@ const ListViewBlockContents = forwardRef(
|
|
|
107
110
|
|
|
108
111
|
return (
|
|
109
112
|
<>
|
|
113
|
+
{ renderAdditionalBlockUI && renderAdditionalBlockUI( block ) }
|
|
110
114
|
{ isLinkUIOpen && (
|
|
111
115
|
<LinkUI
|
|
112
116
|
clientId={ lastInsertedBlockClientId }
|
|
@@ -54,17 +54,18 @@ export const BLOCK_LIST_ITEM_HEIGHT = 36;
|
|
|
54
54
|
/**
|
|
55
55
|
* Show a hierarchical list of blocks.
|
|
56
56
|
*
|
|
57
|
-
* @param {Object}
|
|
58
|
-
* @param {string}
|
|
59
|
-
* @param {string}
|
|
60
|
-
* @param {Array}
|
|
61
|
-
* @param {boolean}
|
|
62
|
-
* @param {boolean}
|
|
63
|
-
* @param {Object}
|
|
64
|
-
* @param {string}
|
|
65
|
-
* @param {string}
|
|
66
|
-
* @param {string}
|
|
67
|
-
* @param {
|
|
57
|
+
* @param {Object} props Components props.
|
|
58
|
+
* @param {string} props.id An HTML element id for the root element of ListView.
|
|
59
|
+
* @param {string} props.parentClientId The client id of the parent block.
|
|
60
|
+
* @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy.
|
|
61
|
+
* @param {boolean} props.showBlockMovers Flag to enable block movers
|
|
62
|
+
* @param {boolean} props.isExpanded Flag to determine whether nested levels are expanded by default.
|
|
63
|
+
* @param {Object} props.LeafMoreMenu Optional more menu substitution.
|
|
64
|
+
* @param {string} props.description Optional accessible description for the tree grid component.
|
|
65
|
+
* @param {string} props.onSelect Optional callback to be invoked when a block is selected.
|
|
66
|
+
* @param {string} props.showAppender Flag to show or hide the block appender.
|
|
67
|
+
* @param {Function} props.renderAdditionalBlockUI Function that renders additional block content UI.
|
|
68
|
+
* @param {Object} ref Forwarded ref.
|
|
68
69
|
*/
|
|
69
70
|
function OffCanvasEditor(
|
|
70
71
|
{
|
|
@@ -77,6 +78,7 @@ function OffCanvasEditor(
|
|
|
77
78
|
LeafMoreMenu,
|
|
78
79
|
description = __( 'Block navigation structure' ),
|
|
79
80
|
onSelect,
|
|
81
|
+
renderAdditionalBlockUI,
|
|
80
82
|
},
|
|
81
83
|
ref
|
|
82
84
|
) {
|
|
@@ -200,6 +202,7 @@ function OffCanvasEditor(
|
|
|
200
202
|
expand,
|
|
201
203
|
collapse,
|
|
202
204
|
LeafMoreMenu,
|
|
205
|
+
renderAdditionalBlockUI,
|
|
203
206
|
} ),
|
|
204
207
|
[
|
|
205
208
|
isMounted.current,
|
|
@@ -208,6 +211,7 @@ function OffCanvasEditor(
|
|
|
208
211
|
expand,
|
|
209
212
|
collapse,
|
|
210
213
|
LeafMoreMenu,
|
|
214
|
+
renderAdditionalBlockUI,
|
|
211
215
|
]
|
|
212
216
|
);
|
|
213
217
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { ResizableBox } from '@wordpress/components';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import BlockPopover from '../block-popover';
|
|
10
|
+
|
|
11
|
+
export default function ResizableBoxPopover( {
|
|
12
|
+
clientId,
|
|
13
|
+
resizableBoxProps,
|
|
14
|
+
...props
|
|
15
|
+
} ) {
|
|
16
|
+
return (
|
|
17
|
+
<BlockPopover
|
|
18
|
+
clientId={ clientId }
|
|
19
|
+
__unstableCoverTarget
|
|
20
|
+
__unstablePopoverSlot="block-toolbar"
|
|
21
|
+
shift={ false }
|
|
22
|
+
{ ...props }
|
|
23
|
+
>
|
|
24
|
+
<ResizableBox { ...resizableBoxProps } />
|
|
25
|
+
</BlockPopover>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -46,7 +46,6 @@ import { useBlockEditContext } from '../block-edit';
|
|
|
46
46
|
import { RemoveBrowserShortcuts } from './remove-browser-shortcuts';
|
|
47
47
|
import { filePasteHandler } from './file-paste-handler';
|
|
48
48
|
import FormatToolbarContainer from './format-toolbar-container';
|
|
49
|
-
import { useNativeProps } from './use-native-props';
|
|
50
49
|
import { store as blockEditorStore } from '../../store';
|
|
51
50
|
import {
|
|
52
51
|
addActiveFormats,
|
|
@@ -97,7 +96,6 @@ function RichTextWrapper(
|
|
|
97
96
|
textAlign,
|
|
98
97
|
selectionColor,
|
|
99
98
|
tagsToEliminate,
|
|
100
|
-
rootTagsToEliminate,
|
|
101
99
|
disableEditingMenu,
|
|
102
100
|
fontSize,
|
|
103
101
|
fontFamily,
|
|
@@ -121,7 +119,6 @@ function RichTextWrapper(
|
|
|
121
119
|
|
|
122
120
|
const fallbackRef = useRef();
|
|
123
121
|
const { clientId, isSelected: blockIsSelected } = useBlockEditContext();
|
|
124
|
-
const nativeProps = useNativeProps();
|
|
125
122
|
const embedHandlerPickerRef = useRef();
|
|
126
123
|
const selector = ( select ) => {
|
|
127
124
|
const {
|
|
@@ -220,6 +217,7 @@ function RichTextWrapper(
|
|
|
220
217
|
selectionChangeEnd
|
|
221
218
|
);
|
|
222
219
|
},
|
|
220
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
223
221
|
[ clientId, identifier ]
|
|
224
222
|
);
|
|
225
223
|
|
|
@@ -373,6 +371,7 @@ function RichTextWrapper(
|
|
|
373
371
|
}
|
|
374
372
|
}
|
|
375
373
|
},
|
|
374
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
376
375
|
[
|
|
377
376
|
onReplace,
|
|
378
377
|
onSplit,
|
|
@@ -615,7 +614,6 @@ function RichTextWrapper(
|
|
|
615
614
|
}
|
|
616
615
|
__unstableMultilineRootTag={ __unstableMultilineRootTag }
|
|
617
616
|
// Native props.
|
|
618
|
-
{ ...nativeProps }
|
|
619
617
|
blockIsSelected={
|
|
620
618
|
originalIsSelected !== undefined
|
|
621
619
|
? originalIsSelected
|
|
@@ -628,7 +626,6 @@ function RichTextWrapper(
|
|
|
628
626
|
textAlign={ textAlign }
|
|
629
627
|
selectionColor={ selectionColor }
|
|
630
628
|
tagsToEliminate={ tagsToEliminate }
|
|
631
|
-
rootTagsToEliminate={ rootTagsToEliminate }
|
|
632
629
|
disableEditingMenu={ disableEditingMenu }
|
|
633
630
|
fontSize={ fontSize }
|
|
634
631
|
fontFamily={ fontFamily }
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
} from '@wordpress/components';
|
|
21
21
|
import { __, sprintf } from '@wordpress/i18n';
|
|
22
22
|
import { settings } from '@wordpress/icons';
|
|
23
|
+
import { usePrevious } from '@wordpress/compose';
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* Internal dependencies
|
|
@@ -71,6 +72,15 @@ export default function SpacingInputControl( {
|
|
|
71
72
|
! isValueSpacingPreset( value )
|
|
72
73
|
);
|
|
73
74
|
|
|
75
|
+
const previousValue = usePrevious( value );
|
|
76
|
+
if (
|
|
77
|
+
previousValue !== value &&
|
|
78
|
+
! isValueSpacingPreset( value ) &&
|
|
79
|
+
showCustomValueControl !== true
|
|
80
|
+
) {
|
|
81
|
+
setShowCustomValueControl( true );
|
|
82
|
+
}
|
|
83
|
+
|
|
74
84
|
const units = useCustomUnits( {
|
|
75
85
|
availableUnits: useSetting( 'spacing.units' ) || [ 'px', 'em', 'rem' ],
|
|
76
86
|
} );
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
display: grid;
|
|
3
3
|
grid-template-columns: auto 1fr auto;
|
|
4
4
|
align-items: center;
|
|
5
|
-
grid-template-rows:
|
|
5
|
+
grid-template-rows: $grid-unit-30 auto;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
.component-spacing-sizes-control {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
.components-base-control__label {
|
|
22
|
-
margin-bottom:
|
|
22
|
+
margin-bottom: $grid-unit-10;
|
|
23
23
|
height: $grid-unit-20;
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
grid-row: 1 / 1;
|
|
56
56
|
align-self: center;
|
|
57
57
|
margin-left: $grid-unit-05;
|
|
58
|
+
margin-bottom: $grid-unit-10;
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
.components-spacing-sizes-control__custom-toggle-all {
|
|
@@ -85,20 +86,20 @@
|
|
|
85
86
|
.components-spacing-sizes-control__custom-value-range {
|
|
86
87
|
grid-column: span 2;
|
|
87
88
|
margin-left: $grid-unit-20;
|
|
88
|
-
margin-top: 8px;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
.components-spacing-sizes-control__custom-value-input {
|
|
91
|
+
.components-base-control.components-spacing-sizes-control__custom-value-input {
|
|
92
92
|
width: 124px;
|
|
93
|
-
margin-top: 8px;
|
|
94
93
|
grid-column: 1;
|
|
94
|
+
margin-bottom: 0;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
.components-range-control {
|
|
97
|
+
.components-base-control.components-range-control {
|
|
98
98
|
height: 40px;
|
|
99
99
|
/* Vertically center the RangeControl until it has true 40px height. */
|
|
100
100
|
display: flex;
|
|
101
101
|
align-items: center;
|
|
102
|
+
margin-bottom: 0;
|
|
102
103
|
|
|
103
104
|
> .components-base-control__field {
|
|
104
105
|
/* Fixes RangeControl contents when the outer wrapper is flex */
|
|
@@ -108,7 +109,6 @@
|
|
|
108
109
|
|
|
109
110
|
.components-spacing-sizes-control__range-control {
|
|
110
111
|
grid-column: span 3;
|
|
111
|
-
margin-top: 8px;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
.components-range-control__mark {
|
package/src/hooks/anchor.js
CHANGED
|
@@ -80,7 +80,7 @@ export const withInspectorControl = createHigherOrderComponent(
|
|
|
80
80
|
{ isWeb && (
|
|
81
81
|
<ExternalLink
|
|
82
82
|
href={ __(
|
|
83
|
-
'https://wordpress.org/
|
|
83
|
+
'https://wordpress.org/documentation/article/page-jumps/'
|
|
84
84
|
) }
|
|
85
85
|
>
|
|
86
86
|
{ __( 'Learn more about anchors' ) }
|
package/src/hooks/border.js
CHANGED
|
@@ -84,7 +84,7 @@ function styleToAttributes( style ) {
|
|
|
84
84
|
|
|
85
85
|
const borderColorValue = style?.border?.color;
|
|
86
86
|
const borderColorSlug = borderColorValue?.startsWith( 'var:preset|color|' )
|
|
87
|
-
?
|
|
87
|
+
? borderColorValue.substring( 'var:preset|color|'.length )
|
|
88
88
|
: undefined;
|
|
89
89
|
const updatedStyle = { ...style };
|
|
90
90
|
updatedStyle.border = {
|