I am working on prosemirror-tables, and I want a feature where I click inside the table on any cell or any part of the table, I want to show some buttons for adding new columns and rows and some buttons for showing the menu.
I can write my custom table node_view, but I can’t figure out how to check if the click happened inside the table. I tried getting view.state.selection, but that will always give textSelection instead of TableSelection.
What I am hoping to achieve is possible or not I am not sure. Can someone help me on this?
I tried to do this using event listener, the style gets changes but it does not seem to reflect the styles
this.dom.addEventListener("click", e => {
if (
e.target instanceof HTMLElement &&
(e.target.closest("td") || e.target.closest("th"))
) {
console.log("clicked inside the table");
this.isButtonVisible = false;
this.lastColumnButton.style.display = "block";
} else {
console.log("clicked outside the table");
this.isButtonVisible = true;
this.lastColumnButton.style.display = "none";
}
});