feat: Add signature and quotes in RichHtmlEditorWebview#2811
feat: Add signature and quotes in RichHtmlEditorWebview#2811
Conversation
951b1be to
532e2be
Compare
|
| fun emptyBody(placeHolderText: String) = | ||
| BodyContentPayload( | ||
| content = "<div id=$INFOMANIAK_BODY_HTML_ID><p class='placeholder'>$placeHolderText</p><br></div>", | ||
| type = BodyContentType.HTML_SANITIZED | ||
| ) | ||
| } |
There was a problem hiding this comment.
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
| .placeholder{ | ||
| color: #b3b3b3; | ||
| } |
There was a problem hiding this comment.
We could adapt this value between light and dark mode to match the previous aspect
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
| fun editorHasPlaceholder() = with(binding.editorWebView) { | ||
| exportHtml { html -> hasPlaceholder = newMessageViewModel.bodyHasPlaceholder(html) } |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
| fun editorHasPlaceholder() = with(binding.editorWebView) { | ||
| exportHtml { html -> hasPlaceholder = newMessageViewModel.bodyHasPlaceholder(html) } | ||
| } |
There was a problem hiding this comment.
No need to use a with() if the value is only accessed once
| private fun removePlaceholder() = with(binding.editorWebView) { | ||
| exportHtml { html -> |
There was a problem hiding this comment.
No need to use a with() if the value is only accessed once
| loadWithOverviewMode = true | ||
| useWideViewPort = true | ||
|
|
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
See if the method processSignatureHtmlForDisplay is still needed or not and remove its definiton if it's not useful.
| val script = context?.readRawResource(R.raw.toggle_quote_visibility_script) | ||
| script?.let { binding.editorWebView.addScript(script) } |
There was a problem hiding this comment.
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
| return """ | ||
| <div id="$INFOMANIAK_SIGNATURE_HTML_ID" class="$INFOMANIAK_SIGNATURE_HTML_CLASS_NAME" spellcheck="false" style="$verticalMarginAttributes"> | ||
| $signatureContent | ||
| </div> | ||
| """.trimIndent() |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
We should be able to avoid splitting entirely if it comes from an existing draft. This will save us some performances





No description provided.