@wordpress/edit-site 4.15.1-next.4d3b314fd5.0 → 4.16.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.
- package/CHANGELOG.md +2 -0
- package/build/components/block-editor/resizable-editor.js +11 -35
- package/build/components/block-editor/resizable-editor.js.map +1 -1
- package/build/components/global-styles/preview.js +2 -2
- package/build/components/global-styles/preview.js.map +1 -1
- package/build/components/global-styles/screen-typography-element.js +49 -2
- package/build/components/global-styles/screen-typography-element.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +128 -81
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/typography-preview.js +54 -0
- package/build/components/global-styles/typography-preview.js.map +1 -0
- package/build/components/global-styles/use-global-styles-output.js +7 -7
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/main-dashboard-button/index.js +2 -2
- package/build/components/main-dashboard-button/index.js.map +1 -1
- package/build/index.js +20 -1
- package/build/index.js.map +1 -1
- package/build-module/components/block-editor/resizable-editor.js +10 -34
- package/build-module/components/block-editor/resizable-editor.js.map +1 -1
- package/build-module/components/global-styles/preview.js +2 -2
- package/build-module/components/global-styles/preview.js.map +1 -1
- package/build-module/components/global-styles/screen-typography-element.js +48 -2
- package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +129 -83
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-preview.js +46 -0
- package/build-module/components/global-styles/typography-preview.js.map +1 -0
- package/build-module/components/global-styles/use-global-styles-output.js +7 -7
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/main-dashboard-button/index.js +3 -3
- package/build-module/components/main-dashboard-button/index.js.map +1 -1
- package/build-module/index.js +19 -1
- package/build-module/index.js.map +1 -1
- package/build-style/style-rtl.css +3 -3
- package/build-style/style.css +3 -3
- package/package.json +29 -29
- package/src/components/block-editor/resizable-editor.js +8 -37
- package/src/components/global-styles/preview.js +2 -2
- package/src/components/global-styles/screen-typography-element.js +65 -1
- package/src/components/global-styles/style.scss +2 -2
- package/src/components/global-styles/typography-panel.js +192 -150
- package/src/components/global-styles/typography-preview.js +49 -0
- package/src/components/global-styles/use-global-styles-output.js +15 -9
- package/src/components/main-dashboard-button/index.js +3 -3
- package/src/components/sidebar/style.scss +1 -1
- package/src/index.js +21 -0
|
@@ -9,25 +9,25 @@ import {
|
|
|
9
9
|
__experimentalTextTransformControl as TextTransformControl,
|
|
10
10
|
} from '@wordpress/block-editor';
|
|
11
11
|
import {
|
|
12
|
-
PanelBody,
|
|
13
12
|
FontSizePicker,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
__experimentalGrid as Grid,
|
|
13
|
+
__experimentalToolsPanel as ToolsPanel,
|
|
14
|
+
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
17
15
|
} from '@wordpress/components';
|
|
18
16
|
import { __ } from '@wordpress/i18n';
|
|
19
|
-
|
|
17
|
+
|
|
20
18
|
/**
|
|
21
19
|
* Internal dependencies
|
|
22
20
|
*/
|
|
23
21
|
import { getSupportedGlobalStylesPanels, useSetting, useStyle } from './hooks';
|
|
24
22
|
|
|
25
23
|
export function useHasTypographyPanel( name ) {
|
|
24
|
+
const hasFontFamily = useHasFontFamilyControl( name );
|
|
26
25
|
const hasLineHeight = useHasLineHeightControl( name );
|
|
27
26
|
const hasFontAppearance = useHasAppearanceControl( name );
|
|
28
27
|
const hasLetterSpacing = useHasLetterSpacingControl( name );
|
|
29
28
|
const supports = getSupportedGlobalStylesPanels( name );
|
|
30
29
|
return (
|
|
30
|
+
hasFontFamily ||
|
|
31
31
|
hasLineHeight ||
|
|
32
32
|
hasFontAppearance ||
|
|
33
33
|
hasLetterSpacing ||
|
|
@@ -35,6 +35,12 @@ export function useHasTypographyPanel( name ) {
|
|
|
35
35
|
);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
function useHasFontFamilyControl( name ) {
|
|
39
|
+
const supports = getSupportedGlobalStylesPanels( name );
|
|
40
|
+
const [ fontFamilies ] = useSetting( 'typography.fontFamilies', name );
|
|
41
|
+
return supports.includes( 'fontFamily' ) && !! fontFamilies?.length;
|
|
42
|
+
}
|
|
43
|
+
|
|
38
44
|
function useHasLineHeightControl( name ) {
|
|
39
45
|
const supports = getSupportedGlobalStylesPanels( name );
|
|
40
46
|
return (
|
|
@@ -54,6 +60,23 @@ function useHasAppearanceControl( name ) {
|
|
|
54
60
|
return hasFontStyles || hasFontWeights;
|
|
55
61
|
}
|
|
56
62
|
|
|
63
|
+
function useAppearanceControlLabel( name ) {
|
|
64
|
+
const supports = getSupportedGlobalStylesPanels( name );
|
|
65
|
+
const hasFontStyles =
|
|
66
|
+
useSetting( 'typography.fontStyle', name )[ 0 ] &&
|
|
67
|
+
supports.includes( 'fontStyle' );
|
|
68
|
+
const hasFontWeights =
|
|
69
|
+
useSetting( 'typography.fontWeight', name )[ 0 ] &&
|
|
70
|
+
supports.includes( 'fontWeight' );
|
|
71
|
+
if ( ! hasFontStyles ) {
|
|
72
|
+
return __( 'Font weight' );
|
|
73
|
+
}
|
|
74
|
+
if ( ! hasFontWeights ) {
|
|
75
|
+
return __( 'Font style' );
|
|
76
|
+
}
|
|
77
|
+
return __( 'Appearance' );
|
|
78
|
+
}
|
|
79
|
+
|
|
57
80
|
function useHasLetterSpacingControl( name, element ) {
|
|
58
81
|
const setting = useSetting( 'typography.letterSpacing', name )[ 0 ];
|
|
59
82
|
if ( ! setting ) {
|
|
@@ -78,12 +101,53 @@ function useHasTextTransformControl( name, element ) {
|
|
|
78
101
|
return supports.includes( 'textTransform' );
|
|
79
102
|
}
|
|
80
103
|
|
|
81
|
-
|
|
82
|
-
const [
|
|
104
|
+
function useStyleWithReset( path, blockName ) {
|
|
105
|
+
const [ style, setStyle ] = useStyle( path, blockName );
|
|
106
|
+
const [ userStyle ] = useStyle( path, blockName, 'user' );
|
|
107
|
+
const hasStyle = () => !! userStyle;
|
|
108
|
+
const resetStyle = () => setStyle( undefined );
|
|
109
|
+
return [ style, setStyle, hasStyle, resetStyle ];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function useFontAppearance( prefix, name ) {
|
|
113
|
+
const [ fontStyle, setFontStyle ] = useStyle(
|
|
114
|
+
prefix + 'typography.fontStyle',
|
|
115
|
+
name
|
|
116
|
+
);
|
|
117
|
+
const [ userFontStyle ] = useStyle(
|
|
118
|
+
prefix + 'typography.fontStyle',
|
|
119
|
+
name,
|
|
120
|
+
'user'
|
|
121
|
+
);
|
|
122
|
+
const [ fontWeight, setFontWeight ] = useStyle(
|
|
123
|
+
prefix + 'typography.fontWeight',
|
|
124
|
+
name
|
|
125
|
+
);
|
|
126
|
+
const [ userFontWeight ] = useStyle(
|
|
127
|
+
prefix + 'typography.fontWeight',
|
|
128
|
+
name,
|
|
129
|
+
'user'
|
|
130
|
+
);
|
|
131
|
+
const hasFontAppearance = () => !! userFontStyle || !! userFontWeight;
|
|
132
|
+
const resetFontAppearance = () => {
|
|
133
|
+
setFontStyle( undefined );
|
|
134
|
+
setFontWeight( undefined );
|
|
135
|
+
};
|
|
136
|
+
return {
|
|
137
|
+
fontStyle,
|
|
138
|
+
setFontStyle,
|
|
139
|
+
fontWeight,
|
|
140
|
+
setFontWeight,
|
|
141
|
+
hasFontAppearance,
|
|
142
|
+
resetFontAppearance,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export default function TypographyPanel( { name, element, headingLevel } ) {
|
|
83
147
|
const supports = getSupportedGlobalStylesPanels( name );
|
|
84
148
|
let prefix = '';
|
|
85
149
|
if ( element === 'heading' ) {
|
|
86
|
-
prefix = `elements.${
|
|
150
|
+
prefix = `elements.${ headingLevel }.`;
|
|
87
151
|
} else if ( element && element !== 'text' ) {
|
|
88
152
|
prefix = `elements.${ element }.`;
|
|
89
153
|
}
|
|
@@ -99,142 +163,99 @@ export default function TypographyPanel( { name, element } ) {
|
|
|
99
163
|
const hasFontWeights =
|
|
100
164
|
useSetting( 'typography.fontWeight', name )[ 0 ] &&
|
|
101
165
|
supports.includes( 'fontWeight' );
|
|
166
|
+
const hasFontFamilyEnabled = useHasFontFamilyControl( name );
|
|
102
167
|
const hasLineHeightEnabled = useHasLineHeightControl( name );
|
|
103
168
|
const hasAppearanceControl = useHasAppearanceControl( name );
|
|
169
|
+
const appearanceControlLabel = useAppearanceControlLabel( name );
|
|
104
170
|
const hasLetterSpacingControl = useHasLetterSpacingControl( name, element );
|
|
105
171
|
const hasTextTransformControl = useHasTextTransformControl( name, element );
|
|
106
172
|
|
|
107
173
|
/* Disable font size controls when the option to style all headings is selected. */
|
|
108
174
|
let hasFontSizeEnabled = supports.includes( 'fontSize' );
|
|
109
|
-
if ( element === 'heading' &&
|
|
175
|
+
if ( element === 'heading' && headingLevel === 'heading' ) {
|
|
110
176
|
hasFontSizeEnabled = false;
|
|
111
177
|
}
|
|
112
178
|
|
|
113
|
-
const [ fontFamily, setFontFamily ] =
|
|
114
|
-
prefix + 'typography.fontFamily',
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
179
|
+
const [ fontFamily, setFontFamily, hasFontFamily, resetFontFamily ] =
|
|
180
|
+
useStyleWithReset( prefix + 'typography.fontFamily', name );
|
|
181
|
+
const [ fontSize, setFontSize, hasFontSize, resetFontSize ] =
|
|
182
|
+
useStyleWithReset( prefix + 'typography.fontSize', name );
|
|
183
|
+
const {
|
|
184
|
+
fontStyle,
|
|
185
|
+
setFontStyle,
|
|
186
|
+
fontWeight,
|
|
187
|
+
setFontWeight,
|
|
188
|
+
hasFontAppearance,
|
|
189
|
+
resetFontAppearance,
|
|
190
|
+
} = useFontAppearance( prefix, name );
|
|
191
|
+
const [ lineHeight, setLineHeight, hasLineHeight, resetLineHeight ] =
|
|
192
|
+
useStyleWithReset( prefix + 'typography.lineHeight', name );
|
|
193
|
+
const [
|
|
194
|
+
letterSpacing,
|
|
195
|
+
setLetterSpacing,
|
|
196
|
+
hasLetterSpacing,
|
|
197
|
+
resetLetterSpacing,
|
|
198
|
+
] = useStyleWithReset( prefix + 'typography.letterSpacing', name );
|
|
199
|
+
const [
|
|
200
|
+
textTransform,
|
|
201
|
+
setTextTransform,
|
|
202
|
+
hasTextTransform,
|
|
203
|
+
resetTextTransform,
|
|
204
|
+
] = useStyleWithReset( prefix + 'typography.textTransform', name );
|
|
121
205
|
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const [ lineHeight, setLineHeight ] = useStyle(
|
|
131
|
-
prefix + 'typography.lineHeight',
|
|
132
|
-
name
|
|
133
|
-
);
|
|
134
|
-
const [ letterSpacing, setLetterSpacing ] = useStyle(
|
|
135
|
-
prefix + 'typography.letterSpacing',
|
|
136
|
-
name
|
|
137
|
-
);
|
|
138
|
-
const [ textTransform, setTextTransform ] = useStyle(
|
|
139
|
-
prefix + 'typography.textTransform',
|
|
140
|
-
name
|
|
141
|
-
);
|
|
142
|
-
const [ backgroundColor ] = useStyle( prefix + 'color.background', name );
|
|
143
|
-
const [ gradientValue ] = useStyle( prefix + 'color.gradient', name );
|
|
144
|
-
const [ color ] = useStyle( prefix + 'color.text', name );
|
|
145
|
-
const extraStyles =
|
|
146
|
-
element === 'link'
|
|
147
|
-
? {
|
|
148
|
-
textDecoration: 'underline',
|
|
149
|
-
}
|
|
150
|
-
: {};
|
|
206
|
+
const resetAll = () => {
|
|
207
|
+
resetFontFamily();
|
|
208
|
+
resetFontSize();
|
|
209
|
+
resetFontAppearance();
|
|
210
|
+
resetLineHeight();
|
|
211
|
+
resetLetterSpacing();
|
|
212
|
+
resetTextTransform();
|
|
213
|
+
};
|
|
151
214
|
|
|
152
215
|
return (
|
|
153
|
-
<
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
value="h3"
|
|
197
|
-
label={ __( 'H3' ) }
|
|
198
|
-
/>
|
|
199
|
-
<ToggleGroupControlOption
|
|
200
|
-
value="h4"
|
|
201
|
-
label={ __( 'H4' ) }
|
|
202
|
-
/>
|
|
203
|
-
<ToggleGroupControlOption
|
|
204
|
-
value="h5"
|
|
205
|
-
label={ __( 'H5' ) }
|
|
206
|
-
/>
|
|
207
|
-
<ToggleGroupControlOption
|
|
208
|
-
value="h6"
|
|
209
|
-
label={ __( 'H6' ) }
|
|
210
|
-
/>
|
|
211
|
-
</ToggleGroupControl>
|
|
212
|
-
</div>
|
|
213
|
-
) }
|
|
214
|
-
{ supports.includes( 'fontFamily' ) && (
|
|
215
|
-
<div className="edit-site-typography-panel__full-width-control">
|
|
216
|
-
<FontFamilyControl
|
|
217
|
-
fontFamilies={ fontFamilies }
|
|
218
|
-
value={ fontFamily }
|
|
219
|
-
onChange={ setFontFamily }
|
|
220
|
-
size="__unstable-large"
|
|
221
|
-
__nextHasNoMarginBottom
|
|
222
|
-
/>
|
|
223
|
-
</div>
|
|
224
|
-
) }
|
|
225
|
-
{ hasFontSizeEnabled && (
|
|
226
|
-
<div className="edit-site-typography-panel__full-width-control">
|
|
227
|
-
<FontSizePicker
|
|
228
|
-
value={ fontSize }
|
|
229
|
-
onChange={ setFontSize }
|
|
230
|
-
fontSizes={ fontSizes }
|
|
231
|
-
disableCustomFontSizes={ disableCustomFontSizes }
|
|
232
|
-
size="__unstable-large"
|
|
233
|
-
__nextHasNoMarginBottom
|
|
234
|
-
/>
|
|
235
|
-
</div>
|
|
236
|
-
) }
|
|
237
|
-
{ hasAppearanceControl && (
|
|
216
|
+
<ToolsPanel label={ __( 'Typography' ) } resetAll={ resetAll }>
|
|
217
|
+
{ hasFontFamilyEnabled && (
|
|
218
|
+
<ToolsPanelItem
|
|
219
|
+
label={ __( 'Font family' ) }
|
|
220
|
+
hasValue={ hasFontFamily }
|
|
221
|
+
onDeselect={ resetFontFamily }
|
|
222
|
+
isShownByDefault
|
|
223
|
+
>
|
|
224
|
+
<FontFamilyControl
|
|
225
|
+
fontFamilies={ fontFamilies }
|
|
226
|
+
value={ fontFamily }
|
|
227
|
+
onChange={ setFontFamily }
|
|
228
|
+
size="__unstable-large"
|
|
229
|
+
__nextHasNoMarginBottom
|
|
230
|
+
/>
|
|
231
|
+
</ToolsPanelItem>
|
|
232
|
+
) }
|
|
233
|
+
{ hasFontSizeEnabled && (
|
|
234
|
+
<ToolsPanelItem
|
|
235
|
+
label={ __( 'Font size' ) }
|
|
236
|
+
hasValue={ hasFontSize }
|
|
237
|
+
onDeselect={ resetFontSize }
|
|
238
|
+
isShownByDefault
|
|
239
|
+
>
|
|
240
|
+
<FontSizePicker
|
|
241
|
+
value={ fontSize }
|
|
242
|
+
onChange={ setFontSize }
|
|
243
|
+
fontSizes={ fontSizes }
|
|
244
|
+
disableCustomFontSizes={ disableCustomFontSizes }
|
|
245
|
+
withReset={ false }
|
|
246
|
+
size="__unstable-large"
|
|
247
|
+
__nextHasNoMarginBottom
|
|
248
|
+
/>
|
|
249
|
+
</ToolsPanelItem>
|
|
250
|
+
) }
|
|
251
|
+
{ hasAppearanceControl && (
|
|
252
|
+
<ToolsPanelItem
|
|
253
|
+
className="single-column"
|
|
254
|
+
label={ appearanceControlLabel }
|
|
255
|
+
hasValue={ hasFontAppearance }
|
|
256
|
+
onDeselect={ resetFontAppearance }
|
|
257
|
+
isShownByDefault
|
|
258
|
+
>
|
|
238
259
|
<FontAppearanceControl
|
|
239
260
|
value={ {
|
|
240
261
|
fontStyle,
|
|
@@ -252,8 +273,16 @@ export default function TypographyPanel( { name, element } ) {
|
|
|
252
273
|
size="__unstable-large"
|
|
253
274
|
__nextHasNoMarginBottom
|
|
254
275
|
/>
|
|
255
|
-
|
|
256
|
-
|
|
276
|
+
</ToolsPanelItem>
|
|
277
|
+
) }
|
|
278
|
+
{ hasLineHeightEnabled && (
|
|
279
|
+
<ToolsPanelItem
|
|
280
|
+
className="single-column"
|
|
281
|
+
label={ __( 'Line height' ) }
|
|
282
|
+
hasValue={ hasLineHeight }
|
|
283
|
+
onDeselect={ resetLineHeight }
|
|
284
|
+
isShownByDefault
|
|
285
|
+
>
|
|
257
286
|
<LineHeightControl
|
|
258
287
|
__nextHasNoMarginBottom
|
|
259
288
|
__unstableInputWidth="auto"
|
|
@@ -261,28 +290,41 @@ export default function TypographyPanel( { name, element } ) {
|
|
|
261
290
|
onChange={ setLineHeight }
|
|
262
291
|
size="__unstable-large"
|
|
263
292
|
/>
|
|
264
|
-
|
|
265
|
-
|
|
293
|
+
</ToolsPanelItem>
|
|
294
|
+
) }
|
|
295
|
+
{ hasLetterSpacingControl && (
|
|
296
|
+
<ToolsPanelItem
|
|
297
|
+
className="single-column"
|
|
298
|
+
label={ __( 'Letter spacing' ) }
|
|
299
|
+
hasValue={ hasLetterSpacing }
|
|
300
|
+
onDeselect={ resetLetterSpacing }
|
|
301
|
+
isShownByDefault
|
|
302
|
+
>
|
|
266
303
|
<LetterSpacingControl
|
|
267
304
|
value={ letterSpacing }
|
|
268
305
|
onChange={ setLetterSpacing }
|
|
269
306
|
size="__unstable-large"
|
|
270
307
|
__unstableInputWidth="auto"
|
|
271
308
|
/>
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
309
|
+
</ToolsPanelItem>
|
|
310
|
+
) }
|
|
311
|
+
{ hasTextTransformControl && (
|
|
312
|
+
<ToolsPanelItem
|
|
313
|
+
label={ __( 'Letter case' ) }
|
|
314
|
+
hasValue={ hasTextTransform }
|
|
315
|
+
onDeselect={ resetTextTransform }
|
|
316
|
+
isShownByDefault
|
|
317
|
+
>
|
|
318
|
+
<TextTransformControl
|
|
319
|
+
value={ textTransform }
|
|
320
|
+
onChange={ setTextTransform }
|
|
321
|
+
showNone
|
|
322
|
+
isBlock
|
|
323
|
+
size="__unstable-large"
|
|
324
|
+
__nextHasNoMarginBottom
|
|
325
|
+
/>
|
|
326
|
+
</ToolsPanelItem>
|
|
327
|
+
) }
|
|
328
|
+
</ToolsPanel>
|
|
287
329
|
);
|
|
288
330
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useStyle } from './hooks';
|
|
5
|
+
|
|
6
|
+
export default function TypographyPreview( { name, element, headingLevel } ) {
|
|
7
|
+
let prefix = '';
|
|
8
|
+
if ( element === 'heading' ) {
|
|
9
|
+
prefix = `elements.${ headingLevel }.`;
|
|
10
|
+
} else if ( element && element !== 'text' ) {
|
|
11
|
+
prefix = `elements.${ element }.`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const [ fontFamily ] = useStyle( prefix + 'typography.fontFamily', name );
|
|
15
|
+
const [ gradientValue ] = useStyle( prefix + 'color.gradient', name );
|
|
16
|
+
const [ backgroundColor ] = useStyle( prefix + 'color.background', name );
|
|
17
|
+
const [ color ] = useStyle( prefix + 'color.text', name );
|
|
18
|
+
const [ fontSize ] = useStyle( prefix + 'typography.fontSize', name );
|
|
19
|
+
const [ fontStyle ] = useStyle( prefix + 'typography.fontStyle', name );
|
|
20
|
+
const [ fontWeight ] = useStyle( prefix + 'typography.fontWeight', name );
|
|
21
|
+
const [ letterSpacing ] = useStyle(
|
|
22
|
+
prefix + 'typography.letterSpacing',
|
|
23
|
+
name
|
|
24
|
+
);
|
|
25
|
+
const extraStyles =
|
|
26
|
+
element === 'link'
|
|
27
|
+
? {
|
|
28
|
+
textDecoration: 'underline',
|
|
29
|
+
}
|
|
30
|
+
: {};
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<div
|
|
34
|
+
className="edit-site-typography-preview"
|
|
35
|
+
style={ {
|
|
36
|
+
fontFamily: fontFamily ?? 'serif',
|
|
37
|
+
background: gradientValue ?? backgroundColor,
|
|
38
|
+
color,
|
|
39
|
+
fontSize,
|
|
40
|
+
fontStyle,
|
|
41
|
+
fontWeight,
|
|
42
|
+
letterSpacing,
|
|
43
|
+
...extraStyles,
|
|
44
|
+
} }
|
|
45
|
+
>
|
|
46
|
+
Aa
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
@@ -434,9 +434,15 @@ export const getNodesWithStyles = ( tree, blockSelectors ) => {
|
|
|
434
434
|
|
|
435
435
|
const pickStyleKeys = ( treeToPickFrom ) =>
|
|
436
436
|
pickBy( treeToPickFrom, ( value, key ) =>
|
|
437
|
-
[
|
|
438
|
-
|
|
439
|
-
|
|
437
|
+
[
|
|
438
|
+
'border',
|
|
439
|
+
'color',
|
|
440
|
+
'spacing',
|
|
441
|
+
'typography',
|
|
442
|
+
'filter',
|
|
443
|
+
'outline',
|
|
444
|
+
'shadow',
|
|
445
|
+
].includes( key )
|
|
440
446
|
);
|
|
441
447
|
|
|
442
448
|
// Top-level.
|
|
@@ -605,12 +611,12 @@ export const toStyles = (
|
|
|
605
611
|
}
|
|
606
612
|
|
|
607
613
|
if ( useRootPaddingAlign ) {
|
|
608
|
-
ruleset += `padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) }
|
|
609
|
-
.has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
|
|
610
|
-
.has-global-padding :where(.has-global-padding) { padding-right: 0; padding-left: 0; }
|
|
611
|
-
.has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); }
|
|
612
|
-
.has-global-padding :where(.has-global-padding) > .alignfull { margin-right: 0; margin-left: 0; }
|
|
613
|
-
.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); }
|
|
614
|
+
ruleset += `padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) }
|
|
615
|
+
.has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
|
|
616
|
+
.has-global-padding :where(.has-global-padding) { padding-right: 0; padding-left: 0; }
|
|
617
|
+
.has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); }
|
|
618
|
+
.has-global-padding :where(.has-global-padding) > .alignfull { margin-right: 0; margin-left: 0; }
|
|
619
|
+
.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); }
|
|
614
620
|
.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;`;
|
|
615
621
|
}
|
|
616
622
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import {
|
|
5
|
-
|
|
5
|
+
__experimentalUseSlotFills as useSlotFills,
|
|
6
6
|
createSlotFill,
|
|
7
7
|
} from '@wordpress/components';
|
|
8
8
|
|
|
@@ -13,8 +13,8 @@ const { Fill, Slot: MainDashboardButtonSlot } = createSlotFill( slotName );
|
|
|
13
13
|
const MainDashboardButton = Fill;
|
|
14
14
|
|
|
15
15
|
const Slot = ( { children } ) => {
|
|
16
|
-
const
|
|
17
|
-
const hasFills = Boolean(
|
|
16
|
+
const fills = useSlotFills( slotName );
|
|
17
|
+
const hasFills = Boolean( fills && fills.length );
|
|
18
18
|
|
|
19
19
|
if ( ! hasFills ) {
|
|
20
20
|
return children;
|
package/src/index.js
CHANGED
|
@@ -18,6 +18,7 @@ import { store as preferencesStore } from '@wordpress/preferences';
|
|
|
18
18
|
import { __ } from '@wordpress/i18n';
|
|
19
19
|
import { store as viewportStore } from '@wordpress/viewport';
|
|
20
20
|
import { getQueryArgs } from '@wordpress/url';
|
|
21
|
+
import { addFilter } from '@wordpress/hooks';
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* Internal dependencies
|
|
@@ -51,6 +52,26 @@ export function reinitializeEditor( target, settings ) {
|
|
|
51
52
|
return;
|
|
52
53
|
}
|
|
53
54
|
|
|
55
|
+
/*
|
|
56
|
+
* Prevent adding the Clasic block in the site editor.
|
|
57
|
+
* Only add the filter when the site editor is initialized, not imported.
|
|
58
|
+
* Also only add the filter(s) after registerCoreBlocks()
|
|
59
|
+
* so that common filters in the block library are not overwritten.
|
|
60
|
+
*
|
|
61
|
+
* This usage here is inspired by previous usage of the filter in the post editor:
|
|
62
|
+
* https://github.com/WordPress/gutenberg/pull/37157
|
|
63
|
+
*/
|
|
64
|
+
addFilter(
|
|
65
|
+
'blockEditor.__unstableCanInsertBlockType',
|
|
66
|
+
'removeClassicBlockFromInserter',
|
|
67
|
+
( canInsert, blockType ) => {
|
|
68
|
+
if ( blockType.name === 'core/freeform' ) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
return canInsert;
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
|
|
54
75
|
// This will be a no-op if the target doesn't have any React nodes.
|
|
55
76
|
unmountComponentAtNode( target );
|
|
56
77
|
const reboot = reinitializeEditor.bind( null, target, settings );
|