Shapes & text boxes
Shapes and text boxes place styled vector containers and independent rich-text callout frames inline or floating anywhere on a page. Shapes can hold editable nested text directly inside their geometry.
- Included in:
documentConfiguration - Pure-Dart imports:
package:vyuh_document_elements/shape.dart,package:vyuh_document_elements/text_box.dart - Flutter extensions:
ShapeDocumentExtension,TextBoxDocumentExtension(bundled inDocumentEditorElements.defaults) - Action namespaces:
ShapeActions,TextBoxActions
Quick example
dart
import 'package:vyuh_document/vyuh_document.dart';
import 'package:vyuh_document_elements/vyuh_document_elements.dart';
final doc = Document.of(documentConfiguration, [
Shape(
kind: ShapeKind.roundedRectangle,
width: 220,
height: 96,
blocks: [Paragraph('Approved for release')],
),
TextBox(
width: 260,
height: 120,
blocks: [
Heading('Sidebar note', level: HeadingLevel.h3),
Paragraph('Independent text frame with full rich-text editing.'),
],
),
]);What you can configure
Shape / ShapeBlock
| Property | Type / Values | Purpose |
|---|---|---|
shapePreset / ShapeKind | rectangle, roundedRectangle, ellipse, triangle, diamond, arrow, and OOXML presets | Vector geometry contour |
shapeParameters | GraphicShapeParameters | Preset-specific geometry adjustments (such as corner radius or arrow head proportion) |
geometry | Width, height, rotation, flip | Container bounds and transforms |
graphicStyle | GraphicFrameStyle (padding, backgroundColor, borderColor, borderWidth, borderStyle) | Fill, stroke weight, dash style, and inner text padding |
textFramePolicy | Vertical alignment, text orientation, auto-fit | Controls how nested storyBlocks fit inside the shape |
storyBlocks | List<DocumentBlock> | Full editable rich text inside the shape |
floatingAnchor | FloatingAnchor? | Inline flow or floating anchored placement with text wrap |
TextBox / TextBoxBlock
| Property | Type / Values | Purpose |
|---|---|---|
width, height | double (points) | Frame dimensions (drag-resizable on canvas) |
graphicStyle | GraphicFrameStyle | Border, fill color, dash style, and inner padding |
blocks | List<DocumentBlock> | Nested editable story (paragraphs, headings, lists) |
floatingAnchor | FloatingAnchor? | Inline or floating sidebar placement |
Actions & commands
| Action ID | Effect |
|---|---|
ShapeActions.insert(String preset) | Insert a shape using the named preset (e.g. 'rectangle', 'roundedRectangle', 'ellipse', 'diamond', 'arrow') |
TextBoxActions.insert | Insert a new text box |
- Typed commands:
SetShapeKind,ResizeShape,ResizeTextBox.
Restricting usage
- Remove shapes and text boxes: Start from
notesConfigurationor calldocumentConfiguration.withoutElements([Shape.element, TextBox.element]). - Offer a fixed shape palette: Pass only your chosen presets (
ShapeActions.insert('roundedRectangle'),ShapeActions.insert('arrow')) in yourActionGroup.
Format parity
| DOCX | HTML | Markdown | |
|---|---|---|---|
Native DrawingML <wps:wsp> / <wps:txbx> shapes & text boxes | Exact vector paths, fills, strokes, and shaped interior text | Positioned SVG / styled container preserving interior text | Interior text preserved cleanly |