@wordpress/block-editor 15.5.1-next.ff1cebbba.0 → 15.6.1-next.36001005c.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 (121) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/background-image-control/index.js +2 -2
  3. package/build/components/background-image-control/index.js.map +2 -2
  4. package/build/components/block-edit/edit.js +2 -2
  5. package/build/components/block-edit/edit.js.map +2 -2
  6. package/build/components/block-quick-navigation/index.js +1 -0
  7. package/build/components/block-quick-navigation/index.js.map +2 -2
  8. package/build/components/global-styles/border-panel.js +2 -1
  9. package/build/components/global-styles/border-panel.js.map +2 -2
  10. package/build/components/global-styles/color-panel.js +2 -1
  11. package/build/components/global-styles/color-panel.js.map +2 -2
  12. package/build/components/global-styles/dimensions-panel.js +3 -2
  13. package/build/components/global-styles/dimensions-panel.js.map +2 -2
  14. package/build/components/global-styles/filters-panel.js +2 -1
  15. package/build/components/global-styles/filters-panel.js.map +2 -2
  16. package/build/components/global-styles/hooks.js +23 -95
  17. package/build/components/global-styles/hooks.js.map +2 -2
  18. package/build/components/global-styles/index.js +0 -14
  19. package/build/components/global-styles/index.js.map +2 -2
  20. package/build/components/global-styles/typography-panel.js +2 -1
  21. package/build/components/global-styles/typography-panel.js.map +2 -2
  22. package/build/components/global-styles/typography-utils.js +2 -49
  23. package/build/components/global-styles/typography-utils.js.map +2 -2
  24. package/build/components/global-styles/utils.js +0 -377
  25. package/build/components/global-styles/utils.js.map +2 -2
  26. package/build/hooks/block-style-variation.js +6 -10
  27. package/build/hooks/block-style-variation.js.map +2 -2
  28. package/build/hooks/duotone.js +3 -3
  29. package/build/hooks/duotone.js.map +2 -2
  30. package/build/hooks/fit-text.js +17 -8
  31. package/build/hooks/fit-text.js.map +2 -2
  32. package/build/hooks/font-size.js +2 -2
  33. package/build/hooks/font-size.js.map +2 -2
  34. package/build/hooks/use-typography-props.js +2 -2
  35. package/build/hooks/use-typography-props.js.map +2 -2
  36. package/build/utils/fit-text-utils.js +4 -4
  37. package/build/utils/fit-text-utils.js.map +2 -2
  38. package/build-module/components/background-image-control/index.js +1 -1
  39. package/build-module/components/background-image-control/index.js.map +2 -2
  40. package/build-module/components/block-edit/edit.js +2 -2
  41. package/build-module/components/block-edit/edit.js.map +2 -2
  42. package/build-module/components/block-quick-navigation/index.js +1 -0
  43. package/build-module/components/block-quick-navigation/index.js.map +2 -2
  44. package/build-module/components/global-styles/border-panel.js +2 -1
  45. package/build-module/components/global-styles/border-panel.js.map +2 -2
  46. package/build-module/components/global-styles/color-panel.js +2 -1
  47. package/build-module/components/global-styles/color-panel.js.map +2 -2
  48. package/build-module/components/global-styles/dimensions-panel.js +2 -1
  49. package/build-module/components/global-styles/dimensions-panel.js.map +2 -2
  50. package/build-module/components/global-styles/filters-panel.js +2 -1
  51. package/build-module/components/global-styles/filters-panel.js.map +2 -2
  52. package/build-module/components/global-styles/hooks.js +27 -95
  53. package/build-module/components/global-styles/hooks.js.map +2 -2
  54. package/build-module/components/global-styles/index.js +0 -14
  55. package/build-module/components/global-styles/index.js.map +2 -2
  56. package/build-module/components/global-styles/typography-panel.js +2 -1
  57. package/build-module/components/global-styles/typography-panel.js.map +2 -2
  58. package/build-module/components/global-styles/typography-utils.js +1 -49
  59. package/build-module/components/global-styles/typography-utils.js.map +2 -2
  60. package/build-module/components/global-styles/utils.js +0 -364
  61. package/build-module/components/global-styles/utils.js.map +2 -2
  62. package/build-module/hooks/block-style-variation.js +4 -12
  63. package/build-module/hooks/block-style-variation.js.map +2 -2
  64. package/build-module/hooks/duotone.js +3 -3
  65. package/build-module/hooks/duotone.js.map +2 -2
  66. package/build-module/hooks/fit-text.js +18 -9
  67. package/build-module/hooks/fit-text.js.map +2 -2
  68. package/build-module/hooks/font-size.js +1 -1
  69. package/build-module/hooks/font-size.js.map +2 -2
  70. package/build-module/hooks/use-typography-props.js +1 -1
  71. package/build-module/hooks/use-typography-props.js.map +2 -2
  72. package/build-module/utils/fit-text-utils.js +4 -4
  73. package/build-module/utils/fit-text-utils.js.map +2 -2
  74. package/build-style/content-rtl.css +4 -0
  75. package/build-style/content.css +4 -0
  76. package/build-style/style-rtl.css +10 -6
  77. package/build-style/style.css +10 -6
  78. package/package.json +36 -35
  79. package/src/components/background-image-control/index.js +1 -1
  80. package/src/components/block-card/style.scss +1 -1
  81. package/src/components/block-edit/edit.js +2 -2
  82. package/src/components/block-navigation/style.scss +1 -1
  83. package/src/components/block-quick-navigation/index.js +1 -0
  84. package/src/components/block-quick-navigation/style.scss +5 -0
  85. package/src/components/block-switcher/style.scss +1 -1
  86. package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
  87. package/src/components/global-styles/border-panel.js +2 -1
  88. package/src/components/global-styles/color-panel.js +2 -1
  89. package/src/components/global-styles/color-panel.native.js +1 -1
  90. package/src/components/global-styles/dimensions-panel.js +2 -1
  91. package/src/components/global-styles/filters-panel.js +2 -1
  92. package/src/components/global-styles/hooks.js +29 -108
  93. package/src/components/global-styles/index.js +0 -8
  94. package/src/components/global-styles/test/typography-utils.js +0 -806
  95. package/src/components/global-styles/test/utils.js +1 -442
  96. package/src/components/global-styles/typography-panel.js +2 -1
  97. package/src/components/global-styles/typography-utils.js +0 -133
  98. package/src/components/global-styles/utils.js +0 -537
  99. package/src/components/inserter/style.scss +2 -2
  100. package/src/components/link-control/test/index.js +7 -6
  101. package/src/components/multi-selection-inspector/style.scss +1 -1
  102. package/src/components/rich-text/content.scss +5 -0
  103. package/src/hooks/block-style-variation.js +4 -12
  104. package/src/hooks/duotone.js +3 -3
  105. package/src/hooks/fit-text.js +27 -11
  106. package/src/hooks/font-size.js +1 -1
  107. package/src/hooks/use-typography-props.js +1 -1
  108. package/src/style.scss +1 -0
  109. package/src/utils/fit-text-utils.js +16 -4
  110. package/tsconfig.json +1 -0
  111. package/build/components/global-styles/get-block-css-selector.js +0 -78
  112. package/build/components/global-styles/get-block-css-selector.js.map +0 -7
  113. package/build/components/global-styles/use-global-styles-output.js +0 -998
  114. package/build/components/global-styles/use-global-styles-output.js.map +0 -7
  115. package/build-module/components/global-styles/get-block-css-selector.js +0 -54
  116. package/build-module/components/global-styles/get-block-css-selector.js.map +0 -7
  117. package/build-module/components/global-styles/use-global-styles-output.js +0 -979
  118. package/build-module/components/global-styles/use-global-styles-output.js.map +0 -7
  119. package/src/components/global-styles/get-block-css-selector.js +0 -114
  120. package/src/components/global-styles/test/use-global-styles-output.js +0 -1131
  121. package/src/components/global-styles/use-global-styles-output.js +0 -1487
