Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(linkBubble): load only when needed #5723

Merged
merged 3 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions src/plugins/LinkBubblePluginView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -32,7 +24,7 @@ class LinkBubblePluginView {
)
document.addEventListener('scroll',
this.closeOnExternalEvents,
{ capture: true }
{ capture: true },
)
}

Expand All @@ -45,7 +37,7 @@ class LinkBubblePluginView {
)
document.removeEventListener('scroll',
this.closeOnExternalEvents,
{ capture: true }
{ capture: true },
)
}

Expand All @@ -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,
Expand Down Expand Up @@ -112,7 +112,7 @@ class LinkBubblePluginView {
}
const clientRect = referenceEl?.getBoundingClientRect()

this.#component.updateProps({
this.#component?.updateProps({
href: domHref(mark),
})

Expand Down
2 changes: 1 addition & 1 deletion src/tests/nodes/TaskItem.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)')
Expand Down
Loading