@wordpress/edit-site 4.12.0 → 4.13.1-next.957ca95e4c.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/add-new-template/new-template.js +8 -3
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/add-new-template/utils.js +90 -52
- package/build/components/add-new-template/utils.js.map +1 -1
- package/build/components/block-editor/resizable-editor.js +26 -12
- package/build/components/block-editor/resizable-editor.js.map +1 -1
- package/build/components/global-styles/border-panel.js +3 -3
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +110 -7
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +4 -4
- package/build/components/global-styles/hooks.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/typography-panel.js +28 -21
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +42 -10
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +39 -5
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/header/document-actions/index.js +1 -0
- package/build/components/header/document-actions/index.js.map +1 -1
- package/build/components/header/index.js +5 -2
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/mode-switcher/index.js +0 -4
- package/build/components/header/mode-switcher/index.js.map +1 -1
- package/build/components/header/more-menu/index.js +13 -3
- package/build/components/header/more-menu/index.js.map +1 -1
- package/build/components/sidebar/default-sidebar.js +11 -1
- package/build/components/sidebar/default-sidebar.js.map +1 -1
- package/build/components/sidebar/plugin-sidebar/index.js +11 -1
- package/build/components/sidebar/plugin-sidebar/index.js.map +1 -1
- package/build/components/template-details/edit-template-title.js +1 -1
- package/build/components/template-details/edit-template-title.js.map +1 -1
- package/build/components/template-details/index.js +18 -8
- package/build/components/template-details/index.js.map +1 -1
- package/build/components/template-details/template-part-area-selector.js +47 -0
- package/build/components/template-details/template-part-area-selector.js.map +1 -0
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +10 -5
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/add-new-template/utils.js +87 -52
- package/build-module/components/add-new-template/utils.js.map +1 -1
- package/build-module/components/block-editor/resizable-editor.js +26 -12
- package/build-module/components/block-editor/resizable-editor.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +3 -3
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +108 -8
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +5 -5
- package/build-module/components/global-styles/hooks.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/typography-panel.js +29 -22
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +42 -10
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +39 -5
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/header/document-actions/index.js +1 -0
- package/build-module/components/header/document-actions/index.js.map +1 -1
- package/build-module/components/header/index.js +5 -2
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/mode-switcher/index.js +0 -4
- package/build-module/components/header/mode-switcher/index.js.map +1 -1
- package/build-module/components/header/more-menu/index.js +13 -3
- package/build-module/components/header/more-menu/index.js.map +1 -1
- package/build-module/components/sidebar/default-sidebar.js +9 -1
- package/build-module/components/sidebar/default-sidebar.js.map +1 -1
- package/build-module/components/sidebar/plugin-sidebar/index.js +9 -1
- package/build-module/components/sidebar/plugin-sidebar/index.js.map +1 -1
- package/build-module/components/template-details/edit-template-title.js +1 -1
- package/build-module/components/template-details/edit-template-title.js.map +1 -1
- package/build-module/components/template-details/index.js +18 -9
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-module/components/template-details/template-part-area-selector.js +35 -0
- package/build-module/components/template-details/template-part-area-selector.js.map +1 -0
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-style/style-rtl.css +4 -6
- package/build-style/style.css +4 -6
- package/package.json +29 -29
- package/src/components/add-new-template/new-template.js +15 -4
- package/src/components/add-new-template/utils.js +82 -20
- package/src/components/block-editor/resizable-editor.js +28 -18
- package/src/components/editor/style.scss +1 -0
- package/src/components/global-styles/border-panel.js +3 -3
- package/src/components/global-styles/dimensions-panel.js +155 -30
- package/src/components/global-styles/hooks.js +6 -8
- package/src/components/global-styles/preview.js +2 -2
- package/src/components/global-styles/style.scss +3 -2
- package/src/components/global-styles/test/use-global-styles-output.js +16 -3
- package/src/components/global-styles/test/utils.js +68 -8
- package/src/components/global-styles/typography-panel.js +96 -94
- package/src/components/global-styles/use-global-styles-output.js +41 -14
- package/src/components/global-styles/utils.js +29 -4
- package/src/components/header/document-actions/index.js +3 -0
- package/src/components/header/index.js +4 -1
- package/src/components/header/mode-switcher/index.js +0 -3
- package/src/components/header/more-menu/index.js +7 -2
- package/src/components/sidebar/default-sidebar.js +12 -0
- package/src/components/sidebar/plugin-sidebar/index.js +12 -0
- package/src/components/template-details/edit-template-title.js +7 -3
- package/src/components/template-details/index.js +20 -7
- package/src/components/template-details/style.scss +0 -5
- package/src/components/template-details/template-part-area-selector.js +38 -0
- package/src/index.js +1 -1
|
@@ -10,9 +10,9 @@ import {
|
|
|
10
10
|
import {
|
|
11
11
|
PanelBody,
|
|
12
12
|
FontSizePicker,
|
|
13
|
-
__experimentalSpacer as Spacer,
|
|
14
13
|
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
15
14
|
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
15
|
+
__experimentalGrid as Grid,
|
|
16
16
|
} from '@wordpress/components';
|
|
17
17
|
import { __ } from '@wordpress/i18n';
|
|
18
18
|
import { useState } from '@wordpress/element';
|
|
@@ -144,109 +144,111 @@ export default function TypographyPanel( { name, element } ) {
|
|
|
144
144
|
>
|
|
145
145
|
Aa
|
|
146
146
|
</div>
|
|
147
|
-
{
|
|
148
|
-
|
|
149
|
-
<
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
147
|
+
<Grid columns={ 2 } rowGap={ 16 } columnGap={ 8 }>
|
|
148
|
+
{ element === 'heading' && (
|
|
149
|
+
<div className="edit-site-typography-panel__full-width-control">
|
|
150
|
+
<ToggleGroupControl
|
|
151
|
+
label={ __( 'Select heading level' ) }
|
|
152
|
+
hideLabelFromVision
|
|
153
|
+
value={ selectedLevel }
|
|
154
|
+
onChange={ setCurrentTab }
|
|
155
|
+
isBlock
|
|
156
|
+
size="__unstable-large"
|
|
157
|
+
__nextHasNoMarginBottom
|
|
158
|
+
>
|
|
159
|
+
<ToggleGroupControlOption
|
|
160
|
+
value="heading"
|
|
161
|
+
/* translators: 'All' refers to selecting all heading levels
|
|
161
162
|
and applying the same style to h1-h6. */
|
|
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
|
-
|
|
163
|
+
label={ __( 'All' ) }
|
|
164
|
+
/>
|
|
165
|
+
<ToggleGroupControlOption
|
|
166
|
+
value="h1"
|
|
167
|
+
label={ __( 'H1' ) }
|
|
168
|
+
/>
|
|
169
|
+
<ToggleGroupControlOption
|
|
170
|
+
value="h2"
|
|
171
|
+
label={ __( 'H2' ) }
|
|
172
|
+
/>
|
|
173
|
+
<ToggleGroupControlOption
|
|
174
|
+
value="h3"
|
|
175
|
+
label={ __( 'H3' ) }
|
|
176
|
+
/>
|
|
177
|
+
<ToggleGroupControlOption
|
|
178
|
+
value="h4"
|
|
179
|
+
label={ __( 'H4' ) }
|
|
180
|
+
/>
|
|
181
|
+
<ToggleGroupControlOption
|
|
182
|
+
value="h5"
|
|
183
|
+
label={ __( 'H5' ) }
|
|
184
|
+
/>
|
|
185
|
+
<ToggleGroupControlOption
|
|
186
|
+
value="h6"
|
|
187
|
+
label={ __( 'H6' ) }
|
|
188
|
+
/>
|
|
189
|
+
</ToggleGroupControl>
|
|
190
|
+
</div>
|
|
191
|
+
) }
|
|
192
|
+
{ supports.includes( 'fontFamily' ) && (
|
|
193
|
+
<div className="edit-site-typography-panel__full-width-control">
|
|
194
|
+
<FontFamilyControl
|
|
195
|
+
fontFamilies={ fontFamilies }
|
|
196
|
+
value={ fontFamily }
|
|
197
|
+
onChange={ setFontFamily }
|
|
198
|
+
size="__unstable-large"
|
|
199
|
+
__nextHasNoMarginBottom
|
|
187
200
|
/>
|
|
188
|
-
</
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
/>
|
|
198
|
-
) }
|
|
199
|
-
{ hasFontSizeEnabled && (
|
|
200
|
-
<FontSizePicker
|
|
201
|
-
value={ fontSize }
|
|
202
|
-
onChange={ setFontSize }
|
|
203
|
-
fontSizes={ fontSizes }
|
|
204
|
-
disableCustomFontSizes={ disableCustomFontSizes }
|
|
205
|
-
size="__unstable-large"
|
|
206
|
-
/>
|
|
207
|
-
) }
|
|
208
|
-
{ hasLineHeightEnabled && (
|
|
209
|
-
<div className="edit-site-typography-panel__half-width-control">
|
|
210
|
-
<Spacer marginBottom={ 6 }>
|
|
211
|
-
<LineHeightControl
|
|
212
|
-
__nextHasNoMarginBottom={ true }
|
|
213
|
-
__unstableInputWidth="auto"
|
|
214
|
-
value={ lineHeight }
|
|
215
|
-
onChange={ setLineHeight }
|
|
201
|
+
</div>
|
|
202
|
+
) }
|
|
203
|
+
{ hasFontSizeEnabled && (
|
|
204
|
+
<div className="edit-site-typography-panel__full-width-control">
|
|
205
|
+
<FontSizePicker
|
|
206
|
+
value={ fontSize }
|
|
207
|
+
onChange={ setFontSize }
|
|
208
|
+
fontSizes={ fontSizes }
|
|
209
|
+
disableCustomFontSizes={ disableCustomFontSizes }
|
|
216
210
|
size="__unstable-large"
|
|
211
|
+
__nextHasNoMarginBottom
|
|
217
212
|
/>
|
|
218
|
-
</
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
213
|
+
</div>
|
|
214
|
+
) }
|
|
215
|
+
{ hasAppearanceControl && (
|
|
216
|
+
<FontAppearanceControl
|
|
217
|
+
value={ {
|
|
218
|
+
fontStyle,
|
|
219
|
+
fontWeight,
|
|
220
|
+
} }
|
|
221
|
+
onChange={ ( {
|
|
222
|
+
fontStyle: newFontStyle,
|
|
223
|
+
fontWeight: newFontWeight,
|
|
224
|
+
} ) => {
|
|
225
|
+
setFontStyle( newFontStyle );
|
|
226
|
+
setFontWeight( newFontWeight );
|
|
227
|
+
} }
|
|
228
|
+
hasFontStyles={ hasFontStyles }
|
|
229
|
+
hasFontWeights={ hasFontWeights }
|
|
230
|
+
size="__unstable-large"
|
|
231
|
+
__nextHasNoMarginBottom
|
|
232
|
+
/>
|
|
233
|
+
) }
|
|
234
|
+
{ hasLineHeightEnabled && (
|
|
235
|
+
<LineHeightControl
|
|
236
|
+
__nextHasNoMarginBottom
|
|
237
|
+
__unstableInputWidth="auto"
|
|
238
|
+
value={ lineHeight }
|
|
239
|
+
onChange={ setLineHeight }
|
|
240
|
+
size="__unstable-large"
|
|
241
|
+
/>
|
|
242
|
+
) }
|
|
243
|
+
{ hasLetterSpacingControl && (
|
|
242
244
|
<LetterSpacingControl
|
|
243
245
|
value={ letterSpacing }
|
|
244
246
|
onChange={ setLetterSpacing }
|
|
245
247
|
size="__unstable-large"
|
|
246
248
|
__unstableInputWidth="auto"
|
|
247
249
|
/>
|
|
248
|
-
|
|
249
|
-
|
|
250
|
+
) }
|
|
251
|
+
</Grid>
|
|
250
252
|
</PanelBody>
|
|
251
253
|
);
|
|
252
254
|
}
|
|
@@ -49,7 +49,8 @@ function compileStyleValue( uncompiledValue ) {
|
|
|
49
49
|
const VARIABLE_REFERENCE_PREFIX = 'var:';
|
|
50
50
|
const VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';
|
|
51
51
|
const VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';
|
|
52
|
-
|
|
52
|
+
|
|
53
|
+
if ( uncompiledValue?.startsWith?.( VARIABLE_REFERENCE_PREFIX ) ) {
|
|
53
54
|
const variable = uncompiledValue
|
|
54
55
|
.slice( VARIABLE_REFERENCE_PREFIX.length )
|
|
55
56
|
.split( VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE )
|
|
@@ -189,12 +190,15 @@ function flattenTree( input = {}, prefix, token ) {
|
|
|
189
190
|
*
|
|
190
191
|
* @param {boolean} useRootPaddingAlign Whether to use CSS custom properties in root selector.
|
|
191
192
|
*
|
|
193
|
+
* @param {Object} tree A theme.json tree containing layout definitions.
|
|
194
|
+
*
|
|
192
195
|
* @return {Array} An array of style declarations.
|
|
193
196
|
*/
|
|
194
197
|
export function getStylesDeclarations(
|
|
195
198
|
blockStyles = {},
|
|
196
199
|
selector = '',
|
|
197
|
-
useRootPaddingAlign
|
|
200
|
+
useRootPaddingAlign,
|
|
201
|
+
tree = {}
|
|
198
202
|
) {
|
|
199
203
|
const isRoot = ROOT_BLOCK_SELECTOR === selector;
|
|
200
204
|
const output = reduce(
|
|
@@ -269,7 +273,19 @@ export function getStylesDeclarations(
|
|
|
269
273
|
const cssProperty = rule.key.startsWith( '--' )
|
|
270
274
|
? rule.key
|
|
271
275
|
: kebabCase( rule.key );
|
|
272
|
-
|
|
276
|
+
|
|
277
|
+
let ruleValue = rule.value;
|
|
278
|
+
if ( typeof ruleValue !== 'string' && ruleValue?.ref ) {
|
|
279
|
+
const refPath = ruleValue.ref.split( '.' );
|
|
280
|
+
ruleValue = get( tree, refPath );
|
|
281
|
+
// Presence of another ref indicates a reference to another dynamic value.
|
|
282
|
+
// Pointing to another dynamic value is not supported.
|
|
283
|
+
if ( ! ruleValue || !! ruleValue?.ref ) {
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
output.push( `${ cssProperty }: ${ ruleValue }` );
|
|
273
289
|
} );
|
|
274
290
|
|
|
275
291
|
return output;
|
|
@@ -564,6 +580,7 @@ export const toStyles = (
|
|
|
564
580
|
const nodesWithStyles = getNodesWithStyles( tree, blockSelectors );
|
|
565
581
|
const nodesWithSettings = getNodesWithSettings( tree, blockSelectors );
|
|
566
582
|
const useRootPaddingAlign = tree?.settings?.useRootPaddingAwareAlignments;
|
|
583
|
+
const { contentSize, wideSize } = tree?.settings?.layout || {};
|
|
567
584
|
|
|
568
585
|
/*
|
|
569
586
|
* Reset default browser margin on the root body element.
|
|
@@ -573,13 +590,23 @@ export const toStyles = (
|
|
|
573
590
|
* user-generated values take precedence in the CSS cascade.
|
|
574
591
|
* @link https://github.com/WordPress/gutenberg/issues/36147.
|
|
575
592
|
*/
|
|
576
|
-
let ruleset = 'body {margin: 0;
|
|
593
|
+
let ruleset = 'body {margin: 0;';
|
|
594
|
+
|
|
595
|
+
if ( contentSize ) {
|
|
596
|
+
ruleset += ` --wp--style--global--content-size: ${ contentSize };`;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
if ( wideSize ) {
|
|
600
|
+
ruleset += ` --wp--style--global--wide-size: ${ wideSize };`;
|
|
601
|
+
}
|
|
577
602
|
|
|
578
603
|
if ( useRootPaddingAlign ) {
|
|
579
|
-
ruleset
|
|
580
|
-
'
|
|
604
|
+
ruleset +=
|
|
605
|
+
'padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) } .has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); } .has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); } .has-global-padding > .alignfull > :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);';
|
|
581
606
|
}
|
|
582
607
|
|
|
608
|
+
ruleset += '}';
|
|
609
|
+
|
|
583
610
|
nodesWithStyles.forEach(
|
|
584
611
|
( {
|
|
585
612
|
selector,
|
|
@@ -624,14 +651,13 @@ export const toStyles = (
|
|
|
624
651
|
if ( duotoneSelector ) {
|
|
625
652
|
const duotoneDeclarations =
|
|
626
653
|
getStylesDeclarations( duotoneStyles );
|
|
627
|
-
if ( duotoneDeclarations.length
|
|
628
|
-
|
|
654
|
+
if ( duotoneDeclarations.length > 0 ) {
|
|
655
|
+
ruleset =
|
|
656
|
+
ruleset +
|
|
657
|
+
`${ duotoneSelector }{${ duotoneDeclarations.join(
|
|
658
|
+
';'
|
|
659
|
+
) };}`;
|
|
629
660
|
}
|
|
630
|
-
ruleset =
|
|
631
|
-
ruleset +
|
|
632
|
-
`${ duotoneSelector }{${ duotoneDeclarations.join(
|
|
633
|
-
';'
|
|
634
|
-
) };}`;
|
|
635
661
|
}
|
|
636
662
|
|
|
637
663
|
// Process blockGap and layout styles.
|
|
@@ -653,7 +679,8 @@ export const toStyles = (
|
|
|
653
679
|
const declarations = getStylesDeclarations(
|
|
654
680
|
styles,
|
|
655
681
|
selector,
|
|
656
|
-
useRootPaddingAlign
|
|
682
|
+
useRootPaddingAlign,
|
|
683
|
+
tree
|
|
657
684
|
);
|
|
658
685
|
if ( declarations?.length ) {
|
|
659
686
|
ruleset =
|
|
@@ -77,6 +77,13 @@ export const PRESET_METADATA = [
|
|
|
77
77
|
{ classSuffix: 'font-family', propertyName: 'font-family' },
|
|
78
78
|
],
|
|
79
79
|
},
|
|
80
|
+
{
|
|
81
|
+
path: [ 'spacing', 'spacingSizes' ],
|
|
82
|
+
valueKey: 'size',
|
|
83
|
+
cssVarInfix: 'spacing',
|
|
84
|
+
valueFunc: ( { size } ) => size,
|
|
85
|
+
classes: [],
|
|
86
|
+
},
|
|
80
87
|
];
|
|
81
88
|
|
|
82
89
|
const STYLE_PATH_TO_CSS_VAR_INFIX = {
|
|
@@ -195,7 +202,7 @@ function getValueFromPresetVariable(
|
|
|
195
202
|
}
|
|
196
203
|
|
|
197
204
|
const presetObject = findInPresetsBy(
|
|
198
|
-
features,
|
|
205
|
+
features.settings,
|
|
199
206
|
blockName,
|
|
200
207
|
metadata.path,
|
|
201
208
|
'slug',
|
|
@@ -213,8 +220,8 @@ function getValueFromPresetVariable(
|
|
|
213
220
|
|
|
214
221
|
function getValueFromCustomVariable( features, blockName, variable, path ) {
|
|
215
222
|
const result =
|
|
216
|
-
get( features, [ 'blocks', blockName, 'custom', ...path ] ) ??
|
|
217
|
-
get( features, [ 'custom', ...path ] );
|
|
223
|
+
get( features.settings, [ 'blocks', blockName, 'custom', ...path ] ) ??
|
|
224
|
+
get( features.settings, [ 'custom', ...path ] );
|
|
218
225
|
if ( ! result ) {
|
|
219
226
|
return variable;
|
|
220
227
|
}
|
|
@@ -222,9 +229,27 @@ function getValueFromCustomVariable( features, blockName, variable, path ) {
|
|
|
222
229
|
return getValueFromVariable( features, blockName, result );
|
|
223
230
|
}
|
|
224
231
|
|
|
232
|
+
/**
|
|
233
|
+
* Attempts to fetch the value of a theme.json CSS variable.
|
|
234
|
+
*
|
|
235
|
+
* @param {Object} features GlobalStylesContext config, e.g., user, base or merged. Represents the theme.json tree.
|
|
236
|
+
* @param {string} blockName The name of a block as represented in the styles property. E.g., 'root' for root-level, and 'core/${blockName}' for blocks.
|
|
237
|
+
* @param {string|*} variable An incoming style value. A CSS var value is expected, but it could be any value.
|
|
238
|
+
* @return {string|*|{ref}} The value of the CSS var, if found. If not found, the passed variable argument.
|
|
239
|
+
*/
|
|
225
240
|
export function getValueFromVariable( features, blockName, variable ) {
|
|
226
241
|
if ( ! variable || typeof variable !== 'string' ) {
|
|
227
|
-
|
|
242
|
+
if ( variable?.ref && typeof variable?.ref === 'string' ) {
|
|
243
|
+
const refPath = variable.ref.split( '.' );
|
|
244
|
+
variable = get( features, refPath );
|
|
245
|
+
// Presence of another ref indicates a reference to another dynamic value.
|
|
246
|
+
// Pointing to another dynamic value is not supported.
|
|
247
|
+
if ( ! variable || !! variable?.ref ) {
|
|
248
|
+
return variable;
|
|
249
|
+
}
|
|
250
|
+
} else {
|
|
251
|
+
return variable;
|
|
252
|
+
}
|
|
228
253
|
}
|
|
229
254
|
const USER_VALUE_PREFIX = 'var:';
|
|
230
255
|
const THEME_VALUE_PREFIX = 'var(--wp--';
|
|
@@ -141,6 +141,9 @@ export default function DocumentActions( {
|
|
|
141
141
|
aria-expanded={ isOpen }
|
|
142
142
|
aria-haspopup="true"
|
|
143
143
|
onClick={ onToggle }
|
|
144
|
+
variant={
|
|
145
|
+
showIconLabels ? 'tertiary' : undefined
|
|
146
|
+
}
|
|
144
147
|
label={ sprintf(
|
|
145
148
|
/* translators: %s: the entity to see details about, like "template"*/
|
|
146
149
|
__( 'Show %s details' ),
|
|
@@ -177,6 +177,9 @@ export default function Header( {
|
|
|
177
177
|
onClick={ toggleListView }
|
|
178
178
|
shortcut={ listViewShortcut }
|
|
179
179
|
showTooltip={ ! showIconLabels }
|
|
180
|
+
variant={
|
|
181
|
+
showIconLabels ? 'tertiary' : undefined
|
|
182
|
+
}
|
|
180
183
|
/>
|
|
181
184
|
</>
|
|
182
185
|
) }
|
|
@@ -232,7 +235,7 @@ export default function Header( {
|
|
|
232
235
|
isEntitiesSavedStatesOpen={ isEntitiesSavedStatesOpen }
|
|
233
236
|
/>
|
|
234
237
|
<PinnedItems.Slot scope="core/edit-site" />
|
|
235
|
-
<MoreMenu />
|
|
238
|
+
<MoreMenu showIconLabels={ showIconLabels } />
|
|
236
239
|
</div>
|
|
237
240
|
</div>
|
|
238
241
|
</div>
|
|
@@ -6,9 +6,6 @@ import { MenuItemsChoice, MenuGroup } from '@wordpress/components';
|
|
|
6
6
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
7
7
|
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* Internal dependencies
|
|
11
|
-
*/
|
|
12
9
|
/**
|
|
13
10
|
* Internal dependencies
|
|
14
11
|
*/
|
|
@@ -21,7 +21,7 @@ import WelcomeGuideMenuItem from './welcome-guide-menu-item';
|
|
|
21
21
|
import CopyContentMenuItem from './copy-content-menu-item';
|
|
22
22
|
import ModeSwitcher from '../mode-switcher';
|
|
23
23
|
|
|
24
|
-
export default function MoreMenu() {
|
|
24
|
+
export default function MoreMenu( { showIconLabels } ) {
|
|
25
25
|
const [ isModalActive, toggleModal ] = useReducer(
|
|
26
26
|
( isActive ) => ! isActive,
|
|
27
27
|
false
|
|
@@ -36,7 +36,12 @@ export default function MoreMenu() {
|
|
|
36
36
|
|
|
37
37
|
return (
|
|
38
38
|
<>
|
|
39
|
-
<MoreMenuDropdown
|
|
39
|
+
<MoreMenuDropdown
|
|
40
|
+
toggleProps={ {
|
|
41
|
+
showTooltip: ! showIconLabels,
|
|
42
|
+
...( showIconLabels && { variant: 'tertiary' } ),
|
|
43
|
+
} }
|
|
44
|
+
>
|
|
40
45
|
{ ( { onClose } ) => (
|
|
41
46
|
<>
|
|
42
47
|
<MenuGroup label={ _x( 'View', 'noun' ) }>
|
|
@@ -5,6 +5,12 @@ import {
|
|
|
5
5
|
ComplementaryArea,
|
|
6
6
|
ComplementaryAreaMoreMenuItem,
|
|
7
7
|
} from '@wordpress/interface';
|
|
8
|
+
import { useSelect } from '@wordpress/data';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
import { store as editSiteStore } from '../../store';
|
|
8
14
|
|
|
9
15
|
export default function DefaultSidebar( {
|
|
10
16
|
className,
|
|
@@ -17,6 +23,11 @@ export default function DefaultSidebar( {
|
|
|
17
23
|
headerClassName,
|
|
18
24
|
panelClassName,
|
|
19
25
|
} ) {
|
|
26
|
+
const showIconLabels = useSelect(
|
|
27
|
+
( select ) => select( editSiteStore ).getSettings().showIconLabels,
|
|
28
|
+
[]
|
|
29
|
+
);
|
|
30
|
+
|
|
20
31
|
return (
|
|
21
32
|
<>
|
|
22
33
|
<ComplementaryArea
|
|
@@ -29,6 +40,7 @@ export default function DefaultSidebar( {
|
|
|
29
40
|
header={ header }
|
|
30
41
|
headerClassName={ headerClassName }
|
|
31
42
|
panelClassName={ panelClassName }
|
|
43
|
+
showIconLabels={ showIconLabels }
|
|
32
44
|
>
|
|
33
45
|
{ children }
|
|
34
46
|
</ComplementaryArea>
|
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { ComplementaryArea } from '@wordpress/interface';
|
|
5
|
+
import { useSelect } from '@wordpress/data';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { store as editSiteStore } from '../../../store';
|
|
5
11
|
|
|
6
12
|
/**
|
|
7
13
|
* Renders a sidebar when activated. The contents within the `PluginSidebar` will appear as content within the sidebar.
|
|
@@ -69,11 +75,17 @@ import { ComplementaryArea } from '@wordpress/interface';
|
|
|
69
75
|
* ```
|
|
70
76
|
*/
|
|
71
77
|
export default function PluginSidebarEditSite( { className, ...props } ) {
|
|
78
|
+
const showIconLabels = useSelect(
|
|
79
|
+
( select ) => select( editSiteStore ).getSettings().showIconLabels,
|
|
80
|
+
[]
|
|
81
|
+
);
|
|
82
|
+
|
|
72
83
|
return (
|
|
73
84
|
<ComplementaryArea
|
|
74
85
|
panelClassName={ className }
|
|
75
86
|
className="edit-site-sidebar"
|
|
76
87
|
scope="core/edit-site"
|
|
88
|
+
showIconLabels={ showIconLabels }
|
|
77
89
|
{ ...props }
|
|
78
90
|
/>
|
|
79
91
|
);
|
|
@@ -19,9 +19,13 @@ export default function EditTemplateTitle( { template } ) {
|
|
|
19
19
|
<TextControl
|
|
20
20
|
label={ __( 'Title' ) }
|
|
21
21
|
value={ forceEmpty ? '' : title }
|
|
22
|
-
help={
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
help={
|
|
23
|
+
template.type !== 'wp_template_part'
|
|
24
|
+
? __(
|
|
25
|
+
'Give the template a title that indicates its purpose, e.g. "Full Width".'
|
|
26
|
+
)
|
|
27
|
+
: null
|
|
28
|
+
}
|
|
25
29
|
onChange={ ( newTitle ) => {
|
|
26
30
|
if ( ! newTitle && ! forceEmpty ) {
|
|
27
31
|
setForceEmpty( true );
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
Button,
|
|
7
7
|
MenuGroup,
|
|
8
8
|
MenuItem,
|
|
9
|
-
|
|
9
|
+
__experimentalVStack as VStack,
|
|
10
10
|
__experimentalText as Text,
|
|
11
11
|
} from '@wordpress/components';
|
|
12
12
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
@@ -20,6 +20,7 @@ import { store as editSiteStore } from '../../store';
|
|
|
20
20
|
import TemplateAreas from './template-areas';
|
|
21
21
|
import EditTemplateTitle from './edit-template-title';
|
|
22
22
|
import { useLink } from '../routes/link';
|
|
23
|
+
import TemplatePartAreaSelector from './template-part-area-selector';
|
|
23
24
|
|
|
24
25
|
export default function TemplateDetails( { template, onClose } ) {
|
|
25
26
|
const { title, description } = useSelect(
|
|
@@ -35,8 +36,13 @@ export default function TemplateDetails( { template, onClose } ) {
|
|
|
35
36
|
postId: undefined,
|
|
36
37
|
} );
|
|
37
38
|
|
|
39
|
+
const isTemplatePart = template.type === 'wp_template_part';
|
|
40
|
+
|
|
38
41
|
// Only user-created and non-default templates can change the name.
|
|
39
|
-
|
|
42
|
+
// But any user-created template part can be renamed.
|
|
43
|
+
const canEditTitle = isTemplatePart
|
|
44
|
+
? ! template.has_theme_file
|
|
45
|
+
: template.is_custom && ! template.has_theme_file;
|
|
40
46
|
|
|
41
47
|
if ( ! template ) {
|
|
42
48
|
return null;
|
|
@@ -49,17 +55,18 @@ export default function TemplateDetails( { template, onClose } ) {
|
|
|
49
55
|
|
|
50
56
|
return (
|
|
51
57
|
<div className="edit-site-template-details">
|
|
52
|
-
<
|
|
58
|
+
<VStack className="edit-site-template-details__group" spacing={ 3 }>
|
|
53
59
|
{ canEditTitle ? (
|
|
54
60
|
<EditTemplateTitle template={ template } />
|
|
55
61
|
) : (
|
|
56
|
-
<
|
|
57
|
-
|
|
62
|
+
<Text
|
|
63
|
+
size={ 16 }
|
|
58
64
|
weight={ 600 }
|
|
59
65
|
className="edit-site-template-details__title"
|
|
66
|
+
as="p"
|
|
60
67
|
>
|
|
61
68
|
{ title }
|
|
62
|
-
</
|
|
69
|
+
</Text>
|
|
63
70
|
) }
|
|
64
71
|
|
|
65
72
|
{ description && (
|
|
@@ -71,7 +78,13 @@ export default function TemplateDetails( { template, onClose } ) {
|
|
|
71
78
|
{ description }
|
|
72
79
|
</Text>
|
|
73
80
|
) }
|
|
74
|
-
</
|
|
81
|
+
</VStack>
|
|
82
|
+
|
|
83
|
+
{ isTemplatePart && (
|
|
84
|
+
<div className="edit-site-template-details__group">
|
|
85
|
+
<TemplatePartAreaSelector id={ template.id } />
|
|
86
|
+
</div>
|
|
87
|
+
) }
|
|
75
88
|
|
|
76
89
|
<TemplateAreas closeTemplateDetailsDropdown={ onClose } />
|
|
77
90
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { SelectControl } from '@wordpress/components';
|
|
6
|
+
import { useEntityProp } from '@wordpress/core-data';
|
|
7
|
+
import { useSelect } from '@wordpress/data';
|
|
8
|
+
import { store as editorStore } from '@wordpress/editor';
|
|
9
|
+
|
|
10
|
+
export default function TemplatePartAreaSelector( { id } ) {
|
|
11
|
+
const [ area, setArea ] = useEntityProp(
|
|
12
|
+
'postType',
|
|
13
|
+
'wp_template_part',
|
|
14
|
+
'area',
|
|
15
|
+
id
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
const definedAreas = useSelect(
|
|
19
|
+
( select ) =>
|
|
20
|
+
select( editorStore ).__experimentalGetDefaultTemplatePartAreas(),
|
|
21
|
+
[]
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const areaOptions = definedAreas.map( ( { label, area: _area } ) => ( {
|
|
25
|
+
label,
|
|
26
|
+
value: _area,
|
|
27
|
+
} ) );
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<SelectControl
|
|
31
|
+
label={ __( 'Area' ) }
|
|
32
|
+
labelPosition="top"
|
|
33
|
+
options={ areaOptions }
|
|
34
|
+
value={ area }
|
|
35
|
+
onChange={ setArea }
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
}
|
package/src/index.js
CHANGED
|
@@ -65,7 +65,7 @@ export function reinitializeEditor( target, settings ) {
|
|
|
65
65
|
keepCaretInsideBlock: false,
|
|
66
66
|
welcomeGuide: true,
|
|
67
67
|
welcomeGuideStyles: true,
|
|
68
|
-
|
|
68
|
+
showListViewByDefault: false,
|
|
69
69
|
} );
|
|
70
70
|
|
|
71
71
|
// Check if the block list view should be open by default.
|