Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/components/Composer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ import Vue from 'vue'
import mitt from 'mitt'

import { findRecipient } from '../service/AutocompleteService.js'
import { detect, html, toHtml, toPlain } from '../util/text.js'
import { detect, html, plain, toHtml, toPlain } from '../util/text.js'
import logger from '../logger.js'
import TextEditor from './TextEditor.vue'
import { buildReplyBody } from '../ReplyBuilder.js'
Expand Down Expand Up @@ -925,6 +925,13 @@ export default {
},
bodyVal(val) {
this.$emit('update:editor-body', val)

const data = this.getMessageData()
if (data.isHtml) {
this.$emit('update:body', html(data.bodyHtml))
} else {
this.$emit('update:body', plain(data.bodyPlain))
}
},
attachments(val) {
this.$emit('update:attachments-data', val)
Expand Down
22 changes: 15 additions & 7 deletions src/components/NewMessageModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
@update:bcc="patchComposerData({ bcc: $event })"
@update:subject="patchComposerData({ subject: $event })"
@update:attachments-data="patchComposerData({ attachments: $event })"
@update:editor-body="patchEditorBody"
@update:body="patchEditorBody"
@update:send-at="patchComposerData({ sendAt: $event / 1000 })"
@update:smime-sign="patchComposerData({ smimeSign: $event })"
@update:smime-encrypt="patchComposerData({ smimeSign: $event })"
Expand Down Expand Up @@ -138,7 +138,7 @@ import { mapStores, mapState, mapActions } from 'pinia'
import RecipientInfo from './RecipientInfo.vue'
import useMainStore from '../store/mainStore.js'
import { messageBodyToTextInstance } from '../util/message.js'
import { toPlain } from '../util/text.js'
import { isHtml, isPlain, toPlain } from '../util/text.js'

export default {
name: 'NewMessageModal',
Expand Down Expand Up @@ -558,11 +558,19 @@ export default {

return composerData.bodyPlain
},
patchEditorBody(editorBody) {
if (this.composerData.isHtml) {
this.patchComposerData({ bodyHtml: editorBody })
} else {
this.patchComposerData({ bodyPlain: editorBody })
async patchEditorBody(body) {
if (isHtml(body)) {
await this.patchComposerData({
isHtml: true,
bodyHtml: body.value,
bodyPlain: undefined,
})
} else if (isPlain(body)) {
await this.patchComposerData({
isHtml: false,
bodyHtml: undefined,
bodyPlain: body.value,
})
}
},
updateCookedComposerData() {
Expand Down
Loading