From 650324f434d2b334914666342060f4d8f56f7c56 Mon Sep 17 00:00:00 2001 From: Valtteri Karesto Date: Mon, 11 Apr 2022 17:07:25 +0300 Subject: [PATCH] Hacky way to hide Peek from context menu --- components/HooksEditor.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/components/HooksEditor.tsx b/components/HooksEditor.tsx index 85744e0..ab196c8 100644 --- a/components/HooksEditor.tsx +++ b/components/HooksEditor.tsx @@ -226,6 +226,22 @@ const HooksEditor = () => { } }); + // Hacky way to hide Peek menu + editor.onContextMenu((e) => { + const host = + document.querySelector(".shadow-root-host"); + + const contextMenuItems = + host?.shadowRoot?.querySelectorAll("li.action-item"); + contextMenuItems?.forEach((k) => { + // If menu item contains "Peek" lets hide it + if (k.querySelector(".action-label")?.textContent === "Peek") { + // @ts-expect-error + k["style"].display = "none"; + } + }); + }); + validateWritability(editor); }} theme={theme === "dark" ? "dark" : "light"}