@wordpress/block-editor 11.3.3 → 11.4.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 (192) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/components/block-popover/inbetween.js +10 -33
  3. package/build/components/block-popover/inbetween.js.map +1 -1
  4. package/build/components/block-types-list/index.native.js +2 -0
  5. package/build/components/block-types-list/index.native.js.map +1 -1
  6. package/build/components/colors-gradients/control.js +6 -3
  7. package/build/components/colors-gradients/control.js.map +1 -1
  8. package/build/components/font-appearance-control/index.js +0 -3
  9. package/build/components/font-appearance-control/index.js.map +1 -1
  10. package/build/components/global-styles/hooks.js +106 -45
  11. package/build/components/global-styles/hooks.js.map +1 -1
  12. package/build/components/global-styles/index.js +24 -0
  13. package/build/components/global-styles/index.js.map +1 -1
  14. package/build/components/global-styles/typography-panel.js +421 -0
  15. package/build/components/global-styles/typography-panel.js.map +1 -0
  16. package/build/components/global-styles/use-global-styles-output.js +6 -2
  17. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  18. package/build/components/iframe/index.js +17 -11
  19. package/build/components/iframe/index.js.map +1 -1
  20. package/build/components/image-editor/aspect-ratio-dropdown.js +2 -1
  21. package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  22. package/build/components/image-size-control/index.js +6 -11
  23. package/build/components/image-size-control/index.js.map +1 -1
  24. package/build/components/inserter/block-patterns-tab.js +9 -15
  25. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  26. package/build/components/inserter/block-types-tab.native.js +4 -1
  27. package/build/components/inserter/block-types-tab.native.js.map +1 -1
  28. package/build/components/inserter/reusable-blocks-tab.native.js +4 -1
  29. package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
  30. package/build/components/inserter/search-results.native.js +4 -1
  31. package/build/components/inserter/search-results.native.js.map +1 -1
  32. package/build/components/link-control/index.js +15 -15
  33. package/build/components/link-control/index.js.map +1 -1
  34. package/build/components/link-control/settings-drawer.js +72 -30
  35. package/build/components/link-control/settings-drawer.js.map +1 -1
  36. package/build/components/link-control/settings.js +52 -0
  37. package/build/components/link-control/settings.js.map +1 -0
  38. package/build/components/list-view/index.js +6 -1
  39. package/build/components/list-view/index.js.map +1 -1
  40. package/build/components/off-canvas-editor/block-contents.js +3 -2
  41. package/build/components/off-canvas-editor/block-contents.js.map +1 -1
  42. package/build/components/off-canvas-editor/leaf-more-menu.js +116 -0
  43. package/build/components/off-canvas-editor/leaf-more-menu.js.map +1 -0
  44. package/build/components/off-canvas-editor/link-ui.js +1 -0
  45. package/build/components/off-canvas-editor/link-ui.js.map +1 -1
  46. package/build/components/rich-text/index.js +0 -2
  47. package/build/components/rich-text/index.js.map +1 -1
  48. package/build/components/url-input/index.js +2 -2
  49. package/build/components/url-input/index.js.map +1 -1
  50. package/build/hooks/dimensions.js +6 -0
  51. package/build/hooks/dimensions.js.map +1 -1
  52. package/build/hooks/font-family.js +2 -76
  53. package/build/hooks/font-family.js.map +1 -1
  54. package/build/hooks/font-size.js +3 -51
  55. package/build/hooks/font-size.js.map +1 -1
  56. package/build/hooks/gap.js +2 -1
  57. package/build/hooks/gap.js.map +1 -1
  58. package/build/hooks/index.js +2 -0
  59. package/build/hooks/index.js.map +1 -1
  60. package/build/hooks/line-height.js +0 -42
  61. package/build/hooks/line-height.js.map +1 -1
  62. package/build/hooks/typography.js +112 -127
  63. package/build/hooks/typography.js.map +1 -1
  64. package/build/private-apis.js +3 -0
  65. package/build/private-apis.js.map +1 -1
  66. package/build/store/selectors.js +18 -1
  67. package/build/store/selectors.js.map +1 -1
  68. package/build-module/components/block-popover/inbetween.js +10 -33
  69. package/build-module/components/block-popover/inbetween.js.map +1 -1
  70. package/build-module/components/block-types-list/index.native.js +2 -0
  71. package/build-module/components/block-types-list/index.native.js.map +1 -1
  72. package/build-module/components/colors-gradients/control.js +6 -3
  73. package/build-module/components/colors-gradients/control.js.map +1 -1
  74. package/build-module/components/font-appearance-control/index.js +2 -1
  75. package/build-module/components/font-appearance-control/index.js.map +1 -1
  76. package/build-module/components/global-styles/hooks.js +100 -46
  77. package/build-module/components/global-styles/hooks.js.map +1 -1
  78. package/build-module/components/global-styles/index.js +2 -1
  79. package/build-module/components/global-styles/index.js.map +1 -1
  80. package/build-module/components/global-styles/typography-panel.js +400 -0
  81. package/build-module/components/global-styles/typography-panel.js.map +1 -0
  82. package/build-module/components/global-styles/use-global-styles-output.js +6 -2
  83. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  84. package/build-module/components/iframe/index.js +17 -11
  85. package/build-module/components/iframe/index.js.map +1 -1
  86. package/build-module/components/image-editor/aspect-ratio-dropdown.js +2 -1
  87. package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  88. package/build-module/components/image-size-control/index.js +7 -12
  89. package/build-module/components/image-size-control/index.js.map +1 -1
  90. package/build-module/components/inserter/block-patterns-tab.js +9 -15
  91. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  92. package/build-module/components/inserter/block-types-tab.native.js +3 -1
  93. package/build-module/components/inserter/block-types-tab.native.js.map +1 -1
  94. package/build-module/components/inserter/reusable-blocks-tab.native.js +3 -1
  95. package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
  96. package/build-module/components/inserter/search-results.native.js +3 -1
  97. package/build-module/components/inserter/search-results.native.js.map +1 -1
  98. package/build-module/components/link-control/index.js +16 -16
  99. package/build-module/components/link-control/index.js.map +1 -1
  100. package/build-module/components/link-control/settings-drawer.js +68 -30
  101. package/build-module/components/link-control/settings-drawer.js.map +1 -1
  102. package/build-module/components/link-control/settings.js +43 -0
  103. package/build-module/components/link-control/settings.js.map +1 -0
  104. package/build-module/components/list-view/index.js +6 -1
  105. package/build-module/components/list-view/index.js.map +1 -1
  106. package/build-module/components/off-canvas-editor/block-contents.js +3 -2
  107. package/build-module/components/off-canvas-editor/block-contents.js.map +1 -1
  108. package/build-module/components/off-canvas-editor/leaf-more-menu.js +99 -0
  109. package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +1 -0
  110. package/build-module/components/off-canvas-editor/link-ui.js +1 -0
  111. package/build-module/components/off-canvas-editor/link-ui.js.map +1 -1
  112. package/build-module/components/rich-text/index.js +0 -2
  113. package/build-module/components/rich-text/index.js.map +1 -1
  114. package/build-module/components/url-input/index.js +2 -2
  115. package/build-module/components/url-input/index.js.map +1 -1
  116. package/build-module/hooks/dimensions.js +6 -0
  117. package/build-module/hooks/dimensions.js.map +1 -1
  118. package/build-module/hooks/font-family.js +3 -69
  119. package/build-module/hooks/font-family.js.map +1 -1
  120. package/build-module/hooks/font-size.js +6 -47
  121. package/build-module/hooks/font-size.js.map +1 -1
  122. package/build-module/hooks/gap.js +3 -2
  123. package/build-module/hooks/gap.js.map +1 -1
  124. package/build-module/hooks/index.js +1 -0
  125. package/build-module/hooks/index.js.map +1 -1
  126. package/build-module/hooks/line-height.js +0 -38
  127. package/build-module/hooks/line-height.js.map +1 -1
  128. package/build-module/hooks/typography.js +110 -123
  129. package/build-module/hooks/typography.js.map +1 -1
  130. package/build-module/private-apis.js +2 -0
  131. package/build-module/private-apis.js.map +1 -1
  132. package/build-module/store/selectors.js +18 -1
  133. package/build-module/store/selectors.js.map +1 -1
  134. package/build-style/style-rtl.css +35 -22
  135. package/build-style/style.css +35 -22
  136. package/package.json +31 -31
  137. package/src/components/block-popover/inbetween.js +21 -53
  138. package/src/components/block-types-list/index.native.js +2 -0
  139. package/src/components/colors-gradients/control.js +3 -0
  140. package/src/components/font-appearance-control/index.js +1 -1
  141. package/src/components/global-styles/hooks.js +186 -66
  142. package/src/components/global-styles/index.js +5 -0
  143. package/src/components/global-styles/typography-panel.js +403 -0
  144. package/src/components/global-styles/use-global-styles-output.js +6 -2
  145. package/src/components/iframe/index.js +20 -18
  146. package/src/components/image-editor/aspect-ratio-dropdown.js +1 -0
  147. package/src/components/image-size-control/index.js +10 -12
  148. package/src/components/image-size-control/style.scss +3 -21
  149. package/src/components/inserter/block-patterns-tab.js +9 -23
  150. package/src/components/inserter/block-types-tab.native.js +2 -0
  151. package/src/components/inserter/reusable-blocks-tab.native.js +2 -0
  152. package/src/components/inserter/search-results.native.js +2 -0
  153. package/src/components/link-control/index.js +22 -22
  154. package/src/components/link-control/settings-drawer.js +85 -30
  155. package/src/components/link-control/settings.js +41 -0
  156. package/src/components/link-control/style.scss +39 -7
  157. package/src/components/link-control/test/index.js +213 -4
  158. package/src/components/list-view/index.js +5 -0
  159. package/src/components/off-canvas-editor/block-contents.js +2 -1
  160. package/src/components/off-canvas-editor/leaf-more-menu.js +115 -0
  161. package/src/components/off-canvas-editor/link-ui.js +1 -0
  162. package/src/components/rich-text/index.js +0 -2
  163. package/src/components/url-input/index.js +3 -2
  164. package/src/hooks/dimensions.js +12 -0
  165. package/src/hooks/font-family.js +0 -58
  166. package/src/hooks/font-size.js +1 -36
  167. package/src/hooks/gap.js +9 -2
  168. package/src/hooks/index.js +1 -0
  169. package/src/hooks/line-height.js +0 -33
  170. package/src/hooks/typography.js +133 -212
  171. package/src/private-apis.js +2 -0
  172. package/src/store/selectors.js +16 -1
  173. package/build/hooks/font-appearance.js +0 -188
  174. package/build/hooks/font-appearance.js.map +0 -1
  175. package/build/hooks/letter-spacing.js +0 -129
  176. package/build/hooks/letter-spacing.js.map +0 -1
  177. package/build/hooks/text-decoration.js +0 -130
  178. package/build/hooks/text-decoration.js.map +0 -1
  179. package/build/hooks/text-transform.js +0 -130
  180. package/build/hooks/text-transform.js.map +0 -1
  181. package/build-module/hooks/font-appearance.js +0 -161
  182. package/build-module/hooks/font-appearance.js.map +0 -1
  183. package/build-module/hooks/letter-spacing.js +0 -107
  184. package/build-module/hooks/letter-spacing.js.map +0 -1
  185. package/build-module/hooks/text-decoration.js +0 -108
  186. package/build-module/hooks/text-decoration.js.map +0 -1
  187. package/build-module/hooks/text-transform.js +0 -108
  188. package/build-module/hooks/text-transform.js.map +0 -1
  189. package/src/hooks/font-appearance.js +0 -146
  190. package/src/hooks/letter-spacing.js +0 -101
  191. package/src/hooks/text-decoration.js +0 -102
  192. package/src/hooks/text-transform.js +0 -101
