Skip to content

Commit

Permalink
Rich Text: Remove restoreContentAndSplit
Browse files Browse the repository at this point in the history
Call `onSplit` directly
  • Loading branch information
aduth committed Jul 9, 2018
1 parent 5a4b048 commit f3d3852
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions editor/components/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ export class RichText extends Component {
const before = domToFormat( beforeNodes, format, this.editor );
const after = domToFormat( afterNodes, format, this.editor );

this.restoreContentAndSplit( before, after );
this.props.onSplit( before, after );
} else {
event.preventDefault();

Expand Down Expand Up @@ -664,7 +664,7 @@ export class RichText extends Component {
after = this.isEmpty( after ) ? null : after;
}

this.restoreContentAndSplit( before, after, blocks );
onSplit( before, after, ...blocks );
}

onNewBlock() {
Expand Down Expand Up @@ -710,7 +710,7 @@ export class RichText extends Component {
this.setContent( this.props.value );

const { format } = this.props;
this.restoreContentAndSplit(
this.props.onSplit(
domToFormat( before, format, this.editor ),
domToFormat( after, format, this.editor )
);
Expand Down Expand Up @@ -875,19 +875,6 @@ export class RichText extends Component {
} ) );
}

/**
* Calling onSplit means we need to abort the change done by TinyMCE.
* we need to call updateContent to restore the initial content before calling onSplit.
*
* @param {Array} before content before the split position
* @param {Array} after content after the split position
* @param {?Array} blocks blocks to insert at the split position
*/
restoreContentAndSplit( before, after, blocks = [] ) {
this.setContent( this.props.value );
this.props.onSplit( before, after, ...blocks );
}

render() {
const {
tagName: Tagname = 'div',
Expand Down

0 comments on commit f3d3852

Please sign in to comment.