From b7e03ae1aae6dce734af77580ac15ebc88807d70 Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Tue, 18 Sep 2018 17:26:28 +0100 Subject: [PATCH] Add table block deprecation --- packages/block-library/src/table/index.js | 59 +++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/packages/block-library/src/table/index.js b/packages/block-library/src/table/index.js index 16f31749a250d1..5ee1139d36f626 100644 --- a/packages/block-library/src/table/index.js +++ b/packages/block-library/src/table/index.js @@ -149,4 +149,63 @@ export const settings = { ); }, + + deprecated: [ + { + attributes: { + hasFixedLayout: { + type: 'boolean', + default: false, + }, + head: getTableSectionAttributeSchema( 'head' ), + body: getTableSectionAttributeSchema( 'body' ), + foot: getTableSectionAttributeSchema( 'foot' ), + }, + + supports: { + align: true, + }, + + save( { attributes } ) { + const { hasFixedLayout, head, body, foot } = attributes; + const isEmpty = ! head.length && ! body.length && ! foot.length; + + if ( isEmpty ) { + return null; + } + + const classes = classnames( { + 'has-fixed-layout': hasFixedLayout, + } ); + + const Section = ( { type, rows } ) => { + if ( ! rows.length ) { + return null; + } + + const Tag = `t${ type }`; + + return ( + + { rows.map( ( { cells }, rowIndex ) => + + { cells.map( ( { content, tag }, cellIndex ) => + + ) } + + ) } + + ); + }; + + return ( + +
+
+
+
+ ); + }, + }, + ], };