@@ -0,0 +1,403 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import {
5
+ FontSizePicker,
6
+ __experimentalToolsPanel as ToolsPanel,
7
+ __experimentalToolsPanelItem as ToolsPanelItem,
8
+ } from '@wordpress/components';
9
+ import { __ } from '@wordpress/i18n';
10
+
11
+ /**
12
+ * Internal dependencies
13
+ */
14
+ import FontFamilyControl from '../font-family';
15
+ import FontAppearanceControl from '../font-appearance-control';
16
+ import LineHeightControl from '../line-height-control';
17
+ import LetterSpacingControl from '../letter-spacing-control';
18
+ import TextTransformControl from '../text-transform-control';
19
+ import TextDecorationControl from '../text-decoration-control';
20
+ import { getValueFromVariable } from './utils';
21
+
22
+ export function useHasTypographyPanel( settings ) {
23
+ const hasFontFamily = useHasFontFamilyControl( settings );
24
+ const hasLineHeight = useHasLineHeightControl( settings );
25
+ const hasFontAppearance = useHasAppearanceControl( settings );
26
+ const hasLetterSpacing = useHasLetterSpacingControl( settings );
27
+ const hasTextTransform = useHasTextTransformControl( settings );
28
+ const hasTextDecoration = useHasTextDecorationControl( settings );
29
+ const hasFontSize = useHasFontSizeControl( settings );
30
+
31
+ return (
32
+ hasFontFamily ||
33
+ hasLineHeight ||
34
+ hasFontAppearance ||
35
+ hasLetterSpacing ||
36
+ hasTextTransform ||
37
+ hasFontSize ||
38
+ hasTextDecoration
39
+ );
40
+ }
41
+
42
+ function useHasFontSizeControl( settings ) {
43
+ const disableCustomFontSizes = ! settings?.typography?.customFontSize;
44
+ const fontSizesPerOrigin = settings?.typography?.fontSizes ?? {};
45
+ const fontSizes =
46
+ fontSizesPerOrigin?.custom ??
47
+ fontSizesPerOrigin?.theme ??
48
+ fontSizesPerOrigin.default;
49
+ return !! fontSizes?.length || ! disableCustomFontSizes;
50
+ }
51
+
52
+ function useHasFontFamilyControl( settings ) {
53
+ const fontFamiliesPerOrigin = settings?.typography?.fontFamilies;
54
+ const fontFamilies =
55
+ fontFamiliesPerOrigin?.custom ??
56
+ fontFamiliesPerOrigin?.theme ??
57
+ fontFamiliesPerOrigin?.default;
58
+ return !! fontFamilies?.length;
59
+ }
60
+
61
+ function useHasLineHeightControl( settings ) {
62
+ return settings?.typography?.lineHeight;
63
+ }
64
+
65
+ function useHasAppearanceControl( settings ) {
66
+ const hasFontStyles = settings?.typography?.fontStyle;
67
+ const hasFontWeights = settings?.typography?.fontWeight;
68
+ return hasFontStyles || hasFontWeights;
69
+ }
70
+
71
+ function useAppearanceControlLabel( settings ) {
72
+ const hasFontStyles = settings?.typography?.fontStyle;
73
+ const hasFontWeights = settings?.typography?.fontWeight;
74
+ if ( ! hasFontStyles ) {
75
+ return __( 'Font weight' );
76
+ }
77
+ if ( ! hasFontWeights ) {
78
+ return __( 'Font style' );
79
+ }
80
+ return __( 'Appearance' );
81
+ }
82
+
83
+ function useHasLetterSpacingControl( settings ) {
84
+ return settings?.typography?.letterSpacing;
85
+ }
86
+
87
+ function useHasTextTransformControl( settings ) {
88
+ return settings?.typography?.textTransform;
89
+ }
90
+
91
+ function useHasTextDecorationControl( settings ) {
92
+ return settings?.typography?.textDecoration;
93
+ }
94
+
95
+ function TypographyToolsPanel( { ...props } ) {
96
+ return <ToolsPanel label={ __( 'Typography' ) } { ...props } />;
97
+ }
98
+
99
+ const DEFAULT_CONTROLS = {
100
+ fontFamily: true,
101
+ fontSize: true,
102
+ fontAppearance: true,
103
+ lineHeight: true,
104
+ letterSpacing: true,
105
+ textTransform: true,
106
+ textDecoration: true,
107
+ };
108
+
109
+ export default function TypographyPanel( {
110
+ as: Wrapper = TypographyToolsPanel,
111
+ value,
112
+ onChange,
113
+ inheritedValue = value,
114
+ settings,
115
+ panelId,
116
+ defaultControls = DEFAULT_CONTROLS,
117
+ } ) {
118
+ const decodeValue = ( rawValue ) =>
119
+ getValueFromVariable( { settings }, '', rawValue );
120
+
121
+ // Font Family
122
+ const hasFontFamilyEnabled = useHasFontFamilyControl( settings );
123
+ const fontFamiliesPerOrigin = settings?.typography?.fontFamilies;
124
+ const fontFamilies =
125
+ fontFamiliesPerOrigin?.custom ??
126
+ fontFamiliesPerOrigin?.theme ??
127
+ fontFamiliesPerOrigin?.default;
128
+ const fontFamily = decodeValue( inheritedValue?.typography?.fontFamily );
129
+ const setFontFamily = ( newValue ) => {
130
+ const slug = fontFamilies?.find(
131
+ ( { fontFamily: f } ) => f === newValue
132
+ )?.slug;
133
+ onChange( {
134
+ ...value,
135
+ typography: {
136
+ ...value?.typography,
137
+ fontFamily: slug
138
+ ? `var:preset|font-family|${ slug }`
139
+ : newValue,
140
+ },
141
+ } );
142
+ };
143
+ const hasFontFamily = () => !! value?.typography?.fontFamily;
144
+ const resetFontFamily = () => setFontFamily( undefined );
145
+
146
+ // Font Size
147
+ const hasFontSizeEnabled = useHasFontSizeControl( settings );
148
+ const disableCustomFontSizes = ! settings?.typography?.customFontSize;
149
+ const fontSizesPerOrigin = settings?.typography?.fontSizes ?? {};
150
+ const fontSizes =
151
+ fontSizesPerOrigin?.custom ??
152
+ fontSizesPerOrigin?.theme ??
153
+ fontSizesPerOrigin.default;
154
+ const fontSize = decodeValue( inheritedValue?.typography?.fontSize );
155
+ const setFontSize = ( newValue, metadata ) => {
156
+ const actualValue = !! metadata?.slug
157
+ ? `var:preset|font-size|${ metadata?.slug }`
158
+ : newValue;
159
+
160
+ onChange( {
161
+ ...value,
162
+ typography: {
163
+ ...value?.typography,
164
+ fontSize: actualValue,
165
+ },
166
+ } );
167
+ };
168
+ const hasFontSize = () => !! value?.typography?.fontSize;
169
+ const resetFontSize = () => setFontSize( undefined );
170
+
171
+ // Appearance
172
+ const hasAppearanceControl = useHasAppearanceControl( settings );
173
+ const appearanceControlLabel = useAppearanceControlLabel( settings );
174
+ const hasFontStyles = settings?.typography?.fontStyle;
175
+ const hasFontWeights = settings?.typography?.fontWeight;
176
+ const fontStyle = decodeValue( inheritedValue?.typography?.fontStyle );
177
+ const fontWeight = decodeValue( inheritedValue?.typography?.fontWeight );
178
+ const setFontAppearance = ( {
179
+ fontStyle: newFontStyle,
180
+ fontWeight: newFontWeight,
181
+ } ) => {
182
+ onChange( {
183
+ ...value,
184
+ typography: {
185
+ ...value?.typography,
186
+ fontStyle: newFontStyle,
187
+ fontWeight: newFontWeight,
188
+ },
189
+ } );
190
+ };
191
+ const hasFontAppearance = () =>
192
+ !! value?.typography?.fontStyle || !! value?.typography?.fontWeight;
193
+ const resetFontAppearance = () => {
194
+ setFontAppearance( {} );
195
+ };
196
+
197
+ // Line Height
198
+ const hasLineHeightEnabled = useHasLineHeightControl( settings );
199
+ const lineHeight = decodeValue( inheritedValue?.typography?.lineHeight );
200
+ const setLineHeight = ( newValue ) => {
201
+ onChange( {
202
+ ...value,
203
+ typography: {
204
+ ...value?.typography,
205
+ lineHeight: newValue,
206
+ },
207
+ } );
208
+ };
209
+ const hasLineHeight = () => !! value?.typography?.lineHeight;
210
+ const resetLineHeight = () => setLineHeight( undefined );
211
+
212
+ // Letter Spacing
213
+ const hasLetterSpacingControl = useHasLetterSpacingControl( settings );
214
+ const letterSpacing = decodeValue(
215
+ inheritedValue?.typography?.letterSpacing
216
+ );
217
+ const setLetterSpacing = ( newValue ) => {
218
+ onChange( {
219
+ ...value,
220
+ typography: {
221
+ ...value?.typography,
222
+ letterSpacing: newValue,
223
+ },
224
+ } );
225
+ };
226
+ const hasLetterSpacing = () => !! value?.typography?.letterSpacing;
227
+ const resetLetterSpacing = () => setLetterSpacing( undefined );
228
+
229
+ // Text Transform
230
+ const hasTextTransformControl = useHasTextTransformControl( settings );
231
+ const textTransform = decodeValue(
232
+ inheritedValue?.typography?.textTransform
233
+ );
234
+ const setTextTransform = ( newValue ) => {
235
+ onChange( {
236
+ ...value,
237
+ typography: {
238
+ ...value?.typography,
239
+ textTransform: newValue,
240
+ },
241
+ } );
242
+ };
243
+ const hasTextTransform = () => !! value?.typography?.textTransform;
244
+ const resetTextTransform = () => setTextTransform( undefined );
245
+
246
+ // Text Decoration
247
+ const hasTextDecorationControl = useHasTextDecorationControl( settings );
248
+ const textDecoration = decodeValue(
249
+ inheritedValue?.typography?.textDecoration
250
+ );
251
+ const setTextDecoration = ( newValue ) => {
252
+ onChange( {
253
+ ...value,
254
+ typography: {
255
+ ...value?.typography,
256
+ textDecoration: newValue,
257
+ },
258
+ } );
259
+ };
260
+ const hasTextDecoration = () => !! value?.typography?.textDecoration;
261
+ const resetTextDecoration = () => setTextDecoration( undefined );
262
+
263
+ const resetAll = () => {
264
+ onChange( {
265
+ ...value,
266
+ typography: {},
267
+ } );
268
+ };
269
+
270
+ return (
271
+ <Wrapper resetAll={ resetAll }>
272
+ { hasFontFamilyEnabled && (
273
+ <ToolsPanelItem
274
+ label={ __( 'Font family' ) }
275
+ hasValue={ hasFontFamily }
276
+ onDeselect={ resetFontFamily }
277
+ isShownByDefault={ defaultControls.fontFamily }
278
+ panelId={ panelId }
279
+ >
280
+ <FontFamilyControl
281
+ fontFamilies={ fontFamilies }
282
+ value={ fontFamily }
283
+ onChange={ setFontFamily }
284
+ size="__unstable-large"
285
+ __nextHasNoMarginBottom
286
+ />
287
+ </ToolsPanelItem>
288
+ ) }
289
+ { hasFontSizeEnabled && (
290
+ <ToolsPanelItem
291
+ label={ __( 'Font size' ) }
292
+ hasValue={ hasFontSize }
293
+ onDeselect={ resetFontSize }
294
+ isShownByDefault={ defaultControls.fontSize }
295
+ panelId={ panelId }
296
+ >
297
+ <FontSizePicker
298
+ value={ fontSize }
299
+ onChange={ setFontSize }
300
+ fontSizes={ fontSizes }
301
+ disableCustomFontSizes={ disableCustomFontSizes }
302
+ withReset={ false }
303
+ withSlider
304
+ size="__unstable-large"
305
+ __nextHasNoMarginBottom
306
+ />
307
+ </ToolsPanelItem>
308
+ ) }
309
+ { hasAppearanceControl && (
310
+ <ToolsPanelItem
311
+ className="single-column"
312
+ label={ appearanceControlLabel }
313
+ hasValue={ hasFontAppearance }
314
+ onDeselect={ resetFontAppearance }
315
+ isShownByDefault={ defaultControls.fontAppearance }
316
+ panelId={ panelId }
317
+ >
318
+ <FontAppearanceControl
319
+ value={ {
320
+ fontStyle,
321
+ fontWeight,
322
+ } }
323
+ onChange={ setFontAppearance }
324
+ hasFontStyles={ hasFontStyles }
325
+ hasFontWeights={ hasFontWeights }
326
+ size="__unstable-large"
327
+ __nextHasNoMarginBottom
328
+ />
329
+ </ToolsPanelItem>
330
+ ) }
331
+ { hasLineHeightEnabled && (
332
+ <ToolsPanelItem
333
+ className="single-column"
334
+ label={ __( 'Line height' ) }
335
+ hasValue={ hasLineHeight }
336
+ onDeselect={ resetLineHeight }
337
+ isShownByDefault={ defaultControls.lineHeight }
338
+ panelId={ panelId }
339
+ >
340
+ <LineHeightControl
341
+ __nextHasNoMarginBottom
342
+ __unstableInputWidth="auto"
343
+ value={ lineHeight }
344
+ onChange={ setLineHeight }
345
+ size="__unstable-large"
346
+ />
347
+ </ToolsPanelItem>
348
+ ) }
349
+ { hasLetterSpacingControl && (
350
+ <ToolsPanelItem
351
+ className="single-column"
352
+ label={ __( 'Letter spacing' ) }
353
+ hasValue={ hasLetterSpacing }
354
+ onDeselect={ resetLetterSpacing }
355
+ isShownByDefault={ defaultControls.letterSpacing }
356
+ panelId={ panelId }
357
+ >
358
+ <LetterSpacingControl
359
+ value={ letterSpacing }
360
+ onChange={ setLetterSpacing }
361
+ size="__unstable-large"
362
+ __unstableInputWidth="auto"
363
+ />
364
+ </ToolsPanelItem>
365
+ ) }
366
+ { hasTextDecorationControl && (
367
+ <ToolsPanelItem
368
+ className="single-column"
369
+ label={ __( 'Text decoration' ) }
370
+ hasValue={ hasTextDecoration }
371
+ onDeselect={ resetTextDecoration }
372
+ isShownByDefault={ defaultControls.textDecoration }
373
+ panelId={ panelId }
374
+ >
375
+ <TextDecorationControl
376
+ value={ textDecoration }
377
+ onChange={ setTextDecoration }
378
+ size="__unstable-large"
379
+ __unstableInputWidth="auto"
380
+ />
381
+ </ToolsPanelItem>
382
+ ) }
383
+ { hasTextTransformControl && (
384
+ <ToolsPanelItem
385
+ label={ __( 'Letter case' ) }
386
+ hasValue={ hasTextTransform }
387
+ onDeselect={ resetTextTransform }
388
+ isShownByDefault={ defaultControls.textTransform }
389
+ panelId={ panelId }
390
+ >
391
+ <TextTransformControl
392
+ value={ textTransform }
393
+ onChange={ setTextTransform }
394
+ showNone
395
+ isBlock
396
+ size="__unstable-large"
397
+ __nextHasNoMarginBottom
398
+ />
399
+ </ToolsPanelItem>
400
+ ) }
401
+ </Wrapper>
402
+ );
403
+ }
@@ -664,13 +664,17 @@ export const toStyles = (
664
664
  }
