feat(editor): copy selected SQL as rich text with highlighting

This commit is contained in:
邹超 authored and GitHub committed 2026-09-14 13:24:10 +08:00
1 parent 94617a5923
commit 2249aa30c0
17 files changed
+339 -4

No files matched your search

+7 -2
View File
@@ -20,7 +20,7 @@ const SHIKI_THEMES = {
},
} as const;
type ShikiHighlighter = Awaited<ReturnType<typeof import("shiki/core").createHighlighterCore>>;
export type ShikiHighlighter = Awaited<ReturnType<typeof import("shiki/core").createHighlighterCore>>;
type ShikiCodeHighlighter = Pick<ShikiHighlighter, "codeToHtml">;
let highlighterPromise: Promise<ShikiHighlighter> | undefined;
@@ -68,7 +68,12 @@ export function escapeHtml(content: string): string {
});
}
function getShikiSqlHighlighter(): Promise<ShikiHighlighter> {
/**
* Lazily-initialized shared highlighter. Exported so other SQL renderers
* (e.g. rich-text copy) reuse one Shiki instance instead of loading the SQL
* grammar and themes a second time.
*/
export function getShikiSqlHighlighter(): Promise<ShikiHighlighter> {
highlighterPromise ??= loadShikiSqlHighlighter();
return highlighterPromise;
}