@wordpress/block-library 8.17.1 → 8.18.1-next.5a1d1283.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 (124) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/column/edit.native.js +5 -5
  3. package/build/column/edit.native.js.map +1 -1
  4. package/build/cover/edit/index.js +3 -1
  5. package/build/cover/edit/index.js.map +1 -1
  6. package/build/cover/shared.js +26 -21
  7. package/build/cover/shared.js.map +1 -1
  8. package/build/embed/embed-link-settings.native.js +0 -1
  9. package/build/embed/embed-link-settings.native.js.map +1 -1
  10. package/build/footnotes/edit.js +2 -3
  11. package/build/footnotes/edit.js.map +1 -1
  12. package/build/group/index.js +1 -0
  13. package/build/group/index.js.map +1 -1
  14. package/build/post-content/edit.js +1 -1
  15. package/build/post-content/edit.js.map +1 -1
  16. package/build/post-template/index.js +1 -1
  17. package/build/post-terms/use-post-terms.js +3 -2
  18. package/build/post-terms/use-post-terms.js.map +1 -1
  19. package/build/query/edit/inspector-controls/index.js +28 -3
  20. package/build/query/edit/inspector-controls/index.js.map +1 -1
  21. package/build/query/edit/query-content.js +2 -1
  22. package/build/query/edit/query-content.js.map +1 -1
  23. package/build/query/index.js +9 -2
  24. package/build/query/index.js.map +1 -1
  25. package/build/query/view.js +75 -0
  26. package/build/query/view.js.map +1 -0
  27. package/build/query-pagination-next/index.js +1 -1
  28. package/build/query-pagination-numbers/edit.js +50 -5
  29. package/build/query-pagination-numbers/edit.js.map +1 -1
  30. package/build/query-pagination-numbers/index.js +7 -1
  31. package/build/query-pagination-numbers/index.js.map +1 -1
  32. package/build/query-pagination-previous/index.js +1 -1
  33. package/build/search/edit.js +3 -1
  34. package/build/search/edit.js.map +1 -1
  35. package/build/search/utils.js +2 -4
  36. package/build/search/utils.js.map +1 -1
  37. package/build/social-link/edit.native.js +1 -3
  38. package/build/social-link/edit.native.js.map +1 -1
  39. package/build-module/column/edit.native.js +5 -5
  40. package/build-module/column/edit.native.js.map +1 -1
  41. package/build-module/cover/edit/index.js +3 -1
  42. package/build-module/cover/edit/index.js.map +1 -1
  43. package/build-module/cover/shared.js +26 -21
  44. package/build-module/cover/shared.js.map +1 -1
  45. package/build-module/embed/embed-link-settings.native.js +0 -1
  46. package/build-module/embed/embed-link-settings.native.js.map +1 -1
  47. package/build-module/footnotes/edit.js +2 -3
  48. package/build-module/footnotes/edit.js.map +1 -1
  49. package/build-module/group/index.js +1 -0
  50. package/build-module/group/index.js.map +1 -1
  51. package/build-module/post-content/edit.js +1 -1
  52. package/build-module/post-content/edit.js.map +1 -1
  53. package/build-module/post-template/index.js +1 -1
  54. package/build-module/post-terms/use-post-terms.js +3 -2
  55. package/build-module/post-terms/use-post-terms.js.map +1 -1
  56. package/build-module/query/edit/inspector-controls/index.js +29 -4
  57. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  58. package/build-module/query/edit/query-content.js +2 -1
  59. package/build-module/query/edit/query-content.js.map +1 -1
  60. package/build-module/query/index.js +9 -2
  61. package/build-module/query/index.js.map +1 -1
  62. package/build-module/query/view.js +72 -0
  63. package/build-module/query/view.js.map +1 -0
  64. package/build-module/query-pagination-next/index.js +1 -1
  65. package/build-module/query-pagination-numbers/edit.js +51 -6
  66. package/build-module/query-pagination-numbers/edit.js.map +1 -1
  67. package/build-module/query-pagination-numbers/index.js +7 -1
  68. package/build-module/query-pagination-numbers/index.js.map +1 -1
  69. package/build-module/query-pagination-previous/index.js +1 -1
  70. package/build-module/search/edit.js +4 -2
  71. package/build-module/search/edit.js.map +1 -1
  72. package/build-module/search/utils.js +0 -1
  73. package/build-module/search/utils.js.map +1 -1
  74. package/build-module/social-link/edit.native.js +1 -3
  75. package/build-module/social-link/edit.native.js.map +1 -1
  76. package/build-style/query/style-rtl.css +140 -0
  77. package/build-style/query/style.css +140 -0
  78. package/build-style/site-logo/style-rtl.css +1 -0
  79. package/build-style/site-logo/style.css +1 -0
  80. package/build-style/style-rtl.css +1 -0
  81. package/build-style/style.css +1 -0
  82. package/package.json +32 -32
  83. package/src/audio/test/__snapshots__/edit.native.js.snap +106 -78
  84. package/src/column/edit.native.js +4 -4
  85. package/src/columns/test/__snapshots__/edit.native.js.snap +14 -0
  86. package/src/columns/test/edit.native.js +47 -17
  87. package/src/cover/edit/index.js +3 -1
  88. package/src/cover/shared.js +25 -20
  89. package/src/cover/test/edit.native.js +1 -5
  90. package/src/embed/embed-link-settings.native.js +0 -1
  91. package/src/embed/test/index.native.js +9 -9
  92. package/src/file/test/__snapshots__/edit.native.js.snap +218 -162
  93. package/src/footnotes/edit.js +3 -1
  94. package/src/group/block.json +1 -0
  95. package/src/image/index.php +5 -0
  96. package/src/post-content/edit.js +2 -2
  97. package/src/post-content/index.php +0 -6
  98. package/src/post-featured-image/index.php +0 -6
  99. package/src/post-navigation-link/index.php +10 -1
  100. package/src/post-template/block.json +2 -1
  101. package/src/post-template/index.php +19 -4
  102. package/src/post-terms/use-post-terms.js +4 -2
  103. package/src/query/block.json +9 -2
  104. package/src/query/edit/inspector-controls/index.js +46 -3
  105. package/src/query/edit/query-content.js +1 -0
  106. package/src/query/index.php +94 -1
  107. package/src/query/style.scss +63 -0
  108. package/src/query/view.js +82 -0
  109. package/src/query-no-results/index.php +1 -5
  110. package/src/query-pagination-next/block.json +7 -1
  111. package/src/query-pagination-next/index.php +20 -3
  112. package/src/query-pagination-numbers/block.json +7 -1
  113. package/src/query-pagination-numbers/edit.js +64 -16
  114. package/src/query-pagination-numbers/index.php +27 -4
  115. package/src/query-pagination-previous/block.json +7 -1
  116. package/src/query-pagination-previous/index.php +19 -2
  117. package/src/search/edit.js +8 -2
  118. package/src/search/test/__snapshots__/edit.native.js.snap +363 -265
  119. package/src/search/utils.js +0 -1
  120. package/src/site-logo/style.scss +1 -0
  121. package/src/social-link/edit.native.js +1 -1
  122. package/src/social-link/editor.native.scss +0 -4
  123. package/src/social-links/test/edit.native.js +30 -0
  124. package/src/social-link/test/index.native.js +0 -132
