mirror of
https://github.com/t8y2/dbx.git
synced 2026-11-02 00:29:30 +00:00
feat: add query editor replace shortcut
This commit is contained in:
@@ -148,6 +148,7 @@ const useRegex = ref(false);
|
||||
const matchCount = ref(0);
|
||||
const currentMatchIndex = ref(0);
|
||||
const searchInputRef = ref<HTMLInputElement>();
|
||||
const replaceInputRef = ref<HTMLInputElement>();
|
||||
|
||||
interface EditorGestureEvent extends Event {
|
||||
scale?: number;
|
||||
@@ -315,6 +316,16 @@ function runKeymapExtension(codeMirrorKeymap: (typeof import("@codemirror/view")
|
||||
return true;
|
||||
},
|
||||
},
|
||||
{
|
||||
key: "Mod-h",
|
||||
preventDefault: true,
|
||||
run: openReplace,
|
||||
},
|
||||
{
|
||||
key: "Ctrl-h",
|
||||
preventDefault: true,
|
||||
run: openReplace,
|
||||
},
|
||||
{
|
||||
key: shortcutToCodeMirrorKey(shortcuts.executeSql),
|
||||
preventDefault: true,
|
||||
@@ -1365,6 +1376,16 @@ function openSearch(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
function openReplace(): boolean {
|
||||
openSearch();
|
||||
showReplace.value = true;
|
||||
nextTick(() => {
|
||||
replaceInputRef.value?.focus();
|
||||
replaceInputRef.value?.select();
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
function closeSearch() {
|
||||
searchVisible.value = false;
|
||||
showReplace.value = false;
|
||||
@@ -1504,6 +1525,7 @@ defineExpose({ openSearch });
|
||||
</div>
|
||||
<div v-if="showReplace" class="flex items-center gap-0.5">
|
||||
<input
|
||||
ref="replaceInputRef"
|
||||
v-model="replaceText"
|
||||
autocapitalize="off"
|
||||
autocorrect="off"
|
||||
@@ -1524,7 +1546,7 @@ defineExpose({ openSearch });
|
||||
:title="t('editor.search.replaceAll')"
|
||||
@click="doReplaceAll"
|
||||
>
|
||||
全部
|
||||
{{ t("editor.search.replaceAll") }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -371,6 +371,7 @@ export interface QueryTab {
|
||||
| "cte"
|
||||
| "set-operation"
|
||||
| "aggregation"
|
||||
| "external-source"
|
||||
| "complex-source"
|
||||
| "computed-columns"
|
||||
| "no-table"
|
||||
|
||||
Reference in New Issue
Block a user