makepad/widgets/families/rich_text/Cargo.toml
AlexZ b25f797c2f rich_text: Markdown draws its inline images instead of an "Image[name: ...]" placeholder -- ![alt](src) now draws the picture through an inline_image Image item, loaded by the shared draw image cache and its existing paths: local paths and file:// URLs decode off the UI thread, data: URLs (base64 or percent-encoded) decode from their bytes, http(s) URLs go through the platform HTTP stack, and an SVG (a data: URL or a .svg file) is parsed by the Image widget's vector path. The picture is its natural size (a texel per point) scaled down to the text column; until it has loaded, and when it cannot load, its alt text stands in for it, and the Markdown relayouts when the decode lands. Network fetches are opt-in through the new load_http_images property (off by default) so an untrusted body makes no requests, and a restricted Splash loads no images at all, as it already emits no link URLs. Each image widget requests its source once; the cache already keeps textures across widget recreation. This replaces the original PR's own 1.3k-line pipeline (its private base64 decoder, per-widget then Cx-global LRU cache, negative cache and HTTP plumbing) with about 200 lines over the existing cache; not taken: its negative cache (a failed URL is requested again only when a new widget shows it) and SVG over HTTP. Checked on the Linux node (Vulkan, hidden --remote instance, grab): a local PNG, a 3000 px file:// PNG scaled to the column, a base64 PNG, a percent-encoded SVG, an SVG file and an HTTP PNG all draw inline; a missing file and an HTTP image with load_http_images off show their alt text; one HTTP request in total and the app idles at 0 % CPU afterwards.
Ported from makepad/makepad#1056.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-29 01:55:15 +02:00

17 lines
871 B
TOML

[package]
name = "makepad-widgets-rich-text"
version = "2.0.0"
authors = ["Makepad <info@makepad.nl>"]
edition = "2021"
description = "Makepad widgets: Text flow, rich text, HTML, Markdown, LaTeX maths and the log list"
license = "MIT OR Apache-2.0"
homepage = "https://github.com/makepad/makepad/"
repository = "https://github.com/makepad/makepad/"
[dependencies]
makepad-widgets-core = { path = "../../core", version = "2.0.0" }
makepad-html = { path = "../../../libs/html", version = "1.0.0" }
unicode-segmentation = { version = "1.12.0", path = "../../../libs/unicode/unicode-segmentation" }
pulldown-cmark = { version = "0.12.2", path = "../../../libs/pulldown-cmark", default-features = false, features = ["simd"] }
makepad-latex-math = { path = "../../../libs/latex_math", version = "0.1.0" }
makepad-base64 = { path = "../../../libs/base64", version = "1.0.0" }