| 775 | } |
| 776 | |
| 777 | function applySearchQuery(editor, searchValue, replaceValue) { |
| 778 | if (!editor) return null; |
| 779 | const options = appSettings?.value?.search ?? {}; |
| 780 | const queryConfig = { |
| 781 | search: String(searchValue ?? ""), |
| 782 | caseSensitive: !!options.caseSensitive, |
| 783 | regexp: !!options.regExp, |
| 784 | wholeWord: !!options.wholeWord, |
| 785 | }; |
| 786 | if (replaceValue !== undefined) { |
| 787 | queryConfig.replace = String(replaceValue ?? ""); |
| 788 | } |
| 789 | const query = new SearchQuery(queryConfig); |
| 790 | editor.dispatch({ effects: setSearchQuery.of(query) }); |
| 791 | return query; |
| 792 | } |
| 793 | |
| 794 | function clearSearchQuery(editor) { |
| 795 | if (!editor) return; |