Skip to main content

Module styled

Module styled 

Source
Expand description

Styled text: the document model label().runs(…) renders and day-piece-texteditor edits, with the Markdown / HTML / RTF codecs over it (docs/texteditor.md). Styled text: the document label().runs(…) renders and day-piece-texteditor edits (docs/texteditor.md).

StyledText is plain text plus two range vectors over it: TextRuns for character attributes and ParagraphRuns for paragraph ones. Text and ranges travel together by construction, because a range only means something against a particular string.

Everything an editor’s toolbar needs is a pure function here rather than a round trip into the toolkit: StyledText::style_of answers “what is the selection’s style” (with a mixed state where the runs disagree), StyledText::apply changes it, and StyledText::reflow moves the ranges over an edit the native editor already made. That is what lets the same logic run on nine backends and be tested on the headless one.

Structs§

ParagraphRun
One styled paragraph.
ParagraphStyle
A ParagraphRun’s attributes with no range attached.
RunStyle
A TextRun’s attributes with no range attached: what a toolbar toggles, what an editor applies to a selection, and what it styles the next typed character with.
StyledText
A styled document: plain text, the character runs over it, and the paragraph attributes over the same offsets.

Enums§

ListStyle
A paragraph’s list decoration, if it is a list item.
ParagraphAlign
How a paragraph’s lines sit in the width they are given.
Underline
A line under a run.

Functions§

coalesce_runs
Merge adjacent runs whose styles came out equal, and drop runs that say nothing beyond base.
paragraph_bounds
The \n-delimited paragraphs of text, as byte ranges INCLUDING the terminator.
paragraphs_are_valid
Whether these paragraph runs are well formed for text: runs_are_valid’s rules, applied to the second range vector.
Day API ↩ Guides· daybrite.dev