665
665
 
666
666
  if ( useRootPaddingAlign ) {
667
+ /*
668
+ * These rules reproduce the ones from https://github.com/WordPress/gutenberg/blob/79103f124925d1f457f627e154f52a56228ed5ad/lib/class-wp-theme-json-gutenberg.php#L2508
669
+ * almost exactly, but for the selectors that target block wrappers in the front end. This code only runs in the editor, so it doesn't need those selectors.
670
+ */
667
671
  ruleset += `padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) }
668
672
  .has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
669
673
  .has-global-padding :where(.has-global-padding) { padding-right: 0; padding-left: 0; }
670
674
  .has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); }
671
675
  .has-global-padding :where(.has-global-padding) > .alignfull { margin-right: 0; margin-left: 0; }
672
- .has-global-padding > .alignfull:where(:not(.has-global-padding)) > :where([class*="wp-block-"]:not(.alignfull):not([class*="__"]),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
673
- .has-global-padding :where(.has-global-padding) > .alignfull:where(:not(.has-global-padding)) > :where([class*="wp-block-"]:not(.alignfull):not([class*="__"]),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: 0; padding-left: 0;`;
676
+ .has-global-padding > .alignfull:where(:not(.has-global-padding)) > :where(.wp-block:not(.alignfull),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
677
+ .has-global-padding :where(.has-global-padding) > .alignfull:where(:not(.has-global-padding)) > :where(.wp-block:not(.alignfull),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: 0; padding-left: 0;`;
674
678
  }
675
679
 
676
680
  ruleset += '}';
@@ -108,6 +108,7 @@ function Iframe( {
108
108
  tabIndex = 0,
109
109
  scale = 1,
110
110
  frameSize = 0,
111
+ expand = false,
111
112
  readonly,
112
113
  forwardedRef: ref,
113
114
  ...props
@@ -246,11 +247,30 @@ function Iframe( {
246
247
  return '<!doctype html>' + renderToString( styleAssets );
247
248
  }, [] );
248
249
 
250
+ // We need to counter the margin created by scaling the iframe. If the scale
251
+ // is e.g. 0.45, then the top + bottom margin is 0.55 (1 - scale). Just the
252
+ // top or bottom margin is 0.55 / 2 ((1 - scale) / 2).
253
+ const marginFromScaling = ( contentHeight * ( 1 - scale ) ) / 2;
254
+
249
255
  return (
250
256
  <>
251
257
  { tabIndex >= 0 && before }
252
258
  <iframe
253
259
  { ...props }
260
+ style={ {
261
+ ...props.style,
262
+ height: expand ? contentHeight : props.style?.height,
263
+ marginTop: scale
264
+ ? -marginFromScaling + frameSize
265
+ : props.style?.marginTop,
266
+ marginBottom: scale
267
+ ? -marginFromScaling + frameSize
268
+ : props.style?.marginBottom,
269
+ transform: scale
270
+ ? `scale( ${ scale } )`
271
+ : props.style?.transform,
272
+ transition: 'all .3s',
273
+ } }
254
274
  ref={ useMergeRefs( [ ref, setRef ] ) }
255
275
  tabIndex={ tabIndex }
256
276
  // Correct doctype is required to enable rendering in standards
@@ -265,13 +285,6 @@ function Iframe( {
265
285
  <head ref={ headRef }>
266
286
  { styleAssets }
267
287
  { head }
268
- <style>
269
- { `html { transition: background 5s; ${
270
- frameSize
271
- ? 'background: #2f2f2f; transition: background 0s;'
272
- : ''
273
- } }` }
274
- </style>
275
288
  </head>
276
289
  <body
277
290
  ref={ bodyRef }
@@ -280,17 +293,6 @@ function Iframe( {
280
293
  'editor-styles-wrapper',
281
294
  ...bodyClasses
282
295
  ) }
283
- style={ {
284
- // This is the remaining percentage from the scaling down
285
- // of the iframe body(`scale(0.45)`). We also need to subtract
286
- // the body's bottom margin.
287
- marginBottom: `-${
288
- contentHeight * ( 1 - scale ) -
289
- frameSize
290
- }px`,
291
- marginTop: frameSize,
292
- transform: `scale( ${ scale } )`,
293
- } }
294
296
  >
295
297
  { contentResizeListener }
296
298
  <StyleProvider document={ iframeDocument }>
@@ -54,6 +54,7 @@ export default function AspectRatioDropdown( { toggleProps } ) {
54
54
  } }
55
55
  value={ aspect }
56
56
  aspectRatios={ [
57
+ // All ratios should be mirrored in PostFeaturedImage in @wordpress/block-library
57
58
  {
58
59
  title: __( 'Original' ),
59
60
  aspect: defaultAspect,
@@ -5,7 +5,8 @@ import {
5
5
  Button,
6
6
  ButtonGroup,
7
7
  SelectControl,
8
- TextControl,
8
+ __experimentalNumberControl as NumberControl,
9
+ __experimentalHStack as HStack,
9
10
  } from '@wordpress/components';
10
11
  import { __ } from '@wordpress/i18n';
11
12
 
@@ -46,12 +47,10 @@ export default function ImageSizeControl( {
46
47
  ) }
47
48
  { isResizable && (
48
49
  <div className="block-editor-image-size-control">
49
- <p className="block-editor-image-size-control__row">
50
- { __( 'Image dimensions' ) }
51
- </p>
52
- <div className="block-editor-image-size-control__row">
53
- <TextControl
54
- type="number"
50
+ <p>{ __( 'Image dimensions' ) }</p>
51
+
52
+ <HStack align="baseline" spacing="3">
53
+ <NumberControl
55
54
  className="block-editor-image-size-control__width"
56
55
  label={ __( 'Width' ) }
57
56
  value={ currentWidth }
@@ -60,8 +59,7 @@ export default function ImageSizeControl( {
60
59
  updateDimension( 'width', value )
61
60
  }
62
61
  />
63
- <TextControl
64
- type="number"
62
+ <NumberControl
65
63
  className="block-editor-image-size-control__height"
66
64
  label={ __( 'Height' ) }
67
65
  value={ currentHeight }
@@ -70,8 +68,8 @@ export default function ImageSizeControl( {
70
68
  updateDimension( 'height', value )
71
69
  }
72
70
  />
73
- </div>
74
- <div className="block-editor-image-size-control__row">
71
+ </HStack>
72
+ <HStack>
75
73
  <ButtonGroup aria-label={ __( 'Image size presets' ) }>
76
74
  { IMAGE_SIZE_PRESETS.map( ( scale ) => {
77
75
  const scaledWidth = Math.round(
@@ -108,7 +106,7 @@ export default function ImageSizeControl( {
108
106
  <Button isSmall onClick={ () => updateDimensions() }>
109
107
  { __( 'Reset' ) }
110
108
  </Button>
111
- </div>
109
+ </HStack>
112
110
  </div>
113
111
  ) }
114
112
  </>
@@ -1,26 +1,8 @@
1
1
  .block-editor-image-size-control {
2
2
  margin-bottom: 1em;
3
3
 
4
- .block-editor-image-size-control__row {
5
- display: flex;
6
- justify-content: space-between;
7
-
8
- .block-editor-image-size-control__width,
9
- .block-editor-image-size-control__height {
10
- margin-bottom: 0.5em;
11
-
12
- // Fix the text and placeholder text being misaligned in Safari
13
- input {
14
- line-height: 1.25;
15
- }
16
- }
17
-
18
- .block-editor-image-size-control__width {
19
- margin-right: 5px;
20
- }
21
-
22
- .block-editor-image-size-control__height {
23
- margin-left: 5px;
24
- }
4
+ .block-editor-image-size-control__width,
5
+ .block-editor-image-size-control__height {
6
+ margin-bottom: 1.115em;
25
7
  }
26
8
  }
@@ -28,7 +28,7 @@ import BlockPatternList from '../block-patterns-list';
28
28
  import PatternsExplorerModal from './block-patterns-explorer/explorer';
29
29
  import MobileTabNavigation from './mobile-tab-navigation';
30
30
 
31
- // Preffered order of pattern categories. Any other categories should
31
+ // Preferred order of pattern categories. Any other categories should
32
32
  // be at the bottom without any re-ordering.
33
33
  const patternCategoriesOrder = [
34
34
  'featured',
@@ -68,28 +68,14 @@ function usePatternsCategories( rootClientId ) {
68
68
  pattern.categories?.includes( category.name )
69
69
  )
70
70
  )
71
- .sort( ( { name: currentName }, { name: nextName } ) => {
72
- // The pattern categories should be ordered as follows:
73
- // 1. The categories from `patternCategoriesOrder` in that specific order should be at the top.
74
- // 2. The rest categories should be at the bottom without any re-ordering.
75
- if (
76
- ! [ currentName, nextName ].some( ( categoryName ) =>
77
- patternCategoriesOrder.includes( categoryName )
78
- )
79
- ) {
80
- return 0;
81
- }
82
- if (
83
- [ currentName, nextName ].every( ( categoryName ) =>
84
- patternCategoriesOrder.includes( categoryName )
85
- )
86
- ) {
87
- return (
88
- patternCategoriesOrder.indexOf( currentName ) -
89
- patternCategoriesOrder.indexOf( nextName )
90
- );
91
- }
92
- return patternCategoriesOrder.includes( currentName ) ? -1 : 1;
71
+ .sort( ( { name: aName }, { name: bName } ) => {
72
+ // Sort categories according to `patternCategoriesOrder`.
73
+ let aIndex = patternCategoriesOrder.indexOf( aName );
74
+ let bIndex = patternCategoriesOrder.indexOf( bName );
75
+ // All other categories should come after that.
76
+ if ( aIndex < 0 ) aIndex = patternCategoriesOrder.length;
77
+ if ( bIndex < 0 ) bIndex = patternCategoriesOrder.length;
78
+ return aIndex - bIndex;
93
79
  } );
94
80
 
95
81
  if (
@@ -2,6 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { useMemo } from '@wordpress/element';
5
+ import { __ } from '@wordpress/i18n';
5
6
 
6
7
  /**
7
8
  * Internal dependencies
@@ -66,6 +67,7 @@ function BlockTypesTab( { onSelect, rootClientId, listProps } ) {
66
67
  sections={ sections }
67
68
  onSelect={ handleSelect }
68
69
  listProps={ listProps }
70
+ label={ __( 'Blocks menu' ) }
69
71
  />
70
72
  );
71
73
  }
@@ -2,6 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { useSelect } from '@wordpress/data';
5
+ import { __ } from '@wordpress/i18n';
5
6
 
6
7
  /**
7
8
  * Internal dependencies
@@ -31,6 +32,7 @@ function ReusableBlocksTab( { onSelect, rootClientId, listProps } ) {
31
32
  sections={ sections }
32
33
  onSelect={ onSelect }
33
34
  listProps={ listProps }
35
+ label={ __( 'Reusable blocks' ) }
34
36
  />
35
37
  );
36
38
  }
@@ -2,6 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { useSelect } from '@wordpress/data';
5
+ import { __ } from '@wordpress/i18n';
5
6
 
6
7
  /**
7
8
  * Internal dependencies
@@ -54,6 +55,7 @@ function InserterSearchResults( {
54
55
  sections={ [ createInserterSection( { key: 'search', items } ) ] }
55
56
  onSelect={ handleSelect }
56
57
  listProps={ listProps }
58
+ label={ __( 'Blocks' ) }
57
59
  />
58
60
  );
59
61
  }