@eigenpal/docx-editor-core/prosemirror/queries
Functions(3)
findInDocument
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[];getPageContent
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;getSelectionInfo
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)
FindInDocumentMatch
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| Member | Type | Summary |
|---|---|---|
| after | string | |
| before | string | |
| match | string | |
| paraId | string |
PageContent
interface PageContent| Member | Type | Summary |
|---|---|---|
| pageNumber | number | |
| paragraphs | Array<{
paraId: string;
text: string;
styleId?: string;
}> | |
| text | string |
SelectionInfo
interface SelectionInfo| Member | Type | Summary |
|---|---|---|
| after | string | |
| before | string | |
| paragraphText | string | |
| paraId | string | null | |
| selectedText | string |