From 68e4a9ce7e48a7ecec949785e406d4f15a9d33c7 Mon Sep 17 00:00:00 2001 From: Ran Luo Date: Sat, 2 Nov 2019 22:50:38 +0800 Subject: [PATCH] fix #1583 (#1585) --- src/muya/lib/contentState/backspaceCtrl.js | 8 ++++++-- src/muya/lib/contentState/enterCtrl.js | 10 +++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/muya/lib/contentState/backspaceCtrl.js b/src/muya/lib/contentState/backspaceCtrl.js index 3840f135..e714213f 100644 --- a/src/muya/lib/contentState/backspaceCtrl.js +++ b/src/muya/lib/contentState/backspaceCtrl.js @@ -500,10 +500,14 @@ const backspaceCtrl = ContentState => { start: { key, offset }, end: { key, offset } } - if (this.isCollapse()) { + let needRenderAll = false + + if (this.isCollapse() && preBlock.type === 'span' && preBlock.functionType === 'paragraphContent') { this.checkInlineUpdate(preBlock) + needRenderAll = true } - this.partialRender() + + needRenderAll ? this.render() : this.partialRender() } } } diff --git a/src/muya/lib/contentState/enterCtrl.js b/src/muya/lib/contentState/enterCtrl.js index db084aa1..3fe3d62c 100644 --- a/src/muya/lib/contentState/enterCtrl.js +++ b/src/muya/lib/contentState/enterCtrl.js @@ -418,6 +418,7 @@ const enterCtrl = ContentState => { } this.insertAfter(newBlock, block) + break } case left === 0 && right === 0: { @@ -511,7 +512,14 @@ const enterCtrl = ContentState => { end: { key, offset } } - this.partialRender() + let needRenderAll = false + + if (this.isCollapse() && cursorBlock.type === 'p') { + this.checkInlineUpdate(cursorBlock.children[0]) + needRenderAll = true + } + + needRenderAll ? this.render() : this.partialRender() } }