Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/reference-guides/core-blocks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ Create structured content in rows and columns to display information.

- **Name:** [core/table](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-text/core-block-table/)
- **Category:** [text](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-text/)
- **Supports:** align, anchor, color (background, gradients, text), interactivity (clientNavigation), spacing (margin, padding), typography (fontSize, lineHeight)
- **Supports:** align, anchor, color (background, gradients, text), interactivity (clientNavigation), spacing (margin, padding), typography (fontSize, lineHeight, textAlign)
- **Attributes:** body, caption, foot, hasFixedLayout, head

## Table of Contents
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/table/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ _Defined via the [`supports`](https://developer.wordpress.org/block-editor/refer
- [`typography`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography):
- [`fontSize`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography-fontsize): `true`
- [`lineHeight`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography-lineheight): `true`
- [`textAlign`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography-textalign): `true`
- [`interactivity`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#interactivity):
- `clientNavigation`: `true`

Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/table/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@
}
},
"typography": {
"__experimentalSkipSerialization": [ "textAlign" ],
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
Expand All @@ -184,6 +185,7 @@
"__experimentalLetterSpacing": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"textAlign": true,
"__experimentalDefaultControls": {
"fontSize": true
}
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/table/edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ function TableEdit( {

const colorProps = useColorProps( attributes );
const borderProps = useBorderProps( attributes );
const textAlign = attributes?.style?.typography?.textAlign;
const blockEditingMode = useBlockEditingMode();

const tableRef = useRef();
Expand Down Expand Up @@ -528,6 +529,7 @@ function TableEdit( {
borderProps.className,
{
'has-fixed-layout': hasFixedLayout,
[ `has-text-align-${ textAlign }` ]: textAlign,
// This is required in the editor only to overcome
// the fact the editor rewrites individual border
// widths into a shorthand format.
Expand Down
5 changes: 4 additions & 1 deletion packages/block-library/src/table/save.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '@wordpress/block-editor';

export default function save( { attributes } ) {
const { hasFixedLayout, head, body, foot, caption } = attributes;
const { hasFixedLayout, head, body, foot, caption, style } = attributes;
const isEmpty = ! head.length && ! body.length && ! foot.length;

if ( isEmpty ) {
Expand All @@ -18,8 +18,11 @@ export default function save( { attributes } ) {
const colorProps = getColorClassesAndStyles( attributes );
const borderProps = getBorderClassesAndStyles( attributes );

const textAlign = style?.typography?.textAlign;

const classes = clsx( colorProps.className, borderProps.className, {
'has-fixed-layout': hasFixedLayout,
[ `has-text-align-${ textAlign }` ]: textAlign,
} );

const hasCaption = ! RichText.isEmpty( caption );
Expand Down
Loading