@@ -7,145 +7,6 @@ import fastDeepEqual from 'fast-deep-equal/es6';
7
7
  * WordPress dependencies
8
8
  */
9
9
  import { useViewportMatch } from '@wordpress/compose';
10
- import { getCSSValueFromRawStyle } from '@wordpress/style-engine';
11
-
12
- /**
13
- * Internal dependencies
14
- */
15
- import { getTypographyFontSizeValue } from './typography-utils';
16
- import { getValueFromObjectPath } from '../../utils/object';
17
-
18
- /* Supporting data. */
19
- export const ROOT_BLOCK_SELECTOR = 'body';
20
- export const ROOT_CSS_PROPERTIES_SELECTOR = ':root';
21
-
22
- export const PRESET_METADATA = [
23
- {
24
- path: [ 'color', 'palette' ],
25
- valueKey: 'color',
26
- cssVarInfix: 'color',
27
- classes: [
28
- { classSuffix: 'color', propertyName: 'color' },
29
- {
30
- classSuffix: 'background-color',
31
- propertyName: 'background-color',
32
- },
33
- {
34
- classSuffix: 'border-color',
35
- propertyName: 'border-color',
36
- },
37
- ],
38
- },
39
- {
40
- path: [ 'color', 'gradients' ],
41
- valueKey: 'gradient',
42
- cssVarInfix: 'gradient',
43
- classes: [
44
- {
45
- classSuffix: 'gradient-background',
46
- propertyName: 'background',
47
- },
48
- ],
49
- },
50
- {
51
- path: [ 'color', 'duotone' ],
52
- valueKey: 'colors',
53
- cssVarInfix: 'duotone',
54
- valueFunc: ( { slug } ) => `url( '#wp-duotone-${ slug }' )`,
55
- classes: [],
56
- },
57
- {
58
- path: [ 'shadow', 'presets' ],
59
- valueKey: 'shadow',
60
- cssVarInfix: 'shadow',
61
- classes: [],
62
- },
63
- {
64
- path: [ 'typography', 'fontSizes' ],
65
- valueFunc: ( preset, settings ) =>
66
- getTypographyFontSizeValue( preset, settings ),
67
- valueKey: 'size',
68
- cssVarInfix: 'font-size',
69
- classes: [ { classSuffix: 'font-size', propertyName: 'font-size' } ],
70
- },
71
- {
72
- path: [ 'typography', 'fontFamilies' ],
73
- valueKey: 'fontFamily',
74
- cssVarInfix: 'font-family',
75
- classes: [
76
- { classSuffix: 'font-family', propertyName: 'font-family' },
77
- ],
78
- },
79
- {
80
- path: [ 'spacing', 'spacingSizes' ],
81
- valueKey: 'size',
82
- cssVarInfix: 'spacing',
83
- classes: [],
84
- },
85
- {
86
- path: [ 'border', 'radiusSizes' ],
87
- valueKey: 'size',
88
- cssVarInfix: 'border-radius',
89
- classes: [],
90
- },
91
- ];
92
-
93
- export const STYLE_PATH_TO_CSS_VAR_INFIX = {
94
- 'color.background': 'color',
95
- 'color.text': 'color',
96
- 'filter.duotone': 'duotone',
97
- 'elements.link.color.text': 'color',
98
- 'elements.link.:hover.color.text': 'color',
99
- 'elements.link.typography.fontFamily': 'font-family',
100
- 'elements.link.typography.fontSize': 'font-size',
101
- 'elements.button.color.text': 'color',
102
- 'elements.button.color.background': 'color',
103
- 'elements.caption.color.text': 'color',
104
- 'elements.button.typography.fontFamily': 'font-family',
105
- 'elements.button.typography.fontSize': 'font-size',
106
- 'elements.heading.color': 'color',
107
- 'elements.heading.color.background': 'color',
108
- 'elements.heading.typography.fontFamily': 'font-family',
109
- 'elements.heading.gradient': 'gradient',
110
- 'elements.heading.color.gradient': 'gradient',
111
- 'elements.h1.color': 'color',
112
- 'elements.h1.color.background': 'color',
113
- 'elements.h1.typography.fontFamily': 'font-family',
114
- 'elements.h1.color.gradient': 'gradient',
115
- 'elements.h2.color': 'color',
116
- 'elements.h2.color.background': 'color',
117
- 'elements.h2.typography.fontFamily': 'font-family',
118
- 'elements.h2.color.gradient': 'gradient',
119
- 'elements.h3.color': 'color',
120
- 'elements.h3.color.background': 'color',
121
- 'elements.h3.typography.fontFamily': 'font-family',
122
- 'elements.h3.color.gradient': 'gradient',
123
- 'elements.h4.color': 'color',
124
- 'elements.h4.color.background': 'color',
125
- 'elements.h4.typography.fontFamily': 'font-family',
126
- 'elements.h4.color.gradient': 'gradient',
127
- 'elements.h5.color': 'color',
128
- 'elements.h5.color.background': 'color',
129
- 'elements.h5.typography.fontFamily': 'font-family',
130
- 'elements.h5.color.gradient': 'gradient',
131
- 'elements.h6.color': 'color',
132
- 'elements.h6.color.background': 'color',
133
- 'elements.h6.typography.fontFamily': 'font-family',
134
- 'elements.h6.color.gradient': 'gradient',
135
- 'color.gradient': 'gradient',
136
- shadow: 'shadow',
137
- 'typography.fontSize': 'font-size',
138
- 'typography.fontFamily': 'font-family',
139
- };
140
-
141
- // A static list of block attributes that store global style preset slugs.
142
- export const STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {
143
- 'color.background': 'backgroundColor',
144
- 'color.text': 'textColor',
145
- 'color.gradient': 'gradient',
146
- 'typography.fontSize': 'fontSize',
147
- 'typography.fontFamily': 'fontFamily',
148
- };
149
10
 
