@wordpress/block-library 9.43.0 → 9.43.1-next.v.202604091042.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 (76) hide show
  1. package/build/code/edit.cjs +2 -1
  2. package/build/code/edit.cjs.map +2 -2
  3. package/build/cover/edit/color-utils.cjs +1 -1
  4. package/build/cover/edit/color-utils.cjs.map +2 -2
  5. package/build/cover/edit/index.cjs +31 -25
  6. package/build/cover/edit/index.cjs.map +2 -2
  7. package/build/cover/embed-video-utils.cjs +9 -7
  8. package/build/cover/embed-video-utils.cjs.map +2 -2
  9. package/build/file/utils/index.cjs +1 -1
  10. package/build/file/utils/index.cjs.map +2 -2
  11. package/build/form/view.cjs +1 -1
  12. package/build/form/view.cjs.map +2 -2
  13. package/build/icon/edit.cjs +1 -3
  14. package/build/icon/edit.cjs.map +2 -2
  15. package/build/image/image.cjs +4 -3
  16. package/build/image/image.cjs.map +2 -2
  17. package/build/navigation-link/link-ui/page-creator.cjs +1 -1
  18. package/build/navigation-link/link-ui/page-creator.cjs.map +2 -2
  19. package/build/navigation-link/shared/update-attributes.cjs +1 -1
  20. package/build/navigation-link/shared/update-attributes.cjs.map +2 -2
  21. package/build/navigation-link/shared/use-link-preview.cjs +1 -1
  22. package/build/navigation-link/shared/use-link-preview.cjs.map +2 -2
  23. package/build/pattern/edit.cjs +1 -1
  24. package/build/pattern/edit.cjs.map +2 -2
  25. package/build/search/block.json +0 -4
  26. package/build/search/edit.cjs +6 -33
  27. package/build/search/edit.cjs.map +2 -2
  28. package/build-module/code/edit.mjs +2 -1
  29. package/build-module/code/edit.mjs.map +2 -2
  30. package/build-module/cover/edit/color-utils.mjs +1 -1
  31. package/build-module/cover/edit/color-utils.mjs.map +2 -2
  32. package/build-module/cover/edit/index.mjs +39 -28
  33. package/build-module/cover/edit/index.mjs.map +2 -2
  34. package/build-module/cover/embed-video-utils.mjs +8 -6
  35. package/build-module/cover/embed-video-utils.mjs.map +2 -2
  36. package/build-module/file/utils/index.mjs +1 -1
  37. package/build-module/file/utils/index.mjs.map +2 -2
  38. package/build-module/form/view.mjs +1 -1
  39. package/build-module/form/view.mjs.map +2 -2
  40. package/build-module/icon/edit.mjs +1 -3
  41. package/build-module/icon/edit.mjs.map +2 -2
  42. package/build-module/image/image.mjs +4 -3
  43. package/build-module/image/image.mjs.map +2 -2
  44. package/build-module/navigation-link/link-ui/page-creator.mjs +1 -1
  45. package/build-module/navigation-link/link-ui/page-creator.mjs.map +2 -2
  46. package/build-module/navigation-link/shared/update-attributes.mjs +1 -1
  47. package/build-module/navigation-link/shared/update-attributes.mjs.map +2 -2
  48. package/build-module/navigation-link/shared/use-link-preview.mjs +1 -1
  49. package/build-module/navigation-link/shared/use-link-preview.mjs.map +2 -2
  50. package/build-module/pattern/edit.mjs +1 -1
  51. package/build-module/pattern/edit.mjs.map +2 -2
  52. package/build-module/search/block.json +0 -4
  53. package/build-module/search/edit.mjs +6 -33
  54. package/build-module/search/edit.mjs.map +2 -2
  55. package/build-style/code/style-rtl.css +1 -1
  56. package/build-style/code/style.css +1 -1
  57. package/build-style/style-rtl.css +1 -1
  58. package/build-style/style.css +1 -1
  59. package/package.json +38 -38
  60. package/src/code/edit.js +1 -0
  61. package/src/code/style.scss +1 -1
  62. package/src/cover/edit/color-utils.js +1 -1
  63. package/src/cover/edit/index.js +63 -34
  64. package/src/cover/embed-video-utils.js +10 -8
  65. package/src/embed/test/index.native.js +3 -2
  66. package/src/file/utils/index.js +1 -1
  67. package/src/form/view.js +1 -1
  68. package/src/icon/edit.js +1 -3
  69. package/src/image/image.js +6 -4
  70. package/src/image/index.php +4 -4
  71. package/src/navigation-link/link-ui/page-creator.js +1 -1
  72. package/src/navigation-link/shared/update-attributes.js +1 -1
  73. package/src/navigation-link/shared/use-link-preview.js +1 -1
  74. package/src/pattern/edit.js +1 -1
  75. package/src/search/block.json +0 -4
  76. package/src/search/edit.js +2 -35
