mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-14 06:43:25 +08:00
feat: Set config.layout=elk when using flowchart-elk
This commit is contained in:
parent
754fa24104
commit
bc3fe33428
@ -1,34 +1,26 @@
|
||||
import type {
|
||||
ExternalDiagramDefinition,
|
||||
DiagramDetector,
|
||||
DiagramLoader,
|
||||
ExternalDiagramDefinition,
|
||||
} from '../../../diagram-api/types.js';
|
||||
import { log } from '../../../logger.js';
|
||||
|
||||
const id = 'flowchart-elk';
|
||||
|
||||
const detector: DiagramDetector = (txt, config): boolean => {
|
||||
const detector: DiagramDetector = (txt, config = {}): boolean => {
|
||||
if (
|
||||
// If diagram explicitly states flowchart-elk
|
||||
/^\s*flowchart-elk/.test(txt) ||
|
||||
// If a flowchart/graph diagram has their default renderer set to elk
|
||||
(/^\s*flowchart|graph/.test(txt) && config?.flowchart?.defaultRenderer === 'elk')
|
||||
) {
|
||||
// This will log at the end, hopefully.
|
||||
setTimeout(
|
||||
() =>
|
||||
log.warn(
|
||||
'flowchart-elk was moved to an external package in Mermaid v11. Please refer [release notes](link) for more details. This diagram will be rendered using `dagre` layout as a fallback.'
|
||||
),
|
||||
500
|
||||
);
|
||||
config.layout = 'elk';
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
const loader: DiagramLoader = async () => {
|
||||
const { diagram } = await import('../flowDiagram-v2.js');
|
||||
const { diagram } = await import('../flowDiagram.js');
|
||||
return { id, diagram };
|
||||
};
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
// @ts-ignore: JISON doesn't support types
|
||||
import flowParser from './parser/flow.jison';
|
||||
import flowDb from './flowDb.js';
|
||||
import renderer from './flowRenderer-v3-unified.js';
|
||||
import flowStyles from './styles.js';
|
||||
import type { MermaidConfig } from '../../config.type.js';
|
||||
import { setConfig } from '../../diagram-api/diagramAPI.js';
|
||||
import flowDb from './flowDb.js';
|
||||
import renderer from './flowRenderer-v3-unified.js';
|
||||
// @ts-ignore: JISON doesn't support types
|
||||
import flowParser from './parser/flow.jison';
|
||||
import flowStyles from './styles.js';
|
||||
|
||||
export const diagram = {
|
||||
parser: flowParser,
|
||||
@ -15,6 +15,9 @@ export const diagram = {
|
||||
if (!cnf.flowchart) {
|
||||
cnf.flowchart = {};
|
||||
}
|
||||
if (cnf.layout) {
|
||||
setConfig({ layout: cnf.layout });
|
||||
}
|
||||
cnf.flowchart.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute;
|
||||
setConfig({ flowchart: { arrowMarkerAbsolute: cnf.arrowMarkerAbsolute } });
|
||||
flowDb.clear();
|
||||
|
Loading…
x
Reference in New Issue
Block a user