From c640998276cfa10b64398e4415701a3fdcbc260d Mon Sep 17 00:00:00 2001 From: Kevin Boos Date: Wed, 10 Apr 2024 00:51:51 -0700 Subject: [PATCH 1/3] More rich Html message support: color, themeing for blocks, etc. Fixed underline/strikethrough and quote block / code block formatting. Support parsing of `data-mx-*` attributes (for ``/`` tags), but they're not fully displayed correctly just yet. --- Cargo.lock | 60 +++++++++--------- src/home/room_screen.rs | 3 +- src/shared/html_or_plaintext.rs | 108 +++++++++++++++++++++++++++++++- src/shared/styles.rs | 1 - 4 files changed, 137 insertions(+), 35 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index efc72441..b0c44b07 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1651,7 +1651,7 @@ checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "jni-sys" version = "0.4.0" -source = "git+https://github.com/makepad/makepad?branch=rik#9dc3f2dbd0d2b97df08eea07e270a3a055c63fe8" +source = "git+https://github.com/makepad/makepad?branch=rik#4fcffef1ebef737baee7dee885e8f349dde34669" [[package]] name = "js-sys" @@ -1833,7 +1833,7 @@ dependencies = [ [[package]] name = "makepad-derive-live" version = "0.4.0" -source = "git+https://github.com/makepad/makepad?branch=rik#9dc3f2dbd0d2b97df08eea07e270a3a055c63fe8" +source = "git+https://github.com/makepad/makepad?branch=rik#4fcffef1ebef737baee7dee885e8f349dde34669" dependencies = [ "makepad-live-id", "makepad-micro-proc-macro", @@ -1842,7 +1842,7 @@ dependencies = [ [[package]] name = "makepad-derive-wasm-bridge" version = "0.4.0" -source = "git+https://github.com/makepad/makepad?branch=rik#9dc3f2dbd0d2b97df08eea07e270a3a055c63fe8" +source = "git+https://github.com/makepad/makepad?branch=rik#4fcffef1ebef737baee7dee885e8f349dde34669" dependencies = [ "makepad-micro-proc-macro", ] @@ -1850,7 +1850,7 @@ dependencies = [ [[package]] name = "makepad-derive-widget" version = "0.4.0" -source = "git+https://github.com/makepad/makepad?branch=rik#9dc3f2dbd0d2b97df08eea07e270a3a055c63fe8" +source = "git+https://github.com/makepad/makepad?branch=rik#4fcffef1ebef737baee7dee885e8f349dde34669" dependencies = [ "makepad-live-id", "makepad-micro-proc-macro", @@ -1859,7 +1859,7 @@ dependencies = [ [[package]] name = "makepad-draw" version = "0.6.0" -source = "git+https://github.com/makepad/makepad?branch=rik#9dc3f2dbd0d2b97df08eea07e270a3a055c63fe8" +source = "git+https://github.com/makepad/makepad?branch=rik#4fcffef1ebef737baee7dee885e8f349dde34669" dependencies = [ "ab_glyph_rasterizer", "makepad-html", @@ -1873,17 +1873,17 @@ dependencies = [ [[package]] name = "makepad-futures" version = "0.4.0" -source = "git+https://github.com/makepad/makepad?branch=rik#9dc3f2dbd0d2b97df08eea07e270a3a055c63fe8" +source = "git+https://github.com/makepad/makepad?branch=rik#4fcffef1ebef737baee7dee885e8f349dde34669" [[package]] name = "makepad-futures-legacy" version = "0.7.0" -source = "git+https://github.com/makepad/makepad?branch=rik#9dc3f2dbd0d2b97df08eea07e270a3a055c63fe8" +source = "git+https://github.com/makepad/makepad?branch=rik#4fcffef1ebef737baee7dee885e8f349dde34669" [[package]] name = "makepad-html" version = "0.4.0" -source = "git+https://github.com/makepad/makepad?branch=rik#9dc3f2dbd0d2b97df08eea07e270a3a055c63fe8" +source = "git+https://github.com/makepad/makepad?branch=rik#4fcffef1ebef737baee7dee885e8f349dde34669" dependencies = [ "makepad-live-id", ] @@ -1891,12 +1891,12 @@ dependencies = [ [[package]] name = "makepad-http" version = "0.4.0" -source = "git+https://github.com/makepad/makepad?branch=rik#9dc3f2dbd0d2b97df08eea07e270a3a055c63fe8" +source = "git+https://github.com/makepad/makepad?branch=rik#4fcffef1ebef737baee7dee885e8f349dde34669" [[package]] name = "makepad-live-compiler" version = "0.5.0" -source = "git+https://github.com/makepad/makepad?branch=rik#9dc3f2dbd0d2b97df08eea07e270a3a055c63fe8" +source = "git+https://github.com/makepad/makepad?branch=rik#4fcffef1ebef737baee7dee885e8f349dde34669" dependencies = [ "makepad-derive-live", "makepad-live-tokenizer", @@ -1906,7 +1906,7 @@ dependencies = [ [[package]] name = "makepad-live-id" version = "0.4.0" -source = "git+https://github.com/makepad/makepad?branch=rik#9dc3f2dbd0d2b97df08eea07e270a3a055c63fe8" +source = "git+https://github.com/makepad/makepad?branch=rik#4fcffef1ebef737baee7dee885e8f349dde34669" dependencies = [ "makepad-live-id-macros", ] @@ -1914,7 +1914,7 @@ dependencies = [ [[package]] name = "makepad-live-id-macros" version = "0.4.0" -source = "git+https://github.com/makepad/makepad?branch=rik#9dc3f2dbd0d2b97df08eea07e270a3a055c63fe8" +source = "git+https://github.com/makepad/makepad?branch=rik#4fcffef1ebef737baee7dee885e8f349dde34669" dependencies = [ "makepad-micro-proc-macro", ] @@ -1922,7 +1922,7 @@ dependencies = [ [[package]] name = "makepad-live-tokenizer" version = "0.4.0" -source = "git+https://github.com/makepad/makepad?branch=rik#9dc3f2dbd0d2b97df08eea07e270a3a055c63fe8" +source = "git+https://github.com/makepad/makepad?branch=rik#4fcffef1ebef737baee7dee885e8f349dde34669" dependencies = [ "makepad-live-id", "makepad-math", @@ -1932,7 +1932,7 @@ dependencies = [ [[package]] name = "makepad-markdown" version = "0.4.0" -source = "git+https://github.com/makepad/makepad?branch=rik#9dc3f2dbd0d2b97df08eea07e270a3a055c63fe8" +source = "git+https://github.com/makepad/makepad?branch=rik#4fcffef1ebef737baee7dee885e8f349dde34669" dependencies = [ "makepad-live-id", ] @@ -1940,17 +1940,17 @@ dependencies = [ [[package]] name = "makepad-math" version = "0.4.0" -source = "git+https://github.com/makepad/makepad?branch=rik#9dc3f2dbd0d2b97df08eea07e270a3a055c63fe8" +source = "git+https://github.com/makepad/makepad?branch=rik#4fcffef1ebef737baee7dee885e8f349dde34669" [[package]] name = "makepad-micro-proc-macro" version = "0.4.0" -source = "git+https://github.com/makepad/makepad?branch=rik#9dc3f2dbd0d2b97df08eea07e270a3a055c63fe8" +source = "git+https://github.com/makepad/makepad?branch=rik#4fcffef1ebef737baee7dee885e8f349dde34669" [[package]] name = "makepad-micro-serde" version = "0.4.0" -source = "git+https://github.com/makepad/makepad?branch=rik#9dc3f2dbd0d2b97df08eea07e270a3a055c63fe8" +source = "git+https://github.com/makepad/makepad?branch=rik#4fcffef1ebef737baee7dee885e8f349dde34669" dependencies = [ "makepad-micro-serde-derive", ] @@ -1958,7 +1958,7 @@ dependencies = [ [[package]] name = "makepad-micro-serde-derive" version = "0.4.0" -source = "git+https://github.com/makepad/makepad?branch=rik#9dc3f2dbd0d2b97df08eea07e270a3a055c63fe8" +source = "git+https://github.com/makepad/makepad?branch=rik#4fcffef1ebef737baee7dee885e8f349dde34669" dependencies = [ "makepad-micro-proc-macro", ] @@ -1966,12 +1966,12 @@ dependencies = [ [[package]] name = "makepad-objc-sys" version = "0.4.0" -source = "git+https://github.com/makepad/makepad?branch=rik#9dc3f2dbd0d2b97df08eea07e270a3a055c63fe8" +source = "git+https://github.com/makepad/makepad?branch=rik#4fcffef1ebef737baee7dee885e8f349dde34669" [[package]] name = "makepad-platform" version = "0.6.0" -source = "git+https://github.com/makepad/makepad?branch=rik#9dc3f2dbd0d2b97df08eea07e270a3a055c63fe8" +source = "git+https://github.com/makepad/makepad?branch=rik#4fcffef1ebef737baee7dee885e8f349dde34669" dependencies = [ "jni-sys", "makepad-futures", @@ -1987,7 +1987,7 @@ dependencies = [ [[package]] name = "makepad-shader-compiler" version = "0.5.0" -source = "git+https://github.com/makepad/makepad?branch=rik#9dc3f2dbd0d2b97df08eea07e270a3a055c63fe8" +source = "git+https://github.com/makepad/makepad?branch=rik#4fcffef1ebef737baee7dee885e8f349dde34669" dependencies = [ "makepad-live-compiler", ] @@ -1995,7 +1995,7 @@ dependencies = [ [[package]] name = "makepad-vector" version = "0.4.0" -source = "git+https://github.com/makepad/makepad?branch=rik#9dc3f2dbd0d2b97df08eea07e270a3a055c63fe8" +source = "git+https://github.com/makepad/makepad?branch=rik#4fcffef1ebef737baee7dee885e8f349dde34669" dependencies = [ "ttf-parser", ] @@ -2003,7 +2003,7 @@ dependencies = [ [[package]] name = "makepad-wasm-bridge" version = "0.4.0" -source = "git+https://github.com/makepad/makepad?branch=rik#9dc3f2dbd0d2b97df08eea07e270a3a055c63fe8" +source = "git+https://github.com/makepad/makepad?branch=rik#4fcffef1ebef737baee7dee885e8f349dde34669" dependencies = [ "makepad-derive-wasm-bridge", "makepad-live-id", @@ -2012,7 +2012,7 @@ dependencies = [ [[package]] name = "makepad-widgets" version = "0.6.0" -source = "git+https://github.com/makepad/makepad?branch=rik#9dc3f2dbd0d2b97df08eea07e270a3a055c63fe8" +source = "git+https://github.com/makepad/makepad?branch=rik#4fcffef1ebef737baee7dee885e8f349dde34669" dependencies = [ "makepad-derive-widget", "makepad-draw", @@ -2025,7 +2025,7 @@ dependencies = [ [[package]] name = "makepad-windows" version = "0.51.1" -source = "git+https://github.com/makepad/makepad?branch=rik#9dc3f2dbd0d2b97df08eea07e270a3a055c63fe8" +source = "git+https://github.com/makepad/makepad?branch=rik#4fcffef1ebef737baee7dee885e8f349dde34669" dependencies = [ "windows-core 0.51.1 (git+https://github.com/makepad/makepad?branch=rik)", "windows-targets", @@ -2034,7 +2034,7 @@ dependencies = [ [[package]] name = "makepad-zune-core" version = "0.2.14" -source = "git+https://github.com/makepad/makepad?branch=rik#9dc3f2dbd0d2b97df08eea07e270a3a055c63fe8" +source = "git+https://github.com/makepad/makepad?branch=rik#4fcffef1ebef737baee7dee885e8f349dde34669" dependencies = [ "bitflags 2.4.1", ] @@ -2042,7 +2042,7 @@ dependencies = [ [[package]] name = "makepad-zune-inflate" version = "0.2.54" -source = "git+https://github.com/makepad/makepad?branch=rik#9dc3f2dbd0d2b97df08eea07e270a3a055c63fe8" +source = "git+https://github.com/makepad/makepad?branch=rik#4fcffef1ebef737baee7dee885e8f349dde34669" dependencies = [ "simd-adler32", ] @@ -2050,7 +2050,7 @@ dependencies = [ [[package]] name = "makepad-zune-jpeg" version = "0.3.17" -source = "git+https://github.com/makepad/makepad?branch=rik#9dc3f2dbd0d2b97df08eea07e270a3a055c63fe8" +source = "git+https://github.com/makepad/makepad?branch=rik#4fcffef1ebef737baee7dee885e8f349dde34669" dependencies = [ "makepad-zune-core", ] @@ -2058,7 +2058,7 @@ dependencies = [ [[package]] name = "makepad-zune-png" version = "0.2.1" -source = "git+https://github.com/makepad/makepad?branch=rik#9dc3f2dbd0d2b97df08eea07e270a3a055c63fe8" +source = "git+https://github.com/makepad/makepad?branch=rik#4fcffef1ebef737baee7dee885e8f349dde34669" dependencies = [ "makepad-zune-core", "makepad-zune-inflate", @@ -4756,7 +4756,7 @@ dependencies = [ [[package]] name = "windows-core" version = "0.51.1" -source = "git+https://github.com/makepad/makepad?branch=rik#9dc3f2dbd0d2b97df08eea07e270a3a055c63fe8" +source = "git+https://github.com/makepad/makepad?branch=rik#4fcffef1ebef737baee7dee885e8f349dde34669" dependencies = [ "windows-targets", ] diff --git a/src/home/room_screen.rs b/src/home/room_screen.rs index 06172e3a..6612040d 100644 --- a/src/home/room_screen.rs +++ b/src/home/room_screen.rs @@ -1080,7 +1080,8 @@ fn populate_message_view( } else { item.html_or_plaintext(id!(message)).show_plaintext(&text.body); } - new_drawn_status.content_drawn = true; + // new_drawn_status.content_drawn = true; + new_drawn_status.content_drawn = false; (item, false) } } diff --git a/src/shared/html_or_plaintext.rs b/src/shared/html_or_plaintext.rs index 9dab4327..b2495f53 100644 --- a/src/shared/html_or_plaintext.rs +++ b/src/shared/html_or_plaintext.rs @@ -1,6 +1,6 @@ //! A `HtmlOrPlaintext` view can display either plaintext or rich HTML content. -use makepad_widgets::*; +use makepad_widgets::{makepad_html::HtmlDoc, *}; live_design! { import makepad_draw::shader::std::*; @@ -9,8 +9,27 @@ live_design! { import makepad_widgets::theme_desktop_dark::*; import crate::shared::styles::*; + // These match the `MESSAGE_*` styles defined in `styles.rs`. + // For some reason, they're not the same. That's TBD. HTML_LINE_SPACING = 8.0 HTML_TEXT_HEIGHT_FACTOR = 1.3 + + + // This is an HTML subwidget used to handle `` and `` tags, + // specifically: foreground text color, background color, and spoilers. + MatrixHtmlSpan = {{MatrixHtmlSpan}}