mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-25 11:16:53 +02:00
tidy-tree as the default layout for mindmaps
on-behalf-of: @Mermaid-Chart <hello@mermaidchart.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { cleanupComments } from './diagram-api/comments.js';
|
import { cleanupComments } from './diagram-api/comments.js';
|
||||||
|
import { detectType } from './diagram-api/detectType.js';
|
||||||
import { extractFrontMatter } from './diagram-api/frontmatter.js';
|
import { extractFrontMatter } from './diagram-api/frontmatter.js';
|
||||||
import type { DiagramMetadata } from './diagram-api/types.js';
|
import type { DiagramMetadata } from './diagram-api/types.js';
|
||||||
import utils, { cleanAndMerge, removeDirectives } from './utils.js';
|
import utils, { cleanAndMerge, removeDirectives } from './utils.js';
|
||||||
@@ -18,6 +19,7 @@ const cleanupText = (code: string) => {
|
|||||||
|
|
||||||
const processFrontmatter = (code: string) => {
|
const processFrontmatter = (code: string) => {
|
||||||
const { text, metadata } = extractFrontMatter(code);
|
const { text, metadata } = extractFrontMatter(code);
|
||||||
|
const diagramType = detectType(text);
|
||||||
const { displayMode, title, config = {} } = metadata;
|
const { displayMode, title, config = {} } = metadata;
|
||||||
if (displayMode) {
|
if (displayMode) {
|
||||||
// Needs to be supported for legacy reasons
|
// Needs to be supported for legacy reasons
|
||||||
@@ -26,6 +28,9 @@ const processFrontmatter = (code: string) => {
|
|||||||
}
|
}
|
||||||
config.gantt.displayMode = displayMode;
|
config.gantt.displayMode = displayMode;
|
||||||
}
|
}
|
||||||
|
if (diagramType === 'mindmap' && !config.layout) {
|
||||||
|
config.layout = 'tidy-tree';
|
||||||
|
}
|
||||||
return { title, config, text };
|
return { title, config, text };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user