Paragraphs & marks
Paragraph is the foundational text leaf of every Vyuh Document configuration — from single-line plain text inputs up to multi-page reports. It pairs block-level typography (ParagraphFormat) with inline character formatting (TextRun + marks).
- Included in: All configurations (
plainText,richText/paragraphsConfiguration,writingConfiguration,notesConfiguration,documentConfiguration) - Pure-Dart import:
package:vyuh_document/vyuh_document.dart - Flutter extension: Built into
DocumentExtension.richTextandDocumentEditorElements.defaults
Quick example
dart
import 'package:vyuh_document/vyuh_document.dart';
final doc = Document.of(DocumentConfiguration.richText, [
Paragraph.runs([
const TextRun(text: 'Ship '),
const TextRun(text: 'faster', bold: true),
const TextRun(text: ' with '),
const TextRun(text: 'typed documents', italic: true, code: true),
const TextRun(text: '.'),
]),
]);What you can configure
Block-level (ParagraphFormat)
| Property | Type / Values | Purpose |
|---|---|---|
alignment | TextAlignment (left, center, right, justify, start, end) | Horizontal text alignment |
textDirection | ParagraphTextDirection (ltr, rtl) | Explicit paragraph writing direction (BiDi) |
beforeSpacing, afterSpacing | double (points) | Vertical spacing above and below the paragraph |
lineSpacing, lineRule | double, line spacing rule | Single, 1.15x, 1.5x, double, exact, or at-least line height |
leftIndent, rightIndent, firstLineIndent, hangingIndent | double (points) | Paragraph margins and first-line / hanging indents |
tabStops | List<ParagraphTabStop> | Custom left, center, right, decimal, and bar tab stops with optional leaders |
dropCap | ParagraphDropCap (placement, lineCount, distanceFromText) | Editorial drop-cap initial letter (dropped or inMargin) |
keepWithNext, keepLinesTogether, pageBreakBefore, widowControl | bool | Pagination flow rules respected identically by editor and PDF |
borders, shading | Paragraph decoration | Top/bottom/left/right borders and background shading |
Inline character marks
| Mark | Character property | Action ID |
|---|---|---|
| Bold | Bold | DocumentActions.bold |
| Italic | Italic | DocumentActions.italic |
| Underline | Underline | DocumentActions.underline |
| Strikethrough | Strikethrough | DocumentActions.strikethrough |
| Inline code | InlineCode | DocumentActions.inlineCode |
| Superscript / Subscript | Superscript, Subscript | DocumentActions.superscript, DocumentActions.subscript |
| Text color & highlight | TextColor, Highlight | DocumentActions.textColor, DocumentActions.highlight |
| Font family & size | CharacterFormat.fontFamily, fontSize | DocumentActions.fontFamily, DocumentActions.fontSize |
| Hyperlink | Link (url) | DocumentActions.link |
Actions & commands
Combine formatting actions in an ActionGroup or execute them atomically with chain():
dart
controller.chain()
..toggleMark(const Bold())
..toggleMark(const Italic())
..commit();Restricting usage
Narrow allowed inline marks per document configuration — excluded marks are rejected by the engine and automatically hidden or disabled in the toolbar:
dart
// Allow only bold, italic, and links — strip colors, highlights, super/subscript
final minimalRichText = DocumentConfiguration.richText.withoutMarks([
const Underline(),
const Strikethrough(),
const Superscript(),
const Subscript(),
const InlineCode(),
]);
// Enforce length budgets across all paragraphs
final bioConfig = minimalRichText.withPolicy(
DocumentPolicy.authoring(
rules: [DocumentRules.maxCharacters(280)],
),
);Format parity
| DOCX | HTML | Markdown | |
|---|---|---|---|
Full <w:pPr> & <w:rPr> round-trip (alignment, spacing, indents, tabs, drop caps, marks) | Exact shaped typography, line spacing, and pagination rules | Semantic <p> with <strong>, <em>, <code>, <a>, styles | Standard & GFM prose with **bold**, *italic*, `code`, [link](url) |