MarkdownWidget
Namespace: Hex1b.Widgets
Assembly: Hex1b.dll
A widget that parses markdown source and renders it as a composed widget tree. Block rendering is extensible via which registers middleware-style handler callbacks.
public sealed record MarkdownWidget : Hex1bWidget, IEquatable<Hex1bWidget>, IEquatable<MarkdownWidget>Inheritance
Object → Hex1bWidget → MarkdownWidget
Implements
Constructors
MarkdownWidget(IHex1bDocument)
Creates a that reads its content from an . The document's is used for efficient change detection; re-parsing only occurs when the version advances.
Parameters:
document(IHex1bDocument): The document to render as markdown.
public MarkdownWidget(IHex1bDocument document)MarkdownWidget(string)
A widget that parses markdown source and renders it as a composed widget tree. Block rendering is extensible via which registers middleware-style handler callbacks.
Parameters:
Source(String): The markdown source text.
public MarkdownWidget(string Source)Properties
Source
The markdown source text.
Returns: String
public string Source { get; init; }Methods
Focusable(bool)
Enables or disables focusable children (links) in the markdown content. When enabled, links become Tab-focusable and the containing scroll panel auto-scrolls to show the focused link.
Parameters:
children(Boolean): Whether child links should be focusable.
Returns: MarkdownWidget
public MarkdownWidget Focusable(bool children = false)OnBlock<TBlock>(Func<MarkdownBlockContext, TBlock, Hex1bWidget>)
Registers a handler for a specific block type. Multiple handlers for the same type form a middleware chain: the last registered is called first. Call within your handler to invoke the next handler in the chain (or the built-in default).
Parameters:
handler(Func<MarkdownBlockContext, <TBlock>, Hex1bWidget>): A function that receives the rendering context and the block, and returns a widget. Usectx.Default(block)to delegate to the next handler.
Returns: MarkdownWidget
public MarkdownWidget OnBlock<TBlock>(Func<MarkdownBlockContext, TBlock, Hex1bWidget> handler) where TBlock : MarkdownBlockOnImageLoad(MarkdownImageLoader)
Registers an image loader callback for rendering embedded images. The callback receives a (relative or absolute) and the alt text, and should return decoded RGBA pixel data, or null to fall back to text rendering.
Parameters:
loader(MarkdownImageLoader):
Returns: MarkdownWidget
public MarkdownWidget OnImageLoad(MarkdownImageLoader loader)OnLinkActivated(Action<MarkdownLinkActivatedEventArgs>)
Registers a synchronous handler for link activation events.
Parameters:
handler(Action<MarkdownLinkActivatedEventArgs>):
Returns: MarkdownWidget
public MarkdownWidget OnLinkActivated(Action<MarkdownLinkActivatedEventArgs> handler)OnLinkActivated(Func<MarkdownLinkActivatedEventArgs, Task>)
Registers an asynchronous handler for link activation events.
Parameters:
handler(Func<MarkdownLinkActivatedEventArgs, Task>):
Returns: MarkdownWidget
public MarkdownWidget OnLinkActivated(Func<MarkdownLinkActivatedEventArgs, Task> handler)