@wordpress/block-editor 15.6.8 → 15.6.9

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 (73) hide show
  1. package/README.md +4 -0
  2. package/build/components/global-styles/color-panel.js +1 -3
  3. package/build/components/global-styles/color-panel.js.map +2 -2
  4. package/build/components/global-styles/typography-panel.js +40 -26
  5. package/build/components/global-styles/typography-panel.js.map +2 -2
  6. package/build/components/index.js +3 -0
  7. package/build/components/index.js.map +2 -2
  8. package/build/components/rich-text/index.js +4 -6
  9. package/build/components/rich-text/index.js.map +2 -2
  10. package/build/components/rich-text/use-format-types.js +10 -27
  11. package/build/components/rich-text/use-format-types.js.map +2 -2
  12. package/build/components/tool-selector/index.js +44 -0
  13. package/build/components/tool-selector/index.js.map +7 -0
  14. package/build/hooks/fit-text.js +13 -6
  15. package/build/hooks/fit-text.js.map +2 -2
  16. package/build/private-apis.js +0 -1
  17. package/build/private-apis.js.map +2 -2
  18. package/build/store/private-keys.js +0 -3
  19. package/build/store/private-keys.js.map +2 -2
  20. package/build/utils/fit-text-utils.js +18 -4
  21. package/build/utils/fit-text-utils.js.map +2 -2
  22. package/build-module/components/global-styles/color-panel.js +1 -3
  23. package/build-module/components/global-styles/color-panel.js.map +2 -2
  24. package/build-module/components/global-styles/typography-panel.js +41 -27
  25. package/build-module/components/global-styles/typography-panel.js.map +2 -2
  26. package/build-module/components/index.js +2 -0
  27. package/build-module/components/index.js.map +2 -2
  28. package/build-module/components/rich-text/index.js +4 -6
  29. package/build-module/components/rich-text/index.js.map +2 -2
  30. package/build-module/components/rich-text/use-format-types.js +10 -27
  31. package/build-module/components/rich-text/use-format-types.js.map +2 -2
  32. package/build-module/components/tool-selector/index.js +14 -0
  33. package/build-module/components/tool-selector/index.js.map +7 -0
  34. package/build-module/hooks/fit-text.js +13 -6
  35. package/build-module/hooks/fit-text.js.map +2 -2
  36. package/build-module/private-apis.js +1 -3
  37. package/build-module/private-apis.js.map +2 -2
  38. package/build-module/store/private-keys.js +0 -2
  39. package/build-module/store/private-keys.js.map +2 -2
  40. package/build-module/utils/fit-text-utils.js +18 -4
  41. package/build-module/utils/fit-text-utils.js.map +2 -2
  42. package/build-style/style-rtl.css +3 -0
  43. package/build-style/style.css +3 -0
  44. package/package.json +8 -8
  45. package/src/components/block-controls/test/index.js +1 -0
  46. package/src/components/block-edit/test/edit.js +10 -0
  47. package/src/components/block-preview/test/index.js +11 -7
  48. package/src/components/block-switcher/test/index.js +2 -0
  49. package/src/components/block-switcher/test/use-transformed.patterns.js +2 -0
  50. package/src/components/block-switcher/test/utils.js +2 -0
  51. package/src/components/colors-gradients/style.scss +5 -0
  52. package/src/components/global-styles/color-panel.js +0 -2
  53. package/src/components/global-styles/test/get-global-styles-changes.js +1 -0
  54. package/src/components/global-styles/typography-panel.js +52 -32
  55. package/src/components/index.js +4 -0
  56. package/src/components/inner-blocks/test/index.js +2 -0
  57. package/src/components/provider/test/use-block-sync.js +1 -0
  58. package/src/components/rich-text/index.js +9 -12
  59. package/src/components/rich-text/use-format-types.js +19 -42
  60. package/src/components/tool-selector/index.js +19 -0
  61. package/src/hooks/fit-text.js +19 -4
  62. package/src/hooks/test/align.js +1 -0
  63. package/src/hooks/test/allowed-blocks.js +8 -0
  64. package/src/hooks/test/font-size.js +1 -0
  65. package/src/hooks/test/metadata.js +4 -0
  66. package/src/hooks/test/text-align.js +1 -0
  67. package/src/private-apis.js +0 -2
  68. package/src/store/private-keys.js +0 -1
  69. package/src/store/test/actions.js +7 -0
  70. package/src/store/test/reducer.js +4 -0
  71. package/src/store/test/registry-selectors.js +2 -0
  72. package/src/store/test/selectors.js +19 -0
  73. package/src/utils/fit-text-utils.js +31 -5