150
11
  export function useToolsPanelDropdownMenuProps() {
151
12
  const isMobile = useViewportMatch( 'medium', '<' );
@@ -160,208 +21,6 @@ export function useToolsPanelDropdownMenuProps() {
160
21
  : {};
161
22
  }
162
23
 
163
- function findInPresetsBy(
164
- features,
165
- blockName,
166
- presetPath,
167
- presetProperty,
168
- presetValueValue
169
- ) {
170
- // Block presets take priority above root level presets.
171
- const orderedPresetsByOrigin = [
172
- getValueFromObjectPath( features, [
173
- 'blocks',
174
- blockName,
175
- ...presetPath,
176
- ] ),
177
- getValueFromObjectPath( features, presetPath ),
178
- ];
179
-
180
- for ( const presetByOrigin of orderedPresetsByOrigin ) {
181
- if ( presetByOrigin ) {
182
- // Preset origins ordered by priority.
183
- const origins = [ 'custom', 'theme', 'default' ];
184
- for ( const origin of origins ) {
185
- const presets = presetByOrigin[ origin ];
186
- if ( presets ) {
187
- const presetObject = presets.find(
188
- ( preset ) =>
189
- preset[ presetProperty ] === presetValueValue
190
- );
191
- if ( presetObject ) {
192
- if ( presetProperty === 'slug' ) {
193
- return presetObject;
194
- }
195
- // If there is a highest priority preset with the same slug but different value the preset we found was overwritten and should be ignored.
196
- const highestPresetObjectWithSameSlug = findInPresetsBy(
197
- features,
198
- blockName,
199
- presetPath,
200
- 'slug',
201
- presetObject.slug
202
- );
203
- if (
204
- highestPresetObjectWithSameSlug[
205
- presetProperty
206
- ] === presetObject[ presetProperty ]
207
- ) {
208
- return presetObject;
209
- }
210
- return undefined;
211
- }
212
- }
213
- }
214
- }
215
- }
216
- }
217
-
218
- export function getPresetVariableFromValue(
219
- features,
220
- blockName,
221
- variableStylePath,
222
- presetPropertyValue
223
- ) {
224
- if ( ! presetPropertyValue ) {
225
- return presetPropertyValue;
226
- }
227
-
228
- const cssVarInfix = STYLE_PATH_TO_CSS_VAR_INFIX[ variableStylePath ];
229
-
230
- const metadata = PRESET_METADATA.find(
231
- ( data ) => data.cssVarInfix === cssVarInfix
232
- );
233
-
234
- if ( ! metadata ) {
235
- // The property doesn't have preset data
236
- // so the value should be returned as it is.
237
- return presetPropertyValue;
238
- }
239
- const { valueKey, path } = metadata;
240
-
241
- const presetObject = findInPresetsBy(
242
- features,
243
- blockName,
244
- path,
245
- valueKey,
246
- presetPropertyValue
247
- );
248
-
249
- if ( ! presetObject ) {
250
- // Value wasn't found in the presets,
251
- // so it must be a custom value.
252
- return presetPropertyValue;
253
- }
254
-
255
- return `var:preset|${ cssVarInfix }|${ presetObject.slug }`;
256
- }
257
-
258
- function getValueFromPresetVariable(
259
- features,
260
- blockName,
261
- variable,
262
- [ presetType, slug ]
263
- ) {
264
- const metadata = PRESET_METADATA.find(
265
- ( data ) => data.cssVarInfix === presetType
266
- );
267
- if ( ! metadata ) {
268
- return variable;
269
- }
270
-
271
- const presetObject = findInPresetsBy(
272
- features.settings,
273
- blockName,
274
- metadata.path,
275
- 'slug',
276
- slug
277
- );
278
-
279
- if ( presetObject ) {
280
- const { valueKey } = metadata;
281
- const result = presetObject[ valueKey ];
282
- return getValueFromVariable( features, blockName, result );
283
- }
284
-
285
- return variable;
286
- }
287
-
288
- function getValueFromCustomVariable( features, blockName, variable, path ) {
289
- const result =
290
- getValueFromObjectPath( features.settings, [
291
- 'blocks',
292
- blockName,
293
- 'custom',
294
- ...path,
295
- ] ) ??
296
- getValueFromObjectPath( features.settings, [ 'custom', ...path ] );
297
- if ( ! result ) {
298
- return variable;
299
- }
300
- // A variable may reference another variable so we need recursion until we find the value.
301
- return getValueFromVariable( features, blockName, result );
302
- }
303
-
304
- /**
305
- * Attempts to fetch the value of a theme.json CSS variable.
306
- *
307
- * @param {Object} features GlobalStylesContext config, e.g., user, base or merged. Represents the theme.json tree.
308
- * @param {string} blockName The name of a block as represented in the styles property. E.g., 'root' for root-level, and 'core/${blockName}' for blocks.
309
- * @param {string|*} variable An incoming style value. A CSS var value is expected, but it could be any value.
310
- * @return {string|*|{ref}} The value of the CSS var, if found. If not found, the passed variable argument.
311
- */
312
- export function getValueFromVariable( features, blockName, variable ) {
313
- if ( ! variable || typeof variable !== 'string' ) {
314
- if ( typeof variable?.ref === 'string' ) {
315
- variable = getValueFromObjectPath( features, variable.ref );
316
- // Presence of another ref indicates a reference to another dynamic value.
317
- // Pointing to another dynamic value is not supported.
318
- if ( ! variable || !! variable?.ref ) {
319
- return variable;
320
- }
321
- } else {
322
- return variable;
323
- }
324
- }
325
- const USER_VALUE_PREFIX = 'var:';
326
- const THEME_VALUE_PREFIX = 'var(--wp--';
327
- const THEME_VALUE_SUFFIX = ')';
328
-
329
- let parsedVar;
330
-
331
- if ( variable.startsWith( USER_VALUE_PREFIX ) ) {
332
- parsedVar = variable.slice( USER_VALUE_PREFIX.length ).split( '|' );
333
- } else if (
334
- variable.startsWith( THEME_VALUE_PREFIX ) &&
335
- variable.endsWith( THEME_VALUE_SUFFIX )
336
- ) {
337
- parsedVar = variable
338
- .slice( THEME_VALUE_PREFIX.length, -THEME_VALUE_SUFFIX.length )
339
- .split( '--' );
340
- } else {
341
- // We don't know how to parse the value: either is raw of uses complex CSS such as `calc(1px * var(--wp--variable) )`
342
- return variable;
343
- }
344
-
345
- const [ type, ...path ] = parsedVar;
346
- if ( type === 'preset' ) {
347
- return getValueFromPresetVariable(
348
- features,
349
- blockName,
350
- variable,
351
- path
352
- );
353
- }
354
- if ( type === 'custom' ) {
355
- return getValueFromCustomVariable(
356
- features,
357
- blockName,
358
- variable,
359
- path
360
- );
361
- }
362
- return variable;
363
- }
364
-
365
24
  /**
366
25
  * Function that scopes a selector with another one. This works a bit like
367
26
  * SCSS nesting except the `&` operator isn't supported.
@@ -397,78 +56,6 @@ export function scopeSelector( scope, selector ) {
397
56
  return selectorsScoped.join( ', ' );
398
57
  }
399
58
 
400
- /**
401
- * Scopes a collection of selectors for features and subfeatures.
402
- *
403
- * @example
404
- * ```js
405
- * const scope = '.custom-scope';
406
- * const selectors = {
407
- * color: '.wp-my-block p',
408
- * typography: { fontSize: '.wp-my-block caption' },
409
- * };
410
- * const result = scopeFeatureSelector( scope, selectors );
411
- * // result is {
412
- * // color: '.custom-scope .wp-my-block p',
413
- * // typography: { fonSize: '.custom-scope .wp-my-block caption' },
414
- * // }
415
- * ```
416
- *
417
- * @param {string} scope Selector to scope collection of selectors with.
418
- * @param {Object} selectors Collection of feature selectors e.g.
419
- *
420
- * @return {Object|undefined} Scoped collection of feature selectors.
421
- */
422
- export function scopeFeatureSelectors( scope, selectors ) {
423
- if ( ! scope || ! selectors ) {
424
- return;
425
- }
426
-
427
- const featureSelectors = {};
428
-
429
- Object.entries( selectors ).forEach( ( [ feature, selector ] ) => {
430
- if ( typeof selector === 'string' ) {
431
- featureSelectors[ feature ] = scopeSelector( scope, selector );
432
- }
433
-
434
- if ( typeof selector === 'object' ) {
435
- featureSelectors[ feature ] = {};
436
-
437
- Object.entries( selector ).forEach(
438
- ( [ subfeature, subfeatureSelector ] ) => {
439
- featureSelectors[ feature ][ subfeature ] = scopeSelector(
440
- scope,
441
- subfeatureSelector
442
- );
443
- }
444
- );
445
- }
446
- } );
447
-
448
- return featureSelectors;
449
- }
450
-
451
- /**
452
- * Appends a sub-selector to an existing one.
453
- *
454
- * Given the compounded `selector` "h1, h2, h3"
455
- * and the `toAppend` selector ".some-class" the result will be
456
- * "h1.some-class, h2.some-class, h3.some-class".
457
- *
458
- * @param {string} selector Original selector.
459
- * @param {string} toAppend Selector to append.
460
- *
461
- * @return {string} The new selector.
462
- */
463
- export function appendToSelector( selector, toAppend ) {
464
- if ( ! selector.includes( ',' ) ) {
465
- return selector + toAppend;
466
- }
467
- const selectors = selector.split( ',' );
468
- const newSelectors = selectors.map( ( sel ) => sel + toAppend );
469
- return newSelectors.join( ',' );
470
- }
471
-
472
59
  /**
473
60
  * Compares global style variations according to their styles and settings properties.
474
61
  *
@@ -494,127 +81,3 @@ export function areGlobalStyleConfigsEqual( original, variation ) {
494
81
  fastDeepEqual( original?.settings, variation?.settings )
495
82
  );
496
83
  }
497
-
498
- /**
499
- * Generates the selector for a block style variation by creating the
500
- * appropriate CSS class and adding it to the ancestor portion of the block's
501
- * selector.
502
- *
503
- * For example, take the Button block which has a compound selector:
504
- * `.wp-block-button .wp-block-button__link`. With a variation named 'custom',
505
- * the class `.is-style-custom` should be added to the `.wp-block-button`
506
- * ancestor only.
507
- *
508
- * This function will take into account comma separated and complex selectors.
509
- *
510
- * @param {string} variation Name for the variation.
511
- * @param {string} blockSelector CSS selector for the block.
512
- *
513
- * @return {string} CSS selector for the block style variation.
514
- */
515
- export function getBlockStyleVariationSelector( variation, blockSelector ) {
516
- const variationClass = `.is-style-${ variation }`;
517
-
518
- if ( ! blockSelector ) {
519
- return variationClass;
520
- }
521
-
522
- const ancestorRegex = /((?::\([^)]+\))?\s*)([^\s:]+)/;
523
- const addVariationClass = ( _match, group1, group2 ) => {
524
- return group1 + group2 + variationClass;
525
- };
526
-
527
- const result = blockSelector
528
- .split( ',' )
529
- .map( ( part ) => part.replace( ancestorRegex, addVariationClass ) );
530
-
531
- return result.join( ',' );
532
- }
533
-
534
- /**
535
- * Looks up a theme file URI based on a relative path.
536
- *
537
- * @param {string} file A relative path.
538
- * @param {Array<Object>} themeFileURIs A collection of absolute theme file URIs and their corresponding file paths.
539
- * @return {string} A resolved theme file URI, if one is found in the themeFileURIs collection.
540
- */
541
- export function getResolvedThemeFilePath( file, themeFileURIs ) {
542
- if ( ! file || ! themeFileURIs || ! Array.isArray( themeFileURIs ) ) {
543
- return file;
544
- }
545
-
546
- const uri = themeFileURIs.find(
547
- ( themeFileUri ) => themeFileUri?.name === file
548
- );
549
-
550
- if ( ! uri?.href ) {
551
- return file;
552
- }
553
-
554
- return uri?.href;
555
- }
556
-
557
- /**
558
- * Resolves ref values in theme JSON.
559
- *
560
- * @param {Object|string} ruleValue A block style value that may contain a reference to a theme.json value.
561
- * @param {Object} tree A theme.json object.
562
- * @return {*} The resolved value or incoming ruleValue.
563
- */
564
- export function getResolvedRefValue( ruleValue, tree ) {
565
- if ( ! ruleValue || ! tree ) {
566
- return ruleValue;
567
- }
568
-
569
- /*
570
- * Where the rule value is an object with a 'ref' property pointing
571
- * to a path, this converts that path into the value at that path.
572
- * For example: { "ref": "style.color.background" } => "#fff".
573
- */
574
- if ( typeof ruleValue !== 'string' && ruleValue?.ref ) {
575
- const resolvedRuleValue = getCSSValueFromRawStyle(
576
- getValueFromObjectPath( tree, ruleValue.ref )
577
- );
578
-
579
- /*
580
- * Presence of another ref indicates a reference to another dynamic value.
581
- * Pointing to another dynamic value is not supported.
582
- */
583
- if ( resolvedRuleValue?.ref ) {
584
- return undefined;
585
- }
586
-
587
- if ( resolvedRuleValue === undefined ) {
588
- return ruleValue;
589
- }
590
-
591
- return resolvedRuleValue;
592
- }
593
- return ruleValue;
594
- }
595
-
596
- /**
597
- * Resolves ref and relative path values in theme JSON.
598
- *
599
- * @param {Object|string} ruleValue A block style value that may contain a reference to a theme.json value.
600
- * @param {Object} tree A theme.json object.
601
- * @return {*} The resolved value or incoming ruleValue.
602
- */
603
- export function getResolvedValue( ruleValue, tree ) {
604
- if ( ! ruleValue || ! tree ) {
605
- return ruleValue;
606
- }
607
-
608
- // Resolve ref values.
609
- const resolvedValue = getResolvedRefValue( ruleValue, tree );
610
-
611
- // Resolve relative paths.
612
- if ( resolvedValue?.url ) {
613
- resolvedValue.url = getResolvedThemeFilePath(
614
- resolvedValue.url,
615
- tree?._links?.[ 'wp:theme-file' ]
616
- );
617
- }
618
-
619
- return resolvedValue;
620
- }
@@ -151,7 +151,7 @@ $block-inserter-tabs-height: 44px;
151
151
  color: $gray-700;
