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