@wordpress/block-editor 15.9.1-next.8b30e05b0.0 → 15.10.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 (196) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +8 -0
  3. package/build/components/block-alignment-matrix-control/index.js +1 -8
  4. package/build/components/block-alignment-matrix-control/index.js.map +2 -2
  5. package/build/components/block-bindings/attribute-control.js +172 -0
  6. package/build/components/block-bindings/attribute-control.js.map +7 -0
  7. package/build/components/block-bindings/index.js +47 -0
  8. package/build/components/block-bindings/index.js.map +7 -0
  9. package/build/components/block-bindings/source-fields-list.js +135 -0
  10. package/build/components/block-bindings/source-fields-list.js.map +7 -0
  11. package/build/components/block-bindings/use-block-bindings-utils.js +66 -0
  12. package/build/components/block-bindings/use-block-bindings-utils.js.map +7 -0
  13. package/build/components/block-edit/edit.js +1 -3
  14. package/build/components/block-edit/edit.js.map +2 -2
  15. package/build/components/block-inspector/edit-contents.js +93 -14
  16. package/build/components/block-inspector/edit-contents.js.map +3 -3
  17. package/build/components/block-inspector/index.js +44 -28
  18. package/build/components/block-inspector/index.js.map +2 -2
  19. package/build/components/block-settings-menu-controls/edit-section-menu-item.js +39 -9
  20. package/build/components/block-settings-menu-controls/edit-section-menu-item.js.map +3 -3
  21. package/build/components/block-styles/preview-panel.js +3 -5
  22. package/build/components/block-styles/preview-panel.js.map +2 -2
  23. package/build/components/block-styles/use-styles-for-block.js +2 -2
  24. package/build/components/block-styles/use-styles-for-block.js.map +2 -2
  25. package/build/components/block-toolbar/index.js +1 -8
  26. package/build/components/block-toolbar/index.js.map +3 -3
  27. package/build/components/content-only-controls/index.js +2 -25
  28. package/build/components/content-only-controls/index.js.map +2 -2
  29. package/build/components/content-only-controls/link/index.js +3 -3
  30. package/build/components/content-only-controls/link/index.js.map +2 -2
  31. package/build/components/content-only-controls/media/index.js +3 -3
  32. package/build/components/content-only-controls/media/index.js.map +2 -2
  33. package/build/components/content-only-controls/rich-text/index.js +3 -2
  34. package/build/components/content-only-controls/rich-text/index.js.map +2 -2
  35. package/build/components/dimensions-tool/width-height-tool.js +4 -16
  36. package/build/components/dimensions-tool/width-height-tool.js.map +3 -3
  37. package/build/components/grid/grid-item-resizer.js +9 -5
  38. package/build/components/grid/grid-item-resizer.js.map +2 -2
  39. package/build/components/image-editor/cropper.js +3 -34
  40. package/build/components/image-editor/cropper.js.map +3 -3
  41. package/build/components/image-editor/index.js +9 -3
  42. package/build/components/image-editor/index.js.map +2 -2
  43. package/build/components/image-editor/use-transform-image.js +62 -32
  44. package/build/components/image-editor/use-transform-image.js.map +2 -2
  45. package/build/components/image-editor/zoom-dropdown.js +2 -2
  46. package/build/components/image-editor/zoom-dropdown.js.map +2 -2
  47. package/build/components/index.js +7 -3
  48. package/build/components/index.js.map +2 -2
  49. package/build/components/inserter/hooks/use-insertion-point.js +5 -2
  50. package/build/components/inserter/hooks/use-insertion-point.js.map +2 -2
  51. package/build/components/inserter-draggable-blocks/index.js +8 -4
  52. package/build/components/inserter-draggable-blocks/index.js.map +2 -2
  53. package/build/components/inspector-controls-tabs/content-tab.js +3 -2
  54. package/build/components/inspector-controls-tabs/content-tab.js.map +2 -2
  55. package/build/components/link-control/index.js +1 -1
  56. package/build/components/link-control/index.js.map +2 -2
  57. package/build/components/link-control/search-input.js +2 -2
  58. package/build/components/link-control/search-input.js.map +2 -2
  59. package/build/hooks/block-bindings.js +22 -260
  60. package/build/hooks/block-bindings.js.map +3 -3
  61. package/build/layouts/grid.js +23 -28
  62. package/build/layouts/grid.js.map +2 -2
  63. package/build/private-apis.js +1 -0
  64. package/build/private-apis.js.map +2 -2
  65. package/build/store/private-keys.js +3 -0
  66. package/build/store/private-keys.js.map +2 -2
  67. package/build/store/private-selectors.js +2 -1
  68. package/build/store/private-selectors.js.map +2 -2
  69. package/build/store/reducer.js +3 -2
  70. package/build/store/reducer.js.map +2 -2
  71. package/build/utils/block-bindings.js +2 -44
  72. package/build/utils/block-bindings.js.map +3 -3
  73. package/build/utils/index.js +2 -5
  74. package/build/utils/index.js.map +2 -2
  75. package/build-module/components/block-alignment-matrix-control/index.js +1 -8
  76. package/build-module/components/block-alignment-matrix-control/index.js.map +2 -2
  77. package/build-module/components/block-bindings/attribute-control.js +150 -0
  78. package/build-module/components/block-bindings/attribute-control.js.map +7 -0
  79. package/build-module/components/block-bindings/index.js +10 -0
  80. package/build-module/components/block-bindings/index.js.map +7 -0
  81. package/build-module/components/block-bindings/source-fields-list.js +104 -0
  82. package/build-module/components/block-bindings/source-fields-list.js.map +7 -0
  83. package/build-module/components/block-bindings/use-block-bindings-utils.js +45 -0
  84. package/build-module/components/block-bindings/use-block-bindings-utils.js.map +7 -0
  85. package/build-module/components/block-edit/edit.js +1 -3
  86. package/build-module/components/block-edit/edit.js.map +2 -2
  87. package/build-module/components/block-inspector/edit-contents.js +93 -14
  88. package/build-module/components/block-inspector/edit-contents.js.map +2 -2
  89. package/build-module/components/block-inspector/index.js +44 -28
  90. package/build-module/components/block-inspector/index.js.map +2 -2
  91. package/build-module/components/block-settings-menu-controls/edit-section-menu-item.js +39 -9
  92. package/build-module/components/block-settings-menu-controls/edit-section-menu-item.js.map +2 -2
  93. package/build-module/components/block-styles/preview-panel.js +3 -5
  94. package/build-module/components/block-styles/preview-panel.js.map +2 -2
  95. package/build-module/components/block-styles/use-styles-for-block.js +2 -2
  96. package/build-module/components/block-styles/use-styles-for-block.js.map +2 -2
  97. package/build-module/components/block-toolbar/index.js +1 -8
  98. package/build-module/components/block-toolbar/index.js.map +2 -2
  99. package/build-module/components/content-only-controls/index.js +2 -25
  100. package/build-module/components/content-only-controls/index.js.map +2 -2
  101. package/build-module/components/content-only-controls/link/index.js +3 -3
  102. package/build-module/components/content-only-controls/link/index.js.map +2 -2
  103. package/build-module/components/content-only-controls/media/index.js +3 -3
  104. package/build-module/components/content-only-controls/media/index.js.map +2 -2
  105. package/build-module/components/content-only-controls/rich-text/index.js +3 -2
  106. package/build-module/components/content-only-controls/rich-text/index.js.map +2 -2
  107. package/build-module/components/dimensions-tool/width-height-tool.js +4 -6
  108. package/build-module/components/dimensions-tool/width-height-tool.js.map +2 -2
  109. package/build-module/components/grid/grid-item-resizer.js +9 -5
  110. package/build-module/components/grid/grid-item-resizer.js.map +2 -2
  111. package/build-module/components/image-editor/cropper.js +3 -34
  112. package/build-module/components/image-editor/cropper.js.map +2 -2
  113. package/build-module/components/image-editor/index.js +9 -3
  114. package/build-module/components/image-editor/index.js.map +2 -2
  115. package/build-module/components/image-editor/use-transform-image.js +63 -33
  116. package/build-module/components/image-editor/use-transform-image.js.map +2 -2
  117. package/build-module/components/image-editor/zoom-dropdown.js +2 -2
  118. package/build-module/components/image-editor/zoom-dropdown.js.map +2 -2
  119. package/build-module/components/index.js +74 -68
  120. package/build-module/components/index.js.map +2 -2
  121. package/build-module/components/inserter/hooks/use-insertion-point.js +5 -2
  122. package/build-module/components/inserter/hooks/use-insertion-point.js.map +2 -2
  123. package/build-module/components/inserter-draggable-blocks/index.js +8 -4
  124. package/build-module/components/inserter-draggable-blocks/index.js.map +2 -2
  125. package/build-module/components/inspector-controls-tabs/content-tab.js +3 -2
  126. package/build-module/components/inspector-controls-tabs/content-tab.js.map +2 -2
  127. package/build-module/components/link-control/index.js +1 -1
  128. package/build-module/components/link-control/index.js.map +2 -2
  129. package/build-module/components/link-control/search-input.js +2 -2
  130. package/build-module/components/link-control/search-input.js.map +2 -2
  131. package/build-module/hooks/block-bindings.js +27 -270
  132. package/build-module/hooks/block-bindings.js.map +2 -2
  133. package/build-module/layouts/grid.js +23 -28
  134. package/build-module/layouts/grid.js.map +2 -2
  135. package/build-module/private-apis.js +3 -1
  136. package/build-module/private-apis.js.map +2 -2
  137. package/build-module/store/private-keys.js +2 -0
  138. package/build-module/store/private-keys.js.map +2 -2
  139. package/build-module/store/private-selectors.js +4 -2
  140. package/build-module/store/private-selectors.js.map +2 -2
  141. package/build-module/store/reducer.js +4 -3
  142. package/build-module/store/reducer.js.map +2 -2
  143. package/build-module/utils/block-bindings.js +1 -42
  144. package/build-module/utils/block-bindings.js.map +2 -2
  145. package/build-module/utils/index.js +1 -3
  146. package/build-module/utils/index.js.map +2 -2
  147. package/build-style/style-rtl.css +6 -6
  148. package/build-style/style.css +6 -6
  149. package/package.json +39 -40
  150. package/src/components/block-alignment-matrix-control/index.js +1 -5
  151. package/src/components/block-bindings/attribute-control.js +174 -0
  152. package/src/components/block-bindings/index.js +6 -0
  153. package/src/components/block-bindings/source-fields-list.js +130 -0
  154. package/src/components/block-bindings/use-block-bindings-utils.js +156 -0
  155. package/src/components/block-edit/edit.js +1 -3
  156. package/src/components/block-inspector/edit-contents.js +108 -18
  157. package/src/components/block-inspector/index.js +53 -30
  158. package/src/components/block-settings-menu-controls/edit-section-menu-item.js +50 -6
  159. package/src/components/block-styles/preview-panel.js +3 -5
  160. package/src/components/block-styles/use-styles-for-block.js +2 -2
  161. package/src/components/block-toolbar/index.js +1 -6
  162. package/src/components/block-toolbar/style.scss +6 -6
  163. package/src/components/content-only-controls/index.js +2 -27
  164. package/src/components/content-only-controls/link/index.js +3 -3
  165. package/src/components/content-only-controls/media/index.js +3 -3
  166. package/src/components/content-only-controls/rich-text/index.js +3 -2
  167. package/src/components/dimensions-tool/width-height-tool.js +6 -13
  168. package/src/components/grid/grid-item-resizer.js +18 -5
  169. package/src/components/image-editor/cropper.js +3 -32
  170. package/src/components/image-editor/index.js +34 -29
  171. package/src/components/image-editor/use-transform-image.js +80 -34
  172. package/src/components/image-editor/zoom-dropdown.js +2 -2
  173. package/src/components/index.js +5 -1
  174. package/src/components/inserter/hooks/use-insertion-point.js +3 -0
  175. package/src/components/inserter/style.scss +1 -1
  176. package/src/components/inserter-draggable-blocks/index.js +19 -8
  177. package/src/components/inspector-controls-tabs/content-tab.js +6 -2
  178. package/src/components/link-control/index.js +1 -1
  179. package/src/components/link-control/search-input.js +8 -2
  180. package/src/components/link-control/test/index.js +146 -7
  181. package/src/hooks/block-bindings.js +27 -347
  182. package/src/layouts/grid.js +40 -72
  183. package/src/layouts/test/grid.js +14 -0
  184. package/src/private-apis.js +2 -0
  185. package/src/store/private-keys.js +1 -0
  186. package/src/store/private-selectors.js +8 -1
  187. package/src/store/reducer.js +10 -3
  188. package/src/utils/block-bindings.js +0 -157
  189. package/src/utils/index.js +0 -1
  190. package/tsconfig.json +1 -0
  191. package/build/components/block-toolbar/block-name-context.js +0 -30
  192. package/build/components/block-toolbar/block-name-context.js.map +0 -7
  193. package/build-module/components/block-toolbar/block-name-context.js +0 -9
  194. package/build-module/components/block-toolbar/block-name-context.js.map +0 -7
  195. package/src/components/block-toolbar/block-name-context.js +0 -9
  196. /package/src/{utils → components/block-bindings}/test/use-block-bindings-utils.js +0 -0
