@wordpress/block-editor 15.6.7 → 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 (122) hide show
  1. package/README.md +4 -0
  2. package/build/components/block-settings-menu-controls/index.js +1 -1
  3. package/build/components/block-settings-menu-controls/index.js.map +2 -2
  4. package/build/components/block-tools/index.js +56 -45
  5. package/build/components/block-tools/index.js.map +3 -3
  6. package/build/components/block-visibility/toolbar.js +1 -1
  7. package/build/components/block-visibility/toolbar.js.map +1 -1
  8. package/build/components/global-styles/color-panel.js +1 -3
  9. package/build/components/global-styles/color-panel.js.map +2 -2
  10. package/build/components/global-styles/typography-panel.js +40 -26
  11. package/build/components/global-styles/typography-panel.js.map +2 -2
  12. package/build/components/index.js +3 -0
  13. package/build/components/index.js.map +2 -2
  14. package/build/components/list-view/block-select-button.js +1 -1
  15. package/build/components/list-view/block-select-button.js.map +1 -1
  16. package/build/components/list-view/block.js +3 -3
  17. package/build/components/list-view/block.js.map +2 -2
  18. package/build/components/rich-text/index.js +4 -6
  19. package/build/components/rich-text/index.js.map +2 -2
  20. package/build/components/rich-text/use-format-types.js +10 -27
  21. package/build/components/rich-text/use-format-types.js.map +2 -2
  22. package/build/components/tool-selector/index.js +44 -0
  23. package/build/components/tool-selector/index.js.map +7 -0
  24. package/build/components/use-block-commands/index.js +1 -1
  25. package/build/components/use-block-commands/index.js.map +2 -2
  26. package/build/components/use-block-drop-zone/index.js +1 -5
  27. package/build/components/use-block-drop-zone/index.js.map +2 -2
  28. package/build/hooks/fit-text.js +13 -6
  29. package/build/hooks/fit-text.js.map +2 -2
  30. package/build/hooks/metadata.js +1 -1
  31. package/build/hooks/metadata.js.map +2 -2
  32. package/build/private-apis.js +0 -1
  33. package/build/private-apis.js.map +2 -2
  34. package/build/store/private-keys.js +0 -3
  35. package/build/store/private-keys.js.map +2 -2
  36. package/build/store/private-selectors.js +1 -1
  37. package/build/store/private-selectors.js.map +2 -2
  38. package/build/utils/fit-text-utils.js +18 -4
  39. package/build/utils/fit-text-utils.js.map +2 -2
  40. package/build-module/components/block-settings-menu-controls/index.js +1 -1
  41. package/build-module/components/block-settings-menu-controls/index.js.map +2 -2
  42. package/build-module/components/block-tools/index.js +56 -45
  43. package/build-module/components/block-tools/index.js.map +2 -2
  44. package/build-module/components/block-visibility/toolbar.js +1 -1
  45. package/build-module/components/block-visibility/toolbar.js.map +1 -1
  46. package/build-module/components/global-styles/color-panel.js +1 -3
  47. package/build-module/components/global-styles/color-panel.js.map +2 -2
  48. package/build-module/components/global-styles/typography-panel.js +41 -27
  49. package/build-module/components/global-styles/typography-panel.js.map +2 -2
  50. package/build-module/components/index.js +2 -0
  51. package/build-module/components/index.js.map +2 -2
  52. package/build-module/components/list-view/block-select-button.js +1 -1
  53. package/build-module/components/list-view/block-select-button.js.map +1 -1
  54. package/build-module/components/list-view/block.js +3 -3
  55. package/build-module/components/list-view/block.js.map +2 -2
  56. package/build-module/components/rich-text/index.js +4 -6
  57. package/build-module/components/rich-text/index.js.map +2 -2
  58. package/build-module/components/rich-text/use-format-types.js +10 -27
  59. package/build-module/components/rich-text/use-format-types.js.map +2 -2
  60. package/build-module/components/tool-selector/index.js +14 -0
  61. package/build-module/components/tool-selector/index.js.map +7 -0
  62. package/build-module/components/use-block-commands/index.js +1 -1
  63. package/build-module/components/use-block-commands/index.js.map +2 -2
  64. package/build-module/components/use-block-drop-zone/index.js +1 -5
  65. package/build-module/components/use-block-drop-zone/index.js.map +2 -2
  66. package/build-module/hooks/fit-text.js +13 -6
  67. package/build-module/hooks/fit-text.js.map +2 -2
  68. package/build-module/hooks/metadata.js +1 -1
  69. package/build-module/hooks/metadata.js.map +2 -2
  70. package/build-module/private-apis.js +1 -3
  71. package/build-module/private-apis.js.map +2 -2
  72. package/build-module/store/private-keys.js +0 -2
  73. package/build-module/store/private-keys.js.map +2 -2
  74. package/build-module/store/private-selectors.js +1 -1
  75. package/build-module/store/private-selectors.js.map +2 -2
  76. package/build-module/utils/fit-text-utils.js +18 -4
  77. package/build-module/utils/fit-text-utils.js.map +2 -2
  78. package/build-style/content-rtl.css +3 -0
  79. package/build-style/content.css +3 -0
  80. package/build-style/style-rtl.css +7 -0
  81. package/build-style/style.css +7 -0
  82. package/package.json +8 -8
  83. package/src/components/block-controls/test/index.js +1 -0
  84. package/src/components/block-edit/test/edit.js +10 -0
  85. package/src/components/block-list/content.scss +5 -0
  86. package/src/components/block-preview/test/index.js +11 -7
  87. package/src/components/block-settings-menu-controls/index.js +1 -1
  88. package/src/components/block-switcher/test/index.js +2 -0
  89. package/src/components/block-switcher/test/use-transformed.patterns.js +2 -0
  90. package/src/components/block-switcher/test/utils.js +2 -0
  91. package/src/components/block-tools/index.js +15 -2
  92. package/src/components/block-tools/style.scss +4 -0
  93. package/src/components/block-visibility/toolbar.js +1 -1
  94. package/src/components/colors-gradients/style.scss +5 -0
  95. package/src/components/global-styles/color-panel.js +0 -2
  96. package/src/components/global-styles/test/get-global-styles-changes.js +1 -0
  97. package/src/components/global-styles/typography-panel.js +52 -32
  98. package/src/components/index.js +4 -0
  99. package/src/components/inner-blocks/test/index.js +2 -0
  100. package/src/components/list-view/block-select-button.js +1 -1
  101. package/src/components/list-view/block.js +3 -3
  102. package/src/components/provider/test/use-block-sync.js +1 -0
  103. package/src/components/rich-text/index.js +9 -12
  104. package/src/components/rich-text/use-format-types.js +19 -42
  105. package/src/components/tool-selector/index.js +19 -0
  106. package/src/components/use-block-commands/index.js +1 -1
  107. package/src/components/use-block-drop-zone/index.js +1 -5
  108. package/src/hooks/fit-text.js +19 -4
  109. package/src/hooks/metadata.js +1 -1
  110. package/src/hooks/test/align.js +1 -0
  111. package/src/hooks/test/allowed-blocks.js +8 -0
  112. package/src/hooks/test/font-size.js +1 -0
  113. package/src/hooks/test/metadata.js +5 -1
  114. package/src/hooks/test/text-align.js +1 -0
  115. package/src/private-apis.js +0 -2
  116. package/src/store/private-keys.js +0 -1
  117. package/src/store/private-selectors.js +1 -1
  118. package/src/store/test/actions.js +7 -0
  119. package/src/store/test/reducer.js +4 -0
  120. package/src/store/test/registry-selectors.js +2 -0
  121. package/src/store/test/selectors.js +19 -0
  122. package/src/utils/fit-text-utils.js +31 -5
@@ -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;