From 18fab9c1ccf8bca0e572c16a282e0df74e5bb3a1 Mon Sep 17 00:00:00 2001 From: tianma-if Date: Wed, 22 Jul 2026 15:38:57 +0800 Subject: [PATCH] feat(web): search selected editor text with shortcut --- apps/web/src/components/EditorPane.tsx | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/apps/web/src/components/EditorPane.tsx b/apps/web/src/components/EditorPane.tsx index f3cf5ddb..fb3ce646 100644 --- a/apps/web/src/components/EditorPane.tsx +++ b/apps/web/src/components/EditorPane.tsx @@ -1360,6 +1360,36 @@ const RichEditorPane = ({ attributes: { class: "prose prose-slate max-w-none focus:outline-none min-h-[300px] px-4 py-3 sm:px-7", }, + handleKeyDown: (view, event) => { + if ( + event.key.toLowerCase() !== "f" || + (!event.ctrlKey && !event.metaKey) || + event.altKey || + event.shiftKey + ) { + return false; + } + + const { from, to } = view.state.selection; + if (from === to) { + return false; + } + + const selectedText = view.state.doc.textBetween(from, to, "\n").trim(); + if (!selectedText) { + return false; + } + + event.preventDefault(); + setNoteSearchQuery(selectedText); + setNoteSearchOpen(true); + setNoteSearchReplaceOpen(false); + window.requestAnimationFrame(() => { + noteSearchInputRef.current?.focus(); + noteSearchInputRef.current?.select(); + }); + return true; + }, handlePaste: (_view, event) => { const files = getImageFilesFromDataTransfer(event.clipboardData);