@@ -60,6 +60,7 @@ const {
60
60
 
61
61
  describe( 'actions', () => {
62
62
  const defaultBlockSettings = {
63
+ apiVersion: 3,
63
64
  attributes: {
64
65
  content: {},
65
66
  },
@@ -863,6 +864,7 @@ describe( 'actions', () => {
863
864
 
864
865
  it( 'should merge the blocks if blocks of the same type', () => {
865
866
  registerBlockType( 'core/test-block', {
867
+ apiVersion: 3,
866
868
  attributes: {
867
869
  content: {},
868
870
  },
@@ -933,6 +935,7 @@ describe( 'actions', () => {
933
935
 
934
936
  it( 'should not merge the blocks have different types without transformation', () => {
935
937
  registerBlockType( 'core/test-block', {
938
+ apiVersion: 3,
936
939
  attributes: {
937
940
  content: {},
938
941
  },
@@ -986,6 +989,7 @@ describe( 'actions', () => {
986
989
 
987
990
  it( 'should transform and merge the blocks', () => {
988
991
  registerBlockType( 'core/test-block', {
992
+ apiVersion: 3,
989
993
  attributes: {
990
994
  content: {
991
995
  type: 'string',
@@ -1004,6 +1008,7 @@ describe( 'actions', () => {
1004
1008
  title: 'test block',
1005
1009
  } );
1006
1010
  registerBlockType( 'core/test-block-2', {
1011
+ apiVersion: 3,
1007
1012
  attributes: {
1008
1013
  content2: {
1009
1014
  type: 'string',
@@ -1081,6 +1086,7 @@ describe( 'actions', () => {
1081
1086
 
1082
1087
  it( 'should not merge the blocks if blockB editing mode is `disabled`', () => {
1083
1088
  registerBlockType( 'core/test-block', {
1089
+ apiVersion: 3,
1084
1090
  attributes: {
1085
1091
  content: {},
1086
1092
  },
@@ -1140,6 +1146,7 @@ describe( 'actions', () => {
1140
1146
 
1141
1147
  it( 'should not merge the blocks if blockA editing mode is `disabled`', () => {
1142
1148
  registerBlockType( 'core/test-block', {
1149
+ apiVersion: 3,
1143
1150
  attributes: {
1144
1151
  content: {},
1145
1152
  },
@@ -199,6 +199,7 @@ describe( 'state', () => {
199
199
  describe( 'blocks()', () => {
200
200
  beforeAll( () => {
201
201
  registerBlockType( 'core/test-block', {
202
+ apiVersion: 3,
202
203
  save: noop,
203
204
  edit: noop,
204
205
  category: 'text',
@@ -213,12 +214,14 @@ describe( 'state', () => {
213
214
  describe( 'replace inner blocks', () => {
214
215
  beforeAll( () => {
215
216
  registerBlockType( 'core/test-parent-block', {
217
+ apiVersion: 3,
216
218
  save: noop,
217
219
  edit: noop,
218
220
  category: 'text',
219
221
  title: 'test parent block',
220
222
  } );
221
223
  registerBlockType( 'core/test-child-block', {
224
+ apiVersion: 3,
222
225
  save: noop,
223
226
  edit: noop,
224
227
  category: 'text',
@@ -2994,6 +2997,7 @@ describe( 'state', () => {
2994
2997
  blockAttributes?.fruit === variationAttributes.fruit,
2995
2998
  } ) );
2996
2999
  registerBlockType( blockWithVariations, {
3000
+ apiVersion: 3,
2997
3001
  save: noop,
2998
3002
  edit: noop,
2999
3003
  title: 'Fruit with variations',
@@ -12,6 +12,7 @@ import { store } from '../';
12
12
  describe( 'selectors', () => {
13
13
  beforeEach( () => {
14
14
  registerBlockType( 'core/test-block-a', {
15
+ apiVersion: 3,
15
16
  save: ( props ) => props.attributes.text,
16
17
  category: 'design',
17
18
  title: 'Test Block A',
@@ -20,6 +21,7 @@ describe( 'selectors', () => {
20
21
  } );
21
22
 
22
23
  registerBlockType( 'core/test-block-b', {
24
+ apiVersion: 3,
23
25
  save: ( props ) => props.attributes.text,
24
26
  category: 'text',
25
27
  title: 'Test Block B',
@@ -85,6 +85,7 @@ describe( 'selectors', () => {
85
85
 
86
86
  beforeEach( () => {
87
87
  registerBlockType( 'core/block', {
88
+ apiVersion: 3,
88
89
  save: () => null,
89
90
  category: 'reusable',
90
91
  title: 'Reusable Block Stub',
@@ -94,6 +95,7 @@ describe( 'selectors', () => {
94
95
  } );
95
96
 
96
97
  registerBlockType( 'core/test-block-a', {
98
+ apiVersion: 3,
97
99
  save: ( props ) => props.attributes.text,
98
100
  category: 'design',
99
101
  title: 'Test Block A',
@@ -102,6 +104,7 @@ describe( 'selectors', () => {
102
104
  } );
103
105
 
104
106
  registerBlockType( 'core/test-block-b', {
107
+ apiVersion: 3,
105
108
  save: ( props ) => props.attributes.text,
106
109
  category: 'text',
107
110
  title: 'Test Block B',
@@ -113,6 +116,7 @@ describe( 'selectors', () => {
113
116
  } );
114
117
 
115
118
  registerBlockType( 'core/test-block-c', {
119
+ apiVersion: 3,
116
120
  save: ( props ) => props.attributes.text,
117
121
  category: 'text',
118
122
  title: 'Test Block C',
@@ -122,6 +126,7 @@ describe( 'selectors', () => {
122
126
  } );
123
127
 
124
128
  registerBlockType( 'core/freeform', {
129
+ apiVersion: 3,
125
130
  save: ( props ) => <RawHTML>{ props.attributes.content }</RawHTML>,
126
131
  category: 'text',
127
132
  title: 'Test Freeform Content Handler',
@@ -134,6 +139,7 @@ describe( 'selectors', () => {
134
139
  } );
135
140
 
136
141
  registerBlockType( 'core/post-content-child', {
142
+ apiVersion: 3,
137
143
  save: () => null,
138
144
  category: 'text',
139
145
  title: 'Test Block Post Content Child',
@@ -143,6 +149,7 @@ describe( 'selectors', () => {
143
149
  } );
144
150
 
145
151
  registerBlockType( 'core/test-block-ancestor', {
152
+ apiVersion: 3,
146
153
  save: ( props ) => props.attributes.text,
147
154
  category: 'text',
148
155
  title: 'Test Block required as ancestor',
@@ -151,6 +158,7 @@ describe( 'selectors', () => {
151
158
  } );
152
159
 
153
160
  registerBlockType( 'core/test-block-parent', {
161
+ apiVersion: 3,
154
162
  save: ( props ) => props.attributes.text,
155
163
  category: 'text',
156
164
  title: 'Test Block required as parent',
@@ -159,6 +167,7 @@ describe( 'selectors', () => {
159
167
  } );
160
168
 
161
169
  registerBlockType( 'core/test-block-requires-ancestor', {
170
+ apiVersion: 3,
162
171
  save: ( props ) => props.attributes.text,
163
172
  category: 'text',
164
173
  title: 'Test Block that requires ancestor',
@@ -168,6 +177,7 @@ describe( 'selectors', () => {
168
177
  } );
169
178
 
170
179
  registerBlockType( 'core/test-block-requires-ancestor-parent', {
180
+ apiVersion: 3,
171
181
  save: ( props ) => props.attributes.text,
172
182
  category: 'text',
173
183
  title: 'Test Block that requires both ancestor and parent',
@@ -3548,6 +3558,7 @@ describe( 'selectors', () => {
3548
3558
  describe( 'getBlockTransformItems', () => {
3549
3559
  beforeAll( () => {
3550
3560
  registerBlockType( 'core/with-tranforms-a', {
3561
+ apiVersion: 3,
3551
3562
  category: 'text',
3552
3563
  title: 'Transforms a',
3553
3564
  edit: () => {},
@@ -3577,6 +3588,7 @@ describe( 'selectors', () => {
3577
3588
  },
3578
3589
  } );
3579
3590
  registerBlockType( 'core/with-tranforms-b', {
3591
+ apiVersion: 3,
3580
3592
  category: 'text',
3581
3593
  title: 'Transforms b',
3582
3594
  edit: () => {},
@@ -3592,6 +3604,7 @@ describe( 'selectors', () => {
3592
3604
  },
3593
3605
  } );
3594
3606
  registerBlockType( 'core/with-tranforms-c', {
3607
+ apiVersion: 3,
3595
3608
  category: 'text',
3596
3609
  title: 'Transforms c',
3597
3610
  edit: () => {},
@@ -4246,18 +4259,21 @@ describe( 'getInserterItems with core blocks prioritization', () => {
4246
4259
  // the core blocks (usually by using the `init` action), thus affecting the display order.
4247
4260
  beforeEach( () => {
4248
4261
  registerBlockType( 'plugin/block-a', {
4262
+ apiVersion: 3,
4249
4263
  save() {},
4250
4264
  category: 'text',
4251
4265
  title: 'Plugin Block A',
4252
4266
  icon: 'test',
4253
4267
  } );
4254
4268
  registerBlockType( 'another-plugin/block-b', {
4269
+ apiVersion: 3,
4255
4270
  save() {},
4256
4271
  category: 'text',
4257
4272
  title: 'Another Plugin Block B',
4258
4273
  icon: 'test',
4259
4274
  } );
4260
4275
  registerBlockType( 'plugin/block-c-with-variations', {
4276
+ apiVersion: 3,
4261
4277
  save() {},
4262
4278
  category: 'text',
4263
4279
  title: 'Plugin Block C with variations',
@@ -4265,11 +4281,13 @@ describe( 'getInserterItems with core blocks prioritization', () => {
4265
4281
  variations: [ { name: 'variation-a' }, { name: 'variation-b' } ],
4266
4282
  } );
4267
4283
  registerBlockType( 'core/block', {
4284
+ apiVersion: 3,
4268
4285
  save() {},
4269
4286
  category: 'text',
4270
4287
  title: 'Core Block A',
4271
4288
  } );
4272
4289
  registerBlockType( 'core/test-block-a', {
4290
+ apiVersion: 3,
4273
4291
  save: ( props ) => props.attributes.text,
4274
4292
  category: 'design',
4275
4293
  title: 'Core Block B',
@@ -4277,6 +4295,7 @@ describe( 'getInserterItems with core blocks prioritization', () => {
4277
4295
  keywords: [ 'testing' ],
4278
4296
  } );
4279
4297
  registerBlockType( 'core/test-block-with-variations', {
4298
+ apiVersion: 3,
4280
4299
  save() {},
4281
4300
  category: 'text',
4282
4301
  title: 'Core Block C with variations',
@@ -18,11 +18,26 @@ function findOptimalFontSize( textElement, applyFontSize ) {
18
18
  let bestSize = minSize;
19
19
 
20
20
  const computedStyle = window.getComputedStyle( textElement );
21
- const paddingLeft = parseFloat( computedStyle.paddingLeft ) || 0;
22
- const paddingRight = parseFloat( computedStyle.paddingRight ) || 0;
21
+ let paddingLeft = parseFloat( computedStyle.paddingLeft ) || 0;
22
+ let paddingRight = parseFloat( computedStyle.paddingRight ) || 0;
23
23
  const range = document.createRange();
24
24
  range.selectNodeContents( textElement );
25
25
 
26
+ let referenceElement = textElement;
27
+ const parentElement = textElement.parentElement;
28
+ if ( parentElement ) {
29
+ const parentElementComputedStyle =
30
+ window.getComputedStyle( parentElement );
31
+ if ( parentElementComputedStyle?.display === 'flex' ) {
32
+ referenceElement = parentElement;
33
+ paddingLeft +=
34
+ parseFloat( parentElementComputedStyle.paddingLeft ) || 0;
35
+ paddingRight +=
36
+ parseFloat( parentElementComputedStyle.paddingRight ) || 0;
37
+ }
38
+ }
39
+ let maxclientHeight = referenceElement.clientHeight;
40
+
26
41
  while ( minSize <= maxSize ) {
27
42
  const midSize = Math.floor( ( minSize + maxSize ) / 2 );
28
43
  applyFontSize( midSize );
@@ -36,12 +51,23 @@ function findOptimalFontSize( textElement, applyFontSize ) {
36
51
  // Check if text fits within the element's width and is not
37
52
  // overflowing into the padding area.
38
53
  const fitsWidth =
39
- textElement.scrollWidth <= textElement.clientWidth &&
40
- textWidth <= textElement.clientWidth - paddingLeft - paddingRight;
54
+ textElement.scrollWidth <= referenceElement.clientWidth &&
55
+ textWidth <=
56
+ referenceElement.clientWidth - paddingLeft - paddingRight;
41
57
  // Check if text fits within the element's height.
42
58
  const fitsHeight =
43
59
  alreadyHasScrollableHeight ||
44
- textElement.scrollHeight <= textElement.clientHeight;
60
+ textElement.scrollHeight <= referenceElement.clientHeight ||
61
+ textElement.scrollHeight <= maxclientHeight;
62
+
63
+ // When there are calculated line heights, text may jump in height
64
+ // the available space may decrease while the font size decreases,
65
+ // making text not fit.
66
+ // We store a maximum reference height: the maximum reference element height that was observed
67
+ // during the loop to avoid issues with such jumps.
68
+ if ( referenceElement.clientHeight > maxclientHeight ) {
69
+ maxclientHeight = referenceElement.clientHeight;
70
+ }
45
71
 
46
72
  if ( fitsWidth && fitsHeight ) {
47
73
  bestSize = midSize;