@wordpress/block-editor 15.6.1-next.36001005c.0 → 15.6.2

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 (169) hide show
  1. package/build/components/background-image-control/index.js +2 -2
  2. package/build/components/background-image-control/index.js.map +2 -2
  3. package/build/components/block-list/block.js +3 -3
  4. package/build/components/block-list/block.js.map +2 -2
  5. package/build/components/block-list/index.js +2 -2
  6. package/build/components/block-list/index.js.map +1 -1
  7. package/build/components/block-quick-navigation/index.js +0 -1
  8. package/build/components/block-quick-navigation/index.js.map +2 -2
  9. package/build/components/global-styles/border-panel.js +1 -2
  10. package/build/components/global-styles/border-panel.js.map +2 -2
  11. package/build/components/global-styles/color-panel.js +1 -2
  12. package/build/components/global-styles/color-panel.js.map +2 -2
  13. package/build/components/global-styles/dimensions-panel.js +2 -3
  14. package/build/components/global-styles/dimensions-panel.js.map +2 -2
  15. package/build/components/global-styles/filters-panel.js +1 -2
  16. package/build/components/global-styles/filters-panel.js.map +2 -2
  17. package/build/components/global-styles/get-block-css-selector.js +78 -0
  18. package/build/components/global-styles/get-block-css-selector.js.map +7 -0
  19. package/build/components/global-styles/hooks.js +95 -23
  20. package/build/components/global-styles/hooks.js.map +2 -2
  21. package/build/components/global-styles/index.js +14 -0
  22. package/build/components/global-styles/index.js.map +2 -2
  23. package/build/components/global-styles/typography-panel.js +19 -3
  24. package/build/components/global-styles/typography-panel.js.map +2 -2
  25. package/build/components/global-styles/typography-utils.js +49 -2
  26. package/build/components/global-styles/typography-utils.js.map +2 -2
  27. package/build/components/global-styles/use-global-styles-output.js +998 -0
  28. package/build/components/global-styles/use-global-styles-output.js.map +7 -0
  29. package/build/components/global-styles/utils.js +377 -0
  30. package/build/components/global-styles/utils.js.map +2 -2
  31. package/build/components/rich-text/index.js +8 -7
  32. package/build/components/rich-text/index.js.map +2 -2
  33. package/build/hooks/allowed-blocks.js +50 -1
  34. package/build/hooks/allowed-blocks.js.map +2 -2
  35. package/build/hooks/block-bindings.js +111 -170
  36. package/build/hooks/block-bindings.js.map +2 -2
  37. package/build/hooks/block-style-variation.js +10 -6
  38. package/build/hooks/block-style-variation.js.map +2 -2
  39. package/build/hooks/custom-class-name.js +1 -1
  40. package/build/hooks/custom-class-name.js.map +1 -1
  41. package/build/hooks/duotone.js +3 -3
  42. package/build/hooks/duotone.js.map +2 -2
  43. package/build/hooks/fit-text.js +33 -20
  44. package/build/hooks/fit-text.js.map +2 -2
  45. package/build/hooks/font-size.js +6 -5
  46. package/build/hooks/font-size.js.map +2 -2
  47. package/build/hooks/metadata.js +48 -2
  48. package/build/hooks/metadata.js.map +2 -2
  49. package/build/hooks/typography.js +11 -4
  50. package/build/hooks/typography.js.map +3 -3
  51. package/build/hooks/use-typography-props.js +2 -2
  52. package/build/hooks/use-typography-props.js.map +2 -2
  53. package/build/store/private-selectors.js +3 -3
  54. package/build/store/private-selectors.js.map +2 -2
  55. package/build/store/selectors.js +38 -13
  56. package/build/store/selectors.js.map +2 -2
  57. package/build/store/utils.js +2 -1
  58. package/build/store/utils.js.map +2 -2
  59. package/build/utils/fit-text-utils.js +4 -4
  60. package/build/utils/fit-text-utils.js.map +2 -2
  61. package/build-module/components/background-image-control/index.js +1 -1
  62. package/build-module/components/background-image-control/index.js.map +2 -2
  63. package/build-module/components/block-list/block.js +3 -3
  64. package/build-module/components/block-list/block.js.map +2 -2
  65. package/build-module/components/block-list/index.js +2 -2
  66. package/build-module/components/block-list/index.js.map +1 -1
  67. package/build-module/components/block-quick-navigation/index.js +0 -1
  68. package/build-module/components/block-quick-navigation/index.js.map +2 -2
  69. package/build-module/components/global-styles/border-panel.js +1 -2
  70. package/build-module/components/global-styles/border-panel.js.map +2 -2
  71. package/build-module/components/global-styles/color-panel.js +1 -2
  72. package/build-module/components/global-styles/color-panel.js.map +2 -2
  73. package/build-module/components/global-styles/dimensions-panel.js +1 -2
  74. package/build-module/components/global-styles/dimensions-panel.js.map +2 -2
  75. package/build-module/components/global-styles/filters-panel.js +1 -2
  76. package/build-module/components/global-styles/filters-panel.js.map +2 -2
  77. package/build-module/components/global-styles/get-block-css-selector.js +54 -0
  78. package/build-module/components/global-styles/get-block-css-selector.js.map +7 -0
  79. package/build-module/components/global-styles/hooks.js +95 -27
  80. package/build-module/components/global-styles/hooks.js.map +2 -2
  81. package/build-module/components/global-styles/index.js +14 -0
  82. package/build-module/components/global-styles/index.js.map +2 -2
  83. package/build-module/components/global-styles/typography-panel.js +19 -3
  84. package/build-module/components/global-styles/typography-panel.js.map +2 -2
  85. package/build-module/components/global-styles/typography-utils.js +49 -1
  86. package/build-module/components/global-styles/typography-utils.js.map +2 -2
  87. package/build-module/components/global-styles/use-global-styles-output.js +979 -0
  88. package/build-module/components/global-styles/use-global-styles-output.js.map +7 -0
  89. package/build-module/components/global-styles/utils.js +364 -0
  90. package/build-module/components/global-styles/utils.js.map +2 -2
  91. package/build-module/components/rich-text/index.js +8 -7
  92. package/build-module/components/rich-text/index.js.map +2 -2
  93. package/build-module/hooks/allowed-blocks.js +49 -1
  94. package/build-module/hooks/allowed-blocks.js.map +2 -2
  95. package/build-module/hooks/block-bindings.js +112 -172
  96. package/build-module/hooks/block-bindings.js.map +2 -2
  97. package/build-module/hooks/block-style-variation.js +12 -4
  98. package/build-module/hooks/block-style-variation.js.map +2 -2
  99. package/build-module/hooks/custom-class-name.js +1 -1
  100. package/build-module/hooks/custom-class-name.js.map +1 -1
  101. package/build-module/hooks/duotone.js +3 -3
  102. package/build-module/hooks/duotone.js.map +2 -2
  103. package/build-module/hooks/fit-text.js +34 -21
  104. package/build-module/hooks/fit-text.js.map +2 -2
  105. package/build-module/hooks/font-size.js +5 -4
  106. package/build-module/hooks/font-size.js.map +2 -2
  107. package/build-module/hooks/metadata.js +46 -1
  108. package/build-module/hooks/metadata.js.map +2 -2
  109. package/build-module/hooks/typography.js +11 -4
  110. package/build-module/hooks/typography.js.map +3 -3
  111. package/build-module/hooks/use-typography-props.js +1 -1
  112. package/build-module/hooks/use-typography-props.js.map +2 -2
  113. package/build-module/store/private-selectors.js +2 -2
  114. package/build-module/store/private-selectors.js.map +2 -2
  115. package/build-module/store/selectors.js +39 -14
  116. package/build-module/store/selectors.js.map +2 -2
  117. package/build-module/store/utils.js +3 -2
  118. package/build-module/store/utils.js.map +2 -2
  119. package/build-module/utils/fit-text-utils.js +4 -4
  120. package/build-module/utils/fit-text-utils.js.map +2 -2
  121. package/build-style/style-rtl.css +6 -10
  122. package/build-style/style.css +6 -10
  123. package/package.json +35 -36
  124. package/src/components/background-image-control/index.js +1 -1
  125. package/src/components/block-card/style.scss +1 -1
  126. package/src/components/block-list/block.js +1 -1
  127. package/src/components/block-list/index.js +2 -2
  128. package/src/components/block-navigation/style.scss +1 -1
  129. package/src/components/block-quick-navigation/index.js +0 -1
  130. package/src/components/block-switcher/style.scss +1 -1
  131. package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
  132. package/src/components/global-styles/border-panel.js +1 -2
  133. package/src/components/global-styles/color-panel.js +1 -2
  134. package/src/components/global-styles/color-panel.native.js +1 -1
  135. package/src/components/global-styles/dimensions-panel.js +1 -2
  136. package/src/components/global-styles/filters-panel.js +1 -2
  137. package/src/components/global-styles/get-block-css-selector.js +114 -0
  138. package/src/components/global-styles/hooks.js +108 -29
  139. package/src/components/global-styles/index.js +8 -0
  140. package/src/components/global-styles/test/typography-utils.js +806 -0
  141. package/src/components/global-styles/test/use-global-styles-output.js +1131 -0
  142. package/src/components/global-styles/test/utils.js +442 -1
  143. package/src/components/global-styles/typography-panel.js +27 -3
  144. package/src/components/global-styles/typography-utils.js +133 -0
  145. package/src/components/global-styles/use-global-styles-output.js +1487 -0
  146. package/src/components/global-styles/utils.js +537 -0
  147. package/src/components/inserter/style.scss +2 -2
  148. package/src/components/multi-selection-inspector/style.scss +1 -1
  149. package/src/components/rich-text/index.js +8 -14
  150. package/src/hooks/allowed-blocks.js +89 -1
  151. package/src/hooks/block-bindings.js +79 -153
  152. package/src/hooks/block-style-variation.js +12 -4
  153. package/src/hooks/custom-class-name.js +1 -1
  154. package/src/hooks/duotone.js +3 -3
  155. package/src/hooks/fit-text.js +39 -30
  156. package/src/hooks/font-size.js +8 -4
  157. package/src/hooks/metadata.js +89 -0
  158. package/src/hooks/test/allowed-blocks.js +278 -0
  159. package/src/hooks/test/metadata.js +316 -0
  160. package/src/hooks/typography.js +15 -4
  161. package/src/hooks/use-typography-props.js +1 -1
  162. package/src/store/private-selectors.js +2 -2
  163. package/src/store/selectors.js +59 -21
  164. package/src/store/test/selectors.js +1 -1
  165. package/src/store/utils.js +2 -1
  166. package/src/style.scss +0 -1
  167. package/src/utils/fit-text-utils.js +4 -16
  168. package/tsconfig.json +0 -1
  169. package/src/components/block-quick-navigation/style.scss +0 -5
