From d63c262f781ceb072d704365d00ea34ad73fb847 Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 23 Apr 2024 13:43:21 +0200 Subject: [PATCH] fix(linkBubble): only render when needed Prevents 503 requests during tests. See #5442. Signed-off-by: Max --- src/plugins/LinkBubblePluginView.js | 18 +++++++++--------- src/tests/nodes/TaskItem.spec.js | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/plugins/LinkBubblePluginView.js b/src/plugins/LinkBubblePluginView.js index e20ae89413a..17c48a47282 100644 --- a/src/plugins/LinkBubblePluginView.js +++ b/src/plugins/LinkBubblePluginView.js @@ -13,14 +13,6 @@ class LinkBubblePluginView { this.view = view this.plugin = plugin this.#editor = this.options.editor - - this.#component = new VueRenderer(LinkBubbleView, { - parent: this.options.parent, - propsData: { - editor: this.options.editor, - href: null, - }, - }) } addEventListeners() { @@ -71,6 +63,14 @@ class LinkBubblePluginView { return } + this.#component ||= new VueRenderer(LinkBubbleView, { + parent: this.options.parent, + propsData: { + editor: this.options.editor, + href: null, + }, + }) + this.tippy = tippy(editorElement, { duration: 100, getReferenceClientRect: null, @@ -112,7 +112,7 @@ class LinkBubblePluginView { } const clientRect = referenceEl?.getBoundingClientRect() - this.#component.updateProps({ + this.#component?.updateProps({ href: domHref(mark), }) diff --git a/src/tests/nodes/TaskItem.spec.js b/src/tests/nodes/TaskItem.spec.js index b0333d80dee..abc0a6d7b6e 100644 --- a/src/tests/nodes/TaskItem.spec.js +++ b/src/tests/nodes/TaskItem.spec.js @@ -18,7 +18,7 @@ describe('TaskItem extension', () => { expect(taskItem.spec.toMarkdown).toBeDefined() }) - test('markdown syntax is preserved through editor', () => { + it('markdown syntax is preserved through editor', () => { // Invalid ones but should be syntactical unchanged expect(markdownThroughEditor('- [F] asd')).toBe('- [F] asd') expect(markdownThroughEditor('- [ [asd](sdf)')).toBe('- [ [asd](sdf)')