Typed Document API reference
dart
import 'package:vyuh_document/vyuh_document.dart';
import 'package:vyuh_document/elements.dart';Pure Dart. Guide: Typed Document API.
Documents and configuration
| Type | Purpose | Key members |
|---|---|---|
DocumentConfiguration | The elements and marks a document may use | DocumentConfiguration(elements:, marks:), richText, elements, marks, elementOf<T>(), allowsMark(mark), decodeCommand(json), describe(), commandNames |
Document | Immutable content read through its configuration | Document.of(config, blocks), Document.fromJson(config, json), body, section(i), sectionCount, footnotes, read(ref), plainText, toJson() |
Node, Block | Base classes of element content | declaration |
Alignment | Text alignment | start, center, end, justify |
Controller
| Type | Purpose | Key members |
|---|---|---|
DocumentController | One participant's live session | DocumentController(config, document:, author:), open(...) (returns Result), document, state, configuration, author, participantId, run(command), preview(command), select(range), join(author:), changes, close() |
DocumentState | Immutable snapshot | document, revision, selection, canUndo, canRedo |
Author | Who made a change | Author.person(name), Author.agent(name), id, isAgent |
Change | One applied change | author, participantId, revision, command, document |
Addressing
| Type | Purpose | Key members |
|---|---|---|
Ref<T> | A typed reference that survives edits | element, exists, description, toJson() |
Position | An offset inside a node's text | Position(ref, offset:) |
Range | Text between two positions in one node | Range(start, end), Range.at(position), isCollapsed |
Story | One flow of blocks | at<T>(i), first<T>(), where<T>(test), all<T>(), label |
Section | A section's body, headers and footers | body, header(kind), footer(kind) |
Notes | The document's footnotes | length, at(i) |
HeaderKind | Which header or footer | primary, first, even |
Guide: Addressing.
Commands
| Type | Purpose |
|---|---|
Command<R> | Base of every command; name, toJson() |
TextCommand: InsertText, DeleteRange, SetText, SplitBlock, ToggleMark, SetAlignment | Text edits |
Mark: Bold, Italic, Underline, Strike, Superscript, Subscript | Marks for ToggleMark and configurations (superscript and subscript replace each other) |
StructureCommand: InsertBlock (.before, .inside), MoveBlock, RemoveBlock, SetAttribute | Block structure and attributes |
HistoryCommand: Undo, Redo | This controller's own history |
Guide: Commands.
Results and errors
| Type | Purpose | Key members |
|---|---|---|
Result<T> | Success or a typed error | valueOrNull, errorOrNull, isDone, then, map |
Done<T>, Failed<T> | The two outcomes | value, error |
DocumentError | Base of every error | message, where, expected, found, hint, toJson(), DocumentError.fromJson(json) |
NotFound, NotAllowed, InvalidAttribute, Unsupported, Conflict, InvalidDocument | Error kinds | |
UnknownCommand | An undeclared command name | didYouMean |
elements.dart
| Type | Purpose | Key members |
|---|---|---|
Paragraph | Text with marks | Paragraph(text, alignment:, keepWithNext:), text, Paragraph.element, Paragraph.alignment, Paragraph.keepWithNext |
Heading | Text at an outline level | Heading(text, level:), text, Heading.element, Heading.level |
HeadingLevel | h1 to h6 | |
HeadingAddress | Story.heading(text:) | |
Footnote, Endnote | Note elements | .element |
FootnoteAddress | Notes.note(i) | |
NoteCommand: InsertFootnote, InsertEndnote, SetFootnoteText, SetEndnoteText | Note commands |
editor_binding.dart (adapters only)
For editor adapters that mount a DocumentController. Applications do not need it.
| Name | Purpose |
|---|---|
DocumentControllerBinding | Extension on DocumentController: canonicalDocument, commandsBetween, adoptCanonical, publishCaret, otherCarets, presenceChanges |
EditorEdit | The command recorded for an edit made in an editor |
ParticipantCaret | Another participant's published caret |