Skip to content

feat: add html and source editing support#12269

Merged
kesselb merged 2 commits into
mainfrom
add/html-source-editing
May 15, 2026
Merged

feat: add html and source editing support#12269
kesselb merged 2 commits into
mainfrom
add/html-source-editing

Conversation

@GretaD
Copy link
Copy Markdown
Contributor

@GretaD GretaD commented Jan 19, 2026

fixes #4557

Todos:

  • Clarify the scope of the feature; what do we want to support?
  • Add elements to allow list
  • Find out why saving, in the source view, does not work
  • Use proxy for images?

@GretaD GretaD self-assigned this Jan 19, 2026
@kesselb
Copy link
Copy Markdown
Contributor

kesselb commented Jan 23, 2026

Greta and I had a co-working call about HTML support for CKEditor.

The original issue is "Not able to configure a pure HTML signature without getting it defaced by the editor." By defaced I mean CKEditor rewrites the provided HTML markup to a version that only uses elements it allows. Some attributes, classes or style definitions are kept, others are silently dropped. This limits what users can do when designing their signatures.

For context, Outlook and Gmail also do not allow arbitrary HTML injection and provide a simple editor like we do. Thunderbird on the other hand allows full freedom in signatures and emails. I acknowledge that this is one of the issues in Mail that gets the most upvotes; I would rather not go too far down that rabbit hole though.

That said, we can break it down into actionable work packages.

  1. Saving from the source editor is currently broken and only works if you switch back from source to preview.

  2. According to https://ckeditor.com/docs/ckeditor5/latest/features/html/general-html-support.html#configuration we need a list of HTML elements we want to allow. For each element, it is possible to allow attributes, classes and style in general, or provide a list of valid values. I assume we would like to enable at least style so users can position elements as they like.

  3. Given the sheer number of style properties (https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties) I doubt we can cover everything with a allow list, though we haven't done full research. If we enable style in general without filtering, a user could for example use background with a URL. Because of our CSP policy that will not work. A similar case for img src was already requested in another issue. To make that fully work images must go through our proxy. It is possible to rewrite the HTML or intercept the loading, but that is a piece of code I would rather not maintain. For the first iteration we should ignore that case and let it remain broken.

@kesselb kesselb force-pushed the add/html-source-editing branch from 82b08aa to d4a8743 Compare January 23, 2026 17:18
@GretaD GretaD force-pushed the add/html-source-editing branch from 2468695 to 5dace15 Compare May 12, 2026 10:26
Comment thread src/components/TextEditor.vue Outdated
Comment thread src/components/TextEditor.vue
@GretaD GretaD force-pushed the add/html-source-editing branch from dc9cbd5 to e60ea28 Compare May 15, 2026 14:13
@kesselb kesselb force-pushed the add/html-source-editing branch from e60ea28 to 142b86a Compare May 15, 2026 15:29
@GretaD GretaD marked this pull request as ready for review May 15, 2026 15:32
@GretaD GretaD requested a review from ChristophWurst as a code owner May 15, 2026 15:32
@GretaD GretaD requested a review from kesselb May 15, 2026 15:35
@kesselb kesselb requested a review from Copilot May 15, 2026 16:10
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds HTML source-editing support to the rich-text editor by switching from DecoupledEditor to ClassicEditor, registering CKEditor's SourceEditing plugin, wiring a debounced input listener so edits in source mode propagate back to the editor, and broadening the HTML allow-list to include tables, figures, anchors, and image attributes/styles.

Changes:

  • Switch editor type to ClassicEditor and register the SourceEditing plugin/toolbar button.
  • Add register/unregister logic with a debounced input handler that calls SourceEditing.updateEditorData(), plus beforeDestroy cleanup.
  • Expand htmlSupport.allow rules and tweak signature settings dropdown max-width.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/components/TextEditor.vue Switches to ClassicEditor, adds SourceEditing plugin and debounced source-mode sync logic, expands HTML allow-list.
src/components/SignatureSettings.vue Reduces dropdown panel max-width and adds an explanatory comment.
src/tests/unit/components/TextEditor.spec.js Adds a unit test verifying source-edit input triggers updateEditorData().

Comment thread src/components/SignatureSettings.vue Outdated
Comment on lines +262 to +264
if (this.editorInstance?.plugins.has('SourceEditing') && this.sourceEditingModeHandler) {
this.editorInstance.plugins.get('SourceEditing').off('change:isSourceEditingMode', this.sourceEditingModeHandler)
}
Comment thread src/components/TextEditor.vue Outdated
Comment thread src/tests/unit/components/TextEditor.spec.js Outdated
AI-assisted: OpenCode (gpt-5.4)
AI-assisted: Claude Code (Claude Sonnet 4.6)

Signed-off-by: greta <gretadoci@gmail.com>
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
@kesselb kesselb force-pushed the add/html-source-editing branch from 142b86a to 0eaad6f Compare May 15, 2026 17:14
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
@kesselb kesselb enabled auto-merge May 15, 2026 17:59
@kesselb kesselb merged commit ab91317 into main May 15, 2026
53 of 58 checks passed
@kesselb kesselb deleted the add/html-source-editing branch May 15, 2026 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

General HTML support for message composer

3 participants