From 24aa33a4f16282812caa16d5666bbd7f57517c7c Mon Sep 17 00:00:00 2001 From: Hufe921 Date: Fri, 17 May 2024 21:59:39 +0800 Subject: [PATCH] fix: re render when the page is visible #578 --- src/editor/core/event/GlobalEvent.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/editor/core/event/GlobalEvent.ts b/src/editor/core/event/GlobalEvent.ts index 5f02d2d..f49f756 100644 --- a/src/editor/core/event/GlobalEvent.ts +++ b/src/editor/core/event/GlobalEvent.ts @@ -146,10 +146,19 @@ export class GlobalEvent { } private _handleVisibilityChange = () => { - if (document.visibilityState) { - const isCollapsed = this.range.getIsCollapsed() - this.cursor?.drawCursor({ - isShow: isCollapsed + if (document.visibilityState === 'visible') { + // 页面可见时重新渲染激活页面 + const range = this.range.getRange() + const isSetCursor = + !!~range.startIndex && + !!~range.endIndex && + range.startIndex === range.endIndex + this.range.replaceRange(range) + this.draw.render({ + isSetCursor, + isCompute: false, + isSubmitHistory: false, + curIndex: range.startIndex }) } }