@wordpress/block-editor 11.1.0 → 11.2.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 +7 -0
- package/LICENSE.md +1 -1
- package/build/components/block-actions/index.js +9 -0
- package/build/components/block-actions/index.js.map +1 -1
- package/build/components/block-inspector/index.js +4 -2
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-preview/auto.js +1 -4
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +4 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/index.js +3 -1
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js +43 -10
- package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build/components/default-style-picker/index.js +1 -0
- package/build/components/default-style-picker/index.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +5 -8
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/iframe/index.js +37 -8
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/iframe/use-compatibility-styles.js +6 -1
- package/build/components/iframe/use-compatibility-styles.js.map +1 -1
- package/build/components/image-size-control/index.js +1 -0
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +4 -4
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/index.js +3 -2
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/menu.js +11 -5
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inspector-controls/groups.js +3 -1
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls-tabs/position-controls-panel.js +46 -0
- package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -0
- package/build/components/inspector-controls-tabs/settings-tab.js +3 -1
- package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -1
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +4 -11
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build/components/link-control/search-input.js +1 -0
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/off-canvas-editor/appender.js +2 -38
- package/build/components/off-canvas-editor/appender.js.map +1 -1
- package/build/components/off-canvas-editor/block-contents.js +38 -5
- package/build/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build/components/off-canvas-editor/block.js +7 -25
- package/build/components/off-canvas-editor/block.js.map +1 -1
- package/build/components/off-canvas-editor/index.js +7 -4
- package/build/components/off-canvas-editor/index.js.map +1 -1
- package/build/components/provider/index.js +3 -1
- package/build/components/provider/index.js.map +1 -1
- package/build/components/rich-text/use-enter.js +4 -5
- package/build/components/rich-text/use-enter.js.map +1 -1
- package/build/components/url-input/button.js +1 -0
- package/build/components/url-input/button.js.map +1 -1
- package/build/components/url-input/index.js +15 -1
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/url-popover/link-editor.js +1 -0
- package/build/components/url-popover/link-editor.js.map +1 -1
- package/build/components/use-paste-styles/index.js +188 -0
- package/build/components/use-paste-styles/index.js.map +1 -0
- package/build/components/writing-flow/use-arrow-nav.js +22 -29
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/hooks/index.js +2 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/metadata.js +1 -1
- package/build/hooks/metadata.js.map +1 -1
- package/build/hooks/position.js +376 -0
- package/build/hooks/position.js.map +1 -0
- package/build/hooks/supports.js +328 -0
- package/build/hooks/supports.js.map +1 -0
- package/build/store/reducer.js +6 -2
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +8 -6
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-actions/index.js +6 -0
- package/build-module/components/block-actions/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +3 -2
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +1 -4
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +4 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/index.js +2 -1
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js +42 -11
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build-module/components/default-style-picker/index.js +1 -0
- package/build-module/components/default-style-picker/index.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +5 -7
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/iframe/index.js +36 -9
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/iframe/use-compatibility-styles.js +6 -1
- package/build-module/components/iframe/use-compatibility-styles.js.map +1 -1
- package/build-module/components/image-size-control/index.js +1 -0
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +4 -4
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/index.js +3 -2
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/menu.js +11 -5
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +3 -1
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js +33 -0
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/settings-tab.js +2 -1
- package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +4 -11
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build-module/components/link-control/search-input.js +1 -0
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/off-canvas-editor/appender.js +3 -36
- package/build-module/components/off-canvas-editor/appender.js.map +1 -1
- package/build-module/components/off-canvas-editor/block-contents.js +37 -7
- package/build-module/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build-module/components/off-canvas-editor/block.js +9 -27
- package/build-module/components/off-canvas-editor/block.js.map +1 -1
- package/build-module/components/off-canvas-editor/index.js +7 -4
- package/build-module/components/off-canvas-editor/index.js.map +1 -1
- package/build-module/components/provider/index.js +3 -1
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/rich-text/use-enter.js +4 -5
- package/build-module/components/rich-text/use-enter.js.map +1 -1
- package/build-module/components/url-input/button.js +1 -0
- package/build-module/components/url-input/button.js.map +1 -1
- package/build-module/components/url-input/index.js +14 -1
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/url-popover/link-editor.js +1 -0
- package/build-module/components/url-popover/link-editor.js.map +1 -1
- package/build-module/components/use-paste-styles/index.js +174 -0
- package/build-module/components/use-paste-styles/index.js.map +1 -0
- package/build-module/components/writing-flow/use-arrow-nav.js +22 -29
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/metadata.js +1 -1
- package/build-module/hooks/metadata.js.map +1 -1
- package/build-module/hooks/position.js +337 -0
- package/build-module/hooks/position.js.map +1 -0
- package/build-module/hooks/supports.js +257 -0
- package/build-module/hooks/supports.js.map +1 -0
- package/build-module/store/reducer.js +6 -2
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +7 -5
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/content-rtl.css +57 -0
- package/build-style/content.css +57 -0
- package/build-style/style-rtl.css +27 -58
- package/build-style/style.css +27 -58
- package/package.json +29 -29
- package/src/components/block-actions/index.js +5 -0
- package/src/components/block-inspector/index.js +3 -1
- package/src/components/block-preview/auto.js +2 -4
- package/src/components/block-settings-menu/block-settings-dropdown.js +4 -0
- package/src/components/block-styles/index.js +4 -1
- package/src/components/block-tools/use-block-toolbar-popover-props.js +68 -12
- package/src/components/button-block-appender/{style.scss → content.scss} +0 -0
- package/src/components/default-style-picker/index.js +1 -0
- package/src/components/font-sizes/with-font-sizes.js +33 -33
- package/src/components/iframe/index.js +52 -19
- package/src/components/iframe/use-compatibility-styles.js +6 -0
- package/src/components/image-size-control/index.js +1 -0
- package/src/components/inserter/block-patterns-tab.js +7 -4
- package/src/components/inserter/index.js +46 -41
- package/src/components/inserter/menu.js +8 -4
- package/src/components/inserter/test/__snapshots__/index.native.js.snap +117 -0
- package/src/components/inserter/test/index.native.js +255 -1
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/position-controls-panel.js +37 -0
- package/src/components/inspector-controls-tabs/settings-tab.js +2 -0
- package/src/components/inspector-controls-tabs/style.scss +15 -0
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +3 -8
- package/src/components/link-control/search-input.js +1 -0
- package/src/components/link-control/style.scss +1 -0
- package/src/components/list-view/style.scss +13 -3
- package/src/components/off-canvas-editor/appender.js +2 -52
- package/src/components/off-canvas-editor/block-contents.js +84 -23
- package/src/components/off-canvas-editor/block.js +28 -60
- package/src/components/off-canvas-editor/index.js +12 -2
- package/src/components/provider/index.js +4 -1
- package/src/components/rich-text/use-enter.js +4 -4
- package/src/components/url-input/README.md +5 -0
- package/src/components/url-input/button.js +1 -0
- package/src/components/url-input/index.js +15 -1
- package/src/components/url-popover/link-editor.js +1 -0
- package/src/components/use-paste-styles/index.js +230 -0
- package/src/components/writing-flow/use-arrow-nav.js +20 -28
- package/src/content.scss +1 -0
- package/src/hooks/index.js +1 -0
- package/src/hooks/metadata.js +1 -2
- package/src/hooks/position.js +375 -0
- package/src/hooks/position.scss +18 -0
- package/src/hooks/supports.js +302 -0
- package/src/hooks/test/__snapshots__/align.native.js.snap +73 -0
- package/src/hooks/test/align.native.js +133 -0
- package/src/store/reducer.js +7 -2
- package/src/store/selectors.js +5 -5
- package/src/store/test/reducer.js +45 -3
- package/src/store/test/selectors.js +12 -9
- package/src/style.scss +2 -1
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
addBlock,
|
|
6
|
+
fireEvent,
|
|
7
|
+
initializeEditor,
|
|
8
|
+
getBlock,
|
|
9
|
+
getEditorHtml,
|
|
10
|
+
render,
|
|
11
|
+
} from 'test/helpers';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* WordPress dependencies
|
|
15
|
+
*/
|
|
16
|
+
import { getBlockTypes, unregisterBlockType } from '@wordpress/blocks';
|
|
17
|
+
import { registerCoreBlocks } from '@wordpress/block-library';
|
|
5
18
|
|
|
6
19
|
/**
|
|
7
20
|
* Internal dependencies
|
|
@@ -20,4 +33,245 @@ describe( 'Inserter', () => {
|
|
|
20
33
|
|
|
21
34
|
expect( screen.getByTestId( 'add-block-button' ) ).toBeTruthy();
|
|
22
35
|
} );
|
|
36
|
+
|
|
37
|
+
describe( 'can add blocks', () => {
|
|
38
|
+
beforeAll( () => {
|
|
39
|
+
// Register all core blocks
|
|
40
|
+
registerCoreBlocks();
|
|
41
|
+
} );
|
|
42
|
+
|
|
43
|
+
afterAll( () => {
|
|
44
|
+
// Clean up registered blocks
|
|
45
|
+
getBlockTypes().forEach( ( block ) => {
|
|
46
|
+
unregisterBlockType( block.name );
|
|
47
|
+
} );
|
|
48
|
+
} );
|
|
49
|
+
|
|
50
|
+
it( 'to the beginning', async () => {
|
|
51
|
+
const screen = await initializeEditor();
|
|
52
|
+
const { getByLabelText, getByTestId } = screen;
|
|
53
|
+
|
|
54
|
+
// Add Spacer block
|
|
55
|
+
await addBlock( screen, 'Spacer' );
|
|
56
|
+
|
|
57
|
+
// Add Heading block
|
|
58
|
+
await addBlock( screen, 'Heading' );
|
|
59
|
+
|
|
60
|
+
// Add Paragraph block
|
|
61
|
+
await addBlock( screen, 'Paragraph' );
|
|
62
|
+
|
|
63
|
+
// Get Inserter button
|
|
64
|
+
const addBlockButton = await getByTestId( 'add-block-button' );
|
|
65
|
+
|
|
66
|
+
// Long press the inserter button
|
|
67
|
+
fireEvent( addBlockButton, 'onLongPress' );
|
|
68
|
+
|
|
69
|
+
// Get Add To Beginning option
|
|
70
|
+
const addBlockToBeginningButton = await getByLabelText(
|
|
71
|
+
'Add To Beginning'
|
|
72
|
+
);
|
|
73
|
+
expect( addBlockToBeginningButton ).toBeVisible();
|
|
74
|
+
fireEvent.press( addBlockToBeginningButton );
|
|
75
|
+
|
|
76
|
+
// Add another block at the beginning
|
|
77
|
+
await addBlock( screen, 'More', { isPickerOpened: true } );
|
|
78
|
+
|
|
79
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
80
|
+
} );
|
|
81
|
+
|
|
82
|
+
it( 'before another block', async () => {
|
|
83
|
+
const screen = await initializeEditor();
|
|
84
|
+
const { getByLabelText, getByTestId } = screen;
|
|
85
|
+
|
|
86
|
+
// Add Paragraph block
|
|
87
|
+
await addBlock( screen, 'Paragraph' );
|
|
88
|
+
|
|
89
|
+
// Get Paragraph block
|
|
90
|
+
const paragraphBlock = await getBlock( screen, 'Paragraph' );
|
|
91
|
+
fireEvent.press( paragraphBlock );
|
|
92
|
+
|
|
93
|
+
// Get Inserter button
|
|
94
|
+
const addBlockButton = await getByTestId( 'add-block-button' );
|
|
95
|
+
|
|
96
|
+
// Long press the inserter button
|
|
97
|
+
fireEvent( addBlockButton, 'onLongPress' );
|
|
98
|
+
|
|
99
|
+
// Get Add Block Before option
|
|
100
|
+
const addBlockBeforeButton = await getByLabelText(
|
|
101
|
+
'Add Block Before'
|
|
102
|
+
);
|
|
103
|
+
expect( addBlockBeforeButton ).toBeVisible();
|
|
104
|
+
fireEvent.press( addBlockBeforeButton );
|
|
105
|
+
|
|
106
|
+
// Add another block before the first one
|
|
107
|
+
await addBlock( screen, 'Heading', { isPickerOpened: true } );
|
|
108
|
+
|
|
109
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
110
|
+
} );
|
|
111
|
+
|
|
112
|
+
it( 'after another block', async () => {
|
|
113
|
+
const screen = await initializeEditor();
|
|
114
|
+
const { getByLabelText, getByTestId } = screen;
|
|
115
|
+
|
|
116
|
+
// Add Spacer block
|
|
117
|
+
await addBlock( screen, 'Spacer' );
|
|
118
|
+
|
|
119
|
+
// Add Heading block
|
|
120
|
+
await addBlock( screen, 'Heading' );
|
|
121
|
+
|
|
122
|
+
// Add Paragraph block
|
|
123
|
+
await addBlock( screen, 'Paragraph' );
|
|
124
|
+
|
|
125
|
+
// Get Heading block
|
|
126
|
+
const headingBlock = await getBlock( screen, 'Heading', {
|
|
127
|
+
rowIndex: 2,
|
|
128
|
+
} );
|
|
129
|
+
fireEvent.press( headingBlock );
|
|
130
|
+
|
|
131
|
+
// Get Inserter button
|
|
132
|
+
const addBlockButton = await getByTestId( 'add-block-button' );
|
|
133
|
+
|
|
134
|
+
// Long press the inserter button
|
|
135
|
+
fireEvent( addBlockButton, 'onLongPress' );
|
|
136
|
+
|
|
137
|
+
// Get Add Block After option
|
|
138
|
+
const addBlockAfterButton = await getByLabelText(
|
|
139
|
+
'Add Block After'
|
|
140
|
+
);
|
|
141
|
+
expect( addBlockAfterButton ).toBeVisible();
|
|
142
|
+
fireEvent.press( addBlockAfterButton );
|
|
143
|
+
|
|
144
|
+
// Add another block after the Heading block
|
|
145
|
+
await addBlock( screen, 'More', { isPickerOpened: true } );
|
|
146
|
+
|
|
147
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
148
|
+
} );
|
|
149
|
+
|
|
150
|
+
it( 'to the end', async () => {
|
|
151
|
+
const screen = await initializeEditor();
|
|
152
|
+
const { getByLabelText, getByTestId } = screen;
|
|
153
|
+
|
|
154
|
+
// Add Spacer block
|
|
155
|
+
await addBlock( screen, 'Spacer' );
|
|
156
|
+
|
|
157
|
+
// Add Heading block
|
|
158
|
+
await addBlock( screen, 'Heading' );
|
|
159
|
+
|
|
160
|
+
// Add Paragraph block
|
|
161
|
+
await addBlock( screen, 'Paragraph' );
|
|
162
|
+
|
|
163
|
+
// Get Spacer block
|
|
164
|
+
const spacerBlock = await getBlock( screen, 'Spacer' );
|
|
165
|
+
fireEvent.press( spacerBlock );
|
|
166
|
+
|
|
167
|
+
// Get Inserter button
|
|
168
|
+
const addBlockButton = await getByTestId( 'add-block-button' );
|
|
169
|
+
|
|
170
|
+
// Long press the inserter button
|
|
171
|
+
fireEvent( addBlockButton, 'onLongPress' );
|
|
172
|
+
|
|
173
|
+
// Get Add To End option
|
|
174
|
+
const addBlockToEndButton = await getByLabelText( 'Add To End' );
|
|
175
|
+
expect( addBlockToEndButton ).toBeVisible();
|
|
176
|
+
fireEvent.press( addBlockToEndButton );
|
|
177
|
+
|
|
178
|
+
// Add another block to the end after the Paragraph Block
|
|
179
|
+
await addBlock( screen, 'More', { isPickerOpened: true } );
|
|
180
|
+
|
|
181
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
182
|
+
} );
|
|
183
|
+
|
|
184
|
+
it( 'adds new block at the end of post', async () => {
|
|
185
|
+
const screen = await initializeEditor();
|
|
186
|
+
|
|
187
|
+
// Add Spacer block
|
|
188
|
+
await addBlock( screen, 'Spacer' );
|
|
189
|
+
|
|
190
|
+
// Add Heading block
|
|
191
|
+
await addBlock( screen, 'Heading' );
|
|
192
|
+
|
|
193
|
+
// Get Heading block
|
|
194
|
+
const headingBlock = await getBlock( screen, 'Heading', {
|
|
195
|
+
rowIndex: 2,
|
|
196
|
+
} );
|
|
197
|
+
expect( headingBlock ).toBeVisible();
|
|
198
|
+
|
|
199
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
200
|
+
} );
|
|
201
|
+
|
|
202
|
+
it( 'inserts between 2 existing blocks', async () => {
|
|
203
|
+
const screen = await initializeEditor();
|
|
204
|
+
|
|
205
|
+
// Add Spacer block
|
|
206
|
+
await addBlock( screen, 'Spacer' );
|
|
207
|
+
|
|
208
|
+
// Add Heading block
|
|
209
|
+
await addBlock( screen, 'Heading' );
|
|
210
|
+
|
|
211
|
+
// Get Spacer block
|
|
212
|
+
const spacerBlock = await getBlock( screen, 'Spacer' );
|
|
213
|
+
fireEvent.press( spacerBlock );
|
|
214
|
+
|
|
215
|
+
// Add More block
|
|
216
|
+
await addBlock( screen, 'More' );
|
|
217
|
+
|
|
218
|
+
// Get More block
|
|
219
|
+
const moreBlock = await getBlock( screen, 'More', { rowIndex: 2 } );
|
|
220
|
+
expect( moreBlock ).toBeVisible();
|
|
221
|
+
|
|
222
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
223
|
+
} );
|
|
224
|
+
|
|
225
|
+
it( 'inserts block at the end of post when no block is selected', async () => {
|
|
226
|
+
const screen = await initializeEditor();
|
|
227
|
+
const { getAllByLabelText } = screen;
|
|
228
|
+
|
|
229
|
+
// Add Spacer block
|
|
230
|
+
await addBlock( screen, 'Spacer' );
|
|
231
|
+
|
|
232
|
+
// Add Heading block
|
|
233
|
+
await addBlock( screen, 'Heading' );
|
|
234
|
+
|
|
235
|
+
// Select the title
|
|
236
|
+
const titleInputElement = await getAllByLabelText(
|
|
237
|
+
'Post title. test'
|
|
238
|
+
)[ 0 ];
|
|
239
|
+
expect( titleInputElement ).toBeVisible();
|
|
240
|
+
fireEvent.press( titleInputElement );
|
|
241
|
+
|
|
242
|
+
// Add More block
|
|
243
|
+
await addBlock( screen, 'More' );
|
|
244
|
+
|
|
245
|
+
// Get More block
|
|
246
|
+
const moreBlock = await getBlock( screen, 'More', { rowIndex: 3 } );
|
|
247
|
+
expect( moreBlock ).toBeVisible();
|
|
248
|
+
|
|
249
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
250
|
+
} );
|
|
251
|
+
|
|
252
|
+
it( 'creates a new Paragraph block tapping on the empty area below the last block', async () => {
|
|
253
|
+
const screen = await initializeEditor();
|
|
254
|
+
const { getByLabelText } = screen;
|
|
255
|
+
|
|
256
|
+
// Add Spacer block
|
|
257
|
+
await addBlock( screen, 'Spacer' );
|
|
258
|
+
|
|
259
|
+
// Add Heading block
|
|
260
|
+
await addBlock( screen, 'Heading' );
|
|
261
|
+
|
|
262
|
+
// Get the empty paragraph placeholder
|
|
263
|
+
const paragraphPlaceholder = await getByLabelText(
|
|
264
|
+
'Add paragraph block'
|
|
265
|
+
);
|
|
266
|
+
fireEvent.press( paragraphPlaceholder );
|
|
267
|
+
|
|
268
|
+
// Get Paragraph block
|
|
269
|
+
const paragraphBlock = await getBlock( screen, 'Paragraph', {
|
|
270
|
+
rowIndex: 3,
|
|
271
|
+
} );
|
|
272
|
+
expect( paragraphBlock ).toBeVisible();
|
|
273
|
+
|
|
274
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
275
|
+
} );
|
|
276
|
+
} );
|
|
23
277
|
} );
|
|
@@ -10,6 +10,7 @@ const InspectorControlsColor = createSlotFill( 'InspectorControlsColor' );
|
|
|
10
10
|
const InspectorControlsDimensions = createSlotFill(
|
|
11
11
|
'InspectorControlsDimensions'
|
|
12
12
|
);
|
|
13
|
+
const InspectorControlsPosition = createSlotFill( 'InspectorControlsPosition' );
|
|
13
14
|
const InspectorControlsTypography = createSlotFill(
|
|
14
15
|
'InspectorControlsTypography'
|
|
15
16
|
);
|
|
@@ -23,6 +24,7 @@ const groups = {
|
|
|
23
24
|
dimensions: InspectorControlsDimensions,
|
|
24
25
|
list: InspectorControlsListView,
|
|
25
26
|
typography: InspectorControlsTypography,
|
|
27
|
+
position: InspectorControlsPosition,
|
|
26
28
|
};
|
|
27
29
|
|
|
28
30
|
export default groups;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
PanelBody,
|
|
6
|
+
__experimentalUseSlotFills as useSlotFills,
|
|
7
|
+
} from '@wordpress/components';
|
|
8
|
+
import { __ } from '@wordpress/i18n';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
import InspectorControlsGroups from '../inspector-controls/groups';
|
|
14
|
+
import { default as InspectorControls } from '../inspector-controls';
|
|
15
|
+
|
|
16
|
+
const PositionControls = () => {
|
|
17
|
+
const fills = useSlotFills(
|
|
18
|
+
InspectorControlsGroups.position.Slot.__unstableName
|
|
19
|
+
);
|
|
20
|
+
const hasFills = Boolean( fills && fills.length );
|
|
21
|
+
|
|
22
|
+
if ( ! hasFills ) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<PanelBody
|
|
28
|
+
className="block-editor-block-inspector__position"
|
|
29
|
+
title={ __( 'Position' ) }
|
|
30
|
+
initialOpen={ false }
|
|
31
|
+
>
|
|
32
|
+
<InspectorControls.Slot __experimentalGroup="position" />
|
|
33
|
+
</PanelBody>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default PositionControls;
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
4
|
import AdvancedControls from './advanced-controls-panel';
|
|
5
|
+
import PositionControls from './position-controls-panel';
|
|
5
6
|
import { default as InspectorControls } from '../inspector-controls';
|
|
6
7
|
|
|
7
8
|
const SettingsTab = ( { showAdvancedControls = false } ) => (
|
|
8
9
|
<>
|
|
9
10
|
<InspectorControls.Slot />
|
|
11
|
+
<PositionControls />
|
|
10
12
|
{ showAdvancedControls && (
|
|
11
13
|
<div>
|
|
12
14
|
<AdvancedControls />
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
.show-icon-labels {
|
|
2
|
+
.block-editor-block-inspector__tabs .components-tab-panel__tabs {
|
|
3
|
+
.components-button.has-icon {
|
|
4
|
+
// Hide the button icons when labels are set to display...
|
|
5
|
+
svg {
|
|
6
|
+
display: none;
|
|
7
|
+
}
|
|
8
|
+
// ... and display labels.
|
|
9
|
+
// Uses ::before as ::after is already used for active tab styling.
|
|
10
|
+
&::before {
|
|
11
|
+
content: attr(aria-label);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -16,12 +16,6 @@ import { store as blockEditorStore } from '../../store';
|
|
|
16
16
|
const EMPTY_ARRAY = [];
|
|
17
17
|
|
|
18
18
|
function getShowTabs( blockName, tabSettings = {} ) {
|
|
19
|
-
// Don't allow settings to force the display of tabs if the block inspector
|
|
20
|
-
// tabs experiment hasn't been opted into.
|
|
21
|
-
if ( ! window?.__experimentalEnableBlockInspectorTabs ) {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
19
|
// Block specific setting takes precedence over generic default.
|
|
26
20
|
if ( tabSettings[ blockName ] !== undefined ) {
|
|
27
21
|
return tabSettings[ blockName ];
|
|
@@ -43,6 +37,7 @@ export default function useInspectorControlsTabs( blockName ) {
|
|
|
43
37
|
default: defaultGroup,
|
|
44
38
|
dimensions: dimensionsGroup,
|
|
45
39
|
list: listGroup,
|
|
40
|
+
position: positionGroup,
|
|
46
41
|
typography: typographyGroup,
|
|
47
42
|
} = InspectorControlsGroups;
|
|
48
43
|
|
|
@@ -71,6 +66,7 @@ export default function useInspectorControlsTabs( blockName ) {
|
|
|
71
66
|
// or Advanced Controls slot, then add this tab.
|
|
72
67
|
const settingsFills = [
|
|
73
68
|
...( useSlotFills( defaultGroup.Slot.__unstableName ) || [] ),
|
|
69
|
+
...( useSlotFills( positionGroup.Slot.__unstableName ) || [] ),
|
|
74
70
|
...( useSlotFills( InspectorAdvancedControls.slotName ) || [] ),
|
|
75
71
|
];
|
|
76
72
|
|
|
@@ -79,8 +75,7 @@ export default function useInspectorControlsTabs( blockName ) {
|
|
|
79
75
|
}
|
|
80
76
|
|
|
81
77
|
const tabSettings = useSelect( ( select ) => {
|
|
82
|
-
return select( blockEditorStore ).getSettings()
|
|
83
|
-
.__experimentalBlockInspectorTabs;
|
|
78
|
+
return select( blockEditorStore ).getSettings().blockInspectorTabs;
|
|
84
79
|
}, [] );
|
|
85
80
|
|
|
86
81
|
const showTabs = getShowTabs( blockName, tabSettings );
|
|
@@ -126,6 +126,7 @@ const LinkControlSearchInput = forwardRef(
|
|
|
126
126
|
return (
|
|
127
127
|
<div className="block-editor-link-control__search-input-container">
|
|
128
128
|
<URLInput
|
|
129
|
+
__nextHasNoMarginBottom
|
|
129
130
|
label={ useLabel ? 'URL' : undefined }
|
|
130
131
|
className={ inputClasses }
|
|
131
132
|
value={ value }
|
|
@@ -22,8 +22,18 @@
|
|
|
22
22
|
&.is-selected.is-synced td {
|
|
23
23
|
background: var(--wp-block-synced-color);
|
|
24
24
|
}
|
|
25
|
-
&.is-synced:not(.is-selected) .block-editor-list-view-block-contents
|
|
26
|
-
|
|
25
|
+
&.is-synced:not(.is-selected) .block-editor-list-view-block-contents {
|
|
26
|
+
&:hover,
|
|
27
|
+
&:focus,
|
|
28
|
+
.block-editor-block-icon {
|
|
29
|
+
color: var(--wp-block-synced-color);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&:focus::after {
|
|
33
|
+
box-shadow:
|
|
34
|
+
inset 0 0 0 1px $white,
|
|
35
|
+
0 0 0 var(--wp-admin-border-width-focus) var(--wp-block-synced-color);
|
|
36
|
+
}
|
|
27
37
|
}
|
|
28
38
|
&.is-selected .block-editor-list-view-block-contents,
|
|
29
39
|
&.is-selected .components-button.has-icon {
|
|
@@ -74,7 +84,7 @@
|
|
|
74
84
|
&.is-branch-selected:not(.is-selected):not(.is-synced-branch) {
|
|
75
85
|
background: rgba(var(--wp-admin-theme-color--rgb), 0.04);
|
|
76
86
|
}
|
|
77
|
-
&.is-synced-branch
|
|
87
|
+
&.is-synced-branch.is-branch-selected {
|
|
78
88
|
background: rgba(var(--wp-block-synced-color--rgb), 0.04);
|
|
79
89
|
}
|
|
80
90
|
&.is-branch-selected.is-first-selected td:first-child {
|
|
@@ -2,24 +2,14 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { useSelect } from '@wordpress/data';
|
|
5
|
-
import { forwardRef
|
|
5
|
+
import { forwardRef } from '@wordpress/element';
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { store as blockEditorStore } from '../../store';
|
|
10
10
|
import Inserter from '../inserter';
|
|
11
|
-
import { LinkUI } from './link-ui';
|
|
12
|
-
import { updateAttributes } from './update-attributes';
|
|
13
|
-
import { useInsertedBlock } from './use-inserted-block';
|
|
14
|
-
|
|
15
|
-
const BLOCKS_WITH_LINK_UI_SUPPORT = [
|
|
16
|
-
'core/navigation-link',
|
|
17
|
-
'core/navigation-submenu',
|
|
18
|
-
];
|
|
19
11
|
|
|
20
12
|
export const Appender = forwardRef( ( props, ref ) => {
|
|
21
|
-
const [ insertedBlockClientId, setInsertedBlockClientId ] = useState();
|
|
22
|
-
|
|
23
13
|
const { hideInserter, clientId } = useSelect( ( select ) => {
|
|
24
14
|
const {
|
|
25
15
|
getTemplateLock,
|
|
@@ -37,59 +27,19 @@ export const Appender = forwardRef( ( props, ref ) => {
|
|
|
37
27
|
};
|
|
38
28
|
}, [] );
|
|
39
29
|
|
|
40
|
-
const {
|
|
41
|
-
insertedBlockAttributes,
|
|
42
|
-
insertedBlockName,
|
|
43
|
-
setInsertedBlockAttributes,
|
|
44
|
-
} = useInsertedBlock( insertedBlockClientId );
|
|
45
|
-
|
|
46
|
-
const maybeSetInsertedBlockOnInsertion = ( _insertedBlock ) => {
|
|
47
|
-
if ( ! _insertedBlock?.clientId ) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
setInsertedBlockClientId( _insertedBlock?.clientId );
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
let maybeLinkUI;
|
|
55
|
-
|
|
56
|
-
if (
|
|
57
|
-
insertedBlockClientId &&
|
|
58
|
-
BLOCKS_WITH_LINK_UI_SUPPORT?.includes( insertedBlockName )
|
|
59
|
-
) {
|
|
60
|
-
maybeLinkUI = (
|
|
61
|
-
<LinkUI
|
|
62
|
-
clientId={ insertedBlockClientId }
|
|
63
|
-
link={ insertedBlockAttributes }
|
|
64
|
-
onClose={ () => setInsertedBlockClientId( null ) }
|
|
65
|
-
hasCreateSuggestion={ false }
|
|
66
|
-
onChange={ ( updatedValue ) => {
|
|
67
|
-
updateAttributes(
|
|
68
|
-
updatedValue,
|
|
69
|
-
setInsertedBlockAttributes,
|
|
70
|
-
insertedBlockAttributes
|
|
71
|
-
);
|
|
72
|
-
setInsertedBlockClientId( null );
|
|
73
|
-
} }
|
|
74
|
-
/>
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
30
|
if ( hideInserter ) {
|
|
79
31
|
return null;
|
|
80
32
|
}
|
|
81
33
|
|
|
82
34
|
return (
|
|
83
35
|
<div className="offcanvas-editor__appender">
|
|
84
|
-
{ maybeLinkUI }
|
|
85
|
-
|
|
86
36
|
<Inserter
|
|
87
37
|
ref={ ref }
|
|
88
38
|
rootClientId={ clientId }
|
|
89
39
|
position="bottom right"
|
|
90
40
|
isAppender={ true }
|
|
91
41
|
selectBlockOnInsert={ false }
|
|
92
|
-
|
|
42
|
+
shouldDirectInsert={ false }
|
|
93
43
|
__experimentalIsQuick
|
|
94
44
|
{ ...props }
|
|
95
45
|
/>
|
|
@@ -7,7 +7,7 @@ import classnames from 'classnames';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { useSelect } from '@wordpress/data';
|
|
10
|
-
import { forwardRef } from '@wordpress/element';
|
|
10
|
+
import { forwardRef, useEffect, useState } from '@wordpress/element';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Internal dependencies
|
|
@@ -15,6 +15,14 @@ import { forwardRef } from '@wordpress/element';
|
|
|
15
15
|
import ListViewBlockSelectButton from './block-select-button';
|
|
16
16
|
import BlockDraggable from '../block-draggable';
|
|
17
17
|
import { store as blockEditorStore } from '../../store';
|
|
18
|
+
import { updateAttributes } from './update-attributes';
|
|
19
|
+
import { LinkUI } from './link-ui';
|
|
20
|
+
import { useInsertedBlock } from './use-inserted-block';
|
|
21
|
+
|
|
22
|
+
const BLOCKS_WITH_LINK_UI_SUPPORT = [
|
|
23
|
+
'core/navigation-link',
|
|
24
|
+
'core/navigation-submenu',
|
|
25
|
+
];
|
|
18
26
|
|
|
19
27
|
const ListViewBlockContents = forwardRef(
|
|
20
28
|
(
|
|
@@ -33,19 +41,54 @@ const ListViewBlockContents = forwardRef(
|
|
|
33
41
|
ref
|
|
34
42
|
) => {
|
|
35
43
|
const { clientId } = block;
|
|
36
|
-
|
|
37
|
-
const {
|
|
44
|
+
const [ isLinkUIOpen, setIsLinkUIOpen ] = useState();
|
|
45
|
+
const {
|
|
46
|
+
blockMovingClientId,
|
|
47
|
+
selectedBlockInBlockEditor,
|
|
48
|
+
lastInsertedBlockClientId,
|
|
49
|
+
} = useSelect(
|
|
38
50
|
( select ) => {
|
|
39
|
-
const {
|
|
40
|
-
|
|
51
|
+
const {
|
|
52
|
+
hasBlockMovingClientId,
|
|
53
|
+
getSelectedBlockClientId,
|
|
54
|
+
getLastInsertedBlocksClientIds,
|
|
55
|
+
} = select( blockEditorStore );
|
|
56
|
+
const lastInsertedBlocksClientIds =
|
|
57
|
+
getLastInsertedBlocksClientIds();
|
|
41
58
|
return {
|
|
42
59
|
blockMovingClientId: hasBlockMovingClientId(),
|
|
43
60
|
selectedBlockInBlockEditor: getSelectedBlockClientId(),
|
|
61
|
+
lastInsertedBlockClientId:
|
|
62
|
+
lastInsertedBlocksClientIds &&
|
|
63
|
+
lastInsertedBlocksClientIds[ 0 ],
|
|
44
64
|
};
|
|
45
65
|
},
|
|
46
66
|
[ clientId ]
|
|
47
67
|
);
|
|
48
68
|
|
|
69
|
+
const {
|
|
70
|
+
insertedBlockAttributes,
|
|
71
|
+
insertedBlockName,
|
|
72
|
+
setInsertedBlockAttributes,
|
|
73
|
+
} = useInsertedBlock( lastInsertedBlockClientId );
|
|
74
|
+
|
|
75
|
+
const hasExistingLinkValue = insertedBlockAttributes?.id;
|
|
76
|
+
|
|
77
|
+
useEffect( () => {
|
|
78
|
+
if (
|
|
79
|
+
clientId === lastInsertedBlockClientId &&
|
|
80
|
+
BLOCKS_WITH_LINK_UI_SUPPORT?.includes( insertedBlockName ) &&
|
|
81
|
+
! hasExistingLinkValue // don't re-show the Link UI if the block already has a link value.
|
|
82
|
+
) {
|
|
83
|
+
setIsLinkUIOpen( true );
|
|
84
|
+
}
|
|
85
|
+
}, [
|
|
86
|
+
lastInsertedBlockClientId,
|
|
87
|
+
clientId,
|
|
88
|
+
insertedBlockName,
|
|
89
|
+
hasExistingLinkValue,
|
|
90
|
+
] );
|
|
91
|
+
|
|
49
92
|
const isBlockMoveTarget =
|
|
50
93
|
blockMovingClientId && selectedBlockInBlockEditor === clientId;
|
|
51
94
|
|
|
@@ -62,26 +105,44 @@ const ListViewBlockContents = forwardRef(
|
|
|
62
105
|
: [ clientId ];
|
|
63
106
|
|
|
64
107
|
return (
|
|
65
|
-
|
|
66
|
-
{
|
|
67
|
-
<
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
isExpanded={ isExpanded }
|
|
81
|
-
{ ...props }
|
|
108
|
+
<>
|
|
109
|
+
{ isLinkUIOpen && (
|
|
110
|
+
<LinkUI
|
|
111
|
+
clientId={ lastInsertedBlockClientId }
|
|
112
|
+
link={ insertedBlockAttributes }
|
|
113
|
+
onClose={ () => setIsLinkUIOpen( false ) }
|
|
114
|
+
hasCreateSuggestion={ false }
|
|
115
|
+
onChange={ ( updatedValue ) => {
|
|
116
|
+
updateAttributes(
|
|
117
|
+
updatedValue,
|
|
118
|
+
setInsertedBlockAttributes,
|
|
119
|
+
insertedBlockAttributes
|
|
120
|
+
);
|
|
121
|
+
setIsLinkUIOpen( false );
|
|
122
|
+
} }
|
|
82
123
|
/>
|
|
83
124
|
) }
|
|
84
|
-
|
|
125
|
+
<BlockDraggable clientIds={ draggableClientIds }>
|
|
126
|
+
{ ( { draggable, onDragStart, onDragEnd } ) => (
|
|
127
|
+
<ListViewBlockSelectButton
|
|
128
|
+
ref={ ref }
|
|
129
|
+
className={ className }
|
|
130
|
+
block={ block }
|
|
131
|
+
onClick={ onClick }
|
|
132
|
+
onToggleExpanded={ onToggleExpanded }
|
|
133
|
+
isSelected={ isSelected }
|
|
134
|
+
position={ position }
|
|
135
|
+
siblingBlockCount={ siblingBlockCount }
|
|
136
|
+
level={ level }
|
|
137
|
+
draggable={ draggable }
|
|
138
|
+
onDragStart={ onDragStart }
|
|
139
|
+
onDragEnd={ onDragEnd }
|
|
140
|
+
isExpanded={ isExpanded }
|
|
141
|
+
{ ...props }
|
|
142
|
+
/>
|
|
143
|
+
) }
|
|
144
|
+
</BlockDraggable>
|
|
145
|
+
</>
|
|
85
146
|
);
|
|
86
147
|
}
|
|
87
148
|
);
|