This guide provides detailed information about the desktop UI implementation for the DOCX to Markdown converter.
The UI is built using Avalonia, a cross-platform .NET UI framework that runs on Windows, macOS, and Linux. This implementation follows the specifications outlined in the PRD (Product Requirements Document).
- Avalonia 11.3.10: Cross-platform UI framework
- CommunityToolkit.Mvvm 8.2.1: MVVM pattern implementation with source generators
- Markdown.Avalonia 11.0.2: Markdown rendering in preview pane
- Docx2Md.Core: Core conversion library
The UI uses the Model-View-ViewModel (MVVM) pattern:
- Views: XAML files defining the UI layout (
MainWindow.axaml) - ViewModels: C# classes containing UI logic and state (
MainWindowViewModel.cs) - Models: Domain models from
Docx2Md.Core(Segment, DocumentModel, etc.)
As specified in the PRD (Section 4), the UI provides three synchronized panes:
- Purpose: Display read-only preview of the original DOCX document
- Features:
- Document title display
- Text representation of document content
- Segment-based preview
- Current Implementation: Simple text preview showing all segments
- Future Enhancement: Rich visual rendering with segment highlighting
- Purpose: Provide detailed view and control over each document segment
- Features:
- DataGrid displaying all segments in order
- Columns:
#: Order indexType: Segment type (Heading, Paragraph, ListItem, etc.)Style: Source Word style nameContent: Extracted text contentMarkdown: Generated Markdown outputDiagnostics: Count of warnings/errors for this segmentExclude: Checkbox to exclude segment from output
- Row selection synchronizes with other panes
- Editable checkboxes for segment exclusion
- Purpose: Show rendered or raw Markdown output
- Features:
- Toggle button to switch between rendered and raw view
- Rendered view: Uses Markdown.Avalonia for rich rendering
- Raw view: Plain text with monospace font for editing/inspection
- Live updates when segments change
-
Open DOCX... (Ctrl+O)
- Opens file picker to select a DOCX file
- Loads and parses the document
- Displays segments in inspector
- Updates all panes
-
Export Markdown... (Ctrl+E)
- Opens save file dialog
- Exports current Markdown to selected location
- Includes all non-excluded segments
- Only enabled when a document is loaded
-
Exit
- Closes the application using proper Avalonia shutdown
- Show DOCX Preview: Toggle left pane visibility
- Show Segment Inspector: Toggle middle pane visibility
- Show Markdown Preview: Toggle right pane visibility
Configuration options that affect conversion (matches PRD Section 8):
- Enable Style-Based Heading Detection: Use paragraph styles to identify headings
- Infer Headings From Formatting: Detect headings from bold/large text
- Convert Underline to Emphasis: Map underline formatting to italic
- Generate Diagnostic Report: Include diagnostics in export
Note: Settings changes automatically reconvert the current document if one is loaded.
Located at the bottom of the window, displays:
- Current operation status
- Document load status
- Number of segments and diagnostics
- Error messages
cd /path/to/docx2md
dotnet run --project src/Docx2Md.UI/Docx2Md.UI.csprojOn startup, the application loads a sample document with:
- Sample heading
- Paragraph text
- Sub-heading
- List item with diagnostic
This allows immediate exploration of the UI without needing a DOCX file.
- Click File → Open DOCX... or press Ctrl+O
- Select a
.docxfile from your system - The document will be parsed and displayed in all three panes
- Segments appear in the inspector with diagnostics
- Click on any row in the Segment Inspector (middle pane)
- View the full content and Markdown output
- Check/uncheck the "Exclude" column to include/exclude segments
- View diagnostic messages for issues or warnings
- Ensure a document is loaded
- Click File → Export Markdown... or press Ctrl+E
- Choose a location and filename
- The Markdown file will be saved with all non-excluded segments
Each segment in the inspector supports:
- Exclusion: Checkbox to exclude from final output
- Type Override: Change segment type (via
OverrideTypeproperty) - Heading Level Override: Force specific heading level (via
OverrideHeadingLevelproperty) - Manual Markdown: Replace auto-generated Markdown (via
ManualMarkdownOverrideproperty)
Current Implementation: Exclusion checkbox is functional. Other overrides are supported in the data model but don't yet have UI controls.
Diagnostics appear in the segment inspector showing:
- Info, Warning, or Error level
- Diagnostic code (e.g.,
LIST_DETECTED,HEADING_INFERRED) - Human-readable message
- Optional details
Examples from PRD Section 7.2:
HEADER_FOOTER_IGNORED: Headers/footers detected but not convertedTABLE_MERGED_CELLS_LOSSY: Complex table structure simplifiedHEADING_INFERRED: Heading detected from formatting rather than styleLIST_CONTINUITY_WARNING: List numbering may be inconsistent
- Ctrl+O: Open DOCX file
- Ctrl+E: Export Markdown
- Tab: Navigate between UI elements
- Arrow Keys: Navigate segment list
The UI runs on:
- Windows: Full support, native file dialogs
- macOS: Full support, native file dialogs
- Linux: Full support, GTK-based file dialogs
Settings can be toggled via the Settings menu. Changes take effect immediately:
- If a document is loaded, it will be reconverted with new settings
- Future document loads will use the new settings
Use the View menu to hide panes you don't need:
- Hide DOCX preview to focus on conversion
- Hide Markdown preview to focus on segment inspection
- Keep only the panes relevant to your workflow
- DOCX Preview: Currently shows simple text representation, not full visual fidelity
- Segment Highlighting: Selection doesn't yet highlight in DOCX/Markdown previews
- Manual Overrides: UI controls for heading level and type overrides not yet implemented
- Drag-and-Drop: Not yet supported for opening files
- Zoom Controls: Not yet implemented for previews
Planned improvements:
- Rich DOCX rendering in left pane
- Segment highlighting synchronized across all panes
- UI controls for all per-segment override options
- Drag-and-drop file opening
- Export settings (image folder, diagnostic format)
- Recent files list
- Settings persistence
- Keyboard-only workflow support
- Ensure .NET 10.0 SDK is installed
- Check that all NuGet packages are restored:
dotnet restore - Verify no port conflicts if running multiple instances
- On Linux, ensure GTK dependencies are installed
- On macOS, check file system permissions
- Ensure Markdown.Avalonia package is installed
- Check that "Raw" toggle is not enabled
- Verify Markdown content is valid
- Verify document was loaded successfully (check status bar)
- Try closing and reopening the document
- Check for errors in the diagnostics column
When contributing to the UI:
- Follow MVVM pattern strictly
- Use
ObservablePropertyfrom CommunityToolkit.Mvvm - Keep ViewModels testable (inject dependencies)
- Update this guide when adding features
- Test on multiple platforms when possible
- PRD.md: Product Requirements Document
- Avalonia Documentation
- CommunityToolkit.Mvvm Docs
- Markdown.Avalonia GitHub