feat(editor): enable search in embedded source views

This commit is contained in:
t8y2 committed 2026-07-23 21:53:54 +08:00
1 parent 3f228a04b0
commit 094d1fefde
4 files changed
+96 -1

No files matched your search

@@ -0,0 +1,23 @@
import type { KeyBinding } from "@codemirror/view";
interface QueryEditorSearchKeymapOptions {
openSearch: () => boolean;
openReplace: () => boolean;
isReadOnly: () => boolean;
}
export function createQueryEditorSearchKeymap(options: QueryEditorSearchKeymapOptions): KeyBinding[] {
return [
{
key: "Mod-f",
preventDefault: true,
run: options.openSearch,
},
{
key: "Mod-h",
preventDefault: true,
// Consume the shortcut in previews without exposing mutation controls.
run: () => options.isReadOnly() || options.openReplace(),
},
];
}