@wordpress/block-editor 11.1.0 → 11.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (201) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE.md +1 -1
  3. package/build/components/block-actions/index.js +9 -0
  4. package/build/components/block-actions/index.js.map +1 -1
  5. package/build/components/block-inspector/index.js +4 -2
  6. package/build/components/block-inspector/index.js.map +1 -1
  7. package/build/components/block-preview/auto.js +1 -4
  8. package/build/components/block-preview/auto.js.map +1 -1
  9. package/build/components/block-settings-menu/block-settings-dropdown.js +4 -1
  10. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  11. package/build/components/block-styles/index.js +3 -1
  12. package/build/components/block-styles/index.js.map +1 -1
  13. package/build/components/block-tools/use-block-toolbar-popover-props.js +43 -10
  14. package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
  15. package/build/components/default-style-picker/index.js +1 -0
  16. package/build/components/default-style-picker/index.js.map +1 -1
  17. package/build/components/font-sizes/with-font-sizes.js +5 -8
  18. package/build/components/font-sizes/with-font-sizes.js.map +1 -1
  19. package/build/components/iframe/index.js +37 -8
  20. package/build/components/iframe/index.js.map +1 -1
  21. package/build/components/iframe/use-compatibility-styles.js +6 -1
  22. package/build/components/iframe/use-compatibility-styles.js.map +1 -1
  23. package/build/components/image-size-control/index.js +1 -0
  24. package/build/components/image-size-control/index.js.map +1 -1
  25. package/build/components/inserter/block-patterns-tab.js +4 -4
  26. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  27. package/build/components/inserter/index.js +3 -2
  28. package/build/components/inserter/index.js.map +1 -1
  29. package/build/components/inserter/menu.js +11 -5
  30. package/build/components/inserter/menu.js.map +1 -1
  31. package/build/components/inspector-controls/groups.js +3 -1
  32. package/build/components/inspector-controls/groups.js.map +1 -1
  33. package/build/components/inspector-controls-tabs/position-controls-panel.js +46 -0
  34. package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -0
  35. package/build/components/inspector-controls-tabs/settings-tab.js +3 -1
  36. package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -1
  37. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +4 -11
  38. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  39. package/build/components/link-control/search-input.js +1 -0
  40. package/build/components/link-control/search-input.js.map +1 -1
  41. package/build/components/off-canvas-editor/appender.js +2 -38
  42. package/build/components/off-canvas-editor/appender.js.map +1 -1
  43. package/build/components/off-canvas-editor/block-contents.js +38 -5
  44. package/build/components/off-canvas-editor/block-contents.js.map +1 -1
  45. package/build/components/off-canvas-editor/block.js +7 -25
  46. package/build/components/off-canvas-editor/block.js.map +1 -1
  47. package/build/components/off-canvas-editor/index.js +7 -4
  48. package/build/components/off-canvas-editor/index.js.map +1 -1
  49. package/build/components/provider/index.js +3 -1
  50. package/build/components/provider/index.js.map +1 -1
  51. package/build/components/rich-text/use-enter.js +4 -5
  52. package/build/components/rich-text/use-enter.js.map +1 -1
  53. package/build/components/url-input/button.js +1 -0
  54. package/build/components/url-input/button.js.map +1 -1
  55. package/build/components/url-input/index.js +15 -1
  56. package/build/components/url-input/index.js.map +1 -1
  57. package/build/components/url-popover/link-editor.js +1 -0
  58. package/build/components/url-popover/link-editor.js.map +1 -1
  59. package/build/components/use-paste-styles/index.js +188 -0
  60. package/build/components/use-paste-styles/index.js.map +1 -0
  61. package/build/components/writing-flow/use-arrow-nav.js +22 -29
  62. package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
  63. package/build/hooks/index.js +2 -0
  64. package/build/hooks/index.js.map +1 -1
  65. package/build/hooks/metadata.js +1 -1
  66. package/build/hooks/metadata.js.map +1 -1
  67. package/build/hooks/position.js +376 -0
  68. package/build/hooks/position.js.map +1 -0
  69. package/build/hooks/supports.js +328 -0
  70. package/build/hooks/supports.js.map +1 -0
  71. package/build/store/reducer.js +6 -2
  72. package/build/store/reducer.js.map +1 -1
  73. package/build/store/selectors.js +8 -6
  74. package/build/store/selectors.js.map +1 -1
  75. package/build-module/components/block-actions/index.js +6 -0
  76. package/build-module/components/block-actions/index.js.map +1 -1
  77. package/build-module/components/block-inspector/index.js +3 -2
  78. package/build-module/components/block-inspector/index.js.map +1 -1
  79. package/build-module/components/block-preview/auto.js +1 -4
  80. package/build-module/components/block-preview/auto.js.map +1 -1
  81. package/build-module/components/block-settings-menu/block-settings-dropdown.js +4 -1
  82. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  83. package/build-module/components/block-styles/index.js +2 -1
  84. package/build-module/components/block-styles/index.js.map +1 -1
  85. package/build-module/components/block-tools/use-block-toolbar-popover-props.js +42 -11
  86. package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
  87. package/build-module/components/default-style-picker/index.js +1 -0
  88. package/build-module/components/default-style-picker/index.js.map +1 -1
  89. package/build-module/components/font-sizes/with-font-sizes.js +5 -7
  90. package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
  91. package/build-module/components/iframe/index.js +36 -9
  92. package/build-module/components/iframe/index.js.map +1 -1
  93. package/build-module/components/iframe/use-compatibility-styles.js +6 -1
  94. package/build-module/components/iframe/use-compatibility-styles.js.map +1 -1
  95. package/build-module/components/image-size-control/index.js +1 -0
  96. package/build-module/components/image-size-control/index.js.map +1 -1
  97. package/build-module/components/inserter/block-patterns-tab.js +4 -4
  98. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  99. package/build-module/components/inserter/index.js +3 -2
  100. package/build-module/components/inserter/index.js.map +1 -1
  101. package/build-module/components/inserter/menu.js +11 -5
  102. package/build-module/components/inserter/menu.js.map +1 -1
  103. package/build-module/components/inspector-controls/groups.js +3 -1
  104. package/build-module/components/inspector-controls/groups.js.map +1 -1
  105. package/build-module/components/inspector-controls-tabs/position-controls-panel.js +33 -0
  106. package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -0
  107. package/build-module/components/inspector-controls-tabs/settings-tab.js +2 -1
  108. package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -1
  109. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +4 -11
  110. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  111. package/build-module/components/link-control/search-input.js +1 -0
  112. package/build-module/components/link-control/search-input.js.map +1 -1
  113. package/build-module/components/off-canvas-editor/appender.js +3 -36
  114. package/build-module/components/off-canvas-editor/appender.js.map +1 -1
  115. package/build-module/components/off-canvas-editor/block-contents.js +37 -7
  116. package/build-module/components/off-canvas-editor/block-contents.js.map +1 -1
  117. package/build-module/components/off-canvas-editor/block.js +9 -27
  118. package/build-module/components/off-canvas-editor/block.js.map +1 -1
  119. package/build-module/components/off-canvas-editor/index.js +7 -4
  120. package/build-module/components/off-canvas-editor/index.js.map +1 -1
  121. package/build-module/components/provider/index.js +3 -1
  122. package/build-module/components/provider/index.js.map +1 -1
  123. package/build-module/components/rich-text/use-enter.js +4 -5
  124. package/build-module/components/rich-text/use-enter.js.map +1 -1
  125. package/build-module/components/url-input/button.js +1 -0
  126. package/build-module/components/url-input/button.js.map +1 -1
  127. package/build-module/components/url-input/index.js +14 -1
  128. package/build-module/components/url-input/index.js.map +1 -1
  129. package/build-module/components/url-popover/link-editor.js +1 -0
  130. package/build-module/components/url-popover/link-editor.js.map +1 -1
  131. package/build-module/components/use-paste-styles/index.js +174 -0
  132. package/build-module/components/use-paste-styles/index.js.map +1 -0
  133. package/build-module/components/writing-flow/use-arrow-nav.js +22 -29
  134. package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
  135. package/build-module/hooks/index.js +1 -0
  136. package/build-module/hooks/index.js.map +1 -1
  137. package/build-module/hooks/metadata.js +1 -1
  138. package/build-module/hooks/metadata.js.map +1 -1
  139. package/build-module/hooks/position.js +337 -0
  140. package/build-module/hooks/position.js.map +1 -0
  141. package/build-module/hooks/supports.js +257 -0
  142. package/build-module/hooks/supports.js.map +1 -0
  143. package/build-module/store/reducer.js +6 -2
  144. package/build-module/store/reducer.js.map +1 -1
  145. package/build-module/store/selectors.js +7 -5
  146. package/build-module/store/selectors.js.map +1 -1
  147. package/build-style/content-rtl.css +57 -0
  148. package/build-style/content.css +57 -0
  149. package/build-style/style-rtl.css +27 -58
  150. package/build-style/style.css +27 -58
  151. package/package.json +29 -29
  152. package/src/components/block-actions/index.js +5 -0
  153. package/src/components/block-inspector/index.js +3 -1
  154. package/src/components/block-preview/auto.js +2 -4
  155. package/src/components/block-settings-menu/block-settings-dropdown.js +4 -0
  156. package/src/components/block-styles/index.js +4 -1
  157. package/src/components/block-tools/use-block-toolbar-popover-props.js +68 -12
  158. package/src/components/button-block-appender/{style.scss → content.scss} +0 -0
  159. package/src/components/default-style-picker/index.js +1 -0
  160. package/src/components/font-sizes/with-font-sizes.js +33 -33
  161. package/src/components/iframe/index.js +52 -19
  162. package/src/components/iframe/use-compatibility-styles.js +6 -0
  163. package/src/components/image-size-control/index.js +1 -0
  164. package/src/components/inserter/block-patterns-tab.js +7 -4
  165. package/src/components/inserter/index.js +46 -41
  166. package/src/components/inserter/menu.js +8 -4
  167. package/src/components/inserter/test/__snapshots__/index.native.js.snap +117 -0
  168. package/src/components/inserter/test/index.native.js +255 -1
  169. package/src/components/inspector-controls/groups.js +2 -0
  170. package/src/components/inspector-controls-tabs/position-controls-panel.js +37 -0
  171. package/src/components/inspector-controls-tabs/settings-tab.js +2 -0
  172. package/src/components/inspector-controls-tabs/style.scss +15 -0
  173. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +3 -8
  174. package/src/components/link-control/search-input.js +1 -0
  175. package/src/components/link-control/style.scss +1 -0
  176. package/src/components/list-view/style.scss +13 -3
  177. package/src/components/off-canvas-editor/appender.js +2 -52
  178. package/src/components/off-canvas-editor/block-contents.js +84 -23
  179. package/src/components/off-canvas-editor/block.js +28 -60
  180. package/src/components/off-canvas-editor/index.js +12 -2
  181. package/src/components/provider/index.js +4 -1
  182. package/src/components/rich-text/use-enter.js +4 -4
  183. package/src/components/url-input/README.md +5 -0
  184. package/src/components/url-input/button.js +1 -0
  185. package/src/components/url-input/index.js +15 -1
  186. package/src/components/url-popover/link-editor.js +1 -0
  187. package/src/components/use-paste-styles/index.js +230 -0
  188. package/src/components/writing-flow/use-arrow-nav.js +20 -28
  189. package/src/content.scss +1 -0
  190. package/src/hooks/index.js +1 -0
  191. package/src/hooks/metadata.js +1 -2
  192. package/src/hooks/position.js +375 -0
  193. package/src/hooks/position.scss +18 -0
  194. package/src/hooks/supports.js +302 -0
  195. package/src/hooks/test/__snapshots__/align.native.js.snap +73 -0
  196. package/src/hooks/test/align.native.js +133 -0
  197. package/src/store/reducer.js +7 -2
  198. package/src/store/selectors.js +5 -5
  199. package/src/store/test/reducer.js +45 -3
  200. package/src/store/test/selectors.js +12 -9
  201. package/src/style.scss +2 -1
