Sign in

    moui_richtext

    Optional rich text and markdown addon for MoUI

    moui
    richtext
    markdown
    gui
    Download zip
    Author
    Version
    0.2.1
    License
    Apache-2.0
    Last updated
    5 days ago
    Downloads
    38

    Dependencies

    wzzc-dev/moui_richtext does not have a README file

    CodeHighlightSpan

    pub struct CodeHighlightSpan {
    text : String
    kind : CodeHighlightToken
    }

    A highlighted slice: a piece of source text and the token kind it belongs to.

    CodeHighlightToken

    pub enum CodeHighlightToken {
    CodePlain
    CodeKeyword
    CodeString
    CodeComment
    CodeNumber
    CodeFunction
    CodeType
    CodeOperator
    CodeAnnotation
    CodeEscape
    } derive(Eq,
    Debug
    )

    Token kinds produced by the highlighter, each with a stable color.

    CodeHighlightToken::equal

    CodeHighlightToken::not_equal

    MarkdownBlock

    pub(all) struct MarkdownBlock {
    kind : MarkdownBlockKind
    text : String
    inlines : Array[MarkdownInline]
    table_alignments : Array[
    TextAlign
    ?]
    code_language : String?
    } derive(Eq, ToJson,
    Debug
    )

    MarkdownBlock::equal

    MarkdownBlock::not_equal

    fn MarkdownBlock::not_equal(x : MarkdownBlock, y : MarkdownBlock) -> Bool

    MarkdownBlock::to_json

    MarkdownBlockKind

    pub(all) enum MarkdownBlockKind {
    Heading(Int)
    Paragraph
    UnorderedListItem
    TaskListItem(Bool)
    OrderedListItem(Int)
    Blockquote
    CodeBlock
    HorizontalRule
    Table
    FootnoteDefinition(String)
    HtmlBlock
    FrontMatter
    } derive(Eq, ToJson,
    Debug
    )

    MarkdownBlockKind::equal

    MarkdownBlockKind::not_equal

    fn MarkdownBlockKind::not_equal(x : MarkdownBlockKind, y : MarkdownBlockKind) -> Bool

    MarkdownBlockKind::to_json

    MarkdownBlockView

    pub struct MarkdownBlockView {
    name : String
    matches : (MarkdownBlock) -> Bool
    project : (MarkdownBlock, MarkdownBlockViewContext) -> MarkdownBlockViewProjection?
    }

    MarkdownBlockViewContext

    pub struct MarkdownBlockViewContext {
    base :
    FontSpec

    base_dir : String?
    }

    MarkdownBlockViewProjection

    pub struct MarkdownBlockViewProjection {
    runs : Array[RichTextRun]
    line_align :
    TextAlign
    ?
    }

    MarkdownDocumentBlock

    pub(all) struct MarkdownDocumentBlock {
    id : Int
    revision : Int
    source_range : MarkdownSourceRange
    content_range : MarkdownSourceRange
    kind : MarkdownBlockKind
    text : String
    fingerprint : UInt64
    inline_count : Int
    } derive(Eq, ToJson,
    Debug
    )

    MarkdownDocumentBlock::equal

    MarkdownDocumentBlock::not_equal

    MarkdownDocumentBlock::to_json

    MarkdownDocumentBlockHeightMetric

    pub(all) struct MarkdownDocumentBlockHeightMetric {
    block_id : Int
    block_index : Int
    revision : Int
    source_range : MarkdownSourceRange
    visual_top_units : Double
    visual_height_units : Double
    source_top_units : Double
    source_height_units : Double
    } derive(Eq, ToJson,
    Debug
    )

    MarkdownDocumentBlockHeightMetric::not_equal

    MarkdownDocumentBlockHeightMetric::to_json

    MarkdownDocumentDirtyRange

    pub(all) struct MarkdownDocumentDirtyRange {
    start_block : Int
    end_block : Int
    source_start : Int
    source_end : Int
    } derive(Eq, ToJson,
    Debug
    )

    MarkdownDocumentDirtyRange::equal

    MarkdownDocumentDirtyRange::not_equal

    MarkdownDocumentDirtyRange::to_json

    MarkdownDocumentHeightIndex

    pub(all) struct MarkdownDocumentHeightIndex {
    visual_content_units : Double
    source_content_units : Double
    blocks : Array[MarkdownDocumentBlockHeightMetric]
    } derive(Eq, ToJson,
    Debug
    )

    MarkdownDocumentHeightIndex::not_equal

    MarkdownDocumentHeightIndex::to_json

    MarkdownDocumentLayoutBlock

    pub(all) struct MarkdownDocumentLayoutBlock {
    block_id : Int
    block_index : Int
    revision : Int
    top : Double
    height : Double
    source_range : MarkdownSourceRange
    } derive(Eq, ToJson,
    Debug
    )

    MarkdownDocumentLayoutBlock::not_equal

    MarkdownDocumentLayoutBlock::to_json

    MarkdownDocumentLayoutCache

    pub(all) struct MarkdownDocumentLayoutCache {
    revision : Int
    width : Double
    scroll_y : Double
    viewport_height : Double
    overscan : Double
    content_height : Double
    visible_start : Int
    visible_end : Int
    blocks : Array[MarkdownDocumentLayoutBlock]
    } derive(Eq, ToJson,
    Debug
    )

    MarkdownDocumentLayoutCache::not_equal

    MarkdownDocumentLayoutCache::to_json

    MarkdownDocumentRichTextWindow

    pub(all) struct MarkdownDocumentRichTextWindow {
    document : RichTextDocument
    content_height : Double
    top_padding : Double
    scroll_y : Double
    viewport_height : Double
    overscan : Double
    visible_start : Int
    visible_end : Int
    block_count : Int
    rendered_block_count : Int
    clip_lines : Int
    } derive(Eq, ToJson,
    Debug
    )

    MarkdownDocumentRichTextWindow::not_equal

    MarkdownDocumentRichTextWindow::to_json

    MarkdownDocumentSession

    pub(all) struct MarkdownDocumentSession {
    text_store : MarkdownDocumentTextStore
    source_length : Int
    source_digest : UInt64
    document_identity : Int
    blocks : Array[MarkdownDocumentBlock]
    editor_blocks : Array[MarkdownEditorBlock]
    line_count : Int
    word_count : Int
    reading_minutes : Int
    active_heading : String
    metadata_title : String
    metadata_tags : Array[String]
    outline : Array[MarkdownEditorOutlineItem]
    revision : Int
    parse_count : Int
    next_block_id : Int
    dirty_range : MarkdownDocumentDirtyRange?
    height_index : MarkdownDocumentHeightIndex
    layout_cache : MarkdownDocumentLayoutCache?
    } derive(Eq, ToJson,
    Debug
    )

    MarkdownDocumentSession::apply

    MarkdownDocumentSession::equal

    MarkdownDocumentSession::estimated_content_height

    fn MarkdownDocumentSession::estimated_content_height(self : MarkdownDocumentSession, base? :
    FontSpec
    , source_mode? : Bool, content_width? : Double) -> Double

    MarkdownDocumentSession::new

    MarkdownDocumentSession::not_equal

    MarkdownDocumentSession::replace_source

    fn MarkdownDocumentSession::replace_source(self : MarkdownDocumentSession, source : String, reason? : MarkdownEditReason) -> MarkdownDocumentSession

    MarkdownDocumentSession::rich_text

    fn MarkdownDocumentSession::rich_text(self : MarkdownDocumentSession, selection : MarkdownEditorSelection, base? :
    FontSpec
    , source_mode? : Bool, focus_mode? : Bool, base_dir? : String?) -> RichTextDocument

    MarkdownDocumentSession::rich_text_window

    fn MarkdownDocumentSession::rich_text_window(self : MarkdownDocumentSession, selection : MarkdownEditorSelection, base? :
    FontSpec
    , source_mode? : Bool, focus_mode? : Bool, base_dir? : String?, scroll_y? : Double, viewport_height? : Double, overscan? : Double, content_width? : Double) -> MarkdownDocumentRichTextWindow

    MarkdownDocumentSession::snapshot

    MarkdownDocumentSession::source

    MarkdownDocumentSession::source_offset_y

    fn MarkdownDocumentSession::source_offset_y(self : MarkdownDocumentSession, source_offset : Int, base? :
    FontSpec
    , source_mode? : Bool, content_width? : Double) -> Double

    MarkdownDocumentSession::to_json

    MarkdownDocumentSession::with_layout_cache

    fn MarkdownDocumentSession::with_layout_cache(self : MarkdownDocumentSession, document : RichTextDocument, base :
    FontSpec
    , width~ : Double, scroll_y~ : Double, viewport_height~ : Double, overscan? : Double, text_system? :
    TextSystem
    ) -> MarkdownDocumentSession

    MarkdownDocumentTextStore

    pub(all) struct MarkdownDocumentTextStore {
    segments :
    Ref
    [Array[MarkdownTextSegment]]
    revision :
    Ref
    [Int]
    materialized :
    Ref
    [(Int, String)]
    }

    MarkdownDocumentTextStore::char_at

    fn MarkdownDocumentTextStore::char_at(self : MarkdownDocumentTextStore, index : Int) -> Char?

    Char at a char-space offset, resolved through the segment index: a binary search plus a scan bounded by the containing segment, never by the document.

    MarkdownDocumentTextStore::edit

    fn MarkdownDocumentTextStore::edit(self : MarkdownDocumentTextStore, range : MarkdownSourceRange, replacement : String) -> Unit

    Apply an edit in place: splice the segments the range spans into a single rewritten segment, shift the offsets of every segment after the edit by the char delta (in place, texts untouched), bump the revision, and invalidate the materialization cache. range and replacement mirror a MarkdownEditTransaction: char offsets into the pre-edit text.

    MarkdownDocumentTextStore::equal

    MarkdownDocumentTextStore::from_texts

    fn MarkdownDocumentTextStore::from_texts(texts : Array[String]) -> MarkdownDocumentTextStore

    Seed the store from per-block texts (one segment per block, in order). The whole document is not joined here — materialization stays lazy until a reader asks for the whole text.

    MarkdownDocumentTextStore::length

    Char length of the document. O(1) — the tail segment carries the end.

    MarkdownDocumentTextStore::new

    MarkdownDocumentTextStore::not_equal

    MarkdownDocumentTextStore::replace_all

    fn MarkdownDocumentTextStore::replace_all(self : MarkdownDocumentTextStore, text : String) -> Unit

    Rebuild the store in place from a whole new text (open, undo restore, external replace). The previous contents are dropped entirely.

    MarkdownDocumentTextStore::revision

    MarkdownDocumentTextStore::seed

    fn MarkdownDocumentTextStore::seed(self : MarkdownDocumentTextStore, text : String) -> Unit

    Adopt an already-materialized whole text (a caller — typically the editing control — just produced exactly this revision's full string). Records it as the cache without copying or joining; segment reads still go through the segment array.

    MarkdownDocumentTextStore::segmented

    fn MarkdownDocumentTextStore::segmented(source : String, boundaries : Array[Int]) -> MarkdownDocumentTextStore

    Segment the document once at (mostly ascending, non-negative) char boundaries — typically the block starts, so every local read (text_of, char_at) stays bounded by one block instead of the document. One linear char pass over source; the materialized cache is seeded with source itself, so the whole text stays free to read.

    MarkdownDocumentTextStore::source

    The whole document text: cached across reads of the same revision, so the single join per revision is the only materialization cost.

    MarkdownDocumentTextStore::text_of

    fn MarkdownDocumentTextStore::text_of(self : MarkdownDocumentTextStore, start : Int, end : Int) -> String

    Text between two char offsets, read through the segment array. Used by block materialization and other local reads that must not materialize the whole document.

    MarkdownDocumentTextStore::to_json

    MarkdownDocumentTextStore::to_repr

    MarkdownEditReason

    pub(all) enum MarkdownEditReason {
    LoadDocument
    TextInput
    CommandEdit
    ReplaceEdit
    ToggleTaskEdit
    MediaEdit
    } derive(Eq, ToJson,
    Debug
    )

    MarkdownEditReason::equal

    MarkdownEditReason::not_equal

    MarkdownEditReason::to_json

    MarkdownEditTransaction

    pub(all) struct MarkdownEditTransaction {
    previous_source : String
    source : String
    edit_range : MarkdownSourceRange
    replacement : String
    deleted : String
    caret : Int
    selection :
    TextRange
    ?
    reason : MarkdownEditReason
    } derive(Eq, ToJson,
    Debug
    )

    MarkdownEditTransaction::equal

    MarkdownEditTransaction::from_edit

    fn MarkdownEditTransaction::from_edit(previous_source : String, source : String, start : Int, deleted~ : String, replacement~ : String, caret~ : Int, selection? :
    TextRange
    ?, reason? : MarkdownEditReason) -> MarkdownEditTransaction

    Build a transaction directly from the committed edit range (the shape from_sources recovers by scanning both documents). The ranges are already grapheme-normalized by the text control.

    MarkdownEditTransaction::from_edit_result

    fn MarkdownEditTransaction::from_edit_result(previous_source : String, result : MarkdownEditorEditResult, reason? : MarkdownEditReason) -> MarkdownEditTransaction

    MarkdownEditTransaction::from_input_transform

    fn MarkdownEditTransaction::from_input_transform(previous_source : String, transform : RichTextInputTransform, reason? : MarkdownEditReason) -> MarkdownEditTransaction

    MarkdownEditTransaction::from_sources

    fn MarkdownEditTransaction::from_sources(previous_source : String, source : String, caret? : Int, selection? :
    TextRange
    ?, reason? : MarkdownEditReason) -> MarkdownEditTransaction

    MarkdownEditTransaction::not_equal

    MarkdownEditTransaction::replace_all

    fn MarkdownEditTransaction::replace_all(previous_source : String, source : String, caret? : Int, selection? :
    TextRange
    ?, reason? : MarkdownEditReason) -> MarkdownEditTransaction

    MarkdownEditTransaction::to_json

    MarkdownEditorBlock

    pub(all) struct MarkdownEditorBlock {
    block : MarkdownBlock
    source_range : MarkdownSourceRange
    content_range : MarkdownSourceRange
    } derive(Eq, ToJson,
    Debug
    )

    MarkdownEditorBlock::equal

    MarkdownEditorBlock::not_equal

    MarkdownEditorBlock::to_json

    MarkdownEditorCommand

    pub(all) enum MarkdownEditorCommand {
    Bold
    Italic
    Code
    Strikethrough
    Highlight
    Link
    Image
    SetLinkTarget(String)
    SetImageTarget(String)
    SetCodeLanguage(String)
    SetFootnoteText(String)
    SetHtmlBlockText(String)
    Paragraph
    Heading(Int)
    BulletList
    TaskList
    OrderedList
    Quote
    CodeBlock
    HorizontalRule
    Table
    InsertTableOfContents
    InsertFrontMatter
    DuplicateBlock
    MoveBlockUp
    MoveBlockDown
    InsertTableRow
    InsertTableColumn
    DeleteTableRow
    DeleteTableColumn
    SetTableColumnAlignment(
    TextAlign
    ?)
    } derive(Eq, ToJson,
    Debug
    )

    MarkdownEditorCommand::equal

    MarkdownEditorCommand::not_equal

    MarkdownEditorCommand::to_json

    MarkdownEditorEditResult

    pub(all) struct MarkdownEditorEditResult {
    source : String
    caret : Int
    selection :
    TextRange
    ?
    edit_range : MarkdownSourceRange?
    } derive(Eq, ToJson,
    Debug
    )

    MarkdownEditorEditResult::equal

    MarkdownEditorEditResult::not_equal

    MarkdownEditorEditResult::to_json

    MarkdownEditorHtmlBlockParseResult

    type MarkdownEditorHtmlBlockParseResult derive(Eq,
    Debug
    )

    MarkdownEditorIndentedCodeParseResult

    type MarkdownEditorIndentedCodeParseResult derive(Eq,
    Debug
    )

    MarkdownEditorInputContext

    pub(all) struct MarkdownEditorInputContext {
    blocks : Array[MarkdownEditorBlock]
    store : MarkdownDocumentTextStore
    }

    Block structure and text store handed to the transform chain so the code-block lookups resolve against the session's current blocks instead of re-parsing (and re-line-splitting) the whole source on every keystroke. Callers must pass the blocks of exactly the text handed to the chain (the pre-edit session state).

    MarkdownEditorOutlineItem

    pub(all) struct MarkdownEditorOutlineItem {
    level : Int
    title : String
    source_start : Int
    } derive(Eq, ToJson,
    Debug
    )

    MarkdownEditorOutlineItem::equal

    MarkdownEditorOutlineItem::not_equal

    MarkdownEditorOutlineItem::to_json

    MarkdownEditorParagraphParseResult

    type MarkdownEditorParagraphParseResult derive(Eq,
    Debug
    )

    MarkdownEditorRunSourceRange

    type MarkdownEditorRunSourceRange derive(Eq,
    Debug
    )

    MarkdownEditorRunSourceRange::not_equal

    MarkdownEditorSelection

    pub(all) struct MarkdownEditorSelection {
    caret : Int
    selection :
    TextRange
    ?
    } derive(Eq, ToJson,
    Debug
    )

    MarkdownEditorSelection::equal

    MarkdownEditorSelection::not_equal

    MarkdownEditorSelection::to_json

    MarkdownEditorSetextHeadingParseResult

    type MarkdownEditorSetextHeadingParseResult derive(Eq,
    Debug
    )

    MarkdownEditorSnapshot

    pub(all) struct MarkdownEditorSnapshot {
    source : String
    blocks : Array[MarkdownEditorBlock]
    rich_text : RichTextDocument
    line_count : Int
    word_count : Int
    reading_minutes : Int
    active_heading : String
    metadata_title : String
    metadata_tags : Array[String]
    outline : Array[MarkdownEditorOutlineItem]
    } derive(Eq, ToJson,
    Debug
    )

    MarkdownEditorSnapshot::equal

    MarkdownEditorSnapshot::not_equal

    MarkdownEditorSnapshot::parse

    fn MarkdownEditorSnapshot::parse(source : String) -> MarkdownEditorSnapshot

    MarkdownEditorSnapshot::parse_with_font

    fn MarkdownEditorSnapshot::parse_with_font(source : String, base :
    FontSpec
    , base_dir? : String?) -> MarkdownEditorSnapshot

    MarkdownEditorSnapshot::to_json

    MarkdownHtmlBlockParseResult

    type MarkdownHtmlBlockParseResult derive(Eq,
    Debug
    )

    MarkdownHtmlBlockParseResult::not_equal

    MarkdownHtmlEntityDecodeResult

    type MarkdownHtmlEntityDecodeResult derive(Eq,
    Debug
    )

    MarkdownHtmlEntityDecodeResult::not_equal

    MarkdownIndentedCodeParseResult

    type MarkdownIndentedCodeParseResult derive(Eq,
    Debug
    )

    MarkdownInline

    pub(all) struct MarkdownInline {
    text : String
    kind : MarkdownInlineKind
    target : String?
    } derive(Eq, ToJson,
    Debug
    )

    MarkdownInline::equal

    MarkdownInline::not_equal

    fn MarkdownInline::not_equal(x : MarkdownInline, y : MarkdownInline) -> Bool

    MarkdownInline::to_json

    MarkdownInlineKind

    pub(all) enum MarkdownInlineKind {
    Plain
    Bold
    Italic
    Code
    Strikethrough
    Highlight
    Link
    Autolink
    Image
    FootnoteReference
    HtmlInline
    } derive(Eq, ToJson,
    Debug
    )

    MarkdownInlineKind::equal

    MarkdownInlineKind::not_equal

    MarkdownInlineKind::to_json

    MarkdownLinkBounds

    pub(all) struct MarkdownLinkBounds {
    open_start : Int
    close_start : Int
    target_end : Int
    target_start : Int
    definition_target_start : Int
    definition_target_end : Int
    reference_label : String
    } derive(Eq,
    Debug
    )

    MarkdownLinkBounds::equal

    MarkdownLinkBounds::not_equal

    MarkdownParagraphParseResult

    type MarkdownParagraphParseResult derive(Eq,
    Debug
    )

    MarkdownParagraphParseResult::not_equal

    MarkdownReferenceContext

    pub(all) struct MarkdownReferenceContext {
    range :
    TextRange

    bounds : MarkdownLinkBounds
    } derive(Eq,
    Debug
    )

    MarkdownReferenceContext::equal

    MarkdownReferenceContext::not_equal

    MarkdownScrollGlide

    pub(all) struct MarkdownScrollGlide {
    from_y : Double
    to_y : Double
    start_ms : Double
    tau_ms : Double
    } derive(Eq, ToJson,
    Debug
    )

    MarkdownScrollGlide::display_offset

    fn MarkdownScrollGlide::display_offset(self : MarkdownScrollGlide, now_ms : Double, compensation? : Double, scale? : Double) -> Double

    Sample the offset that the current frame is actually showing.

    Geometry measurement is committed during paint, while the owning app may not have rebuilt its glide yet. Every input and paint path must therefore use the same frame-local value: the exact glide sample plus the pending anchor translation, quantized once at the end.

    MarkdownScrollGlide::equal

    MarkdownScrollGlide::exact_offset_at

    fn MarkdownScrollGlide::exact_offset_at(self : MarkdownScrollGlide, now_ms : Double) -> Double

    The un-quantized offset at now_ms. Re-keying a mid-flight glide (feeding the shown position back as the new from_y) must use this, not the device-snapped offset_at: rounding the hidden state would shift the position by up to half a device pixel on every wheel event and reintroduce the sub-pixel jitter the snap exists to remove.

    MarkdownScrollGlide::is_animating

    fn MarkdownScrollGlide::is_animating(self : MarkdownScrollGlide, now_ms : Double) -> Bool

    Whether the glide is still in flight at now_ms. False once the offset has reached the target (within the settle threshold), which is what stops the host's animation-driven redraw loop.

    MarkdownScrollGlide::new

    fn MarkdownScrollGlide::new(from_y~ : Double, to_y~ : Double, start_ms~ : Double, tau_ms? : Double) -> MarkdownScrollGlide

    MarkdownScrollGlide::not_equal

    MarkdownScrollGlide::offset_at

    fn MarkdownScrollGlide::offset_at(self : MarkdownScrollGlide, now_ms : Double, scale? : Double) -> Double

    The scroll offset to draw at now_ms, snapped to whole device pixels. Fractional offsets make glyph rasterization shimmer while scrolling; snapping to the physical pixel grid keeps text crisp. The scale factor is the device pixel ratio (Environment.scale_factor): at 2x, scale=2.0 quantizes to 0.5 logical pixels, matching how browsers scroll — a whole logical pixel is 2 physical pixels and reads as coarse stepping on a Retina display. The internal state machine (from_y/to_y, the settle test) stays in exact logical units; only the displayed value is quantized, so the target never accumulates rounding error.

    MarkdownScrollGlide::offset_at_with_compensation

    fn MarkdownScrollGlide::offset_at_with_compensation(self : MarkdownScrollGlide, now_ms : Double, compensation : Double, scale? : Double) -> Double

    Sample the displayed offset after a pending geometry translation and snap that combined value once. Snapping before adding the translation can differ by one device pixel on a scaled display, which is visible as a one-frame backwards nudge when a measured block commits during a glide.

    MarkdownScrollGlide::settled

    fn MarkdownScrollGlide::settled(y : Double) -> MarkdownScrollGlide

    A glide already at rest at y: paints y for every clock value.

    MarkdownScrollGlide::to_json

    MarkdownScrollGlide::with_anchor_compensation

    fn MarkdownScrollGlide::with_anchor_compensation(self : MarkdownScrollGlide, compensation : Double, max_offset : Double, now_ms? : Double) -> MarkdownScrollGlide

    Apply a geometry anchor compensation while preserving the animation's direction and velocity. Both endpoints move together, so a height change cannot create an input-free reverse jump.

    MarkdownSetextHeadingParseResult

    type MarkdownSetextHeadingParseResult derive(Eq,
    Debug
    )

    MarkdownSourceRange

    pub(all) struct MarkdownSourceRange {
    start : Int
    end : Int
    } derive(Eq, ToJson,
    Debug
    )

    MarkdownSourceRange::equal

    MarkdownSourceRange::not_equal

    MarkdownSourceRange::to_json

    MarkdownTextSegment

    pub(all) struct MarkdownTextSegment {
    start : Int
    end : Int
    text : String
    } derive(Eq, ToJson,
    Debug
    )

    Internal detail of MarkdownDocumentTextStore; public only because the session (a pub(all) struct) transitively exposes the store. Do not construct or mutate segments directly — go through the store API.

    MarkdownTextSegment::equal

    MarkdownTextSegment::not_equal

    MarkdownTextSegment::to_json

    RichTextBlock

    pub(all) struct RichTextBlock {
    runs : Array[RichTextRun]
    table : RichTextTable?
    prefix : String
    marker : RichTextMarker?
    font :
    FontSpec
    ?
    color :
    Color
    ?
    background :
    Brush
    ?
    border_left :
    BorderStyle
    ?
    inset :
    Insets

    line_height : Double?
    corner_radius : Double
    rule : Bool
    line_align :
    TextAlign
    ?
    source_range : RichTextSourceRange?
    content_range : RichTextSourceRange?
    } derive(Eq, ToJson,
    Debug
    )

    RichTextBlock::equal

    RichTextBlock::new

    fn RichTextBlock::new(runs~ : Array[RichTextRun], table? : RichTextTable?, prefix? : String, marker? : RichTextMarker?, font? :
    FontSpec
    ?, color? :
    Color
    ?, background? :
    Brush
    ?, border_left? :
    BorderStyle
    ?, inset? :
    Insets
    , line_height? : Double?, corner_radius? : Double, rule? : Bool, source_range? : RichTextSourceRange?, content_range? : RichTextSourceRange?, line_align? :
    TextAlign
    ?) -> RichTextBlock

    RichTextBlock::not_equal

    fn RichTextBlock::not_equal(x : RichTextBlock, y : RichTextBlock) -> Bool

    RichTextBlock::to_json

    RichTextDecoration

    pub(all) enum RichTextDecoration {
    Strikethrough
    } derive(Eq, ToJson,
    Debug
    )

    RichTextDecoration::equal

    RichTextDecoration::not_equal

    RichTextDecoration::to_json

    RichTextDocument

    pub(all) struct RichTextDocument {
    blocks : Array[RichTextBlock]
    } derive(Eq, ToJson,
    Debug
    )

    RichTextDocument::equal

    RichTextDocument::new

    RichTextDocument::not_equal

    fn RichTextDocument::not_equal(x : RichTextDocument, y : RichTextDocument) -> Bool

    RichTextDocument::plain

    fn RichTextDocument::plain(text : String) -> RichTextDocument

    RichTextDocument::to_json

    RichTextInputTransform

    pub(all) struct RichTextInputTransform {
    text : String
    caret : Int
    selection :
    TextRange
    ?
    edit_range : MarkdownSourceRange?
    } derive(Eq, ToJson,
    Debug
    )

    RichTextInputTransform::equal

    RichTextInputTransform::new

    fn RichTextInputTransform::new(text~ : String, caret~ : Int, selection? :
    TextRange
    ?, edit_range? : MarkdownSourceRange?) -> RichTextInputTransform

    RichTextInputTransform::not_equal

    RichTextInputTransform::to_json

    RichTextMarker

    pub(all) enum RichTextMarker {
    TaskCheckbox(Bool)
    } derive(Eq, ToJson,
    Debug
    )

    Shape-and-state marker drawn in a block's prefix lane instead of a glyph.

    Task list items render a real rounded box with a vector checkmark; a font glyph (☑/☐) depends on which installed face happens to cover U+2610, so its shape, weight, and color drift per machine. The block keeps a text-shaped prefix so caret, selection, and hit-test arithmetic stay character-indexed; only the painted lane swaps the glyph for the marker.

    RichTextMarker::equal

    RichTextMarker::not_equal

    fn RichTextMarker::not_equal(x : RichTextMarker, y : RichTextMarker) -> Bool

    RichTextMarker::to_json

    RichTextRun

    pub(all) struct RichTextRun {
    text : String
    visual_text : String?
    image_source : String?
    image_size :
    Size
    ?
    image_width_fraction : Double?
    image_fit :
    ImageFit

    font :
    FontSpec
    ?
    color :
    Color
    ?
    background :
    Brush
    ?
    background_radius : Double
    decoration : RichTextDecoration?
    source_range : RichTextSourceRange?
    } derive(Eq, ToJson,
    Debug
    )

    RichTextRun::equal

    fn RichTextRun::equal(RichTextRun, RichTextRun) -> Bool

    RichTextRun::new

    fn RichTextRun::new(text~ : String, visual_text? : String?, image_source? : String?, image_size? :
    Size
    ?, image_fit? :
    ImageFit
    , font? :
    FontSpec
    ?, color? :
    Color
    ?, background? :
    Brush
    ?, background_radius? : Double, decoration? : RichTextDecoration?, source_range? : RichTextSourceRange?, image_width_fraction? : Double?) -> RichTextRun

    RichTextRun::not_equal

    fn RichTextRun::not_equal(x : RichTextRun, y : RichTextRun) -> Bool

    RichTextRun::to_json

    fn RichTextRun::to_json(RichTextRun) -> Json

    RichTextSourceRange

    pub(all) struct RichTextSourceRange {
    start : Int
    end : Int
    } derive(Eq, ToJson,
    Debug
    )

    RichTextSourceRange::equal

    RichTextSourceRange::not_equal

    RichTextSourceRange::to_json

    RichTextTable

    pub(all) struct RichTextTable {
    rows : Array[Array[RichTextTableCell]]
    row_height : Double
    cell_padding :
    Insets

    border :
    Color

    header_background :
    Brush
    ?
    } derive(Eq, ToJson,
    Debug
    )

    RichTextTable::equal

    RichTextTable::not_equal

    fn RichTextTable::not_equal(x : RichTextTable, y : RichTextTable) -> Bool

    RichTextTable::to_json

    RichTextTableCell

    pub(all) struct RichTextTableCell {
    text : String
    runs : Array[RichTextRun]
    header : Bool
    align :
    TextAlign
    ?
    source_range : RichTextSourceRange?
    } derive(Eq, ToJson,
    Debug
    )

    One table cell. text is the cell's raw source (markers included); runs is the styled projection (markers hidden, one run per inline span) used by paint/geometry. Empty runs means "render text plain", which keeps viewer-side tables and any legacy construction unstyled but correct.

    RichTextTableCell::equal

    RichTextTableCell::not_equal

    fn RichTextTableCell::not_equal(x : RichTextTableCell, y : RichTextTableCell) -> Bool

    RichTextTableCell::to_json

    code_highlight_tokenize

    fn code_highlight_tokenize(source : String, language : String) -> Array[CodeHighlightSpan]

    Tokenize a code source into highlight spans. Adjacent spans of the same kind are merged so the run list stays compact. Returns a single plain span when the language is unsupported or the source is empty.

    controlled_markdown_editor

    fn[Msg] controlled_markdown_editor(value~ : String, on_input~ : (String) -> Msg, placeholder~ : String, size~ :
    Size
    , font~ :
    FontSpec
    , foreground~ :
    Color
    , placeholder_color~ :
    Color
    , background~ :
    Brush
    , border? :
    BorderStyle
    ?, focused_border? :
    BorderStyle
    ?, cursor_color~ :
    Color
    , corner_radius? : Double, on_selection_change? : (Int,
    TextRange
    ?) -> Msg?, on_prefix_click? : (Int) -> Msg?, accepts_tab_input? : Bool, key? : String?) ->
    View
    [Msg]

    controlled_markdown_session_editor

    fn[Msg] controlled_markdown_session_editor(session~ : MarkdownDocumentSession, selection~ : MarkdownEditorSelection, on_transaction~ : (MarkdownEditTransaction) -> Msg, placeholder~ : String, size~ :
    Size
    , font~ :
    FontSpec
    , foreground~ :
    Color
    , placeholder_color~ :
    Color
    , background~ :
    Brush
    , border? :
    BorderStyle
    ?, focused_border? :
    BorderStyle
    ?, cursor_color~ :
    Color
    , corner_radius? : Double, source_mode? : Bool, focus_mode? : Bool, base_dir? : String?, on_selection_change? : (Int,
    TextRange
    ?) -> Msg?, on_prefix_click? : (Int) -> Msg?, on_command_click? : (Int) -> Msg?, accepts_tab_input? : Bool, scroll_glide? : MarkdownScrollGlide, on_scroll? : (Double, Double) -> Msg?, visible_viewport_height? : Double, visible_overscan? : Double, key? : String?) ->
    View
    [Msg]

    controlled_rich_text_editor

    fn[Msg] controlled_rich_text_editor(value~ : String, on_input~ : (String) -> Msg, placeholder~ : String, size~ :
    Size
    , format~ : (String) -> RichTextDocument, font~ :
    FontSpec
    , foreground~ :
    Color
    , placeholder_color~ :
    Color
    , background~ :
    Brush
    , border? :
    BorderStyle
    ?, focused_border? :
    BorderStyle
    ?, cursor_color~ :
    Color
    , corner_radius? : Double, on_selection_change? : (Int,
    TextRange
    ?) -> Msg?, on_prefix_click? : (Int) -> Msg?, on_command_click? : (Int) -> Msg?, input_transform? : (String, Int,
    TextRange
    ?, String) -> RichTextInputTransform??, accepts_tab_input? : Bool, visible_scroll_y? : Double, on_scroll? : (Double) -> Msg?, visible_viewport_height? : Double, visible_overscan? : Double, selection_caret? : Int, selection_range? :
    TextRange
    ?, kind? : String, key? : String?) ->
    View
    [Msg]

    markdown_block_to_rich_text

    fn markdown_block_to_rich_text(block : MarkdownBlock, base :
    FontSpec
    , base_dir? : String?) -> RichTextBlock

    markdown_block_views

    let markdown_block_views : Array[MarkdownBlockView]

    Ordered contribution registry. Contributions are wired at compile time by passing them into the editor assembly.

    markdown_editor

    fn[Msg] markdown_editor(value~ : String, placeholder~ : String, size~ :
    Size
    , font~ :
    FontSpec
    , foreground~ :
    Color
    , placeholder_color~ :
    Color
    , background~ :
    Brush
    , border? :
    BorderStyle
    ?, focused_border? :
    BorderStyle
    ?, cursor_color~ :
    Color
    , corner_radius? : Double, on_input? : (String) -> Msg?, on_selection_change? : (Int,
    TextRange
    ?) -> Msg?, on_prefix_click? : (Int) -> Msg?, accepts_tab_input? : Bool, key? : String?) ->
    View
    [Msg]

    markdown_editor_active_block_label

    fn markdown_editor_active_block_label(source : String, selection : MarkdownEditorSelection) -> String

    markdown_editor_active_selection

    fn markdown_editor_active_selection(selection :
    TextRange
    ?) ->
    TextRange
    ?

    markdown_editor_apply_command_at

    fn markdown_editor_apply_command_at(source : String, command : MarkdownEditorCommand, selection : MarkdownEditorSelection?) -> MarkdownEditorEditResult

    markdown_editor_ascii_word_char

    fn markdown_editor_ascii_word_char(ch : Char) -> Bool

    markdown_editor_clamp_int

    fn markdown_editor_clamp_int(value : Int, min : Int, max : Int) -> Int

    markdown_editor_format

    fn markdown_editor_format(source : String, base? :
    FontSpec
    , base_dir? : String?) -> RichTextDocument

    markdown_editor_format_for_selection

    fn markdown_editor_format_for_selection(source : String, selection : MarkdownEditorSelection, base? :
    FontSpec
    , base_dir? : String?) -> RichTextDocument

    markdown_editor_format_for_writing_mode

    fn markdown_editor_format_for_writing_mode(source : String, selection : MarkdownEditorSelection, base? :
    FontSpec
    , focus_mode~ : Bool, base_dir? : String?) -> RichTextDocument

    markdown_editor_image_context

    fn markdown_editor_image_context(source : String, selection : MarkdownEditorSelection) -> MarkdownReferenceContext?

    markdown_editor_indent_lines

    fn markdown_editor_indent_lines(source : String, caret : Int, selection :
    TextRange
    ?) -> RichTextInputTransform

    markdown_editor_inline_marker

    fn markdown_editor_inline_marker(command : MarkdownEditorCommand) -> String

    markdown_editor_inline_marker_pair_at_caret

    fn markdown_editor_inline_marker_pair_at_caret(source : String, caret : Int, marker : String) ->
    TextRange
    ?

    markdown_editor_insert_hard_break

    fn markdown_editor_insert_hard_break(source : String, caret : Int, selection :
    TextRange
    ?) -> RichTextInputTransform?

    fn markdown_editor_link_context(source : String, selection : MarkdownEditorSelection) -> MarkdownReferenceContext?

    markdown_editor_max_int

    fn markdown_editor_max_int(a : Int, b : Int) -> Int

    markdown_editor_outdent_lines

    fn markdown_editor_outdent_lines(source : String, caret : Int, selection :
    TextRange
    ?) -> RichTextInputTransform?

    markdown_editor_preview_text

    fn markdown_editor_preview_text(source : String) -> String

    markdown_editor_range_has_inline_marker

    fn markdown_editor_range_has_inline_marker(source : String, range :
    TextRange
    , marker : String) -> Bool

    markdown_editor_selected_footnote_text

    fn markdown_editor_selected_footnote_text(source : String, selection : MarkdownEditorSelection) -> String?

    markdown_editor_selected_html_block_text

    fn markdown_editor_selected_html_block_text(source : String, selection : MarkdownEditorSelection) -> String?

    markdown_editor_selected_image_target

    fn markdown_editor_selected_image_target(source : String, selection : MarkdownEditorSelection) -> String?

    fn markdown_editor_selected_link_target(source : String, selection : MarkdownEditorSelection) -> String?

    markdown_editor_substring

    fn markdown_editor_substring(source : String, start : Int, end : Int) -> String

    markdown_editor_text_length

    fn markdown_editor_text_length(source : String) -> Int

    markdown_editor_toggle_current_task

    fn markdown_editor_toggle_current_task(source : String, selection : MarkdownEditorSelection) -> MarkdownEditorEditResult?

    markdown_editor_toggle_task_at

    fn markdown_editor_toggle_task_at(source : String, content_offset : Int) -> MarkdownEditorEditResult?

    markdown_editor_transform_input

    fn markdown_editor_transform_input(source : String, caret : Int, selection :
    TextRange
    ?, input : String, context? : MarkdownEditorInputContext?, split_paragraph_on_enter? : Bool) -> RichTextInputTransform?

    let markdown_html_image_gallery_view : MarkdownBlockView

    markdown_image_metrics_note_bytes

    fn markdown_image_metrics_note_bytes(source : String, bytes : Bytes) -> Bool

    Feed asynchronously fetched image bytes into the intrinsic-size cache.

    Remote sources are fetched outside the layout pass, so their real size only becomes available at load completion; noting it lets later projections reserve the correct box instead of the placeholder ratio. Returns true when the cached size for source changed, which is the signal to re-project the document. Unusable bytes never overwrite a cached size.

    markdown_image_metrics_size

    fn markdown_image_metrics_size(source : String) ->
    Size
    ?

    Return the intrinsic pixel size of a resolved image source, or None when the format is unknown, the source is remote without a registered reader, or it cannot be read.

    markdown_image_metrics_size_from_bytes

    fn markdown_image_metrics_size_from_bytes(bytes : Bytes) ->
    Size
    ?

    Parse the intrinsic size from the leading bytes of a PNG, JPEG, GIF, BMP, WebP or SVG image.

    markdown_join_lines

    fn markdown_join_lines(lines : Array[String]) -> String

    markdown_scroll_peek_frame_time

    fn markdown_scroll_peek_frame_time() -> Double

    markdown_scroll_peek_geometry_compensation

    fn markdown_scroll_peek_geometry_compensation() -> Double

    Read, without consuming, the compensation published by the last paint. Retained view nodes use this while the owning app is between paints and its next state rebuild: geometry has already moved, so rendering against the old glide would expose one frame of backward displacement.

    markdown_scroll_publish_frame_time

    fn markdown_scroll_publish_frame_time(now_ms : Double) -> Unit

    Record the runtime clock used by the most recent paint. App-level view construction has no paint context, so this is the only safe timestamp to use when it must apply a measurement compensation between frames.

    markdown_scroll_publish_geometry_compensation

    fn markdown_scroll_publish_geometry_compensation(delta : Double) -> Unit

    Publish a measurement compensation for the owner of the controlled editor to consume on its next state/view build.

    markdown_scroll_take_geometry_compensation

    fn markdown_scroll_take_geometry_compensation() -> Double

    Consume pending measurement compensation exactly once.

    markdown_set_image_metrics_reader

    fn markdown_set_image_metrics_reader(reader : (String) -> Bytes?) -> Unit

    Register the host reader that returns the leading bytes of a local image source. Passing a None-returning reader restores pure-fallback mode.

    markdown_set_remote_image_reader

    fn markdown_set_remote_image_reader(reader : (String) -> Bytes?) -> Unit

    Register the reader that resolves remote image sources for the size probe. Passing a None-returning reader restores pure-fallback mode.

    markdown_split_lines

    fn markdown_split_lines(text : String) -> Array[String]

    markdown_split_table_cells

    fn markdown_split_table_cells(line : String) -> Array[String]

    markdown_viewer

    fn[Msg] markdown_viewer(source~ : String, size~ :
    Size
    , font? :
    FontSpec
    , foreground? :
    Color
    , background? :
    Brush
    , corner_radius? : Double, on_link_click? : (String) -> Msg?, visible_scroll_y? : Double, visible_viewport_height? : Double, visible_overscan? : Double, key? : String?) ->
    View
    [Msg]

    A read-only markdown viewer that renders markdown source using the same MarkdownDocumentSession pipeline as the markdown editor, but without editing capabilities (no caret, selection, IME, or keyboard input).

    The viewer is designed for embedding inside a scroll_view or similar scrollable parent. Pass visible_scroll_y, visible_viewport_height, and visible_overscan so the paint pass can cull off-screen blocks for performance, matching the session editor's windowed rendering strategy.

    parse_markdown

    fn parse_markdown(text : String) -> Array[MarkdownBlock]

    parse_markdown_inlines

    fn parse_markdown_inlines(text : String) -> Array[MarkdownInline]

    rich_text_document_caret_rect_at_source

    fn rich_text_document_caret_rect_at_source(document : RichTextDocument, source_caret : Int, content :
    Rect
    , base_font :
    FontSpec
    , text_system? :
    TextSystem
    ) ->
    Rect
    ?

    rich_text_document_height

    fn rich_text_document_height(document : RichTextDocument, base_font :
    FontSpec
    , text_system? :
    TextSystem
    , block_width? : Double) -> Double

    rich_text_editor_content_rect

    fn rich_text_editor_content_rect(frame :
    Rect
    ) ->
    Rect