Table of Contents

Class RichTextDocumentEdit

Namespace
RichEdit.Maui
Assembly
RichEdit.Maui.dll

Builds one atomic transaction against a RichTextDocument.

public sealed class RichTextDocumentEdit
Inheritance
RichTextDocumentEdit
Inherited Members

Remarks

Instances are supplied to Edit(Action<RichTextDocumentEdit>, RichTextEditOptions) and are valid only for the duration of that callback. Each operation observes earlier operations in the same transaction.

Methods

ApplyList(TextSpan, RichTextListId, int)

Applies an existing list definition to intersecting paragraphs.

public void ApplyList(TextSpan range, RichTextListId listId, int level = 0)

Parameters

range TextSpan

The range whose paragraphs become list items.

listId RichTextListId

The existing document-local list identifier.

level int

The zero-based definition level.

ChangeListLevel(TextSpan, int)

Changes list nesting for intersecting list paragraphs. Outdenting above the first level removes list state. Indenting beyond the defined levels extends the document-local definition by repeating its final marker style and layout progression, up to the RTF limit of nine levels.

public void ChangeListLevel(TextSpan range, int delta)

Parameters

range TextSpan

The range whose list items are changed.

delta int

The signed level adjustment.

ClearCharacterFormat(TextSpan)

Resets character formatting in a range to the document default format.

public void ClearCharacterFormat(TextSpan range)

Parameters

range TextSpan

The nonempty text range to reset.

ClearParagraphFormat(TextSpan)

Resets affected paragraphs to the document default paragraph format.

public void ClearParagraphFormat(TextSpan range)

Parameters

range TextSpan

The range whose paragraphs are reset.

CreateList(RichTextListDefinition)

Adds a reusable list definition and returns its document-local identity.

public RichTextListId CreateList(RichTextListDefinition definition)

Parameters

definition RichTextListDefinition

The complete caller-defined list levels.

Returns

RichTextListId

The newly allocated positive list identifier.

DeleteText(TextSpan)

Deletes a range of logical text and any inline objects it contains.

public void DeleteText(TextSpan range)

Parameters

range TextSpan

The range to delete.

InsertField(int, string, string?, RichTextCharacterFormat?)

Inserts a field result and associates it with an RTF field instruction.

public RichTextFieldId InsertField(int position, string instruction, string? result, RichTextCharacterFormat? format = null)

Parameters

position int

The result insertion offset.

instruction string

The RTF field instruction.

result string

The visible field result.

format RichTextCharacterFormat

An optional character format for the result.

Returns

RichTextFieldId

The stable document-local identity allocated for the field.

InsertImage(int, RichTextImage)

Inserts an inline image and its U+FFFC logical placeholder.

public void InsertImage(int position, RichTextImage image)

Parameters

position int

The insertion offset.

image RichTextImage

The owned image payload and presentation metadata.

InsertText(int, string?, RichTextCharacterFormat?)

Inserts plain text at a UTF-16 document offset.

public void InsertText(int position, string? text, RichTextCharacterFormat? format = null)

Parameters

position int

The insertion offset.

text string

The text to insert. Null is treated as an empty string.

format RichTextCharacterFormat

An optional character format for the inserted text; the caret format is used when omitted.

RemoveField(RichTextFieldId)

Removes one field while retaining its visible result text.

public void RemoveField(RichTextFieldId fieldId)

Parameters

fieldId RichTextFieldId

The stable document-local field identity.

RemoveFields(TextSpan)

Removes fields intersecting a range while retaining their visible result text.

public void RemoveFields(TextSpan range)

Parameters

range TextSpan

The field range to clear.

RemoveImage(int)

Removes an inline image and its U+FFFC logical placeholder.

public void RemoveImage(int position)

Parameters

position int

The image's U+FFFC document position.

Removes every hyperlink intersecting a range.

public void RemoveLinks(TextSpan range)

Parameters

range TextSpan

The range from which links are removed.

RemoveList(TextSpan)

Removes list-item state and list-owned indentation from intersecting paragraphs.

public void RemoveList(TextSpan range)

Parameters

range TextSpan

The range whose paragraphs leave their lists.

RemoveListPicture(string)

Removes an unreferenced owned list-marker picture.

public void RemoveListPicture(string pictureId)

Parameters

pictureId string

The ordinal picture identifier.

ReplaceFragment(TextSpan, RichTextDocumentFragment)

Replaces a range with an immutable rich document fragment.

public void ReplaceFragment(TextSpan range, RichTextDocumentFragment fragment)

Parameters

range TextSpan

The range to replace.

fragment RichTextDocumentFragment

The rich fragment to insert.

ReplaceText(TextSpan, string?, RichTextCharacterFormat?)

Replaces a range of logical text.

public void ReplaceText(TextSpan range, string? text, RichTextCharacterFormat? format = null)

Parameters

range TextSpan

The range to replace.

text string

The replacement text. Null is treated as an empty string.

format RichTextCharacterFormat

