mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-24 02:37:05 +02:00
refactor: Update DBs to remove directive handling
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import mermaidAPI from '../../mermaidAPI.js';
|
|
||||||
import * as configApi from '../../config.js';
|
import * as configApi from '../../config.js';
|
||||||
import { sanitizeText } from '../common/common.js';
|
import { sanitizeText } from '../common/common.js';
|
||||||
import { setAccTitle, getAccTitle, getAccDescription, setAccDescription } from '../../commonDb.js';
|
import { setAccTitle, getAccTitle, getAccDescription, setAccDescription } from '../../commonDb.js';
|
||||||
@@ -33,10 +32,6 @@ export const setC4Type = function (c4TypeParam) {
|
|||||||
c4Type = sanitizedText;
|
c4Type = sanitizedText;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const parseDirective = function (statement, context, type) {
|
|
||||||
mermaidAPI.parseDirective(this, statement, context, type);
|
|
||||||
};
|
|
||||||
|
|
||||||
//type, from, to, label, ?techn, ?descr, ?sprite, ?tags, $link
|
//type, from, to, label, ?techn, ?descr, ?sprite, ?tags, $link
|
||||||
export const addRel = function (type, from, to, label, techn, descr, sprite, tags, link) {
|
export const addRel = function (type, from, to, label, techn, descr, sprite, tags, link) {
|
||||||
// Don't allow label nulling
|
// Don't allow label nulling
|
||||||
@@ -816,7 +811,6 @@ export default {
|
|||||||
getAccTitle,
|
getAccTitle,
|
||||||
getAccDescription,
|
getAccDescription,
|
||||||
setAccDescription,
|
setAccDescription,
|
||||||
parseDirective,
|
|
||||||
getConfig: () => configApi.getConfig().c4,
|
getConfig: () => configApi.getConfig().c4,
|
||||||
clear,
|
clear,
|
||||||
LINETYPE,
|
LINETYPE,
|
||||||
|
@@ -5,7 +5,6 @@ import { log } from '../../logger.js';
|
|||||||
import * as configApi from '../../config.js';
|
import * as configApi from '../../config.js';
|
||||||
import common from '../common/common.js';
|
import common from '../common/common.js';
|
||||||
import utils from '../../utils.js';
|
import utils from '../../utils.js';
|
||||||
import mermaidAPI from '../../mermaidAPI.js';
|
|
||||||
import {
|
import {
|
||||||
setAccTitle,
|
setAccTitle,
|
||||||
getAccTitle,
|
getAccTitle,
|
||||||
@@ -37,11 +36,6 @@ let functions: any[] = [];
|
|||||||
|
|
||||||
const sanitizeText = (txt: string) => common.sanitizeText(txt, configApi.getConfig());
|
const sanitizeText = (txt: string) => common.sanitizeText(txt, configApi.getConfig());
|
||||||
|
|
||||||
export const parseDirective = function (statement: string, context: string, type: string) {
|
|
||||||
// @ts-ignore Don't wanna mess it up
|
|
||||||
mermaidAPI.parseDirective(this, statement, context, type);
|
|
||||||
};
|
|
||||||
|
|
||||||
const splitClassNameAndType = function (id: string) {
|
const splitClassNameAndType = function (id: string) {
|
||||||
let genericType = '';
|
let genericType = '';
|
||||||
let className = id;
|
let className = id;
|
||||||
@@ -456,7 +450,6 @@ export const addClassesToNamespace = function (id: string, classNames: string[])
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
parseDirective,
|
|
||||||
setAccTitle,
|
setAccTitle,
|
||||||
getAccTitle,
|
getAccTitle,
|
||||||
getAccDescription,
|
getAccDescription,
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import { log } from '../../logger.js';
|
import { log } from '../../logger.js';
|
||||||
import mermaidAPI from '../../mermaidAPI.js';
|
|
||||||
import * as configApi from '../../config.js';
|
import * as configApi from '../../config.js';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -28,10 +27,6 @@ const Identification = {
|
|||||||
IDENTIFYING: 'IDENTIFYING',
|
IDENTIFYING: 'IDENTIFYING',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const parseDirective = function (statement, context, type) {
|
|
||||||
mermaidAPI.parseDirective(this, statement, context, type);
|
|
||||||
};
|
|
||||||
|
|
||||||
const addEntity = function (name) {
|
const addEntity = function (name) {
|
||||||
if (entities[name] === undefined) {
|
if (entities[name] === undefined) {
|
||||||
entities[name] = { attributes: [] };
|
entities[name] = { attributes: [] };
|
||||||
@@ -85,7 +80,6 @@ const clear = function () {
|
|||||||
export default {
|
export default {
|
||||||
Cardinality,
|
Cardinality,
|
||||||
Identification,
|
Identification,
|
||||||
parseDirective,
|
|
||||||
getConfig: () => configApi.getConfig().er,
|
getConfig: () => configApi.getConfig().er,
|
||||||
addEntity,
|
addEntity,
|
||||||
addAttributes,
|
addAttributes,
|
||||||
|
@@ -2,7 +2,6 @@ import { select } from 'd3';
|
|||||||
import utils from '../../utils.js';
|
import utils from '../../utils.js';
|
||||||
import * as configApi from '../../config.js';
|
import * as configApi from '../../config.js';
|
||||||
import common from '../common/common.js';
|
import common from '../common/common.js';
|
||||||
import mermaidAPI from '../../mermaidAPI.js';
|
|
||||||
import { log } from '../../logger.js';
|
import { log } from '../../logger.js';
|
||||||
import {
|
import {
|
||||||
setAccTitle,
|
setAccTitle,
|
||||||
@@ -34,10 +33,6 @@ let funs = [];
|
|||||||
|
|
||||||
const sanitizeText = (txt) => common.sanitizeText(txt, config);
|
const sanitizeText = (txt) => common.sanitizeText(txt, config);
|
||||||
|
|
||||||
export const parseDirective = function (statement, context, type) {
|
|
||||||
mermaidAPI.parseDirective(this, statement, context, type);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to lookup domId from id in the graph definition.
|
* Function to lookup domId from id in the graph definition.
|
||||||
*
|
*
|
||||||
@@ -771,7 +766,6 @@ export const lex = {
|
|||||||
firstGraph,
|
firstGraph,
|
||||||
};
|
};
|
||||||
export default {
|
export default {
|
||||||
parseDirective,
|
|
||||||
defaultConfig: () => configApi.defaultConfig.flowchart,
|
defaultConfig: () => configApi.defaultConfig.flowchart,
|
||||||
setAccTitle,
|
setAccTitle,
|
||||||
getAccTitle,
|
getAccTitle,
|
||||||
|
@@ -6,7 +6,6 @@ import dayjsAdvancedFormat from 'dayjs/plugin/advancedFormat.js';
|
|||||||
import { log } from '../../logger.js';
|
import { log } from '../../logger.js';
|
||||||
import * as configApi from '../../config.js';
|
import * as configApi from '../../config.js';
|
||||||
import utils from '../../utils.js';
|
import utils from '../../utils.js';
|
||||||
import mermaidAPI from '../../mermaidAPI.js';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
setAccTitle,
|
setAccTitle,
|
||||||
@@ -42,10 +41,6 @@ let weekday = 'sunday';
|
|||||||
// The serial order of the task in the script
|
// The serial order of the task in the script
|
||||||
let lastOrder = 0;
|
let lastOrder = 0;
|
||||||
|
|
||||||
export const parseDirective = function (statement, context, type) {
|
|
||||||
mermaidAPI.parseDirective(this, statement, context, type);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const clear = function () {
|
export const clear = function () {
|
||||||
sections = [];
|
sections = [];
|
||||||
tasks = [];
|
tasks = [];
|
||||||
@@ -730,7 +725,6 @@ export const bindFunctions = function (element) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
parseDirective,
|
|
||||||
getConfig: () => configApi.getConfig().gantt,
|
getConfig: () => configApi.getConfig().gantt,
|
||||||
clear,
|
clear,
|
||||||
setDateFormat,
|
setDateFormat,
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
import { log } from '../../logger.js';
|
import { log } from '../../logger.js';
|
||||||
import { random } from '../../utils.js';
|
import { random } from '../../utils.js';
|
||||||
import mermaidAPI from '../../mermaidAPI.js';
|
|
||||||
import * as configApi from '../../config.js';
|
import * as configApi from '../../config.js';
|
||||||
import { getConfig } from '../../config.js';
|
import { getConfig } from '../../config.js';
|
||||||
import common from '../common/common.js';
|
import common from '../common/common.js';
|
||||||
@@ -33,10 +32,6 @@ function getId() {
|
|||||||
return random({ length: 7 });
|
return random({ length: 7 });
|
||||||
}
|
}
|
||||||
|
|
||||||
export const parseDirective = function (statement, context, type) {
|
|
||||||
mermaidAPI.parseDirective(this, statement, context, type);
|
|
||||||
};
|
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * @param currentCommit
|
// * @param currentCommit
|
||||||
// * @param otherCommit
|
// * @param otherCommit
|
||||||
@@ -507,7 +502,6 @@ export const commitType = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
parseDirective,
|
|
||||||
getConfig: () => configApi.getConfig().gitGraph,
|
getConfig: () => configApi.getConfig().gitGraph,
|
||||||
setDirection,
|
setDirection,
|
||||||
setOptions,
|
setOptions,
|
||||||
|
@@ -62,17 +62,6 @@ describe('pie', () => {
|
|||||||
expect(sections['bat']).toBe(40);
|
expect(sections['bat']).toBe(40);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle simple pie with a directive', () => {
|
|
||||||
parser.parse(`%%{init: {'logLevel':0}}%%
|
|
||||||
pie
|
|
||||||
"ash" : 60
|
|
||||||
"bat" : 40
|
|
||||||
`);
|
|
||||||
const sections = db.getSections();
|
|
||||||
expect(sections['ash']).toBe(60);
|
|
||||||
expect(sections['bat']).toBe(40);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should handle simple pie with a title', () => {
|
it('should handle simple pie with a title', () => {
|
||||||
parser.parse(`pie title a 60/40 pie
|
parser.parse(`pie title a 60/40 pie
|
||||||
"ash" : 60
|
"ash" : 60
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import { log } from '../../logger.js';
|
import { log } from '../../logger.js';
|
||||||
import { parseDirective as _parseDirective } from '../../directiveUtils.js';
|
|
||||||
import { getConfig as commonGetConfig } from '../../config.js';
|
import { getConfig as commonGetConfig } from '../../config.js';
|
||||||
import { sanitizeText } from '../common/common.js';
|
import { sanitizeText } from '../common/common.js';
|
||||||
import {
|
import {
|
||||||
@@ -11,7 +10,6 @@ import {
|
|||||||
setAccDescription,
|
setAccDescription,
|
||||||
clear as commonClear,
|
clear as commonClear,
|
||||||
} from '../../commonDb.js';
|
} from '../../commonDb.js';
|
||||||
import type { ParseDirectiveDefinition } from '../../diagram-api/types.js';
|
|
||||||
import type { PieFields, PieDB, Sections } from './pieTypes.js';
|
import type { PieFields, PieDB, Sections } from './pieTypes.js';
|
||||||
import type { RequiredDeep } from 'type-fest';
|
import type { RequiredDeep } from 'type-fest';
|
||||||
import type { PieDiagramConfig } from '../../config.type.js';
|
import type { PieDiagramConfig } from '../../config.type.js';
|
||||||
@@ -31,10 +29,6 @@ const config: Required<PieDiagramConfig> = structuredClone(DEFAULT_PIE_CONFIG);
|
|||||||
|
|
||||||
const getConfig = (): Required<PieDiagramConfig> => structuredClone(config);
|
const getConfig = (): Required<PieDiagramConfig> => structuredClone(config);
|
||||||
|
|
||||||
const parseDirective: ParseDirectiveDefinition = (statement, context, type) => {
|
|
||||||
_parseDirective(this, statement, context, type);
|
|
||||||
};
|
|
||||||
|
|
||||||
const clear = (): void => {
|
const clear = (): void => {
|
||||||
sections = structuredClone(DEFAULT_PIE_DB.sections);
|
sections = structuredClone(DEFAULT_PIE_DB.sections);
|
||||||
showData = DEFAULT_PIE_DB.showData;
|
showData = DEFAULT_PIE_DB.showData;
|
||||||
@@ -67,7 +61,6 @@ const getShowData = (): boolean => showData;
|
|||||||
export const db: PieDB = {
|
export const db: PieDB = {
|
||||||
getConfig,
|
getConfig,
|
||||||
|
|
||||||
parseDirective,
|
|
||||||
clear,
|
clear,
|
||||||
setDiagramTitle,
|
setDiagramTitle,
|
||||||
getDiagramTitle,
|
getDiagramTitle,
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import type { PieDiagramConfig } from '../../config.type.js';
|
import type { PieDiagramConfig } from '../../config.type.js';
|
||||||
import type { DiagramDB, ParseDirectiveDefinition } from '../../diagram-api/types.js';
|
import type { DiagramDB } from '../../diagram-api/types.js';
|
||||||
|
|
||||||
export interface PieFields {
|
export interface PieFields {
|
||||||
sections: Sections;
|
sections: Sections;
|
||||||
@@ -46,7 +46,6 @@ export interface PieDB extends DiagramDB {
|
|||||||
getConfig: () => Required<PieDiagramConfig>;
|
getConfig: () => Required<PieDiagramConfig>;
|
||||||
|
|
||||||
// common db
|
// common db
|
||||||
parseDirective: ParseDirectiveDefinition;
|
|
||||||
clear: () => void;
|
clear: () => void;
|
||||||
setDiagramTitle: (title: string) => void;
|
setDiagramTitle: (title: string) => void;
|
||||||
getDiagramTitle: () => string;
|
getDiagramTitle: () => string;
|
||||||
|
@@ -19,7 +19,6 @@ const mockDB: Record<string, Mock<any, any>> = {
|
|||||||
setYAxisTopText: vi.fn(),
|
setYAxisTopText: vi.fn(),
|
||||||
setYAxisBottomText: vi.fn(),
|
setYAxisBottomText: vi.fn(),
|
||||||
setDiagramTitle: vi.fn(),
|
setDiagramTitle: vi.fn(),
|
||||||
parseDirective: vi.fn(),
|
|
||||||
addPoint: vi.fn(),
|
addPoint: vi.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -45,23 +44,6 @@ describe('Testing quadrantChart jison file', () => {
|
|||||||
expect(parserFnConstructor(str)).not.toThrow();
|
expect(parserFnConstructor(str)).not.toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to parse directive', () => {
|
|
||||||
const str =
|
|
||||||
'%%{init: {"quadrantChart": {"chartWidth": 600, "chartHeight": 600} } }%% \n quadrantChart';
|
|
||||||
expect(parserFnConstructor(str)).not.toThrow();
|
|
||||||
expect(mockDB.parseDirective.mock.calls[0]).toEqual(['%%{', 'open_directive']);
|
|
||||||
expect(mockDB.parseDirective.mock.calls[1]).toEqual(['init', 'type_directive']);
|
|
||||||
expect(mockDB.parseDirective.mock.calls[2]).toEqual([
|
|
||||||
'{"quadrantChart": {"chartWidth": 600, "chartHeight": 600} }',
|
|
||||||
'arg_directive',
|
|
||||||
]);
|
|
||||||
expect(mockDB.parseDirective.mock.calls[3]).toEqual([
|
|
||||||
'}%%',
|
|
||||||
'close_directive',
|
|
||||||
'quadrantChart',
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be able to parse xAxis text', () => {
|
it('should be able to parse xAxis text', () => {
|
||||||
let str = 'quadrantChart\nx-axis urgent --> not urgent';
|
let str = 'quadrantChart\nx-axis urgent --> not urgent';
|
||||||
expect(parserFnConstructor(str)).not.toThrow();
|
expect(parserFnConstructor(str)).not.toThrow();
|
||||||
@@ -243,8 +225,7 @@ describe('Testing quadrantChart jison file', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to parse the whole chart', () => {
|
it('should be able to parse the whole chart', () => {
|
||||||
const str = `%%{init: {"quadrantChart": {"chartWidth": 600, "chartHeight": 600} } }%%
|
const str = `quadrantChart
|
||||||
quadrantChart
|
|
||||||
title Analytics and Business Intelligence Platforms
|
title Analytics and Business Intelligence Platforms
|
||||||
x-axis "Completeness of Vision ❤" --> "x-axis-2"
|
x-axis "Completeness of Vision ❤" --> "x-axis-2"
|
||||||
y-axis Ability to Execute --> "y-axis-2"
|
y-axis Ability to Execute --> "y-axis-2"
|
||||||
@@ -258,17 +239,6 @@ describe('Testing quadrantChart jison file', () => {
|
|||||||
Incorta: [0.20, 0.30]`;
|
Incorta: [0.20, 0.30]`;
|
||||||
|
|
||||||
expect(parserFnConstructor(str)).not.toThrow();
|
expect(parserFnConstructor(str)).not.toThrow();
|
||||||
expect(mockDB.parseDirective.mock.calls[0]).toEqual(['%%{', 'open_directive']);
|
|
||||||
expect(mockDB.parseDirective.mock.calls[1]).toEqual(['init', 'type_directive']);
|
|
||||||
expect(mockDB.parseDirective.mock.calls[2]).toEqual([
|
|
||||||
'{"quadrantChart": {"chartWidth": 600, "chartHeight": 600} }',
|
|
||||||
'arg_directive',
|
|
||||||
]);
|
|
||||||
expect(mockDB.parseDirective.mock.calls[3]).toEqual([
|
|
||||||
'}%%',
|
|
||||||
'close_directive',
|
|
||||||
'quadrantChart',
|
|
||||||
]);
|
|
||||||
expect(mockDB.setXAxisLeftText).toHaveBeenCalledWith({
|
expect(mockDB.setXAxisLeftText).toHaveBeenCalledWith({
|
||||||
text: 'Completeness of Vision ❤',
|
text: 'Completeness of Vision ❤',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
|
@@ -1,5 +1,3 @@
|
|||||||
import { log } from '../../logger.js';
|
|
||||||
import mermaidAPI from '../../mermaidAPI.js';
|
|
||||||
import * as configApi from '../../config.js';
|
import * as configApi from '../../config.js';
|
||||||
import { sanitizeText } from '../common/common.js';
|
import { sanitizeText } from '../common/common.js';
|
||||||
import {
|
import {
|
||||||
@@ -94,11 +92,6 @@ function getQuadrantData() {
|
|||||||
return quadrantBuilder.build();
|
return quadrantBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
export const parseDirective = function (statement: string, context: string, type: string) {
|
|
||||||
// @ts-ignore: TODO Fix ts errors
|
|
||||||
mermaidAPI.parseDirective(this, statement, context, type);
|
|
||||||
};
|
|
||||||
|
|
||||||
const clear = function () {
|
const clear = function () {
|
||||||
quadrantBuilder.clear();
|
quadrantBuilder.clear();
|
||||||
commonClear();
|
commonClear();
|
||||||
@@ -117,7 +110,6 @@ export default {
|
|||||||
setYAxisBottomText,
|
setYAxisBottomText,
|
||||||
addPoint,
|
addPoint,
|
||||||
getQuadrantData,
|
getQuadrantData,
|
||||||
parseDirective,
|
|
||||||
clear,
|
clear,
|
||||||
setAccTitle,
|
setAccTitle,
|
||||||
getAccTitle,
|
getAccTitle,
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
import * as configApi from '../../config.js';
|
import * as configApi from '../../config.js';
|
||||||
import { log } from '../../logger.js';
|
import { log } from '../../logger.js';
|
||||||
import mermaidAPI from '../../mermaidAPI.js';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
setAccTitle,
|
setAccTitle,
|
||||||
@@ -48,10 +47,6 @@ const Relationships = {
|
|||||||
TRACES: 'traces',
|
TRACES: 'traces',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const parseDirective = function (statement, context, type) {
|
|
||||||
mermaidAPI.parseDirective(this, statement, context, type);
|
|
||||||
};
|
|
||||||
|
|
||||||
const addRequirement = (name, type) => {
|
const addRequirement = (name, type) => {
|
||||||
if (requirements[name] === undefined) {
|
if (requirements[name] === undefined) {
|
||||||
requirements[name] = {
|
requirements[name] = {
|
||||||
@@ -149,7 +144,6 @@ export default {
|
|||||||
VerifyType,
|
VerifyType,
|
||||||
Relationships,
|
Relationships,
|
||||||
|
|
||||||
parseDirective,
|
|
||||||
getConfig: () => configApi.getConfig().req,
|
getConfig: () => configApi.getConfig().req,
|
||||||
|
|
||||||
addRequirement,
|
addRequirement,
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
import mermaidAPI from '../../mermaidAPI.js';
|
|
||||||
import * as configApi from '../../config.js';
|
import * as configApi from '../../config.js';
|
||||||
import { log } from '../../logger.js';
|
import { log } from '../../logger.js';
|
||||||
import { sanitizeText } from '../common/common.js';
|
import { sanitizeText } from '../common/common.js';
|
||||||
@@ -25,10 +24,6 @@ let currentBox = undefined;
|
|||||||
let lastCreated = undefined;
|
let lastCreated = undefined;
|
||||||
let lastDestroyed = undefined;
|
let lastDestroyed = undefined;
|
||||||
|
|
||||||
export const parseDirective = function (statement, context, type) {
|
|
||||||
mermaidAPI.parseDirective(this, statement, context, type);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const addBox = function (data) {
|
export const addBox = function (data) {
|
||||||
boxes.push({
|
boxes.push({
|
||||||
name: data.text,
|
name: data.text,
|
||||||
@@ -619,7 +614,6 @@ export default {
|
|||||||
getBoxes,
|
getBoxes,
|
||||||
getDiagramTitle,
|
getDiagramTitle,
|
||||||
setDiagramTitle,
|
setDiagramTitle,
|
||||||
parseDirective,
|
|
||||||
getConfig: () => configApi.getConfig().sequence,
|
getConfig: () => configApi.getConfig().sequence,
|
||||||
clear,
|
clear,
|
||||||
parseMessage,
|
parseMessage,
|
||||||
|
@@ -2051,9 +2051,7 @@ describe('when rendering a sequenceDiagram with directives', () => {
|
|||||||
|
|
||||||
it('should handle one actor, when theme is dark and logLevel is 1 DX1 (dfg1)', async () => {
|
it('should handle one actor, when theme is dark and logLevel is 1 DX1 (dfg1)', async () => {
|
||||||
const str = `
|
const str = `
|
||||||
%%{init: { "theme": "dark", "logLevel": 1 } }%%
|
|
||||||
sequenceDiagram
|
sequenceDiagram
|
||||||
%%{wrap}%%
|
|
||||||
participant Alice
|
participant Alice
|
||||||
`;
|
`;
|
||||||
diagram = new Diagram(str);
|
diagram = new Diagram(str);
|
||||||
@@ -2062,8 +2060,6 @@ participant Alice
|
|||||||
|
|
||||||
const { bounds, models } = diagram.renderer.bounds.getBounds();
|
const { bounds, models } = diagram.renderer.bounds.getBounds();
|
||||||
const mermaid = mermaidAPI.getConfig();
|
const mermaid = mermaidAPI.getConfig();
|
||||||
expect(mermaid.theme).toBe('dark');
|
|
||||||
expect(mermaid.logLevel).toBe(1);
|
|
||||||
expect(bounds.startx).toBe(0);
|
expect(bounds.startx).toBe(0);
|
||||||
expect(bounds.startx).toBe(0);
|
expect(bounds.startx).toBe(0);
|
||||||
expect(bounds.starty).toBe(0);
|
expect(bounds.starty).toBe(0);
|
||||||
@@ -2073,7 +2069,6 @@ participant Alice
|
|||||||
});
|
});
|
||||||
it('should handle one actor, when logLevel is 3 (dfg0)', async () => {
|
it('should handle one actor, when logLevel is 3 (dfg0)', async () => {
|
||||||
const str = `
|
const str = `
|
||||||
%%{initialize: { "logLevel": 3 }}%%
|
|
||||||
sequenceDiagram
|
sequenceDiagram
|
||||||
participant Alice
|
participant Alice
|
||||||
`;
|
`;
|
||||||
@@ -2083,7 +2078,6 @@ participant Alice
|
|||||||
|
|
||||||
const { bounds, models } = diagram.renderer.bounds.getBounds();
|
const { bounds, models } = diagram.renderer.bounds.getBounds();
|
||||||
const mermaid = mermaidAPI.getConfig();
|
const mermaid = mermaidAPI.getConfig();
|
||||||
expect(mermaid.logLevel).toBe(3);
|
|
||||||
expect(bounds.startx).toBe(0);
|
expect(bounds.startx).toBe(0);
|
||||||
expect(bounds.startx).toBe(0);
|
expect(bounds.startx).toBe(0);
|
||||||
expect(bounds.starty).toBe(0);
|
expect(bounds.starty).toBe(0);
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
import { log } from '../../logger.js';
|
import { log } from '../../logger.js';
|
||||||
import { generateId } from '../../utils.js';
|
import { generateId } from '../../utils.js';
|
||||||
import mermaidAPI from '../../mermaidAPI.js';
|
|
||||||
import common from '../common/common.js';
|
import common from '../common/common.js';
|
||||||
import * as configApi from '../../config.js';
|
import * as configApi from '../../config.js';
|
||||||
import {
|
import {
|
||||||
@@ -77,10 +76,6 @@ export const relationType = {
|
|||||||
|
|
||||||
const clone = (o) => JSON.parse(JSON.stringify(o));
|
const clone = (o) => JSON.parse(JSON.stringify(o));
|
||||||
|
|
||||||
export const parseDirective = function (statement, context, type) {
|
|
||||||
mermaidAPI.parseDirective(this, statement, context, type);
|
|
||||||
};
|
|
||||||
|
|
||||||
const setRootDoc = (o) => {
|
const setRootDoc = (o) => {
|
||||||
log.info('Setting root doc', o);
|
log.info('Setting root doc', o);
|
||||||
// rootDoc = { id: 'root', doc: o };
|
// rootDoc = { id: 'root', doc: o };
|
||||||
@@ -547,7 +542,6 @@ const setDirection = (dir) => {
|
|||||||
const trimColon = (str) => (str && str[0] === ':' ? str.substr(1).trim() : str.trim());
|
const trimColon = (str) => (str && str[0] === ':' ? str.substr(1).trim() : str.trim());
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
parseDirective,
|
|
||||||
getConfig: () => configApi.getConfig().state,
|
getConfig: () => configApi.getConfig().state,
|
||||||
addState,
|
addState,
|
||||||
clear,
|
clear,
|
||||||
|
@@ -55,16 +55,6 @@ describe('state diagram V2, ', function () {
|
|||||||
const title = stateDb.getAccTitle();
|
const title = stateDb.getAccTitle();
|
||||||
expect(title).toBe('a simple title of the diagram');
|
expect(title).toBe('a simple title of the diagram');
|
||||||
});
|
});
|
||||||
it('simple with directive', function () {
|
|
||||||
const str = `%%{init: {'logLevel': 0 }}%%
|
|
||||||
stateDiagram-v2\n
|
|
||||||
State1 : this is another string
|
|
||||||
[*] --> State1
|
|
||||||
State1 --> [*]
|
|
||||||
`;
|
|
||||||
|
|
||||||
parser.parse(str);
|
|
||||||
});
|
|
||||||
it('should handle relation definitions', function () {
|
it('should handle relation definitions', function () {
|
||||||
const str = `stateDiagram-v2\n
|
const str = `stateDiagram-v2\n
|
||||||
[*] --> State1
|
[*] --> State1
|
||||||
|
@@ -66,16 +66,6 @@ describe('state diagram, ', function () {
|
|||||||
const title = stateDb.getAccTitle();
|
const title = stateDb.getAccTitle();
|
||||||
expect(title).toBe('a simple title of the diagram');
|
expect(title).toBe('a simple title of the diagram');
|
||||||
});
|
});
|
||||||
it('simple with directive', function () {
|
|
||||||
const str = `%%{init: {'logLevel': 0 }}%%
|
|
||||||
stateDiagram\n
|
|
||||||
State1 : this is another string
|
|
||||||
[*] --> State1
|
|
||||||
State1 --> [*]
|
|
||||||
`;
|
|
||||||
|
|
||||||
parser.parse(str);
|
|
||||||
});
|
|
||||||
it('should handle relation definitions', function () {
|
it('should handle relation definitions', function () {
|
||||||
const str = `stateDiagram\n
|
const str = `stateDiagram\n
|
||||||
[*] --> State1
|
[*] --> State1
|
||||||
|
@@ -1,26 +1,8 @@
|
|||||||
import { parser as timeline } from './parser/timeline.jison';
|
import { parser as timeline } from './parser/timeline.jison';
|
||||||
import * as timelineDB from './timelineDb.js';
|
import * as timelineDB from './timelineDb.js';
|
||||||
// import { injectUtils } from './mermaidUtils.js';
|
|
||||||
import * as _commonDb from '../../commonDb.js';
|
import * as _commonDb from '../../commonDb.js';
|
||||||
import { parseDirective as _parseDirective } from '../../directiveUtils.js';
|
|
||||||
|
|
||||||
import {
|
import { setLogLevel } from '../../diagram-api/diagramAPI.js';
|
||||||
log,
|
|
||||||
setLogLevel,
|
|
||||||
getConfig,
|
|
||||||
sanitizeText,
|
|
||||||
setupGraphViewBox,
|
|
||||||
} from '../../diagram-api/diagramAPI.js';
|
|
||||||
|
|
||||||
// injectUtils(
|
|
||||||
// log,
|
|
||||||
// setLogLevel,
|
|
||||||
// getConfig,
|
|
||||||
// sanitizeText,
|
|
||||||
// setupGraphViewBox,
|
|
||||||
// _commonDb,
|
|
||||||
// _parseDirective
|
|
||||||
// );
|
|
||||||
|
|
||||||
describe('when parsing a timeline ', function () {
|
describe('when parsing a timeline ', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
import { parseDirective as _parseDirective } from '../../directiveUtils.js';
|
|
||||||
import * as commonDb from '../../commonDb.js';
|
import * as commonDb from '../../commonDb.js';
|
||||||
let currentSection = '';
|
let currentSection = '';
|
||||||
let currentTaskId = 0;
|
let currentTaskId = 0;
|
||||||
@@ -9,10 +8,6 @@ const rawTasks = [];
|
|||||||
|
|
||||||
export const getCommonDb = () => commonDb;
|
export const getCommonDb = () => commonDb;
|
||||||
|
|
||||||
export const parseDirective = (statement, context, type) => {
|
|
||||||
_parseDirective(this, statement, context, type);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const clear = function () {
|
export const clear = function () {
|
||||||
sections.length = 0;
|
sections.length = 0;
|
||||||
tasks.length = 0;
|
tasks.length = 0;
|
||||||
@@ -104,5 +99,4 @@ export default {
|
|||||||
addTask,
|
addTask,
|
||||||
addTaskOrg,
|
addTaskOrg,
|
||||||
addEvent,
|
addEvent,
|
||||||
parseDirective,
|
|
||||||
};
|
};
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
import mermaidAPI from '../../mermaidAPI.js';
|
|
||||||
import * as configApi from '../../config.js';
|
import * as configApi from '../../config.js';
|
||||||
import {
|
import {
|
||||||
setAccTitle,
|
setAccTitle,
|
||||||
@@ -16,10 +15,6 @@ const sections = [];
|
|||||||
const tasks = [];
|
const tasks = [];
|
||||||
const rawTasks = [];
|
const rawTasks = [];
|
||||||
|
|
||||||
export const parseDirective = function (statement, context, type) {
|
|
||||||
mermaidAPI.parseDirective(this, statement, context, type);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const clear = function () {
|
export const clear = function () {
|
||||||
sections.length = 0;
|
sections.length = 0;
|
||||||
tasks.length = 0;
|
tasks.length = 0;
|
||||||
@@ -118,7 +113,6 @@ const getActors = function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
parseDirective,
|
|
||||||
getConfig: () => configApi.getConfig().journey,
|
getConfig: () => configApi.getConfig().journey,
|
||||||
clear,
|
clear,
|
||||||
setDiagramTitle,
|
setDiagramTitle,
|
||||||
|
Reference in New Issue
Block a user