Skip to content

Type Editor


Type Editor / @type-editor/search / search-query/RegExpQuery / RegExpQuery

Class: RegExpQuery

Defined in: search-query/RegExpQuery.ts:14

Query implementation for regular expression searches. Handles pattern matching with capture groups.

Extends

Implements

Constructors

Constructor

ts
new RegExpQuery(query): RegExpQuery;

Defined in: search-query/RegExpQuery.ts:25

Creates a new regular expression query implementation.

Parameters

ParameterTypeDescription
querySearchQueryThe parent search query configuration

Returns

RegExpQuery

Overrides

AbstractQueryImpl.constructor

Methods

findNext()

ts
findNext(
   state,
   from,
   to): SearchResult;

Defined in: search-query/RegExpQuery.ts:39

Finds the next occurrence matching the regular expression in the document.

Parameters

ParameterTypeDescription
statePmEditorStateThe editor state to search in
fromnumberThe position to start searching from
tonumberThe position to search up to

Returns

SearchResult

The search result with match details if found, or null if no match exists

Implementation of

QueryImpl.findNext


findPrev()

ts
findPrev(
   state,
   from,
   to): SearchResult;

Defined in: search-query/RegExpQuery.ts:76

Finds the previous occurrence matching the regular expression in the document. Since regex doesn't support backward search, this iterates forward to find the last match.

Parameters

ParameterTypeDescription
statePmEditorStateThe editor state to search in
fromnumberThe position to start searching from
tonumberThe position to search back to

Returns

SearchResult

The search result with match details if found, or null if no match exists

Implementation of

QueryImpl.findPrev


scanTextblocks()

ts
protected scanTextblocks<T>(
   node,
   from,
   to,
   callback,
   nodeStart?): T;

Defined in: search-query/AbstractQueryImpl.ts:29

Scans through text blocks in a document tree, calling a callback for each text block that intersects with the given range.

Supports both forward scanning (from < to) and backward scanning (from > to).

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDefault valueDescription
nodeNode_2undefinedThe node to scan
fromnumberundefinedThe start position of the range
tonumberundefinedThe end position of the range
callback(node, startPos) => TundefinedFunction called for each text block, should return a result or null to continue
nodeStartnumber0The starting position of the current node in the document

Returns

T

The first non-null result from the callback, or null if none found

Inherited from

AbstractQueryImpl.scanTextblocks


textContent()

ts
protected textContent(node): string;

Defined in: search-query/AbstractQueryImpl.ts:90

Extracts the text content from a node, with caching for performance.

  • Text nodes contribute their text
  • Leaf nodes (like images) are represented by the Object Replacement Character (U+FFFC)
  • Block nodes have their content extracted recursively with spaces around them

Parameters

ParameterTypeDescription
nodeNode_2The node to extract text content from

Returns

string

The text content of the node

Inherited from

AbstractQueryImpl.textContent