@@ -2,7 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { addFilter } from '@wordpress/hooks';
5
- import { hasBlockSupport } from '@wordpress/blocks';
5
+ import { hasBlockSupport, getBlockType } from '@wordpress/blocks';
6
6
  import { useSelect } from '@wordpress/data';
7
7
 
8
8
  /**
@@ -72,3 +72,91 @@ addFilter(
72
72
  'core/allowedBlocks/attribute',
73
73
  addAttribute
74
74
  );
75
+
76
+ /**
77
+ * Add transforms to preserve allowedBlocks on block transformations.
78
+ *
79
+ * @param {Object} result The transformed block.
80
+ * @param {Array} source Original blocks transformed.
81
+ * @param {number} index Index of the transformed block.
82
+ * @param {Array} results All blocks that resulted from the transformation.
83
+ * @return {Object} Modified transformed block.
84
+ */
85
+ export function addTransforms( result, source, index, results ) {
86
+ if ( ! hasBlockSupport( result.name, 'allowedBlocks' ) ) {
87
+ return result;
88
+ }
89
+
90
+ // If the condition verifies we are probably in the presence of a wrapping transform
91
+ // e.g: nesting paragraphs in a group or columns and in that case the attribute should not be kept.
92
+ if (
93
+ source.length !== 1 &&
94
+ results.length === 1 &&
95
+ result.innerBlocks.length === source.length
96
+ ) {
97
+ return result;
98
+ }
99
+
100
+ // If we are transforming one block to multiple blocks or multiple blocks to one block,
101
+ // we ignore the attribute during the transform.
102
+ if (
103
+ ( results.length === 1 && source.length > 1 ) ||
104
+ ( results.length > 1 && source.length === 1 )
105
+ ) {
106
+ return result;
107
+ }
108
+
109
+ // If we are transforming multiple blocks to multiple blocks with different counts,
110
+ // we ignore the attribute during the transform.
111
+ if (
112
+ results.length > 1 &&
113
+ source.length > 1 &&
114
+ results.length !== source.length
115
+ ) {
116
+ return result;
117
+ }
118
+
119
+ // If the target block already has allowedBlocks, we don't need to preserve
120
+ // the source allowedBlocks.
121
+ if ( result.attributes.allowedBlocks ) {
122
+ return result;
123
+ }
124
+
125
+ const sourceAllowedBlocks = source[ index ]?.attributes?.allowedBlocks;
126
+
127
+ if ( ! sourceAllowedBlocks ) {
128
+ return result;
129
+ }
130
+
131
+ const blockType = getBlockType( result.name );
132
+ const destinationAllowedBlocks = blockType?.allowedBlocks || [];
133
+
134
+ if ( ! destinationAllowedBlocks.length ) {
135
+ return {
136
+ ...result,
137
+ attributes: {
138
+ ...result.attributes,
139
+ allowedBlocks: sourceAllowedBlocks,
140
+ },
141
+ };
142
+ }
143
+
144
+ // Filter out any source allowed blocks that are not defined in the destination allowed blocks.
145
+ const filteredSourceAllowedBlocks = sourceAllowedBlocks.filter( ( block ) =>
146
+ destinationAllowedBlocks.includes( block )
147
+ );
148
+
149
+ return {
150
+ ...result,
151
+ attributes: {
152
+ ...result.attributes,
153
+ allowedBlocks: filteredSourceAllowedBlocks,
154
+ },
155
+ };
156
+ }
157
+
158
+ addFilter(
159
+ 'blocks.switchToBlockType.transformedBlock',
160
+ 'core/allowedBlocks/addTransforms',
161
+ addTransforms
162
+ );
@@ -15,11 +15,10 @@ import {
15
15
  __experimentalToolsPanel as ToolsPanel,
16
16
  __experimentalToolsPanelItem as ToolsPanelItem,
17
17
  __experimentalVStack as VStack,
18
- Modal,
19
18
  privateApis as componentsPrivateApis,
20
19
  } from '@wordpress/components';
