fix: Add empty line before signature in compose conversation editor (#12702)
Co-authored-by: Shivam Mishra <scm.mymail@gmail.com>
This commit is contained in:
@@ -21,6 +21,10 @@ const props = defineProps({
|
|||||||
enableCannedResponses: { type: Boolean, default: true },
|
enableCannedResponses: { type: Boolean, default: true },
|
||||||
enabledMenuOptions: { type: Array, default: () => [] },
|
enabledMenuOptions: { type: Array, default: () => [] },
|
||||||
enableCaptainTools: { type: Boolean, default: false },
|
enableCaptainTools: { type: Boolean, default: false },
|
||||||
|
signature: { type: String, default: '' },
|
||||||
|
allowSignature: { type: Boolean, default: false },
|
||||||
|
sendWithSignature: { type: Boolean, default: false },
|
||||||
|
channelType: { type: String, default: '' },
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue']);
|
const emit = defineEmits(['update:modelValue']);
|
||||||
@@ -100,6 +104,10 @@ watch(
|
|||||||
:enable-canned-responses="enableCannedResponses"
|
:enable-canned-responses="enableCannedResponses"
|
||||||
:enabled-menu-options="enabledMenuOptions"
|
:enabled-menu-options="enabledMenuOptions"
|
||||||
:enable-captain-tools="enableCaptainTools"
|
:enable-captain-tools="enableCaptainTools"
|
||||||
|
:signature="signature"
|
||||||
|
:allow-signature="allowSignature"
|
||||||
|
:send-with-signature="sendWithSignature"
|
||||||
|
:channel-type="channelType"
|
||||||
@input="handleInput"
|
@input="handleInput"
|
||||||
@focus="handleFocus"
|
@focus="handleFocus"
|
||||||
@blur="handleBlur"
|
@blur="handleBlur"
|
||||||
|
|||||||
@@ -92,7 +92,6 @@ const setSignature = () => {
|
|||||||
|
|
||||||
const toggleMessageSignature = () => {
|
const toggleMessageSignature = () => {
|
||||||
setSignatureFlagForInbox(props.channelType, !sendWithSignature.value);
|
setSignatureFlagForInbox(props.channelType, !sendWithSignature.value);
|
||||||
setSignature();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Added this watch to dynamically set signature on target inbox change.
|
// Added this watch to dynamically set signature on target inbox change.
|
||||||
|
|||||||
@@ -199,16 +199,20 @@ const handleInboxAction = ({ value, action, ...rest }) => {
|
|||||||
state.attachedFiles = [];
|
state.attachedFiles = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeTargetInbox = value => {
|
const removeSignatureFromMessage = () => {
|
||||||
v$.value.$reset();
|
// Always remove the signature from message content when inbox/contact is removed
|
||||||
// Remove the signature from message content
|
// to ensure no leftover signature content remains
|
||||||
// Based on the Advance Editor (used in isEmailOrWebWidget) and Plain editor(all other inboxes except WhatsApp)
|
const signatureToRemove = inboxTypes.value.isEmailOrWebWidget
|
||||||
if (props.sendWithSignature) {
|
? props.messageSignature
|
||||||
const signatureToRemove = inboxTypes.value.isEmailOrWebWidget
|
: extractTextFromMarkdown(props.messageSignature);
|
||||||
? props.messageSignature
|
if (signatureToRemove) {
|
||||||
: extractTextFromMarkdown(props.messageSignature);
|
|
||||||
state.message = removeSignature(state.message, signatureToRemove);
|
state.message = removeSignature(state.message, signatureToRemove);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const removeTargetInbox = value => {
|
||||||
|
v$.value.$reset();
|
||||||
|
removeSignatureFromMessage();
|
||||||
emit('updateTargetInbox', value);
|
emit('updateTargetInbox', value);
|
||||||
state.attachedFiles = [];
|
state.attachedFiles = [];
|
||||||
};
|
};
|
||||||
@@ -216,6 +220,7 @@ const removeTargetInbox = value => {
|
|||||||
const clearSelectedContact = () => {
|
const clearSelectedContact = () => {
|
||||||
emit('clearSelectedContact');
|
emit('clearSelectedContact');
|
||||||
state.attachedFiles = [];
|
state.attachedFiles = [];
|
||||||
|
removeSignatureFromMessage();
|
||||||
};
|
};
|
||||||
|
|
||||||
const onClickInsertEmoji = emoji => {
|
const onClickInsertEmoji = emoji => {
|
||||||
@@ -354,6 +359,7 @@ const shouldShowMessageEditor = computed(() => {
|
|||||||
:is-email-or-web-widget-inbox="inboxTypes.isEmailOrWebWidget"
|
:is-email-or-web-widget-inbox="inboxTypes.isEmailOrWebWidget"
|
||||||
:has-errors="validationStates.isMessageInvalid"
|
:has-errors="validationStates.isMessageInvalid"
|
||||||
:has-attachments="state.attachedFiles.length > 0"
|
:has-attachments="state.attachedFiles.length > 0"
|
||||||
|
:channel-type="inboxChannelType"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<AttachmentPreviews
|
<AttachmentPreviews
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ const props = defineProps({
|
|||||||
hasAttachments: { type: Boolean, default: false },
|
hasAttachments: { type: Boolean, default: false },
|
||||||
sendWithSignature: { type: Boolean, default: false },
|
sendWithSignature: { type: Boolean, default: false },
|
||||||
messageSignature: { type: String, default: '' },
|
messageSignature: { type: String, default: '' },
|
||||||
|
channelType: { type: String, default: '' },
|
||||||
});
|
});
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
@@ -90,6 +91,10 @@ const replaceText = async message => {
|
|||||||
"
|
"
|
||||||
enable-variables
|
enable-variables
|
||||||
:show-character-count="false"
|
:show-character-count="false"
|
||||||
|
:signature="messageSignature"
|
||||||
|
allow-signature
|
||||||
|
:send-with-signature="sendWithSignature"
|
||||||
|
:channel-type="channelType"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
|
|||||||
@@ -302,7 +302,16 @@ function isBodyEmpty(content) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleEmptyBodyWithSignature() {
|
function handleEmptyBodyWithSignature() {
|
||||||
const { schema, tr } = state;
|
const { schema, tr, doc } = state;
|
||||||
|
|
||||||
|
const isEmptyParagraph = node =>
|
||||||
|
node && node.type === schema.nodes.paragraph && node.content.size === 0;
|
||||||
|
|
||||||
|
// Check if empty paragraph already exists to prevent duplicates when toggling signatures
|
||||||
|
if (isEmptyParagraph(doc.firstChild)) {
|
||||||
|
focusEditorInputField('start');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// create a paragraph node and
|
// create a paragraph node and
|
||||||
// start a transaction to append it at the end
|
// start a transaction to append it at the end
|
||||||
|
|||||||
Reference in New Issue
Block a user