152
152
  text-transform: uppercase;
153
153
  font-size: 11px;
154
- font-weight: 500;
154
+ font-weight: $font-weight-medium;
155
155
  }
156
156
 
157
157
  .block-editor-inserter__panel-dropdown select.components-select-control__input.components-select-control__input.components-select-control__input {
@@ -440,7 +440,7 @@ $block-inserter-tabs-height: 44px;
440
440
  }
441
441
 
442
442
  .components-heading.block-editor-inserter__patterns-category-panel-title {
443
- font-weight: 500;
443
+ font-weight: $font-weight-medium;
444
444
  }
445
445
 
446
446
  .block-editor-inserter__patterns-explore-button,
@@ -1518,17 +1518,18 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
1518
1518
 
1519
1519
  await user.click( createButton );
1520
1520
 
1521
- searchInput = screen.getByRole( 'combobox', {
1522
- name: 'Search or type URL',
1523
- } );
1524
-
1525
- const errorNotice = screen.getAllByText(
1521
+ // Wait for the error message to appear after the async operation fails
1522
+ const errorNotice = await screen.findByText(
1526
1523
  'API response returned invalid entity.'
1527
- )[ 1 ];
1524
+ );
1528
1525
 
1529
1526
  // Catch the error in the test to avoid test failures.