21
20
  import { useSelect } from '@wordpress/data';
22
- import { useContext, useState } from '@wordpress/element';
21
+ import { useContext } from '@wordpress/element';
23
22
  import { useViewportMatch } from '@wordpress/compose';
24
23
 
25
24
  /**
@@ -63,12 +62,7 @@ const useToolsPanelDropdownMenuProps = () => {
63
62
  : {};
64
63
  };
65
64
 
66
- function BlockBindingsPanelMenuContent( {
67
- attribute,
68
- binding,
69
- sources,
70
- onOpenModal,
71
- } ) {
65
+ function BlockBindingsPanelMenuContent( { attribute, binding, sources } ) {
72
66
  const { clientId } = useBlockEditContext();
73
67
  const { updateBlockBindings } = useBlockBindingsUtils();
74
68
  const isMobile = useViewportMatch( 'medium', '<' );
@@ -99,105 +93,85 @@ function BlockBindingsPanelMenuContent( {
99
93
  return null;
100
94
  }
101
95
 
102
- if ( source.mode === 'dropdown' ) {
103
- return (
104
- <Menu
105
- key={ sourceKey }
106
- placement={
107
- isMobile ? 'bottom-start' : 'left-start'
108
- }
109
- >
110
- <Menu.SubmenuTriggerItem>
111
- <Menu.ItemLabel>
112
- { source.label }
113
- </Menu.ItemLabel>
114
- </Menu.SubmenuTriggerItem>
115
- <Menu.Popover gutter={ 8 }>
116
- <Menu.Group>
117
- { sourceDataItems.map( ( item ) => {
118
- const itemBindings = {
119
- source: sourceKey,
120
- args: item?.args || {
121
- key: item.key,
122
- },
123
- };
124
- const values = source.getValues( {
125
- select,
126
- context: blockContext,
127
- bindings: {
128
- [ attribute ]: itemBindings,
129
- },
130
- } );
131
- return (
132
- <Menu.CheckboxItem
133
- key={
134
- sourceKey +
135
- JSON.stringify(
136
- item.args
137
- ) || item.key
138
- }
139
- onChange={ () => {
140
- const isCurrentlySelected =
141
- fastDeepEqual(
142
- binding?.args,
143
- item.args
144
- ) ??
145
- // Deprecate key dependency in 7.0.
146
- item.key ===
147
- binding?.args?.key;
148
-
149
- if ( isCurrentlySelected ) {
150
- // Unset if the same item is selected again.
151
- updateBlockBindings( {
152
- [ attribute ]:
153
- undefined,
154
- } );
155
- } else {
156
- updateBlockBindings( {
157
- [ attribute ]:
158
- itemBindings,
159
- } );
160
- }
161
- } }
162
- name={ attribute + '-binding' }
163
- value={ values[ attribute ] }
164
- checked={
96
+ return (
97
+ <Menu
98
+ key={ sourceKey }
99
+ placement={ isMobile ? 'bottom-start' : 'left-start' }
100
+ >
101
+ <Menu.SubmenuTriggerItem>
102
+ <Menu.ItemLabel>{ source.label }</Menu.ItemLabel>
103
+ </Menu.SubmenuTriggerItem>
104
+ <Menu.Popover gutter={ 8 }>
105
+ <Menu.Group>
106
+ { sourceDataItems.map( ( item ) => {
107
+ const itemBindings = {
108
+ source: sourceKey,
109
+ args: item?.args || {
110
+ key: item.key,
111
+ },
112
+ };
113
+ const values = source.getValues( {
114
+ select,
115
+ context: blockContext,
116
+ bindings: {
117
+ [ attribute ]: itemBindings,
118
+ },
119
+ } );
120
+ return (
121
+ <Menu.CheckboxItem
122
+ key={
123
+ sourceKey +
124
+ JSON.stringify(
125
+ item.args
126
+ ) || item.key
127
+ }
128
+ onChange={ () => {
129
+ const isCurrentlySelected =
165
130
  fastDeepEqual(
166
131
  binding?.args,
167
132
  item.args
168
133
  ) ??
169
134
  // Deprecate key dependency in 7.0.
170
135
  item.key ===
171
- binding?.args?.key
136
+ binding?.args?.key;
137
+
138
+ if ( isCurrentlySelected ) {
139
+ // Unset if the same item is selected again.
140
+ updateBlockBindings( {
141
+ [ attribute ]:
142
+ undefined,
143
+ } );
144
+ } else {
145
+ updateBlockBindings( {
146
+ [ attribute ]:
147
+ itemBindings,
148
+ } );
172
149
  }
173
- >
174
- <Menu.ItemLabel>
175
- { item?.label }
176
- </Menu.ItemLabel>
177
- <Menu.ItemHelpText>
178
- { values[ attribute ] }
179
- </Menu.ItemHelpText>
180
- </Menu.CheckboxItem>
181
- );
182
- } ) }
183
- </Menu.Group>
184
- </Menu.Popover>
185
- </Menu>
186
- );
187
- }
188
-
189
- if ( source.mode === 'modal' ) {
190
- return (
191
- <Menu.Item
192
- key={ sourceKey }
193
- onClick={ () => onOpenModal( { sourceKey } ) }
194
- >
195
- <Menu.ItemLabel>{ source.label }</Menu.ItemLabel>
196
- </Menu.Item>
197
- );
198
- }
199
-
200
- return null;
150
+ } }
151
+ name={ attribute + '-binding' }
152
+ value={ values[ attribute ] }
153
+ checked={
154
+ fastDeepEqual(
155
+ binding?.args,
156
+ item.args
157
+ ) ??
158
+ // Deprecate key dependency in 7.0.
159
+ item.key === binding?.args?.key
160
+ }
161
+ >
162
+ <Menu.ItemLabel>
163
+ { item?.label }
164
+ </Menu.ItemLabel>
165
+ <Menu.ItemHelpText>
166
+ { values[ attribute ] }
167
+ </Menu.ItemHelpText>
168
+ </Menu.CheckboxItem>
169
+ );
170
+ } ) }
171
+ </Menu.Group>
172
+ </Menu.Popover>
173
+ </Menu>
174
+ );
201
175
  } ) }
202
176
  </Menu>
203
177
  );
@@ -282,16 +256,11 @@ function EditableBlockBindingsPanelItem( {
282
256
  attribute,
283
257
  binding,
284
258
  sources,
285
- setModalState,
286
259
  blockName,
287
260
  } ) {
288
261
  const { updateBlockBindings } = useBlockBindingsUtils();
289
262
  const isMobile = useViewportMatch( 'medium', '<' );
290
263
 
291
- const handleOpenModal = ( { sourceKey } ) => {
292
- setModalState( { attribute, sourceKey } );
293
- };
294
-
295
264
  return (
296
265
  <ToolsPanelItem
297
266
  hasValue={ () => !! binding }
@@ -316,7 +285,6 @@ function EditableBlockBindingsPanelItem( {
316
285
  attribute={ attribute }
317
286
  binding={ binding }
318
287
  sources={ sources }
319
- onOpenModal={ handleOpenModal }
320
288
  />
321
289
  </Menu.Popover>
322
290
  </Menu>
@@ -328,11 +296,6 @@ export const BlockBindingsPanel = ( { name: blockName, metadata } ) => {
328
296
  const blockContext = useContext( BlockContext );
329
297
  const { removeAllBlockBindings } = useBlockBindingsUtils();
330
298
  const dropdownMenuProps = useToolsPanelDropdownMenuProps();
331
- const [ modalState, setModalState ] = useState( null );
332
-
333
- const handleCloseModal = () => {
334
- setModalState( null );
335
- };
336
299
 
337
300
  // Use useSelect to ensure sources are updated whenever there are updates in block context
338
301
  // or when underlying data changes.
@@ -352,7 +315,7 @@ export const BlockBindingsPanel = ( { name: blockName, metadata } ) => {
352
315
  Object.entries( registeredSources ).forEach(
353
316
  ( [
354
317
  sourceName,
355
- { editorUI, getFieldsList, usesContext, label, getValues },
318
+ { getFieldsList, usesContext, label, getValues },
356
319
  ] ) => {
357
320
  // Populate context.
358
321
  const context = {};
@@ -361,44 +324,19 @@ export const BlockBindingsPanel = ( { name: blockName, metadata } ) => {
361
324
  context[ key ] = blockContext[ key ];
362
325
  }
363
326
  }
364
-
365
- if ( editorUI ) {
366
- const editorUIResult = editorUI( {
327
+ if ( getFieldsList ) {
328
+ const fieldsListResult = getFieldsList( {
367
329
  select,
368
330
  context,
369
331
  } );
370
-
371
332
  _sources[ sourceName ] = {
372
- ...editorUIResult,
333
+ data: fieldsListResult || [],
373
334
  label,
374
335
  getValues,
375
336
  };
376
- } else if ( getFieldsList ) {
377
- // Backward compatibility: Convert getFieldsList to editorUI format.
378
- const fieldsListResult = getFieldsList( {
379
- select,
380
- context,
381
- } );
382
-
383
- if ( fieldsListResult ) {
384
- const data = Object.entries( fieldsListResult ).map(
385
- ( [ key, field ] ) => ( {
386
- label: field.label || key,
387
- type: field.type || 'string',
388
- args: { key },
389
- } )
390
- );
391
-
392
- _sources[ sourceName ] = {
393
- mode: 'dropdown', // Default mode for backward compatibility.
394
- data,
395
- label,
396
- getValues,
397
- };
398
- }
399
337
  } else {
400
338
  /*
401
- * Include sources without editorUI if they are already used in a binding.
339
+ * Include sources without getFieldsList if they are already used in a binding.
402
340
  * This allows them to be displayed in read-only mode.
403
341
  */
