fix: add Shiki SQL syntax highlighting to all SQL display components

Add useSqlHighlighter composable and integrate Shiki highlighting into
DangerConfirmDialog, QueryHistory, DataGrid (replacing regex-based
highlighting), SqlFileExecutionDialog, SchemaDiffDialog, TreeItem,
ObjectBrowser, and FieldLineageDialog. Also fix danger dialog overflow
by adding overflow-hidden to DialogContent and wrap/scroll support.
This commit is contained in:
t8y2
2026-05-26 15:31:15 +08:00
parent a1f718d6bd
commit f5f986cdd6
10 changed files with 221 additions and 26 deletions
@@ -0,0 +1,20 @@
import { computed, onMounted, ref } from "vue";
import { useTheme } from "@/composables/useTheme";
import { type SqlHighlighter, createShikiSqlHighlighter } from "@/lib/sqlHighlighter";
export function useSqlHighlighter() {
const { isDark } = useTheme();
const sqlHighlighter = ref<SqlHighlighter>();
onMounted(async () => {
sqlHighlighter.value = await createShikiSqlHighlighter({
appearance: () => (isDark.value ? "dark" : "light"),
});
});
function highlight(sql: string): string {
return sqlHighlighter.value?.(sql) ?? sql;
}
return { highlight, sqlHighlighter };
}