Fix link tooltip removal

This commit is contained in:
Giuseppe Criscione 2024-10-18 00:27:49 +02:00
parent 0b67e7b59a
commit b311aebc37

View File

@ -16,18 +16,9 @@ class LinkTooltipView {
this.editorView.dom.addEventListener(
"scroll",
debounce(
() => {
if (this.tooltip) {
this.tooltip.remove();
}
this.tooltip = undefined;
this.currentLink = undefined;
},
100,
true,
),
debounce(() => this.destroy(), 100, true),
);
this.editorView.dom.addEventListener("blur", () => this.destroy());
}
update(view: EditorView) {
@ -61,13 +52,17 @@ class LinkTooltipView {
});
}
} else {
if (this.tooltip) {
this.tooltip.remove();
}
this.tooltip = undefined;
this.currentLink = undefined;
this.destroy();
}
}
destroy() {
if (this.tooltip) {
this.tooltip.remove();
}
this.tooltip = undefined;
this.currentLink = undefined;
}
}
export function linkTooltip(): Plugin {