fix: prepend signature instead of replacing email content

This commit is contained in:
Shariq Ansari 2024-06-11 12:26:26 +05:30
parent b634063f56
commit c625206076
2 changed files with 31 additions and 20 deletions

View File

@ -479,6 +479,7 @@
</div> </div>
<div class="flex gap-0.5"> <div class="flex gap-0.5">
<Tooltip :text="__('Reply')"> <Tooltip :text="__('Reply')">
<div>
<Button <Button
variant="ghost" variant="ghost"
class="text-gray-700" class="text-gray-700"
@ -486,8 +487,10 @@
> >
<ReplyIcon class="h-4 w-4" /> <ReplyIcon class="h-4 w-4" />
</Button> </Button>
</div>
</Tooltip> </Tooltip>
<Tooltip :text="__('Reply All')"> <Tooltip :text="__('Reply All')">
<div>
<Button <Button
variant="ghost" variant="ghost"
class="text-gray-700" class="text-gray-700"
@ -495,6 +498,7 @@
> >
<ReplyAllIcon class="h-4 w-4" /> <ReplyAllIcon class="h-4 w-4" />
</Button> </Button>
</div>
</Tooltip> </Tooltip>
</div> </div>
</div> </div>

View File

@ -144,16 +144,23 @@ const signature = createResource({
auto: true, auto: true,
}) })
function setSignature(editor) {
signature.data = signature.data.replace(/\n/g, '<br>')
let emailContent = editor.getHTML()
emailContent = emailContent.startsWith('<p></p>')
? emailContent.slice(7)
: emailContent
editor.commands.setContent(signature.data + emailContent)
editor.commands.focus('start')
}
watch( watch(
() => showEmailBox.value, () => showEmailBox.value,
(value) => { (value) => {
if (value) { if (value) {
newEmailEditor.value.editor.commands.focus() let editor = newEmailEditor.value.editor
editor.commands.focus()
if (!newEmail.value && signature.data) { setSignature(editor)
signature.data = signature.data.replace(/\n/g, '<br>')
newEmail.value = signature.data
}
} }
} }
) )