1530
1527
  expect( throwsError ).toThrow( Error );
1531
1528
 
1529
+ searchInput = screen.getByRole( 'combobox', {
1530
+ name: 'Search or type URL',
1531
+ } );
1532
+
1532
1533
  // Check human readable error notice is perceivable.
1533
1534
  expect( errorNotice ).toBeVisible();
1534
1535
  // eslint-disable-next-line testing-library/no-node-access
@@ -5,7 +5,7 @@
5
5
  }
6
6
 
7
7
  .block-editor-multi-selection-inspector__card-title {
8
- font-weight: 500;
8
+ font-weight: $font-weight-medium;
9
9
  }
10
10
 
11
11
  .block-editor-multi-selection-inspector__card .block-editor-block-icon {
@@ -47,3 +47,8 @@ figcaption.block-editor-rich-text__editable [data-rich-text-placeholder]::before
47
47
  padding: 0 2px;
48
48
  }
49
49
  }
50
+
51
+ // Hide selection within non-editable elements, we draw our own boundaries.
52
+ .rich-text [contenteditable="false"]::selection {
53
+ background-color: transparent;
54
+ }
@@ -4,15 +4,12 @@
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';
7
8
 
8
9
  /**
9
10
  * Internal dependencies
10
11
  */
11
- import {
12
- GlobalStylesContext,
13
- toStyles,
14
- getBlockSelectors,
15
- } from '../components/global-styles';
12
+ import { GlobalStylesContext } from '../components/global-styles';
16
13
  import { usePrivateStyleOverride } from './utils';
