feat(query-editor): 新增编辑器内搜索入口

- 在查询编辑器工具栏新增搜索入口并直连 Monaco 查找\n- 接管 Ctrl/Cmd+F,优先打开编辑器内搜索而不是浏览器默认查找\n- 补充多语言文案与静态测试覆盖\n\nFixes #539
This commit is contained in:
Syngnat
2026-06-29 20:00:27 +08:00
parent a7fdab5bb2
commit 93006d8423
11 changed files with 171 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ import {
FormatPainterOutlined,
PlayCircleOutlined,
RobotOutlined,
SearchOutlined,
SaveOutlined,
SettingOutlined,
StopOutlined,
@@ -51,6 +52,7 @@ type QueryEditorToolbarProps = {
onRun: () => void;
onCancel: () => void;
onQuickSave: () => void;
onFindInEditor: () => void;
onFormat: () => void;
onToggleResultPanelVisibility: () => void;
onAIAction: (action: "generate" | "explain" | "optimize" | "schema") => void;
@@ -112,6 +114,7 @@ const QueryEditorToolbar: React.FC<QueryEditorToolbarProps> = ({
onRun,
onCancel,
onQuickSave,
onFindInEditor,
onFormat,
onToggleResultPanelVisibility,
onAIAction,
@@ -161,6 +164,17 @@ const QueryEditorToolbar: React.FC<QueryEditorToolbarProps> = ({
),
})
: t("query_editor.action.format_sql");
const findInEditorShortcutCombo =
activeShortcutPlatform === "mac" ? "Meta+F" : "Ctrl+F";
const findInEditorTitle = t(
"query_editor.action.find_in_editor_with_shortcut",
{
shortcut: getShortcutDisplayLabel(
findInEditorShortcutCombo,
activeShortcutPlatform,
),
},
);
const aiMenuItems: MenuProps["items"] = [
{
key: "ai-generate",
@@ -371,6 +385,11 @@ const QueryEditorToolbar: React.FC<QueryEditorToolbarProps> = ({
className={isV2Ui ? "gn-v2-query-toolbar-action-pair" : undefined}
style={{ display: "flex", gap: "8px", alignItems: "center" }}
>
<Tooltip title={findInEditorTitle}>
<Button icon={<SearchOutlined />} onClick={onFindInEditor}>
{t("query_editor.action.find_in_editor")}
</Button>
</Tooltip>
<Tooltip title={formatSqlTitle}>
<Button icon={<FormatPainterOutlined />} onClick={onFormat}>
{t("query_editor.action.format")}