Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

web: refresh search on note switch

Abdullah Atta1ca5511e78cb
diff --git a/apps/web/src/components/editor/tiptap.tsx b/apps/web/src/components/editor/tiptap.tsx
index 8c5423fb6..db25d12b5 100644
--- a/apps/web/src/components/editor/tiptap.tsx
+++ b/apps/web/src/components/editor/tiptap.tsx
@@ -170,6 +170,7 @@ function TipTap(props: TipTapProps) {
}
});
if (onLoad) onLoad();
+ editor.commands.refreshSearch();
},
onUpdate: ({ editor, transaction }) => {
onContentChange?.();
diff --git a/packages/editor/src/extensions/search-replace/search-replace.ts b/packages/editor/src/extensions/search-replace/search-replace.ts
index 143aea635..780fd4f15 100644
--- a/packages/editor/src/extensions/search-replace/search-replace.ts
+++ b/packages/editor/src/extensions/search-replace/search-replace.ts
@@ -33,6 +33,7 @@ declare module "@tiptap/core" {
searchreplace: {
startSearch: () => ReturnType;
endSearch: () => ReturnType;
+ refreshSearch: () => ReturnType;
search: (term: string, options?: SearchSettings) => ReturnType;
moveToNextResult: () => ReturnType;
moveToPreviousResult: () => ReturnType;
@@ -228,6 +229,11 @@ export const SearchReplace = Extension.create<SearchOptions, SearchStorage>({
if (dispatch) updateView(state, dispatch);
return true;
},
+ refreshSearch:
+ () =>
+ ({ commands }) => {
+ return commands.search(this.storage.searchTerm, this.storage);
+ },
search:
(term, options?: SearchSettings) =>
({ state, dispatch }) => {