Skip to content

Comments

feat: Add signature and quotes in RichHtmlEditorWebview#2811

Open
solrubado wants to merge 13 commits intomainfrom
rich-editor
Open

feat: Add signature and quotes in RichHtmlEditorWebview#2811
solrubado wants to merge 13 commits intomainfrom
rich-editor

Conversation

@solrubado
Copy link
Contributor

No description provided.

@solrubado solrubado changed the title feature: Add signature and quotes in RichHtmlEditorWebview feat: Add signature and quotes in RichHtmlEditorWebview Feb 16, 2026
@sonarqubecloud
Copy link

@LunarX LunarX self-requested a review February 20, 2026 13:30
Copy link
Contributor

@LunarX LunarX left a comment

Choose a reason for hiding this comment

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

The textfield for the redaction has a different color than the background now. Also the placeholder and my signature are not displayed at all.

Edit: Ok it looks like it's more of an issue of some of the logic not loading in time instead.

In this before:
Image

On main:
Image

Comment on lines +29 to 34
fun emptyBody(placeHolderText: String) =
BodyContentPayload(
content = "<div id=$INFOMANIAK_BODY_HTML_ID><p class='placeholder'>$placeHolderText</p><br></div>",
type = BodyContentType.HTML_SANITIZED
)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

If we want to force it so we will always be using the same placeholder text, I'd rather have to pass the context as argument and factorize the string id logic inside this method

Comment on lines +16 to +18
.placeholder{
color: #b3b3b3;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We could adapt this value between light and dark mode to match the previous aspect

Copy link
Contributor

@LunarX LunarX left a comment

Choose a reason for hiding this comment

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

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

Comment on lines +434 to +435
fun editorHasPlaceholder() = with(binding.editorWebView) {
exportHtml { html -> hasPlaceholder = newMessageViewModel.bodyHasPlaceholder(html) }
Copy link
Contributor

@LunarX LunarX Feb 20, 2026

Choose a reason for hiding this comment

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

We could probably remove these exportHtml by displaying the placeholder using a TextView like it was done previously instead of having to deal with the html here which is heavy and adds unnecessary html logic

Copy link
Contributor

Choose a reason for hiding this comment

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

Also the signature changing logic's exportHtml could be replaced by a js script that will find the current signature's div and replace its content

Comment on lines +434 to 436
fun editorHasPlaceholder() = with(binding.editorWebView) {
exportHtml { html -> hasPlaceholder = newMessageViewModel.bodyHasPlaceholder(html) }
}
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to use a with() if the value is only accessed once

Comment on lines +447 to +448
private fun removePlaceholder() = with(binding.editorWebView) {
exportHtml { html ->
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to use a with() if the value is only accessed once

Comment on lines -138 to -140
loadWithOverviewMode = true
useWideViewPort = true

Copy link
Contributor

Choose a reason for hiding this comment

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

Right now, the behavior of the fragment webview has been modified compared to main which doesn't look necessary

} else {
quoteWebView.loadContent(quote, quoteGroup)
}
val script = context?.readRawResource(R.raw.toggle_quote_visibility_script)
Copy link
Contributor

Choose a reason for hiding this comment

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

Define this script like the others inside the companion object of HtmlFormatter

}

private fun WebView.loadSignatureContent(html: String, webViewGroup: Group) {
val processedHtml = webViewUtils.processSignatureHtmlForDisplay(html, context.isNightModeEnabled())
Copy link
Contributor

Choose a reason for hiding this comment

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

See if the method processSignatureHtmlForDisplay is still needed or not and remove its definiton if it's not useful.

Comment on lines +695 to +696
val script = context?.readRawResource(R.raw.toggle_quote_visibility_script)
script?.let { binding.editorWebView.addScript(script) }
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can create a new method for the redaction inside like processHtmlForPrint and the like. This method should use HtmlFormatter to centralize the html processing logic like adding scripts or css in a single place.

Take a look if we can also centralize the different css processing of the redaction webview as well as this script inside the HtmlFormatter

Comment on lines +36 to +40
return """
<div id="$INFOMANIAK_SIGNATURE_HTML_ID" class="$INFOMANIAK_SIGNATURE_HTML_CLASS_NAME" spellcheck="false" style="$verticalMarginAttributes">
$signatureContent
</div>
""".trimIndent()
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid logic that relies on these new ids (like INFOMANIAK_SIGNATURE_HTML_ID) and instead rely on INFOMANIAK_SIGNATURE_HTML_CLASS_NAME and such because they exist on the webmail as well and it lets us handle both webmail's drafts and app's drafts the same way

""".trimIndent()
}

suspend fun splitContentAndQuote(body: Body): SplitBody {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should be able to avoid splitting entirely if it comes from an existing draft. This will save us some performances

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants