mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-31 16:24:33 +00:00
fix(editor): bundle SQL formatter for offline use
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { format } from "sql-formatter";
|
||||
|
||||
export type SqlFormatDialect = "mysql" | "postgres" | "sqlite" | "sqlserver" | "generic";
|
||||
|
||||
function formatterLanguage(dialect: SqlFormatDialect) {
|
||||
@@ -17,7 +19,6 @@ function formatterLanguage(dialect: SqlFormatDialect) {
|
||||
|
||||
export async function formatSqlText(sql: string, dialect: SqlFormatDialect = "generic"): Promise<string> {
|
||||
if (!sql.trim()) return sql;
|
||||
const { format } = await import("sql-formatter");
|
||||
return format(sql, {
|
||||
language: formatterLanguage(dialect),
|
||||
keywordCase: "upper",
|
||||
|
||||
Reference in New Issue
Block a user