Add full shell, replaceable Omics adapter and bilingual interaction
Implement approved specification #32 and tickets #33-#37. Keep host authentication server-verified and pin session interaction language. Compile scoped base selectors for browser compatibility and retain full gutters during CSS pruning.
This commit is contained in:
@@ -1,10 +1,19 @@
|
||||
let _initialized = false;
|
||||
let initializedTheme: "light" | "dark" | undefined;
|
||||
let rendering: Promise<unknown> = Promise.resolve();
|
||||
|
||||
export async function renderMermaid(def: string): Promise<string> {
|
||||
export function renderMermaid(def: string, theme: "light" | "dark" = "light"): Promise<string> {
|
||||
// Mermaid configuration is global: serialize renders so a theme change cannot
|
||||
// recolor another diagram midway through its asynchronous rendering.
|
||||
const result = rendering.then(() => renderDiagram(def, theme));
|
||||
rendering = result.catch(() => undefined);
|
||||
return result;
|
||||
}
|
||||
|
||||
async function renderDiagram(def: string, theme: "light" | "dark"): Promise<string> {
|
||||
const mermaid = (await import("mermaid")).default;
|
||||
if (!_initialized) {
|
||||
mermaid.initialize({ startOnLoad: false, theme: "default" });
|
||||
_initialized = true;
|
||||
if (initializedTheme !== theme) {
|
||||
mermaid.initialize({ startOnLoad: false, theme: theme === "dark" ? "dark" : "default" });
|
||||
initializedTheme = theme;
|
||||
}
|
||||
const id = `mermaid-${Math.random().toString(36).slice(2)}`;
|
||||
const container = document.createElement("div");
|
||||
|
||||
Reference in New Issue
Block a user