AI
AiMarkdownView
BitAiMarkdownView renders a parsed Markdown document: the prose of an assistant message, with its code blocks, tables, task lists, footnotes, mathematics and inline citation markers. It takes an already-parsed document rather than a string, so the caller decides how parsing happens - BitAiStreamingMarkdown reuses an incremental parser across deltas, a static caller parses once with BitAiMarkdownParser. Model output is untrusted, so raw HTML is escaped unless it is opted into, link and image URLs of a scheme that can run script are neutralised, and images follow the image policy of the options. Fenced code in a language the app registered (a chart, a diagram) and mathematics defer to renderers of the app's own.
Notes
Usage
Every example is live. Open its code to see exactly what produced the component running underneath.
Basic
Choosing a render mode
Blazor renders on the server, over a circuit, or in the browser, on WebAssembly - and one size fits all each page can pick its own. Start with the docs or https://blazorui.bitplatform.dev, and set it with @rendermode.
Measure the first paint.
Measure the cost of every update:
on the server, in messages;
in the browser, in milliseconds.
Blocks
| Mode | Runs on | First paint | Offline |
|---|---|---|---|
| Server | The server, over a circuit | Fast | No |
| WebAssembly | The browser | Slower | Yes |
Rendering more often than the eye can follow is not smoother. It is just louder.
Pick a render mode
Measure the first paint
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();Streaming caret
The answer is still being written, so its last paragraph is open
Install the package:
dotnet add package Bit.BlazorUI.AIFootnotes & headings
Mathematics
The energy of a body at rest is E = mc^2, and the area of a circle is \pi r^2.
\sigma = \sqrt{\sum_{i=1}^{n} (x_i - \mu)^2 / n}Code languages
Where the time of a first visit goes:
And of a second visit:
Citations
Interactive Server keeps component state on the server and streams UI diffs over a SignalR circuit . If that circuit drops, the state goes with it unless you have persisted it yourself . A number no citation has, such as [3], stays the text it is.
Custom citation chip
Interactive Server keeps component state on the server and streams UI diffs over a SignalR circuit . If that circuit drops, the state goes with it unless you have persisted it yourself . A number no citation has, such as [3], stays the text it is.
Images
From this site: 
From a listed host: 
From another host: ![]()
Inline:
Untrusted content
A link a model was talked into: claim your prize.
Press <kbd>Ctrl</kbd> + <kbd>K</kbd> to search.
<details><summary>An HTML block</summary>Rendered as markup only when raw HTML is allowed.</details>
Markdown options
| Option | Default |
|---|---|
| Tables | on |
a task that is done
one that is not
Struck through, a bare URL https://bitplatform.dev and x^2. One line, and the next.
A cited claim and a footnote1.
Listed under the text.
↩
More of the syntax
A heading underlined
A link with a title: the docs, and a reference link whose address is given further down. https://www.bitplatform.dev, https://github.com/bitfoundation/bitplatform and mailto:[email protected] are links too.
A backslash at the end of a line
breaks it. Escapes keep *stars* and [brackets] as they are, and entities read as their characters: © → €.
An indented block is code: dotnet runA numbered list may start at any number
and counts on from there.
The document tree
Install
Add the package to the project:
dotnet add package Bit.BlazorUI.AIRegister
Register the services once, at startup:
csharpbuilder.Services.AddBitBlazorUIAIServices();
Then put a chat on a page:
razor<BitAiChat />
- level 2, "Install", id guide-bit-ai-h-install
- level 2, "Register", id guide-bit-ai-h-register
- bash, 1 line(s)
- csharp, 1 line(s)
- razor, 1 line(s)
Cascading parameters
A link of a view inside the BitParams, such as this one, is bold - unless its view sets Styles of its own.
A link of a view inside the BitParams, such as this one, is bold - unless its view sets Styles of its own.
Style & Class
RTL
دو حالت رندر
بلیزر روی سرور یا در مرورگر رندر میکند:
روی سرور، از راه یک اتصال؛
در مرورگر، روی WebAssembly.
رندر بیشتر از آنچه چشم میبیند، روانتر نیست.
| حالت | اجرا | نخستین نمایش |
|---|---|---|
| سرور | روی سرور | سریع |
| وباسمبلی | در مرورگر | کندتر |
CSS variables
The public custom properties this component reads off its root, for what no parameter covers.
Every variable is read with a fallback and never declared by the component, so it inherits like any other custom property:
set one on :root (or in a [bit-theme] block) to restyle every instance, on any ancestor to restyle the ones inside it,
or on the Style of one instance to restyle it - and any instance nested inside it, which inherits the value too; a parameter changes one alone,
as does the real CSS property on the instance's Style / Styles when that property does not inherit (opacity: 1 keeps
one disabled instance undimmed without undimming a disabled one inside it), while an inherited one such as color or
font-family also reaches the nested instances that do not set it themselves. Leave a variable unset and the component
falls back to the theme token beside it.
BitAiMarkdownView CSS variables
| Name | Default value | Description |
|---|---|---|
| --bit-AiMarkdownView-color | inherit | Text color of the prose. |
| --bit-AiMarkdownView-font-size | inherit | Text size of the prose. |
| --bit-AiMarkdownView-line-height | 1.6 | Line height of the prose. |
| --bit-AiMarkdownView-block-spacing | spacing(2) | Room between two blocks (paragraphs, lists, tables, code blocks, ...); a heading gets one and a half times as much above it. |
| --bit-AiMarkdownView-heading-color | inherit | Text color of the headings. |
| --bit-AiMarkdownView-heading-font-weight | var(--bit-tpg-fw-semibold) | Weight of the headings. |
| --bit-AiMarkdownView-link-color | var(--bit-clr-pri-fg) | Text color of the links (and of the footnote links). |
| --bit-AiMarkdownView-link-hover-color | the link color | Text color of a link under the pointer. |
| --bit-AiMarkdownView-code-color | inherit | Text color of the code spans and of the mathematics fallback. |
| --bit-AiMarkdownView-code-background | 8% of var(--bit-clr-fg-pri) | Background of the code spans and of the mathematics fallback: a translucent wash of the text color, so it reads on whatever the message sits on. |
| --bit-AiMarkdownView-code-radius | var(--bit-shp-radius-sm) | Corner radius of the code spans and of the mathematics fallback. |
| --bit-AiMarkdownView-code-font-family | var(--bit-tpg-font-family-mono) | Font of the code spans and of the mathematics fallback. |
| --bit-AiMarkdownView-marker-color | var(--bit-clr-fg-ter) | Bullets and numbers of the lists. |
| --bit-AiMarkdownView-quote-color | var(--bit-clr-fg-sec) | Text color of the block quotes. |
| --bit-AiMarkdownView-quote-border-color | var(--bit-clr-brd-pri) | Bar down the start edge of the block quotes. |
| --bit-AiMarkdownView-rule-color | var(--bit-clr-brd-sec) | Thematic breaks, and the line above the footnotes. |
| --bit-AiMarkdownView-table-border-color | var(--bit-clr-brd-sec) | Border of the tables and of their rows. |
| --bit-AiMarkdownView-table-header-background | 4% of var(--bit-clr-fg-pri) | Background of the header row of the tables. |
| --bit-AiMarkdownView-table-font-size | var(--bit-tpg-fs-sm) | Text size of the tables. |
| --bit-AiMarkdownView-table-radius | var(--bit-shp-radius-surface) | Corner radius of the tables. |
| --bit-AiMarkdownView-image-radius | var(--bit-shp-radius-surface) | Corner radius of the images. |
| --bit-AiMarkdownView-muted-color | var(--bit-clr-fg-sec) | The footnotes, and the alternative text of a blocked image. |
| --bit-AiMarkdownView-caret-color | var(--bit-clr-pri) | The caret after streaming text. |
| --bit-AiMarkdownView-scroll-margin | spacing(3) | Room kept above a heading, a footnote or a footnote reference an in-page link scrolls to - the height of a sticky app bar, so what the link leads to is not left under it. |
API
Every parameter, public member, sub-class and enum this component exposes.
BitAiMarkdownView parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| Citations | IReadOnlyList<BitAiCitation>? | null | The citations that the inline citation markers of the document resolve against. A marker whose number matches the Number of a citation is drawn as a BitAiCitationMarker - or by the BitAiRendererRegistry.CitationRenderer, when the app registered one - unless BitAiUiOptions.InlineCitations is off; one that matches none stays the literal text it was. |
| Classes | BitAiMarkdownViewClassStyles? | null | Custom CSS classes for different parts of the Markdown view. |
| Document | BitAiMarkdownDocument? | null | The parsed document to render (BitAiMarkdownParser.Parse, or the incremental parser a BitAiStreamingMarkdown holds). Nothing is rendered while it is null. It is a public tree of blocks and inlines an app can read too (see The document tree). |
| OnCitationClick | EventCallback<BitAiCitation> | The callback for when the user activates an inline citation marker, with the citation it stands for. A chip drawn by a registered CitationRenderer is handed it as the OnActivate of its BitAiCitationContext, which the chip raises through ActivateAsync(). | |
| ShowCaret | bool | false | Draws a caret at the end of the text while the document is still being written (parsed with isComplete false), the sign that more text is on its way: after the paragraph or the heading being written, in a list item just started, and after the blocks - where the next one will start - when the text so far ends in a code block, a table or a blank line. BitAiUiOptions.ShowStreamingCaret turns the caret off for every view at once. |
| Styles | BitAiMarkdownViewClassStyles? | null | Custom CSS styles for different parts of the Markdown view. |
BitComponentBase parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| AriaLabel | string? | null | Gets or sets the accessible label for the component, used by assistive technologies. |
| Class | string? | null | Gets or sets the CSS class name(s) to apply to the rendered element. |
| Dir | BitDir? | null | Gets or sets the text directionality for the component's content. |
| Disabled | bool | false | Gets or sets a value indicating whether the component is disabled and cannot respond to user interaction. |
| ForceAnimation | bool | false | Gets or sets a value indicating whether the component's animations play at their full duration even when reduced motion is requested. |
| HtmlAttributes | Dictionary<string, object> | new Dictionary<string, object>() | Captures additional HTML attributes to be applied to the rendered element, in addition to the component's parameters. An attribute written on the component wins over an entry of the same name. |
| Id | string? | null | Gets or sets the unique identifier for the component's root element. |
| Style | string? | null | Gets or sets the CSS style string to apply to the rendered element. |
| TabIndex | string? | null | Gets or sets the tab order index for the component when navigating with the keyboard. |
| Visibility | BitVisibility | BitVisibility.Visible | Gets or sets the visibility state (visible, hidden, or collapsed) of the component. |
BitComponentBase public members
| Name | Type | Default value | Description |
|---|---|---|---|
| UniqueId | Guid | Guid.NewGuid() | Gets the readonly unique identifier for the component's root element, assigned when the component instance is constructed. |
| RootElement | ElementReference | Gets the reference to the root HTML element associated with this component. |
BitAiMarkdownViewClassStyles properties
| Name | Type | Default value | Description |
|---|---|---|---|
| Root | string? | null | Custom CSS classes/styles for the root element of the BitAiMarkdownView. |
| Paragraph | string? | null | Custom CSS classes/styles for every paragraph of the BitAiMarkdownView. |
| Heading | string? | null | Custom CSS classes/styles for every heading of the BitAiMarkdownView. |
| List | string? | null | Custom CSS classes/styles for every list (bulleted, numbered or task list) of the BitAiMarkdownView. |
| ListItem | string? | null | Custom CSS classes/styles for every list item of the BitAiMarkdownView. |
| Quote | string? | null | Custom CSS classes/styles for every block quote of the BitAiMarkdownView. |
| TableContainer | string? | null | Custom CSS classes/styles for the scroll container of every table of the BitAiMarkdownView, which also draws its frame. |
| Table | string? | null | Custom CSS classes/styles for every table of the BitAiMarkdownView. |
| Separator | string? | null | Custom CSS classes/styles for every thematic break (horizontal rule) of the BitAiMarkdownView. |
| InlineCode | string? | null | Custom CSS classes/styles for every inline code span of the BitAiMarkdownView. |
| Link | string? | null | Custom CSS classes/styles for every link of the BitAiMarkdownView. |
| Image | string? | null | Custom CSS classes/styles for every image of the BitAiMarkdownView. |
| ImagePlaceholder | BitActionButtonClassStyles? | null | Custom CSS classes/styles for the button (a BitActionButton) the BitAiMarkdownView shows in place of an image the image policy loads only on request. |
| BlockedImage | string? | null | Custom CSS classes/styles for the alternative text the BitAiMarkdownView shows in place of an image the image policy blocks. |
| Math | string? | null | Custom CSS classes/styles for the built-in rendering of every mathematical expression of the BitAiMarkdownView (not used while a MathRenderer is registered). |
| FootnoteReference | string? | null | Custom CSS classes/styles for every footnote reference of the BitAiMarkdownView. |
| Footnotes | string? | null | Custom CSS classes/styles for the footnotes section of the BitAiMarkdownView. |
| Caret | string? | null | Custom CSS classes/styles for the caret the BitAiMarkdownView draws after streaming text. |
BitAiMarkdownParser properties
Parses Markdown into the BitAiMarkdownDocument the view renders: a CommonMark subset with the GitHub-flavoured extensions models write (tables, task lists, strikethrough, autolinks, footnotes, mathematics), built to parse a half-written answer many times a second rather than for conformance. Every block records whether the source ended inside it, which is what keeps streaming settled. A text with link reference or footnote definitions is parsed twice - once to collect them, once to resolve the references - since a definition may follow the text that uses it. For text that grows, the BitAiIncrementalMarkdownParser a BitAiStreamingMarkdown holds (see its page) reuses the work done for the text already seen.
| Name | Type | Default value | Description |
|---|---|---|---|
| Parse(string? markdown, BitAiMarkdownOptions? options = null, bool isComplete = true) | BitAiMarkdownDocument | Parses the Markdown with the given extensions (BitAiMarkdownOptions.Default when null). isComplete false marks the trailing block open: more text is expected. A null or empty source is an empty document. |
BitAiInlineParser properties
Parses the inline content of one block - emphasis, strikethrough, code spans, links, images, mathematics, footnote references and citation markers - for an app that shows a line of model text (a title, a label) without the blocks around it. The block parser runs it on every paragraph, heading and table cell.
| Name | Type | Default value | Description |
|---|---|---|---|
| Parse(string? text, BitAiMarkdownOptions? options = null, bool isComplete = true) | List<BitAiMarkdownInline> | The inlines of the text, with the given extensions (BitAiMarkdownOptions.Default when null). isComplete false - more text expected - leaves an unmatched emphasis or code delimiter at the end out rather than showing it. Reference links and footnotes need the definitions of a whole document, so they are not resolved here. A null or empty text has none. |
BitAiMarkdownDocument properties
A parsed document: what BitAiMarkdownParser.Parse returns and the view renders, itself a BitAiMarkdownBlock. Its blocks are a tree of BitAiMarkdownBlock nodes (paragraphs, headings, lists, quotes, tables, fenced code, mathematics, ...) whose text is BitAiMarkdownInline nodes - a public tree an app can walk (see The document tree).
| Name | Type | Default value | Description |
|---|---|---|---|
| Blocks | List<BitAiMarkdownBlock> | [] | The blocks of the document, in order. |
| Footnotes | List<BitAiFootnoteBlock> | [] | The footnotes the text cites, in the order they are first cited and numbered from one; a definition nobody cites is dropped. The view lists them after the blocks, each with a link back to every reference to it. |
| IsOpen | bool | false | Whether the document was parsed with more text expected (isComplete false), whatever its last block is - the condition for the caret of ShowCaret. |
| Empty | BitAiMarkdownDocument | Static: an empty document. |
BitAiMarkdownBlock properties
The base of every block of a document (a BitAiMarkdownNode, the base of every node). The parser fills the blocks in; to an app they are read-only. The block types it produces are listed under its one member.
| Name | Type | Default value | Description |
|---|---|---|---|
| IsOpen | bool | false | True when the block may still grow because the source ended inside it. A renderer defers on it what would flicker: an open fenced block is not highlighted, and the caret follows an open paragraph or heading. |
| BitAiParagraphBlock | sealed class | A run of text ended by a blank line or another block: Inlines (List<BitAiMarkdownInline>). | |
| BitAiHeadingBlock | sealed class | A heading: Level (int, 1 to 6; the view renders it one level lower, so a # is an h2), Inlines, and Id (string? - bit-ai-h-<slug> while HeadingIds is on, which the view renders after its own id). | |
| BitAiCodeBlock | sealed class | A code block: Code (string, without the fences), Language (string?, from the info string) and Meta (string?, the rest of the info string), and IsFenced (bool: fenced with ``` or ~~~, or indented by four spaces). | |
| BitAiListBlock | sealed class | A bulleted or numbered list: IsOrdered (bool), Start (int, the first number of a numbered list), IsLoose (bool, items separated by blank lines and spaced apart) and Items (List<BitAiListItemBlock>). | |
| BitAiListItemBlock | sealed class | An item of a list: IsChecked (bool? - the checkbox of a task-list item, null for an item without one) and Blocks (List<BitAiMarkdownBlock>). | |
| BitAiQuoteBlock | sealed class | A block quote: Blocks (List<BitAiMarkdownBlock>). | |
| BitAiTableBlock | sealed class | A pipe table: Header (List<List<BitAiMarkdownInline>>, the inlines of each header cell), Rows (List<List<List<BitAiMarkdownInline>>>, the cells of each body row) and Alignments (List<BitAiColumnAlignment>, one per column). | |
| BitAiThematicBreakBlock | sealed class | A horizontal rule (---, *** or ___), with no member of its own. | |
| BitAiFootnoteBlock | sealed class | A footnote the text cites, listed on the Footnotes of the document: Label (string, as written, without the caret), Number (int, its position in the list), ReferenceCount (int, how many references cite it, each with a back-link) and Blocks. | |
| BitAiMathBlock | sealed class | Displayed mathematics ($$...$$): Expression (string, without the delimiters). | |
| BitAiHtmlBlock | sealed class | A block of raw HTML, read only while AllowRawHtml is on (otherwise the markup is text of a paragraph): Html (string). |
BitAiMarkdownInline properties
The base of every inline node - the text of a paragraph, a heading, a list item or a table cell (a BitAiMarkdownNode too). The inline types the parser produces, filled in by it and read-only to an app:
| Name | Type | Default value | Description |
|---|---|---|---|
| BitAiTextInline | sealed class | Literal text: Text (string), which is also its ToString(). | |
| BitAiEmphasisInline | sealed class | Emphasised text: IsStrong (bool: true for **strong**, false for *ordinary*) and Inlines. | |
| BitAiStrikethroughInline | sealed class | Struck-through text (~~...~~): Inlines. | |
| BitAiCodeInline | sealed class | A code span: Code (string). | |
| BitAiLinkInline | sealed class | A link: Url (string, as written - the view renders it only when its scheme is safe), Title (string?), Inlines (the link text) and IsAutoLink (bool: a bare or angle-bracketed address rather than [text](url)). | |
| BitAiImageInline | sealed class | An image: Url (string), Alt (string, the alternative text) and Title (string?). The view loads it under the image policy. | |
| BitAiLineBreakInline | sealed class | A line break inside a paragraph: IsHard (bool - true for a backslash or two spaces at the end of the line, and for every break under SoftBreaksAsHardBreaks; a soft one renders as a space). | |
| BitAiMathInline | sealed class | Inline mathematics ($...$): Expression (string, without the delimiters). | |
| BitAiCitationMarkerInline | sealed class | A citation marker written [n] (with CitationMarkers on): Number (int) - what the Citations of the view resolve it against - and CitationId (string?). | |
| BitAiFootnoteReferenceInline | sealed class | A footnote reference written [^label]: Label (string), Number (int, assigned in the order the footnotes are first cited) and Ordinal (int, which reference to the footnote it is, from one). | |
| BitAiRawHtmlInline | sealed class | Raw inline HTML, read only while AllowRawHtml is on (otherwise the markup is text): Html (string). An element closed later in the same text is one inline, its content included (<kbd>Ctrl</kbd>). The view renders it as markup only while the options in force allow raw HTML too, and as text otherwise. |
BitAiMarkdownOptions properties
Which Markdown extensions to enable and how to treat untrusted markup - a record handed to BitAiMarkdownParser.Parse, and the Markdown of BitAiUiOptions, which a BitAiStreamingMarkdown parses with and every view reads AllowRawHtml from. The defaults are what an AI chat wants: the GitHub-flavoured extensions on, raw HTML off. BitAiMarkdownOptions.Default holds them.
| Name | Type | Default value | Description |
|---|---|---|---|
| Tables | bool | true | Parse pipe tables. |
| Strikethrough | bool | true | Parse strikethrough written with double tildes. |
| TaskLists | bool | true | Parse task-list checkboxes in list items. The view draws them disabled: they show what the model wrote, nothing of the page can change them. |
| AutoLinks | bool | true | Turn bare URLs into links. |
| Math | bool | true | Parse dollar-delimited mathematics ($inline$ and $$display$$). |
| CitationMarkers | bool | true | Turn bracketed digit runs such as [3] into citation markers, which the Citations of the view resolve. |
| AllowRawHtml | bool | false | Keep raw HTML as markup instead of escaping it. The view renders it only when the options in force (BitAiUiOptions.Markdown) allow it too. Leave it off unless the Markdown comes from a source you trust as much as your own code: a model can be talked into emitting a script tag. |
| HeadingIds | bool | true | Give headings anchor ids derived from their text (bit-ai-h-<slug>, numbered -2, -3, ... when a text repeats), which the view renders after its own id. |
| HideDanglingDelimiters | bool | true | Hide a trailing unmatched emphasis or code delimiter while the text is still streaming, so a bold run does not flash a literal asterisk before its closing one arrives - in a paragraph and in a heading being written alike. With Tables on, the header row of a table whose delimiter row has not arrived yet is held back the same way, rather than shown as a line of pipes. |
| MaxNestingDepth | int | 32 | How deeply blocks and inline spans may nest before further markers are read as literal text - a bound on the parser's recursion and on the tree the view walks, so a line of ten thousand > cannot take the process down. |
| SoftBreaksAsHardBreaks | bool | false | Treat a single newline inside a paragraph as a line break, as chat clients often do (CommonMark renders it as a space). |
| Footnotes | bool | true | Parse footnotes: [^1] in the text with a matching [^1]: note definition. |
BitAiImagePolicy properties
Which images are fetched - the Images of BitAiUiOptions, which the images of the Markdown follow, and the image parts, the image and SVG artifacts and the favicons of sources too (a favicon only when the policy shows it outright, never as a placeholder). A model can be talked into emitting an image URL, and a browser fetching it leaks the reader's address and the fact that they read the message to whoever controls the host. The default allows images; a host handling sensitive conversations restricts them to its own CDN, asks before loading, or blocks them. Script-capable URL schemes are neutralised whatever the policy.
| Name | Type | Default value | Description |
|---|---|---|---|
| Allow | BitAiImagePolicy | Static: shows every image whose URL scheme is safe. The default policy. | |
| Block | BitAiImagePolicy | Static: shows no remote image (nor a data image); each one is replaced by its alternative text. | |
| ClickToLoad | BitAiImagePolicy | Static: loads each remote image only when the reader activates its placeholder. | |
| AllowListedHosts(params string[] hosts) | BitAiImagePolicy | Static: shows the remote images of the given hosts (compared without regard to case; a leading *. matches subdomains) and a click-to-load placeholder for the rest. A relative URL is fetched from the host of the document's base address, which is what the views ask about it: list the app's own host to show its images. | |
| AllowDataImages | bool | true | Whether inline data: images are shown. They involve no network request, so they are shown under every policy but Block while this is on. |
| Hosts | IReadOnlyCollection<string> | [] | The hosts allowed under AllowListedHosts. |
| Mode | BitAiImageMode | BitAiImageMode.Allow | How images are treated. |
| Decide(string url) | BitAiImageDecision | Decides what to do with one image source (already checked for a safe scheme): show it, show a placeholder that loads it on request, or hide it. The views ask about the address the browser fetches - a relative or protocol-relative source resolved against the document's base address; a source handed to it still relative has no host, so no host list shows it. |
BitAiMathContext properties
What a mathematics renderer is handed. The renderer is a BitAiMathRenderer - delegate RenderFragment BitAiMathRenderer(BitAiMathContext context) - set as BitAiRendererRegistry.MathRenderer, which replaces the built-in monospace fallback of every view.
| Name | Type | Default value | Description |
|---|---|---|---|
| Expression | string | The expression source, without its dollar delimiters. | |
| IsBlock | bool | True for display mathematics ($$...$$), false for an inline expression. |
BitAiCodeBlockContext properties
What a code block renderer is handed. The renderer is a BitAiCodeBlockRenderer - delegate RenderFragment BitAiCodeBlockRenderer(BitAiCodeBlockContext context) - registered for one language with BitAiRendererRegistry.RegisterCodeLanguage, which renders the fenced blocks of that language in place of the BitAiCodeBlockView.
| Name | Type | Default value | Description |
|---|---|---|---|
| Code | string | The source inside the fence. | |
| Language | string? | The language of the fence info string, as written. | |
| Meta | string? | The rest of the info string after the language, when there is one (```bars title="Load"). | |
| IsStreaming | bool | Whether the block is still receiving content - its closing fence has not arrived. A renderer of a diagram language waits for it to turn false: a half-written diagram is a syntax error, and one flashing on every token is worse than the source. |
BitAiCitationContext properties
What a citation renderer is handed (a sealed record). The renderer is a BitAiCitationRenderer - delegate RenderFragment BitAiCitationRenderer(BitAiCitationContext context) - set as BitAiRendererRegistry.CitationRenderer, which draws the chip of every resolved citation marker in place of the BitAiCitationMarker, inside a boundary of its own. The source list under a message and the card of a citation part are not drawn by it.
| Name | Type | Default value | Description |
|---|---|---|---|
| Citation | BitAiCitation | The citation the marker resolved to: its Number, its Source, its Quote and its Locator. | |
| Message | BitAiMessage? | null | The message the citation belongs to - always null from the Markdown view, which is handed the citations rather than a message. |
| OnActivate | EventCallback<BitAiCitation> | What activating the citation does where it is drawn: the OnCitationClick of the view. Raise it through ActivateAsync(). | |
| ActivateAsync() | Task | Activates the citation the way the built-in chip does when it is clicked: raises OnActivate with the Citation. Does nothing when the view was given no OnCitationClick. |
BitAiRendererRegistry properties
The members of the renderer registry the Markdown view reads (it also holds the renderers of parts, tools, artifacts and structured data). The registry is a singleton service: register at startup, through ConfigureRenderers of AddBitBlazorUIAIServices, and treat the entries as immutable afterwards.
| Name | Type | Default value | Description |
|---|---|---|---|
| MathRenderer | BitAiMathRenderer? | null | Renders the mathematics of every view when set, in place of the fallback (the source in monospace, under bit-aimdv-mth / bit-aimdv-mtb with a data-math attribute a script can typeset from). |
| CitationRenderer | BitAiCitationRenderer? | null | Draws the chip of every resolved citation marker of every view when set, in place of the BitAiCitationMarker - handed the OnCitationClick of the view as OnActivate, so its chip acts the way the built-in one does. |
| RegisterCodeLanguage(string language, BitAiCodeBlockRenderer renderer) | void | Registers a renderer for the fenced blocks of one language (mermaid, vega, ...), matched without regard to case, in place of the code view. | |
| FindCodeLanguage(string? language) | BitAiCodeBlockRenderer? | The renderer registered for a language, or null for the built-in code view. |
BitAiImageMode enum
| Name | Value | Description |
|---|---|---|
| Allow | 0 | Show every image whose URL scheme is safe. |
| AllowListedHosts | 1 | Show images only from the listed hosts; the others get a placeholder that loads them on request. |
| Block | 2 | Show no remote images; each is replaced by its alternative text. |
| ClickToLoad | 3 | Show a placeholder that loads the image when the reader asks for it. |
BitAiImageDecision enum
| Name | Value | Description |
|---|---|---|
| Show | 0 | Render the image. |
| AskFirst | 1 | Render a placeholder button that loads the image when activated. |
| Hide | 2 | Render the alternative text in place of the image. |
BitAiColumnAlignment enum
| Name | Value | Description |
|---|---|---|
| None | 0 | No alignment written (---): the cells sit at the start of the reading direction. |
| Left | 1 | Left aligned (:---): drawn at the start of the reading direction, as None is. |
| Center | 2 | Centre aligned (:---:). |
| Right | 3 | Right aligned (---:): drawn at the end of the reading direction, so it follows a right-to-left text. |
BitVisibility enum
| Name | Value | Description |
|---|---|---|
| Visible | 0 | The content of the component is visible. |
| Hidden | 1 | The content of the component is hidden, but the space it takes on the page remains (visibility:hidden). |
| Collapsed | 2 | The component is hidden (display:none). |
BitDir enum
| Name | Value | Description |
|---|---|---|
| Ltr | 0 | Ltr (left to right) is to be used for languages that are written from the left to the right (like English). |
| Rtl | 1 | Rtl (right to left) is to be used for languages that are written from the right to the left (like Arabic). |
| Auto | 2 | Auto lets the user agent decide. It uses a basic algorithm as it parses the characters inside the element until it finds a character with a strong directionality, then applies that directionality to the whole element. |
Feedback
Found a mistake, a gap, or something that could be clearer? Every page and every component is one click from its source.