diff --git a/app.vue b/app.vue index 8f0571f..72bffa2 100644 --- a/app.vue +++ b/app.vue @@ -12,22 +12,20 @@ import type { ContextMenuInterface } from './types/interfaces'; const banner = useState("banner", () => false); -const contextMenu = useState("contextMenu"); +const contextMenu = useState("contextMenu", () => ({ show: false, pointerX: 0, pointerY: 0, items: [] })); onMounted(() => { loadPreferredThemes() - document.removeEventListener("contextmenu", contextMenuHandler); - document.addEventListener("contextmenu", (e) => { - if (e.target instanceof Element && e.target.classList.contains("default-contextmenu")) return; - contextMenuHandler(e); - }); document.addEventListener("mousedown", (e) => { - if (e.target instanceof HTMLElement && e.target.closest("#context-menu")) return; + if (e.target instanceof HTMLElement && e.target.classList.contains("context-menu-item")) return; console.log("click"); console.log("target:", e.target); console.log(e.target instanceof HTMLDivElement); - removeContextMenu(contextMenu); + if (contextMenu.value.show) { + console.log("context menu is shown, hiding"); + removeContextMenu(contextMenu); + } if (e.target instanceof HTMLElement && e.target.classList.contains("message-text") && e.target.contentEditable) { e.target.contentEditable = "false"; } @@ -52,14 +50,6 @@ onMounted(() => { }); }); -function contextMenuHandler(e: MouseEvent) { - e.preventDefault(); - //console.log("Opened context menu"); - //createContextMenu(e, [ - // { name: "Wah", callback: () => { return } } - //]); -} - diff --git a/components/Message.vue b/components/Message.vue index c926616..74b0bca 100644 --- a/components/Message.vue +++ b/components/Message.vue @@ -1,5 +1,5 @@