Plain Text
Plain Text is included by the core extensions. It supports text entry, replacement, selection, wrapping and shared undo/redo, without rich-text marks, lists or headings. For formatting and list operations, see Rich Text.
Create standalone text
dart
import 'package:vyuh_diagram_extension_editor/vyuh_diagram_extension_editor.dart';
import 'package:vyuh_diagram_flutter/vyuh_diagram_flutter.dart';
final controller = DiagramController(
configuration: DiagramConfiguration(extensions: [EditorExtension()]),
);
final id = controller.createText(at: const DiagramPoint(100, 100), text: 'Hello diagram');
controller.setText(id, 'Updated text');
// DiagramCanvas(controller: controller)Compose text inside a shape
dart
import 'package:vyuh_diagram_flutter/extension_api.dart';
final card = ShapeDefinition(
type: 'app.card',
body: const ShapeText(
'title',
text: 'A plain title',
textType: PlainTextDefinition(maxLines: 1),
),
);Register it through the shapes of a portable DiagramExtension. See Shapes and shape anatomy.
Definitions and layout
Standalone text is a core element. The core text extension (vyuh.core.text), always installed, contributes the plain text type (PlainTextDefinition, named text) through textTypes. Every installed text type is also a type of the standalone text element, whose element type is the text type's name: text for plain text, richText once RichTextExtension() from the Rich Text extension is installed. The core gives each one the same standard bounds, minimum/default size, capabilities and layers, filled by that text type; registry.requireText(type) reads it.
| ShapeText option | Purpose |
|---|---|
| Positional slot ID | Stable story region identity |
text | Initial content |
textType | The text filling the slot: PlainTextDefinition (default) or RichTextDefinition, each with maxLines (1 is single-line, completing on Enter; 0 is unlimited) |
editable | Whether this slot can be edited |
alignment, verticalAlignment | Text placement |
horizontalPadding, verticalPadding | Region inset |
overflow | Allow single-line text to extend beyond its region |
Text layout, selection and input use the same resolved geometry. Standalone text has a frame and story; it does not need a painted shape background.
Replacement and selection
controller.edits.setText(id, text) accepts optional slot: and storyId: for multiple regions or stories. Other slots are preserved. Replacement removes formatting in the target region and participates in normal admission and history. A denial is available through allowed; requireAllowed() throws on denial.
The shared model uses TextStory, TextParagraph and TextRun even for Plain Text. Supporting styled runs in the schema does not enable a Rich Text editor. Install the rich-text extension explicitly for that behavior.