This commit is contained in:
Sidharth Vinod
2024-03-23 15:35:41 +05:30
parent f6fa88e5ff
commit 63e3b1af52
2 changed files with 12 additions and 12 deletions

View File

@@ -1,4 +1,4 @@
<!DOCTYPE html> <!doctype html>
<html> <html>
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />

View File

@@ -110,7 +110,7 @@ function processAndSetConfigs(text: string) {
*/ */
async function parse( async function parse(
text: string, text: string,
parseOptions: ParseOptions & { suppressErrors: true }, parseOptions: ParseOptions & { suppressErrors: true }
): Promise<ParseResult | false>; ): Promise<ParseResult | false>;
async function parse(text: string, parseOptions?: ParseOptions): Promise<ParseResult>; async function parse(text: string, parseOptions?: ParseOptions): Promise<ParseResult>;
async function parse(text: string, parseOptions?: ParseOptions): Promise<ParseResult | false> { async function parse(text: string, parseOptions?: ParseOptions): Promise<ParseResult | false> {
@@ -138,7 +138,7 @@ async function parse(text: string, parseOptions?: ParseOptions): Promise<ParseRe
export const cssImportantStyles = ( export const cssImportantStyles = (
cssClass: string, cssClass: string,
element: string, element: string,
cssClasses: string[] = [], cssClasses: string[] = []
): string => { ): string => {
return `\n.${cssClass} ${element} { ${cssClasses.join(' !important; ')} !important; }`; return `\n.${cssClass} ${element} { ${cssClasses.join(' !important; ')} !important; }`;
}; };
@@ -152,7 +152,7 @@ export const cssImportantStyles = (
*/ */
export const createCssStyles = ( export const createCssStyles = (
config: MermaidConfig, config: MermaidConfig,
classDefs: Record<string, DiagramStyleClassDef> | null | undefined = {}, classDefs: Record<string, DiagramStyleClassDef> | null | undefined = {}
): string => { ): string => {
let cssStyles = ''; let cssStyles = '';
@@ -201,7 +201,7 @@ export const createUserStyles = (
config: MermaidConfig, config: MermaidConfig,
graphType: string, graphType: string,
classDefs: Record<string, DiagramStyleClassDef> | undefined, classDefs: Record<string, DiagramStyleClassDef> | undefined,
svgId: string, svgId: string
): string => { ): string => {
const userCSSstyles = createCssStyles(config, classDefs); const userCSSstyles = createCssStyles(config, classDefs);
const allStyles = getStyles(graphType, userCSSstyles, config.themeVariables); const allStyles = getStyles(graphType, userCSSstyles, config.themeVariables);
@@ -223,7 +223,7 @@ export const createUserStyles = (
export const cleanUpSvgCode = ( export const cleanUpSvgCode = (
svgCode = '', svgCode = '',
inSandboxMode: boolean, inSandboxMode: boolean,
useArrowMarkerUrls: boolean, useArrowMarkerUrls: boolean
): string => { ): string => {
let cleanedUpSvg = svgCode; let cleanedUpSvg = svgCode;
@@ -231,7 +231,7 @@ export const cleanUpSvgCode = (
if (!useArrowMarkerUrls && !inSandboxMode) { if (!useArrowMarkerUrls && !inSandboxMode) {
cleanedUpSvg = cleanedUpSvg.replace( cleanedUpSvg = cleanedUpSvg.replace(
/marker-end="url\([\d+./:=?A-Za-z-]*?#/g, /marker-end="url\([\d+./:=?A-Za-z-]*?#/g,
'marker-end="url(#', 'marker-end="url(#'
); );
} }
@@ -279,7 +279,7 @@ export const appendDivSvgG = (
id: string, id: string,
enclosingDivId: string, enclosingDivId: string,
divStyle?: string, divStyle?: string,
svgXlink?: string, svgXlink?: string
): D3Element => { ): D3Element => {
const enclosingDiv = parentRoot.append('div'); const enclosingDiv = parentRoot.append('div');
enclosingDiv.attr('id', enclosingDivId); enclosingDiv.attr('id', enclosingDivId);
@@ -328,7 +328,7 @@ export const removeExistingElements = (
doc: Document, doc: Document,
id: string, id: string,
divId: string, divId: string,
iFrameId: string, iFrameId: string
) => { ) => {
// Remove existing SVG element if it exists // Remove existing SVG element if it exists
doc.getElementById(id)?.remove(); doc.getElementById(id)?.remove();
@@ -347,7 +347,7 @@ export const removeExistingElements = (
const render = async function ( const render = async function (
id: string, id: string,
text: string, text: string,
svgContainingElement?: Element, svgContainingElement?: Element
): Promise<RenderResult> { ): Promise<RenderResult> {
addDiagrams(); addDiagrams();
@@ -532,7 +532,7 @@ function initialize(options: MermaidConfig = {}) {
if (options?.theme && options.theme in theme) { if (options?.theme && options.theme in theme) {
// Todo merge with user options // Todo merge with user options
options.themeVariables = theme[options.theme as keyof typeof theme].getThemeVariables( options.themeVariables = theme[options.theme as keyof typeof theme].getThemeVariables(
options.themeVariables, options.themeVariables
); );
} else if (options) { } else if (options) {
options.themeVariables = theme.default.getThemeVariables(options.themeVariables); options.themeVariables = theme.default.getThemeVariables(options.themeVariables);
@@ -562,7 +562,7 @@ function addA11yInfo(
diagramType: string, diagramType: string,
svgNode: D3Element, svgNode: D3Element,
a11yTitle?: string, a11yTitle?: string,
a11yDescr?: string, a11yDescr?: string
): void { ): void {
setA11yDiagramInfo(svgNode, diagramType); setA11yDiagramInfo(svgNode, diagramType);
addSVGa11yTitleDescription(svgNode, a11yTitle, a11yDescr, svgNode.attr('id')); addSVGa11yTitleDescription(svgNode, a11yTitle, a11yDescr, svgNode.attr('id'));