feat: Add signature and quotes in RichHtmlEditorWebview#2811
feat: Add signature and quotes in RichHtmlEditorWebview#2811
Conversation
951b1be to
532e2be
Compare
LunarX
left a comment
There was a problem hiding this comment.
Check if the computation of saveSnapshot and isSnapshotTheSame are correct when you open a new message, modify nothing and then leave. Because right now it saves a new draft everytime even when there are no modifications
34ee10e to
b9d10ac
Compare
LunarX
left a comment
There was a problem hiding this comment.
I haven't finished reviewing yet but here a some of the comments. We can review them together
LunarX
left a comment
There was a problem hiding this comment.
Some more comments the rest comes later
|
This PR/issue depends on: |
| */ | ||
|
|
||
| (function() { | ||
| var signatureElement = document.querySelector('.%s'); |
|
Failed to generate code suggestions for PR |
PR Reviewer Guide 🔍(Review updated until commit ca4cec7)Here are some key observations to aid the review process:
|
|
Failed to generate code suggestions for PR |
|
Persistent review updated to latest commit ca4cec7 |
|
Failed to generate code suggestions for PR |
…nt is already sanitized
… and remove empty spaces
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 49 out of 49 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| fun deleteInlineAttachments(cids: List<String>) { | ||
| val cidsToDelete = cids.map { it.removePrefix("cid:") } |
There was a problem hiding this comment.
deleteInlineAttachments() builds cidsToDelete as a List and then calls contains() inside a filter, making the removal O(n*m) for large attachment/cid lists.
Consider converting cidsToDelete to a Set before filtering so lookups are O(1).
| val cidsToDelete = cids.map { it.removePrefix("cid:") } | |
| val cidsToDelete = cids.mapTo(mutableSetOf()) { it.removePrefix("cid:") } |
| } | ||
|
|
||
| private fun Document.getElementPositionOrMax(className: String): Int { | ||
| return this.selectFirst(className)?.sourceRange()?.start()?.pos() ?: Int.MAX_VALUE |
There was a problem hiding this comment.
getElementPositionOrMax() relies on Element.sourceRange() to decide whether reply vs forward quotes come first. However JsoupParserUtil.jsoupParseWithLog() currently uses Jsoup.parse(value) without enabling source position tracking, so sourceRange() will be null and this will always return Int.MAX_VALUE, making the quote-splitting decision incorrect.
Consider either (a) switching parsing here to a jsoup Parser configured to track source positions, or (b) reverting to a string-index based approach (as was done previously) to pick the earliest quote block reliably.
| return this.selectFirst(className)?.sourceRange()?.start()?.pos() ?: Int.MAX_VALUE | |
| val element = this.selectFirst(className) ?: return Int.MAX_VALUE | |
| val documentHtml = outerHtml() | |
| val elementHtml = element.outerHtml() | |
| val position = documentHtml.indexOf(elementHtml) | |
| return if (position >= 0) position else Int.MAX_VALUE |
| // (the text could get hidden later with the show quotes button). | ||
| doc.removeEmptyElements(MessageBodyUtils.INFOMANIAK_REPLY_QUOTE_HTML_CLASS_NAME) | ||
| doc.removeEmptyElements(MessageBodyUtils.INFOMANIAK_FORWARD_QUOTE_HTML_CLASS_NAME) | ||
| return doc.html() |
There was a problem hiding this comment.
removeUnwantedHtml() returns doc.html(), which includes jsoup’s document-level wrappers (e.g. <head>…</head><body>…</body>). Since the editor typically works with an HTML fragment (body inner HTML), this can change what gets saved/sent and potentially introduce unexpected tags.
Consider returning the body fragment (doc.body().html()) or reusing the existing “unwrap document wrapping” logic (like EditorContentManager’s getHtmlWithoutDocumentWrapping()).
| return doc.html() | |
| return doc.body().html() |





Depends on Infomaniak/android-rich-html-editor#46