An optional character format for replacement text; the caret format is used when omitted.

RestartList(TextSpan, int)

Restarts intersecting numbered-list items at a positive value.

public void RestartList(TextSpan range, int startAt)

Parameters

range TextSpan

The range whose list items are restarted.

startAt int

The positive restart value.

SetCharacterFormat(TextSpan, RichTextCharacterFormat)

Replaces all selected character-format properties with one format.

public void SetCharacterFormat(TextSpan range, RichTextCharacterFormat format)

Parameters

range TextSpan

The nonempty text range to format.

format RichTextCharacterFormat

The format to apply.

SetCharacterFormats(IEnumerable<RichTextRun>)

Sets character formats for ordered, non-overlapping ranges in one pass. Formatting outside the supplied ranges is preserved.

public void SetCharacterFormats(IEnumerable<RichTextRun> runs)

Parameters

runs IEnumerable<RichTextRun>

The nonempty ranges and their replacement character formats, ordered by start offset.

Exceptions

ArgumentException

A range is empty, overlaps another range, or is out of order.

ArgumentOutOfRangeException

A range extends beyond the document.

SetDefaultCharacterFormat(RichTextCharacterFormat)

Changes the declared default character format.

public void SetDefaultCharacterFormat(RichTextCharacterFormat format)

Parameters

format RichTextCharacterFormat

The new document default.

SetDefaultParagraphFormat(RichTextParagraphFormat)

Changes the declared default paragraph format.

public void SetDefaultParagraphFormat(RichTextParagraphFormat format)

Parameters

format RichTextParagraphFormat

The new document default.

Creates or replaces a hyperlink over a nonempty range.

public void SetLink(TextSpan range, string target, string? toolTip = null)

Parameters

range TextSpan

The hyperlink display-text range.

target string

The application-defined link target.

toolTip string

An optional RTF hyperlink tooltip.

SetListPicture(RichTextListPicture)

Adds or replaces an owned list-marker picture.

public void SetListPicture(RichTextListPicture picture)

Parameters

picture RichTextListPicture

The picture value and unique document-local identifier.

SetMetadata(string, string?)

Sets or removes an application metadata value.

public void SetMetadata(string name, string? value)

Parameters

name string

The ordinal metadata key.

value string

The value to set, or null to remove the key.

SetParagraphFormat(TextSpan, RichTextParagraphFormat)

Replaces the paragraph format of every paragraph intersecting a range.

public void SetParagraphFormat(TextSpan range, RichTextParagraphFormat format)

Parameters

range TextSpan

The range whose paragraphs are affected.

format RichTextParagraphFormat

The format to apply.

UpdateCharacterFormat(TextSpan, Func<RichTextCharacterFormat, RichTextCharacterFormat>)

Updates character formats in a range while preserving run boundaries.

public void UpdateCharacterFormat(TextSpan range, Func<RichTextCharacterFormat, RichTextCharacterFormat> update)

Parameters

range TextSpan

The nonempty text range to format.

update Func<RichTextCharacterFormat, RichTextCharacterFormat>

A transformation applied to every intersecting run.

UpdateField(RichTextFieldId, string, string?, RichTextCharacterFormat?)

Updates one identified field and replaces its visible result atomically.

public void UpdateField(RichTextFieldId fieldId, string instruction, string? result, RichTextCharacterFormat? format = null)

Parameters

fieldId RichTextFieldId

The stable document-local field identity.

instruction string

The replacement RTF field instruction.

result string

The replacement visible result. Null is treated as empty.

format RichTextCharacterFormat

An optional character format for the replacement result.

UpdateField(TextSpan, string, string?, RichTextCharacterFormat?)

Updates one field instruction and replaces its visible result atomically.

public void UpdateField(TextSpan range, string instruction, string? result, RichTextCharacterFormat? format = null)

Parameters

range TextSpan

The exact current result range of one field.

instruction string

The replacement RTF field instruction.

result string

The replacement visible result. Null is treated as empty.

format RichTextCharacterFormat

An optional character format for the replacement result.

UpdateImage(int, RichTextImage)

Updates an existing inline image without changing its logical position.

public void UpdateImage(int position, RichTextImage image)

Parameters

position int

The image's U+FFFC document position.

image RichTextImage

The replacement image value.

UpdateList(RichTextListId, RichTextListDefinition)

Replaces an existing reusable list definition.

public void UpdateList(RichTextListId listId, RichTextListDefinition definition)

Parameters

listId RichTextListId

The document-local list identifier.

definition RichTextListDefinition

The replacement list levels.

UpdateParagraphFormat(TextSpan, Func<RichTextParagraphFormat, RichTextParagraphFormat>)

Updates the format of every paragraph intersecting a range.

public void UpdateParagraphFormat(TextSpan range, Func<RichTextParagraphFormat, RichTextParagraphFormat> update)

Parameters

range TextSpan

The range whose paragraphs are affected.

update Func<RichTextParagraphFormat, RichTextParagraphFormat>

A transformation applied to each paragraph format.