From 475ca365c00f729c0b35b8756d40da4dc4b04680 Mon Sep 17 00:00:00 2001 From: iamsivin Date: Tue, 21 Apr 2026 18:23:05 +0530 Subject: [PATCH] feat: add context menu disable feature --- .../dashboard/components-next/message/Message.vue | 8 ++++++++ app/javascript/react-components/doc.md | 2 ++ .../src/components/ChatwootProvider.jsx | 10 ++++++++++ 3 files changed, 20 insertions(+) diff --git a/app/javascript/dashboard/components-next/message/Message.vue b/app/javascript/dashboard/components-next/message/Message.vue index 226bf60b7..324326199 100644 --- a/app/javascript/dashboard/components-next/message/Message.vue +++ b/app/javascript/dashboard/components-next/message/Message.vue @@ -373,6 +373,8 @@ const componentToRender = computed(() => { }); const shouldShowContextMenu = computed(() => { + // eslint-disable-next-line no-underscore-dangle + if (window.__WOOT_DISABLE_CONTEXT_MENU__) return false; return !props.contentAttributes?.isUnsupported; }); @@ -439,6 +441,12 @@ const shouldRenderMessage = computed(() => { }); function openContextMenu(e) { + // eslint-disable-next-line no-underscore-dangle + if (window.__WOOT_DISABLE_CONTEXT_MENU__) { + e.preventDefault(); + return; + } + const shouldSkipContextMenu = e.target?.classList.contains('skip-context-menu') || ['a', 'img'].includes(e.target?.tagName.toLowerCase()); diff --git a/app/javascript/react-components/doc.md b/app/javascript/react-components/doc.md index ce8e940f7..954dba7ba 100644 --- a/app/javascript/react-components/doc.md +++ b/app/javascript/react-components/doc.md @@ -135,6 +135,7 @@ interface ChatwootProviderProps { disableUpload?: boolean; // Disable file attachments disableEditor?: boolean; // Disable reply editor disableSignature?: boolean; // Disable signature controls and insertion + disableContextMenu?: boolean; // Disable right-click message context menu (copy, translate, delete, copy link, reply, canned response) signature?: string; // Custom message signature (overrides user profile signature) } ``` @@ -150,6 +151,7 @@ window.__WOOT_CONVERSATION_ID__ // Active conversation window.__EDITOR_DISABLE_UPLOAD__ // Upload flag window.__DISABLE_EDITOR__ // Editor flag window.__WOOT_DISABLE_SIGNATURE__ // Disable signature controls and insertion +window.__WOOT_DISABLE_CONTEXT_MENU__ // Disable message right-click context menu window.__WOOT_CUSTOM_SIGNATURE__ // Custom signature (overrides profile) window.__WOOT_ISOLATED_SHELL__ // Disables audio notifications window.__CHATWOOT_STORE__ // Vuex store reference diff --git a/app/javascript/react-components/src/components/ChatwootProvider.jsx b/app/javascript/react-components/src/components/ChatwootProvider.jsx index 785ef0d97..fcb82df4d 100644 --- a/app/javascript/react-components/src/components/ChatwootProvider.jsx +++ b/app/javascript/react-components/src/components/ChatwootProvider.jsx @@ -19,6 +19,7 @@ export const ChatwootProvider = ({ disableUpload, disableEditor, disableSignature, + disableContextMenu, signature, signatureReadOnly, children, @@ -43,6 +44,7 @@ export const ChatwootProvider = ({ disableEditor: disableEditor || false, disableUpload: disableUpload || false, disableSignature: disableSignature || false, + disableContextMenu: disableContextMenu || false, websocketURL: websocketURL, pubsubToken: pubsubToken, signature: signature || '', @@ -64,6 +66,7 @@ export const ChatwootProvider = ({ window.__EDITOR_DISABLE_UPLOAD__ = config.disableUpload; window.__DISABLE_EDITOR__ = config.disableEditor; window.__WOOT_DISABLE_SIGNATURE__ = config.disableSignature; + window.__WOOT_DISABLE_CONTEXT_MENU__ = config.disableContextMenu; window.__WOOT_CUSTOM_SIGNATURE__ = config.signature || undefined; window.__WOOT_SIGNATURE_READ_ONLY__ = config.signatureReadOnly; window.__WOOT_ISOLATED_SHELL__ = true; @@ -133,6 +136,13 @@ export const ChatwootProvider = ({ ); }, [disableSignature]); + // Keep context-menu toggle global in sync when the prop changes after init + useEffect(() => { + const value = disableContextMenu === true; + // eslint-disable-next-line no-underscore-dangle + window.__WOOT_DISABLE_CONTEXT_MENU__ = value; + }, [disableContextMenu]); + if (!initializationComplete) { return null; }