Scale graphics with text and add click-to-enlarge previews - #29
Conversation
…ocus-ring bleed, themed overlay - Mermaid: take the snapshot only when the web view's frame matches the reported height. A diagram that first rendered below the fold posted its height (70 pt) while the un-placed cell still had the 200 pt default frame; the 646×200 bitmap (diagram + blank space) was cached under the scale/width key and, because #29 seeds `diagramHeight` from `cached.size.height`, every re-creation of the block pinned its row at 200 pt. The page's resize listener posts again once the frame catches up, and the snapshot fires then. Reproduced with log instrumentation, verified fixed on fresh open + scroll. - Preview: drop first responder before covering the document. AppKit draws focus rings above every view, so the sidebar collapse button (first responder after launch with keyboard navigation on) kept its ring visible through the overlay. - Preview: document theme background and text colour instead of the system background — a dark custom theme under a light appearance no longer opens a white panel. `GraphicPreview.diagram` carries the theme. - Fixture `QuickMD/test-image-scaling.md` moved out of the public tree into the local `test-files/` set (repo convention; images live next to it). - CHANGELOG (Added / Fixed, credit @arvearve #28 #29), README feature line. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017oPbKHjsi1HB3RWgxxFTKz
|
Merged locally with Follow-up on top of it (91aceb9), three things found in that run:
Also moved |
The SVG half of #30 without the WebKit renderer or any vendored library: the block's markup is handed to NSImage as data and CoreSVG draws it (`public.svg-image` is a supported NSImage type on every release we target; scripts and external references in the markup are ignored by the decoder, non-SVG text yields nil). - Parser: a ```svg fence (case-insensitive, like ```mermaid) becomes `.svgImage(source:)` with id "svg-N". - `Views/SVGBlockView.swift`: decodes off-main, shows the image scaled with the zoom through `BlockLayout.ImageBlock.displayWidth` (never wider than the column) but, unlike a bitmap, capped at its own declared size × zoom so icons stay icon-sized; click opens the #29 window-filling preview; undecodable markup shows a notice. - `SVGImageDecoder.swift`: the one decode shared by the block and by `PrintableSVGView` (print / PDF: a plain SwiftUI `Image`, so ImageRenderer draws it as a vector; garbage degrades to the styled code block like a failed Mermaid render). Kept out of the view file so the test target, which compiles model files only, can exercise it. - Measurer: `.reported` row seeded like `.image`; anchor signature "s|"; search skips SVG markup (a hit inside a path could be neither shown nor highlighted). - Tests: parser (svg / SVG fence → block, verbatim markup), decoder (declared size, viewBox-only, size-less, inert script, garbage, HTML), measurer fixture and kind checks include the new block. 195 tests. - README (Inline SVG feature line, tree, feature list), CHANGELOG (Added, suggested by @arvearve in #30). Verified in the app (Debug, AX-driven): declared 320×120 at 100 % → 400×150 at 125 %; a 1600-wide viewBox capped at 600 → column width at 125 %; a 24 pt icon → 30 pt; garbage → notice; linked .svg still renders; preview opens vector-sharp; PDF export shows the blocks as images and the garbage block as code. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017oPbKHjsi1HB3RWgxxFTKz
Graphics follow the zoom and open in a window-filling preview (#28/#29 @arvearve), ordered lists share one text edge (#27 @rosekanari), fenced ```svg blocks render natively, the 1.8.0 layout fallback is removed. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017oPbKHjsi1HB3RWgxxFTKz
|
Shipped in v1.10.0: https://github.com/b451c/quickmd/releases/tag/v1.10.0 - credited in the CHANGELOG and release notes. Thank you! |
Embedded images and Mermaid diagrams previously kept fixed dimensions when document text size changed. This change scales graphics and image captions with the text, and lets readers click either graphic type to open a window-filling preview.
Closes #28.
Changes
QuickMD/test-image-scaling.md, an image-width regression test, and a standalone WebKit check using the actual Mermaid template.Validation
swift scripts/check-mermaid-scaling.swiftpassed proportional scaling, narrow-column shrinking, and preview-fit checks. Before the fix, Mermaid remained 356 points wide at 75%, 100%, and 150%; afterward it measured 267, 356, and 534 points.Inline enlargement stops at the column width; clicking opens the preview using the available window space.