feat: add context menu disable feature

This commit is contained in:
iamsivin
2026-04-21 18:23:05 +05:30
parent 6ff0c67501
commit 475ca365c0
3 changed files with 20 additions and 0 deletions
@@ -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());
+2
View File
@@ -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
@@ -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;
}