feat: add utils to create and remove the context menu

This commit is contained in:
SauceyRed 2025-07-10 23:57:25 +02:00
parent 0ea9c8f168
commit b51efc01e9
Signed by: sauceyred
GPG key ID: 2BF92EB6D8A5CCA7
2 changed files with 23 additions and 0 deletions

View file

@ -0,0 +1,17 @@
import { render } from "vue";
import ContextMenu from "~/components/ContextMenu.vue";
import type { ContextMenuItem } from "~/types/interfaces";
export default (e: MouseEvent, menuItems: ContextMenuItem[]) => {
console.log("Rendering new context menu");
const menuContainer = document.createElement("div");
menuContainer.id = "context-menu";
document.body.appendChild(menuContainer);
const contextMenu = h(ContextMenu, {
menuItems,
cursorX: e.clientX,
cursorY: e.clientY
});
render(contextMenu, menuContainer);
console.log("Rendered");
}

View file

@ -0,0 +1,6 @@
export default () => {
const contextMenu = document.getElementById("context-menu");
if (contextMenu) {
contextMenu.remove();
}
}