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
rangeTextSpanThe range whose paragraphs become list items.
listIdRichTextListIdThe existing document-local list identifier.
levelintThe 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
ClearCharacterFormat(TextSpan)
Resets character formatting in a range to the document default format.
public void ClearCharacterFormat(TextSpan range)
Parameters
rangeTextSpanThe nonempty text range to reset.
ClearParagraphFormat(TextSpan)
Resets affected paragraphs to the document default paragraph format.
public void ClearParagraphFormat(TextSpan range)
Parameters
rangeTextSpanThe range whose paragraphs are reset.
CreateList(RichTextListDefinition)
Adds a reusable list definition and returns its document-local identity.
public RichTextListId CreateList(RichTextListDefinition definition)
Parameters
definitionRichTextListDefinitionThe 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
rangeTextSpanThe 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
positionintThe result insertion offset.
instructionstringThe RTF field instruction.
resultstringThe visible field result.
formatRichTextCharacterFormatAn 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
positionintThe insertion offset.
imageRichTextImageThe 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
positionintThe insertion offset.
textstringThe text to insert. Null is treated as an empty string.
formatRichTextCharacterFormatAn 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
fieldIdRichTextFieldIdThe stable document-local field identity.
RemoveFields(TextSpan)
Removes fields intersecting a range while retaining their visible result text.
public void RemoveFields(TextSpan range)
Parameters
rangeTextSpanThe field range to clear.
RemoveImage(int)
Removes an inline image and its U+FFFC logical placeholder.
public void RemoveImage(int position)
Parameters
positionintThe image's U+FFFC document position.
RemoveLinks(TextSpan)
Removes every hyperlink intersecting a range.
public void RemoveLinks(TextSpan range)
Parameters
rangeTextSpanThe 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
rangeTextSpanThe range whose paragraphs leave their lists.
RemoveListPicture(string)
Removes an unreferenced owned list-marker picture.
public void RemoveListPicture(string pictureId)
Parameters
pictureIdstringThe ordinal picture identifier.
ReplaceFragment(TextSpan, RichTextDocumentFragment)
Replaces a range with an immutable rich document fragment.
public void ReplaceFragment(TextSpan range, RichTextDocumentFragment fragment)
Parameters
rangeTextSpanThe range to replace.
fragmentRichTextDocumentFragmentThe 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
rangeTextSpanThe range to replace.
textstringThe replacement text. Null is treated as an empty string.
formatRichTextCharacterFormatAn 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
SetCharacterFormat(TextSpan, RichTextCharacterFormat)
Replaces all selected character-format properties with one format.
public void SetCharacterFormat(TextSpan range, RichTextCharacterFormat format)
Parameters
rangeTextSpanThe nonempty text range to format.
formatRichTextCharacterFormatThe 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
runsIEnumerable<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
formatRichTextCharacterFormatThe new document default.
SetDefaultParagraphFormat(RichTextParagraphFormat)
Changes the declared default paragraph format.
public void SetDefaultParagraphFormat(RichTextParagraphFormat format)
Parameters
formatRichTextParagraphFormatThe new document default.
SetLink(TextSpan, string, string?)
Creates or replaces a hyperlink over a nonempty range.
public void SetLink(TextSpan range, string target, string? toolTip = null)
Parameters
rangeTextSpanThe hyperlink display-text range.
targetstringThe application-defined link target.
toolTipstringAn optional RTF hyperlink tooltip.
SetListPicture(RichTextListPicture)
Adds or replaces an owned list-marker picture.
public void SetListPicture(RichTextListPicture picture)
Parameters
pictureRichTextListPictureThe 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
SetParagraphFormat(TextSpan, RichTextParagraphFormat)
Replaces the paragraph format of every paragraph intersecting a range.
public void SetParagraphFormat(TextSpan range, RichTextParagraphFormat format)
Parameters
rangeTextSpanThe range whose paragraphs are affected.
formatRichTextParagraphFormatThe 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
rangeTextSpanThe nonempty text range to format.
updateFunc<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
fieldIdRichTextFieldIdThe stable document-local field identity.
instructionstringThe replacement RTF field instruction.
resultstringThe replacement visible result. Null is treated as empty.
formatRichTextCharacterFormatAn 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
rangeTextSpanThe exact current result range of one field.
instructionstringThe replacement RTF field instruction.
resultstringThe replacement visible result. Null is treated as empty.
formatRichTextCharacterFormatAn 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
positionintThe image's U+FFFC document position.
imageRichTextImageThe replacement image value.
UpdateList(RichTextListId, RichTextListDefinition)
Replaces an existing reusable list definition.
public void UpdateList(RichTextListId listId, RichTextListDefinition definition)
Parameters
listIdRichTextListIdThe document-local list identifier.
definitionRichTextListDefinitionThe 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
rangeTextSpanThe range whose paragraphs are affected.
updateFunc<RichTextParagraphFormat, RichTextParagraphFormat>A transformation applied to each paragraph format.