Unified management of keymap

This commit is contained in:
2025-06-21 00:28:06 +08:00
parent cb3d369aef
commit 6acab678d0
21 changed files with 1536 additions and 990 deletions

View File

@@ -1,5 +1,4 @@
export { VSCodeSearch, vscodeSearch} from "./plugin";
export { searchVisibilityField, SearchVisibilityEffect } from "./state";
export { customSearchKeymap } from "./keymap";
export { searchBaseTheme } from "./theme"
export * from "./commands"

View File

@@ -1,81 +0,0 @@
import { KeyBinding } from "@codemirror/view";
import { deleteCharacterBackwards, deleteCharacterFowards, hideSearchVisibilityCommand, searchFindPrevious, searchFindReplaceMatch, searchMoveCursorLeft, searchMoveCursorRight, searchReplaceAll, searchShowReplace, searchToggleCase, searchToggleRegex, searchToggleWholeWord, selectAllCommand, showSearchVisibilityCommand } from "./commands";
export const customSearchKeymap: KeyBinding[] = [
// 全局快捷键 - 不需要 scope 限制
{
key: 'Mod-f',
run: showSearchVisibilityCommand,
},
// 添加备用快捷键绑定,确保兼容性
{
key: 'Ctrl-f',
run: showSearchVisibilityCommand,
},
// 搜索面板内的快捷键 - 需要 scope 限制
{
key: 'Mod-a',
run: selectAllCommand,
scope: 'search'
},
{
key: 'Escape',
run: hideSearchVisibilityCommand,
scope: 'search'
},
{
key: 'Alt-c',
run: searchToggleCase,
scope: 'search'
},
{
key: 'Alt-w',
run: searchToggleWholeWord,
scope: 'search'
},
{
key: 'Alt-r',
run: searchToggleRegex,
scope: 'search'
},
{
key: 'Mod-h',
run: searchShowReplace,
scope: 'search'
},
{
key: 'Enter',
run: searchFindReplaceMatch,
scope: 'search'
},
{
key: 'Shift-Enter',
run: searchFindPrevious,
scope: 'search'
},
{
key: 'Mod-Alt-Enter',
run: searchReplaceAll,
scope: 'search'
},
{
key: 'Backspace',
run: deleteCharacterBackwards,
scope: 'search'
},
{
key: 'Delete',
run: deleteCharacterFowards,
scope: 'search'
},
{
key: "ArrowLeft",
run: searchMoveCursorLeft,
scope: 'search'
},
{
key: "ArrowRight",
run: searchMoveCursorRight,
scope: 'search'
},
];