Table of Contents

Struct DocumentPosition

Namespace
DocWright.Dom.Editing
Assembly
DocWright.Dom.dll

A point in a paragraph's content, where text is inserted, a span starts or ends, or a paragraph is split.

public readonly struct DocumentPosition : IEquatable<DocumentPosition>
Implements
Inherited Members
Extension Methods

Remarks

The offset counts the paragraph's content the way the text-editing operations do: a text run contributes one per UTF-16 character; a tab, a break, an image, a shape, a note reference, a preserved island and an inline a reader synthesized count one each; bookmark and hyperlink markers, field characters and a field's code count nothing. A field's result is ordinary text. Inline content controls are looked through: their content counts where it stands. A position in an empty paragraph is InParagraph(p, 0).

A position is a value, not a live cursor: an edit before it in the same paragraph leaves it naming a different point. Every edit returns the position a caret goes to afterwards (After).

Properties

Offset

Gets the offset into the paragraph's content.

Paragraph

Gets the paragraph; null only for default(DocumentPosition).

Methods

After(Inline)

The position right after an inline: where a selection of it ends (Phase 150).

Before(Inline)

Creates the position just before an inline in its paragraph (a picture, a tab, a break, a run).

EndOf(Paragraph)

Creates a position at the end of a paragraph's content, before its mark.

Equals(DocumentPosition)
Equals(object?)
FindRun(out int)

Finds the text run this position falls in: the run holding the character before it, or, when the character before is not text (or there is none), the run holding the character after it.

GetHashCode()
InParagraph(Paragraph, int)

Creates a position at an offset into a paragraph's content.

InRun(TextRun, int)

Creates a position before character offset of a text run, in the paragraph that holds it (directly or inside an inline content control).

StartOf(Paragraph)

Creates a position at the start of a paragraph.

ToString()

Describes the position. Reading it never assigns a node id.

Operators

operator ==(DocumentPosition, DocumentPosition)

Determines whether two positions name the same point.

operator !=(DocumentPosition, DocumentPosition)

Determines whether two positions name different points.