Editor widget
DocumentEditor from package:vyuh_document_editor/document_editor.dart takes three independent settings: the controller (content), the surface (where it shows) and the chrome (which controls).
dart
DocumentEditor(
controller: controller, // content
surface: const DocumentSurface.field(minLines: 3, maxLines: 8),
chrome: EditorChrome.floating,
focusNode: focusNode, // optional
autofocus: true,
);Try them live: line, field, notes, pages.
Anatomy of the full editor
With every part of the chrome switched on, the editor becomes a workspace.
Surfaces
DocumentSurface | Shows |
|---|---|
.line(onSubmit:) | One line; Enter calls onSubmit |
.field(minLines: 1, maxLines:) | Grows with its content, then scrolls |
.pageless(maxWidth:) | A continuous column |
.pages() | Physical pages, as printed (default) |
Switching between pageless and pages keeps the selection, the reading position and the undo history.
Chrome
EditorChrome | Shows |
|---|---|
EditorChrome.none | The document alone (default) |
EditorChrome.floating | A format bubble over a text selection |
EditorChrome.toolbar(Toolbar([...])) | A toolbar row of typed parts |
EditorChrome(toolbar:, bubble:) | A row and a bubble |
EditorChrome.full | The whole command toolbar, with rulers over pages |
Toolbar parts
| Part | Shown when the configuration has |
|---|---|
BoldButton, ItalicButton, UnderlineButton, StrikeButton, SuperscriptButton, SubscriptButton | That mark |
LinkButton | Any mark |
HeadingButton(level:) | Heading |
ListButton(ordered:) | ListItem |
TableButton | Table |
UndoButton, RedoButton | Always |
Toolbar.formatting and Toolbar.standard are presets. A part runs the same command as its shortcut and the command palette. Toolbars, menus, shortcuts and paste offer only the configuration's elements.
Links
LinkButton and Command/Ctrl + K open the link dialog for the selection. Hover a link, or move the caret into it, to open, copy, edit or remove it.
Host bindings
For image resolvers, fonts, your own link dialog, review modes, PDF export or the Properties inspector, use DocumentEditorController with DocumentEditor from vyuh_document_editor.dart. The tutorial shows the switch.
Next
- Tutorial step 2: toolbar and structure.
- Toolbar: the runtime toolbar configuration.