| 1 |
import { |
| 2 |
useBlockProps, |
| 3 |
useInnerBlocksProps, |
| 4 |
RichText, |
| 5 |
} from '@wordpress/block-editor'; |
| 6 |
|
| 7 |
export default function save( { attributes } ) { |
| 8 |
const { caption, headers, footers, hasHeader, hasFooter, isEmpty } = |
| 9 |
attributes; |
| 10 |
const blockProps = useBlockProps.save(); |
| 11 |
const innerBlocksProps = useInnerBlocksProps.save( { |
| 12 |
className: 'gkit-table__body', |
| 13 |
} ); |
| 14 |
|
| 15 |
return ( |
| 16 |
! isEmpty && ( |
| 17 |
<figure { ...blockProps }> |
| 18 |
<table className="gkit-table"> |
| 19 |
<thead className="gkit-table__header"> |
| 20 |
<tr>{ Headers }</tr> |
| 21 |
</thead> |
| 22 |
<tbody { ...innerBlocksProps } /> |
| 23 |
<tfoot className="gkit-table__footer"> |
| 24 |
<tr>{ Footers }</tr> |
| 25 |
</tfoot> |
| 26 |
</table> |
| 27 |
{ caption && ( |
| 28 |
<RichText.Content |
| 29 |
identifier="caption" |
| 30 |
tagName="figcaption" |
| 31 |
className="gkit-table__caption" |
| 32 |
value={ caption } |
| 33 |
/> |
| 34 |
) } |
| 35 |
</figure> |
| 36 |
) |
| 37 |
); |
| 38 |
} |
| 39 |
|