@wordpress/block-library 9.42.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 (153) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/code/edit.cjs +2 -1
  3. package/build/code/edit.cjs.map +2 -2
  4. package/build/cover/edit/color-utils.cjs +1 -1
  5. package/build/cover/edit/color-utils.cjs.map +2 -2
  6. package/build/cover/edit/index.cjs +31 -25
  7. package/build/cover/edit/index.cjs.map +2 -2
  8. package/build/cover/embed-video-utils.cjs +9 -7
  9. package/build/cover/embed-video-utils.cjs.map +2 -2
  10. package/build/file/utils/index.cjs +1 -1
  11. package/build/file/utils/index.cjs.map +2 -2
  12. package/build/form/view.cjs +1 -1
  13. package/build/form/view.cjs.map +2 -2
  14. package/build/form-input/edit.cjs +36 -29
  15. package/build/form-input/edit.cjs.map +2 -2
  16. package/build/form-input/variations.cjs +10 -0
  17. package/build/form-input/variations.cjs.map +2 -2
  18. package/build/group/block.json +3 -1
  19. package/build/icon/edit.cjs +1 -3
  20. package/build/icon/edit.cjs.map +2 -2
  21. package/build/image/image.cjs +17 -7
  22. package/build/image/image.cjs.map +2 -2
  23. package/build/latest-comments/deprecated.cjs +33 -0
  24. package/build/latest-comments/deprecated.cjs.map +2 -2
  25. package/build/list-item/block.json +1 -0
  26. package/build/navigation/edit/index.cjs +123 -119
  27. package/build/navigation/edit/index.cjs.map +3 -3
  28. package/build/navigation/edit/navigation-menu-selector.cjs +2 -1
  29. package/build/navigation/edit/navigation-menu-selector.cjs.map +2 -2
  30. package/build/navigation-link/link-ui/page-creator.cjs +1 -1
  31. package/build/navigation-link/link-ui/page-creator.cjs.map +2 -2
  32. package/build/navigation-link/shared/update-attributes.cjs +1 -1
  33. package/build/navigation-link/shared/update-attributes.cjs.map +2 -2
  34. package/build/navigation-link/shared/use-link-preview.cjs +1 -1
  35. package/build/navigation-link/shared/use-link-preview.cjs.map +2 -2
  36. package/build/pattern/edit.cjs +1 -1
  37. package/build/pattern/edit.cjs.map +2 -2
  38. package/build/search/block.json +0 -4
  39. package/build/search/edit.cjs +6 -33
  40. package/build/search/edit.cjs.map +2 -2
  41. package/build/site-logo/edit.cjs +19 -13
  42. package/build/site-logo/edit.cjs.map +3 -3
  43. package/build/site-tagline/deprecated.cjs +2 -1
  44. package/build/site-tagline/deprecated.cjs.map +2 -2
  45. package/build/tab/save.cjs +2 -4
  46. package/build/tab/save.cjs.map +2 -2
  47. package/build/tabs/save.cjs +2 -4
  48. package/build/tabs/save.cjs.map +2 -2
  49. package/build/utils/media-control.cjs +1 -1
  50. package/build/utils/media-control.cjs.map +2 -2
  51. package/build-module/code/edit.mjs +2 -1
  52. package/build-module/code/edit.mjs.map +2 -2
  53. package/build-module/cover/edit/color-utils.mjs +1 -1
  54. package/build-module/cover/edit/color-utils.mjs.map +2 -2
  55. package/build-module/cover/edit/index.mjs +39 -28
  56. package/build-module/cover/edit/index.mjs.map +2 -2
  57. package/build-module/cover/embed-video-utils.mjs +8 -6
  58. package/build-module/cover/embed-video-utils.mjs.map +2 -2
  59. package/build-module/file/utils/index.mjs +1 -1
  60. package/build-module/file/utils/index.mjs.map +2 -2
  61. package/build-module/form/view.mjs +1 -1
  62. package/build-module/form/view.mjs.map +2 -2
  63. package/build-module/form-input/edit.mjs +36 -29
  64. package/build-module/form-input/edit.mjs.map +2 -2
  65. package/build-module/form-input/variations.mjs +10 -0
  66. package/build-module/form-input/variations.mjs.map +2 -2
  67. package/build-module/group/block.json +3 -1
  68. package/build-module/icon/edit.mjs +1 -3
  69. package/build-module/icon/edit.mjs.map +2 -2
  70. package/build-module/image/image.mjs +17 -7
  71. package/build-module/image/image.mjs.map +2 -2
  72. package/build-module/latest-comments/deprecated.mjs +33 -0
  73. package/build-module/latest-comments/deprecated.mjs.map +2 -2
  74. package/build-module/list-item/block.json +1 -0
  75. package/build-module/navigation/edit/index.mjs +123 -119
  76. package/build-module/navigation/edit/index.mjs.map +2 -2
  77. package/build-module/navigation/edit/navigation-menu-selector.mjs +2 -1
  78. package/build-module/navigation/edit/navigation-menu-selector.mjs.map +2 -2
  79. package/build-module/navigation-link/link-ui/page-creator.mjs +1 -1
  80. package/build-module/navigation-link/link-ui/page-creator.mjs.map +2 -2
  81. package/build-module/navigation-link/shared/update-attributes.mjs +1 -1
  82. package/build-module/navigation-link/shared/update-attributes.mjs.map +2 -2
  83. package/build-module/navigation-link/shared/use-link-preview.mjs +1 -1
  84. package/build-module/navigation-link/shared/use-link-preview.mjs.map +2 -2
  85. package/build-module/pattern/edit.mjs +1 -1
  86. package/build-module/pattern/edit.mjs.map +2 -2
  87. package/build-module/search/block.json +0 -4
  88. package/build-module/search/edit.mjs +6 -33
  89. package/build-module/search/edit.mjs.map +2 -2
  90. package/build-module/site-logo/edit.mjs +21 -14
  91. package/build-module/site-logo/edit.mjs.map +2 -2
  92. package/build-module/site-tagline/deprecated.mjs +2 -1
  93. package/build-module/site-tagline/deprecated.mjs.map +2 -2
  94. package/build-module/tab/save.mjs +2 -4
  95. package/build-module/tab/save.mjs.map +2 -2
  96. package/build-module/tabs/save.mjs +2 -4
  97. package/build-module/tabs/save.mjs.map +2 -2
  98. package/build-module/utils/media-control.mjs +1 -1
  99. package/build-module/utils/media-control.mjs.map +2 -2
  100. package/build-style/code/style-rtl.css +1 -1
  101. package/build-style/code/style.css +1 -1
  102. package/build-style/editor-rtl.css +15 -5
  103. package/build-style/editor.css +15 -5
  104. package/build-style/form-input/editor-rtl.css +6 -5
  105. package/build-style/form-input/editor.css +6 -5
  106. package/build-style/icon/editor-rtl.css +5 -0
  107. package/build-style/icon/editor.css +5 -0
  108. package/build-style/image/editor-rtl.css +4 -0
  109. package/build-style/image/editor.css +4 -0
  110. package/build-style/navigation/style-rtl.css +4 -1
  111. package/build-style/navigation/style.css +4 -1
  112. package/build-style/style-rtl.css +5 -2
  113. package/build-style/style.css +5 -2
  114. package/package.json +38 -38
  115. package/src/code/edit.js +1 -0
  116. package/src/code/style.scss +1 -1
  117. package/src/cover/edit/color-utils.js +1 -1
  118. package/src/cover/edit/index.js +63 -34
  119. package/src/cover/embed-video-utils.js +10 -8
  120. package/src/embed/test/index.native.js +3 -2
  121. package/src/file/utils/index.js +1 -1
  122. package/src/form/view.js +1 -1
  123. package/src/form-input/edit.js +19 -15
  124. package/src/form-input/editor.scss +6 -6
  125. package/src/form-input/variations.js +10 -0
  126. package/src/group/block.json +3 -1
  127. package/src/home-link/index.php +14 -33
  128. package/src/icon/edit.js +1 -3
  129. package/src/icon/editor.scss +5 -0
  130. package/src/image/editor.scss +5 -0
  131. package/src/image/image.js +24 -7
  132. package/src/image/index.php +4 -4
  133. package/src/latest-comments/deprecated.js +33 -0
  134. package/src/list-item/block.json +1 -0
  135. package/src/loginout/index.php +13 -0
  136. package/src/navigation/edit/index.js +134 -130
  137. package/src/navigation/edit/navigation-menu-selector.js +2 -1
  138. package/src/navigation/style.scss +5 -3
  139. package/src/navigation-link/index.php +10 -38
  140. package/src/navigation-link/link-ui/page-creator.js +1 -1
  141. package/src/navigation-link/shared/build-css-font-sizes.php +43 -0
  142. package/src/navigation-link/shared/update-attributes.js +1 -1
  143. package/src/navigation-link/shared/use-link-preview.js +1 -1
  144. package/src/navigation-submenu/index.php +10 -38
  145. package/src/page-list/index.php +14 -41
  146. package/src/pattern/edit.js +1 -1
  147. package/src/search/block.json +0 -4
  148. package/src/search/edit.js +2 -35
  149. package/src/site-logo/edit.js +24 -13
  150. package/src/site-tagline/deprecated.js +1 -0
  151. package/src/tab/save.js +2 -6
  152. package/src/tabs/save.js +2 -6
  153. package/src/utils/media-control.js +3 -1
