mirror of
				https://github.com/mermaid-js/mermaid.git
				synced 2025-10-25 17:04:19 +02:00 
			
		
		
		
	chore: Fix config type
This commit is contained in:
		| @@ -6,6 +6,16 @@ | ||||
|  | ||||
| # Module: config | ||||
|  | ||||
| ## Type Aliases | ||||
|  | ||||
| ### MermaidConfigWithDefaults | ||||
|  | ||||
| Ƭ **MermaidConfigWithDefaults**: `RequiredDeep`<`MermaidConfig`> | ||||
|  | ||||
| #### Defined in | ||||
|  | ||||
| [config.ts:10](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L10) | ||||
|  | ||||
| ## Variables | ||||
|  | ||||
| ### defaultConfig | ||||
| @@ -14,7 +24,7 @@ | ||||
|  | ||||
| #### Defined in | ||||
|  | ||||
| [config.ts:8](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L8) | ||||
| [config.ts:12](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L12) | ||||
|  | ||||
| ## Functions | ||||
|  | ||||
| @@ -36,13 +46,13 @@ Pushes in a directive to the configuration | ||||
|  | ||||
| #### Defined in | ||||
|  | ||||
| [config.ts:188](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L188) | ||||
| [config.ts:192](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L192) | ||||
|  | ||||
| --- | ||||
|  | ||||
| ### getConfig | ||||
|  | ||||
| ▸ **getConfig**(): `MermaidConfig` | ||||
| ▸ **getConfig**(): `RequiredObjectDeep`<`MermaidConfig`> | ||||
|  | ||||
| ## getConfig | ||||
|  | ||||
| @@ -54,13 +64,13 @@ Pushes in a directive to the configuration | ||||
|  | ||||
| #### Returns | ||||
|  | ||||
| `MermaidConfig` | ||||
| `RequiredObjectDeep`<`MermaidConfig`> | ||||
|  | ||||
| The currentConfig | ||||
|  | ||||
| #### Defined in | ||||
|  | ||||
| [config.ts:131](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L131) | ||||
| [config.ts:135](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L135) | ||||
|  | ||||
| --- | ||||
|  | ||||
| @@ -84,7 +94,7 @@ The siteConfig | ||||
|  | ||||
| #### Defined in | ||||
|  | ||||
| [config.ts:96](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L96) | ||||
| [config.ts:100](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L100) | ||||
|  | ||||
| --- | ||||
|  | ||||
| @@ -118,7 +128,7 @@ The siteConfig | ||||
|  | ||||
| #### Defined in | ||||
|  | ||||
| [config.ts:218](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L218) | ||||
| [config.ts:222](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L222) | ||||
|  | ||||
| --- | ||||
|  | ||||
| @@ -147,7 +157,7 @@ options in-place | ||||
|  | ||||
| #### Defined in | ||||
|  | ||||
| [config.ts:146](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L146) | ||||
| [config.ts:150](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L150) | ||||
|  | ||||
| --- | ||||
|  | ||||
| @@ -167,7 +177,7 @@ options in-place | ||||
|  | ||||
| #### Defined in | ||||
|  | ||||
| [config.ts:75](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L75) | ||||
| [config.ts:79](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L79) | ||||
|  | ||||
| --- | ||||
|  | ||||
| @@ -199,7 +209,7 @@ The currentConfig merged with the sanitized conf | ||||
|  | ||||
| #### Defined in | ||||
|  | ||||
| [config.ts:113](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L113) | ||||
| [config.ts:117](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L117) | ||||
|  | ||||
| --- | ||||
|  | ||||
| @@ -232,7 +242,7 @@ The new siteConfig | ||||
|  | ||||
| #### Defined in | ||||
|  | ||||
| [config.ts:61](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L61) | ||||
| [config.ts:65](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L65) | ||||
|  | ||||
| --- | ||||
|  | ||||
| @@ -253,7 +263,7 @@ The new siteConfig | ||||
|  | ||||
| #### Defined in | ||||
|  | ||||
| [config.ts:15](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L15) | ||||
| [config.ts:19](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L19) | ||||
|  | ||||
| --- | ||||
|  | ||||
| @@ -273,4 +283,4 @@ The new siteConfig | ||||
|  | ||||
| #### Defined in | ||||
|  | ||||
| [config.ts:79](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L79) | ||||
| [config.ts:83](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L83) | ||||
|   | ||||
| @@ -31,7 +31,7 @@ Renames and re-exports [mermaidAPI](mermaidAPI.md#mermaidapi) | ||||
|  | ||||
| ### mermaidAPI | ||||
|  | ||||
| • `Const` **mermaidAPI**: `Readonly`<{ `defaultConfig`: `MermaidConfig` = configApi.defaultConfig; `getConfig`: () => `MermaidConfig` = configApi.getConfig; `getDiagramFromText`: (`text`: `string`, `metadata`: `Pick`<`DiagramMetadata`, `"title"`>) => `Promise`<`Diagram`> ; `getSiteConfig`: () => `MermaidConfig` = configApi.getSiteConfig; `globalReset`: () => `void` ; `initialize`: (`options`: `MermaidConfig`) => `void` ; `parse`: (`text`: `string`, `parseOptions?`: [`ParseOptions`](../interfaces/mermaidAPI.ParseOptions.md)) => `Promise`<`boolean`> ; `render`: (`id`: `string`, `text`: `string`, `svgContainingElement?`: `Element`) => `Promise`<[`RenderResult`](../interfaces/mermaidAPI.RenderResult.md)> ; `reset`: () => `void` ; `setConfig`: (`conf`: `MermaidConfig`) => `MermaidConfig` = configApi.setConfig; `updateSiteConfig`: (`conf`: `MermaidConfig`) => `MermaidConfig` = configApi.updateSiteConfig }> | ||||
| • `Const` **mermaidAPI**: `Readonly`<{ `defaultConfig`: `MermaidConfig` = configApi.defaultConfig; `getConfig`: () => `RequiredObjectDeep`<`MermaidConfig`> = configApi.getConfig; `getDiagramFromText`: (`text`: `string`, `metadata`: `Pick`<`DiagramMetadata`, `"title"`>) => `Promise`<`Diagram`> ; `getSiteConfig`: () => `MermaidConfig` = configApi.getSiteConfig; `globalReset`: () => `void` ; `initialize`: (`options`: `MermaidConfig`) => `void` ; `parse`: (`text`: `string`, `parseOptions?`: [`ParseOptions`](../interfaces/mermaidAPI.ParseOptions.md)) => `Promise`<`boolean`> ; `render`: (`id`: `string`, `text`: `string`, `svgContainingElement?`: `Element`) => `Promise`<[`RenderResult`](../interfaces/mermaidAPI.RenderResult.md)> ; `reset`: () => `void` ; `setConfig`: (`conf`: `MermaidConfig`) => `MermaidConfig` = configApi.setConfig; `updateSiteConfig`: (`conf`: `MermaidConfig`) => `MermaidConfig` = configApi.updateSiteConfig }> | ||||
|  | ||||
| ## mermaidAPI configuration defaults | ||||
|  | ||||
|   | ||||
| @@ -2,8 +2,12 @@ import assignWithDepth from './assignWithDepth.js'; | ||||
| import { log } from './logger.js'; | ||||
| import theme from './themes/index.js'; | ||||
| import config from './defaultConfig.js'; | ||||
| import type { MermaidConfig, MermaidConfigWithDefaults } from './config.type.js'; | ||||
| import type { MermaidConfig } from './config.type.js'; | ||||
| import { sanitizeDirective } from './utils/sanitizeDirective.js'; | ||||
| import type { RequiredDeep } from 'type-fest'; | ||||
|  | ||||
| // I'd prefer this to be named MermaidConfig, so all the functions can use the shorter name. | ||||
| export type MermaidConfigWithDefaults = RequiredDeep<MermaidConfig>; | ||||
|  | ||||
| export const defaultConfig: MermaidConfig = Object.freeze(config); | ||||
|  | ||||
|   | ||||
| @@ -5,8 +5,6 @@ | ||||
|  * and run json-schema-to-typescript to regenerate this file. | ||||
|  */ | ||||
|  | ||||
| import { RequiredDeep } from 'type-fest'; | ||||
|  | ||||
| /** | ||||
|  * Configuration options to pass to the `dompurify` library. | ||||
|  */ | ||||
| @@ -167,9 +165,6 @@ 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". | ||||
|   | ||||
| @@ -7,10 +7,11 @@ import cytoscape from 'cytoscape'; | ||||
| // @ts-expect-error No types available | ||||
| import coseBilkent from 'cytoscape-cose-bilkent'; | ||||
| import * as db from './mindmapDb.js'; | ||||
| import type { MermaidConfig, MermaidConfigWithDefaults } from '../../config.type.js'; | ||||
| import type { MermaidConfig } from '../../config.type.js'; | ||||
| import type { Diagram } from '../../Diagram.js'; | ||||
| import type { MindmapDB } from './mindmapTypes.js'; | ||||
| import type { D3Element } from '../../mermaidAPI.js'; | ||||
| import type { MermaidConfigWithDefaults } from '../../config.js'; | ||||
|  | ||||
| // Inject the layout algorithm into cytoscape | ||||
| cytoscape.use(coseBilkent); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Sidharth Vinod
					Sidharth Vinod