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
Snapshot
Gets the current candidate as an immutable, validated snapshot.
public RichDocumentSnapshot Snapshot { get; }
Property Value
Methods
AcceptRevision(Guid)
Accepts a change group and its pending prerequisites atomically, releasing retained before-content.
public void AcceptRevision(Guid group)
Parameters
groupGuid
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
namestringrangeRichTextSelection
Returns
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
rangeRichTextSelectiontextstringauthorstringcreatedDateTimeOffset?
Returns
AddImageAsset(RichImageKind, ReadOnlyMemory<byte>)
Copies encoded image bytes into a document-owned resource.
public RichAssetId AddImageAsset(RichImageKind kind, ReadOnlyMemory<byte> data)
Parameters
kindRichImageKinddataReadOnlyMemory<byte>
Returns
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
selectionRichSelectionformatRichCharacterStyle
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
selectionRichSelectionformatRichParagraphStyle
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
selectionRichCellSelection
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
blockRichNodeId
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
tableIdRichNodeIdindexintcountint
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
tableIdRichNodeIdindexintcountint
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
tableIdRichNodeIdindexintcolumnsIEnumerable<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
pointRichTextPointinstructionstringresultstring
Returns
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
parentRichNodeIdindexintfragmentRichDocumentFragment
Returns
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
pointRichTextPointassetRichAssetIdwidthRichLengthheightRichLengthalternativeTextstring
Returns
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
boundaryRichBoundarySelectiontextstringstyleRichStyleId?
Returns
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
parentRichNodeIdindexinttextstringstyleRichStyleId?
Returns
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
tableIdRichNodeIdindexintcountint
InsertSoftBreak(RichTextPoint)
Inserts an authored soft line break without creating a paragraph boundary.
public RichNodeId InsertSoftBreak(RichTextPoint point)
Parameters
pointRichTextPoint
Returns
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
parentRichNodeIdindexintrowsintcolumnsIEnumerable<RichLength>
Returns
JoinListItem(RichTextPoint)
Joins a list item's leading paragraph with the previous item, or unwraps the first item.
public RichTextPoint JoinListItem(RichTextPoint point)
Parameters
pointRichTextPoint
Returns
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
firstRichNodeIdsecondRichNodeId
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
selectionRichCellSelection
Returns
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
blockRichNodeIddestinationRichNodeIdindexint
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
groupGuid
RemoveAnnotation(RichAnnotationId)
Removes one persistent bookmark or comment in this transaction.
public void RemoveAnnotation(RichAnnotationId id)
Parameters
RemoveImageAsset(RichAssetId)
Removes an image resource. A transaction cannot commit while images still reference it.
public void RemoveImageAsset(RichAssetId asset)
Parameters
assetRichAssetId
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
selectionRichSelectionfragmentRichDocumentFragment
Returns
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
selectionRichSelectiontextstringtypingFormatRichCharacterStyle
Returns
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
selectionsRichTextSelectionSetfragmentsIReadOnlyList<RichDocumentFragment>
Returns
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
selectionsRichTextSelectionSettextIReadOnlyList<string>typingFormatRichCharacterStyle
Returns
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
startRichTextPointlengthinttextstring
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
idRichAnnotationIdrangeRichTextSelection
SetCellFormat(RichCellSelection, RichCellFormat)
Sets authored appearance on a normalized cell rectangle. Merged cells are updated once.
public void SetCellFormat(RichCellSelection selection, RichCellFormat format)
Parameters
selectionRichCellSelectionformatRichCellFormat
SetCharacterFormat(RichTextPoint, int, RichCharacterStyle)
Sets direct character overrides on a bounded paragraph-local range.
public void SetCharacterFormat(RichTextPoint start, int length, RichCharacterStyle format)
Parameters
startRichTextPointlengthintformatRichCharacterStyle
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
startRichTextPointlengthintstyleRichStyleId?
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
tableIdRichNodeIdThe table to resize.
columnsIEnumerable<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
idRichAnnotationIdtextstring
SetDefaultCharacterFormat(RichCharacterStyle)
Changes authored document character defaults without rewriting text or style references.
public void SetDefaultCharacterFormat(RichCharacterStyle format)
Parameters
formatRichCharacterStyle
SetDefaultParagraphFormat(RichParagraphStyle)
Changes authored document paragraph defaults without rewriting paragraph nodes.
public void SetDefaultParagraphFormat(RichParagraphStyle format)
Parameters
formatRichParagraphStyle
SetFieldResult(RichNodeId, string)
Updates a field's retained display result without changing its identity or instruction.
public void SetFieldResult(RichNodeId field, string result)
Parameters
fieldRichNodeIdresultstring
SetHyperlink(RichTextPoint, int, RichHyperlink?)
Sets or removes an authored hyperlink on a paragraph-local range.
public void SetHyperlink(RichTextPoint start, int length, RichHyperlink? link)
Parameters
startRichTextPointlengthintlinkRichHyperlink
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
listIdRichNodeIdnumberedboolstartNumberintnumberStyleRichListNumberingStyle
SetParagraphCharacterFormat(RichNodeId, RichCharacterStyle)
Sets the direct character defaults of an entire paragraph.
public void SetParagraphCharacterFormat(RichNodeId paragraph, RichCharacterStyle format)
Parameters
paragraphRichNodeIdformatRichCharacterStyle
SetParagraphFormat(RichNodeId, RichParagraphStyle)
Changes direct paragraph properties without changing its identity or text.
public void SetParagraphFormat(RichNodeId paragraph, RichParagraphStyle format)
Parameters
paragraphRichNodeIdformatRichParagraphStyle
SetParagraphStyle(RichNodeId, RichStyleId?)
Assigns a reusable paragraph style. References are validated before the transaction can commit.
public void SetParagraphStyle(RichNodeId paragraph, RichStyleId? style)
Parameters
paragraphRichNodeIdstyleRichStyleId?
SetSelection(RichSelection)
Sets the invoking view's selection in final candidate coordinates.
public void SetSelection(RichSelection selection)
Parameters
selectionRichSelection
SetStyles(RichStyleSheet)
Replaces document-owned styles without rewriting referenced content.
public void SetStyles(RichStyleSheet styles)
Parameters
stylesRichStyleSheet
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
cellRichNodeId
SplitListItem(RichTextPoint)
Splits a list item at a paragraph point. An empty single-paragraph item leaves its list.
public RichTextPoint SplitListItem(RichTextPoint point)
Parameters
pointRichTextPoint
Returns
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
pointRichTextPoint
Returns
UnwrapList(RichNodeId)
Unwraps a list into its parent container, retaining item blocks and their paragraph addresses.
public void UnwrapList(RichNodeId listId)
Parameters
listIdRichNodeId
UnwrapListItem(RichNodeId)
Removes one item's list membership, retaining its blocks and the surrounding lists' displayed counters.
public void UnwrapListItem(RichNodeId itemId)
Parameters
itemIdRichNodeId
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
selectionRichSelectionupdateFunc<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
selectionRichSelectionupdateFunc<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
parentRichNodeIdindexintcountintnumberedboolstartNumberintnumberStyleRichListNumberingStyle
Returns
Remarks
Each item starts with a paragraph. A nonparagraph block receives an empty marker paragraph.