Upgrade @codemirror/view and height fixes

This commit is contained in:
Zef Hemel
2024-01-02 12:43:10 +01:00
parent 11693fbd00
commit 6b6ab30c92
6 changed files with 28 additions and 6 deletions
+17 -1
View File
@@ -28,11 +28,27 @@ export class LinkWidget extends WidgetType {
const anchor = document.createElement("a");
anchor.className = this.options.cssClass;
anchor.textContent = this.options.text;
anchor.addEventListener("click", (e) => {
// Mouse handling
anchor.addEventListener("mousedown", (e) => {
e.preventDefault();
e.stopPropagation();
this.options.callback(e);
});
// Touch handling
let touchCount = 0;
anchor.addEventListener("touchmove", () => {
touchCount++;
});
anchor.addEventListener("touchend", (e) => {
if (touchCount === 0) {
e.preventDefault();
e.stopPropagation();
this.options.callback(new MouseEvent("click", e));
}
touchCount = 0;
});
anchor.setAttribute("title", this.options.title);
anchor.href = this.options.href || "#";
return anchor;