@wordpress/block-library 7.11.0 → 7.12.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 (261) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/archives/edit.js +7 -0
  3. package/build/archives/edit.js.map +1 -1
  4. package/build/archives/index.js +4 -0
  5. package/build/archives/index.js.map +1 -1
  6. package/build/block/edit.js +4 -2
  7. package/build/block/edit.js.map +1 -1
  8. package/build/block/edit.native.js +4 -2
  9. package/build/block/edit.native.js.map +1 -1
  10. package/build/calendar/edit.js +12 -5
  11. package/build/calendar/edit.js.map +1 -1
  12. package/build/columns/edit.native.js +2 -1
  13. package/build/columns/edit.native.js.map +1 -1
  14. package/build/cover/edit/resizable-cover.js +6 -0
  15. package/build/cover/edit/resizable-cover.js.map +1 -1
  16. package/build/group/transforms.js +5 -0
  17. package/build/group/transforms.js.map +1 -1
  18. package/build/index.native.js +17 -4
  19. package/build/index.native.js.map +1 -1
  20. package/build/list/index.js +6 -0
  21. package/build/list/index.js.map +1 -1
  22. package/build/list/v2/edit.js +16 -5
  23. package/build/list/v2/edit.js.map +1 -1
  24. package/build/list/v2/tag-name.js +31 -0
  25. package/build/list/v2/tag-name.js.map +1 -0
  26. package/build/list/v2/tag-name.native.js +32 -0
  27. package/build/list/v2/tag-name.native.js.map +1 -0
  28. package/build/list/v2/transforms.js +1 -11
  29. package/build/list/v2/transforms.js.map +1 -1
  30. package/build/list-item/edit.js +1 -0
  31. package/build/list-item/edit.js.map +1 -1
  32. package/build/list-item/edit.native.js +158 -0
  33. package/build/list-item/edit.native.js.map +1 -0
  34. package/build/list-item/icons.native.js +53 -0
  35. package/build/list-item/icons.native.js.map +1 -0
  36. package/build/list-item/list-style-type.native.js +136 -0
  37. package/build/list-item/list-style-type.native.js.map +1 -0
  38. package/build/media-text/deprecated.js +188 -66
  39. package/build/media-text/deprecated.js.map +1 -1
  40. package/build/media-text/edit.js +2 -1
  41. package/build/media-text/edit.js.map +1 -1
  42. package/build/media-text/media-container.js +1 -1
  43. package/build/media-text/media-container.js.map +1 -1
  44. package/build/navigation/edit/index.js +68 -123
  45. package/build/navigation/edit/index.js.map +1 -1
  46. package/build/navigation/edit/navigation-menu-selector.js +11 -14
  47. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  48. package/build/navigation/edit/placeholder/index.js +4 -2
  49. package/build/navigation/edit/placeholder/index.js.map +1 -1
  50. package/build/navigation/edit/responsive-wrapper.js +13 -3
  51. package/build/navigation/edit/responsive-wrapper.js.map +1 -1
  52. package/build/navigation/edit/use-create-navigation-menu.js +5 -1
  53. package/build/navigation/edit/use-create-navigation-menu.js.map +1 -1
  54. package/build/navigation/edit/use-inner-blocks.js +43 -0
  55. package/build/navigation/edit/use-inner-blocks.js.map +1 -0
  56. package/build/navigation/edit/utils.js +28 -0
  57. package/build/navigation/edit/utils.js.map +1 -0
  58. package/build/navigation/use-navigation-menu.js +7 -3
  59. package/build/navigation/use-navigation-menu.js.map +1 -1
  60. package/build/post-author/edit.js +5 -2
  61. package/build/post-author/edit.js.map +1 -1
  62. package/build/post-author-biography/edit.js +7 -1
  63. package/build/post-author-biography/edit.js.map +1 -1
  64. package/build/post-content/edit.js +4 -2
  65. package/build/post-content/edit.js.map +1 -1
  66. package/build/post-featured-image/edit.js +16 -2
  67. package/build/post-featured-image/edit.js.map +1 -1
  68. package/build/post-featured-image/index.js +9 -0
  69. package/build/post-featured-image/index.js.map +1 -1
  70. package/build/query/edit/inspector-controls/index.js +42 -9
  71. package/build/query/edit/inspector-controls/index.js.map +1 -1
  72. package/build/query/edit/inspector-controls/taxonomy-controls.js +21 -14
  73. package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  74. package/build/query-title/edit.js +20 -7
  75. package/build/query-title/edit.js.map +1 -1
  76. package/build/query-title/index.js +4 -0
  77. package/build/query-title/index.js.map +1 -1
  78. package/build/query-title/variations.js +10 -0
  79. package/build/query-title/variations.js.map +1 -1
  80. package/build/quote/transforms.js +2 -2
  81. package/build/quote/transforms.js.map +1 -1
  82. package/build/separator/edit.js +1 -1
  83. package/build/separator/edit.js.map +1 -1
  84. package/build/social-links/edit.js +1 -0
  85. package/build/social-links/edit.js.map +1 -1
  86. package/build/template-part/edit/index.js +4 -2
  87. package/build/template-part/edit/index.js.map +1 -1
  88. package/build-module/archives/edit.js +7 -0
  89. package/build-module/archives/edit.js.map +1 -1
  90. package/build-module/archives/index.js +4 -0
  91. package/build-module/archives/index.js.map +1 -1
  92. package/build-module/block/edit.js +5 -3
  93. package/build-module/block/edit.js.map +1 -1
  94. package/build-module/block/edit.native.js +5 -3
  95. package/build-module/block/edit.native.js.map +1 -1
  96. package/build-module/calendar/edit.js +12 -4
  97. package/build-module/calendar/edit.js.map +1 -1
  98. package/build-module/columns/edit.native.js +3 -2
  99. package/build-module/columns/edit.native.js.map +1 -1
  100. package/build-module/cover/edit/resizable-cover.js +6 -0
  101. package/build-module/cover/edit/resizable-cover.js.map +1 -1
  102. package/build-module/group/transforms.js +5 -0
  103. package/build-module/group/transforms.js.map +1 -1
  104. package/build-module/index.native.js +16 -4
  105. package/build-module/index.native.js.map +1 -1
  106. package/build-module/list/index.js +1 -1
  107. package/build-module/list/index.js.map +1 -1
  108. package/build-module/list/v2/edit.js +15 -5
  109. package/build-module/list/v2/edit.js.map +1 -1
  110. package/build-module/list/v2/tag-name.js +21 -0
  111. package/build-module/list/v2/tag-name.js.map +1 -0
  112. package/build-module/list/v2/tag-name.native.js +21 -0
  113. package/build-module/list/v2/tag-name.native.js.map +1 -0
  114. package/build-module/list/v2/transforms.js +1 -10
  115. package/build-module/list/v2/transforms.js.map +1 -1
  116. package/build-module/list-item/edit.js +1 -3
  117. package/build-module/list-item/edit.js.map +1 -1
  118. package/build-module/list-item/edit.native.js +141 -0
  119. package/build-module/list-item/edit.native.js.map +1 -0
  120. package/build-module/list-item/icons.native.js +37 -0
  121. package/build-module/list-item/icons.native.js.map +1 -0
  122. package/build-module/list-item/list-style-type.native.js +124 -0
  123. package/build-module/list-item/list-style-type.native.js.map +1 -0
  124. package/build-module/media-text/deprecated.js +189 -65
  125. package/build-module/media-text/deprecated.js.map +1 -1
  126. package/build-module/media-text/edit.js +2 -1
  127. package/build-module/media-text/edit.js.map +1 -1
  128. package/build-module/media-text/media-container.js +1 -1
  129. package/build-module/media-text/media-container.js.map +1 -1
  130. package/build-module/navigation/edit/index.js +66 -122
  131. package/build-module/navigation/edit/index.js.map +1 -1
  132. package/build-module/navigation/edit/navigation-menu-selector.js +12 -15
  133. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  134. package/build-module/navigation/edit/placeholder/index.js +4 -2
  135. package/build-module/navigation/edit/placeholder/index.js.map +1 -1
  136. package/build-module/navigation/edit/responsive-wrapper.js +12 -3
  137. package/build-module/navigation/edit/responsive-wrapper.js.map +1 -1
  138. package/build-module/navigation/edit/use-create-navigation-menu.js +5 -1
  139. package/build-module/navigation/edit/use-create-navigation-menu.js.map +1 -1
  140. package/build-module/navigation/edit/use-inner-blocks.js +33 -0
  141. package/build-module/navigation/edit/use-inner-blocks.js.map +1 -0
  142. package/build-module/navigation/edit/utils.js +21 -0
  143. package/build-module/navigation/edit/utils.js.map +1 -0
  144. package/build-module/navigation/use-navigation-menu.js +7 -3
  145. package/build-module/navigation/use-navigation-menu.js.map +1 -1
  146. package/build-module/post-author/edit.js +5 -2
  147. package/build-module/post-author/edit.js.map +1 -1
  148. package/build-module/post-author-biography/edit.js +6 -1
  149. package/build-module/post-author-biography/edit.js.map +1 -1
  150. package/build-module/post-content/edit.js +5 -3
  151. package/build-module/post-content/edit.js.map +1 -1
  152. package/build-module/post-featured-image/edit.js +17 -3
  153. package/build-module/post-featured-image/edit.js.map +1 -1
  154. package/build-module/post-featured-image/index.js +9 -0
  155. package/build-module/post-featured-image/index.js.map +1 -1
  156. package/build-module/query/edit/inspector-controls/index.js +42 -9
  157. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  158. package/build-module/query/edit/inspector-controls/taxonomy-controls.js +16 -12
  159. package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  160. package/build-module/query-title/edit.js +20 -8
  161. package/build-module/query-title/edit.js.map +1 -1
  162. package/build-module/query-title/index.js +4 -0
  163. package/build-module/query-title/index.js.map +1 -1
  164. package/build-module/query-title/variations.js +10 -0
  165. package/build-module/query-title/variations.js.map +1 -1
  166. package/build-module/quote/transforms.js +3 -3
  167. package/build-module/quote/transforms.js.map +1 -1
  168. package/build-module/separator/edit.js +1 -1
  169. package/build-module/separator/edit.js.map +1 -1
  170. package/build-module/social-links/edit.js +1 -0
  171. package/build-module/social-links/edit.js.map +1 -1
  172. package/build-module/template-part/edit/index.js +5 -3
  173. package/build-module/template-part/edit/index.js.map +1 -1
  174. package/build-style/editor-rtl.css +10 -0
  175. package/build-style/editor.css +10 -0
  176. package/build-style/latest-posts/editor-rtl.css +3 -0
  177. package/build-style/latest-posts/editor.css +3 -0
  178. package/build-style/navigation/style-rtl.css +17 -19
  179. package/build-style/navigation/style.css +17 -19
  180. package/build-style/query/editor-rtl.css +7 -0
  181. package/build-style/query/editor.css +7 -0
  182. package/build-style/query-pagination/style-rtl.css +6 -0
  183. package/build-style/query-pagination/style.css +6 -0
  184. package/build-style/search/style-rtl.css +2 -0
  185. package/build-style/search/style.css +2 -0
  186. package/build-style/style-rtl.css +26 -19
  187. package/build-style/style.css +26 -19
  188. package/build-style/tag-cloud/style-rtl.css +1 -0
  189. package/build-style/tag-cloud/style.css +1 -0
  190. package/package.json +28 -29
  191. package/src/archives/block.json +4 -0
  192. package/src/archives/edit.js +12 -1
  193. package/src/archives/index.php +5 -3
  194. package/src/audio/test/__snapshots__/edit.native.js.snap +16 -2
  195. package/src/block/edit.js +4 -4
  196. package/src/block/edit.native.js +4 -4
  197. package/src/calendar/edit.js +11 -4
  198. package/src/columns/edit.native.js +4 -2
  199. package/src/cover/edit/resizable-cover.js +6 -0
  200. package/src/cover/index.php +2 -2
  201. package/src/file/test/__snapshots__/edit.native.js.snap +32 -4
  202. package/src/group/transforms.js +7 -0
  203. package/src/home-link/index.php +8 -17
  204. package/src/image/test/edit.native.js +6 -10
  205. package/src/index.native.js +15 -2
  206. package/src/latest-posts/editor.scss +5 -0
  207. package/src/list/index.js +1 -1
  208. package/src/list/test/__snapshots__/edit.native.js.snap +133 -0
  209. package/src/list/test/edit.native.js +511 -7
  210. package/src/list/v2/edit.js +12 -4
  211. package/src/list/v2/tag-name.js +13 -0
  212. package/src/list/v2/tag-name.native.js +12 -0
  213. package/src/list/v2/transforms.js +1 -9
  214. package/src/list-item/edit.js +1 -1
  215. package/src/list-item/edit.native.js +148 -0
  216. package/src/list-item/icons.native.js +34 -0
  217. package/src/list-item/list-style-type.native.js +139 -0
  218. package/src/list-item/style.native.scss +45 -0
  219. package/src/media-text/deprecated.js +561 -415
  220. package/src/media-text/edit.js +1 -0
  221. package/src/media-text/media-container.js +3 -1
  222. package/src/media-text/test/media-container.js +24 -0
  223. package/src/navigation/edit/index.js +83 -164
  224. package/src/navigation/edit/navigation-menu-selector.js +12 -26
  225. package/src/navigation/edit/placeholder/index.js +4 -2
  226. package/src/navigation/edit/responsive-wrapper.js +24 -3
  227. package/src/navigation/edit/use-create-navigation-menu.js +4 -0
  228. package/src/navigation/edit/use-inner-blocks.js +39 -0
  229. package/src/navigation/edit/utils.js +30 -0
  230. package/src/navigation/index.php +6 -0
  231. package/src/navigation/style.scss +12 -22
  232. package/src/navigation/use-navigation-menu.js +9 -5
  233. package/src/navigation-link/index.php +1 -1
  234. package/src/navigation-submenu/index.php +1 -1
  235. package/src/page-list/index.php +4 -4
  236. package/src/post-author/edit.js +6 -3
  237. package/src/post-author-biography/edit.js +4 -1
  238. package/src/post-content/edit.js +4 -4
  239. package/src/post-featured-image/block.json +9 -0
  240. package/src/post-featured-image/edit.js +23 -1
  241. package/src/post-featured-image/index.php +3 -1
  242. package/src/post-title/index.php +2 -1
  243. package/src/preformatted/test/__snapshots__/edit.native.js.snap +16 -2
  244. package/src/query/edit/inspector-controls/index.js +129 -65
  245. package/src/query/edit/inspector-controls/taxonomy-controls.js +17 -10
  246. package/src/query/editor.scss +9 -0
  247. package/src/query-pagination/style.scss +14 -0
  248. package/src/query-title/block.json +4 -0
  249. package/src/query-title/edit.js +33 -6
  250. package/src/query-title/index.php +17 -1
  251. package/src/query-title/variations.js +13 -0
  252. package/src/quote/transforms.js +3 -7
  253. package/src/search/style.scss +2 -0
  254. package/src/search/test/__snapshots__/edit.native.js.snap +56 -7
  255. package/src/separator/edit.js +1 -1
  256. package/src/separator/test/edit.js +5 -3
  257. package/src/site-title/index.php +8 -9
  258. package/src/social-link/index.php +1 -1
  259. package/src/social-links/edit.js +1 -0
  260. package/src/tag-cloud/style.scss +1 -0
  261. package/src/template-part/edit/index.js +4 -4