17
14
  import { getValueFromObjectPath } from '../utils/object';
18
15
  import { store as blockEditorStore } from '../store';
@@ -127,7 +124,6 @@ export function __unstableBlockStyleVariationOverridesWithConfig( { config } ) {
127
124
  };
128
125
  const blockSelectors = getBlockSelectors(
129
126
  getBlockTypes(),
130
- getBlockStyles,
131
127
  override.clientId
132
128
  );
133
129
  const hasBlockGapSupport = false;
@@ -322,11 +318,7 @@ function useBlockProps( { name, className, clientId } ) {
322
318
  }
323
319
 
324
320
  const variationConfig = { settings, styles };
325
- const blockSelectors = getBlockSelectors(
326
- getBlockTypes(),
327
- getBlockStyles,
328
- clientId
329
- );
321
+ const blockSelectors = getBlockSelectors( getBlockTypes(), clientId );
330
322
  const hasBlockGapSupport = false;
331
323
  const hasFallbackGapSupport = true;
332
324
  const disableLayoutStyles = true;
@@ -349,7 +341,7 @@ function useBlockProps( { name, className, clientId } ) {
349
341
  variationStyles: true,
350
342
  }
351
343
  );
352
- }, [ variation, settings, styles, getBlockStyles, clientId ] );
344
+ }, [ variation, settings, styles, clientId ] );
353
345
 
354
346
  usePrivateStyleOverride( {
355
347
  id: `variation-${ clientId }`,
@@ -15,6 +15,7 @@ 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';
18
19
 
19
20
  /**
20
21
  * Internal dependencies
@@ -30,7 +31,6 @@ import {
30
31
  getDuotoneStylesheet,
31
32
  getDuotoneUnsetStylesheet,
32
33
  } 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 = getBlockCSSSelector( blockType );
357
+ const rootSelector = getBlockSelector( 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 getBlockCSSSelector( blockType, 'filter.duotone', {
364
+ return getBlockSelector( blockType, 'filter.duotone', {
365
365
  fallback: true,
366
366
  } );
367
367
  }