@@ -0,0 +1,73 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Align options for group block sets Full width option 1`] = `
4
+ "<!-- wp:group {\\"align\\":\\"full\\",\\"layout\\":{\\"type\\":\\"constrained\\"}} -->
5
+ <div class=\\"wp-block-group alignfull\\"></div>
6
+ <!-- /wp:group -->"
7
+ `;
8
+
9
+ exports[`Align options for group block sets None option 1`] = `
10
+ "<!-- wp:group {\\"layout\\":{\\"type\\":\\"constrained\\"}} -->
11
+ <div class=\\"wp-block-group\\"></div>
12
+ <!-- /wp:group -->"
13
+ `;
14
+
15
+ exports[`Align options for group block sets Wide width option 1`] = `
16
+ "<!-- wp:group {\\"align\\":\\"wide\\",\\"layout\\":{\\"type\\":\\"constrained\\"}} -->
17
+ <div class=\\"wp-block-group alignwide\\"></div>
18
+ <!-- /wp:group -->"
19
+ `;
20
+
21
+ exports[`Align options for media block sets Align center option 1`] = `
22
+ "<!-- wp:image {\\"align\\":\\"center\\",\\"id\\":1,\\"sizeSlug\\":\\"large\\",\\"linkDestination\\":\\"none\\"} -->
23
+ <figure class=\\"wp-block-image aligncenter size-large\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-1\\"/></figure>
24
+ <!-- /wp:image -->"
25
+ `;
26
+
27
+ exports[`Align options for media block sets Align left option 1`] = `
28
+ "<!-- wp:image {\\"align\\":\\"left\\",\\"id\\":1,\\"sizeSlug\\":\\"large\\",\\"linkDestination\\":\\"none\\"} -->
29
+ <figure class=\\"wp-block-image alignleft size-large\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-1\\"/></figure>
30
+ <!-- /wp:image -->"
31
+ `;
32
+
33
+ exports[`Align options for media block sets Align right option 1`] = `
34
+ "<!-- wp:image {\\"align\\":\\"right\\",\\"id\\":1,\\"sizeSlug\\":\\"large\\",\\"linkDestination\\":\\"none\\"} -->
35
+ <figure class=\\"wp-block-image alignright size-large\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-1\\"/></figure>
36
+ <!-- /wp:image -->"
37
+ `;
38
+
39
+ exports[`Align options for media block sets Full width option 1`] = `
40
+ "<!-- wp:image {\\"align\\":\\"full\\",\\"id\\":1,\\"sizeSlug\\":\\"large\\",\\"linkDestination\\":\\"none\\"} -->
41
+ <figure class=\\"wp-block-image alignfull size-large\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-1\\"/></figure>
42
+ <!-- /wp:image -->"
43
+ `;
44
+
45
+ exports[`Align options for media block sets None option 1`] = `
46
+ "<!-- wp:image {\\"id\\":1,\\"sizeSlug\\":\\"large\\",\\"linkDestination\\":\\"none\\"} -->
47
+ <figure class=\\"wp-block-image size-large\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-1\\"/></figure>
48
+ <!-- /wp:image -->"
49
+ `;
50
+
51
+ exports[`Align options for media block sets Wide width option 1`] = `
52
+ "<!-- wp:image {\\"align\\":\\"wide\\",\\"id\\":1,\\"sizeSlug\\":\\"large\\",\\"linkDestination\\":\\"none\\"} -->
53
+ <figure class=\\"wp-block-image alignwide size-large\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-1\\"/></figure>
54
+ <!-- /wp:image -->"
55
+ `;
56
+
57
+ exports[`Align options for text block sets Align text center option 1`] = `
58
+ "<!-- wp:paragraph {\\"align\\":\\"center\\"} -->
59
+ <p class=\\"has-text-align-center\\"></p>
60
+ <!-- /wp:paragraph -->"
61
+ `;
62
+
63
+ exports[`Align options for text block sets Align text left option 1`] = `
64
+ "<!-- wp:paragraph {\\"align\\":\\"left\\"} -->
65
+ <p class=\\"has-text-align-left\\"></p>
66
+ <!-- /wp:paragraph -->"
67
+ `;
68
+
69
+ exports[`Align options for text block sets Align text right option 1`] = `
70
+ "<!-- wp:paragraph {\\"align\\":\\"right\\"} -->
71
+ <p class=\\"has-text-align-right\\"></p>
72
+ <!-- /wp:paragraph -->"
73
+ `;
@@ -0,0 +1,133 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import {
5
+ addBlock,
6
+ getEditorHtml,
7
+ initializeEditor,
8
+ getBlock,
9
+ fireEvent,
10
+ within,
11
+ } from 'test/helpers';
12
+
13
+ /**
14
+ * WordPress dependencies
15
+ */
16
+ import { getBlockTypes, unregisterBlockType } from '@wordpress/blocks';
17
+ import { registerCoreBlocks } from '@wordpress/block-library';
18
+
19
+ const imageHTML = `<!-- wp:image {"id":1,"sizeSlug":"large","linkDestination":"none"} -->
20
+ <figure class="wp-block-image size-large"><img src="https://test-site.files.wordpress.com/local-image-1.jpeg" alt="" class="wp-image-1"/></figure>
21
+ <!-- /wp:image -->`;
22
+
23
+ beforeAll( () => {
24
+ // Register all core blocks
25
+ registerCoreBlocks();
26
+ } );
27
+
28
+ afterAll( () => {
29
+ // Clean up registered blocks
30
+ getBlockTypes().forEach( ( block ) => {
31
+ unregisterBlockType( block.name );
32
+ } );
33
+ } );
34
+
35
+ describe( 'Align options', () => {
36
+ describe( 'for media block', () => {
37
+ [
38
+ 'None',
39
+ 'Align left',
40
+ 'Align center',
41
+ 'Align right',
42
+ 'Wide width',
43
+ 'Full width',
44
+ ].forEach( ( alignmentOption ) =>
45
+ it( `sets ${ alignmentOption } option`, async () => {
46
+ const screen = await initializeEditor( {
47
+ initialHtml: imageHTML,
48
+ } );
49
+ const { getByLabelText } = screen;
50
+
51
+ // Get Image block
52
+ const imageBlock = await getBlock( screen, 'Image' );
53
+ expect( imageBlock ).toBeVisible();
54
+ fireEvent.press( imageBlock );
55
+
56
+ // Open alignments menu
57
+ const alignmentButtons = getByLabelText( 'Align' );
58
+ fireEvent.press( alignmentButtons );
59
+
60
+ // Select alignment option.
61
+ fireEvent.press( await getByLabelText( alignmentOption ) );
62
+
63
+ expect( getEditorHtml() ).toMatchSnapshot();
64
+ } )
65
+ );
66
+ } );
67
+
68
+ describe( 'for text block', () => {
69
+ [ 'Align text left', 'Align text center', 'Align text right' ].forEach(
70
+ ( alignmentOption ) =>
71
+ it( `sets ${ alignmentOption } option`, async () => {
72
+ const screen = await initializeEditor();
73
+ const { getByLabelText } = screen;
74
+
75
+ // Add Paragraph block
76
+ await addBlock( screen, 'Paragraph' );
77
+
78
+ // Get Paragraph block
79
+ const paragraphBlock = await getBlock(
80
+ screen,
81
+ 'Paragraph'
82
+ );
83
+ expect( paragraphBlock ).toBeVisible();
84
+
85
+ // Open alignments menu
86
+ const alignmentButtons = getByLabelText( 'Align' );
87
+ fireEvent.press( alignmentButtons );
88
+
89
+ // Select alignment option.
90
+ fireEvent.press( await getByLabelText( alignmentOption ) );
91
+
92
+ expect( getEditorHtml() ).toMatchSnapshot();
93
+ } )
94
+ );
95
+ } );
96
+
97
+ describe( 'for group block', () => {
98
+ [ 'None', 'Wide width', 'Full width' ].forEach( ( alignmentOption ) =>
99
+ it( `sets ${ alignmentOption } option`, async () => {
100
+ const screen = await initializeEditor();
101
+ const { getByLabelText } = screen;
102
+
103
+ // Add Group block
104
+ await addBlock( screen, 'Group' );
105
+
106
+ // Get Paragraph block
107
+ const groupBlock = await getBlock( screen, 'Group' );
108
+ expect( groupBlock ).toBeVisible();
109
+
110
+ // Trigger inner blocks layout
111
+ const innerBlockListWrapper = await within(
112
+ groupBlock
113
+ ).findByTestId( 'block-list-wrapper' );
114
+ fireEvent( innerBlockListWrapper, 'layout', {
115
+ nativeEvent: {
116
+ layout: {
117
+ width: 300,
118
+ },
119
+ },
120
+ } );
121
+
122
+ // Open alignments menu
123
+ const alignmentButtons = getByLabelText( 'Align' );
124
+ fireEvent.press( alignmentButtons );
125
+
126
+ // Select alignment option.
127
+ fireEvent.press( await getByLabelText( alignmentOption ) );
128
+
129
+ expect( getEditorHtml() ).toMatchSnapshot();
130
+ } )
131
+ );
132
+ } );
133
+ } );
@@ -1829,14 +1829,19 @@ export function highlightedBlock( state, action ) {
1829
1829
  export function lastBlockInserted( state = {}, action ) {
1830
1830
  switch ( action.type ) {
1831
1831
  case 'INSERT_BLOCKS':
1832
+ case 'REPLACE_BLOCKS':
1833
+ case 'REPLACE_INNER_BLOCKS':
1832
1834
  if ( ! action.blocks.length ) {
1833
1835
  return state;
1834
1836
  }
1835
1837
 
1836
- const clientId = action.blocks[ 0 ].clientId;
1838
+ const clientIds = action.blocks.map( ( block ) => {
1839
+ return block.clientId;
1840
+ } );
1841
+
1837
1842
  const source = action.meta?.source;
1838
1843
 
1839
- return { clientId, source };
1844
+ return { clientIds, source };
1840
1845
  case 'RESET_BLOCKS':
1841
1846
  return {};
1842
1847
  }
@@ -2647,19 +2647,19 @@ export const __experimentalGetActiveBlockIdByBlockNames = createSelector(
2647
2647
  export function wasBlockJustInserted( state, clientId, source ) {
2648
2648
  const { lastBlockInserted } = state;
2649
2649
  return (
2650
- lastBlockInserted.clientId === clientId &&
2650
+ lastBlockInserted.clientIds?.includes( clientId ) &&
2651
2651
  lastBlockInserted.source === source
2652
2652
  );
2653
2653
  }
2654
2654
 
2655
2655
  /**
2656
- * Gets the client id of the last inserted block.
2656
+ * Gets the client ids of the last inserted blocks.
2657
2657
  *
2658
2658
  * @param {Object} state Global application state.
2659
- * @return {string|undefined} Client Id of the last inserted block.
2659
+ * @return {Array|undefined} Client Ids of the last inserted block(s).
2660
2660
  */
2661
- export function getLastInsertedBlockClientId( state ) {
2662
- return state?.lastBlockInserted?.clientId;
2661
+ export function getLastInsertedBlocksClientIds( state ) {
2662
+ return state?.lastBlockInserted?.clientIds;
2663
2663
  }
2664
2664
 
2665
2665
  /**
@@ -3255,7 +3255,7 @@ describe( 'state', () => {
3255
3255
  } );
3256
3256
 
3257
3257
  describe( 'lastBlockInserted', () => {
3258
- it( 'should return client id if last block inserted is called with action INSERT_BLOCKS', () => {
3258
+ it( 'should contain client id if last block inserted is called with action INSERT_BLOCKS', () => {
3259
3259
  const expectedClientId = '62bfef6e-d5e9-43ba-b7f9-c77cf354141f';
3260
3260
 
3261
3261
  const action = {
@@ -3272,7 +3272,7 @@ describe( 'state', () => {
3272
3272
 
3273
3273
  const state = lastBlockInserted( {}, action );
3274
3274
 
3275
- expect( state.clientId ).toBe( expectedClientId );
3275
+ expect( state.clientIds ).toContain( expectedClientId );
3276
3276
  } );
3277
3277
 
3278
3278
  it( 'should return inserter_menu source if last block inserted is called with action INSERT_BLOCKS', () => {
@@ -3297,7 +3297,7 @@ describe( 'state', () => {
3297
3297
 
3298
3298
  it( 'should return state if last block inserted is called with action INSERT_BLOCKS and block list is empty', () => {
3299
3299
  const expectedState = {
3300
- clientId: '9db792c6-a25a-495d-adbd-97d56a4c4189',
3300
+ clientIds: [ '9db792c6-a25a-495d-adbd-97d56a4c4189' ],
3301
3301
  };
3302
3302
 
3303
3303
  const action = {
@@ -3313,6 +3313,48 @@ describe( 'state', () => {
3313
3313
  expect( state ).toEqual( expectedState );
3314
3314
  } );
3315
3315
 
3316
+ it( 'should return client ids of blocks when called with REPLACE_BLOCKS', () => {
3317
+ const clientIdOne = '62bfef6e-d5e9-43ba-b7f9-c77cf354141f';
3318
+ const clientIdTwo = '9db792c6-a25a-495d-adbd-97d56a4c4189';
3319
+
3320
+ const action = {
3321
+ blocks: [
3322
+ {
3323
+ clientId: clientIdOne,
3324
+ },
3325
+ {
3326
+ clientId: clientIdTwo,
3327
+ },
3328
+ ],
3329
+ type: 'REPLACE_BLOCKS',
3330
+ };
3331
+
3332
+ const state = lastBlockInserted( {}, action );
3333
+
3334
+ expect( state.clientIds ).toEqual( [ clientIdOne, clientIdTwo ] );
3335
+ } );
3336
+
3337
+ it( 'should return client ids of all blocks when inner blocks are replaced with REPLACE_INNER_BLOCKS', () => {
3338
+ const clientIdOne = '62bfef6e-d5e9-43ba-b7f9-c77cf354141f';
3339
+ const clientIdTwo = '9db792c6-a25a-495d-adbd-97d56a4c4189';
3340
+
3341
+ const action = {
3342
+ blocks: [
3343
+ {
3344
+ clientId: clientIdOne,
3345
+ },
3346
+ {
3347
+ clientId: clientIdTwo,
3348
+ },
3349
+ ],
3350
+ type: 'REPLACE_INNER_BLOCKS',
3351
+ };
3352
+
3353
+ const state = lastBlockInserted( {}, action );
3354
+
3355
+ expect( state.clientIds ).toEqual( [ clientIdOne, clientIdTwo ] );
3356
+ } );
3357
+
3316
3358
  it( 'should return empty state if last block inserted is called with action RESET_BLOCKS', () => {
3317
3359
  const expectedState = {};
3318
3360
 
@@ -73,7 +73,7 @@ const {
73
73
  __experimentalGetPatternTransformItems,
74
74
  wasBlockJustInserted,
75
75
  __experimentalGetGlobalBlocksByName,
76
- getLastInsertedBlockClientId,
76
+ getLastInsertedBlocksClientIds,
77
77
  } = selectors;
78
78
 
79
79
  describe( 'selectors', () => {
@@ -4457,7 +4457,7 @@ describe( 'selectors', () => {
4457
4457
 
4458
4458
  const state = {
4459
4459
  lastBlockInserted: {
4460
- clientId: expectedClientId,
4460
+ clientIds: [ expectedClientId ],
4461
4461
  source,
4462
4462
  },
4463
4463
  };
@@ -4474,7 +4474,7 @@ describe( 'selectors', () => {
4474
4474
 
4475
4475
  const state = {
4476
4476
  lastBlockInserted: {
4477
- clientId: unexpectedClientId,
4477
+ clientIds: [ unexpectedClientId ],
4478
4478
  source,
4479
4479
  },
4480
4480
  };
@@ -4490,7 +4490,7 @@ describe( 'selectors', () => {
4490
4490
 
4491
4491
  const state = {
4492
4492
  lastBlockInserted: {
4493
- clientId,
4493
+ clientIds: [ clientId ],
4494
4494
  },
4495
4495
  };
4496
4496
 
@@ -4667,22 +4667,25 @@ describe( '__unstableGetClientIdsTree', () => {
4667
4667
  } );
4668
4668
  } );
4669
4669
 
4670
- describe( 'getLastInsertedBlockClientId', () => {
4670
+ describe( 'getLastInsertedBlocksClientIds', () => {
4671
4671
  it( 'should return undefined if no blocks have been inserted', () => {
4672
4672
  const state = {
4673
4673
  lastBlockInserted: {},
4674
4674
  };
4675
4675
 
4676
- expect( getLastInsertedBlockClientId( state ) ).toEqual( undefined );
4676
+ expect( getLastInsertedBlocksClientIds( state ) ).toEqual( undefined );
4677
4677
  } );
4678
4678
 
4679
- it( 'should return clientId if blocks have been inserted', () => {
4679
+ it( 'should return clientIds if blocks have been inserted', () => {
4680
4680
  const state = {
4681
4681
  lastBlockInserted: {
4682
- clientId: '123456',
4682
+ clientIds: [ '123456', '78910' ],
4683
4683
  },
4684
4684
  };
4685
4685
 
4686
- expect( getLastInsertedBlockClientId( state ) ).toEqual( '123456' );
4686
+ expect( getLastInsertedBlocksClientIds( state ) ).toEqual( [
4687
+ '123456',
4688
+ '78910',
4689
+ ] );
4687
4690
  } );
4688
4691
  } );
package/src/style.scss CHANGED
@@ -22,7 +22,6 @@
22
22
  @import "./components/block-pattern-setup/style.scss";
23
23
  @import "./components/block-variation-transforms/style.scss";
24
24
  @import "./components/border-radius-control/style.scss";
25
- @import "./components/button-block-appender/style.scss";
26
25
  @import "./components/colors-gradients/style.scss";
27
26
  @import "./components/contrast-checker/style.scss";
28
27
  @import "./components/date-format-picker/style.scss";
@@ -31,6 +30,7 @@
31
30
  @import "./components/height-control/style.scss";
32
31
  @import "./components/image-size-control/style.scss";
33
32
  @import "./components/inserter-list-item/style.scss";
33
+ @import "./components/inspector-controls-tabs/style.scss";
34
34
  @import "./components/inspector-popover-header/style.scss";
35
35
  @import "./components/justify-content-control/style.scss";
36
36
  @import "./components/link-control/style.scss";
@@ -50,6 +50,7 @@
50
50
  @import "./hooks/layout.scss";
51
51
  @import "./hooks/border.scss";
52
52
  @import "./hooks/dimensions.scss";
53
+ @import "./hooks/position.scss";
53
54
  @import "./hooks/typography.scss";
54
55
  @import "./hooks/color.scss";
55
56
  @import "./hooks/padding.scss";