Editor
document_editor.dart: the typed editor
dart
import 'package:vyuh_document_editor/document_editor.dart';| Type | Purpose | Key members |
|---|---|---|
DocumentEditor | Shows and edits a typed DocumentController | controller, surface (default .pages()), chrome (default .none), focusNode, autofocus, extensions (including host extensions), actions (a host-owned DocumentActionCatalog), commentComposer, view (a DocumentView: decorations, range geometry, the active comment; see Decorations), textInput, contextMenu, onRefused (see Authority) |
DocumentView | The host's view state of one typed editor | DocumentView(controller); decorate(source, decorations), rectsFor(range), activeComment; pass as DocumentEditor(view:). See Decorations |
RangeDecoration | A look over a range of one node's text | RangeDecoration(range, style:, priority:, exports:, key:) |
DocumentSurface | Where the document shows | .line(onSubmit:), .field(minLines:, maxLines:), .pageless(maxWidth:), .pages(), isPaged |
LineSurface, FieldSurface, PagelessSurface, PagesSurface | The surface variants | |
EditorChrome | Which controls show | none, floating, EditorChrome.toolbar(toolbar), EditorChrome(toolbar:, bubble:), full |
Toolbar | An ordered set of parts | Toolbar(parts), Toolbar.formatting, Toolbar.standard |
ToolbarPart, MarkButton | Base classes; a host may subclass ToolbarPart | availableIn(configuration), actionId |
ActionButton(id) | Any registered action as a part: a host's own action (from a DocumentHostExtension) or a built-in one | |
DocumentHostExtension, DocumentActionCatalog, DocumentActionState, DocumentCommentComposer | Host contributions, the action catalog, the comment prompt | See the runtime tables below |
BoldButton, ItalicButton, UnderlineButton, StrikeButton, SuperscriptButton, SubscriptButton, LinkButton, HeadingButton(level:), ListButton(ordered:), TableButton, UndoButton, RedoButton | Typed parts |
Guide: Editor widget.
vyuh_document_editor.dart: the editor runtime
dart
import 'package:vyuh_document_editor/vyuh_document_editor.dart';Re-exports package:vyuh_document/types.dart and engine_sessions.dart.
Controller
| Type | Purpose | Key members |
|---|---|---|
DocumentEditorController | The editing runtime: document, selection, history, commands | DocumentEditorController(document:, extensions:, schema:, layoutMode:, authority:, onRefused:, authorId:), .richText(...), fromSource(source:), document, state, toJson(), toJsonString(), replaceDocument, undo, redo, canUndo, complete, canRevertCompletion, revertCompletion (see Taking a completion back), transaction(recipe), setSelection, selectAll, selectNode, moveCaret*, copy, cut, paste, focusPageRegion, insertPageBreak, insertColumnBreak, insertSectionBreak, setSectionFormat, canAddComment, addCommentToSelection, addReplyToComment, updateComment, deleteComment, setCommentResolved, requestComment (the one comment prompt; returns the created DocumentComment), canRequestComment, actionCatalog, acceptRevision, rejectRevision, acceptAllRevisions, rejectAllRevisions, changes, lastChange, selectionTextColor, selectionTextColorIsMixed, setSelectionTextColor, clearSelectionCharacterProperties, search, replaceAll, protectSelection, configureInteractionMode, configureLayoutMode, configureAuthority, authority, refusals, refusalOf, selectionEditRefusal, documentEditRefusal, protectSelectionRefusal, permitSelectionRefusal, unprotectSelectionRefusal, protectionAuthoringRefusal, protectedRegionEditRefusal (see Authority), linkRequestHandler, dispose |
DocumentController | The host contract the runtime implements (used by actions and shortcuts) | Not the typed DocumentController |
DocumentActionCatalog, DocumentActionState | The mounted editor's actions for host chrome: each action's label, description, insert kind, icon, visible, enabled, active, disabled reason and shortcut; invoke(id); notifies when a state changes. Empty until an editor mounts | controller.actionCatalog; isMounted, actions, stateOf(id), invoke(id, payload:), registry |
DocumentChangeFeed, DocumentChange, DocumentChangeOrigin, DocumentTextChange, DocumentCommentChanges | Every change to the document, with its origin | See Observing changes |
DocumentEditorLayoutMode | paginated or pageless | |
DocumentSource | Loads a document: .document, .json, .jsonString, .jsonBytes, .bytes(decoder), .uri(loader:), .loader, .stream | |
DocumentExtension | An installed capability | richText, definition, register(registry) |
DocumentEditorElements | The default extension list, from package:vyuh_document_editor_elements | defaults, defaultsWith(...) |
DocumentHostExtension | The host's editor contributions as one more extension, with no elements: actions, action providers, inline interactions, sections, key handlers, triggers, input rules; may replace or unregister a starter one by id | DocumentHostExtension(id:, register: (registry) { ... }); pass it in the controller's (or typed DocumentEditor's) extensions, after the starter kit. See Host contributions |
createDocumentElementRegistryFromExtensions | Builds the element registry for a list of extensions |
Widget and configuration
| Type | Purpose | Key members |
|---|---|---|
DocumentEditor | The runtime editor widget | controller, configuration, focusNode, autofocus, assetResolver, linkOpener, canvasController, interactionMode, showFormattingMarks, zoom, layoutRevision, scrollController, searchNavigator |
DocumentEditorConfiguration | Behavior and presentation | theme, schema, showFormattingMarks, showGeometryDebug, showScrollbar, pageCacheBuffer, toolbar, review, authority, formFields, contextMenu, textInput, resources, inspector; .richText(...), copyWith. Host contributions are extensions, not configuration: see Host contributions |
DocumentToolbarConfiguration | Toolbar rows, placement, collapse, actions | rows, placement, collapsible, initiallyExpanded, actionIds, groups, menus; .disabled() |
DocumentToolbarMenuConfiguration, DocumentWorkspaceToolbarRows, DocumentToolbarPlacement, ToolbarGroup | Toolbar parts | |
DocumentEditorTheme | The one editor theme (a ThemeExtension): chrome, canvas, page spacing, caret, selection, handles, marks, rulers, scrollbar, notices | .light(), .dark(), .fromColorScheme(scheme), .of(context), materialTheme, copyWith; fields such as canvasColor, continuousContentPadding, pageGap, caretShape (thin line, outline, block, underline), caretColor (null for automatic contrast), selectionColor |
EditorActionId | The typed identity of an action; each owner declares a closed set | HistoryActionId, MarkActionId, CharacterFormatActionId, TextInsertActionId, ParagraphActionId, ParagraphStyleActionId, HeadingActionId, ListActionId, BreakActionId, TableActionId, ImageActionId, BlockQuoteActionId, BlockQuoteFormatActionId, CodeBlockActionId, ChecklistActionId, DividerActionId, TextBlockInsertActionId, ShapeInsertActionId, StandardFieldActionId, PageRegionActionId, ReviewActionId, ReferenceActionId, ClipboardActionId, KeymapActionId, SearchActionId, WorkspaceCommandId; key is the persisted form |
DocumentToolbarSectionId | The typed identity of a selection toolbar section | EditorToolbarSectionId |
ElementRegistry.decodeActionKeys | Reads persisted action keys back into typed IDs | returns ids and unknownKeys; never throws on an unknown key |
DocumentKeyHandler | One step of the key path | id, priority (DocumentKeyPriority bands), handle(DocumentKeyEvent) returning DocumentKeyResult.handled or ignored; built-in ids on DocumentKeyHandlerId |
DocumentTriggerContribution | A typed trigger such as / or @ | id, trigger, position (DocumentTriggerPosition), items(query, context), title, presenter; DocumentTriggerId.slash, rankDocumentTriggerItems |
InputRule | A type-to-format rule, committed as a completion | id, pattern, apply, trigger (InputRuleTrigger.afterText or onSplit), triggerCharacters, blockTypes, priority (higher first; stable registration order for ties; default 0); starter ids on DocumentInputRuleId |
SearchActionId | Find (Command/Control+F) and replace as actions | find, replace; register the same id to replace the editor's search everywhere (keys, Edit menu, ribbon) |
DocumentContextMenuConfiguration, DocumentReviewConfiguration, DocumentFormFieldConfiguration, DocumentEditorResources | Configuration groups. DocumentContextMenuConfiguration enables the menu or supplies a presenter; its rows are registered actions (see Configuration). DocumentReviewConfiguration.commentComposer is the one comment prompt | See Configuration |
DocumentContextMenuPresentation, DocumentContextMenuRow | Targeted immutable menu rows and guarded invocation | target, rows, invoke(row); row action, label, icon, group; documentContextMenuRows(registry:, controller:, target:) |
DocumentTextInputConfiguration | Native keyboard preferences; updates preserve the current input connection and composition | capitalization, keyboardAppearance, autocorrect, enableSuggestions, smartDashesType, smartQuotesType, enableIMEPersonalizedLearning |
DocumentTriggerPresentation | One trigger session's presentation | items, query, highlightedItem, onHighlighted, navigating, onSelected, onDismiss |
DocumentInteractionMode | editing, suggesting, commenting, reviewing, viewing | |
PaginatedCanvasController, PaginatedCanvasLayoutMode | The paged canvas (zoom, layout, export gate) |
Composition and read queries
DocumentCompositionObserver(controller) is a live ValueListenable<DocumentInputSession?>. Its commits stream publishes DocumentCompositionCommit with the exact canonical snapshot and final document. The typed DocumentView provides inputSession and compositionCommits; its agent description includes the current input-session identity and phase. See Final IME text for lifecycle and disposal.
Runtime controllers also expose commentThreads, commentThread(id), anchoredText(id), isCommentOrphaned(id), effectiveStyleIdOf(block) and updateCommentDetails(id, text:, authorName:, metadata:). These delegate to the canonical query, cascade and command services.
Resources
| Type | Purpose |
|---|---|
ImageAssetResolver | resolve(assetId) to an ImageProvider |
DocumentImageFailure and kinds, DocumentImageDecodeGate | Image loading failures |
DocumentFontLoader | Resolves and registers document fonts; layoutRevision, loadRequiredDocumentFonts, ensureFamily |
DocumentFontLoadingPolicy, DocumentFontRetryPolicy, DocumentUnavailableFontPolicy, DocumentGuaranteedFallbackFont | Font policies |
LinkOpener, openExternalLink | Opening links |
DocumentSearchNavigator, DocumentSearchSurfaceController | Search UI; navigator updateQuery, updateOptions, patternError, isPreparing, matchCount, next, previous. Invalid regex queries clear stale matches and recover on a valid query; see Search diagnostics |
DocumentPasteNotice | What paste changed or dropped |
Guides: Fonts and images, Links, Loading.