Skip to content

Commit

Permalink
Extract blockAttributes and supports into variables and re-use
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan committed Sep 25, 2018
1 parent eab3703 commit f7a8fc3
Showing 1 changed file with 18 additions and 24 deletions.
42 changes: 18 additions & 24 deletions packages/block-library/src/table/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill="none" d="M0 0h24v24H0V0z" /><g><path d="M20 3H5L3 5v14l2 2h15l2-2V5l-2-2zm0 2v3H5V5h15zm-5 14h-5v-9h5v9zM5 10h3v9H5v-9zm12 9v-9h3v9h-3z" /></g></svg>,
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: [
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f7a8fc3

Please sign in to comment.