Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

937 B
Raw Blame
import type { Command, KeyBinding } from "@codemirror/view";
import { matchesShortcut } from "@/lib/editor/keyboardShortcuts";
import { parseShortcutStrokes } from "@/lib/editor/shortcutDisplay";
import { shortcutToCodeMirrorKey } from "@/lib/editor/shortcutRegistry";

export function createQueryEditorSelectionCaseShortcutBindings(shortcut: string, run: Command, platform = globalThis.navigator?.platform || ""): KeyBinding[] {
  if (!shortcut) return [];

  // CodeMirror matches event.key, but macOS Option+letter produces a composed
  // character. Use the shared physical-key fallback for single-stroke bindings.
  if (parseShortcutStrokes(shortcut).length === 1) {
    return [
      {
        any(view, event) {
          if (!matchesShortcut(event, shortcut, platform)) return false;
          return run(view);
        },
      },
    ];
  }

  return [{ key: shortcutToCodeMirrorKey(shortcut), preventDefault: true, run }];
}