@@ -99,7 +99,6 @@
99
99
  .wp-block-navigation ul,
100
100
  .wp-block-navigation ul li {
101
101
  list-style: none;
102
- padding: 0;
103
102
  }
104
103
  .wp-block-navigation .wp-block-navigation-item {
105
104
  background-color: inherit;
@@ -186,6 +185,10 @@
186
185
  --navigation-layout-justify: space-between;
187
186
  }
188
187
 
188
+ :where(.wp-block-navigation) ul li {
189
+ padding: 0;
190
+ }
191
+
189
192
  .wp-block-navigation .has-child .wp-block-navigation__submenu-container {
190
193
  background-color: inherit;
191
194
  color: inherit;
@@ -427,7 +427,7 @@
427
427
  display: block;
428
428
  font-family: inherit;
429
429
  overflow-wrap: break-word;
430
- white-space: pre-wrap;
430
+ white-space: break-spaces;
431
431
  direction: ltr;
432
432
  text-align: initial;
433
433
  }
@@ -2466,7 +2466,6 @@ ul {
2466
2466
  .wp-block-navigation ul,
2467
2467
  .wp-block-navigation ul li {
2468
2468
  list-style: none;
2469
- padding: 0;
2470
2469
  }
2471
2470
  .wp-block-navigation .wp-block-navigation-item {
2472
2471
  background-color: inherit;
@@ -2553,6 +2552,10 @@ ul {
2553
2552
  --navigation-layout-justify: space-between;
2554
2553
  }
2555
2554
 
2555
+ :where(.wp-block-navigation) ul li {
2556
+ padding: 0;
2557
+ }
2558
+
2556
2559
  .wp-block-navigation .has-child .wp-block-navigation__submenu-container {
2557
2560
  background-color: inherit;
2558
2561
  color: inherit;
@@ -430,7 +430,7 @@
430
430
  display: block;
431
431
  font-family: inherit;
432
432
  overflow-wrap: break-word;
433
- white-space: pre-wrap;
433
+ white-space: break-spaces;
434
434
  /*!rtl:begin:ignore*/
435
435
  direction: ltr;
436
436
  text-align: initial;
@@ -2496,7 +2496,6 @@ ul {
2496
2496
  .wp-block-navigation ul,
2497
2497
  .wp-block-navigation ul li {
2498
2498
  list-style: none;
2499
- padding: 0;
2500
2499
  }
2501
2500
  .wp-block-navigation .wp-block-navigation-item {
2502
2501
  background-color: inherit;
@@ -2583,6 +2582,10 @@ ul {
2583
2582
  --navigation-layout-justify: space-between;
2584
2583
  }
2585
2584
 
2585
+ :where(.wp-block-navigation) ul li {
2586
+ padding: 0;
2587
+ }
2588
+
2586
2589
  .wp-block-navigation .has-child .wp-block-navigation__submenu-container {
2587
2590
  background-color: inherit;
2588
2591
  color: inherit;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-library",
3
- "version": "9.42.0",
3
+ "version": "9.43.1-next.v.202604091042.0+668146787",
4
4
  "description": "Block library for the WordPress editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -95,42 +95,42 @@
95
95
  ],
96
96
  "dependencies": {
97
97
  "@arraypress/waveform-player": "1.2.1",
98
- "@wordpress/a11y": "^4.42.0",
99
- "@wordpress/api-fetch": "^7.42.0",
100
- "@wordpress/autop": "^4.42.0",
101
- "@wordpress/base-styles": "^6.18.0",
102
- "@wordpress/blob": "^4.42.0",
103
- "@wordpress/block-editor": "^15.15.0",
104
- "@wordpress/blocks": "^15.15.0",
105
- "@wordpress/components": "^32.4.0",
106
- "@wordpress/compose": "^7.42.0",
107
- "@wordpress/core-data": "^7.42.0",
108
- "@wordpress/data": "^10.42.0",
109
- "@wordpress/date": "^5.42.0",
110
- "@wordpress/deprecated": "^4.42.0",
111
- "@wordpress/dom": "^4.42.0",
112
- "@wordpress/element": "^6.42.0",
113
- "@wordpress/escape-html": "^3.42.0",
114
- "@wordpress/hooks": "^4.42.0",
115
- "@wordpress/html-entities": "^4.42.0",
116
- "@wordpress/i18n": "^6.15.0",
117
- "@wordpress/icons": "^12.0.0",
118
- "@wordpress/interactivity": "^6.42.0",
119
- "@wordpress/interactivity-router": "^2.42.0",
120
- "@wordpress/keyboard-shortcuts": "^5.42.0",
121
- "@wordpress/keycodes": "^4.42.0",
122
- "@wordpress/latex-to-mathml": "^1.10.0",
123
- "@wordpress/notices": "^5.42.0",
124
- "@wordpress/patterns": "^2.42.0",
125
- "@wordpress/primitives": "^4.42.0",
126
- "@wordpress/private-apis": "^1.42.0",
127
- "@wordpress/reusable-blocks": "^5.42.0",
128
- "@wordpress/rich-text": "^7.42.0",
129
- "@wordpress/server-side-render": "^6.18.0",
130
- "@wordpress/upload-media": "^0.27.0",
131
- "@wordpress/url": "^4.42.0",
132
- "@wordpress/viewport": "^6.42.0",
133
- "@wordpress/wordcount": "^4.42.0",
98
+ "@wordpress/a11y": "^4.43.1-next.v.202604091042.0+668146787",
99
+ "@wordpress/api-fetch": "^7.43.1-next.v.202604091042.0+668146787",
100
+ "@wordpress/autop": "^4.43.1-next.v.202604091042.0+668146787",
101
+ "@wordpress/base-styles": "^6.19.1-next.v.202604091042.0+668146787",
102
+ "@wordpress/blob": "^4.43.1-next.v.202604091042.0+668146787",
103
+ "@wordpress/block-editor": "^15.16.1-next.v.202604091042.0+668146787",
104
+ "@wordpress/blocks": "^15.16.1-next.v.202604091042.0+668146787",
105
+ "@wordpress/components": "^32.5.2-next.v.202604091042.0+668146787",
106
+ "@wordpress/compose": "^7.43.1-next.v.202604091042.0+668146787",
107
+ "@wordpress/core-data": "^7.43.2-next.v.202604091042.0+668146787",
108
+ "@wordpress/data": "^10.43.1-next.v.202604091042.0+668146787",
109
+ "@wordpress/date": "^5.43.1-next.v.202604091042.0+668146787",
110
+ "@wordpress/deprecated": "^4.43.1-next.v.202604091042.0+668146787",
111
+ "@wordpress/dom": "^4.43.1-next.v.202604091042.0+668146787",
112
+ "@wordpress/element": "^6.44.1-next.v.202604091042.0+668146787",
113
+ "@wordpress/escape-html": "^3.43.1-next.v.202604091042.0+668146787",
114
+ "@wordpress/hooks": "^4.43.1-next.v.202604091042.0+668146787",
115
+ "@wordpress/html-entities": "^4.43.1-next.v.202604091042.0+668146787",
116
+ "@wordpress/i18n": "^6.17.1-next.v.202604091042.0+668146787",
117
+ "@wordpress/icons": "^12.1.1-next.v.202604091042.0+668146787",
118
+ "@wordpress/interactivity": "^6.43.1-next.v.202604091042.0+668146787",
119
+ "@wordpress/interactivity-router": "^2.43.1-next.v.202604091042.0+668146787",
120
+ "@wordpress/keyboard-shortcuts": "^5.43.1-next.v.202604091042.0+668146787",
121
+ "@wordpress/keycodes": "^4.43.1-next.v.202604091042.0+668146787",
122
+ "@wordpress/latex-to-mathml": "^1.11.1-next.v.202604091042.0+668146787",
123
+ "@wordpress/notices": "^5.43.1-next.v.202604091042.0+668146787",
124
+ "@wordpress/patterns": "^2.43.1-next.v.202604091042.0+668146787",
125
+ "@wordpress/primitives": "^4.43.1-next.v.202604091042.0+668146787",
126
+ "@wordpress/private-apis": "^1.43.1-next.v.202604091042.0+668146787",
127
+ "@wordpress/reusable-blocks": "^5.43.1-next.v.202604091042.0+668146787",
128
+ "@wordpress/rich-text": "^7.43.1-next.v.202604091042.0+668146787",
129
+ "@wordpress/server-side-render": "^6.19.1-next.v.202604091042.0+668146787",
130
+ "@wordpress/upload-media": "^0.28.1-next.v.202604091042.0+668146787",
131
+ "@wordpress/url": "^4.43.1-next.v.202604091042.0+668146787",
132
+ "@wordpress/viewport": "^6.43.1-next.v.202604091042.0+668146787",
133
+ "@wordpress/wordcount": "^4.43.1-next.v.202604091042.0+668146787",
134
134
  "change-case": "^4.1.2",
135
135
  "clsx": "^2.1.1",
136
136
  "colord": "^2.7.0",
@@ -151,5 +151,5 @@
151
151
  "publishConfig": {
152
152
  "access": "public"
153
153
  },
154
- "gitHead": "c20787b1778ae64c2db65643b1c236309d68e6ba"
154
+ "gitHead": "73606df74f1c38a084bfa5db97205259ef817593"
155
155
  }
package/src/code/edit.js CHANGED
@@ -29,6 +29,7 @@ export default function CodeEdit( {
29
29
  __unstableOnSplitAtDoubleLineEnd={ () =>
30
30
  insertBlocksAfter( createBlock( getDefaultBlockName() ) )
31
31
  }
32
+ style={ { whiteSpace: 'break-spaces' } }
32
33
  />
33
34
  </pre>
34
35
  );
@@ -8,7 +8,7 @@
8
8
  display: block;
9
9
  font-family: inherit;
10
10
  overflow-wrap: break-word;
11
- white-space: pre-wrap;
11
+ white-space: break-spaces;
12
12
  // Set direction and avoid inheriting alignment from a parent element.
13
13
  /*!rtl:begin:ignore*/
14
14
  direction: ltr;
@@ -92,7 +92,7 @@ export const getMediaColor = memoize( async ( url ) => {
92
92
  crossOrigin: imgCrossOrigin,
93
93
  } );
94
94
  return color.hex;
95
- } catch ( error ) {
95
+ } catch {
96
96
  // If there's an error return the fallback color.
97
97
  return DEFAULT_BACKGROUND_COLOR;
98
98
  }
@@ -7,8 +7,13 @@ import clsx from 'clsx';
7
7
  * WordPress dependencies
8
8
  */
9
9
  import { useEntityProp, store as coreStore } from '@wordpress/core-data';
10
- import { useEffect, useMemo, useRef } from '@wordpress/element';
11
- import { Placeholder, Spinner } from '@wordpress/components';
10
+ import {
11
+ useEffect,
12
+ useLayoutEffect,
13
+ useMemo,
14
+ useRef,
15
+ } from '@wordpress/element';
16
+ import { Placeholder, SandBox, Spinner } from '@wordpress/components';
12
17
  import { compose, useResizeObserver } from '@wordpress/compose';
13
18
  import {
14
19
  withColors,
@@ -49,7 +54,7 @@ import {
49
54
  DEFAULT_OVERLAY_COLOR,
50
55
  } from './color-utils';
51
56
  import { DEFAULT_MEDIA_SIZE_SLUG } from '../constants';
52
- import { getIframeSrc, getBackgroundVideoSrc } from '../embed-video-utils';
57
+ import { getBackgroundEmbedHtml } from '../embed-video-utils';
53
58
 
54
59
  function getInnerBlocksTemplate( attributes ) {
55
60
  return [
@@ -121,6 +126,14 @@ function CoverEdit( {
121
126
 
122
127
  const { __unstableMarkNextChangeAsNotPersistent } =
123
128
  useDispatch( blockEditorStore );
129
+
130
+ // Ref to access latest values after async operations (e.g. getMediaColor),
131
+ // avoiding stale values that could overwrite concurrent remote changes.
132
+ const propsRef = useRef( { attributes, overlayColor } );
133
+ useLayoutEffect( () => {
134
+ propsRef.current = { attributes, overlayColor };
135
+ } );
136
+
124
137
  const { media } = useSelect(
125
138
  ( select ) => {
126
139
  return {
@@ -155,22 +168,26 @@ function CoverEdit( {
155
168
 
156
169
  const averageBackgroundColor = await getMediaColor( mediaUrl );
157
170
 
158
- let newOverlayColor = overlayColor.color;
159
- if ( ! isUserOverlayColor ) {
171
+ // Read latest values after await to avoid stale closures.
172
+ const { attributes: currentAttrs, overlayColor: currentOverlay } =
173
+ propsRef.current;
174
+
175
+ let newOverlayColor = currentOverlay.color;
176
+ if ( ! currentAttrs.isUserOverlayColor ) {
160
177
  newOverlayColor = averageBackgroundColor;
161
178
  __unstableMarkNextChangeAsNotPersistent();
162
179
  setOverlayColor( newOverlayColor );
163
180
  }
164
181
 
165
182
  const newIsDark = compositeIsDark(
166
- dimRatio,
183
+ currentAttrs.dimRatio,
167
184
  newOverlayColor,
168
185
  averageBackgroundColor
169
186
  );
170
187
  __unstableMarkNextChangeAsNotPersistent();
171
188
  setAttributes( {
172
189
  isDark: newIsDark,
173
- isUserOverlayColor: isUserOverlayColor || false,
190
+ isUserOverlayColor: currentAttrs.isUserOverlayColor || false,
174
191
  } );
175
192
  } )();
176
193
  // Update the block only when the featured image changes.
@@ -201,8 +218,12 @@ function CoverEdit( {
201
218
  isImage ? newMedia?.url : undefined
202
219
  );
203
220
 
204
- let newOverlayColor = overlayColor.color;
205
- if ( ! isUserOverlayColor ) {
221
+ // Read latest values to avoid stale closures.
222
+ const { attributes: currentAttrs, overlayColor: currentOverlay } =
223
+ propsRef.current;
224
+
225
+ let newOverlayColor = currentOverlay.color;
226
+ if ( ! currentAttrs.isUserOverlayColor ) {
206
227
  newOverlayColor = averageBackgroundColor;
207
228
  setOverlayColor( newOverlayColor );
208
229
 
@@ -214,7 +235,9 @@ function CoverEdit( {
214
235
  // to avoid resetting to 50 if it has been explicitly set to 100.
215
236
  // See issue #52835 for context.
216
237
  const newDimRatio =
217
- originalUrl === undefined && dimRatio === 100 ? 50 : dimRatio;
238
+ currentAttrs.url === undefined && currentAttrs.dimRatio === 100
239
+ ? 50
240
+ : currentAttrs.dimRatio;
218
241
 
219
242
  const newIsDark = compositeIsDark(
220
243
  newDimRatio,
@@ -256,7 +279,7 @@ function CoverEdit( {
256
279
  useFeaturedImage: undefined,
257
280
  dimRatio: newDimRatio,
258
281
  isDark: newIsDark,
259
- isUserOverlayColor: isUserOverlayColor || false,
282
+ isUserOverlayColor: currentAttrs.isUserOverlayColor || false,
260
283
  } );
261
284
  };
262
285
 
@@ -290,8 +313,12 @@ function CoverEdit( {
290
313
 
291
314
  const onSetOverlayColor = async ( newOverlayColor ) => {
292
315
  const averageBackgroundColor = await getMediaColor( url );
316
+
317
+ // Read latest dimRatio after await to avoid stale closure.
318
+ const { attributes: currentAttrs } = propsRef.current;
319
+
293
320
  const newIsDark = compositeIsDark(
294
- dimRatio,
321
+ currentAttrs.dimRatio,
295
322
  newOverlayColor,
296
323
  averageBackgroundColor
297
324
  );
@@ -309,9 +336,13 @@ function CoverEdit( {
309
336
 
310
337
  const onUpdateDimRatio = async ( newDimRatio ) => {
311
338
  const averageBackgroundColor = await getMediaColor( url );
339
+
340
+ // Read latest overlayColor after await to avoid stale closure.
341
+ const { overlayColor: currentOverlay } = propsRef.current;
342
+
312
343
  const newIsDark = compositeIsDark(
313
344
  newDimRatio,
314
- overlayColor.color,
345
+ currentOverlay.color,
315
346
  averageBackgroundColor
316
347
  );
317
348
 
@@ -365,23 +396,15 @@ function CoverEdit( {
365
396
  [ url, backgroundType ]
366
397
  );
367
398
 
368
- // Compute embedSrc on-the-fly from embed preview for editor display
369
- const embedSrc = useMemo( () => {
399
+ // Compute embed HTML for editor display via SandBox
400
+ const embedHtml = useMemo( () => {
370
401
  if (
371
402
  backgroundType !== EMBED_VIDEO_BACKGROUND_TYPE ||
372
403
  ! embedPreview?.html
373
404
  ) {
374
405
  return null;
375
406
  }
376
-
377
- // Extract iframe src from embed HTML
378
- const iframeSrc = getIframeSrc( embedPreview.html );
379
- if ( ! iframeSrc ) {
380
- return null;
381
- }
382
-
383
- // Modify the src to add background video parameters (provider auto-detected)
384
- return getBackgroundVideoSrc( iframeSrc );
407
+ return getBackgroundEmbedHtml( embedPreview.html );
385
408
  }, [ embedPreview, backgroundType ] );
386
409
 
387
410
  const isUploadingMedia = isTemporaryMedia( id, url );
@@ -477,11 +500,15 @@ function CoverEdit( {
477
500
  ? await getMediaColor( mediaUrl )
478
501
  : DEFAULT_BACKGROUND_COLOR;
479
502
 
480
- const newOverlayColor = ! isUserOverlayColor
503
+ // Read latest values after await to avoid stale closures.
504
+ const { attributes: currentAttrs, overlayColor: currentOverlay } =
505
+ propsRef.current;
506
+
507
+ const newOverlayColor = ! currentAttrs.isUserOverlayColor
481
508
  ? averageBackgroundColor
482
- : overlayColor.color;
509
+ : currentOverlay.color;
483
510
 
484
- if ( ! isUserOverlayColor ) {
511
+ if ( ! currentAttrs.isUserOverlayColor ) {
485
512
  if ( newUseFeaturedImage ) {
486
513
  setOverlayColor( newOverlayColor );
487
514
  } else {
@@ -492,7 +519,8 @@ function CoverEdit( {
492
519
  __unstableMarkNextChangeAsNotPersistent();
493
520
  }
494
521
 
495
- const newDimRatio = dimRatio === 100 ? 50 : dimRatio;
522
+ const newDimRatio =
523
+ currentAttrs.dimRatio === 100 ? 50 : currentAttrs.dimRatio;
496
524
  const newIsDark = compositeIsDark(
497
525
  newDimRatio,
498
526
  newOverlayColor,
@@ -668,21 +696,22 @@ function CoverEdit( {
668
696
  style={ mediaStyle }
669
697
  />
670
698
  ) }
671
- { isEmbedVideoBackground && embedSrc && (
699
+ { isEmbedVideoBackground && embedHtml && (
672
700
  <div
673
701
  ref={ mediaElement }
674
702
  className="wp-block-cover__video-background wp-block-cover__embed-background"
675
703
  style={ mediaStyle }
676
704
  >
677
- <iframe
678
- src={ embedSrc }
705
+ <SandBox
706
+ html={ embedHtml }
679
707
  title="Background video"
680
- frameBorder="0"
681
- allow="autoplay; fullscreen"
708
+ styles={ [
709
+ 'iframe{position:fixed;top:0;left:0;width:100%;height:100%;}',
710
+ ] }
682
711
  />
683
712
  </div>
684
713
  ) }
685
- { isEmbedVideoBackground && ! embedSrc && isFetchingEmbed && (
714
+ { isEmbedVideoBackground && ! embedHtml && isFetchingEmbed && (
686
715
  <Spinner />
687
716
  ) }
688
717
 
@@ -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
  } );
@@ -115,6 +115,20 @@ function InputFieldBlock( { attributes, setAttributes, className } ) {
115
115
  'Affects the "name" attribute of the input element, and is used as a name for the form submission results.'
116
116
  ) }
117
117
  />
118
+ { 'hidden' === type && (
119
+ <TextControl
120
+ __next40pxDefaultSize
121
+ autoComplete="off"
122
+ label={ __( 'Value' ) }
123
+ value={ value }
124
+ onChange={ ( newVal ) =>
125
+ setAttributes( { value: newVal } )
126
+ }
127
+ help={ __(
128
+ 'Sets the stored value for this hidden field.'
129
+ ) }
130
+ />
131
+ ) }
118
132
  </InspectorControls>
119
133
  </>
120
134
  );
@@ -133,23 +147,13 @@ function InputFieldBlock( { attributes, setAttributes, className } ) {
133
147
 
134
148
  if ( 'hidden' === type ) {
135
149
  return (
136
- <>
150
+ <div { ...blockProps }>
137
151
  { controls }
138
- <input
139
- type="hidden"
140
- className={ clsx(
141
- className,
142
- 'wp-block-form-input__input',
143
- colorProps.className,
144
- borderProps.className
145
- ) }
146
- aria-label={ __( 'Value' ) }
147
- value={ value }
148
- onChange={ ( event ) =>
149
- setAttributes( { value: event.target.value } )
150
- }
152
+ <span
153
+ className="wp-block-form-input__label is-input-hidden"
154
+ data-message={ __( 'Hidden field' ) }
151
155
  />
152
- </>
156
+ </div>
153
157
  );
154
158
  }
155
159
 
@@ -1,24 +1,24 @@
1
1
  .wp-block-form-input {
2
2
  .is-input-hidden {
3
+ display: flex;
4
+ position: relative;
3
5
  font-size: 0.85em;
4
6
  opacity: 0.3;
5
7
  border: 1px dashed;
6
8
  padding: 0.5em;
7
9
  box-sizing: border-box;
8
10
  background: repeating-linear-gradient(45deg, transparent, transparent 5px, currentColor 5px, currentColor 6px);
11
+ justify-content: center;
12
+ align-items: center;
9
13
 
10
- input[type="text"] {
11
- background: transparent;
14
+ &::after {
15
+ content: attr(data-message);
12
16
  }
13
17
  }
14
18
  &.is-selected {
15
19
  .is-input-hidden {
16
20
  opacity: 1;
17
21
  background: none;
18
-
19
- input[type="text"] {
20
- background: unset;
21
- }
22
22
  }
23
23
  }
24
24
  }
@@ -70,6 +70,16 @@ const variations = [
70
70
  scope: [ 'inserter', 'transform' ],
71
71
  isActive: ( blockAttributes ) => blockAttributes?.type === 'number',
72
72
  },
73
+ {
74
+ name: 'hidden',
75
+ title: __( 'Hidden Input' ),
76
+ icon: 'visibility',
77
+ description: __( 'A hidden input field.' ),
78
+ attributes: { type: 'hidden' },
79
+ isDefault: true,
80
+ scope: [ 'inserter', 'transform' ],
81
+ isActive: ( blockAttributes ) => blockAttributes?.type === 'hidden',
82
+ },
73
83
  ];
74
84
 
75
85
  export default variations;
@@ -28,8 +28,10 @@
28
28
  "background": {
29
29
  "backgroundImage": true,
30
30
  "backgroundSize": true,
31
+ "gradient": true,
31
32
  "__experimentalDefaultControls": {
32
- "backgroundImage": true
33
+ "backgroundImage": true,
34
+ "gradient": true
33
35
  }
34
36
  },
35
37
  "color": {