JSON, Markdown, DOCX, and PDF
Every format goes through one canonical Document. Codecs decode into it and encode from it; PDF and print draw the pages the editor already laid out. Each codec returns its report or diagnostics beside the result.
JSON
Document.fromJson or DocumentSource.jsonString loads; toJson() or toJsonString() saves. Store referenced fonts and images separately.
DOCX
DocxCodec (vyuh_document_codec_docx) opens and saves Word files. decodeWithReport returns fidelity issues and receipts; encodeWithReport returns a support report. Keep both with your workflow. Browse compatibility.
Markdown
MarkdownCodec (vyuh_document_md_codec) converts CommonMark and GFM in pure Dart. Decode once to get a Document, edit it in the ordinary editor, and encode when you need Markdown again. Keep the diagnostics with the result.
dart
import 'package:vyuh_document_md_codec/vyuh_document_md_codec.dart';
import 'package:vyuh_document/types.dart';
MarkdownDecodeResult importMarkdown(String source) {
return const MarkdownCodec().decode(source, dialect: MarkdownDialect.gfm);
}
MarkdownEncodeResult exportMarkdown(Document document) {
return const MarkdownCodec().encode(document, dialect: MarkdownDialect.gfm);
}
// Edit the imported result.document with the ordinary document editor.
// Save exportMarkdown(controller.document).source when Markdown is needed.
// Keep diagnostics from both conversions alongside the host's file workflow.Mermaid and math syntax register through MarkdownExtensionRegistry; their renderers and editors stay separate from the codec.
PDF and print
vyuh_document_codec_pdf paints the complete layout of the current revision, with fonts and assets prepared. Call waitForCurrentExportLayout(...) to wait until every page is ready. Your app saves, downloads or sends the bytes.
Connect controls to effects
DocumentExportMenu and the workspace transfer actions only draw the controls. DocumentEditorTransferActions groups your import and export callbacks; a null callback hides that target.
See import and export integration.