@@ -72,20 +72,20 @@ export default {
72
72
  } ) {
73
73
  const { allowSizingOnChildren = false } = layoutBlockSupport;
74
74
 
75
- // In the experiment we want to also show column control in Auto mode, and
76
- // the minimum width control in Manual mode.
77
- const showColumnsControl =
78
- window.__experimentalEnableGridInteractivity ||
79
- !! layout?.columnCount;
75
+ // Always show both column and minimum width controls in Auto mode.
76
+ // Manual mode (with isManualPlacement) is only available behind the experiment flag.
77
+ const showColumnsControl = true;
80
78
  const showMinWidthControl =
81
- window.__experimentalEnableGridInteractivity ||
82
- ! layout?.columnCount;
79
+ ! layout?.isManualPlacement ||
80
+ window.__experimentalEnableGridInteractivity;
83
81
  return (
84
82
  <>
85
- <GridLayoutTypeControl
86
- layout={ layout }
87
- onChange={ onChange }
88
- />
83
+ { window.__experimentalEnableGridInteractivity && (
84
+ <GridLayoutTypeControl
85
+ layout={ layout }
86
+ onChange={ onChange }
87
+ />
88
+ ) }
89
89
  <VStack spacing={ 4 }>
90
90
  { showColumnsControl && (
91
91
  <GridLayoutColumnsAndRowsControl
@@ -243,7 +243,7 @@ function GridLayoutMinimumWidthControl( { layout, onChange } ) {
243
243
  return (
244
244
  <fieldset className="block-editor-hooks__grid-layout-minimum-width-control">
245
245
  <BaseControl.VisualLabel as="legend">
246
- { __( 'Minimum column width' ) }
246
+ { __( 'Min. column width' ) }
247
247
  </BaseControl.VisualLabel>
248
248
  <Flex gap={ 4 }>
249
249
  <FlexItem isBlock>
@@ -278,6 +278,11 @@ function GridLayoutMinimumWidthControl( { layout, onChange } ) {
278
278
  />
279
279
  </FlexItem>
280
280
  </Flex>
281
+ <p className="components-base-control__help">
282
+ { __(
283
+ 'Columns will wrap to fewer per row when they can no longer maintain the minimum width.'
284
+ ) }
285
+ </p>
281
286
  </fieldset>
282
287
  );
283
288
  }
@@ -288,10 +293,8 @@ function GridLayoutColumnsAndRowsControl( {
288
293
  onChange,
289
294
  allowSizingOnChildren,
290
295
  } ) {
291
- // If the grid interactivity experiment is enabled, allow unsetting the column count.
292
- const defaultColumnCount = window.__experimentalEnableGridInteractivity
293
- ? undefined
294
- : 3;
296
+ // Allow unsetting the column count in Auto mode.
297
+ const defaultColumnCount = undefined;
295
298
  const {
296
299
  columnCount = defaultColumnCount,
297
300
  rowCount,
@@ -301,10 +304,9 @@ function GridLayoutColumnsAndRowsControl( {
301
304
  return (
302
305
  <>
303
306
  <fieldset className="block-editor-hooks__grid-layout-columns-and-rows-controls">
304
- { ( ! window.__experimentalEnableGridInteractivity ||
305
- ! isManualPlacement ) && (
307
+ { ! isManualPlacement && (
306
308
  <BaseControl.VisualLabel as="legend">
307
- { __( 'Columns' ) }
309
+ { __( 'Max. columns' ) }
308
310
  </BaseControl.VisualLabel>
309
311
  ) }
310
312
  <Flex gap={ 4 }>
@@ -312,46 +314,28 @@ function GridLayoutColumnsAndRowsControl( {
312
314
  <NumberControl
313
315
  size="__unstable-large"
314
316
  onChange={ ( value ) => {
315
- if (
316
- window.__experimentalEnableGridInteractivity
317
- ) {
318
- // Allow unsetting the column count when in auto mode.
319
- const defaultNewColumnCount =
320
- isManualPlacement ? 1 : undefined;
321
- const newColumnCount =
322
- value === '' || value === '0'
323
- ? defaultNewColumnCount
324
- : parseInt( value, 10 );
325
- onChange( {
326
- ...layout,
327
- columnCount: newColumnCount,
328
- } );
329
- } else {
330
- // Don't allow unsetting the column count.
331
- const newColumnCount =
332
- value === '' || value === '0'
333
- ? 1
334
- : parseInt( value, 10 );
335
- onChange( {
336
- ...layout,
337
- columnCount: newColumnCount,
338
- } );
339
- }
317
+ // Allow unsetting the column count when in auto mode.
318
+ const defaultNewColumnCount = isManualPlacement
319
+ ? 1
320
+ : undefined;
321
+ const newColumnCount =
322
+ value === '' || value === '0'
323
+ ? defaultNewColumnCount
324
+ : parseInt( value, 10 );
325
+ onChange( {
326
+ ...layout,
327
+ columnCount: newColumnCount,
328
+ } );
340
329
  } }
341
330
  value={ columnCount }
342
331
  min={ 1 }
343
332
  label={ __( 'Columns' ) }
344
- hideLabelFromVision={
345
- ! window.__experimentalEnableGridInteractivity ||
346
- ! isManualPlacement
347
- }
333
+ hideLabelFromVision={ ! isManualPlacement }
348
334
  />
349
335
  </FlexItem>
350
336
 
351
337
  <FlexItem isBlock>
352
- { window.__experimentalEnableGridInteractivity &&
353
- allowSizingOnChildren &&
354
- isManualPlacement ? (
338
+ { allowSizingOnChildren && isManualPlacement ? (
355
339
  <NumberControl
356
340
  size="__unstable-large"
357
341
  onChange={ ( value ) => {
@@ -414,11 +398,7 @@ function GridLayoutTypeControl( { layout, onChange } ) {
414
398
  minimumColumnWidth || '12rem'
415
399
  );
416
400
 
417
- const gridPlacement =
418
- isManualPlacement ||
419
- ( !! columnCount && ! window.__experimentalEnableGridInteractivity )
420
- ? 'manual'
421
- : 'auto';
401
+ const gridPlacement = isManualPlacement ? 'manual' : 'auto';
422
402
 
423
403
  const onChangeType = ( value ) => {
424
404
  if ( value === 'manual' ) {
@@ -429,17 +409,9 @@ function GridLayoutTypeControl( { layout, onChange } ) {
429
409
  }
430
410
  onChange( {
431
411
  ...layout,
432
- columnCount: value === 'manual' ? tempColumnCount : null,
433
- rowCount:
434
- value === 'manual' &&
435
- window.__experimentalEnableGridInteractivity
436
- ? tempRowCount
437
- : undefined,
438
- isManualPlacement:
439
- value === 'manual' &&
440
- window.__experimentalEnableGridInteractivity
441
- ? true
442
- : undefined,
412
+ columnCount: value === 'manual' ? tempColumnCount : tempColumnCount,
413
+ rowCount: value === 'manual' ? tempRowCount : undefined,
414
+ isManualPlacement: value === 'manual' ? true : undefined,
443
415
  minimumColumnWidth:
444
416
  value === 'auto' ? tempMinimumColumnWidth : null,
445
417
  } );
@@ -462,11 +434,7 @@ function GridLayoutTypeControl( { layout, onChange } ) {
462
434
  value={ gridPlacement }
463
435
  onChange={ onChangeType }
464
436
  isBlock
465
- help={
466
- window.__experimentalEnableGridInteractivity
467
- ? helpText
468
- : undefined
469
- }
437
+ help={ helpText }
470
438
  >
471
439
  <ToggleGroupControlOption
472
440
  key="auto"
@@ -30,6 +30,20 @@ describe( 'getLayoutStyle', () => {
30
30
  layoutDefinitions: undefined,
31
31
  } );
32
32
 
33
+ expect( result ).toBe( expected );
34
+ } );
35
+ it( 'should return `grid-template-columns` with max() function if both minimumColumnWidth and columnCount are provided', () => {
36
+ const expected = `.my-container { grid-template-columns: repeat(auto-fill, minmax(max(12rem, ( 100% - (1.2rem*2) ) / 3), 1fr)); container-type: inline-size; }`;
37
+
38
+ const result = grid.getLayoutStyle( {
39
+ selector: '.my-container',
40
+ layout: { minimumColumnWidth: '12rem', columnCount: 3 },
41
+ style: {},
42
+ blockName: 'test-block',
43
+ hasBlockGapSupport: false,
44
+ layoutDefinitions: undefined,
45
+ } );
46
+
33
47
  expect( result ).toBe( expected );
34
48
  } );
35
49
  } );
@@ -42,6 +42,7 @@ import {
42
42
  mediaEditKey,
43
43
  getMediaSelectKey,
44
44
  essentialFormatKey,
45
+ isIsolatedEditorKey,
45
46
  } from './store/private-keys';
46
47
  import { requiresWrapperOnCopy } from './components/writing-flow/utils';
47
48
  import { PrivateRichText } from './components/rich-text/';
@@ -110,6 +111,7 @@ lock( privateApis, {
110
111
  mediaEditKey,
111
112
  getMediaSelectKey,
112
113
  essentialFormatKey,
114
+ isIsolatedEditorKey,
113
115
  useBlockElement,
114
116
  useBlockElementRef,
115
117
  } );
@@ -6,3 +6,4 @@ export const sectionRootClientIdKey = Symbol( 'sectionRootClientIdKey' );
6
6
  export const mediaEditKey = Symbol( 'mediaEditKey' );
7
7
  export const getMediaSelectKey = Symbol( 'getMediaSelect' );
8
8
  export const essentialFormatKey = Symbol( 'essentialFormat' );
9
+ export const isIsolatedEditorKey = Symbol( 'isIsolatedEditor' );
@@ -35,6 +35,7 @@ import {
35
35
  selectBlockPatternsKey,
36
36
  reusableBlocksSelectKey,
37
37
  sectionRootClientIdKey,
38
+ isIsolatedEditorKey,
38
39
  } from './private-keys';
39
40
 
40
41
  const { isContentBlock } = unlock( blocksPrivateApis );
@@ -524,9 +525,15 @@ export function isSectionBlock( state, clientId ) {
524
525
 
525
526
  const attributes = getBlockAttributes( state, clientId );
526
527
  const isTemplatePart = blockName === 'core/template-part';
528
+
529
+ // When in an isolated editing context (e.g., editing a template part or pattern directly),
530
+ // don't treat nested unsynced patterns as section blocks.
531
+ const isIsolatedEditor = state.settings?.[ isIsolatedEditorKey ];
532
+
527
533
  if (
528
534
  ( attributes?.metadata?.patternName || isTemplatePart ) &&
529
- !! window?.__experimentalContentOnlyPatternInsertion
535
+ !! window?.__experimentalContentOnlyPatternInsertion &&
536
+ ! isIsolatedEditor
530
537
  ) {
531
538
  return true;
532
539
  }
@@ -19,7 +19,7 @@ import {
19
19
  */
20
20
  import { PREFERENCES_DEFAULTS, SETTINGS_DEFAULTS } from './defaults';
21
21
  import { insertAt, moveTo } from './array';
22
- import { sectionRootClientIdKey } from './private-keys';
22
+ import { sectionRootClientIdKey, isIsolatedEditorKey } from './private-keys';
23
23
  import { unlock } from '../lock-unlock';
24
24
 
25
25
  const { isContentBlock } = unlock( blocksPrivateApis );
@@ -2292,10 +2292,16 @@ function getDerivedBlockEditingModesForTree( state, treeClientId = '' ) {
2292
2292
  ( clientId ) =>
2293
2293
  state.blockListSettings[ clientId ]?.templateLock === 'contentOnly'
2294
2294
  );
2295
+
2296
+ // When in an isolated editing context (e.g., editing a template part or pattern directly),
2297
+ // don't apply contentOnly mode to nested unsynced patterns or template parts.
2298
+ const isIsolatedEditor = state.settings?.[ isIsolatedEditorKey ];
2299
+
2295
2300
  // Use array.from for better back compat. Older versions of the iterator returned
2296
2301
  // from `keys()` didn't have the `filter` method.
2297
2302
  const unsyncedPatternClientIds =
2298
- !! window?.__experimentalContentOnlyPatternInsertion
2303
+ !! window?.__experimentalContentOnlyPatternInsertion &&
2304
+ ! isIsolatedEditor
2299
2305
  ? Array.from( state.blocks.attributes.keys() ).filter(
2300
2306
  ( clientId ) =>
2301
2307
  state.blocks.attributes.get( clientId )?.metadata
@@ -2305,7 +2311,8 @@ function getDerivedBlockEditingModesForTree( state, treeClientId = '' ) {
2305
2311
  const contentOnlyParents = [
2306
2312
  ...contentOnlyTemplateLockedClientIds,
2307
2313
  ...unsyncedPatternClientIds,
2308
- ...( window?.__experimentalContentOnlyPatternInsertion
2314
+ ...( window?.__experimentalContentOnlyPatternInsertion &&
2315
+ ! isIsolatedEditor
2309
2316
  ? templatePartClientIds
2310
2317
  : [] ),
2311
2318
  ];
@@ -1,28 +1,6 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useDispatch, useRegistry } from '@wordpress/data';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
- import { store as blockEditorStore } from '../store';
10
- import { useBlockEditContext } from '../components/block-edit';
11
-
12
1
  const DEFAULT_ATTRIBUTE = '__default';
13
2
  const PATTERN_OVERRIDES_SOURCE = 'core/pattern-overrides';
14
3
 
15
- /**
16
- * Checks if the given object is empty.
17
- *
18
- * @param {?Object} object The object to check.
19
- *
20
- * @return {boolean} Whether the object is empty.
21
- */
22
- function isObjectEmpty( object ) {
23
- return ! object || Object.keys( object ).length === 0;
24
- }
25
-
26
4
  /**
27
5
  * Checks if the block has the `__default` binding for pattern overrides.
28
6
  *
@@ -66,138 +44,3 @@ export function replacePatternOverridesDefaultBinding(
66
44
 
67
45
  return bindings;
68
46
  }
69
-
70
- /**
71
- * Contains utils to update the block `bindings` metadata.
72
- *
73
- * @typedef {Object} WPBlockBindingsUtils
74
- *
75
- * @property {Function} updateBlockBindings Updates the value of the bindings connected to block attributes.
76
- * @property {Function} removeAllBlockBindings Removes the bindings property of the `metadata` attribute.
77
- */
78
-
79
- /**
80
- * Retrieves the existing utils needed to update the block `bindings` metadata.
81
- * They can be used to create, modify, or remove connections from the existing block attributes.
82
- *
83
- * It contains the following utils:
84
- * - `updateBlockBindings`: Updates the value of the bindings connected to block attributes. It can be used to remove a specific binding by setting the value to `undefined`.
85
- * - `removeAllBlockBindings`: Removes the bindings property of the `metadata` attribute.
86
- *
87
- * @since 6.7.0 Introduced in WordPress core.
88
- *
89
- * @param {?string} clientId Optional block client ID. If not set, it will use the current block client ID from the context.
90
- *
91
- * @return {?WPBlockBindingsUtils} Object containing the block bindings utils.
92
- *
93
- * @example
94
- * ```js
95
- * import { useBlockBindingsUtils } from '@wordpress/block-editor'
96
- * const { updateBlockBindings, removeAllBlockBindings } = useBlockBindingsUtils();
97
- *
98
- * // Update url and alt attributes.
99
- * updateBlockBindings( {
100
- * url: {
101
- * source: 'core/post-meta',
102
- * args: {
103
- * key: 'url_custom_field',
104
- * },
105
- * },
106
- * alt: {
107
- * source: 'core/post-meta',
108
- * args: {
109
- * key: 'text_custom_field',
110
- * },
111
- * },
112
- * } );
113
- *
114
- * // Remove binding from url attribute.
115
- * updateBlockBindings( { url: undefined } );
116
- *
117
- * // Remove bindings from all attributes.
118
- * removeAllBlockBindings();
119
- * ```
120
- */
121
- export function useBlockBindingsUtils( clientId ) {
122
- const { clientId: contextClientId } = useBlockEditContext();
123
- const blockClientId = clientId || contextClientId;
124
- const { updateBlockAttributes } = useDispatch( blockEditorStore );
125
- const { getBlockAttributes } = useRegistry().select( blockEditorStore );
126
-
127
- /**
128
- * Updates the value of the bindings connected to block attributes.
129
- * It removes the binding when the new value is `undefined`.
130
- *
131
- * @param {Object} bindings Bindings including the attributes to update and the new object.
132
- * @param {string} bindings.source The source name to connect to.
133
- * @param {Object} [bindings.args] Object containing the arguments needed by the source.
134
- *
135
- * @example
136
- * ```js
137
- * import { useBlockBindingsUtils } from '@wordpress/block-editor'
138
- *
139
- * const { updateBlockBindings } = useBlockBindingsUtils();
140
- * updateBlockBindings( {
141
- * url: {
142
- * source: 'core/post-meta',
143
- * args: {
144
- * key: 'url_custom_field',
145
- * },
146
- * },
147
- * alt: {
148
- * source: 'core/post-meta',
149
- * args: {
150
- * key: 'text_custom_field',
151
- * },
152
- * }
153
- * } );
154
- * ```
155
- */
156
- const updateBlockBindings = ( bindings ) => {
157
- const { metadata: { bindings: currentBindings, ...metadata } = {} } =
158
- getBlockAttributes( blockClientId );
159
- const newBindings = { ...currentBindings };
160
-
161
- Object.entries( bindings ).forEach( ( [ attribute, binding ] ) => {
162
- if ( ! binding && newBindings[ attribute ] ) {
163
- delete newBindings[ attribute ];
164
- return;
165
- }
166
- newBindings[ attribute ] = binding;
167
- } );
168
-
169
- const newMetadata = {
170
- ...metadata,
171
- bindings: newBindings,
172
- };
173
-
174
- if ( isObjectEmpty( newMetadata.bindings ) ) {
175
- delete newMetadata.bindings;
176
- }
177
-
178
- updateBlockAttributes( blockClientId, {
179
- metadata: isObjectEmpty( newMetadata ) ? undefined : newMetadata,
180
- } );
181
- };
182
-
183
- /**
184
- * Removes the bindings property of the `metadata` attribute.
185
- *
186
- * @example
187
- * ```js
188
- * import { useBlockBindingsUtils } from '@wordpress/block-editor'
189
- *
190
- * const { removeAllBlockBindings } = useBlockBindingsUtils();
191
- * removeAllBlockBindings();
192
- * ```
193
- */
194
- const removeAllBlockBindings = () => {
195
- const { metadata: { bindings, ...metadata } = {} } =
196
- getBlockAttributes( blockClientId );
197
- updateBlockAttributes( blockClientId, {
198
- metadata: isObjectEmpty( metadata ) ? undefined : metadata,
199
- } );
200
- };
201
-
202
- return { updateBlockBindings, removeAllBlockBindings };
203
- }
@@ -1,3 +1,2 @@
1
1
  export { default as transformStyles } from './transform-styles';
2
2
  export { default as getPxFromCssUnit } from './get-px-from-css-unit';
3
- export { useBlockBindingsUtils } from './block-bindings';
package/tsconfig.json CHANGED
@@ -23,6 +23,7 @@
23
23
  { "path": "../html-entities" },
24
24
  { "path": "../i18n" },
25
25
  { "path": "../icons" },
26
+ { "path": "../image-cropper" },
26
27
  { "path": "../interactivity" },
27
28
  { "path": "../is-shallow-equal" },
28
29
  { "path": "../keycodes" },
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // packages/block-editor/src/components/block-toolbar/block-name-context.js
21
- var block_name_context_exports = {};
22
- __export(block_name_context_exports, {
23
- default: () => block_name_context_default
24
- });
25
- module.exports = __toCommonJS(block_name_context_exports);
26
- var import_element = require("@wordpress/element");
27
- var __unstableBlockNameContext = (0, import_element.createContext)("");
28
- __unstableBlockNameContext.displayName = "__unstableBlockNameContext";
29
- var block_name_context_default = __unstableBlockNameContext;
30
- //# sourceMappingURL=block-name-context.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/block-toolbar/block-name-context.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\nconst __unstableBlockNameContext = createContext( '' );\n__unstableBlockNameContext.displayName = '__unstableBlockNameContext';\n\nexport default __unstableBlockNameContext;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA8B;AAE9B,IAAM,iCAA6B,8BAAe,EAAG;AACrD,2BAA2B,cAAc;AAEzC,IAAO,6BAAQ;",
6
- "names": []
7
- }
@@ -1,9 +0,0 @@
1
- // packages/block-editor/src/components/block-toolbar/block-name-context.js
2
- import { createContext } from "@wordpress/element";
3
- var __unstableBlockNameContext = createContext("");
4
- __unstableBlockNameContext.displayName = "__unstableBlockNameContext";
5
- var block_name_context_default = __unstableBlockNameContext;
6
- export {
7
- block_name_context_default as default
8
- };
9
- //# sourceMappingURL=block-name-context.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/block-toolbar/block-name-context.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\nconst __unstableBlockNameContext = createContext( '' );\n__unstableBlockNameContext.displayName = '__unstableBlockNameContext';\n\nexport default __unstableBlockNameContext;\n"],
5
- "mappings": ";AAGA,SAAS,qBAAqB;AAE9B,IAAM,6BAA6B,cAAe,EAAG;AACrD,2BAA2B,cAAc;AAEzC,IAAO,6BAAQ;",
6
- "names": []
7
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { createContext } from '@wordpress/element';
5
-
6
- const __unstableBlockNameContext = createContext( '' );
7
- __unstableBlockNameContext.displayName = '__unstableBlockNameContext';
8
-
9
- export default __unstableBlockNameContext;