mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-08 18:16:44 +02:00
refactor: remove layout-specific checks and create generic function
on-behalf-of: @Mermaid-Chart <hello@mermaidchart.com>
This commit is contained in:
@@ -18,8 +18,8 @@
|
||||
|
||||
- [addDirective](functions/addDirective.md)
|
||||
- [getConfig](functions/getConfig.md)
|
||||
- [getLayoutInfo](functions/getLayoutInfo.md)
|
||||
- [getSiteConfig](functions/getSiteConfig.md)
|
||||
- [getUserDefinedConfig](functions/getUserDefinedConfig.md)
|
||||
- [reset](functions/reset.md)
|
||||
- [sanitize](functions/sanitize.md)
|
||||
- [saveConfigFromInitialize](functions/saveConfigFromInitialize.md)
|
||||
|
@@ -1,27 +0,0 @@
|
||||
> **Warning**
|
||||
>
|
||||
> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT.
|
||||
>
|
||||
> ## Please edit the corresponding file in [/packages/mermaid/src/docs/config/setup/config/functions/getLayoutInfo.md](../../../../../packages/mermaid/src/docs/config/setup/config/functions/getLayoutInfo.md).
|
||||
|
||||
[**mermaid**](../../README.md)
|
||||
|
||||
---
|
||||
|
||||
# Function: getLayoutInfo()
|
||||
|
||||
> **getLayoutInfo**(): `object`
|
||||
|
||||
Defined in: [packages/mermaid/src/config.ts:260](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L260)
|
||||
|
||||
## Returns
|
||||
|
||||
`object`
|
||||
|
||||
### isUserDefined
|
||||
|
||||
> **isUserDefined**: `boolean`
|
||||
|
||||
### layout
|
||||
|
||||
> **layout**: `string`
|
19
docs/config/setup/config/functions/getUserDefinedConfig.md
Normal file
19
docs/config/setup/config/functions/getUserDefinedConfig.md
Normal file
@@ -0,0 +1,19 @@
|
||||
> **Warning**
|
||||
>
|
||||
> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT.
|
||||
>
|
||||
> ## Please edit the corresponding file in [/packages/mermaid/src/docs/config/setup/config/functions/getUserDefinedConfig.md](../../../../../packages/mermaid/src/docs/config/setup/config/functions/getUserDefinedConfig.md).
|
||||
|
||||
[**mermaid**](../../README.md)
|
||||
|
||||
---
|
||||
|
||||
# Function: getUserDefinedConfig()
|
||||
|
||||
> **getUserDefinedConfig**(): [`MermaidConfig`](../../mermaid/interfaces/MermaidConfig.md)
|
||||
|
||||
Defined in: [packages/mermaid/src/config.ts:252](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L252)
|
||||
|
||||
## Returns
|
||||
|
||||
[`MermaidConfig`](../../mermaid/interfaces/MermaidConfig.md)
|
@@ -249,18 +249,16 @@ const checkConfig = (config: MermaidConfig) => {
|
||||
}
|
||||
};
|
||||
|
||||
const isUserDefinedLayout = (): boolean => {
|
||||
if (configFromInitialize?.layout) {
|
||||
return true;
|
||||
export const getUserDefinedConfig = (): MermaidConfig => {
|
||||
let userConfig: MermaidConfig = {};
|
||||
|
||||
if (configFromInitialize) {
|
||||
userConfig = assignWithDepth(userConfig, configFromInitialize);
|
||||
}
|
||||
|
||||
return directives.some((d) => !!d.layout);
|
||||
};
|
||||
for (const d of directives) {
|
||||
userConfig = assignWithDepth(userConfig, d);
|
||||
}
|
||||
|
||||
export const getLayoutInfo = () => {
|
||||
const cfg = getConfig();
|
||||
return {
|
||||
layout: cfg.layout ?? 'dagre',
|
||||
isUserDefined: isUserDefinedLayout(),
|
||||
};
|
||||
return userConfig;
|
||||
};
|
||||
|
Reference in New Issue
Block a user