Skip to content

v2.5.0

Choose a tag to compare

@AuroraZiling AuroraZiling released this 22 Oct 07:17
· 9 commits to main since this release
510b6a0

v2.5.0 replaces CSharpMath with RaTeX for LaTeX rendering, and moves cross-block text selection into state shared per selection scope, so every renderer in a scope agrees on what is selected and whether it can be copied.

Important

The LiveMarkdown.Avalonia.Math package now renders formulas with RaTeX.Avalonia 1.0.0 and no longer depends on Sylinko.CSharpMath.Avalonia. Node registration, $...$ / $$...$$ syntax, style classes and the error-style selectors are unchanged, but formulas are laid out by a different engine, so expect visual differences.

Highlights

LaTeX rendering moves to RaTeX

  • MathInlineNode and MathBlockNode now share a MathPresenter that parses and lays out with Ratex.TryParseAndLayout and draws through RaTeX's FormulaControl; existing node registration code needs no changes.
  • Missing glyphs (CJK, emoji, other fallback scripts) are measured with Avalonia's font manager after the first layout pass and laid out again, so fallback text keeps its native position instead of being placed with estimated metrics.
  • Default-colored formulas follow the surrounding Foreground and light/dark theme switches, while explicit \textcolor{...} / {\color{...} ...} — including mid-expression — keep the color they ask for.
  • Inline formulas inherit the surrounding font size (headings, nested spans) and take their baseline from the rendered formula; display formulas keep their own size.
  • When parsing or layout fails, the source text replaces the previous formula, the Error class is applied, and the message is exposed as a tooltip; a partially streamed formula recovers on the next update.

Selection state shared per scope

  • A new internal MarkdownSelectionScope owns the selection for one scope root: range calculation, the drag snapshot, and the CanCopy flag live there, and MarkdownRenderer delegates to it instead of keeping a private copy.
  • CanCopy is published once per scope, so after any renderer in an IsSelectionScope container changes the selection the other renderers update too, and a menu bound to any of them stays correct.
  • The platform Select All gesture (Ctrl+A) now selects the whole visible scope. It was previously marked handled without selecting anything.
  • Renderers join, leave and re-parent scopes as the visual tree changes; removing a renderer, clearing the document or hiding a branch drops the selection it contributed instead of leaving CanCopy stuck on.
  • A drag is cancelled when the blocks it selected are removed or hidden, so a stale snapshot can no longer overwrite the selection.
  • MarkdownTextBlock now raises ContextRequested itself after its renderer handles the input, so a flyout attached closer to the text can bind Copy / SelectAll directly.
  • State synchronization no longer rescans the visual tree per update: with 5,000 unrelated blocks and 2,000 updates, it went from ~306 ms to ~0.04 ms, with zero allocations on the new path (state-sync stage only).

Demo and docs

  • The demo context flyout gains a Select All item next to Copy and opens at the pointer.
  • The LaTeX sample now covers RaTeX rendering: delimiters, CJK/emoji fallback, explicit and scoped colors, LaTeX font sizes, heading size inheritance, baseline alignment and wrapping, matrices and multiline layout.
  • README documents the shared CanCopy behavior and scope-wide Select All / Copy.

Compatibility

  • The public selection API is unchanged: SelectedText, CanCopy, SelectAll(), ClearSelection() and the compatibility shim SelectionScopeName behave as before, now over the shared scope.
  • The Math package no longer depends on Sylinko.CSharpMath.Avalonia; styles written against CSharpMath's MathView no longer apply. The documented selectors (MarkdownTextBlock.Math, MarkdownTextBlock.MathBlock, .Error) are unchanged.
  • Remove any direct Sylinko.CSharpMath.Avalonia reference from your app; no Math node API changed.

Full Changelog: v2.4.3...v2.5.0