404
342
  _sources[ sourceName ] = {
@@ -438,9 +376,6 @@ export const BlockBindingsPanel = ( { name: blockName, metadata } ) => {
438
376
  // Lock the UI when the user can't update bindings or there are no fields to connect to.
439
377
  const readOnly = ! canUpdateBlockBindings || ! hasCompatibleData;
440
378
 
441
- const RenderModalContent =
442
- sources[ modalState?.sourceKey ]?.renderModalContent;
443
-
444
379
  if ( bindings === undefined && ! hasCompatibleData ) {
445
380
  return null;
446
381
  }
@@ -490,7 +425,6 @@ export const BlockBindingsPanel = ( { name: blockName, metadata } ) => {
490
425
  attribute={ attribute }
491
426
  binding={ binding }
492
427
  sources={ sources }
493
- setModalState={ setModalState }
494
428
  blockName={ blockName }
495
429
  />
496
430
  );
@@ -508,14 +442,6 @@ export const BlockBindingsPanel = ( { name: blockName, metadata } ) => {
508
442
  </p>
509
443
  </Text>
510
444
  </ToolsPanel>
511
- { RenderModalContent && (
512
- <Modal onRequestClose={ handleCloseModal }>
513
- <RenderModalContent
514
- attribute={ modalState.attribute }
515
- closeModal={ handleCloseModal }
516
- />
517
- </Modal>
518
- ) }
519
445
  </InspectorControls>
520
446
  );
521
447
  };
@@ -4,12 +4,15 @@
4
4
  import { getBlockTypes, store as blocksStore } from '@wordpress/blocks';
5
5
  import { useSelect } from '@wordpress/data';
6
6
  import { useContext, useMemo } from '@wordpress/element';
7
- import { toStyles, getBlockSelectors } from '@wordpress/global-styles-engine';
8
7
 
9
8
  /**
10
9
  * Internal dependencies
11
10
  */
12
- import { GlobalStylesContext } from '../components/global-styles';
11
+ import {
12
+ GlobalStylesContext,
13
+ toStyles,
14
+ getBlockSelectors,
15
+ } from '../components/global-styles';
13
16
  import { usePrivateStyleOverride } from './utils';
14
17
  import { getValueFromObjectPath } from '../utils/object';
15
18
  import { store as blockEditorStore } from '../store';
@@ -124,6 +127,7 @@ export function __unstableBlockStyleVariationOverridesWithConfig( { config } ) {
124
127
  };
125
128
  const blockSelectors = getBlockSelectors(
126
129
  getBlockTypes(),
130
+ getBlockStyles,
127
131
  override.clientId
128
132
  );
129
133
  const hasBlockGapSupport = false;
@@ -318,7 +322,11 @@ function useBlockProps( { name, className, clientId } ) {
318
322
  }
319
323
 
320
324
  const variationConfig = { settings, styles };
321
- const blockSelectors = getBlockSelectors( getBlockTypes(), clientId );
325
+ const blockSelectors = getBlockSelectors(
326
+ getBlockTypes(),
327
+ getBlockStyles,
328
+ clientId
329
+ );
322
330
  const hasBlockGapSupport = false;
323
331
  const hasFallbackGapSupport = true;
324
332
  const disableLayoutStyles = true;
@@ -341,7 +349,7 @@ function useBlockProps( { name, className, clientId } ) {
341
349
  variationStyles: true,
342
350
  }
343
351
  );
