Skip to content
Dustin Horne edited this page Mar 5, 2026 · 3 revisions

ParentElement.RichText.Core

A .NET rich-text editing library built on RichTextKit and SkiaSharp. It provides a document controller, formatting operations, inline images, embedded tables, clipboard support, and import/export to RTF.


Architecture Overview

┌─────────────────────────────────────────────────────────┐
│                      Your UI Layer                      │
│          (Avalonia, MAUI, WPF, Blazor, etc.)            │
└────────────────────────┬────────────────────────────────┘
                         │ IDocumentController
┌────────────────────────▼────────────────────────────────┐
│                  DocumentController                     │
│   Formatting · Clipboard · Tables · Undo/Redo · PDF     │
├──────────────┬──────────────────────┬───────────────────┤
│  CaretController  │  ShortcutHandler  │  StyleManager    │
├──────────────┴──────────────────────┴───────────────────┤
│          ParentElement.Topten.RichTextKit                │
│              TextDocument · IStyle · Layout              │
└─────────────────────────────────────────────────────────┘

Namespaces

Namespace Description
ParentElement.RichText.Core.Abstractions.Controllers Core interfaces — start here
ParentElement.RichText.Core.Abstractions.IO Import / export contracts
ParentElement.RichText.Core.Controllers DocumentController concrete implementation
ParentElement.RichText.Core.Content Read-only content model returned by DocumentReader
ParentElement.RichText.Core.Data Settings and info data structures
ParentElement.RichText.Core.Geometry Platform-agnostic Point, Rectangle, Size
ParentElement.RichText.Core.Images Inline image support
ParentElement.RichText.Core.Input Keyboard handling and shortcut mapping
ParentElement.RichText.Core.Tables Inline table support
ParentElement.RichText.Core.IO RTF import and export

Pages

Interfaces

Page Description
IDocumentController The primary contract for all editor operations
IClipboardHandler Platform clipboard abstraction
IExportContent Export a document to a stream or file
IImportContent Import content into a document
ICellWriter Write-only API for populating table cell content

Implementation

Page Description
DocumentController Concrete IDocumentController implementation

Content Model

Page Description
Content-Model ContentBlock, ContentRun, ContentTable, ContentTableCell, DocumentReader

Data Structures

Page Description
Data-Structures DocumentSettings, DocumentMargins, DocumentInfo, NavigationInfo, ViewModifier

Supporting APIs

Page Description
Geometry Point, Rectangle, Size
Input-and-Shortcuts KeyInfo, KeyMap, Shortcut, ShortcutHandler, KeyCode
Tables InlineTable, TableCell, TableOptions, TableBorderStyle, CellController
Images InlineImage, EditorCursor, ResizeHandleType
IO ExporterBase, ImporterBase, RtfExporter, RtfImporter

Quick Start

// 1. Configure the document
var settings = new DocumentSettings
{
    PageWidth    = 800,
    DocumentMargins = new DocumentMargins(40, 40, 40, 40),
    ShowPageBreaks = true,
};

// 2. Create the controller
IDocumentController editor = new DocumentController(settings, myClipboard);

// 3. Wire up rendering and input in your UI framework
editor.RequestRedraw  = () => myCanvas.InvalidateSurface();
editor.VisibleBounds  = new Rectangle(0, 0, viewWidth, viewHeight);

// 4. Draw
void OnPaintSurface(SKCanvas canvas)
{
    editor.Draw(canvas);
}

// 5. Forward pointer and key events
void OnPointerDown(float x, float y) => editor.Click(new Point(x, y));
void OnPointerMove(float x, float y) => editor.DragTo(new Point(x, y));
async void OnKeyDown(KeyInfo key)    => await editor.OnKeyEvent(key);

Clone this wiki locally