@wordpress/block-library 7.13.0 → 7.13.1-next.957ca95e4c.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/build/columns/transforms.js +10 -1
- package/build/columns/transforms.js.map +1 -1
- package/build/cover/edit/block-controls.js +9 -2
- package/build/cover/edit/block-controls.js.map +1 -1
- package/build/gallery/gap-styles.js +5 -4
- package/build/gallery/gap-styles.js.map +1 -1
- package/build/home-link/index.js +14 -1
- package/build/home-link/index.js.map +1 -1
- package/build/image/edit.js +3 -1
- package/build/image/edit.js.map +1 -1
- package/build/image/use-client-width.js +3 -1
- package/build/image/use-client-width.js.map +1 -1
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build/index.native.js +3 -15
- package/build/index.native.js.map +1 -1
- package/build/latest-posts/deprecated.js +14 -1
- package/build/latest-posts/deprecated.js.map +1 -1
- package/build/latest-posts/index.js +14 -1
- package/build/latest-posts/index.js.map +1 -1
- package/build/list/deprecated.js +84 -1
- package/build/list/deprecated.js.map +1 -1
- package/build/list/edit.js +153 -134
- package/build/list/edit.js.map +1 -1
- package/build/list/index.js +29 -34
- package/build/list/index.js.map +1 -1
- package/build/list/save.js +1 -5
- package/build/list/save.js.map +1 -1
- package/build/list/{v2/tag-name.js → tag-name.js} +0 -0
- package/build/list/tag-name.js.map +1 -0
- package/build/list/{v2/tag-name.native.js → tag-name.native.js} +0 -0
- package/build/list/tag-name.native.js.map +1 -0
- package/build/list/transforms.js +61 -95
- package/build/list/transforms.js.map +1 -1
- package/build/list/{v2/migrate.js → utils.js} +3 -2
- package/build/list/utils.js.map +1 -0
- package/build/list-item/edit.native.js +21 -3
- package/build/list-item/edit.native.js.map +1 -1
- package/build/list-item/hooks/use-copy.js +2 -0
- package/build/list-item/hooks/use-copy.js.map +1 -1
- package/build/list-item/hooks/use-merge.js +0 -1
- package/build/list-item/hooks/use-merge.js.map +1 -1
- package/build/list-item/hooks/use-outdent-list-item.js +0 -1
- package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build/list-item/hooks/use-space.js +10 -1
- package/build/list-item/hooks/use-space.js.map +1 -1
- package/build/list-item/index.js +0 -1
- package/build/list-item/index.js.map +1 -1
- package/build/list-item/utils.js +0 -1
- package/build/list-item/utils.js.map +1 -1
- package/build/navigation/edit/index.js +6 -3
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/responsive-wrapper.js +6 -4
- package/build/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +4 -15
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/post-excerpt/index.js +4 -2
- package/build/post-excerpt/index.js.map +1 -1
- package/build/post-terms/edit.js +0 -1
- package/build/post-terms/edit.js.map +1 -1
- package/build/post-terms/use-post-terms.js +4 -24
- package/build/post-terms/use-post-terms.js.map +1 -1
- package/build/query-no-results/index.js +13 -0
- package/build/query-no-results/index.js.map +1 -1
- package/build/query-pagination-numbers/index.js +4 -2
- package/build/query-pagination-numbers/index.js.map +1 -1
- package/build/query-title/index.js +1 -0
- package/build/query-title/index.js.map +1 -1
- package/build/quote/index.js +4 -2
- package/build/quote/index.js.map +1 -1
- package/build/term-description/index.js +6 -0
- package/build/term-description/index.js.map +1 -1
- package/build/verse/index.js +1 -0
- package/build/verse/index.js.map +1 -1
- package/build-module/columns/transforms.js +10 -1
- package/build-module/columns/transforms.js.map +1 -1
- package/build-module/cover/edit/block-controls.js +10 -3
- package/build-module/cover/edit/block-controls.js.map +1 -1
- package/build-module/gallery/gap-styles.js +6 -5
- package/build-module/gallery/gap-styles.js.map +1 -1
- package/build-module/home-link/index.js +14 -1
- package/build-module/home-link/index.js.map +1 -1
- package/build-module/image/edit.js +4 -2
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/use-client-width.js +3 -1
- package/build-module/image/use-client-width.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js +3 -15
- package/build-module/index.native.js.map +1 -1
- package/build-module/latest-posts/deprecated.js +14 -1
- package/build-module/latest-posts/deprecated.js.map +1 -1
- package/build-module/latest-posts/index.js +14 -1
- package/build-module/latest-posts/index.js.map +1 -1
- package/build-module/list/deprecated.js +83 -1
- package/build-module/list/deprecated.js.map +1 -1
- package/build-module/list/edit.js +151 -134
- package/build-module/list/edit.js.map +1 -1
- package/build-module/list/index.js +29 -29
- package/build-module/list/index.js.map +1 -1
- package/build-module/list/save.js +2 -6
- package/build-module/list/save.js.map +1 -1
- package/build-module/list/{v2/tag-name.js → tag-name.js} +0 -0
- package/build-module/list/tag-name.js.map +1 -0
- package/build-module/list/{v2/tag-name.native.js → tag-name.native.js} +0 -0
- package/build-module/list/tag-name.native.js.map +1 -0
- package/build-module/list/transforms.js +62 -97
- package/build-module/list/transforms.js.map +1 -1
- package/build-module/list/{v2/migrate.js → utils.js} +3 -2
- package/build-module/list/utils.js.map +1 -0
- package/build-module/list-item/edit.native.js +19 -3
- package/build-module/list-item/edit.native.js.map +1 -1
- package/build-module/list-item/hooks/use-copy.js +2 -0
- package/build-module/list-item/hooks/use-copy.js.map +1 -1
- package/build-module/list-item/hooks/use-merge.js +0 -1
- package/build-module/list-item/hooks/use-merge.js.map +1 -1
- package/build-module/list-item/hooks/use-outdent-list-item.js +0 -1
- package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build-module/list-item/hooks/use-space.js +10 -1
- package/build-module/list-item/hooks/use-space.js.map +1 -1
- package/build-module/list-item/index.js +0 -1
- package/build-module/list-item/index.js.map +1 -1
- package/build-module/list-item/utils.js +0 -1
- package/build-module/list-item/utils.js.map +1 -1
- package/build-module/navigation/edit/index.js +5 -3
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/responsive-wrapper.js +6 -4
- package/build-module/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +5 -15
- package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build-module/post-excerpt/index.js +4 -2
- package/build-module/post-excerpt/index.js.map +1 -1
- package/build-module/post-terms/edit.js +0 -1
- package/build-module/post-terms/edit.js.map +1 -1
- package/build-module/post-terms/use-post-terms.js +5 -25
- package/build-module/post-terms/use-post-terms.js.map +1 -1
- package/build-module/query-no-results/index.js +13 -0
- package/build-module/query-no-results/index.js.map +1 -1
- package/build-module/query-pagination-numbers/index.js +4 -2
- package/build-module/query-pagination-numbers/index.js.map +1 -1
- package/build-module/query-title/index.js +1 -0
- package/build-module/query-title/index.js.map +1 -1
- package/build-module/quote/index.js +4 -2
- package/build-module/quote/index.js.map +1 -1
- package/build-module/term-description/index.js +6 -0
- package/build-module/term-description/index.js.map +1 -1
- package/build-module/verse/index.js +1 -0
- package/build-module/verse/index.js.map +1 -1
- package/build-style/button/style-rtl.css +1 -4
- package/build-style/button/style.css +1 -4
- package/build-style/code/editor-rtl.css +79 -0
- package/build-style/code/editor.css +79 -0
- package/build-style/cover/editor-rtl.css +0 -3
- package/build-style/cover/editor.css +0 -3
- package/build-style/editor-rtl.css +9 -44
- package/build-style/editor.css +9 -44
- package/build-style/group/editor-rtl.css +2 -22
- package/build-style/group/editor.css +2 -22
- package/build-style/navigation/editor-rtl.css +3 -19
- package/build-style/navigation/editor.css +3 -19
- package/build-style/navigation/style-rtl.css +8 -1
- package/build-style/navigation/style.css +8 -1
- package/build-style/style-rtl.css +9 -5
- package/build-style/style.css +9 -5
- package/package.json +28 -28
- package/src/button/style.scss +1 -8
- package/src/code/editor.scss +3 -0
- package/src/columns/transforms.js +17 -3
- package/src/cover/edit/block-controls.js +15 -3
- package/src/cover/editor.scss +0 -4
- package/src/editor.scss +1 -0
- package/src/gallery/gap-styles.js +10 -6
- package/src/gallery/index.php +23 -2
- package/src/group/editor.scss +1 -28
- package/src/home-link/block.json +14 -1
- package/src/image/edit.js +3 -3
- package/src/image/use-client-width.js +1 -1
- package/src/index.js +1 -4
- package/src/index.native.js +2 -13
- package/src/latest-posts/block.json +14 -1
- package/src/list/deprecated.js +71 -1
- package/src/list/edit.js +146 -133
- package/src/list/index.js +25 -24
- package/src/list/save.js +3 -4
- package/src/list/{v2/tag-name.js → tag-name.js} +0 -0
- package/src/list/{v2/tag-name.native.js → tag-name.native.js} +0 -0
- package/src/list/test/__snapshots__/edit.native.js.snap +14 -2
- package/src/list/test/edit.native.js +0 -154
- package/src/list/transforms.js +57 -111
- package/src/list/{v2/migrate.js → utils.js} +2 -2
- package/src/list-item/block.json +0 -1
- package/src/list-item/edit.native.js +32 -2
- package/src/list-item/hooks/use-copy.js +2 -0
- package/src/list-item/hooks/use-space.js +10 -2
- package/src/list-item/style.native.scss +8 -0
- package/src/navigation/edit/index.js +14 -4
- package/src/navigation/edit/responsive-wrapper.js +8 -3
- package/src/navigation/edit/unsaved-inner-blocks.js +14 -24
- package/src/navigation/editor.scss +2 -23
- package/src/navigation/index.php +13 -8
- package/src/navigation/style.scss +11 -2
- package/src/post-excerpt/block.json +4 -2
- package/src/post-terms/edit.js +0 -1
- package/src/post-terms/use-post-terms.js +10 -15
- package/src/query-no-results/block.json +13 -0
- package/src/query-pagination-numbers/block.json +4 -2
- package/src/query-title/block.json +1 -0
- package/src/quote/block.json +4 -2
- package/src/term-description/block.json +6 -0
- package/src/verse/block.json +1 -0
- package/build/list/v2/deprecated.js +0 -117
- package/build/list/v2/deprecated.js.map +0 -1
- package/build/list/v2/edit.js +0 -200
- package/build/list/v2/edit.js.map +0 -1
- package/build/list/v2/index.js +0 -36
- package/build/list/v2/index.js.map +0 -1
- package/build/list/v2/migrate.js.map +0 -1
- package/build/list/v2/save.js +0 -34
- package/build/list/v2/save.js.map +0 -1
- package/build/list/v2/tag-name.js.map +0 -1
- package/build/list/v2/tag-name.native.js.map +0 -1
- package/build/list/v2/transforms.js +0 -137
- package/build/list/v2/transforms.js.map +0 -1
- package/build-module/list/v2/deprecated.js +0 -104
- package/build-module/list/v2/deprecated.js.map +0 -1
- package/build-module/list/v2/edit.js +0 -179
- package/build-module/list/v2/edit.js.map +0 -1
- package/build-module/list/v2/index.js +0 -21
- package/build-module/list/v2/index.js.map +0 -1
- package/build-module/list/v2/migrate.js.map +0 -1
- package/build-module/list/v2/save.js +0 -23
- package/build-module/list/v2/save.js.map +0 -1
- package/build-module/list/v2/tag-name.js.map +0 -1
- package/build-module/list/v2/tag-name.native.js.map +0 -1
- package/build-module/list/v2/transforms.js +0 -127
- package/build-module/list/v2/transforms.js.map +0 -1
- package/src/list/test/migrate.js +0 -158
- package/src/list/v2/deprecated.js +0 -89
- package/src/list/v2/edit.js +0 -192
- package/src/list/v2/index.js +0 -22
- package/src/list/v2/save.js +0 -18
- package/src/list/v2/transforms.js +0 -120
|
@@ -119,20 +119,6 @@ describe( 'List V2 block', () => {
|
|
|
119
119
|
|
|
120
120
|
// Select List block
|
|
121
121
|
const listBlock = getByA11yLabel( /List Block\. Row 1/ );
|
|
122
|
-
|
|
123
|
-
fireEvent(
|
|
124
|
-
within( listBlock ).getByTestId( 'block-list-wrapper' ),
|
|
125
|
-
'layout',
|
|
126
|
-
{
|
|
127
|
-
nativeEvent: {
|
|
128
|
-
layout: {
|
|
129
|
-
width: 100,
|
|
130
|
-
height: 50,
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
}
|
|
134
|
-
);
|
|
135
|
-
|
|
136
122
|
fireEvent.press( listBlock );
|
|
137
123
|
|
|
138
124
|
// Select List Item block
|
|
@@ -180,61 +166,18 @@ describe( 'List V2 block', () => {
|
|
|
180
166
|
// Select List block
|
|
181
167
|
const listBlock = getByA11yLabel( /List Block\. Row 1/ );
|
|
182
168
|
|
|
183
|
-
fireEvent(
|
|
184
|
-
within( listBlock ).getByTestId( 'block-list-wrapper' ),
|
|
185
|
-
'layout',
|
|
186
|
-
{
|
|
187
|
-
nativeEvent: {
|
|
188
|
-
layout: {
|
|
189
|
-
width: 100,
|
|
190
|
-
height: 50,
|
|
191
|
-
},
|
|
192
|
-
},
|
|
193
|
-
}
|
|
194
|
-
);
|
|
195
|
-
|
|
196
169
|
fireEvent.press( listBlock );
|
|
197
170
|
|
|
198
171
|
// Select List Item block
|
|
199
172
|
const firstNestedLevelBlock = within( listBlock ).getByA11yLabel(
|
|
200
173
|
/List item Block\. Row 2/
|
|
201
174
|
);
|
|
202
|
-
|
|
203
|
-
fireEvent(
|
|
204
|
-
within( firstNestedLevelBlock ).getByTestId( 'block-list-wrapper' ),
|
|
205
|
-
'layout',
|
|
206
|
-
{
|
|
207
|
-
nativeEvent: {
|
|
208
|
-
layout: {
|
|
209
|
-
width: 100,
|
|
210
|
-
height: 350,
|
|
211
|
-
},
|
|
212
|
-
},
|
|
213
|
-
}
|
|
214
|
-
);
|
|
215
|
-
|
|
216
175
|
fireEvent.press( firstNestedLevelBlock );
|
|
217
176
|
|
|
218
177
|
// Select second level list
|
|
219
178
|
const secondNestedLevelBlock = within(
|
|
220
179
|
firstNestedLevelBlock
|
|
221
180
|
).getByA11yLabel( /List Block\. Row 1/ );
|
|
222
|
-
|
|
223
|
-
fireEvent(
|
|
224
|
-
within( secondNestedLevelBlock ).getByTestId(
|
|
225
|
-
'block-list-wrapper'
|
|
226
|
-
),
|
|
227
|
-
'layout',
|
|
228
|
-
{
|
|
229
|
-
nativeEvent: {
|
|
230
|
-
layout: {
|
|
231
|
-
width: 100,
|
|
232
|
-
height: 50,
|
|
233
|
-
},
|
|
234
|
-
},
|
|
235
|
-
}
|
|
236
|
-
);
|
|
237
|
-
|
|
238
181
|
fireEvent.press( secondNestedLevelBlock );
|
|
239
182
|
|
|
240
183
|
expect( getEditorHtml() ).toMatchSnapshot();
|
|
@@ -256,20 +199,6 @@ describe( 'List V2 block', () => {
|
|
|
256
199
|
|
|
257
200
|
// Select List block
|
|
258
201
|
const listBlock = getByA11yLabel( /List Block\. Row 1/ );
|
|
259
|
-
|
|
260
|
-
fireEvent(
|
|
261
|
-
within( listBlock ).getByTestId( 'block-list-wrapper' ),
|
|
262
|
-
'layout',
|
|
263
|
-
{
|
|
264
|
-
nativeEvent: {
|
|
265
|
-
layout: {
|
|
266
|
-
width: 100,
|
|
267
|
-
height: 50,
|
|
268
|
-
},
|
|
269
|
-
},
|
|
270
|
-
}
|
|
271
|
-
);
|
|
272
|
-
|
|
273
202
|
fireEvent.press( listBlock );
|
|
274
203
|
|
|
275
204
|
// Select Secont List Item block
|
|
@@ -300,40 +229,12 @@ describe( 'List V2 block', () => {
|
|
|
300
229
|
|
|
301
230
|
// Select List block
|
|
302
231
|
const listBlock = getByA11yLabel( /List Block\. Row 1/ );
|
|
303
|
-
|
|
304
|
-
fireEvent(
|
|
305
|
-
within( listBlock ).getByTestId( 'block-list-wrapper' ),
|
|
306
|
-
'layout',
|
|
307
|
-
{
|
|
308
|
-
nativeEvent: {
|
|
309
|
-
layout: {
|
|
310
|
-
width: 100,
|
|
311
|
-
height: 50,
|
|
312
|
-
},
|
|
313
|
-
},
|
|
314
|
-
}
|
|
315
|
-
);
|
|
316
|
-
|
|
317
232
|
fireEvent.press( listBlock );
|
|
318
233
|
|
|
319
234
|
// Select List Item block
|
|
320
235
|
const firstNestedLevelBlock = within( listBlock ).getByA11yLabel(
|
|
321
236
|
/List item Block\. Row 1/
|
|
322
237
|
);
|
|
323
|
-
|
|
324
|
-
fireEvent(
|
|
325
|
-
within( firstNestedLevelBlock ).getByTestId( 'block-list-wrapper' ),
|
|
326
|
-
'layout',
|
|
327
|
-
{
|
|
328
|
-
nativeEvent: {
|
|
329
|
-
layout: {
|
|
330
|
-
width: 100,
|
|
331
|
-
height: 350,
|
|
332
|
-
},
|
|
333
|
-
},
|
|
334
|
-
}
|
|
335
|
-
);
|
|
336
|
-
|
|
337
238
|
fireEvent.press( firstNestedLevelBlock );
|
|
338
239
|
|
|
339
240
|
// Select Inner block List
|
|
@@ -341,19 +242,6 @@ describe( 'List V2 block', () => {
|
|
|
341
242
|
/List Block\. Row 1/
|
|
342
243
|
);
|
|
343
244
|
|
|
344
|
-
fireEvent(
|
|
345
|
-
within( innerBlockList ).getByTestId( 'block-list-wrapper' ),
|
|
346
|
-
'layout',
|
|
347
|
-
{
|
|
348
|
-
nativeEvent: {
|
|
349
|
-
layout: {
|
|
350
|
-
width: 100,
|
|
351
|
-
height: 50,
|
|
352
|
-
},
|
|
353
|
-
},
|
|
354
|
-
}
|
|
355
|
-
);
|
|
356
|
-
|
|
357
245
|
// Select nested List Item block
|
|
358
246
|
const listItemBlock = within( innerBlockList ).getByA11yLabel(
|
|
359
247
|
/List item Block\. Row 1/
|
|
@@ -386,20 +274,6 @@ describe( 'List V2 block', () => {
|
|
|
386
274
|
|
|
387
275
|
// Select List block
|
|
388
276
|
const listBlock = getByA11yLabel( /List Block\. Row 1/ );
|
|
389
|
-
|
|
390
|
-
fireEvent(
|
|
391
|
-
within( listBlock ).getByTestId( 'block-list-wrapper' ),
|
|
392
|
-
'layout',
|
|
393
|
-
{
|
|
394
|
-
nativeEvent: {
|
|
395
|
-
layout: {
|
|
396
|
-
width: 100,
|
|
397
|
-
height: 50,
|
|
398
|
-
},
|
|
399
|
-
},
|
|
400
|
-
}
|
|
401
|
-
);
|
|
402
|
-
|
|
403
277
|
fireEvent.press( listBlock );
|
|
404
278
|
|
|
405
279
|
// Update to ordered list
|
|
@@ -428,20 +302,6 @@ describe( 'List V2 block', () => {
|
|
|
428
302
|
|
|
429
303
|
// Select List block
|
|
430
304
|
const listBlock = getByA11yLabel( /List Block\. Row 1/ );
|
|
431
|
-
|
|
432
|
-
fireEvent(
|
|
433
|
-
within( listBlock ).getByTestId( 'block-list-wrapper' ),
|
|
434
|
-
'layout',
|
|
435
|
-
{
|
|
436
|
-
nativeEvent: {
|
|
437
|
-
layout: {
|
|
438
|
-
width: 100,
|
|
439
|
-
height: 50,
|
|
440
|
-
},
|
|
441
|
-
},
|
|
442
|
-
}
|
|
443
|
-
);
|
|
444
|
-
|
|
445
305
|
fireEvent.press( listBlock );
|
|
446
306
|
|
|
447
307
|
// Update to ordered list
|
|
@@ -481,20 +341,6 @@ describe( 'List V2 block', () => {
|
|
|
481
341
|
|
|
482
342
|
// Select List block
|
|
483
343
|
const listBlock = getByA11yLabel( /List Block\. Row 1/ );
|
|
484
|
-
|
|
485
|
-
fireEvent(
|
|
486
|
-
within( listBlock ).getByTestId( 'block-list-wrapper' ),
|
|
487
|
-
'layout',
|
|
488
|
-
{
|
|
489
|
-
nativeEvent: {
|
|
490
|
-
layout: {
|
|
491
|
-
width: 100,
|
|
492
|
-
height: 50,
|
|
493
|
-
},
|
|
494
|
-
},
|
|
495
|
-
}
|
|
496
|
-
);
|
|
497
|
-
|
|
498
344
|
fireEvent.press( listBlock );
|
|
499
345
|
|
|
500
346
|
// Update to ordered list
|
package/src/list/transforms.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { createBlock
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
toHTMLString,
|
|
12
|
-
} from '@wordpress/rich-text';
|
|
4
|
+
import { createBlock } from '@wordpress/blocks';
|
|
5
|
+
import { create, split, toHTMLString } from '@wordpress/rich-text';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { createListBlockFromDOMElement } from './utils';
|
|
13
11
|
|
|
14
12
|
function getListContentSchema( { phrasingContentSchema } ) {
|
|
15
13
|
const listContentSchema = {
|
|
@@ -32,6 +30,15 @@ function getListContentSchema( { phrasingContentSchema } ) {
|
|
|
32
30
|
return listContentSchema;
|
|
33
31
|
}
|
|
34
32
|
|
|
33
|
+
function getListContentFlat( blocks ) {
|
|
34
|
+
return blocks.flatMap( ( { name, attributes, innerBlocks = [] } ) => {
|
|
35
|
+
if ( name === 'core/list-item' ) {
|
|
36
|
+
return [ attributes.content, ...getListContentFlat( innerBlocks ) ];
|
|
37
|
+
}
|
|
38
|
+
return getListContentFlat( innerBlocks );
|
|
39
|
+
} );
|
|
40
|
+
}
|
|
41
|
+
|
|
35
42
|
const transforms = {
|
|
36
43
|
from: [
|
|
37
44
|
{
|
|
@@ -39,30 +46,28 @@ const transforms = {
|
|
|
39
46
|
isMultiBlock: true,
|
|
40
47
|
blocks: [ 'core/paragraph', 'core/heading' ],
|
|
41
48
|
transform: ( blockAttributes ) => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
anchor: blockAttributes.anchor,
|
|
65
|
-
} );
|
|
49
|
+
let childBlocks = [];
|
|
50
|
+
if ( blockAttributes.length > 1 ) {
|
|
51
|
+
childBlocks = blockAttributes.map( ( { content } ) => {
|
|
52
|
+
return createBlock( 'core/list-item', { content } );
|
|
53
|
+
} );
|
|
54
|
+
} else if ( blockAttributes.length === 1 ) {
|
|
55
|
+
const value = create( {
|
|
56
|
+
html: blockAttributes[ 0 ].content,
|
|
57
|
+
} );
|
|
58
|
+
childBlocks = split( value, '\n' ).map( ( result ) => {
|
|
59
|
+
return createBlock( 'core/list-item', {
|
|
60
|
+
content: toHTMLString( { value: result } ),
|
|
61
|
+
} );
|
|
62
|
+
} );
|
|
63
|
+
}
|
|
64
|
+
return createBlock(
|
|
65
|
+
'core/list',
|
|
66
|
+
{
|
|
67
|
+
anchor: blockAttributes.anchor,
|
|
68
|
+
},
|
|
69
|
+
childBlocks
|
|
70
|
+
);
|
|
66
71
|
},
|
|
67
72
|
},
|
|
68
73
|
{
|
|
@@ -72,102 +77,43 @@ const transforms = {
|
|
|
72
77
|
ol: getListContentSchema( args ).ol,
|
|
73
78
|
ul: getListContentSchema( args ).ul,
|
|
74
79
|
} ),
|
|
75
|
-
transform
|
|
76
|
-
const attributes = {
|
|
77
|
-
ordered: node.nodeName === 'OL',
|
|
78
|
-
anchor: node.id === '' ? undefined : node.id,
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
if ( attributes.ordered ) {
|
|
82
|
-
const type = node.getAttribute( 'type' );
|
|
83
|
-
|
|
84
|
-
if ( type ) {
|
|
85
|
-
attributes.type = type;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if ( node.getAttribute( 'reversed' ) !== null ) {
|
|
89
|
-
attributes.reversed = true;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const start = parseInt( node.getAttribute( 'start' ), 10 );
|
|
93
|
-
|
|
94
|
-
if (
|
|
95
|
-
! isNaN( start ) &&
|
|
96
|
-
// start=1 only makes sense if the list is reversed.
|
|
97
|
-
( start !== 1 || attributes.reversed )
|
|
98
|
-
) {
|
|
99
|
-
attributes.start = start;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return createBlock( 'core/list', {
|
|
104
|
-
...getBlockAttributes( 'core/list', node.outerHTML ),
|
|
105
|
-
...attributes,
|
|
106
|
-
} );
|
|
107
|
-
},
|
|
80
|
+
transform: createListBlockFromDOMElement,
|
|
108
81
|
},
|
|
109
82
|
...[ '*', '-' ].map( ( prefix ) => ( {
|
|
110
83
|
type: 'prefix',
|
|
111
84
|
prefix,
|
|
112
85
|
transform( content ) {
|
|
113
|
-
return createBlock( 'core/list', {
|
|
114
|
-
|
|
115
|
-
|
|
86
|
+
return createBlock( 'core/list', {}, [
|
|
87
|
+
createBlock( 'core/list-item', { content } ),
|
|
88
|
+
] );
|
|
116
89
|
},
|
|
117
90
|
} ) ),
|
|
118
91
|
...[ '1.', '1)' ].map( ( prefix ) => ( {
|
|
119
92
|
type: 'prefix',
|
|
120
93
|
prefix,
|
|
121
94
|
transform( content ) {
|
|
122
|
-
return createBlock(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
95
|
+
return createBlock(
|
|
96
|
+
'core/list',
|
|
97
|
+
{
|
|
98
|
+
ordered: true,
|
|
99
|
+
},
|
|
100
|
+
[ createBlock( 'core/list-item', { content } ) ]
|
|
101
|
+
);
|
|
126
102
|
},
|
|
127
103
|
} ) ),
|
|
128
104
|
],
|
|
129
105
|
to: [
|
|
130
|
-
{
|
|
106
|
+
...[ 'core/paragraph', 'core/heading' ].map( ( block ) => ( {
|
|
131
107
|
type: 'block',
|
|
132
|
-
blocks: [
|
|
133
|
-
transform: (
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
multilineTag: 'li',
|
|
138
|
-
multilineWrapperTags: [ 'ul', 'ol' ],
|
|
139
|
-
} ),
|
|
140
|
-
__UNSTABLE_LINE_SEPARATOR
|
|
141
|
-
).map( ( piece ) =>
|
|
142
|
-
createBlock( 'core/paragraph', {
|
|
143
|
-
content: toHTMLString( { value: piece } ),
|
|
108
|
+
blocks: [ block ],
|
|
109
|
+
transform: ( _attributes, childBlocks ) => {
|
|
110
|
+
return getListContentFlat( childBlocks ).map( ( content ) =>
|
|
111
|
+
createBlock( block, {
|
|
112
|
+
content,
|
|
144
113
|
} )
|
|
145
|
-
)
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
type: 'block',
|
|
149
|
-
blocks: [ 'core/heading' ],
|
|
150
|
-
transform: ( { values } ) =>
|
|
151
|
-
split(
|
|
152
|
-
create( {
|
|
153
|
-
html: values,
|
|
154
|
-
multilineTag: 'li',
|
|
155
|
-
multilineWrapperTags: [ 'ul', 'ol' ],
|
|
156
|
-
} ),
|
|
157
|
-
__UNSTABLE_LINE_SEPARATOR
|
|
158
|
-
).map( ( piece ) =>
|
|
159
|
-
createBlock( 'core/heading', {
|
|
160
|
-
content: toHTMLString( { value: piece } ),
|
|
161
|
-
} )
|
|
162
|
-
),
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
type: 'block',
|
|
166
|
-
blocks: [ 'core/table-of-contents' ],
|
|
167
|
-
transform: () => {
|
|
168
|
-
return createBlock( 'core/table-of-contents' );
|
|
114
|
+
);
|
|
169
115
|
},
|
|
170
|
-
},
|
|
116
|
+
} ) ),
|
|
171
117
|
],
|
|
172
118
|
};
|
|
173
119
|
|
|
@@ -11,11 +11,11 @@ import { createBlock } from '@wordpress/blocks';
|
|
|
11
11
|
export function createListBlockFromDOMElement( listElement ) {
|
|
12
12
|
const listAttributes = {
|
|
13
13
|
ordered: 'OL' === listElement.tagName,
|
|
14
|
+
anchor: listElement.id === '' ? undefined : listElement.id,
|
|
14
15
|
start: listElement.getAttribute( 'start' )
|
|
15
16
|
? parseInt( listElement.getAttribute( 'start' ), 10 )
|
|
16
17
|
: undefined,
|
|
17
|
-
reversed:
|
|
18
|
-
listElement.getAttribute( 'reversed' ) === true ? true : undefined,
|
|
18
|
+
reversed: listElement.hasAttribute( 'reversed' ) ? true : undefined,
|
|
19
19
|
type: listElement.getAttribute( 'type' ) ?? undefined,
|
|
20
20
|
};
|
|
21
21
|
|
package/src/list-item/block.json
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
store as blockEditorStore,
|
|
15
15
|
} from '@wordpress/block-editor';
|
|
16
16
|
import { __ } from '@wordpress/i18n';
|
|
17
|
+
import { usePreferredColorSchemeStyle } from '@wordpress/compose';
|
|
17
18
|
import { useSelect } from '@wordpress/data';
|
|
18
19
|
import { useState, useCallback } from '@wordpress/element';
|
|
19
20
|
|
|
@@ -26,6 +27,8 @@ import { IndentUI } from './edit.js';
|
|
|
26
27
|
import styles from './style.scss';
|
|
27
28
|
import ListStyleType from './list-style-type';
|
|
28
29
|
|
|
30
|
+
const OPACITY = '9e';
|
|
31
|
+
|
|
29
32
|
export default function ListItemEdit( {
|
|
30
33
|
attributes,
|
|
31
34
|
setAttributes,
|
|
@@ -84,11 +87,35 @@ export default function ListItemEdit( {
|
|
|
84
87
|
const blockProps = useBlockProps( {
|
|
85
88
|
...( hasInnerBlocks && styles[ 'wp-block-list-item__nested-blocks' ] ),
|
|
86
89
|
} );
|
|
90
|
+
|
|
87
91
|
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
88
92
|
allowedBlocks: [ 'core/list' ],
|
|
89
|
-
|
|
93
|
+
useCompactList: true,
|
|
90
94
|
} );
|
|
91
95
|
|
|
96
|
+
// Set default placeholder text color from light/dark scheme or base colors
|
|
97
|
+
const defaultPlaceholderFromScheme = usePreferredColorSchemeStyle(
|
|
98
|
+
styles[ 'wp-block-list-item__list-item-placeholder' ],
|
|
99
|
+
styles[ 'wp-block-list-item__list-item-placeholder--dark' ]
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const currentTextColor = style?.color || style?.baseColors?.color?.text;
|
|
103
|
+
|
|
104
|
+
const defaultPlaceholderTextColor = currentTextColor
|
|
105
|
+
? currentTextColor
|
|
106
|
+
: defaultPlaceholderFromScheme?.color;
|
|
107
|
+
|
|
108
|
+
// Add hex opacity to default placeholder text color and style object
|
|
109
|
+
const defaultPlaceholderTextColorWithOpacity =
|
|
110
|
+
defaultPlaceholderTextColor + OPACITY;
|
|
111
|
+
|
|
112
|
+
const styleWithPlaceholderOpacity = {
|
|
113
|
+
...style,
|
|
114
|
+
...( style?.color && {
|
|
115
|
+
placeholderColor: style.color + OPACITY,
|
|
116
|
+
} ),
|
|
117
|
+
};
|
|
118
|
+
|
|
92
119
|
const onSplit = useSplit( clientId );
|
|
93
120
|
const onMerge = useMerge( clientId );
|
|
94
121
|
const onLayout = useCallback( ( { nativeEvent } ) => {
|
|
@@ -128,12 +155,15 @@ export default function ListItemEdit( {
|
|
|
128
155
|
}
|
|
129
156
|
value={ content }
|
|
130
157
|
placeholder={ placeholder || __( 'List' ) }
|
|
158
|
+
placeholderTextColor={
|
|
159
|
+
defaultPlaceholderTextColorWithOpacity
|
|
160
|
+
}
|
|
131
161
|
onSplit={ onSplit }
|
|
132
162
|
onMerge={ onMerge }
|
|
133
163
|
onReplace={ ( blocks, ...args ) => {
|
|
134
164
|
onReplace( convertToListItems( blocks ), ...args );
|
|
135
165
|
} }
|
|
136
|
-
style={
|
|
166
|
+
style={ styleWithPlaceholderOpacity }
|
|
137
167
|
deleteEnter={ true }
|
|
138
168
|
containerWidth={ contentWidth }
|
|
139
169
|
/>
|
|
@@ -29,8 +29,10 @@ export default function useCopy( clientId ) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
node.addEventListener( 'copy', onCopy );
|
|
32
|
+
node.addEventListener( 'cut', onCopy );
|
|
32
33
|
return () => {
|
|
33
34
|
node.removeEventListener( 'copy', onCopy );
|
|
35
|
+
node.removeEventListener( 'cut', onCopy );
|
|
34
36
|
};
|
|
35
37
|
}, [] );
|
|
36
38
|
}
|
|
@@ -19,13 +19,21 @@ export default function useSpace( clientId ) {
|
|
|
19
19
|
return useRefEffect(
|
|
20
20
|
( element ) => {
|
|
21
21
|
function onKeyDown( event ) {
|
|
22
|
+
const { keyCode, shiftKey, altKey, metaKey, ctrlKey } = event;
|
|
23
|
+
|
|
22
24
|
if (
|
|
23
25
|
event.defaultPrevented ||
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
! canIndent ||
|
|
27
|
+
keyCode !== SPACE ||
|
|
28
|
+
// Only override when no modifiers are pressed.
|
|
29
|
+
shiftKey ||
|
|
30
|
+
altKey ||
|
|
31
|
+
metaKey ||
|
|
32
|
+
ctrlKey
|
|
26
33
|
) {
|
|
27
34
|
return;
|
|
28
35
|
}
|
|
36
|
+
|
|
29
37
|
const selectionStart = getSelectionStart();
|
|
30
38
|
const selectionEnd = getSelectionEnd();
|
|
31
39
|
if (
|
|
@@ -36,6 +36,7 @@ import {
|
|
|
36
36
|
import { __, sprintf } from '@wordpress/i18n';
|
|
37
37
|
import { speak } from '@wordpress/a11y';
|
|
38
38
|
import { createBlock } from '@wordpress/blocks';
|
|
39
|
+
import { close, Icon } from '@wordpress/icons';
|
|
39
40
|
|
|
40
41
|
/**
|
|
41
42
|
* Internal dependencies
|
|
@@ -465,15 +466,25 @@ function Navigation( {
|
|
|
465
466
|
setOverlayMenuPreview( ! overlayMenuPreview );
|
|
466
467
|
} }
|
|
467
468
|
>
|
|
468
|
-
{ hasIcon &&
|
|
469
|
-
|
|
469
|
+
{ hasIcon && (
|
|
470
|
+
<>
|
|
471
|
+
<OverlayMenuIcon />
|
|
472
|
+
<Icon icon={ close } />
|
|
473
|
+
</>
|
|
474
|
+
) }
|
|
475
|
+
{ ! hasIcon && (
|
|
476
|
+
<>
|
|
477
|
+
<span>{ __( 'Menu' ) }</span>
|
|
478
|
+
<span>{ __( 'Close' ) }</span>
|
|
479
|
+
</>
|
|
480
|
+
) }
|
|
470
481
|
</Button>
|
|
471
482
|
) }
|
|
472
483
|
{ overlayMenuPreview && (
|
|
473
484
|
<ToggleControl
|
|
474
485
|
label={ __( 'Show icon button' ) }
|
|
475
486
|
help={ __(
|
|
476
|
-
'Configure the visual appearance of the button opening the overlay menu.'
|
|
487
|
+
'Configure the visual appearance of the button opening and closing the overlay menu.'
|
|
477
488
|
) }
|
|
478
489
|
onChange={ ( value ) =>
|
|
479
490
|
setAttributes( { hasIcon: value } )
|
|
@@ -633,7 +644,6 @@ function Navigation( {
|
|
|
633
644
|
overlayTextColor={ overlayTextColor }
|
|
634
645
|
>
|
|
635
646
|
<UnsavedInnerBlocks
|
|
636
|
-
blockProps={ blockProps }
|
|
637
647
|
blocks={ uncontrolledInnerBlocks }
|
|
638
648
|
clientId={ clientId }
|
|
639
649
|
navigationMenus={ navigationMenus }
|
|
@@ -79,7 +79,7 @@ export default function ResponsiveWrapper( {
|
|
|
79
79
|
{ ! isOpen && (
|
|
80
80
|
<Button
|
|
81
81
|
aria-haspopup="true"
|
|
82
|
-
aria-label={ __( 'Open menu' ) }
|
|
82
|
+
aria-label={ hasIcon && __( 'Open menu' ) }
|
|
83
83
|
className={ openButtonClasses }
|
|
84
84
|
onClick={ () => onToggle( true ) }
|
|
85
85
|
>
|
|
@@ -104,10 +104,15 @@ export default function ResponsiveWrapper( {
|
|
|
104
104
|
<div { ...dialogProps }>
|
|
105
105
|
<Button
|
|
106
106
|
className="wp-block-navigation__responsive-container-close"
|
|
107
|
-
aria-label={ __( 'Close menu' ) }
|
|
107
|
+
aria-label={ hasIcon && __( 'Close menu' ) }
|
|
108
108
|
onClick={ () => onToggle( false ) }
|
|
109
109
|
>
|
|
110
|
-
<Icon icon={ close } />
|
|
110
|
+
{ hasIcon && <Icon icon={ close } /> }
|
|
111
|
+
{ ! hasIcon && (
|
|
112
|
+
<span className="wp-block-navigation__toggle_button_label">
|
|
113
|
+
{ __( 'Close' ) }
|
|
114
|
+
</span>
|
|
115
|
+
) }
|
|
111
116
|
</Button>
|
|
112
117
|
<div
|
|
113
118
|
className="wp-block-navigation__responsive-container-content"
|