Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

Commit

Permalink
Slate Table block type w/ 1 issue:
Browse files Browse the repository at this point in the history
the Save button does not work always
  • Loading branch information
silviubogan committed Jul 31, 2020
1 parent 092bb9d commit 85449d6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 4 additions & 2 deletions src/Table/Cell.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ class Cell extends Component {
}

handleFocus() {
this.setState({ selected: true });
this.setState({ selected: true }, () => {
this.props.onSelectCell(this.props.row, this.props.cell);
});
}

/**
Expand All @@ -92,7 +94,7 @@ class Cell extends Component {
* @returns {undefined}
*/
onChange(val) {
this.props.onChange(this.props.row, this.props.cell, val);
this.props.onChange(this.props.row, this.props.cell, [...val]);
}

handleContainerFocus() {
Expand Down
2 changes: 1 addition & 1 deletion src/Table/Edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ class Edit extends Component {
const table = { ...this.props.data.table };
table.rows[row].cells[cell] = {
...table.rows[row].cells[cell],
value: slateValue,
value: [...slateValue],
};
this.props.onChangeBlock(this.props.block, {
...this.props.data,
Expand Down
15 changes: 7 additions & 8 deletions src/Table/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import React from 'react';
import PropTypes from 'prop-types';
import { Table } from 'semantic-ui-react';
import { map } from 'lodash';
import redraft from 'redraft';
import TextBlockView from '../TextBlock/TextBlockView';
import { Node } from 'slate';

import { settings } from '~/config';

Expand Down Expand Up @@ -35,13 +36,11 @@ const View = ({ data }) => (
key={cell.key}
as={cell.type === 'header' ? 'th' : 'td'}
>
{cell.value && cell.value.blocks && cell.value.blocks[0].text
? redraft(
cell.value,
settings.ToHTMLRenderers,
settings.ToHTMLOptions,
)
: '\u00A0'}
{cell.value && Node.string(cell.value[0]).length > 0 ? (
<TextBlockView data={{ value: cell.value }} />
) : (
'\u00A0'
)}
</Table.Cell>
))}
</Table.Row>
Expand Down
1 change: 0 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ const applyConfig = (config) => {
view: [],
},
blockHasValue: (data) => {
// console.error('NOT IMPLEMENTED');
return true;
},
};
Expand Down

0 comments on commit 85449d6

Please sign in to comment.