feat: allow disabling signature

This commit is contained in:
Shivam Mishra
2026-03-05 16:01:03 +05:30
parent 6a6c3b7c27
commit 2f46cf162d
3 changed files with 36 additions and 2 deletions
+2
View File
@@ -134,6 +134,7 @@ interface ChatwootProviderProps {
pubsubToken?: string; // PubSub authentication token
disableUpload?: boolean; // Disable file attachments
disableEditor?: boolean; // Disable reply editor
disableSignature?: boolean; // Disable signature controls and insertion
signature?: string; // Custom message signature (overrides user profile signature)
}
```
@@ -148,6 +149,7 @@ window.__PUBSUB_TOKEN__ // Real-time auth token
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_CUSTOM_SIGNATURE__ // Custom signature (overrides profile)
window.__WOOT_ISOLATED_SHELL__ // Disables audio notifications
window.__CHATWOOT_STORE__ // Vuex store reference
@@ -18,6 +18,7 @@ export const ChatwootProvider = ({
conversationId,
disableUpload,
disableEditor,
disableSignature,
signature,
children,
}) => {
@@ -40,6 +41,7 @@ export const ChatwootProvider = ({
conversationId: Number(conversationId),
disableEditor: disableEditor || false,
disableUpload: disableUpload || false,
disableSignature: disableSignature || false,
websocketURL: websocketURL,
pubsubToken: pubsubToken,
signature: signature || '',
@@ -59,6 +61,7 @@ export const ChatwootProvider = ({
window.__WOOT_CONVERSATION_ID__ = config.conversationId;
window.__EDITOR_DISABLE_UPLOAD__ = config.disableUpload;
window.__DISABLE_EDITOR__ = config.disableEditor;
window.__WOOT_DISABLE_SIGNATURE__ = config.disableSignature;
window.__WOOT_CUSTOM_SIGNATURE__ = config.signature || undefined;
window.__WOOT_ISOLATED_SHELL__ = true;
/* eslint-enable no-underscore-dangle */
@@ -100,6 +103,16 @@ export const ChatwootProvider = ({
);
}, [signature]);
// Keep signature toggle global in sync when the prop changes after init
useEffect(() => {
const value = disableSignature === true;
// eslint-disable-next-line no-underscore-dangle
window.__WOOT_DISABLE_SIGNATURE__ = value;
window.dispatchEvent(
new CustomEvent('chatwoot:disable-signature-change', { detail: value })
);
}, [disableSignature]);
if (!initializationComplete) {
return null;
}
+21 -2
View File
@@ -40,6 +40,8 @@ export default {
updateEditorSelectionWith: '',
// eslint-disable-next-line no-underscore-dangle
customSignatureValue: window.__WOOT_CUSTOM_SIGNATURE__ || '',
// eslint-disable-next-line no-underscore-dangle
disableSignatureValue: window.__WOOT_DISABLE_SIGNATURE__ === true,
};
},
computed: {
@@ -166,7 +168,13 @@ export default {
hasCustomSignature() {
return !!this.customSignature;
},
allowSignature() {
return !this.disableSignatureValue;
},
signatureToApply() {
if (!this.allowSignature) {
return '';
}
const signature = this.customSignature || this.messageSignature;
return this.showRichContentEditor
? signature
@@ -180,6 +188,10 @@ export default {
'chatwoot:signature-change',
this.onSignatureChange
);
window.addEventListener(
'chatwoot:disable-signature-change',
this.onDisableSignatureChange
);
// // A hacky fix to solve the drag and drop
// // Is showing on top of new conversation modal drag and drop
@@ -197,11 +209,18 @@ export default {
'chatwoot:signature-change',
this.onSignatureChange
);
window.removeEventListener(
'chatwoot:disable-signature-change',
this.onDisableSignatureChange
);
},
methods: {
onSignatureChange(event) {
this.customSignatureValue = event.detail || '';
},
onDisableSignatureChange(event) {
this.disableSignatureValue = event.detail === true;
},
getElementToBind() {
return this.replyEditor;
},
@@ -423,7 +442,7 @@ export default {
enable-variables
:variables="messageVariables"
:signature="signatureToApply"
allow-signature
:allow-signature="allowSignature"
:force-signature="hasCustomSignature"
:channel-type="channelType"
@typing-off="onTypingOff"
@@ -464,7 +483,7 @@ export default {
:message="message"
:enable-multiple-file-upload="allowFileUpload"
:allow-file-upload="allowFileUpload"
allow-signature
:allow-signature="allowSignature"
/>
</div>
</template>