mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-04 21:46:15 +03:00
Inline images: data-mx-emoticon height override
Change-Id: I3f1ab2aff5b17635600d76f4ca41fc539359b1ce
This commit is contained in:
parent
3c702b7230
commit
04cc69c206
1 changed files with 14 additions and 0 deletions
|
@ -67,6 +67,11 @@ class EventHtmlRenderer @Inject constructor(
|
|||
fun afterRender(renderedText: Spannable)
|
||||
}
|
||||
|
||||
private fun String.removeHeightWidthAttrs(): String {
|
||||
return replace(Regex("""height="([^"]*)""""), "")
|
||||
.replace(Regex("""width="([^"]*)""""), "")
|
||||
}
|
||||
|
||||
private fun buildMarkwon() = Markwon.builder(context)
|
||||
.usePlugins(listOf(
|
||||
HtmlPlugin.create(htmlConfigure),
|
||||
|
@ -78,6 +83,15 @@ class EventHtmlRenderer @Inject constructor(
|
|||
.blockQuoteColor(quoteBarColor)
|
||||
}
|
||||
},
|
||||
object : AbstractMarkwonPlugin() { // Overwrite height for data-mx-emoticon, to ensure emoji-like height
|
||||
override fun processMarkdown(markdown: String): String {
|
||||
return markdown
|
||||
.replace(Regex("""<img\s+([^>]*)data-mx-emoticon([^>]*)>""")) { matchResult ->
|
||||
"""<img height="1.2em" """ + matchResult.groupValues[1].removeHeightWidthAttrs() +
|
||||
" data-mx-emoticon" + matchResult.groupValues[2].removeHeightWidthAttrs() + ">"
|
||||
}
|
||||
}
|
||||
},
|
||||
GlideImagesPlugin.create(object: GlideImagesPlugin.GlideStore {
|
||||
override fun load(drawable: AsyncDrawable): RequestBuilder<Drawable> {
|
||||
val url = drawable.destination
|
||||
|
|
Loading…
Add table
Reference in a new issue