Choose extensions
Pass an ordered extension set when you create the controller. Extensions install capabilities; the schema narrows what they admit.
| Starting point | Composition | Adds |
|---|---|---|
| Rich-text note | DocumentExtension.richText | Paragraphs, marks, links, clipboard, history, keyboard navigation |
| Paragraphs and tables | Rich-text set plus TableDocumentExtension | Tables |
| Full document | DocumentEditorElements.defaults (vyuh_document_editor_elements) | The bundled starter set |
| Advanced elements | Explicit extension packages | Equations, Mermaid, diagrams |
To call an element's methods, import its package as well as installing its extension.
Add tables to a note
This installs rich-text editing and the table adapter. The schema admits paragraphs in table cells and the ordinary marks.
dart
import 'package:flutter/widgets.dart';
import 'package:vyuh_document_editor/vyuh_document_editor.dart';
import 'package:vyuh_document_extension_table/model.dart';
import 'package:vyuh_document_extension_table_editor/vyuh_document_extension_table_editor.dart';
final controller = DocumentEditorController(
layoutMode: DocumentEditorLayoutMode.pageless,
document: Document.empty(),
extensions: [...DocumentExtension.richText, const TableDocumentExtension()],
schema: DocumentSchemaPolicy.restricted(
blockTypes: {ParagraphBlock.schemaTypeValue, TableBlock.schemaTypeValue},
inlineTypes: {TextRun.schemaTypeValue},
markTypes: TextMark.values,
),
);
void addTable() => controller.insertTable(rows: 3, cols: 2);
Widget buildTableNote() => SizedBox(
width: 520,
height: 320,
child: DocumentEditor(
controller: controller,
configuration: const DocumentEditorConfiguration(
layoutMode: DocumentEditorLayoutMode.pageless,
),
),
);Images
Add ImageDocumentExtension (from package:vyuh_document_extension_image_editor/vyuh_document_extension_image_editor.dart) for block and inline images, admit the image types in your schema, and supply DocumentEditor.assetResolver. Import package:vyuh_document_extension_image/vyuh_document_extension_image.dart for insertImage, setImageSize and requestPictureChange.
Controller lifetime
The extension set is fixed for a controller's lifetime; create a new controller for a different set. When you narrow the schema, migrate content or handle its rejection.
Empty-content hints
Block editor extensions also own their empty-content placeholders. Replace the matching default owner to choose animated hints, plain text, custom widgets or no hint. The placeholder guide shows how to compose the list for either editor API.