From 10855895df01e4eb45d55bb9689647b3e51817b4 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Thu, 28 Jun 2018 15:32:10 -0400 Subject: [PATCH] Rich Text: Remove restoreContentAndSplit Call `onSplit` directly --- editor/components/rich-text/index.js | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/editor/components/rich-text/index.js b/editor/components/rich-text/index.js index 3487f2629929f..cd62c6e6f5643 100644 --- a/editor/components/rich-text/index.js +++ b/editor/components/rich-text/index.js @@ -501,7 +501,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(); @@ -603,11 +603,11 @@ export class RichText extends Component { after = this.isEmpty( after ) ? null : after; } - this.restoreContentAndSplit( before, after, blocks ); + this.props.onSplit( before, after, ...blocks ); } else if ( context.paste ) { - this.restoreContentAndSplit( null, null, blocks ); + this.props.onSplit( null, null, ...blocks ); } else { - this.restoreContentAndSplit( [], [], blocks ); + this.props.onSplit( [], [], ...blocks ); } } @@ -654,7 +654,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 ) ); @@ -821,19 +821,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',