From f1df5116b37446af9179ab3c461855e07f261be5 Mon Sep 17 00:00:00 2001 From: Jiuqing Song Date: Thu, 4 Apr 2024 15:52:50 -0700 Subject: [PATCH] improve --- .../lib/hyperlink/HyperlinkPlugin.ts | 3 +++ .../test/hyperlink/HyperlinkPluginTest.ts | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/packages/roosterjs-content-model-plugins/lib/hyperlink/HyperlinkPlugin.ts b/packages/roosterjs-content-model-plugins/lib/hyperlink/HyperlinkPlugin.ts index e68a2d8cad9..3e137362211 100644 --- a/packages/roosterjs-content-model-plugins/lib/hyperlink/HyperlinkPlugin.ts +++ b/packages/roosterjs-content-model-plugins/lib/hyperlink/HyperlinkPlugin.ts @@ -67,6 +67,9 @@ export class HyperlinkPlugin implements EditorPlugin { this.disposer(); this.disposer = null; } + + this.currentNode = null; + this.currentLink = null; this.editor = null; } diff --git a/packages/roosterjs-content-model-plugins/test/hyperlink/HyperlinkPluginTest.ts b/packages/roosterjs-content-model-plugins/test/hyperlink/HyperlinkPluginTest.ts index 3167493376f..47d20637d85 100644 --- a/packages/roosterjs-content-model-plugins/test/hyperlink/HyperlinkPluginTest.ts +++ b/packages/roosterjs-content-model-plugins/test/hyperlink/HyperlinkPluginTest.ts @@ -96,6 +96,8 @@ describe('HyperlinkPlugin', () => { expect(getAttributeSpy).toHaveBeenCalledWith('href'); expect(tooltipSpy).toHaveBeenCalledWith(mockedUrl, mockedLink); expect(setDomAttributeSpy).toHaveBeenCalledWith('title', MockedTooltip); + + plugin.dispose(); }); it('MouseOut', () => { @@ -132,6 +134,8 @@ describe('HyperlinkPlugin', () => { expect(getAttributeSpy).toHaveBeenCalledWith('href'); expect(tooltipSpy).not.toHaveBeenCalled(); expect(setDomAttributeSpy).toHaveBeenCalledWith('title', null); + + plugin.dispose(); }); it('mouseUp', () => { @@ -195,6 +199,8 @@ describe('HyperlinkPlugin', () => { expect(preventDefaultSpy).toHaveBeenCalled(); expect(openSpy).toHaveBeenCalledWith(mockedUrl, '_blank'); + + plugin.dispose(); }); it('mouseUp with target', () => { @@ -224,6 +230,8 @@ describe('HyperlinkPlugin', () => { expect(preventDefaultSpy).toHaveBeenCalled(); expect(openSpy).toHaveBeenCalledWith(mockedUrl, mockedTarget); + + plugin.dispose(); }); it('mouseUp with onLinkClick parameter', () => { @@ -279,6 +287,8 @@ describe('HyperlinkPlugin', () => { }); expect(preventDefaultSpy).toHaveBeenCalled(); expect(openSpy).toHaveBeenCalledWith(mockedUrl, '_blank'); + + plugin.dispose(); }); it('keyDown and keyUp', () => { @@ -337,6 +347,8 @@ describe('HyperlinkPlugin', () => { expect(containsSpy).toHaveBeenCalledWith(mockedNode); expect(setAttributeSpy).toHaveBeenCalledWith('href', mockedUrl2); + + plugin.dispose(); }); it('keyDown and keyUp, not contain', () => { @@ -389,6 +401,8 @@ describe('HyperlinkPlugin', () => { expect(containsSpy).toHaveBeenCalledWith(mockedNode); expect(setAttributeSpy).not.toHaveBeenCalled(); + + plugin.dispose(); }); it('keyDown and keyUp, url not match', () => { @@ -438,5 +452,7 @@ describe('HyperlinkPlugin', () => { expect(containsSpy).not.toHaveBeenCalled(); expect(setAttributeSpy).not.toHaveBeenCalled(); + + plugin.dispose(); }); });