mirror of
https://github.com/t8y2/dbx.git
synced 2026-11-02 00:29:30 +00:00
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:
@@ -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 };
|
||||
}
|
||||
Reference in New Issue
Block a user