From 549df61cbf9d4fa5cbed6367651e51c47fd426b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E4=BA=91=E9=A3=9E?= Date: Wed, 14 Dec 2022 17:54:59 +0800 Subject: [PATCH] feat:set the cursor when the page is visible --- src/editor/core/event/GlobalEvent.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/editor/core/event/GlobalEvent.ts b/src/editor/core/event/GlobalEvent.ts index eacda88..1b27e51 100644 --- a/src/editor/core/event/GlobalEvent.ts +++ b/src/editor/core/event/GlobalEvent.ts @@ -38,6 +38,14 @@ export class GlobalEvent { public register() { this.cursor = this.draw.getCursor() + window.addEventListener('blur', (evt) => { + this.recoverEffect(evt) + }) + document.addEventListener('visibilitychange', () => { + if (document.visibilityState) { + this.cursor?.drawCursor() + } + }) document.addEventListener('keyup', () => { this.setRangeStyle() }) @@ -52,7 +60,7 @@ export class GlobalEvent { }, { passive: false }) } - public recoverEffect(evt: MouseEvent) { + public recoverEffect(evt: Event) { if (!this.cursor) return const cursorDom = this.cursor.getCursorDom() const agentDom = this.cursor.getAgentDom() @@ -73,7 +81,6 @@ export class GlobalEvent { } this.cursor.recoveryCursor() this.range.recoveryRangeStyle() - this.range.setRange(-1, -1) this.previewer.clearResizer() this.tableTool.dispose() this.hyperlinkParticle.clearHyperlinkPopup()