Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite table block to use a simpler RichText value #8767

Merged
merged 13 commits into from
Aug 23, 2018
1 change: 1 addition & 0 deletions packages/block-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"url": "^0.11.0"
},
"devDependencies": {
"deep-freeze": "^0.0.1",
"enzyme": "^3.3.0",
"react-test-renderer": "^16.4.1"
},
Expand Down
11 changes: 1 addition & 10 deletions packages/block-library/src/table/edit.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
/**
* External dependencies
*/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added these lines because that was @aduth's preference some time ago. I don't really mind, but it is not a doc block... So maybe it's better with the line, or just one asterisk at the start.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to change it, let's update in one batch all of them to match one style.

import classnames from 'classnames';

/**
* WordPress dependencies
*/

import { Fragment, Component } from '@wordpress/element';
import { InspectorControls, BlockControls, RichText } from '@wordpress/editor';
import { __ } from '@wordpress/i18n';
Expand All @@ -23,7 +21,6 @@ import {
/**
* Internal dependencies
*/

import {
createTable,
updateCellContent,
Expand All @@ -33,12 +30,6 @@ import {
deleteColumn,
} from './state';

/**
* Browser dependencies
*/

const { parseInt } = window;

export default class TableEdit extends Component {
constructor() {
super( ...arguments );
Expand Down Expand Up @@ -78,7 +69,7 @@ export default class TableEdit extends Component {
/**
* Updates the initial row count used for table creation.
*
* @param {[type]} initialRowCount New initial row count.
* @param {number} initialRowCount New initial row count.
*/
onChangeInitialRowCount( initialRowCount ) {
this.setState( { initialRowCount } );
Expand Down
3 changes: 0 additions & 3 deletions packages/block-library/src/table/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
/**
* External dependencies
*/

import classnames from 'classnames';

/**
* WordPress dependencies
*/

import { __ } from '@wordpress/i18n';
import { getPhrasingContentSchema } from '@wordpress/blocks';
import { RichText } from '@wordpress/editor';

/**
* Internal dependencies
*/

import edit from './edit';

const tableContentPasteSchema = {
Expand Down
1 change: 0 additions & 1 deletion packages/block-library/src/table/state.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/

import { times } from 'lodash';

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`core/embed block edit matches snapshot 1`] = `
exports[`core/table block edit matches snapshot 1`] = `
<form>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is much nicer than providing the default 2x2 table 💯

<div
class="components-base-control"
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/table/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { name, settings } from '../';
import { blockEditRender } from '../../test/helpers';

describe( 'core/embed', () => {
describe( 'core/table', () => {
test( 'block edit matches snapshot', () => {
const wrapper = blockEditRender( name, settings );

Expand Down
14 changes: 9 additions & 5 deletions packages/block-library/src/table/test/state.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
/**
* Internal dependencies
* External dependencies
*/
import deepFreeze from 'deep-freeze';

/**
* Internal dependencies
*/
import {
createTable,
updateCellContent,
Expand All @@ -11,7 +15,7 @@ import {
deleteColumn,
} from '../state';

const table = {
const table = deepFreeze( {
body: [
{
cells: [
Expand All @@ -38,9 +42,9 @@ const table = {
],
},
],
};
} );

const tableWithContent = {
const tableWithContent = deepFreeze( {
body: [
{
cells: [
Expand All @@ -67,7 +71,7 @@ const tableWithContent = {
],
},
],
};
} );

describe( 'createTable', () => {
it( 'should create a table', () => {
Expand Down