-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Description
Description
I tried to add a new block style to my core/heading block. The new style is called title.
The idea is to replicate the h1 element style into the title custom block style.
After discussion in #59163, I tried to use the ref value and block style variations in the theme.json to bind the h1 values into my new title block style.
This works well on the front website and block editor.
But when I use the Global Styles panel (Site Editor) to change the H1 style (Global Styles > Typography > Headings > H1 tab), there is an issue when using the fontSize presets control.
The real time CSS generated is still in raw value var:preset|font-size|large instead of var(--wp--preset--font-size--large).
But after we clicked the Save button (top right side), the generated CSS is flushed again and shows the correct value.
Step-by-step reproduction instructions
- Add the Snippet 1 (below) to the
theme.jsonfile. This will add block style variation fortitleblock style oncore/headingblock. - Go to Site Editor and add a
core/headingblock into the template content. - Choose the
Titleblock style. The heading block should replicate the H1 style even though the heading block level is not set toh1. - Go to the Global Styles panel and browse to
Typography > Headings > H1 tab. - Change the font size value using the
S M L XL XXLpresets. - The font size is not applied to the heading block with
Titlestyle, because Site Editor JS generate invalid CSS value (see screenshot above).
Screenshots, screen recording, code snippet
Snippet 1 (theme.json):
{
...
"styles": {
"blocks": {
"core/heading": {
"variations": {
"title": {
"typography": {
"fontFamily": { "ref": "styles.elements.h1.typography.fontFamily" },
"fontSize": { "ref": "styles.elements.h1.typography.fontSize" },
"fontStyle": { "ref": "styles.elements.h1.typography.fontStyle" },
"fontWeight": { "ref": "styles.elements.h1.typography.fontWeight" },
"letterSpacing": { "ref": "styles.elements.h1.typography.letterSpacing" },
"lineHeight": { "ref": "styles.elements.h1.typography.lineHeight" },
"textDecoration": { "ref": "styles.elements.h1.typography.textDecoration" },
"textTransform": { "ref": "styles.elements.h1.typography.textTransform" }
}
}
}
}
}
}
}
Environment info
- WordPress 6.4.3
- Gutenberg 17.8.2
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes