Table of Contents

Class RichDocumentEdit

Namespace
RichEdit.Core
Assembly
RichEdit.Core.dll

Builds one schema-validated rich transaction using structural identities and paragraph-local text addresses.

public sealed class RichDocumentEdit
Inheritance
RichDocumentEdit
Inherited Members

Properties

Body

Gets the body story identity.

public RichNodeId Body { get; }

Property Value

RichNodeId

Snapshot

Gets the current candidate as an immutable, validated snapshot.

public RichDocumentSnapshot Snapshot { get; }

Property Value

RichDocumentSnapshot

Methods

AcceptRevision(Guid)

Accepts a change group and its pending prerequisites atomically, releasing retained before-content.

public void AcceptRevision(Guid group)

Parameters

group Guid

AddBookmark(string, RichTextSelection)

Adds a persistent named anchor. Deleting its complete text range or an endpoint's paragraph retains an orphaned bookmark.

public RichAnnotationId AddBookmark(string name, RichTextSelection range)

Parameters

name string
range RichTextSelection

Returns

RichAnnotationId

AddComment(RichTextSelection, string, string, DateTimeOffset?)

Adds a persistent comment, normalizing its optional timestamp to a UTC minute.

public RichAnnotationId AddComment(RichTextSelection range, string text, string author = "", DateTimeOffset? created = null)

Parameters

range RichTextSelection
text string
author string
created DateTimeOffset?

Returns

RichAnnotationId

AddImageAsset(RichImageKind, ReadOnlyMemory<byte>)

Copies encoded image bytes into a document-owned resource.

public RichAssetId AddImageAsset(RichImageKind kind, ReadOnlyMemory<byte> data)

Parameters

kind RichImageKind
data ReadOnlyMemory<byte>

Returns

RichAssetId

ApplyCharacterFormat(RichSelection, RichCharacterStyle)

Overlays specified properties on all selected characters, preserving other direct overrides and style references.

public void ApplyCharacterFormat(RichSelection selection, RichCharacterStyle format)

Parameters

selection RichSelection
format RichCharacterStyle

Remarks

Inherit leaves a property unchanged. Use UpdateCharacterFormat to restore explicit inheritance.

ApplyParagraphFormat(RichSelection, RichParagraphStyle)

Overlays specified properties on paragraphs touched by a typed selection.

public void ApplyParagraphFormat(RichSelection selection, RichParagraphStyle format)

Parameters

selection RichSelection
format RichParagraphStyle

ClearCells(RichCellSelection)

Clears selected cell contents after expanding to whole merged cells, preserving the grid and each cell's initial paragraph defaults.

public void ClearCells(RichCellSelection selection)

Parameters

selection RichCellSelection

DeleteBlock(RichNodeId)

Deletes one complete block and its descendants, leaving an empty paragraph when its container would become empty.

public void DeleteBlock(RichNodeId block)

Parameters

block RichNodeId

DeleteColumns(RichNodeId, int, int)

Deletes columns, shrinking intersected spans and retaining any surviving part of a merged cell.

public void DeleteColumns(RichNodeId tableId, int index, int count = 1)

Parameters

tableId RichNodeId
index int
count int

DeleteRows(RichNodeId, int, int)

Deletes rows, shrinking intersected spans and retaining the content of cells that still span surviving rows.

public void DeleteRows(RichNodeId tableId, int index, int count = 1)

Parameters

tableId RichNodeId
index int
count int

InsertColumns(RichNodeId, int, IEnumerable<RichLength>)

Inserts columns, extending merged cells that cross the insertion boundary.

public void InsertColumns(RichNodeId tableId, int index, IEnumerable<RichLength> columns)

Parameters

tableId RichNodeId
index int
columns IEnumerable<RichLength>

InsertField(RichTextPoint, string, string)

Inserts one field atom. Its instruction is retained as data and is never executed by the library.

public RichNodeId InsertField(RichTextPoint point, string instruction, string result)

Parameters

point RichTextPoint
instruction string
result string

Returns

RichNodeId

InsertFragment(RichNodeId, int, RichDocumentFragment)

Inserts self-contained fragment blocks into a story, list item, or cell, remapping all document-owned identities.

public ImmutableArray<RichNodeId> InsertFragment(RichNodeId parent, int index, RichDocumentFragment fragment)

Parameters

parent RichNodeId
index int
fragment RichDocumentFragment

Returns

ImmutableArray<RichNodeId>

Remarks

Fragment defaults become a private imported base style, so destination defaults cannot change the copied appearance.

InsertImage(RichTextPoint, RichAssetId, RichLength, RichLength, string?)

Inserts an authored image as one inline atom, sharing the parent document's history.

public RichNodeId InsertImage(RichTextPoint point, RichAssetId asset, RichLength width, RichLength height, string? alternativeText = null)

Parameters

point RichTextPoint
asset RichAssetId
width RichLength
height RichLength
alternativeText string

Returns

RichNodeId

InsertParagraph(RichBoundarySelection, string, RichStyleId?)

Materializes an authored paragraph at a structural caret boundary, without changing the adjacent block.

public RichNodeId InsertParagraph(RichBoundarySelection boundary, string text = "", RichStyleId? style = null)

Parameters

boundary RichBoundarySelection
text string
style RichStyleId?

Returns

RichNodeId

InsertParagraph(RichNodeId, int, string, RichStyleId?)

Inserts a paragraph into a story, list item, or cell at a zero-based block index.

public RichNodeId InsertParagraph(RichNodeId parent, int index, string text = "", RichStyleId? style = null)

Parameters

parent RichNodeId
index int
text string
style RichStyleId?

Returns

RichNodeId

InsertRows(RichNodeId, int, int)

Inserts rows, extending merged cells that cross the insertion boundary.

public void InsertRows(RichNodeId tableId, int index, int count = 1)

Parameters

tableId RichNodeId
index int
count int

InsertSoftBreak(RichTextPoint)

Inserts an authored soft line break without creating a paragraph boundary.

public RichNodeId InsertSoftBreak(RichTextPoint point)

Parameters

point RichTextPoint

Returns

RichNodeId

InsertTable(RichNodeId, int, int, IEnumerable<RichLength>)

Inserts a table whose cells contain empty paragraphs, in the parent document transaction.

public RichNodeId InsertTable(RichNodeId parent, int index, int rows, IEnumerable<RichLength> columns)

Parameters

parent RichNodeId
index int
rows int
columns IEnumerable<RichLength>

Returns

RichNodeId

JoinListItem(RichTextPoint)

Joins a list item's leading paragraph with the previous item, or unwraps the first item.

public RichTextPoint JoinListItem(RichTextPoint point)

Parameters

point RichTextPoint

Returns

RichTextPoint

Remarks

Following nested blocks move with their item. Adjacent paragraphs join without losing their text-address maps.

JoinParagraphs(RichNodeId, RichNodeId)

Joins adjacent paragraphs in the same text container. Joining across a cell or list boundary is rejected.

public void JoinParagraphs(RichNodeId first, RichNodeId second)

Parameters

first RichNodeId
second RichNodeId

MergeCells(RichCellSelection)

Merges a normalized cell rectangle, retaining all cell blocks in row-major order in the top-left cell.

public RichNodeId MergeCells(RichCellSelection selection)

Parameters

selection RichCellSelection

Returns

RichNodeId

MoveBlock(RichNodeId, RichNodeId, int)

Moves a block to a new position while preserving all identities and text addresses.

public void MoveBlock(RichNodeId block, RichNodeId destination, int index)

Parameters

block RichNodeId
destination RichNodeId
index int

Remarks

The insertion index addresses the destination before removal of the moved block.

RejectRevision(Guid)

Rejects a change group and dependent pending groups atomically, restoring retained content and resource relationships.

public void RejectRevision(Guid group)

Parameters

group Guid

RemoveAnnotation(RichAnnotationId)

Removes one persistent bookmark or comment in this transaction.

public void RemoveAnnotation(RichAnnotationId id)

Parameters

id RichAnnotationId

RemoveImageAsset(RichAssetId)

Removes an image resource. A transaction cannot commit while images still reference it.

public void RemoveImageAsset(RichAssetId asset)

Parameters

asset RichAssetId

ReplaceSelection(RichSelection, RichDocumentFragment)

Replaces a typed selection with rich content, joining boundary paragraphs and retaining tables and lists as blocks.

public RichSelection ReplaceSelection(RichSelection selection, RichDocumentFragment fragment)

Parameters

selection RichSelection
fragment RichDocumentFragment

Returns

RichSelection

Remarks

Joining into an existing paragraph carries copied character inheritance in imported character styles. The destination paragraph keeps its paragraph properties unless it is empty.

ReplaceSelection(RichSelection, string, RichCharacterStyle?)

Replaces a typed selection with semantic paragraphs and soft breaks, returning the resulting caret.

public RichSelection ReplaceSelection(RichSelection selection, string text, RichCharacterStyle? typingFormat = null)

Parameters

selection RichSelection
text string
typingFormat RichCharacterStyle

Returns

RichSelection

Remarks

Text replacement joins paragraphs and list items within one text container and removes fully enclosed blocks. Use cell selections across table cells.

ReplaceSelections(RichTextSelectionSet, IReadOnlyList<RichDocumentFragment>)

Pastes one fragment at each normalized text selection, retaining selection identities and one transaction.

public RichTextSelectionSet ReplaceSelections(RichTextSelectionSet selections, IReadOnlyList<RichDocumentFragment> fragments)

Parameters

selections RichTextSelectionSet
fragments IReadOnlyList<RichDocumentFragment>

Returns

RichTextSelectionSet

ReplaceSelections(RichTextSelectionSet, IReadOnlyList<string>, RichCharacterStyle?)

Plans one replacement per normalized selection against the same candidate and retains stable selection identities.

public RichTextSelectionSet ReplaceSelections(RichTextSelectionSet selections, IReadOnlyList<string> text, RichCharacterStyle? typingFormat = null)

Parameters

selections RichTextSelectionSet
text IReadOnlyList<string>
typingFormat RichCharacterStyle

Returns

RichTextSelectionSet

ReplaceText(RichTextPoint, int, string)

Replaces an exact UTF-16 range inside one paragraph, retaining unaffected inline styles and identities.

public void ReplaceText(RichTextPoint start, int length, string text)

Parameters

start RichTextPoint
length int
text string

Remarks

Paragraph and soft-break characters require their explicit structural commands.

SetAnnotationRange(RichAnnotationId, RichTextSelection)

Reattaches a bookmark or comment to a current rich range.

public void SetAnnotationRange(RichAnnotationId id, RichTextSelection range)

Parameters

id RichAnnotationId
range RichTextSelection

SetCellFormat(RichCellSelection, RichCellFormat)

Sets authored appearance on a normalized cell rectangle. Merged cells are updated once.

public void SetCellFormat(RichCellSelection selection, RichCellFormat format)

Parameters

selection RichCellSelection
format RichCellFormat

SetCharacterFormat(RichTextPoint, int, RichCharacterStyle)

Sets direct character overrides on a bounded paragraph-local range.

public void SetCharacterFormat(RichTextPoint start, int length, RichCharacterStyle format)

Parameters

start RichTextPoint
length int
format RichCharacterStyle

SetCharacterStyle(RichTextPoint, int, RichStyleId?)

Assigns a character style to a paragraph-local range. Null restores inheritance.

public void SetCharacterStyle(RichTextPoint start, int length, RichStyleId? style)

Parameters

start RichTextPoint
length int
style RichStyleId?

SetColumnWidths(RichNodeId, IEnumerable<RichLength>)

Resizes the existing table columns without changing cells, spans, content, or selections.

public void SetColumnWidths(RichNodeId tableId, IEnumerable<RichLength> columns)

Parameters

tableId RichNodeId

The table to resize.

columns IEnumerable<RichLength>

One positive width per existing column; the total must fit an RTF cell boundary.

SetCommentText(RichAnnotationId, string)

Changes comment text without changing its identity, author, timestamp, or anchor.

public void SetCommentText(RichAnnotationId id, string text)

Parameters

id RichAnnotationId
text string

SetDefaultCharacterFormat(RichCharacterStyle)

Changes authored document character defaults without rewriting text or style references.

public void SetDefaultCharacterFormat(RichCharacterStyle format)

Parameters

format RichCharacterStyle

SetDefaultParagraphFormat(RichParagraphStyle)

Changes authored document paragraph defaults without rewriting paragraph nodes.

public void SetDefaultParagraphFormat(RichParagraphStyle format)

Parameters

format RichParagraphStyle

SetFieldResult(RichNodeId, string)

Updates a field's retained display result without changing its identity or instruction.

public void SetFieldResult(RichNodeId field, string result)

Parameters

field RichNodeId
result string

Sets or removes an authored hyperlink on a paragraph-local range.

public void SetHyperlink(RichTextPoint start, int length, RichHyperlink? link)

Parameters

start RichTextPoint
length int
link RichHyperlink

SetListNumbering(RichNodeId, bool, int, RichListNumberingStyle)

Changes a list's marker kind or starting counter without rewriting its item content.

public void SetListNumbering(RichNodeId listId, bool numbered, int startNumber = 1, RichListNumberingStyle numberStyle = RichListNumberingStyle.Decimal)

Parameters

listId RichNodeId
numbered bool
startNumber int
numberStyle RichListNumberingStyle

SetParagraphCharacterFormat(RichNodeId, RichCharacterStyle)

Sets the direct character defaults of an entire paragraph.

public void SetParagraphCharacterFormat(RichNodeId paragraph, RichCharacterStyle format)

Parameters

paragraph RichNodeId
format RichCharacterStyle

SetParagraphFormat(RichNodeId, RichParagraphStyle)

Changes direct paragraph properties without changing its identity or text.

public void SetParagraphFormat(RichNodeId paragraph, RichParagraphStyle format)

Parameters

paragraph RichNodeId
format RichParagraphStyle

SetParagraphStyle(RichNodeId, RichStyleId?)

Assigns a reusable paragraph style. References are validated before the transaction can commit.

public void SetParagraphStyle(RichNodeId paragraph, RichStyleId? style)

Parameters

paragraph RichNodeId
style RichStyleId?

SetSelection(RichSelection)

Sets the invoking view's selection in final candidate coordinates.

public void SetSelection(RichSelection selection)

Parameters

selection RichSelection

SetStyles(RichStyleSheet)

Replaces document-owned styles without rewriting referenced content.

public void SetStyles(RichStyleSheet styles)

Parameters

styles RichStyleSheet

SplitCell(RichNodeId)

Splits a merged cell into grid cells. The top-left cell retains its identity and content; new cells are empty.

public void SplitCell(RichNodeId cell)

Parameters

cell RichNodeId

SplitListItem(RichTextPoint)

Splits a list item at a paragraph point. An empty single-paragraph item leaves its list.

public RichTextPoint SplitListItem(RichTextPoint point)

Parameters

point RichTextPoint

Returns

RichTextPoint

SplitParagraph(RichTextPoint)

Splits a paragraph at an exact local text boundary, retaining the original identity on the first part.

public RichNodeId SplitParagraph(RichTextPoint point)

Parameters

point RichTextPoint

Returns

RichNodeId

UnwrapList(RichNodeId)

Unwraps a list into its parent container, retaining item blocks and their paragraph addresses.

public void UnwrapList(RichNodeId listId)

Parameters

listId RichNodeId

UnwrapListItem(RichNodeId)

Removes one item's list membership, retaining its blocks and the surrounding lists' displayed counters.

public void UnwrapListItem(RichNodeId itemId)

Parameters

itemId RichNodeId

UpdateCharacterFormat(RichSelection, Func<RichCharacterStyle, RichCharacterStyle>)

Transforms direct overrides in the typed selection. Selected paragraph ends include their character defaults.

public void UpdateCharacterFormat(RichSelection selection, Func<RichCharacterStyle, RichCharacterStyle> update)

Parameters

selection RichSelection
update Func<RichCharacterStyle, RichCharacterStyle>

Remarks

Collapsed text carets do not author formatting. Their typing state belongs to a session.

UpdateParagraphFormat(RichSelection, Func<RichParagraphStyle, RichParagraphStyle>)

Transforms direct paragraph overrides once per selected paragraph.

public void UpdateParagraphFormat(RichSelection selection, Func<RichParagraphStyle, RichParagraphStyle> update)

Parameters

selection RichSelection
update Func<RichParagraphStyle, RichParagraphStyle>

WrapInList(RichNodeId, int, int, bool, int, RichListNumberingStyle)

Wraps contiguous blocks in a semantic list, retaining their identities and rich text addresses.

public RichNodeId WrapInList(RichNodeId parent, int index, int count, bool numbered = false, int startNumber = 1, RichListNumberingStyle numberStyle = RichListNumberingStyle.Decimal)

Parameters

parent RichNodeId
index int
count int
numbered bool
startNumber int
numberStyle RichListNumberingStyle

Returns

RichNodeId

Remarks

Each item starts with a paragraph. A nonparagraph block receives an empty marker paragraph.