@docx-editor.dev/core/prosemirror/queries

Functions (6)

clampRangeToDocfunctionSource ↗

Clamp a caller-supplied [from, to] range to a valid in-document span, or return null when it cannot be made valid: non-integer, negative, reversed (to < from), or a from past the document end. to is clamped to the document size so an out-of-range end never makes doc.resolve() throw a RangeError. Both adapters' highlightRange route raw caller positions through this so the no-op contract holds identically.

declare function clampRangeToDoc(doc: Node, from: number, to: number): PmRange | null;

findChangeRangefunctionSource ↗

Resolve a tracked-change revisionId to the PM position range of its first site. Delegates to [extractTrackedChanges](extractTrackedChanges) so a coalesced revision (sites scattered across paragraphs, replace pairs, Enter chains) resolves to the same entry the sidebar shows. Matches on the entry's primary revisionId, its insertionRevisionId, or any coalescedRevisionIds member. Returns null when no entry carries the id (the change was accepted/rejected/deleted) — the caller uses this to show a "location no longer exists" affordance instead of a silent no-op.

Pure read over view.state; no dispatch.

declare function findChangeRange(view: EditorView | null, revisionId: number): PmRange | null;

findCommentRangefunctionSource ↗

Resolve a commentId to the PM position range its comment mark spans. Walks every inline node carrying a comment mark with the matching id and returns the union range (earliest start → latest end), so a comment whose range is interrupted by un-marked inline atoms still resolves to a single span. Returns null when the id is no longer present (the comment was deleted, or the marked text was removed) — the caller distinguishes "scrolled" from "stale" on that signal.

Pure read over view.state; no dispatch.

declare function findCommentRange(view: EditorView | null, commentId: number): PmRange | null;

findInDocumentfunctionSource ↗

Walk the PM doc looking for query. Returns up to limit matches — one per paragraph (rejects paragraphs where the query appears more than once, mirroring findTextInPmParagraph's ambiguity guard so the LLM gets a clearer error than a silent mistarget).

declare function findInDocument(view: EditorView | null, query: string, opts?: {
    caseSensitive?: boolean;
    limit?: number;
}): FindInDocumentMatch[];

getPageContentfunctionSource ↗

Collect paragraphs visible on pageNumber (1-indexed) from the paginated pageLayout. Dedupes by paraId so paragraphs split across page boundaries are reported once.

declare function getPageContent(view: EditorView | null, pageLayout: PageLayout | null, pageNumber: number): PageContent | null;

getSelectionInfofunctionSource ↗

Describe the current selection in agent-readable form — paraId of the containing paragraph, the selected text, the full paragraph text, and the leading/trailing slices. Vanilla view: insertion-marked text never appears, matching what the agent reads and can anchor against.

declare function getSelectionInfo(view: EditorView | null): SelectionInfo | null;

Interfaces (4)

FindInDocumentMatchinterfaceSource ↗

interface FindInDocumentMatch
MemberTypeSummary
afterstring
beforestring
matchstring
paraIdstring

PageContentinterfaceSource ↗

interface PageContent
MemberTypeSummary
pageNumbernumber
paragraphsArray<{ paraId: string; text: string; styleId?: string; }>
textstring

PmRangeinterfaceSource ↗

A resolved PM position range — half-open [from, to) in PM coordinates.

interface PmRange
MemberTypeSummary
fromnumber
tonumber

SelectionInfointerfaceSource ↗

interface SelectionInfo
MemberTypeSummary
afterstring
beforestring
paragraphTextstring
paraIdstring | null
selectedTextstring

On this page