@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.
Files changed (242) hide show
  1. package/build/columns/transforms.js +10 -1
  2. package/build/columns/transforms.js.map +1 -1
  3. package/build/cover/edit/block-controls.js +9 -2
  4. package/build/cover/edit/block-controls.js.map +1 -1
  5. package/build/gallery/gap-styles.js +5 -4
  6. package/build/gallery/gap-styles.js.map +1 -1
  7. package/build/home-link/index.js +14 -1
  8. package/build/home-link/index.js.map +1 -1
  9. package/build/image/edit.js +3 -1
  10. package/build/image/edit.js.map +1 -1
  11. package/build/image/use-client-width.js +3 -1
  12. package/build/image/use-client-width.js.map +1 -1
  13. package/build/index.js +1 -1
  14. package/build/index.js.map +1 -1
  15. package/build/index.native.js +3 -15
  16. package/build/index.native.js.map +1 -1
  17. package/build/latest-posts/deprecated.js +14 -1
  18. package/build/latest-posts/deprecated.js.map +1 -1
  19. package/build/latest-posts/index.js +14 -1
  20. package/build/latest-posts/index.js.map +1 -1
  21. package/build/list/deprecated.js +84 -1
  22. package/build/list/deprecated.js.map +1 -1
  23. package/build/list/edit.js +153 -134
  24. package/build/list/edit.js.map +1 -1
  25. package/build/list/index.js +29 -34
  26. package/build/list/index.js.map +1 -1
  27. package/build/list/save.js +1 -5
  28. package/build/list/save.js.map +1 -1
  29. package/build/list/{v2/tag-name.js → tag-name.js} +0 -0
  30. package/build/list/tag-name.js.map +1 -0
  31. package/build/list/{v2/tag-name.native.js → tag-name.native.js} +0 -0
  32. package/build/list/tag-name.native.js.map +1 -0
  33. package/build/list/transforms.js +61 -95
  34. package/build/list/transforms.js.map +1 -1
  35. package/build/list/{v2/migrate.js → utils.js} +3 -2
  36. package/build/list/utils.js.map +1 -0
  37. package/build/list-item/edit.native.js +21 -3
  38. package/build/list-item/edit.native.js.map +1 -1
  39. package/build/list-item/hooks/use-copy.js +2 -0
  40. package/build/list-item/hooks/use-copy.js.map +1 -1
  41. package/build/list-item/hooks/use-merge.js +0 -1
  42. package/build/list-item/hooks/use-merge.js.map +1 -1
  43. package/build/list-item/hooks/use-outdent-list-item.js +0 -1
  44. package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
  45. package/build/list-item/hooks/use-space.js +10 -1
  46. package/build/list-item/hooks/use-space.js.map +1 -1
  47. package/build/list-item/index.js +0 -1
  48. package/build/list-item/index.js.map +1 -1
  49. package/build/list-item/utils.js +0 -1
  50. package/build/list-item/utils.js.map +1 -1
  51. package/build/navigation/edit/index.js +6 -3
  52. package/build/navigation/edit/index.js.map +1 -1
  53. package/build/navigation/edit/responsive-wrapper.js +6 -4
  54. package/build/navigation/edit/responsive-wrapper.js.map +1 -1
  55. package/build/navigation/edit/unsaved-inner-blocks.js +4 -15
  56. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  57. package/build/post-excerpt/index.js +4 -2
  58. package/build/post-excerpt/index.js.map +1 -1
  59. package/build/post-terms/edit.js +0 -1
  60. package/build/post-terms/edit.js.map +1 -1
  61. package/build/post-terms/use-post-terms.js +4 -24
  62. package/build/post-terms/use-post-terms.js.map +1 -1
  63. package/build/query-no-results/index.js +13 -0
  64. package/build/query-no-results/index.js.map +1 -1
  65. package/build/query-pagination-numbers/index.js +4 -2
  66. package/build/query-pagination-numbers/index.js.map +1 -1
  67. package/build/query-title/index.js +1 -0
  68. package/build/query-title/index.js.map +1 -1
  69. package/build/quote/index.js +4 -2
  70. package/build/quote/index.js.map +1 -1
  71. package/build/term-description/index.js +6 -0
  72. package/build/term-description/index.js.map +1 -1
  73. package/build/verse/index.js +1 -0
  74. package/build/verse/index.js.map +1 -1
  75. package/build-module/columns/transforms.js +10 -1
  76. package/build-module/columns/transforms.js.map +1 -1
  77. package/build-module/cover/edit/block-controls.js +10 -3
  78. package/build-module/cover/edit/block-controls.js.map +1 -1
  79. package/build-module/gallery/gap-styles.js +6 -5
  80. package/build-module/gallery/gap-styles.js.map +1 -1
  81. package/build-module/home-link/index.js +14 -1
  82. package/build-module/home-link/index.js.map +1 -1
  83. package/build-module/image/edit.js +4 -2
  84. package/build-module/image/edit.js.map +1 -1
  85. package/build-module/image/use-client-width.js +3 -1
  86. package/build-module/image/use-client-width.js.map +1 -1
  87. package/build-module/index.js +1 -1
  88. package/build-module/index.js.map +1 -1
  89. package/build-module/index.native.js +3 -15
  90. package/build-module/index.native.js.map +1 -1
  91. package/build-module/latest-posts/deprecated.js +14 -1
  92. package/build-module/latest-posts/deprecated.js.map +1 -1
  93. package/build-module/latest-posts/index.js +14 -1
  94. package/build-module/latest-posts/index.js.map +1 -1
  95. package/build-module/list/deprecated.js +83 -1
  96. package/build-module/list/deprecated.js.map +1 -1
  97. package/build-module/list/edit.js +151 -134
  98. package/build-module/list/edit.js.map +1 -1
  99. package/build-module/list/index.js +29 -29
  100. package/build-module/list/index.js.map +1 -1
  101. package/build-module/list/save.js +2 -6
  102. package/build-module/list/save.js.map +1 -1
  103. package/build-module/list/{v2/tag-name.js → tag-name.js} +0 -0
  104. package/build-module/list/tag-name.js.map +1 -0
  105. package/build-module/list/{v2/tag-name.native.js → tag-name.native.js} +0 -0
  106. package/build-module/list/tag-name.native.js.map +1 -0
  107. package/build-module/list/transforms.js +62 -97
  108. package/build-module/list/transforms.js.map +1 -1
  109. package/build-module/list/{v2/migrate.js → utils.js} +3 -2
  110. package/build-module/list/utils.js.map +1 -0
  111. package/build-module/list-item/edit.native.js +19 -3
  112. package/build-module/list-item/edit.native.js.map +1 -1
  113. package/build-module/list-item/hooks/use-copy.js +2 -0
  114. package/build-module/list-item/hooks/use-copy.js.map +1 -1
  115. package/build-module/list-item/hooks/use-merge.js +0 -1
  116. package/build-module/list-item/hooks/use-merge.js.map +1 -1
  117. package/build-module/list-item/hooks/use-outdent-list-item.js +0 -1
  118. package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
  119. package/build-module/list-item/hooks/use-space.js +10 -1
  120. package/build-module/list-item/hooks/use-space.js.map +1 -1
  121. package/build-module/list-item/index.js +0 -1
  122. package/build-module/list-item/index.js.map +1 -1
  123. package/build-module/list-item/utils.js +0 -1
  124. package/build-module/list-item/utils.js.map +1 -1
  125. package/build-module/navigation/edit/index.js +5 -3
  126. package/build-module/navigation/edit/index.js.map +1 -1
  127. package/build-module/navigation/edit/responsive-wrapper.js +6 -4
  128. package/build-module/navigation/edit/responsive-wrapper.js.map +1 -1
  129. package/build-module/navigation/edit/unsaved-inner-blocks.js +5 -15
  130. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  131. package/build-module/post-excerpt/index.js +4 -2
  132. package/build-module/post-excerpt/index.js.map +1 -1
  133. package/build-module/post-terms/edit.js +0 -1
  134. package/build-module/post-terms/edit.js.map +1 -1
  135. package/build-module/post-terms/use-post-terms.js +5 -25
  136. package/build-module/post-terms/use-post-terms.js.map +1 -1
  137. package/build-module/query-no-results/index.js +13 -0
  138. package/build-module/query-no-results/index.js.map +1 -1
  139. package/build-module/query-pagination-numbers/index.js +4 -2
  140. package/build-module/query-pagination-numbers/index.js.map +1 -1
  141. package/build-module/query-title/index.js +1 -0
  142. package/build-module/query-title/index.js.map +1 -1
  143. package/build-module/quote/index.js +4 -2
  144. package/build-module/quote/index.js.map +1 -1
  145. package/build-module/term-description/index.js +6 -0
  146. package/build-module/term-description/index.js.map +1 -1
  147. package/build-module/verse/index.js +1 -0
  148. package/build-module/verse/index.js.map +1 -1
  149. package/build-style/button/style-rtl.css +1 -4
  150. package/build-style/button/style.css +1 -4
  151. package/build-style/code/editor-rtl.css +79 -0
  152. package/build-style/code/editor.css +79 -0
  153. package/build-style/cover/editor-rtl.css +0 -3
  154. package/build-style/cover/editor.css +0 -3
  155. package/build-style/editor-rtl.css +9 -44
  156. package/build-style/editor.css +9 -44
  157. package/build-style/group/editor-rtl.css +2 -22
  158. package/build-style/group/editor.css +2 -22
  159. package/build-style/navigation/editor-rtl.css +3 -19
  160. package/build-style/navigation/editor.css +3 -19
  161. package/build-style/navigation/style-rtl.css +8 -1
  162. package/build-style/navigation/style.css +8 -1
  163. package/build-style/style-rtl.css +9 -5
  164. package/build-style/style.css +9 -5
  165. package/package.json +28 -28
  166. package/src/button/style.scss +1 -8
  167. package/src/code/editor.scss +3 -0
  168. package/src/columns/transforms.js +17 -3
  169. package/src/cover/edit/block-controls.js +15 -3
  170. package/src/cover/editor.scss +0 -4
  171. package/src/editor.scss +1 -0
  172. package/src/gallery/gap-styles.js +10 -6
  173. package/src/gallery/index.php +23 -2
  174. package/src/group/editor.scss +1 -28
  175. package/src/home-link/block.json +14 -1
  176. package/src/image/edit.js +3 -3
  177. package/src/image/use-client-width.js +1 -1
  178. package/src/index.js +1 -4
  179. package/src/index.native.js +2 -13
  180. package/src/latest-posts/block.json +14 -1
  181. package/src/list/deprecated.js +71 -1
  182. package/src/list/edit.js +146 -133
  183. package/src/list/index.js +25 -24
  184. package/src/list/save.js +3 -4
  185. package/src/list/{v2/tag-name.js → tag-name.js} +0 -0
  186. package/src/list/{v2/tag-name.native.js → tag-name.native.js} +0 -0
  187. package/src/list/test/__snapshots__/edit.native.js.snap +14 -2
  188. package/src/list/test/edit.native.js +0 -154
  189. package/src/list/transforms.js +57 -111
  190. package/src/list/{v2/migrate.js → utils.js} +2 -2
  191. package/src/list-item/block.json +0 -1
  192. package/src/list-item/edit.native.js +32 -2
  193. package/src/list-item/hooks/use-copy.js +2 -0
  194. package/src/list-item/hooks/use-space.js +10 -2
  195. package/src/list-item/style.native.scss +8 -0
  196. package/src/navigation/edit/index.js +14 -4
  197. package/src/navigation/edit/responsive-wrapper.js +8 -3
  198. package/src/navigation/edit/unsaved-inner-blocks.js +14 -24
  199. package/src/navigation/editor.scss +2 -23
  200. package/src/navigation/index.php +13 -8
  201. package/src/navigation/style.scss +11 -2
  202. package/src/post-excerpt/block.json +4 -2
  203. package/src/post-terms/edit.js +0 -1
  204. package/src/post-terms/use-post-terms.js +10 -15
  205. package/src/query-no-results/block.json +13 -0
  206. package/src/query-pagination-numbers/block.json +4 -2
  207. package/src/query-title/block.json +1 -0
  208. package/src/quote/block.json +4 -2
  209. package/src/term-description/block.json +6 -0
  210. package/src/verse/block.json +1 -0
  211. package/build/list/v2/deprecated.js +0 -117
  212. package/build/list/v2/deprecated.js.map +0 -1
  213. package/build/list/v2/edit.js +0 -200
  214. package/build/list/v2/edit.js.map +0 -1
  215. package/build/list/v2/index.js +0 -36
  216. package/build/list/v2/index.js.map +0 -1
  217. package/build/list/v2/migrate.js.map +0 -1
  218. package/build/list/v2/save.js +0 -34
  219. package/build/list/v2/save.js.map +0 -1
  220. package/build/list/v2/tag-name.js.map +0 -1
  221. package/build/list/v2/tag-name.native.js.map +0 -1
  222. package/build/list/v2/transforms.js +0 -137
  223. package/build/list/v2/transforms.js.map +0 -1
  224. package/build-module/list/v2/deprecated.js +0 -104
  225. package/build-module/list/v2/deprecated.js.map +0 -1
  226. package/build-module/list/v2/edit.js +0 -179
  227. package/build-module/list/v2/edit.js.map +0 -1
  228. package/build-module/list/v2/index.js +0 -21
  229. package/build-module/list/v2/index.js.map +0 -1
  230. package/build-module/list/v2/migrate.js.map +0 -1
  231. package/build-module/list/v2/save.js +0 -23
  232. package/build-module/list/v2/save.js.map +0 -1
  233. package/build-module/list/v2/tag-name.js.map +0 -1
  234. package/build-module/list/v2/tag-name.native.js.map +0 -1
  235. package/build-module/list/v2/transforms.js +0 -127
  236. package/build-module/list/v2/transforms.js.map +0 -1
  237. package/src/list/test/migrate.js +0 -158
  238. package/src/list/v2/deprecated.js +0 -89
  239. package/src/list/v2/edit.js +0 -192
  240. package/src/list/v2/index.js +0 -22
  241. package/src/list/v2/save.js +0 -18
  242. 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
