mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
Remove unnecessary parsing stage from render and prepare text before parsing
This commit is contained in:
parent
104aece46e
commit
518da3236f
@ -4,6 +4,10 @@ import parser from './parser/sankey.jison';
|
|||||||
import db from './sankeyDB.js';
|
import db from './sankeyDB.js';
|
||||||
import styles from './styles.js';
|
import styles from './styles.js';
|
||||||
import renderer from './sankeyRenderer.js';
|
import renderer from './sankeyRenderer.js';
|
||||||
|
import { prepareTextForParsing } from './sankeyUtils.js';
|
||||||
|
|
||||||
|
const originalParse = parser.parse.bind(parser);
|
||||||
|
parser.parse = (text: string) => originalParse(prepareTextForParsing(text));
|
||||||
|
|
||||||
export const diagram: DiagramDefinition = {
|
export const diagram: DiagramDefinition = {
|
||||||
parser,
|
parser,
|
||||||
|
@ -17,7 +17,6 @@ import {
|
|||||||
sankeyJustify as d3SankeyJustify,
|
sankeyJustify as d3SankeyJustify,
|
||||||
} from 'd3-sankey';
|
} from 'd3-sankey';
|
||||||
import { configureSvgSize } from '../../setupGraphViewbox.js';
|
import { configureSvgSize } from '../../setupGraphViewbox.js';
|
||||||
import { prepareTextForParsing } from './sankeyUtils.js';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws a sequenceDiagram in the tag with id: id based on the graph definition in text.
|
* Draws a sequenceDiagram in the tag with id: id based on the graph definition in text.
|
||||||
@ -28,14 +27,6 @@ import { prepareTextForParsing } from './sankeyUtils.js';
|
|||||||
* @param diagObj - A standard diagram containing the db and the text and type etc of the diagram
|
* @param diagObj - A standard diagram containing the db and the text and type etc of the diagram
|
||||||
*/
|
*/
|
||||||
export const draw = function (text: string, id: string, _version: string, diagObj: Diagram): void {
|
export const draw = function (text: string, id: string, _version: string, diagObj: Diagram): void {
|
||||||
// Clear DB before parsing
|
|
||||||
//
|
|
||||||
diagObj.db.clear?.();
|
|
||||||
|
|
||||||
// Launch parsing
|
|
||||||
const preparedText = prepareTextForParsing(text);
|
|
||||||
diagObj.parser.parse(preparedText);
|
|
||||||
|
|
||||||
// TODO: Figure out what is happening there
|
// TODO: Figure out what is happening there
|
||||||
// The main thing is svg object that is a d3 wrapper for svg operations
|
// The main thing is svg object that is a d3 wrapper for svg operations
|
||||||
//
|
//
|
||||||
|
Loading…
x
Reference in New Issue
Block a user