New

docx-editor 1.x has shipped. Vue support, i18n, agents. Read the migration guide →

API Referencev1.3.2

@eigenpal/docx-editor-core/prosemirror/queries

Functions(3)

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[];

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

declare function getPageContent(view: EditorView | null, layout: Layout | null, pageNumber: number): PageContent | null;

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(3)

Pure ref-API query helpers — read-only inspectors over the PM document and the paginated layout. Back the adapters' `findInDocument`, `getSelectionInfo`, and `getPageContent` ref methods.

Every function takes the PM view (or layout + view) as a parameter instead of closing over a framework ref, so the React and Vue adapters (and the future vanilla wrapper) share one implementation.

interface FindInDocumentMatch
MemberTypeSummary
afterstring
beforestring
matchstring
paraIdstring
interface PageContent
MemberTypeSummary
pageNumbernumber
paragraphsArray<{ paraId: string; text: string; styleId?: string; }>
textstring
interface SelectionInfo
MemberTypeSummary
afterstring
beforestring
paragraphTextstring
paraIdstring | null
selectedTextstring