Element authoring
dart
import 'package:vyuh_document/element.dart';Guide: Declare an element.
Declarations
| Name | Purpose |
|---|---|
Element<T> | Element.block(...) / Element.inline(...): name, contains, bridge, label, groups, attributes, traits, commands; displayName, has<Trait>() |
ElementName | The serialized element name |
Node, Block, Inline | Base classes of content classes |
ElementCommands<C> | A command family: handle, codecs, names |
Bridge<T> | Phase-1 adapter onto the canonical definition: wrap, unwrap, definitions, accepts, id, children, withChildren |
Edit | What a command handler works with: document, read(ref), parentOf(ref), apply(engineCommands), freshId(), refTo(element, id) |
Content rules
| Name | Meaning |
|---|---|
ContentRule | Base of the grammar |
Text() | Text with inlines |
Nothing() | No children (an atom) |
Many(item, min:, max:) | Repeated children |
Optional(item) | Zero or one |
Sequence([...]) | Rules in order |
AnyOf(group) | Any element of a group |
Particle | An element or group a rule repeats |
Group, Groups.block, Groups.inline | Element groups |
Attributes and traits
| Name | Meaning |
|---|---|
Attribute<T, V> | Base of attributes |
Choice<T, E> | An enum value |
Number<T> | A number with optional min/max |
Flag<T> | A boolean |
Trait | Base of traits |
SplitsAcrossPages, KeepTogether, Atom, Frame, Rows, Columns, PageAware | Layout and editing behavior |
OwnsStories(StoryKind), Numbered(Counter) | Stories and numbering |
Commands and JSON
| Name | Purpose |
|---|---|
CommandName | A command's serialized name |
CommandCodec<C> | Generated JSON codec of a command |
CommandReader | Reads command arguments while decoding |
Argument, ArgumentType | Argument descriptions for describe() |
DocumentDescription, ElementDescription | The grammar describe() returns; toJson(), toPrettyJson() |
Helpers
| Name | Purpose |
|---|---|
freshNodeId() | A new node identity |
refToNode(element, id, origin:), missingRef(element, notFound), refId(ref), refOrigin(ref) | Build and read references |
documentStories(document) | Every story of a canonical document |
replaceNode, replaceCoreBlock | Engine commands that replace a node |
Generator
vyuh_document_generator (development tool, not published) writes <library>.g.dart next to each library with command families: dart run vyuh_document_generator. Its library exposes generatePackage, generatedPackages, GeneratedFile, parseLibrary and SourceLibrary.