@@ -1,16 +1,520 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { render } from 'test/helpers';
4
+ import {
5
+ changeTextOfRichText,
6
+ fireEvent,
7
+ getEditorHtml,
8
+ initializeEditor,
9
+ waitFor,
10
+ within,
11
+ } from 'test/helpers';
5
12
 
6
13
  /**
7
- * Internal dependencies
14
+ * WordPress dependencies
8
15
  */
9
- import ListEdit from '../edit';
16
+ import { getBlockTypes, unregisterBlockType } from '@wordpress/blocks';
17
+ import { registerCoreBlocks } from '@wordpress/block-library';
10
18
 
11
- describe( 'ListEdit component', () => {
12
- it( 'renders without crashing', () => {
13
- const screen = render( <ListEdit attributes={ {} } /> );
14
- expect( screen.container ).toBeTruthy();
19
+ describe( 'List block', () => {
20
+ beforeAll( () => {
21
+ // Register all core blocks
22
+ registerCoreBlocks( {
23
+ __experimentalEnableListBlockV2: false,
24
+ } );
25
+ } );
26
+
27
+ afterAll( () => {
28
+ // Clean up registered blocks
29
+ getBlockTypes().forEach( ( block ) => {
30
+ unregisterBlockType( block.name );
31
+ } );
32
+ } );
33
+
34
+ it( 'inserts block', async () => {
35
+ const { getByA11yLabel, getByTestId, getByText } =
36
+ await initializeEditor();
37
+
38
+ fireEvent.press( getByA11yLabel( 'Add block' ) );
39
+
40
+ const blockList = getByTestId( 'InserterUI-Blocks' );
41
+ // onScroll event used to force the FlatList to render all items
42
+ fireEvent.scroll( blockList, {
43
+ nativeEvent: {
44
+ contentOffset: { y: 0, x: 0 },
45
+ contentSize: { width: 100, height: 100 },
46
+ layoutMeasurement: { width: 100, height: 100 },
47
+ },
48
+ } );
49
+
50
+ fireEvent.press( await waitFor( () => getByText( 'List' ) ) );
51
+
52
+ expect( getByA11yLabel( /List Block\. Row 1/ ) ).toBeVisible();
53
+ expect( getEditorHtml() ).toMatchSnapshot();
54
+ } );
55
+
56
+ it( 'renders a list with a few items', async () => {
57
+ const initialHtml = `<!-- wp:list -->
58
+ <ul><li>Item 1</li><li>Item 2</li><li>Item 3</li></ul>
59
+ <!-- /wp:list -->`;
60
+
61
+ const { getByA11yLabel } = await initializeEditor( {
62
+ initialHtml,
63
+ } );
64
+
65
+ // Select List block
66
+ const listBlock = getByA11yLabel( /List Block\. Row 1/ );
67
+ fireEvent.press( listBlock );
68
+
69
+ expect( getEditorHtml() ).toMatchSnapshot();
70
+ } );
71
+ } );
72
+
73
+ describe( 'List V2 block', () => {
74
+ beforeAll( () => {
75
+ // Register all core blocks
76
+ registerCoreBlocks( {
77
+ __experimentalEnableListBlockV2: true,
78
+ } );
79
+ } );
80
+
81
+ afterAll( () => {
82
+ // Clean up registered blocks
83
+ getBlockTypes().forEach( ( block ) => {
84
+ unregisterBlockType( block.name );
85
+ } );
86
+ } );
87
+
88
+ it( 'inserts block', async () => {
89
+ const { getByA11yLabel, getByTestId, getByText } =
90
+ await initializeEditor();
91
+
92
+ fireEvent.press( getByA11yLabel( 'Add block' ) );
93
+
94
+ const blockList = getByTestId( 'InserterUI-Blocks' );
95
+ // onScroll event used to force the FlatList to render all items
96
+ fireEvent.scroll( blockList, {
97
+ nativeEvent: {
98
+ contentOffset: { y: 0, x: 0 },
99
+ contentSize: { width: 100, height: 100 },
100
+ layoutMeasurement: { width: 100, height: 100 },
101
+ },
102
+ } );
103
+
104
+ fireEvent.press( await waitFor( () => getByText( 'List' ) ) );
105
+
106
+ expect( getByA11yLabel( /List Block\. Row 1/ ) ).toBeVisible();
107
+ expect( getEditorHtml() ).toMatchSnapshot();
108
+ } );
109
+
110
+ it( 'adds one item to the list', async () => {
111
+ const initialHtml = `<!-- wp:list -->
112
+ <ul><!-- wp:list-item -->
113
+ <li></li><!-- /wp:list-item --></ul>
114
+ <!-- /wp:list -->`;
115
+
116
+ const { getByA11yLabel } = await initializeEditor( {
117
+ initialHtml,
118
+ } );
119
+
120
+ // Select List block
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
+ fireEvent.press( listBlock );
137
+
138
+ // Select List Item block
139
+ const listItemBlock = getByA11yLabel( /List item Block\. Row 1/ );
140
+ fireEvent.press( listItemBlock );
141
+
142
+ const listItemField =
143
+ within( listBlock ).getByPlaceholderText( 'List' );
144
+ changeTextOfRichText( listItemField, 'First list item' );
145
+
146
+ expect( getEditorHtml() ).toMatchSnapshot();
147
+ } );
148
+
149
+ it( 'shows different indentation levels', async () => {
150
+ const initialHtml = `<!-- wp:list -->
151
+ <ul><!-- wp:list-item -->
152
+ <li>List item 1</li>
153
+ <!-- /wp:list-item -->
154
+ <!-- wp:list-item -->
155
+ <li>List item 2<!-- wp:list -->
156
+ <ul><!-- wp:list-item -->
157
+ <li>List item nested 1</li>
158
+ <!-- /wp:list-item -->
159
+ <!-- wp:list-item -->
160
+ <li>List item nested 2<!-- wp:list -->
161
+ <ul><!-- wp:list-item -->
162
+ <li>Extra item 1</li>
163
+ <!-- /wp:list-item -->
164
+ <!-- wp:list-item -->
165
+ <li>Extra item 2</li>
166
+ <!-- /wp:list-item --></ul>
167
+ <!-- /wp:list --></li>
168
+ <!-- /wp:list-item --></ul>
169
+ <!-- /wp:list --></li>
170
+ <!-- /wp:list-item -->
171
+ <!-- wp:list-item -->
172
+ <li>List item 3</li>
173
+ <!-- /wp:list-item --></ul>
174
+ <!-- /wp:list -->`;
175
+
176
+ const { getByA11yLabel } = await initializeEditor( {
177
+ initialHtml,
178
+ } );
179
+
180
+ // Select List block
181
+ const listBlock = getByA11yLabel( /List Block\. Row 1/ );
182
+
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
+ fireEvent.press( listBlock );
197
+
198
+ // Select List Item block
199
+ const firstNestedLevelBlock = within( listBlock ).getByA11yLabel(
200
+ /List item Block\. Row 2/
201
+ );
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
+ fireEvent.press( firstNestedLevelBlock );
217
+
218
+ // Select second level list
219
+ const secondNestedLevelBlock = within(
220
+ firstNestedLevelBlock
221
+ ).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
+ fireEvent.press( secondNestedLevelBlock );
239
+
240
+ expect( getEditorHtml() ).toMatchSnapshot();
241
+ } );
242
+
243
+ it( 'changes the indentation level', async () => {
244
+ const initialHtml = `<!-- wp:list -->
245
+ <ul><!-- wp:list-item -->
246
+ <li>Item 1</li>
247
+ <!-- /wp:list-item -->
248
+ <!-- wp:list-item -->
249
+ <li>Item 2</li>
250
+ <!-- /wp:list-item --></ul>
251
+ <!-- /wp:list -->`;
252
+
253
+ const { getByA11yLabel } = await initializeEditor( {
254
+ initialHtml,
255
+ } );
256
+
257
+ // Select List block
258
+ 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
+ fireEvent.press( listBlock );
274
+
275
+ // Select Secont List Item block
276
+ const listItemBlock = getByA11yLabel( /List item Block\. Row 2/ );
277
+ fireEvent.press( listItemBlock );
278
+
279
+ // Update indentation
280
+ const indentButton = getByA11yLabel( 'Indent' );
281
+ fireEvent.press( indentButton );
282
+
283
+ expect( getEditorHtml() ).toMatchSnapshot();
284
+ } );
285
+
286
+ it( 'removes the indentation level', async () => {
287
+ const initialHtml = `<!-- wp:list -->
288
+ <ul><!-- wp:list-item -->
289
+ <li>Item 1<!-- wp:list -->
290
+ <ul><!-- wp:list-item -->
291
+ <li>Item 2</li>
292
+ <!-- /wp:list-item --></ul>
293
+ <!-- /wp:list --></li>
294
+ <!-- /wp:list-item --></ul>
295
+ <!-- /wp:list -->`;
296
+
297
+ const { getByA11yLabel } = await initializeEditor( {
298
+ initialHtml,
299
+ } );
300
+
301
+ // Select List block
302
+ 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
+ fireEvent.press( listBlock );
318
+
319
+ // Select List Item block
320
+ const firstNestedLevelBlock = within( listBlock ).getByA11yLabel(
321
+ /List item Block\. Row 1/
322
+ );
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
+ fireEvent.press( firstNestedLevelBlock );
338
+
339
+ // Select Inner block List
340
+ const innerBlockList = within( firstNestedLevelBlock ).getByA11yLabel(
341
+ /List Block\. Row 1/
342
+ );
343
+
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
+ // Select nested List Item block
358
+ const listItemBlock = within( innerBlockList ).getByA11yLabel(
359
+ /List item Block\. Row 1/
360
+ );
361
+ fireEvent.press( listItemBlock );
362
+
363
+ // Update indentation
364
+ const outdentButton = getByA11yLabel( 'Outdent' );
365
+ fireEvent.press( outdentButton );
366
+
367
+ expect( getEditorHtml() ).toMatchSnapshot();
368
+ } );
369
+
370
+ it( 'changes to ordered list', async () => {
371
+ const initialHtml = `<!-- wp:list -->
372
+ <ul><!-- wp:list-item -->
373
+ <li>Item 1</li>
374
+ <!-- /wp:list-item -->
375
+ <!-- wp:list-item -->
376
+ <li>Item 2</li>
377
+ <!-- /wp:list-item -->
378
+ <!-- wp:list-item -->
379
+ <li>Item 3</li>
380
+ <!-- /wp:list-item --></ul>
381
+ <!-- /wp:list -->`;
382
+
383
+ const { getByA11yLabel } = await initializeEditor( {
384
+ initialHtml,
385
+ } );
386
+
387
+ // Select List block
388
+ 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
+ fireEvent.press( listBlock );
404
+
405
+ // Update to ordered list
406
+ const orderedButton = getByA11yLabel( 'Ordered' );
407
+ fireEvent.press( orderedButton );
408
+
409
+ expect( getEditorHtml() ).toMatchSnapshot();
410
+ } );
411
+
412
+ it( 'changes to reverse ordered list', async () => {
413
+ const initialHtml = `<!-- wp:list -->
414
+ <ul><!-- wp:list-item -->
415
+ <li>Item 1</li>
416
+ <!-- /wp:list-item -->
417
+ <!-- wp:list-item -->
418
+ <li>Item 2</li>
419
+ <!-- /wp:list-item -->
420
+ <!-- wp:list-item -->
421
+ <li>Item 3</li>
422
+ <!-- /wp:list-item --></ul>
423
+ <!-- /wp:list -->`;
424
+
425
+ const { getByA11yLabel, getByTestId } = await initializeEditor( {
426
+ initialHtml,
427
+ } );
428
+
429
+ // Select List block
430
+ 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
+ fireEvent.press( listBlock );
446
+
447
+ // Update to ordered list
448
+ const orderedButton = getByA11yLabel( 'Ordered' );
449
+ fireEvent.press( orderedButton );
450
+
451
+ // Set order to reverse
452
+
453
+ // Open block settings
454
+ fireEvent.press( getByA11yLabel( 'Open Settings' ) );
455
+ await waitFor(
456
+ () => getByTestId( 'block-settings-modal' ).props.isVisible
457
+ );
458
+
459
+ const reverseButton = getByA11yLabel( /Reverse list numbering\. Off/ );
460
+ fireEvent.press( reverseButton );
461
+
462
+ expect( getEditorHtml() ).toMatchSnapshot();
463
+ } );
464
+
465
+ it( 'sets a start value to an ordered list', async () => {
466
+ const initialHtml = `<!-- wp:list -->
467
+ <ul><!-- wp:list-item -->
468
+ <li>Item 1</li>
469
+ <!-- /wp:list-item -->
470
+ <!-- wp:list-item -->
471
+ <li>Item 2</li>
472
+ <!-- /wp:list-item -->
473
+ <!-- wp:list-item -->
474
+ <li>Item 3</li>
475
+ <!-- /wp:list-item --></ul>
476
+ <!-- /wp:list -->`;
477
+
478
+ const { getByA11yLabel, getByTestId } = await initializeEditor( {
479
+ initialHtml,
480
+ } );
481
+
482
+ // Select List block
483
+ 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
+ fireEvent.press( listBlock );
499
+
500
+ // Update to ordered list
501
+ const orderedButton = getByA11yLabel( 'Ordered' );
502
+ fireEvent.press( orderedButton );
503
+
504
+ // Set order to reverse
505
+
506
+ // Open block settings
507
+ fireEvent.press( getByA11yLabel( 'Open Settings' ) );
508
+ await waitFor(
509
+ () => getByTestId( 'block-settings-modal' ).props.isVisible
510
+ );
511
+
512
+ const startValueButton = getByA11yLabel( /Start value\. Empty/ );
513
+ fireEvent.press( startValueButton );
514
+ const startValueInput =
515
+ within( startValueButton ).getByDisplayValue( '' );
516
+ fireEvent.changeText( startValueInput, '25' );
517
+
518
+ expect( getEditorHtml() ).toMatchSnapshot();
15
519
  } );
16
520
  } );
@@ -24,7 +24,7 @@ import {
24
24
  formatOutdentRTL,
25
25
  } from '@wordpress/icons';
26
26
  import { createBlock } from '@wordpress/blocks';
27
- import { useCallback, useEffect } from '@wordpress/element';
27
+ import { useCallback, useEffect, Platform } from '@wordpress/element';
28
28
  import deprecated from '@wordpress/deprecated';
29
29
 
30
30
  /**
@@ -32,8 +32,10 @@ import deprecated from '@wordpress/deprecated';
32
32
  */
33
33
  import OrderedListSettings from '../ordered-list-settings';
34
34
  import { migrateToListV2 } from './migrate';
35
+ import TagName from './tag-name';
35
36
 
36
37
  const TEMPLATE = [ [ 'core/list-item' ] ];
38
+ const NATIVE_MARGIN_SPACING = 8;
37
39
 
38
40
  /**
39
41
  * At the moment, deprecations don't handle create blocks from attributes
@@ -126,16 +128,21 @@ function IndentUI( { clientId } ) {
126
128
  );
127
129
  }
128
130
 
129
- function Edit( { attributes, setAttributes, clientId } ) {
130
- const blockProps = useBlockProps();
131
+ function Edit( { attributes, setAttributes, clientId, style } ) {
132
+ const blockProps = useBlockProps( {
133
+ ...( Platform.isNative && { style } ),
134
+ } );
131
135
  const innerBlocksProps = useInnerBlocksProps( blockProps, {
132
136
  allowedBlocks: [ 'core/list-item' ],
133
137
  template: TEMPLATE,
134
138
  templateInsertUpdatesSelection: true,
139
+ ...( Platform.isNative && {
140
+ marginVertical: NATIVE_MARGIN_SPACING,
141
+ marginHorizontal: NATIVE_MARGIN_SPACING,
142
+ } ),
135
143
  } );
136
144
  useMigrateOnLoad( attributes, clientId );
137
145
  const { ordered, reversed, start } = attributes;
138
- const TagName = ordered ? 'ol' : 'ul';
139
146
 
140
147
  const controls = (
141
148
  <BlockControls group="block">
@@ -164,6 +171,7 @@ function Edit( { attributes, setAttributes, clientId } ) {
164
171
  return (
165
172
  <>
166
173
  <TagName
174
+ ordered={ ordered }
167
175
  reversed={ reversed }
168
176
  start={ start }
169
177
  { ...innerBlocksProps }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { forwardRef } from '@wordpress/element';
5
+
6
+ function TagName( props, ref ) {
7
+ const { ordered, ...extraProps } = props;
8
+ const Tag = ordered ? 'ol' : 'ul';
9
+
10
+ return <Tag ref={ ref } { ...extraProps } />;
11
+ }
12
+
13
+ export default forwardRef( TagName );
@@ -0,0 +1,12 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { forwardRef } from '@wordpress/element';
5
+ import { View } from '@wordpress/primitives';
6
+
7
+ function TagName( props, ref ) {
8
+ const { start, ...extraProps } = props;
9
+ return <View ref={ ref } { ...extraProps } />;
10
+ }
11
+
12
+ export default forwardRef( TagName );
@@ -1,11 +1,3 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- /**
5
- * External dependencies
6
- */
7
- import { flatMap } from 'lodash';
8
-
9
1
  /**
10
2
  * WordPress dependencies
11
3
  */
@@ -39,7 +31,7 @@ function getListContentSchema( { phrasingContentSchema } ) {
39
31
  }
40
32
 
41
33
  function getListContentFlat( blocks ) {
42
- return flatMap( blocks, ( { name, attributes, innerBlocks = [] } ) => {
34
+ return blocks.flatMap( ( { name, attributes, innerBlocks = [] } ) => {
43
35
  if ( name === 'core/list-item' ) {
44
36
  return [ attributes.content, ...getListContentFlat( innerBlocks ) ];
45
37
  }
@@ -30,7 +30,7 @@ import {
30
30
  } from './hooks';
31
31
  import { convertToListItems } from './utils';
32
32
 
33
- function IndentUI( { clientId } ) {
33
+ export function IndentUI( { clientId } ) {
34
34
  const [ canIndent, indentListItem ] = useIndentListItem( clientId );
35
35
  const [ canOutdent, outdentListItem ] = useOutdentListItem( clientId );
36
36