@@ -4,14 +4,16 @@
4
4
  import {
5
5
  act,
6
6
  addBlock,
7
+ dismissModal,
7
8
  fireEvent,
9
+ getBlock,
8
10
  getEditorHtml,
9
11
  initializeEditor,
12
+ openBlockActionsMenu,
10
13
  openBlockSettings,
11
- within,
12
- getBlock,
13
- dismissModal,
14
+ screen,
14
15
  waitForModalVisible,
16
+ within,
15
17
  } from 'test/helpers';
16
18
 
17
19
  /**
@@ -43,7 +45,7 @@ afterAll( () => {
43
45
 
44
46
  describe( 'Columns block', () => {
45
47
  it( 'inserts block', async () => {
46
- const screen = await initializeEditor();
48
+ await initializeEditor();
47
49
 
48
50
  // Add block
49
51
  await addBlock( screen, 'Columns' );
@@ -55,7 +57,7 @@ describe( 'Columns block', () => {
55
57
  } );
56
58
 
57
59
  it( 'adds a column block using the appender', async () => {
58
- const screen = await initializeEditor( {
60
+ await initializeEditor( {
59
61
  initialHtml: TWO_COLUMNS_BLOCK_HTML,
60
62
  } );
61
63
 
@@ -73,7 +75,7 @@ describe( 'Columns block', () => {
73
75
 
74
76
  describe( 'when using the number of columns setting', () => {
75
77
  it( 'adds a column block when incrementing the value', async () => {
76
- const screen = await initializeEditor( {
78
+ await initializeEditor( {
77
79
  initialHtml: TWO_COLUMNS_BLOCK_HTML,
78
80
  } );
79
81
  const { getByLabelText } = screen;
@@ -95,7 +97,7 @@ describe( 'Columns block', () => {
95
97
  } );
96
98
 
97
99
  it( 'adds at least 15 Column blocks without limitation', async () => {
98
- const screen = await initializeEditor( {
100
+ await initializeEditor( {
99
101
  initialHtml: TWO_COLUMNS_BLOCK_HTML,
100
102
  } );
101
103
  const { getByLabelText } = screen;
@@ -120,7 +122,7 @@ describe( 'Columns block', () => {
120
122
  } );
121
123
 
122
124
  it( 'removes a column block when decrementing the value', async () => {
123
- const screen = await initializeEditor( {
125
+ await initializeEditor( {
124
126
  initialHtml: TWO_COLUMNS_BLOCK_HTML,
125
127
  } );
126
128
  const { getByLabelText } = screen;
@@ -142,7 +144,7 @@ describe( 'Columns block', () => {
142
144
  } );
143
145
 
144
146
  it( 'reaches the minimum limit of number of column blocks', async () => {
145
- const screen = await initializeEditor();
147
+ await initializeEditor();
146
148
 
147
149
  // Add block
148
150
  await addBlock( screen, 'Columns' );
@@ -185,7 +187,7 @@ describe( 'Columns block', () => {
185
187
  } );
186
188
 
187
189
  it( 'removes column with the remove button', async () => {
188
- const screen = await initializeEditor( {
190
+ await initializeEditor( {
189
191
  initialHtml: TWO_COLUMNS_BLOCK_HTML,
190
192
  } );
191
193
  const { getByLabelText } = screen;
@@ -210,7 +212,7 @@ describe( 'Columns block', () => {
210
212
  } );
211
213
 
212
214
  it( 'removes the only one left Column with the remove button', async () => {
213
- const screen = await initializeEditor( {
215
+ await initializeEditor( {
214
216
  initialHtml: TWO_COLUMNS_BLOCK_HTML,
215
217
  } );
216
218
  const { getByLabelText } = screen;
@@ -247,7 +249,7 @@ describe( 'Columns block', () => {
247
249
  } );
248
250
 
249
251
  it( 'changes vertical alignment on Columns', async () => {
250
- const screen = await initializeEditor( {
252
+ await initializeEditor( {
251
253
  initialHtml: TWO_COLUMNS_BLOCK_HTML,
252
254
  } );
253
255
  const { getByLabelText } = screen;
@@ -270,7 +272,7 @@ describe( 'Columns block', () => {
270
272
  } );
271
273
 
272
274
  it( 'changes the vertical alignment on individual Column', async () => {
273
- const screen = await initializeEditor( {
275
+ await initializeEditor( {
274
276
  initialHtml: TWO_COLUMNS_BLOCK_HTML,
275
277
  } );
276
278
 
@@ -308,7 +310,7 @@ describe( 'Columns block', () => {
308
310
  } );
309
311
 
310
312
  it( 'sets current vertical alignment on new Columns', async () => {
311
- const screen = await initializeEditor( {
313
+ await initializeEditor( {
312
314
  initialHtml: TWO_COLUMNS_BLOCK_HTML,
313
315
  } );
314
316
  const { getByLabelText } = screen;
@@ -337,7 +339,7 @@ describe( 'Columns block', () => {
337
339
 
338
340
  describe( 'when using columns percentage mechanism', () => {
339
341
  it( "updates the slider's input value", async () => {
340
- const screen = await initializeEditor();
342
+ await initializeEditor();
341
343
 
342
344
  // Add block
343
345
  await addBlock( screen, 'Columns' );
@@ -377,7 +379,7 @@ describe( 'Columns block', () => {
377
379
  } );
378
380
 
379
381
  it( 'sets custom values correctly', async () => {
380
- const screen = await initializeEditor( {
382
+ await initializeEditor( {
381
383
  initialHtml: TWO_COLUMNS_BLOCK_HTML,
382
384
  } );
383
385
  const { getByLabelText, getByTestId } = screen;
@@ -443,7 +445,7 @@ describe( 'Columns block', () => {
443
445
  test.each( testData )(
444
446
  'sets the predefined percentages for %s',
445
447
  async ( layout ) => {
446
- const screen = await initializeEditor();
448
+ await initializeEditor();
447
449
 
448
450
  // Add block
449
451
  await addBlock( screen, 'Columns' );
@@ -463,4 +465,32 @@ describe( 'Columns block', () => {
463
465
  }
464
466
  );
465
467
  } );
468
+
469
+ it( 'transforms a nested Columns block into a Group block', async () => {
470
+ await initializeEditor( {
471
+ initialHtml: `<!-- wp:group {"layout":{"type":"constrained"}} -->
472
+ <div class="wp-block-group"><!-- wp:columns -->
473
+ <div class="wp-block-columns"><!-- wp:column {"width":"100%"} -->
474
+ <div class="wp-block-column" style="flex-basis:100%"><!-- wp:paragraph -->
475
+ <p></p>
476
+ <!-- /wp:paragraph --></div>
477
+ <!-- /wp:column --></div>
478
+ <!-- /wp:columns --></div>
479
+ <!-- /wp:group -->`,
480
+ } );
481
+
482
+ // Get Columns block
483
+ const columnsBlock = await getBlock( screen, 'Columns' );
484
+ fireEvent.press( columnsBlock );
485
+
486
+ // Open block actions menu
487
+ await openBlockActionsMenu( screen );
488
+
489
+ // Tap on the Transform block button
490
+ fireEvent.press( screen.getByLabelText( /Transform block…/ ) );
491
+
492
+ // Tap on the Group transform button
493
+ fireEvent.press( screen.getByLabelText( 'Group' ) );
494
+ expect( getEditorHtml() ).toMatchSnapshot();
495
+ } );
466
496
  } );
@@ -151,8 +151,10 @@ function CoverEdit( {
151
151
  const setMedia = attributesFromMedia( setAttributes, dimRatio );
152
152
 
153
153
  const onSelectMedia = async ( newMedia ) => {
154
+ // Only pass the url to getCoverIsDark if the media is an image as video is not handled.
155
+ const newUrl = newMedia?.type === 'image' ? newMedia.url : undefined;
154
156
  const isDarkSetting = await getCoverIsDark(
155
- newMedia.url,
157
+ newUrl,
156
158
  dimRatio,
157
159
  overlayColor.color
158
160
  );
@@ -167,26 +167,31 @@ export async function getCoverIsDark( url, dimRatio = 50, overlayColor ) {
167
167
  .toRgb();
168
168
 
169
169
  if ( url ) {
170
- const imgCrossOrigin = applyFilters(
171
- 'media.crossOrigin',
172
- undefined,
173
- url
174
- );
175
- const {
176
- value: [ r, g, b, a ],
177
- } = await retrieveFastAverageColor().getColorAsync( url, {
178
- // Previously the default color was white, but that changed
179
- // in v6.0.0 so it has to be manually set now.
180
- defaultColor: [ 255, 255, 255, 255 ],
181
- // Errors that come up don't reject the promise, so error
182
- // logging has to be silenced with this option.
183
- silent: process.env.NODE_ENV === 'production',
184
- crossOrigin: imgCrossOrigin,
185
- } );
186
- // FAC uses 0-255 for alpha, but colord expects 0-1.
187
- const media = { r, g, b, a: a / 255 };
188
- const composite = compositeSourceOver( overlay, media );
189
- return colord( composite ).isDark();
170
+ try {
171
+ const imgCrossOrigin = applyFilters(
172
+ 'media.crossOrigin',
173
+ undefined,
174
+ url
175
+ );
176
+ const {
177
+ value: [ r, g, b, a ],
178
+ } = await retrieveFastAverageColor().getColorAsync( url, {
179
+ // Previously the default color was white, but that changed
180
+ // in v6.0.0 so it has to be manually set now.
181
+ defaultColor: [ 255, 255, 255, 255 ],
182
+ // Errors that come up don't reject the promise, so error
183
+ // logging has to be silenced with this option.
184
+ silent: process.env.NODE_ENV === 'production',
185
+ crossOrigin: imgCrossOrigin,
186
+ } );
187
+ // FAC uses 0-255 for alpha, but colord expects 0-1.
188
+ const media = { r, g, b, a: a / 255 };
189
+ const composite = compositeSourceOver( overlay, media );
190
+ return colord( composite ).isDark();
191
+ } catch ( error ) {
192
+ // If there's an error, just assume the image is dark.
193
+ return true;
194
+ }
190
195
  }
191
196
 
192
197
  // Assume a white background because it isn't easy to get the actual
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { Image, Pressable } from 'react-native';
4
+ import { Image } from 'react-native';
5
5
  import {
6
6
  getEditorHtml,
7
7
  initializeEditor,
@@ -12,7 +12,6 @@ import {
12
12
  getBlock,
13
13
  openBlockSettings,
14
14
  } from 'test/helpers';
15
- import HsvColorPicker from 'react-native-hsv-color-picker';
16
15
 
17
16
  /**
18
17
  * WordPress dependencies
@@ -541,9 +540,6 @@ describe( 'color settings', () => {
541
540
  } );
542
541
 
543
542
  it( 'displays the hex color value in the custom color picker', async () => {
544
- HsvColorPicker.mockImplementation( ( props ) => {
545
- return <Pressable { ...props } testID="hsv-color-picker" />;
546
- } );
547
543
  const screen = await initializeEditor( {
548
544
  initialHtml: COVER_BLOCK_PLACEHOLDER_HTML,
549
545
  } );
@@ -90,7 +90,6 @@ const EmbedLinkSettings = ( {
90
90
  onDismiss={ onDismiss }
91
91
  setAttributes={ onSetAttributes }
92
92
  options={ linkSettingsOptions }
93
- testID="embed-edit-url-modal"
94
93
  withBottomSheet={ withBottomSheet }
95
94
  showIcon
96
95
  />
@@ -241,7 +241,7 @@ describe( 'Embed block', () => {
241
241
 
242
242
  // Wait for edit URL modal to be visible.
243
243
  const embedEditURLModal = editor.getByTestId(
244
- 'embed-edit-url-modal'
244
+ 'link-settings-navigation'
245
245
  );
246
246
  await waitForModalVisible( embedEditURLModal );
247
247
 
@@ -259,7 +259,7 @@ describe( 'Embed block', () => {
259
259
 
260
260
  // Wait for edit URL modal to be visible.
261
261
  const embedEditURLModal = editor.getByTestId(
262
- 'embed-edit-url-modal'
262
+ 'link-settings-navigation'
263
263
  );
264
264
  await waitForModalVisible( embedEditURLModal );
265
265
 
@@ -299,7 +299,7 @@ describe( 'Embed block', () => {
299
299
 
300
300
  // Wait for edit URL modal to be visible.
301
301
  const embedEditURLModal = editor.getByTestId(
302
- 'embed-edit-url-modal'
302
+ 'link-settings-navigation'
303
303
  );
304
304
  await waitForModalVisible( embedEditURLModal );
305
305
 
@@ -338,7 +338,7 @@ describe( 'Embed block', () => {
338
338
 
339
339
  // Wait for edit URL modal to be visible.
340
340
  const embedEditURLModal = editor.getByTestId(
341
- 'embed-edit-url-modal'
341
+ 'link-settings-navigation'
342
342
  );
343
343
  await waitForModalVisible( embedEditURLModal );
344
344
 
@@ -359,7 +359,7 @@ describe( 'Embed block', () => {
359
359
 
360
360
  // Wait for edit URL modal to be visible.
361
361
  const embedEditURLModal = editor.getByTestId(
362
- 'embed-edit-url-modal'
362
+ 'link-settings-navigation'
363
363
  );
364
364
  await waitForModalVisible( embedEditURLModal );
365
365
 
@@ -400,7 +400,7 @@ describe( 'Embed block', () => {
400
400
 
401
401
  // Wait for edit URL modal to be visible.
402
402
  const embedEditURLModal = editor.getByTestId(
403
- 'embed-edit-url-modal'
403
+ 'link-settings-navigation'
404
404
  );
405
405
  await waitForModalVisible( embedEditURLModal );
406
406
 
@@ -584,7 +584,7 @@ describe( 'Embed block', () => {
584
584
 
585
585
  // Wait for edit URL modal to be visible.
586
586
  const embedEditURLModal = editor.getByTestId(
587
- 'embed-edit-url-modal'
587
+ 'link-settings-navigation'
588
588
  );
589
589
  await waitForModalVisible( embedEditURLModal );
590
590
 
@@ -623,7 +623,7 @@ describe( 'Embed block', () => {
623
623
 
624
624
  // Wait for edit URL modal to be visible.
625
625
  const embedEditURLModal = editor.getByTestId(
626
- 'embed-edit-url-modal'
626
+ 'link-settings-navigation'
627
627
  );
628
628
  await waitForModalVisible( embedEditURLModal );
629
629
 
@@ -804,7 +804,7 @@ describe( 'Embed block', () => {
804
804
 
805
805
  // Dismiss the edit URL modal.
806
806
  const embedEditURLModal = editor.getByTestId(
807
- 'embed-edit-url-modal'
807
+ 'link-settings-navigation'
808
808
  );
809
809
  fireEvent( embedEditURLModal, 'backdropPress' );
810
810
  fireEvent( embedEditURLModal, MODAL_DISMISS_EVENT );