-
Notifications
You must be signed in to change notification settings - Fork 0
IDocumentController
Dustin Horne edited this page Mar 5, 2026
·
1 revision
Namespace: ParentElement.RichText.Core.Abstractions.Controllers
The primary interface for all editor operations. Implemented by DocumentController. Pass this interface to import/export adapters, clipboard handlers, and UI bindings to keep your code decoupled from the concrete implementation.
public interface IDocumentController : ITextDocumentView| Property | Type | Access | Description |
|---|---|---|---|
Settings |
DocumentSettings |
get | Current page size, margins, and default style |
PageWidth |
float |
get / set | Width of the document page in pixels |
DocumentHeight |
float |
get | Total rendered height of the document content |
IsModified |
bool |
get |
true when the document has unsaved changes |
ReadOnly |
bool |
get / set | When true, all editing operations are suppressed |
| Property | Type | Access | Description |
|---|---|---|---|
VisibleBounds |
Rectangle |
get / set | Viewport rectangle in document coordinates |
HasFocus |
bool |
get / set | Whether the editor currently holds keyboard focus |
ScrollScale |
float |
get / set | Zoom scale used to translate pointer coordinates |
BackgroundColor |
SKColor |
get / set | Background color of the document page |
SelectionColor |
SKColor |
get / set | Highlight color for selected text |
| Property | Type | Description |
|---|---|---|
RequestRedraw |
Action? |
Invoked when the canvas needs repainting |
RequestCursorUpdate |
Action<EditorCursor>? |
Invoked when the pointer cursor shape should change |
Shortcuts |
ShortcutHandler |
Register and manage keyboard shortcut actions |
| Property | Type | Description |
|---|---|---|
IsInTableCell |
bool |
Whether the caret is inside a table cell |
IsInTableHeaderRow |
bool |
Whether the caret is inside a header row |
IsMultiCellSelectingTable |
bool |
Whether a multi-cell table selection is active |
| Event | Signature | Description |
|---|---|---|
OnContentSizeChanged |
Action<DocumentInfo>? |
Raised when the total document size changes |
OnNavigation |
Action<NavigationInfo>? |
Raised when the caret moves or selection changes |
| Method | Returns | Description |
|---|---|---|
ApplyBold() |
Task |
Toggle bold on the current selection |
ApplyItalic() |
Task |
Toggle italic on the current selection |
ApplyUnderline() |
Task |
Toggle underline on the current selection |
ApplyStrikethrough() |
Task |
Toggle strikethrough on the current selection |
ApplySubscript() |
Task |
Toggle subscript on the current selection |
ApplySuperscript() |
Task |
Toggle superscript on the current selection |
ApplyFontColor(SKColor) |
Task |
Set foreground color of selected text |
ApplyBackgroundColor(SKColor) |
Task |
Set highlight color of selected text |
ApplyFontFamily(string) |
Task |
Set font family of selected text |
ApplyFontSize(int) |
Task |
Set font size (points) of selected text |
ApplyStyle(IStyle) |
Task |
Apply all attributes of a style to the selection |
ReplaceStyle(IStyle) |
void |
Replace matching style spans across the document |
| Method | Returns | Description |
|---|---|---|
ApplyAlignment(TextAlignment) |
Task |
Set alignment of the selected paragraphs |
AdjustLineSpacing(float) |
void |
Adjust line height multiplier by a delta |
AdjustParagraphIndent(float) |
void |
Adjust the left indent by a delta (pixels) |
SetBlockIndent(float) |
void |
Set an absolute left block indent (pixels) |
ToggleFirstLineIndent() |
void |
Toggle a first-line indent on the current paragraph |
ApplyDocumentSettings(DocumentSettings) |
void |
Replace document settings and re-render |
| Method | Returns | Description |
|---|---|---|
ApplyListFormat(ListType, int) |
void |
Apply a list type and nesting level directly |
ToggleBulletList() |
void |
Toggle bullet list on selected paragraphs |
ToggleNumberedList() |
void |
Toggle numbered list on selected paragraphs |
ChangeListLevel(int) |
void |
Increase or decrease list nesting by a delta |
| Method | Returns | Description |
|---|---|---|
Insert(string) |
void |
Insert text at the caret, replacing any selection |
InsertInlineImage(SKImage, float, float) |
void |
Insert an image with explicit display dimensions |
InsertTable(TableOptions) |
InlineTable |
Insert a table and return the new instance |
| Method | Returns | Description |
|---|---|---|
InsertTableRowBefore() |
void |
Insert a row above the current row |
InsertTableRowAfter() |
void |
Insert a row below the current row |
InsertTableColumnBefore() |
void |
Insert a column to the left of the current column |
InsertTableColumnAfter() |
void |
Insert a column to the right of the current column |
DeleteTableRow() |
void |
Delete the row containing the caret |
DeleteTableColumn() |
void |
Delete the column containing the caret |
CanMergeSelectedCells() |
bool |
Returns true if the selection can be merged |
MergeSelectedCells() |
void |
Merge the current multi-cell selection |
| Method | Returns | Description |
|---|---|---|
SelectAll() |
Task |
Select all content |
SelectNone() |
void |
Collapse selection to a caret |
Copy() |
Task<bool> |
Copy selection to clipboard; returns true if content was copied |
Cut() |
Task |
Cut selection to clipboard |
Paste() |
Task |
Paste clipboard content at the caret |
| Method | Returns | Description |
|---|---|---|
Click(Point) |
void |
Move caret to the document position nearest the point |
DragTo(Point) |
void |
Extend selection to the point |
HoverAt(Point) |
void |
Update cursor hint without changing selection |
PointerReleased(Point) |
void |
Signal that the pointer button was released |
ScrollBy(float, float) |
void |
Scroll by a relative offset in pixels |
ScrollTo(float, float) |
void |
Scroll to an absolute position in pixels |
OnKeyEvent(KeyInfo) |
Task<bool> |
Process a key event; returns true if handled |
| Method | Returns | Description |
|---|---|---|
Undo() |
Task |
Reverse the most recent operation |
Redo() |
Task |
Re-apply the most recently undone operation |
ClearDocument() |
void |
Remove all content and reset to empty |
MarkClean() |
void |
Clear the modified flag |
| Method | Returns | Description |
|---|---|---|
GetContentReader() |
DocumentReader |
Structured read access to the document content |
GetPageCount() |
int |
Total number of pages |
Draw(SKCanvas) |
void |
Render the visible document region |
RenderPageToBitmap(int, float) |
SKBitmap |
Render a page (1-based) to a bitmap at a given scale |
PrintToPdf(Stream) |
void |
Write the entire document as a PDF to a stream |
// Subscribe to navigation changes to update a toolbar
editor.OnNavigation += info =>
{
boldButton.IsActive = info.StyleAtCaret.Bold ?? false;
italicButton.IsActive = info.StyleAtCaret.Italic ?? false;
fontPicker.SelectedFont = info.StyleAtCaret.FontFamily;
};
// Register a custom shortcut
editor.Shortcuts.Map(new Shortcut(KeyCode.S, control: true), async () =>
{
await SaveDocumentAsync();
});
// Apply formatting from toolbar buttons
await editor.ApplyBold();
await editor.ApplyFontSize(14);
await editor.ApplyAlignment(TextAlignment.Center);See also: DocumentController · Data-Structures · Input-and-Shortcuts