mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
convert flowDb to class.
This commit is contained in:
parent
df636c6d0a
commit
9ef6090c8c
@ -1,9 +1,11 @@
|
||||
import flowDb from './flowDb.js';
|
||||
import { FlowDb } from './flowDb.js';
|
||||
import type { FlowSubGraph } from './types.js';
|
||||
|
||||
describe('flow db subgraphs', () => {
|
||||
let flowDb: FlowDb;
|
||||
let subgraphs: FlowSubGraph[];
|
||||
beforeEach(() => {
|
||||
flowDb = new FlowDb();
|
||||
subgraphs = [
|
||||
{ nodes: ['a', 'b', 'c', 'e'] },
|
||||
{ nodes: ['f', 'g', 'h'] },
|
||||
@ -44,8 +46,9 @@ describe('flow db subgraphs', () => {
|
||||
});
|
||||
|
||||
describe('flow db addClass', () => {
|
||||
let flowDb: FlowDb;
|
||||
beforeEach(() => {
|
||||
flowDb.clear();
|
||||
flowDb = new FlowDb();
|
||||
});
|
||||
it('should detect many classes', () => {
|
||||
flowDb.addClass('a,b', ['stroke-width: 8px']);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
import type { MermaidConfig } from '../../config.type.js';
|
||||
import { setConfig } from '../../diagram-api/diagramAPI.js';
|
||||
import flowDb from './flowDb.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';
|
||||
@ -8,7 +8,9 @@ import flowStyles from './styles.js';
|
||||
|
||||
export const diagram = {
|
||||
parser: flowParser,
|
||||
db: flowDb,
|
||||
get db() {
|
||||
return new FlowDb();
|
||||
},
|
||||
renderer,
|
||||
styles: flowStyles,
|
||||
init: (cnf: MermaidConfig) => {
|
||||
@ -20,7 +22,5 @@ export const diagram = {
|
||||
}
|
||||
cnf.flowchart.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute;
|
||||
setConfig({ flowchart: { arrowMarkerAbsolute: cnf.arrowMarkerAbsolute } });
|
||||
flowDb.clear();
|
||||
flowDb.setGen('gen-2');
|
||||
},
|
||||
};
|
||||
|
@ -7,7 +7,6 @@ import { getRegisteredLayoutAlgorithm, render } from '../../rendering-util/rende
|
||||
import { setupViewPortForSVG } from '../../rendering-util/setupViewPortForSVG.js';
|
||||
import type { LayoutData } from '../../rendering-util/types.js';
|
||||
import utils from '../../utils.js';
|
||||
import { getDirection } from './flowDb.js';
|
||||
|
||||
export const getClasses = function (
|
||||
text: string,
|
||||
@ -37,7 +36,7 @@ export const draw = async function (text: string, id: string, _version: string,
|
||||
log.debug('Data: ', data4Layout);
|
||||
// Create the root SVG
|
||||
const svg = getDiagramElement(id, securityLevel);
|
||||
const direction = getDirection();
|
||||
const direction = diag.db.getDirection();
|
||||
|
||||
data4Layout.type = diag.type;
|
||||
data4Layout.layoutAlgorithm = getRegisteredLayoutAlgorithm(layout);
|
||||
|
@ -1,4 +1,4 @@
|
||||
import flowDb from '../flowDb.js';
|
||||
import { FlowDb } from '../flowDb.js';
|
||||
import flow from './flow.jison';
|
||||
import { setConfig } from '../../../config.js';
|
||||
|
||||
@ -8,7 +8,7 @@ setConfig({
|
||||
|
||||
describe('[Arrows] when parsing', () => {
|
||||
beforeEach(function () {
|
||||
flow.parser.yy = flowDb;
|
||||
flow.parser.yy = new FlowDb();
|
||||
flow.parser.yy.clear();
|
||||
});
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import flowDb from '../flowDb.js';
|
||||
import { FlowDb } from '../flowDb.js';
|
||||
import flow from './flow.jison';
|
||||
import { setConfig } from '../../../config.js';
|
||||
import { cleanupComments } from '../../../diagram-api/comments.js';
|
||||
@ -9,7 +9,7 @@ setConfig({
|
||||
|
||||
describe('[Comments] when parsing', () => {
|
||||
beforeEach(function () {
|
||||
flow.parser.yy = flowDb;
|
||||
flow.parser.yy = new FlowDb();
|
||||
flow.parser.yy.clear();
|
||||
});
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import flowDb from '../flowDb.js';
|
||||
import { FlowDb } from '../flowDb.js';
|
||||
import flow from './flow.jison';
|
||||
import { setConfig } from '../../../config.js';
|
||||
|
||||
@ -8,7 +8,7 @@ setConfig({
|
||||
|
||||
describe('when parsing directions', function () {
|
||||
beforeEach(function () {
|
||||
flow.parser.yy = flowDb;
|
||||
flow.parser.yy = new FlowDb();
|
||||
flow.parser.yy.clear();
|
||||
flow.parser.yy.setGen('gen-2');
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
import flowDb from '../flowDb.js';
|
||||
import { FlowDb } from '../flowDb.js';
|
||||
import flow from './flow.jison';
|
||||
import { setConfig } from '../../../config.js';
|
||||
|
||||
@ -42,7 +42,7 @@ const doubleEndedEdges = [
|
||||
|
||||
describe('[Edges] when parsing', () => {
|
||||
beforeEach(function () {
|
||||
flow.parser.yy = flowDb;
|
||||
flow.parser.yy = new FlowDb();
|
||||
flow.parser.yy.clear();
|
||||
});
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import flowDb from '../flowDb.js';
|
||||
import { FlowDb } from '../flowDb.js';
|
||||
import flow from './flow.jison';
|
||||
import { setConfig } from '../../../config.js';
|
||||
|
||||
@ -8,7 +8,7 @@ setConfig({
|
||||
|
||||
describe('[Text] when parsing', () => {
|
||||
beforeEach(function () {
|
||||
flow.parser.yy = flowDb;
|
||||
flow.parser.yy = new FlowDb();
|
||||
flow.parser.yy.clear();
|
||||
});
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import flowDb from '../flowDb.js';
|
||||
import { FlowDb } from '../flowDb.js';
|
||||
import flow from './flow.jison';
|
||||
import { setConfig } from '../../../config.js';
|
||||
import { vi } from 'vitest';
|
||||
@ -9,7 +9,9 @@ setConfig({
|
||||
});
|
||||
|
||||
describe('[Interactions] when parsing', () => {
|
||||
let flowDb;
|
||||
beforeEach(function () {
|
||||
flowDb = new FlowDb();
|
||||
flow.parser.yy = flowDb;
|
||||
flow.parser.yy.clear();
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
import flowDb from '../flowDb.js';
|
||||
import { FlowDb } from '../flowDb.js';
|
||||
import flow from './flow.jison';
|
||||
import { setConfig } from '../../../config.js';
|
||||
|
||||
@ -8,7 +8,7 @@ setConfig({
|
||||
|
||||
describe('[Lines] when parsing', () => {
|
||||
beforeEach(function () {
|
||||
flow.parser.yy = flowDb;
|
||||
flow.parser.yy = new FlowDb();
|
||||
flow.parser.yy.clear();
|
||||
});
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import flowDb from '../flowDb.js';
|
||||
import { FlowDb } from '../flowDb.js';
|
||||
import flow from './flow.jison';
|
||||
import { setConfig } from '../../../config.js';
|
||||
|
||||
@ -8,7 +8,7 @@ setConfig({
|
||||
|
||||
describe('parsing a flow chart with markdown strings', function () {
|
||||
beforeEach(function () {
|
||||
flow.parser.yy = flowDb;
|
||||
flow.parser.yy = new FlowDb();
|
||||
flow.parser.yy.clear();
|
||||
});
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import flowDb from '../flowDb.js';
|
||||
import { FlowDb } from '../flowDb.js';
|
||||
import flow from './flow.jison';
|
||||
import { setConfig } from '../../../config.js';
|
||||
|
||||
@ -8,7 +8,7 @@ setConfig({
|
||||
|
||||
describe('when parsing directions', function () {
|
||||
beforeEach(function () {
|
||||
flow.parser.yy = flowDb;
|
||||
flow.parser.yy = new FlowDb();
|
||||
flow.parser.yy.clear();
|
||||
flow.parser.yy.setGen('gen-2');
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
import flowDb from '../flowDb.js';
|
||||
import { FlowDb } from '../flowDb.js';
|
||||
import flow from './flow.jison';
|
||||
import { setConfig } from '../../../config.js';
|
||||
|
||||
@ -31,7 +31,7 @@ const specialChars = ['#', ':', '0', '&', ',', '*', '.', '\\', 'v', '-', '/', '_
|
||||
|
||||
describe('[Singlenodes] when parsing', () => {
|
||||
beforeEach(function () {
|
||||
flow.parser.yy = flowDb;
|
||||
flow.parser.yy = new FlowDb();
|
||||
flow.parser.yy.clear();
|
||||
});
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import flowDb from '../flowDb.js';
|
||||
import { FlowDb } from '../flowDb.js';
|
||||
import flow from './flow.jison';
|
||||
import { setConfig } from '../../../config.js';
|
||||
|
||||
@ -8,7 +8,7 @@ setConfig({
|
||||
|
||||
describe('[Style] when parsing', () => {
|
||||
beforeEach(function () {
|
||||
flow.parser.yy = flowDb;
|
||||
flow.parser.yy = new FlowDb();
|
||||
flow.parser.yy.clear();
|
||||
flow.parser.yy.setGen('gen-2');
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
import flowDb from '../flowDb.js';
|
||||
import { FlowDb } from '../flowDb.js';
|
||||
import flow from './flow.jison';
|
||||
import { setConfig } from '../../../config.js';
|
||||
|
||||
@ -8,7 +8,7 @@ setConfig({
|
||||
|
||||
describe('[Text] when parsing', () => {
|
||||
beforeEach(function () {
|
||||
flow.parser.yy = flowDb;
|
||||
flow.parser.yy = new FlowDb();
|
||||
flow.parser.yy.clear();
|
||||
});
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import flowDb from '../flowDb.js';
|
||||
import { FlowDb } from '../flowDb.js';
|
||||
import flow from './flow.jison';
|
||||
import { setConfig } from '../../../config.js';
|
||||
|
||||
@ -8,7 +8,7 @@ setConfig({
|
||||
|
||||
describe('when parsing flowcharts', function () {
|
||||
beforeEach(function () {
|
||||
flow.parser.yy = flowDb;
|
||||
flow.parser.yy = new FlowDb();
|
||||
flow.parser.yy.clear();
|
||||
flow.parser.yy.setGen('gen-2');
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
import flowDb from '../flowDb.js';
|
||||
import { FlowDb } from '../flowDb.js';
|
||||
import flow from './flow.jison';
|
||||
import { cleanupComments } from '../../../diagram-api/comments.js';
|
||||
import { setConfig } from '../../../config.js';
|
||||
@ -9,7 +9,7 @@ setConfig({
|
||||
|
||||
describe('parsing a flow chart', function () {
|
||||
beforeEach(function () {
|
||||
flow.parser.yy = flowDb;
|
||||
flow.parser.yy = new FlowDb();
|
||||
flow.parser.yy.clear();
|
||||
});
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import flowDb from '../flowDb.js';
|
||||
import { FlowDb } from '../flowDb.js';
|
||||
import flow from './flow.jison';
|
||||
import { setConfig } from '../../../config.js';
|
||||
|
||||
@ -8,7 +8,7 @@ setConfig({
|
||||
|
||||
describe('when parsing subgraphs', function () {
|
||||
beforeEach(function () {
|
||||
flow.parser.yy = flowDb;
|
||||
flow.parser.yy = new FlowDb();
|
||||
flow.parser.yy.clear();
|
||||
flow.parser.yy.setGen('gen-2');
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user