mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-10-21 15:09:39 +02:00
feat: add helper to differentiate user-defined layout from default
on-behalf-of: @Mermaid-Chart <hello@mermaidchart.com>
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
- [addDirective](functions/addDirective.md)
|
- [addDirective](functions/addDirective.md)
|
||||||
- [getConfig](functions/getConfig.md)
|
- [getConfig](functions/getConfig.md)
|
||||||
|
- [getLayoutInfo](functions/getLayoutInfo.md)
|
||||||
- [getSiteConfig](functions/getSiteConfig.md)
|
- [getSiteConfig](functions/getSiteConfig.md)
|
||||||
- [reset](functions/reset.md)
|
- [reset](functions/reset.md)
|
||||||
- [sanitize](functions/sanitize.md)
|
- [sanitize](functions/sanitize.md)
|
||||||
|
27
docs/config/setup/config/functions/getLayoutInfo.md
Normal file
27
docs/config/setup/config/functions/getLayoutInfo.md
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
> **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`
|
@@ -248,3 +248,19 @@ const checkConfig = (config: MermaidConfig) => {
|
|||||||
issueWarning('LAZY_LOAD_DEPRECATED');
|
issueWarning('LAZY_LOAD_DEPRECATED');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isUserDefinedLayout = (): boolean => {
|
||||||
|
if (configFromInitialize?.layout) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return directives.some((d) => !!d.layout);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getLayoutInfo = () => {
|
||||||
|
const cfg = getConfig();
|
||||||
|
return {
|
||||||
|
layout: cfg.layout ?? 'dagre',
|
||||||
|
isUserDefined: isUserDefinedLayout(),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
Reference in New Issue
Block a user