Skip to content

Commit

Permalink
Add warning when enable/disable formatting
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Kesselberg <[email protected]>
  • Loading branch information
kesselb committed Aug 16, 2022
1 parent 5e927ee commit f6d9ad1
Showing 1 changed file with 32 additions and 11 deletions.
43 changes: 32 additions & 11 deletions src/components/Composer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@
<ActionCheckbox
:checked="!encrypt && !editorPlainText"
:disabled="encrypt"
@check="editorMode = 'html'"
@uncheck="editorMode = 'plaintext'">
@check="setEditorModeHtml"
@uncheck="setEditorModeText">
{{ t('mail', 'Enable formatting') }}
</ActionCheckbox>
<ActionCheckbox
Expand Down Expand Up @@ -434,7 +434,7 @@ import RecipientListItem from './RecipientListItem'
import UnfoldMoreHorizontal from 'vue-material-design-icons/UnfoldMoreHorizontal'
import UnfoldLessHorizontal from 'vue-material-design-icons/UnfoldLessHorizontal'
import { showError } from '@nextcloud/dialogs'
import { translate as t, getCanonicalLocale, getFirstDay, getLocale } from '@nextcloud/l10n'
import { getCanonicalLocale, getFirstDay, getLocale, translate as t } from '@nextcloud/l10n'
import Vue from 'vue'
import { findRecipient } from '../service/AutocompleteService'
Expand All @@ -447,12 +447,9 @@ import MailvelopeEditor from './MailvelopeEditor'
import { getMailvelope } from '../crypto/mailvelope'
import { isPgpgMessage } from '../crypto/pgp'
import { matchError } from '../errors/match'
import NoSentMailboxConfiguredError
from '../errors/NoSentMailboxConfiguredError'
import NoDraftsMailboxConfiguredError
from '../errors/NoDraftsMailboxConfiguredError'
import ManyRecipientsError
from '../errors/ManyRecipientsError'
import NoSentMailboxConfiguredError from '../errors/NoSentMailboxConfiguredError'
import NoDraftsMailboxConfiguredError from '../errors/NoDraftsMailboxConfiguredError'
import ManyRecipientsError from '../errors/ManyRecipientsError'
import Send from 'vue-material-design-icons/Send'
import SendClock from 'vue-material-design-icons/SendClock'
Expand All @@ -477,6 +474,9 @@ const STATES = Object.seal({
DISCARDED: 7,
})
const EDITOR_MODE_HTML = 'html'
const EDITOR_MODE_TEXT = 'plaintext'
export default {
name: 'Composer',
components: {
Expand Down Expand Up @@ -608,7 +608,7 @@ export default {
keyRing: undefined,
keysMissing: [],
},
editorMode: (this.body?.format !== 'html') ? 'plaintext' : 'html',
editorMode: (this.body?.format !== 'html') ? EDITOR_MODE_TEXT : EDITOR_MODE_HTML,
addShareLink: t('mail', 'Add share link from {productName} Files', { productName: OC?.theme?.name ?? 'Nextcloud' }),
requestMdn: false,
appendSignature: true,
Expand Down Expand Up @@ -689,7 +689,7 @@ export default {
return this.selectTo.length > 0 || this.selectCc.length > 0 || this.selectBcc.length > 0
},
editorPlainText() {
return this.editorMode === 'plaintext'
return this.editorMode === EDITOR_MODE_TEXT
},
submitButtonTitle() {
if (this.sendAtVal) {
Expand Down Expand Up @@ -1214,6 +1214,27 @@ export default {
this.showCC = !(this.showCC && this.selectCc.length === 0 && this.autoLimit)
this.showBCC = !(this.showBCC && this.selectBcc.length === 0 && this.autoLimit)
},
setEditorModeHtml() {
this.editorMode = EDITOR_MODE_HTML
},
setEditorModeText() {
OC.dialogs.confirmDestructive(
t('mail', 'Any existing formatting (for example bold, italic, underline or inline images) will be removed.'),
t('mail', 'Turn off formatting'),
{
type: OC.dialogs.YES_NO_BUTTONS,
confirm: t('mail', 'Turn off and remove formatting'),
confirmClasses: 'error',
cancel: t('mail', 'Keep formatting'),
},
(decision) => {
if (decision) {
this.bodyVal = toPlain(html(this.bodyVal)).value
this.editorMode = EDITOR_MODE_TEXT
}
},
)
},
},
}
</script>
Expand Down

0 comments on commit f6d9ad1

Please sign in to comment.