-
-
-
-
-
-
-
-
+
+ { ! isFontFamilyDisabled && (
+ hasFontFamilyValue( props ) }
+ label={ __( 'Font family' ) }
+ onDeselect={ () => resetFontFamily( props ) }
+ isShownByDefault={ defaultControls?.fontFamily }
+ resetAllFilter={ ( newAttributes ) => ( {
+ ...newAttributes,
+ fontFamily: undefined,
+ } ) }
+ panelId={ clientId }
+ >
+
+
+ ) }
+ { ! isFontSizeDisabled && (
+ hasFontSizeValue( props ) }
+ label={ __( 'Font size' ) }
+ onDeselect={ () => resetFontSize( props ) }
+ isShownByDefault={ defaultControls?.fontSize }
+ resetAllFilter={ ( newAttributes ) => ( {
+ ...newAttributes,
+ fontSize: undefined,
+ style: {
+ ...newAttributes.style,
+ typography: {
+ ...newAttributes.style?.typography,
+ fontSize: undefined,
+ },
+ },
+ } ) }
+ panelId={ clientId }
+ >
+
+
+ ) }
+ { ! isFontAppearanceDisabled && (
+ hasFontAppearanceValue( props ) }
+ label={ __( 'Appearance' ) }
+ onDeselect={ () => resetFontAppearance( props ) }
+ isShownByDefault={ defaultControls?.fontAppearance }
+ resetAllFilter={ ( newAttributes ) => ( {
+ ...newAttributes,
+ style: {
+ ...newAttributes.style,
+ typography: {
+ ...newAttributes.style?.typography,
+ fontStyle: undefined,
+ fontWeight: undefined,
+ },
+ },
+ } ) }
+ panelId={ clientId }
+ >
+
+
+ ) }
+ { ! isLineHeightDisabled && (
+ hasLineHeightValue( props ) }
+ label={ __( 'Line height' ) }
+ onDeselect={ () => resetLineHeight( props ) }
+ isShownByDefault={ defaultControls?.lineHeight }
+ resetAllFilter={ createResetAllFilter( 'lineHeight' ) }
+ panelId={ clientId }
+ >
+
+
+ ) }
+ { ! isTextDecorationDisabled && (
+ hasTextDecorationValue( props ) }
+ label={ __( 'Decoration' ) }
+ onDeselect={ () => resetTextDecoration( props ) }
+ isShownByDefault={ defaultControls?.textDecoration }
+ resetAllFilter={ createResetAllFilter( 'textDecoration' ) }
+ panelId={ clientId }
+ >
+
+
+ ) }
+ { ! isTextTransformDisabled && (
+ hasTextTransformValue( props ) }
+ label={ __( 'Letter case' ) }
+ onDeselect={ () => resetTextTransform( props ) }
+ isShownByDefault={ defaultControls?.textTransform }
+ resetAllFilter={ createResetAllFilter( 'textTransform' ) }
+ panelId={ clientId }
+ >
+
+
+ ) }
+ { ! isLetterSpacingDisabled && (
+ hasLetterSpacingValue( props ) }
+ label={ __( 'Letter-spacing' ) }
+ onDeselect={ () => resetLetterSpacing( props ) }
+ isShownByDefault={ defaultControls?.letterSpacing }
+ resetAllFilter={ createResetAllFilter( 'letterSpacing' ) }
+ panelId={ clientId }
+ >
+
+
+ ) }
);
}
diff --git a/packages/block-editor/src/hooks/typography.scss b/packages/block-editor/src/hooks/typography.scss
new file mode 100644
index 00000000000000..293b66d7540537
--- /dev/null
+++ b/packages/block-editor/src/hooks/typography.scss
@@ -0,0 +1,12 @@
+.typography-block-support-panel {
+ .components-font-appearance-control,
+ .components-font-size-picker__controls,
+ .block-editor-text-decoration-control__buttons,
+ .block-editor-text-transform-control__buttons {
+ margin-bottom: 0;
+ }
+
+ .block-editor-line-height-control input {
+ max-width: 100%;
+ }
+}
diff --git a/packages/block-editor/src/style.scss b/packages/block-editor/src/style.scss
index 22a48857359ac7..de72069bcde141 100644
--- a/packages/block-editor/src/style.scss
+++ b/packages/block-editor/src/style.scss
@@ -46,7 +46,6 @@
@import "./components/responsive-block-control/style.scss";
@import "./components/rich-text/style.scss";
@import "./components/skip-to-selected-block/style.scss";
-@import "./components/text-decoration-and-transform/style.scss";
@import "./components/text-transform-control/style.scss";
@import "./components/text-decoration-control/style.scss";
@import "./components/tool-selector/style.scss";
@@ -56,6 +55,7 @@
@import "./hooks/anchor.scss";
@import "./hooks/layout.scss";
@import "./hooks/border.scss";
+@import "./hooks/typography.scss";
@import "./components/block-toolbar/style.scss";
@import "./components/inserter/style.scss";
diff --git a/packages/block-library/src/paragraph/block.json b/packages/block-library/src/paragraph/block.json
index d05e48a7bebe23..d024ee2a8fce15 100644
--- a/packages/block-library/src/paragraph/block.json
+++ b/packages/block-library/src/paragraph/block.json
@@ -37,7 +37,11 @@
},
"typography": {
"fontSize": true,
- "lineHeight": true
+ "lineHeight": true,
+ "__experimentalDefaultControls": {
+ "fontSize": true,
+ "lineHeight": true
+ }
},
"__experimentalSelector": "p",
"__unstablePasteTextInline": true
diff --git a/packages/e2e-tests/specs/editor/various/font-size-picker.test.js b/packages/e2e-tests/specs/editor/various/font-size-picker.test.js
index c2e9bceed1de26..7e405330fb717c 100644
--- a/packages/e2e-tests/specs/editor/various/font-size-picker.test.js
+++ b/packages/e2e-tests/specs/editor/various/font-size-picker.test.js
@@ -17,6 +17,13 @@ const openFontSizeSelectControl = async () => {
return selectControl.click();
};
+const openTypographyToolsPanelMenu = async () => {
+ const toggleSelector =
+ "//div[contains(@class, 'typography-block-support-panel')]//button[contains(@class, 'components-dropdown-menu__toggle')]";
+ const toggle = await page.waitForXPath( toggleSelector );
+ return toggle.click();
+};
+
const FONT_SIZE_TOGGLE_GROUP_SELECTOR =
"//div[contains(@class, 'components-font-size-picker__controls')]//div[contains(@class, 'components-toggle-group-control')]";
@@ -122,11 +129,11 @@ describe( 'Font Size Picker', () => {
"
` );
} );
- it( 'should reset a named font size using the reset button', async () => {
+ it( 'should reset a named font size using the tools panel menu', async () => {
// Create a paragraph block with some content.
await clickBlockAppender();
await page.keyboard.type(
- 'Paragraph with font size reset using button'
+ 'Paragraph with font size reset using tools panel menu'
);
await openFontSizeSelectControl();
@@ -134,19 +141,17 @@ describe( 'Font Size Picker', () => {
await page.keyboard.press( 'Enter' );
expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
"
- Paragraph with font size reset using button
+ Paragraph with font size reset using tools panel menu
"
` );
- await toggleCustomInput( true );
- await page.keyboard.press( 'Tab' );
- await page.keyboard.press( 'Tab' );
- await page.keyboard.press( 'Tab' );
+ // Open Typography ToolsPanel, font size will be first in menu and gain focus.
+ await openTypographyToolsPanelMenu();
await page.keyboard.press( 'Enter' );
expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
"
- Paragraph with font size reset using button
+ Paragraph with font size reset using tools panel menu
"
` );
} );
@@ -205,29 +210,27 @@ describe( 'Font Size Picker', () => {
` );
} );
- it( 'should reset a named font size using the reset button', async () => {
+ it( 'should reset a named font size using the tools panel menu', async () => {
// Create a paragraph block with some content.
await clickBlockAppender();
await page.keyboard.type(
- 'Paragraph with font size reset using button'
+ 'Paragraph with font size reset using tools panel menu'
);
await clickFontSizeButtonByLabel( 'Small' );
expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
"
- Paragraph with font size reset using button
+ Paragraph with font size reset using tools panel menu
"
` );
- await toggleCustomInput( true );
- await page.keyboard.press( 'Tab' );
- await page.keyboard.press( 'Tab' );
- await page.keyboard.press( 'Tab' );
+ // Open Typography ToolsPanel, font size will be first in menu and gain focus.
+ await openTypographyToolsPanelMenu();
await page.keyboard.press( 'Enter' );
expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
"
- Paragraph with font size reset using button
+ Paragraph with font size reset using tools panel menu
"
` );
} );