From 03edbacbbc2dce3932da65482f7c8cf6e3c4ce9d Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Mon, 2 Jul 2018 10:32:54 -0400 Subject: [PATCH] Rich Text: Remove restoreContentAndSplit Call `onSplit` directly --- editor/components/rich-text/index.js | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/editor/components/rich-text/index.js b/editor/components/rich-text/index.js index ce2d8be73c9d9..c7ced3ec4db8f 100644 --- a/editor/components/rich-text/index.js +++ b/editor/components/rich-text/index.js @@ -568,7 +568,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(); this.onCreateUndoLevel(); @@ -689,7 +689,7 @@ export class RichText extends Component { after = this.isEmpty( after ) ? null : after; } - this.restoreContentAndSplit( before, after, blocks ); + onSplit( before, after, ...blocks ); } onNewBlock() { @@ -735,7 +735,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 ) ); @@ -902,19 +902,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.updateContent(); - this.props.onSplit( before, after, ...blocks ); - } - render() { const { tagName: Tagname = 'div',