UNPKG

medium-proeditor

Version:

A powerful & customizable Medium-style rich text editor

45 lines 1.86 kB
import type { NodeWithPos, Predicate, Range } from '../types'; import type { Selection } from 'prosemirror-state'; import type { Node as ProseMirrorNode, ResolvedPos } from 'prosemirror-model'; /** * Finds the closest parent node to a resolved position that matches a predicate. * @param $pos The resolved position to search from * @param predicate The predicate to match * @returns The closest parent node to the resolved position that matches the predicate * @example ```js * findParentNodeClosestToPos($from, node => node.type.name === 'paragraph') * ``` */ export declare function findParentNodeClosestToPos($pos: ResolvedPos, predicate: Predicate): { pos: number; start: number; depth: number; node: ProseMirrorNode; } | undefined; /** * Finds the closest parent node to the current selection that matches a predicate. * @param predicate The predicate to match * @returns A command that finds the closest parent node to the current selection that matches the predicate * @example ```js * findParentNode(node => node.type.name === 'paragraph') * ``` */ export declare function findParentNode(predicate: Predicate): (selection: Selection) => { pos: number; start: number; depth: number; node: ProseMirrorNode; } | undefined; /** * Finds child nodes within a ProseMirror node that match a predicate. */ export declare function findChildren(node: ProseMirrorNode, predicate: Predicate): NodeWithPos[]; /** * Same as `findChildren` but searches only within a `range`. * @param node The Prosemirror node to search in * @param range The range to search in * @param predicate The predicate to match * @returns An array of nodes with their positions */ export declare function findChildrenInRange(node: ProseMirrorNode, range: Range, predicate: Predicate): NodeWithPos[]; //# sourceMappingURL=findNodes.d.ts.map