How to change replace value in SearchQuery

I’m trying to use custom modal form for search/replace functionality.
This is example for searching:
onChange={e => {
const a = new SearchCursor(view?.state.doc!,;
view?.dispatch({ selection: { anchor: a.value.from, head: } });
But I also want to use one more input for enter replace value, but can’t trigger setSearchQuery.
I have found similar question on forum with this template - view.dispatch({effects: setSearchQuery(…)}), but ts not allows to pass arguments to that fn.
Please help!

Why not, though?

can you provide an example with arguments for this view.dispatch({effects: setSearchQuery(…)}), plese
I have the following error:
TS2349: This expression is not callable. Type ‘StateEffectType’ has no call signatures.

You need to call setSearchQuery.of({...}), since the type of setSearchQuery is StateEffectType.

something like that?
view?.dispatch({effects: setSearchQuery.of(new SearchQuery({
search: ‘searchedText’,
replace: ‘replacedText’
but I get unchanged searchQuery: {search: ‘’, caseSensitive: false, regexp: false, replace: ‘’, valid: false}

Or I did something wrong?

Looking at the docs, it seems you have to create a SearchQuery instance and pass that. This information is all there, if you pay attention—learning to read the types properly is going to be necessary to work with the library.

1 Like