From f7a8fc39fe5e7be1b53871c19dd59954747a29f9 Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Tue, 25 Sep 2018 15:05:34 +0100 Subject: [PATCH] Extract blockAttributes and supports into variables and re-use --- packages/block-library/src/table/index.js | 42 ++++++++++------------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/packages/block-library/src/table/index.js b/packages/block-library/src/table/index.js index 5ee1139d36f62..520c08e795583 100644 --- a/packages/block-library/src/table/index.js +++ b/packages/block-library/src/table/index.js @@ -75,25 +75,29 @@ function getTableSectionAttributeSchema( section ) { export const name = 'core/table'; +const blockAttributes = { + hasFixedLayout: { + type: 'boolean', + default: false, + }, + head: getTableSectionAttributeSchema( 'head' ), + body: getTableSectionAttributeSchema( 'body' ), + foot: getTableSectionAttributeSchema( 'foot' ), +}; + +const supports = { + align: true, +}; + export const settings = { title: __( 'Table' ), description: __( 'Insert a table -- perfect for sharing charts and data.' ), icon: , category: 'formatting', - attributes: { - hasFixedLayout: { - type: 'boolean', - default: false, - }, - head: getTableSectionAttributeSchema( 'head' ), - body: getTableSectionAttributeSchema( 'body' ), - foot: getTableSectionAttributeSchema( 'foot' ), - }, + attributes: blockAttributes, - supports: { - align: true, - }, + supports, transforms: { from: [ @@ -152,19 +156,9 @@ export const settings = { deprecated: [ { - attributes: { - hasFixedLayout: { - type: 'boolean', - default: false, - }, - head: getTableSectionAttributeSchema( 'head' ), - body: getTableSectionAttributeSchema( 'body' ), - foot: getTableSectionAttributeSchema( 'foot' ), - }, + attributes: blockAttributes, - supports: { - align: true, - }, + supports, save( { attributes } ) { const { hasFixedLayout, head, body, foot } = attributes;