Skip to content

prosekit/extensions/search

Options for defineSearchQuery

search: string

The search string (or regular expression).

replace?: string

The replace text.

caseSensitive?: boolean

Indicates whether the search is case-sensitive

false

literal?: boolean

By default, string search will replace \n, \r, and \t in the query with newline, return, and tab characters. When this is set to true, that behavior is disabled.

false

regexp?: boolean

When true, the search string is interpreted as a regular expression.

false

wholeWord?: boolean

Enable whole-word matching.

false


The match count for the current search query, and the position of the match that the selection sits on.

total: number

The total number of matches for the current search query.

active: number

The one-based position of the match that the selection sits on, or 0 when the selection is not on a match.

type SearchStatusHandler = (status: SearchStatus) => void

A function that receives the current search status.

function defineSearchQuery(options?: SearchQueryOptions): PlainExtension

Defines an extension that stores a current search query and replace string. When called without options, it stores an empty query, which can be updated later with the setSearchQuery command.


function defineSearchCommands(): SearchCommandsExtension

Defines commands for search and replace.


function getSearchStatus(state: EditorState): SearchStatus

Returns the current search status.


function defineSearchStatusHandler(handler: SearchStatusHandler): PlainExtension

Registers a handler that is called whenever the search status changes. It can be used to render a match counter.