Skip to content

Build your personal knowledge base with Trilium Notes

feat(spreadsheet): allow triggering find/replace from context menu

Elian Doran99ba192a44bd
diff --git a/apps/client/src/widgets/ribbon/NoteActions.tsx b/apps/client/src/widgets/ribbon/NoteActions.tsx
index 7810cfe1ae..46a0d9d6b7 100644
--- a/apps/client/src/widgets/ribbon/NoteActions.tsx
+++ b/apps/client/src/widgets/ribbon/NoteActions.tsx
@@ -75,7 +75,7 @@ export function NoteContextMenu({ note, noteContext, itemsAtStart, itemsNearNote
const noteType = useNoteProperty(note, "type") ?? "";
const [viewType] = useNoteLabel(note, "viewType");
const canBeConvertedToAttachment = note?.isEligibleForConversionToAttachment();
- const isSearchable = ["text", "code", "book", "mindMap", "doc"].includes(noteType);
+ const isSearchable = ["text", "code", "book", "mindMap", "doc", "spreadsheet"].includes(noteType);
const isInOptionsOrHelp = note?.noteId.startsWith("_options") || note?.noteId.startsWith("_help");
const isExportableToImage = ["mermaid", "mindMap"].includes(noteType);
const isContentAvailable = note.isContentAvailable();
diff --git a/apps/client/src/widgets/type_widgets/Spreadsheet.tsx b/apps/client/src/widgets/type_widgets/Spreadsheet.tsx
index b306864e71..2325e4641a 100644
--- a/apps/client/src/widgets/type_widgets/Spreadsheet.tsx
+++ b/apps/client/src/widgets/type_widgets/Spreadsheet.tsx
@@ -42,6 +42,7 @@ function SpreadsheetEditor({ note, noteContext, readOnly }: TypeWidgetProps & {
useInitializeSpreadsheet(containerRef, apiRef, readOnly);
useDarkMode(apiRef);
usePersistence(note, noteContext, apiRef, containerRef, readOnly);
+ useSearchIntegration(apiRef);
// Focus the spreadsheet when the note is focused.
useTriliumEvent("focusOnDetail", () => {
@@ -275,3 +276,12 @@ function usePersistence(note: FNote, noteContext: NoteContext | null | undefined
}, []);
}
+function useSearchIntegration(apiRef: MutableRef<FUniver | undefined>) {
+ useTriliumEvent("findInText", () => {
+ const univerAPI = apiRef.current;
+ if (!univerAPI) return;
+
+ // Open find/replace panel and populate the search term.
+ univerAPI.executeCommand("ui.operation.open-find-dialog");
+ });
+}