From df435da9a57f384201cb703effa9cf77f5bcbf87 Mon Sep 17 00:00:00 2001 From: Jiuqing Song Date: Tue, 17 Dec 2024 22:46:00 -0800 Subject: [PATCH] improve --- .../lib/watermark/WatermarkPlugin.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/roosterjs-content-model-plugins/lib/watermark/WatermarkPlugin.ts b/packages/roosterjs-content-model-plugins/lib/watermark/WatermarkPlugin.ts index f6c309fa13d..1ab7d186a7f 100644 --- a/packages/roosterjs-content-model-plugins/lib/watermark/WatermarkPlugin.ts +++ b/packages/roosterjs-content-model-plugins/lib/watermark/WatermarkPlugin.ts @@ -18,6 +18,7 @@ export class WatermarkPlugin implements EditorPlugin { private format: WatermarkFormat; private isShowing = false; private darkTextColor: string | null = null; + private disposer: (() => void) | null = null; /** * Create an instance of Watermark plugin @@ -43,7 +44,7 @@ export class WatermarkPlugin implements EditorPlugin { */ initialize(editor: IEditor) { this.editor = editor; - this.editor.attachDomEvent({ + this.disposer = this.editor.attachDomEvent({ compositionstart: { beforeDispatch: this.onCompositionStart, }, @@ -54,6 +55,9 @@ export class WatermarkPlugin implements EditorPlugin { * Dispose this plugin */ dispose() { + this.disposer?.(); + this.disposer = null; + this.editor = null; }