Add MermaidConfigWithDefaults

This commit is contained in:
Sidharth Vinod 2024-01-28 16:02:28 +05:30
parent f30c26485e
commit ba0bddf417
No known key found for this signature in database
GPG Key ID: FB5CCD378D3907CD
3 changed files with 7 additions and 3 deletions

View File

@ -2,7 +2,7 @@ import assignWithDepth from './assignWithDepth.js';
import { log } from './logger.js';
import theme from './themes/index.js';
import config from './defaultConfig.js';
import type { MermaidConfig } from './config.type.js';
import type { MermaidConfig, MermaidConfigWithDefaults } from './config.type.js';
import { sanitizeDirective } from './utils/sanitizeDirective.js';
export const defaultConfig: MermaidConfig = Object.freeze(config);
@ -128,7 +128,7 @@ export const setConfig = (conf: MermaidConfig): MermaidConfig => {
*
* @returns The currentConfig
*/
export const getConfig = (): MermaidConfig => {
export const getConfig = (): MermaidConfigWithDefaults => {
return assignWithDepth({}, currentConfig);
};
/**

View File

@ -5,6 +5,8 @@
* and run json-schema-to-typescript to regenerate this file.
*/
import { RequiredDeep } from 'type-fest';
/**
* Configuration options to pass to the `dompurify` library.
*/
@ -165,6 +167,9 @@ export interface MermaidConfig {
wrap?: boolean;
fontSize?: number;
}
// I'd prefer this to be named MermaidConfig, so all the functions can use the shorter name.
export type MermaidConfigWithDefaults = RequiredDeep<MermaidConfig>;
/**
* This interface was referenced by `MermaidConfig`'s JSON-Schema
* via the `definition` "BaseDiagramConfig".

View File

@ -1,6 +1,5 @@
import type { Diagram } from '../../Diagram.js';
import { getConfig, defaultConfig } from '../../diagram-api/diagramAPI.js';
import {
select as d3select,
scaleOrdinal as d3scaleOrdinal,