344
- }, [ variation, settings, styles, clientId ] );
352
+ }, [ variation, settings, styles, getBlockStyles, clientId ] );
345
353
 
346
354
  usePrivateStyleOverride( {
347
355
  id: `variation-${ clientId }`,
@@ -145,6 +145,6 @@ addFilter(
145
145
 
146
146
  addFilter(
147
147
  'blocks.switchToBlockType.transformedBlock',
148
- 'core/color/addTransforms',
148
+ 'core/customClassName/addTransforms',
149
149
  addTransforms
150
150
  );
@@ -15,7 +15,6 @@ import {
15
15
  import { useInstanceId } from '@wordpress/compose';
16
16
  import { addFilter } from '@wordpress/hooks';
17
17
  import { useMemo, useEffect } from '@wordpress/element';
18
- import { getBlockSelector } from '@wordpress/global-styles-engine';
19
18
 
20
19
  /**
21
20
  * Internal dependencies
@@ -31,6 +30,7 @@ import {
31
30
  getDuotoneStylesheet,
32
31
  getDuotoneUnsetStylesheet,
33
32
  } from '../components/duotone/utils';
33
+ import { getBlockCSSSelector } from '../components/global-styles/get-block-css-selector';
34
34
  import { scopeSelector } from '../components/global-styles/utils';
35
35
  import {
36
36
  cleanEmptyObject,
@@ -354,14 +354,14 @@ function useBlockProps( { clientId, name, style } ) {
354
354
  false
355
355
  );
356
356
  if ( experimentalDuotone ) {
357
- const rootSelector = getBlockSelector( blockType );
357
+ const rootSelector = getBlockCSSSelector( blockType );
358
358
  return typeof experimentalDuotone === 'string'
359
359
  ? scopeSelector( rootSelector, experimentalDuotone )
360
360
  : rootSelector;
361
361
  }
362
362
 
363
363
  // Regular filter.duotone support uses filter.duotone selectors with fallbacks.
364
- return getBlockSelector( blockType, 'filter.duotone', {
364
+ return getBlockCSSSelector( blockType, 'filter.duotone', {
365
365
  fallback: true,
366
366
  } );
367
367
  }
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { addFilter } from '@wordpress/hooks';
5
5
  import { hasBlockSupport } from '@wordpress/blocks';
6
- import { useEffect, useCallback, useRef } from '@wordpress/element';
6
+ import { useEffect, useCallback } from '@wordpress/element';
7
7
  import { useSelect } from '@wordpress/data';
8
8
  import { __ } from '@wordpress/i18n';
9
9
  import {
@@ -62,28 +62,18 @@ function useFitText( { fitText, name, clientId } ) {
62
62
  const hasFitTextSupport = hasBlockSupport( name, FIT_TEXT_SUPPORT_KEY );
63
63
  const blockElement = useBlockElement( clientId );
64
64
 
65
- // Monitor block attribute changes and selection state
65
+ // Monitor block attribute changes
66
66
  // Any attribute may change the available space.
67
- const { blockAttributes, isSelected } = useSelect(
67
+ const blockAttributes = useSelect(
68
68
  ( select ) => {
69
- if ( ! clientId ) {
70
- return { blockAttributes: undefined, isSelected: false };
69
+ if ( ! clientId || ! hasFitTextSupport || ! fitText ) {
70
+ return;
71
71
  }
72
- return {
73
- blockAttributes:
74
- select( blockEditorStore ).getBlockAttributes( clientId ),
75
- isSelected:
76
- select( blockEditorStore ).isBlockSelected( clientId ),
77
- };
72
+ return select( blockEditorStore ).getBlockAttributes( clientId );
78
73
  },
79
- [ clientId ]
74
+ [ clientId, hasFitTextSupport, fitText ]
80
75
  );
81
76
 
82
- const isSelectedRef = useRef();
83
- useEffect( () => {
84
- isSelectedRef.current = isSelected;
85
- }, [ isSelected ] );
86
-
87
77
  const applyFitText = useCallback( () => {
88
78
  if ( ! blockElement || ! hasFitTextSupport || ! fitText ) {
89
79
  return;
@@ -104,13 +94,8 @@ function useFitText( { fitText, name, clientId } ) {
104
94
  styleElement.textContent = css;
105
95
  };
106
96
 
107
- // Avoid very jarring resizes when a user is actively editing the
108
- // block. Placing a ceiling on how much the block can grow curbs the
109
- // effect of the first few keypresses.
110
- const maxSize = isSelectedRef.current ? 200 : undefined;
111
-
112
- optimizeFitText( blockElement, blockSelector, applyStylesFn, maxSize );
113
- }, [ blockElement, clientId, hasFitTextSupport, fitText, isSelectedRef ] );
97
+ optimizeFitText( blockElement, blockSelector, applyStylesFn );
98
+ }, [ blockElement, clientId, hasFitTextSupport, fitText ] );
114
99
 
115
100
  useEffect( () => {
116
101
  if (
@@ -164,7 +149,6 @@ function useFitText( { fitText, name, clientId } ) {
164
149
  }
165
150
  }, [
166
151
  blockAttributes,
167
- isSelected,
168
152
  fitText,
169
153
  applyFitText,
170
154
  blockElement,
@@ -180,12 +164,16 @@ function useFitText( { fitText, name, clientId } ) {
180
164
  * @param {Function} props.setAttributes Function to set block attributes.
181
165
  * @param {string} props.name Block name.
182
166
  * @param {boolean} props.fitText Whether fit text is enabled.
167
+ * @param {string} props.fontSize Font size slug.
168
+ * @param {Object} props.style Block style object.
183
169
  */
184
170
  export function FitTextControl( {
185
171
  clientId,
186
172
  fitText = false,
187
173
  setAttributes,
188
174
  name,
175
+ fontSize,
176
+ style,
189
177
  } ) {
190
178
  if ( ! hasBlockSupport( name, FIT_TEXT_SUPPORT_KEY ) ) {
191
179
  return null;
@@ -203,13 +191,34 @@ export function FitTextControl( {
203
191
  __nextHasNoMarginBottom
204
192
  label={ __( 'Fit text' ) }
205
193
  checked={ fitText }
206
- onChange={ () =>
207
- setAttributes( { fitText: ! fitText || undefined } )
208
- }
194
+ onChange={ () => {
195
+ const newFitText = ! fitText || undefined;
196
+ const updates = { fitText: newFitText };
197
+
198
+ // When enabling fit text, clear font size if it has a value
199
+ if ( newFitText ) {
200
+ if ( fontSize ) {
201
+ updates.fontSize = undefined;
202
+ }
203
+ if ( style?.typography?.fontSize ) {
204
+ updates.style = {
205
+ ...style,
206
+ typography: {
207
+ ...style?.typography,
208
+ fontSize: undefined,
209
+ },
210
+ };
211
+ }
212
+ }
213
+
214
+ setAttributes( updates );
215
+ } }
209
216
  help={
210
217
  fitText
211
218
  ? __( 'Text will resize to fit its container.' )
212
- : __( 'Resize text to fit its container.' )
219
+ : __(
220
+ 'The text will resize to fit its container, resetting other font size settings.'
221
+ )
213
222
  }
214
223
  />
215
224
  </ToolsPanelItem>
@@ -278,7 +287,7 @@ const hasFitTextSupport = ( blockNameOrType ) => {
278
287
  export default {
279
288
  useBlockProps,
280
289
  addSaveProps,
281
- attributeKeys: [ 'fitText' ],
290
+ attributeKeys: [ 'fitText', 'fontSize', 'style' ],
282
291
  hasSupport: hasFitTextSupport,
283
292
  edit: FitTextControl,
284
293
  };
@@ -4,7 +4,6 @@
4
4
  import { addFilter } from '@wordpress/hooks';
5
5
  import { hasBlockSupport } from '@wordpress/blocks';
6
6
  import TokenList from '@wordpress/token-list';
7
- import { getTypographyFontSizeValue } from '@wordpress/global-styles-engine';
8
7
 
9
8
  /**
10
9
  * Internal dependencies
@@ -22,6 +21,7 @@ import {
22
21
  shouldSkipSerialization,
23
22
  } from './utils';
24
23
  import { useSettings } from '../components/use-settings';
24
+ import { getTypographyFontSizeValue } from '../components/global-styles/typography-utils';
25
25
 
26
26
  export const FONT_SIZE_SUPPORT_KEY = 'typography.fontSize';
27
27
 
@@ -97,8 +97,11 @@ export function FontSizeEdit( props ) {
97
97
  } = props;
98
98
  const [ fontSizes ] = useSettings( 'typography.fontSizes' );
99
99
 
100
- const onChange = ( value ) => {
101
- const fontSizeSlug = getFontSizeObjectByValue( fontSizes, value ).slug;
100
+ const onChange = ( value, selectedItem ) => {
101
+ // Use the selectedItem's slug if available, otherwise fall back to finding by value
102
+ const fontSizeSlug =
103
+ selectedItem?.slug ||
104
+ getFontSizeObjectByValue( fontSizes, value ).slug;
102
105
 
103
106
  setAttributes( {
104
107
  style: cleanEmptyObject( {
@@ -124,7 +127,8 @@ export function FontSizeEdit( props ) {
124
127
  return (
125
128
  <FontSizePicker
126
129
  onChange={ onChange }
127
- value={ fontSizeValue }
130
+ value={ fontSize || fontSizeValue }
131
+ valueMode={ fontSize ? 'slug' : 'literal' }
128
132
  withReset={ false }
129
133
  withSlider
130
134
  size="__unstable-large"