@@ -1,15 +1,13 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { createBlock, getBlockAttributes } from '@wordpress/blocks';
5
- import {
6
- __UNSTABLE_LINE_SEPARATOR,
7
- create,
8
- join,
9
- replace,
10
- split,
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
- return createBlock( 'core/list', {
43
- values: toHTMLString( {
44
- value: join(
45
- blockAttributes.map( ( { content } ) => {
46
- const value = create( { html: content } );
47
-
48
- if ( blockAttributes.length > 1 ) {
49
- return value;
50
- }
51
-
52
- // When converting only one block, transform
53
- // every line to a list item.
54
- return replace(
55
- value,
56
- /\n/g,
57
- __UNSTABLE_LINE_SEPARATOR
58
- );
59
- } ),
60
- __UNSTABLE_LINE_SEPARATOR
61
- ),
62
- multilineTag: 'li',
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( node ) {
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
- values: `<li>${ content }</li>`,
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( 'core/list', {
123
- ordered: true,
124
- values: `<li>${ content }</li>`,
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: [ 'core/paragraph' ],
133
- transform: ( { values } ) =>
134
- split(
135
- create( {
136
- html: values,
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
 
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "$schema": "https://schemas.wp.org/trunk/block.json",
3
3
  "apiVersion": 2,
4
- "__experimental": "list-v2",
5
4
  "name": "core/list-item",
6
5
  "title": "List item",
7
6
  "category": "text",
@@ -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
- renderAppender: false,
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={ 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
- event.keyCode !== SPACE ||
25
- ! canIndent
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 (
@@ -47,3 +47,11 @@
47
47
  .wp-block-list-item__list-item-container {
48
48
  margin-right: 8;
49
49
  }
50
+
51
+ .wp-block-list-item__list-item-placeholder {
52
+ color: $gray;
53
+ }
54
+
55
+ .wp-block-list-item__list-item-placeholder--dark {
56
+ color: $gray-50;
57
+ }
@@ -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 && <OverlayMenuIcon /> }
469
- { ! hasIcon && <span>{ __( 'Menu' ) }</span> }
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"