@@ -74,18 +74,20 @@ function findVideoEmbedProvider( url ) {
74
74
  }
75
75
 
76
76
  /**
77
- * Extracts iframe src from embed HTML.
77
+ * Modifies embed HTML to use background video parameters.
78
78
  *
79
- * @param {string} html The embed HTML.
80
- * @return {string|null} The iframe src URL or null if not found.
79
+ * @param {string} html The original embed HTML.
80
+ * @return {string|null} The modified embed HTML, or null if not possible.
81
81
  */
82
- export function getIframeSrc( html ) {
83
- if ( ! html ) {
82
+ export function getBackgroundEmbedHtml( html ) {
83
+ const srcMatch = html?.match( /src=["']([^"']+)["']/ );
84
+ if ( ! srcMatch ) {
84
85
  return null;
85
86
  }
86
87
 
87
- const srcMatch = html.match( /src=["']([^"']+)["']/ );
88
- return srcMatch ? srcMatch[ 1 ] : null;
88
+ const iframeSrc = srcMatch[ 1 ];
89
+ const backgroundSrc = getBackgroundVideoSrc( iframeSrc );
90
+ return html.replace( iframeSrc, backgroundSrc );
89
91
  }
90
92
 
91
93
  /**
@@ -189,7 +191,7 @@ export function getBackgroundVideoSrc( src ) {
189
191
  }
190
192
 
191
193
  return url.toString();
192
- } catch ( error ) {
194
+ } catch {
193
195
  // If URL parsing fails, return original src
194
196
  return src;
195
197
  }
@@ -28,9 +28,10 @@ import { requestPreview } from '@wordpress/react-native-bridge';
28
28
  /**
29
29
  * Internal dependencies
30
30
  */
31
+ import { WebView } from 'react-native-webview';
32
+
31
33
  import * as paragraph from '../../paragraph';
32
34
  import * as embed from '..';
33
- import { WebView } from 'react-native-webview';
34
35
 
35
36
  // Override modal mock to prevent unmounting it when is not visible.
36
37
  // This is required to be able to trigger onClose and onDismiss events when
@@ -1114,7 +1115,7 @@ describe( 'Embed block', () => {
1114
1115
  try {
1115
1116
  mediaSettingsPanel =
1116
1117
  await screen.findByText( 'Media settings' );
1117
- } catch ( e ) {
1118
+ } catch {
1118
1119
  // NOOP.
1119
1120
  }
1120
1121
 
@@ -54,7 +54,7 @@ const createActiveXObject = ( type ) => {
54
54
  let ax;
55
55
  try {
56
56
  ax = new window.ActiveXObject( type );
57
- } catch ( e ) {
57
+ } catch {
58
58
  ax = undefined;
59
59
  }
60
60
  return ax;
package/src/form/view.js CHANGED
@@ -47,7 +47,7 @@ document.querySelectorAll( 'form.wp-block-form' ).forEach( function ( form ) {
47
47
  } else {
48
48
  redirectNotification( 'error' );
49
49
  }
50
- } catch ( error ) {
50
+ } catch {
51
51
  redirectNotification( 'error' );
52
52
  }
53
53
  } );
package/src/icon/edit.js CHANGED
@@ -78,9 +78,7 @@ export function Edit( { attributes, setAttributes } ) {
78
78
  ? getEntityRecord( 'root', 'icon', icon )
79
79
  : null,
80
80
  allIcons: isInserterOpen
81
- ? getEntityRecords( 'root', 'icon', {
82
- per_page: -1,
83
- } )
81
+ ? getEntityRecords( 'root', 'icon' )
84
82
  : undefined,
85
83
  };
86
84
  },
@@ -396,6 +396,9 @@ export default function Image( {
396
396
  hasNonContentControls &&
397
397
  ! isWideAligned &&
398
398
  isLargeViewport;
399
+ // An image is uploading if it has a temporary blob URL, or if it is
400
+ // being processed client-side (e.g. transcoded or generating sub-sizes).
401
+ const isUploading = !! temporaryURL || isSideloading;
399
402
  const imageSizeOptions = imageSizes
400
403
  .filter(
401
404
  ( { slug } ) => image?.media_details?.sizes?.[ slug ]?.source_url
@@ -885,9 +888,7 @@ export default function Image( {
885
888
  onSelectURL={ onSelectURL }
886
889
  onError={ onUploadError }
887
890
  onReset={ () => onSelectImage( undefined ) }
888
- isUploading={
889
- !! temporaryURL || isSideloading
890
- }
891
+ isUploading={ isUploading }
891
892
  emptyLabel={ __( 'Add image' ) }
892
893
  />
893
894
  </ToolsPanelItem>
@@ -1078,7 +1079,7 @@ export default function Image( {
1078
1079
  ...shadowProps.style,
1079
1080
  } }
1080
1081
  />
1081
- { ( temporaryURL || isSideloading ) && <Spinner /> }
1082
+ { isUploading && <Spinner /> }
1082
1083
  </>
1083
1084
  );
1084
1085
 
@@ -1110,6 +1111,7 @@ export default function Image( {
1110
1111
  isResizable &&
1111
1112
  isSingleSelected &&
1112
1113
  ! isEditingImage &&
1114
+ ! isUploading &&
1113
1115
  ! SIZED_LAYOUTS.includes( parentLayoutType )
1114
1116
  ) {
1115
1117
  const numericRatio = aspectRatio && evalAspectRatio( aspectRatio );
@@ -205,8 +205,8 @@ function block_core_image_render_lightbox( $block_content, $block, $block_instan
205
205
  array(
206
206
  'defaultAriaLabel' => __( 'Enlarged image' ),
207
207
  'closeButtonText' => esc_html__( 'Close' ),
208
- 'prevButtonText' => esc_html__( 'Previous' ),
209
- 'nextButtonText' => esc_html__( 'Next' ),
208
+ 'prevButtonText' => esc_html_x( 'Previous', 'previous image in lightbox' ),
209
+ 'nextButtonText' => esc_html_x( 'Next', 'next image in lightbox' ),
210
210
  )
211
211
  );
212
212
 
@@ -323,8 +323,8 @@ function block_core_image_render_lightbox( $block_content, $block, $block_instan
323
323
  function block_core_image_print_lightbox_overlay() {
324
324
  $dialog_label = esc_attr__( 'Enlarged images' );
325
325
  $close_button_text = esc_attr__( 'Close' );
326
- $prev_button_text = esc_attr__( 'Previous' );
327
- $next_button_text = esc_attr__( 'Next' );
326
+ $prev_button_text = esc_attr_x( 'Previous', 'previous image in lightbox' );
327
+ $next_button_text = esc_attr_x( 'Next', 'next image in lightbox' );
328
328
  $close_button_icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20" aria-hidden="true" focusable="false"><path d="m13.06 12 6.47-6.47-1.06-1.06L12 10.94 5.53 4.47 4.47 5.53 10.94 12l-6.47 6.47 1.06 1.06L12 13.06l6.47 6.47 1.06-1.06L13.06 12Z"></path></svg>';
329
329
  $prev_button_icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="28" height="28" aria-hidden="true" focusable="false"><path d="M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z"></path></svg>';
330
330
  $next_button_icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="28" height="28" aria-hidden="true" focusable="false"><path d="M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z"></path></svg>';
@@ -103,7 +103,7 @@ export function LinkUIPageCreator( {
103
103
 
104
104
  onPageCreated( pageLink );
105
105
  }
106
- } catch ( error ) {
106
+ } catch {
107
107
  // Show error notice
108
108
  createErrorNotice(
109
109
  __( 'Failed to create page. Please try again.' ),
@@ -34,7 +34,7 @@ const shouldSeverEntityLink = ( originalUrl, newUrl ) => {
34
34
  ? window.location.origin
35
35
  : 'https://wordpress.org' );
36
36
  return new URL( url, base );
37
- } catch ( error ) {
37
+ } catch {
38
38
  // If URL construction still fails, it's likely an invalid URL
39
39
  // and we should sever the entity link
40
40
  return null;
@@ -101,7 +101,7 @@ export function computeDisplayUrl( { linkUrl, homeUrl } = {} ) {
101
101
  // Different host - this is an external link
102
102
  isExternal = true;
103
103
  }
104
- } catch ( e ) {
104
+ } catch {
105
105
  // URL parsing failed - treat as external (e.g. no homeUrl, or URL without protocol)
106
106
  isExternal = true;
107
107
  }
@@ -78,7 +78,7 @@ const PatternEdit = ( { attributes, clientId } ) => {
78
78
  if ( ! hasRecursionError && selectedPattern?.blocks ) {
79
79
  try {
80
80
  parsePatternDependencies( selectedPattern );
81
- } catch ( error ) {
81
+ } catch {
82
82
  setHasRecursionError( true );
83
83
  return;
84
84
  }
@@ -42,10 +42,6 @@
42
42
  "query": {
43
43
  "type": "object",
44
44
  "default": {}
45
- },
46
- "isSearchFieldHidden": {
47
- "type": "boolean",
48
- "default": false
49
45
  }
50
46
  },
51
47
  "supports": {
@@ -70,7 +70,6 @@ export default function SearchEdit( {
70
70
  buttonText,
71
71
  buttonPosition,
72
72
  buttonUseIcon,
73
- isSearchFieldHidden,
74
73
  style,
75
74
  } = attributes;
76
75
 
@@ -139,6 +138,7 @@ export default function SearchEdit( {
139
138
  const isButtonPositionOutside = 'button-outside' === buttonPosition;
140
139
  const hasNoButton = 'no-button' === buttonPosition;
141
140
  const hasOnlyButton = 'button-only' === buttonPosition;
141
+ const isSearchFieldHidden = hasOnlyButton && ! isSelected;
142
142
  const searchFieldRef = useRef();
143
143
  const buttonRef = useRef();
144
144
 
@@ -147,25 +147,6 @@ export default function SearchEdit( {
147
147
  defaultValues: { '%': PC_WIDTH_DEFAULT, px: PX_WIDTH_DEFAULT },
148
148
  } );
149
149
 
150
- useEffect( () => {
151
- if ( hasOnlyButton && ! isSelected ) {
152
- setAttributes( {
153
- isSearchFieldHidden: true,
154
- } );
155
- }
156
- }, [ hasOnlyButton, isSelected, setAttributes ] );
157
-
158
- // Show the search field when width changes.
159
- useEffect( () => {
160
- if ( ! hasOnlyButton || ! isSelected ) {
161
- return;
162
- }
163
-
164
- setAttributes( {
165
- isSearchFieldHidden: false,
166
- } );
167
- }, [ hasOnlyButton, isSelected, setAttributes, width ] );
168
-
169
150
  const getBlockClassNames = () => {
170
151
  return clsx(
171
152
  className,
@@ -183,7 +164,7 @@ export default function SearchEdit( {
183
164
  buttonUseIcon && ! hasNoButton
184
165
  ? 'wp-block-search__icon-button'
185
166
  : undefined,
186
- hasOnlyButton && isSearchFieldHidden
167
+ isSearchFieldHidden
187
168
  ? 'wp-block-search__searchfield-hidden'
188
169
  : undefined
189
170
  );
@@ -292,14 +273,6 @@ export default function SearchEdit( {
292
273
  }
293
274
  : borderProps.style ),
294
275
  };
295
- const handleButtonClick = () => {
296
- if ( hasOnlyButton ) {
297
- setAttributes( {
298
- isSearchFieldHidden: ! isSearchFieldHidden,
299
- } );
300
- }
301
- };
302
-
303
276
  return (
304
277
  <>
305
278
  { buttonUseIcon && (
@@ -312,7 +285,6 @@ export default function SearchEdit( {
312
285
  ? stripHTML( buttonText )
313
286
  : __( 'Search' )
314
287
  }
315
- onClick={ handleButtonClick }
316
288
  ref={ buttonRef }
317
289
  >
318
290
  <Icon icon={ search } />
@@ -331,7 +303,6 @@ export default function SearchEdit( {
331
303
  onChange={ ( html ) =>
332
304
  setAttributes( { buttonText: html } )
333
305
  }
334
- onClick={ handleButtonClick }
335
306
  />
336
307
  ) }
337
308
  </>
@@ -351,7 +322,6 @@ export default function SearchEdit( {
351
322
  showLabel: true,
352
323
  buttonUseIcon: false,
353
324
  buttonPosition: 'button-outside',
354
- isSearchFieldHidden: false,
355
325
  } );
356
326
  } }
357
327
  dropdownMenuProps={ dropdownMenuProps }
@@ -382,7 +352,6 @@ export default function SearchEdit( {
382
352
  onDeselect={ () => {
383
353
  setAttributes( {
384
354
  buttonPosition: 'button-outside',
385
- isSearchFieldHidden: false,
386
355
  } );
387
356
  } }
388
357
  isShownByDefault
@@ -394,8 +363,6 @@ export default function SearchEdit( {
394
363
  onChange={ ( value ) => {
395
364
  setAttributes( {
396
365
  buttonPosition: value,
397
- isSearchFieldHidden:
398
- value === 'button-only',
399
366
  } );
400
367
  } }
401
368
  options={ buttonPositionControls }