From e9da85da40010eb1922c8735c01a08c92cbb1437 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20de=20Jager?= Date: Mon, 22 Jun 2026 11:45:16 +0200 Subject: [PATCH] fix(settings): respect the writing mode in the signature editor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The signature editor was always rich text, so a signature image was mangled into raw HTML when the account's writing mode was plain text. - Drive the signature editor's mode from the account's writing mode and re-encode the signature to the active format (HTML or plain text). - Warn before switching from rich text to plain text, since that drops formatting, inline images and links — including those in the signature. Fixes #7142 Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Joël de Jager --- src/components/EditorSettings.vue | 74 +++++++++++++++---- src/components/SignatureSettings.vue | 26 +++++-- .../components/SignatureSettings.vue.spec.js | 2 + 3 files changed, 81 insertions(+), 21 deletions(-) diff --git a/src/components/EditorSettings.vue b/src/components/EditorSettings.vue index f8889b85e4..7aae6865e5 100644 --- a/src/components/EditorSettings.vue +++ b/src/components/EditorSettings.vue @@ -8,20 +8,24 @@

-

@@ -31,6 +35,7 @@ diff --git a/src/components/SignatureSettings.vue b/src/components/SignatureSettings.vue index e5bdc18d27..280ea63389 100644 --- a/src/components/SignatureSettings.vue +++ b/src/components/SignatureSettings.vue @@ -28,8 +28,9 @@
@@ -66,8 +67,9 @@ import { mapStores } from 'pinia' import IconCheck from 'vue-material-design-icons/Check.vue' import TextEditor from './TextEditor.vue' import logger from '../logger.js' +import { EDITOR_MODE_HTML } from '../store/constants.js' import useMainStore from '../store/mainStore.js' -import { detect, toHtml } from '../util/text.js' +import { detect, toHtml, toPlain } from '../util/text.js' export default { name: 'SignatureSettings', @@ -98,6 +100,10 @@ export default { computed: { ...mapStores(useMainStore), + editorIsHtml() { + return this.account.editorMode === EDITOR_MODE_HTML + }, + identities() { const identities = this.account.aliases.map((alias) => { return { @@ -122,6 +128,10 @@ export default { }, watch: { + editorIsHtml() { + this.signature = this.formatSignature(this.signature) + }, + async signatureAboveQuote(val, oldVal) { try { await this.mainStore.patchAccount({ @@ -146,9 +156,15 @@ export default { changeIdentity(identity) { logger.debug('select identity', { identity }) this.identity = identity - this.signature = identity.signature - ? toHtml(detect(identity.signature)).value - : '' + this.signature = this.formatSignature(identity.signature) + }, + + formatSignature(signature) { + if (!signature) { + return '' + } + const detected = detect(signature) + return this.editorIsHtml ? toHtml(detected).value : toPlain(detected).value }, async deleteSignature() { diff --git a/src/tests/unit/components/SignatureSettings.vue.spec.js b/src/tests/unit/components/SignatureSettings.vue.spec.js index 7622c572ee..01aba87b5e 100644 --- a/src/tests/unit/components/SignatureSettings.vue.spec.js +++ b/src/tests/unit/components/SignatureSettings.vue.spec.js @@ -6,6 +6,7 @@ import { createLocalVue, shallowMount } from '@vue/test-utils' import SignatureSettings from '../../../components/SignatureSettings.vue' import Nextcloud from '../../../mixins/Nextcloud.js' +import { EDITOR_MODE_HTML } from '../../../store/constants.js' const localVue = createLocalVue() @@ -18,6 +19,7 @@ describe('SignatureSettings', () => { propsData: { account: { aliases: [], + editorMode: EDITOR_MODE_HTML, signature: String('

Lorem ipsum

').repeat(120000), }, },