mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-21 06:53:17 +08:00
Rename BlockDiagram to Block
This commit is contained in:
parent
86e1bb38ee
commit
791e67641e
@ -33,7 +33,7 @@ export interface MermaidConfig {
|
|||||||
gitGraph?: GitGraphDiagramConfig;
|
gitGraph?: GitGraphDiagramConfig;
|
||||||
c4?: C4DiagramConfig;
|
c4?: C4DiagramConfig;
|
||||||
sankey?: SankeyDiagramConfig;
|
sankey?: SankeyDiagramConfig;
|
||||||
blockDiagram?: BlockDiagramConfig;
|
block?: BlockDiagramConfig;
|
||||||
dompurifyConfig?: DOMPurify.Config;
|
dompurifyConfig?: DOMPurify.Config;
|
||||||
wrap?: boolean;
|
wrap?: boolean;
|
||||||
fontSize?: number;
|
fontSize?: number;
|
||||||
|
@ -19,6 +19,7 @@ import flowchartElk from '../diagrams/flowchart/elk/detector.js';
|
|||||||
import timeline from '../diagrams/timeline/detector.js';
|
import timeline from '../diagrams/timeline/detector.js';
|
||||||
import mindmap from '../diagrams/mindmap/detector.js';
|
import mindmap from '../diagrams/mindmap/detector.js';
|
||||||
import sankey from '../diagrams/sankey/sankeyDetector.js';
|
import sankey from '../diagrams/sankey/sankeyDetector.js';
|
||||||
|
import block from '../diagrams/block/blockDetector.js';
|
||||||
import { registerLazyLoadedDiagrams } from './detectType.js';
|
import { registerLazyLoadedDiagrams } from './detectType.js';
|
||||||
import { registerDiagram } from './diagramAPI.js';
|
import { registerDiagram } from './diagramAPI.js';
|
||||||
|
|
||||||
@ -81,6 +82,7 @@ export const addDiagrams = () => {
|
|||||||
state,
|
state,
|
||||||
journey,
|
journey,
|
||||||
quadrantChart,
|
quadrantChart,
|
||||||
sankey
|
sankey,
|
||||||
|
block
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -23,7 +23,7 @@ const clear = (): void => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
getConfig: () => configApi.getConfig().blockDiagram,
|
getConfig: () => configApi.getConfig().block,
|
||||||
|
|
||||||
getAccTitle,
|
getAccTitle,
|
||||||
setAccTitle,
|
setAccTitle,
|
@ -1,9 +1,9 @@
|
|||||||
import type { DiagramDetector, ExternalDiagramDefinition } from '../../diagram-api/types.js';
|
import type { DiagramDetector, ExternalDiagramDefinition } from '../../diagram-api/types.js';
|
||||||
|
|
||||||
const id = 'sankey';
|
const id = 'block';
|
||||||
|
|
||||||
const detector: DiagramDetector = (txt) => {
|
const detector: DiagramDetector = (txt) => {
|
||||||
return /^\s*blockDiagram-beta/.test(txt);
|
return /^\s*block-beta/.test(txt);
|
||||||
};
|
};
|
||||||
|
|
||||||
const loader = async () => {
|
const loader = async () => {
|
@ -1,9 +1,9 @@
|
|||||||
import { DiagramDefinition } from '../../diagram-api/types.js';
|
import { DiagramDefinition } from '../../diagram-api/types.js';
|
||||||
// @ts-ignore: jison doesn't export types
|
// @ts-ignore: jison doesn't export types
|
||||||
import parser from './parser/sankey.jison';
|
import parser from './parser/blockDiagram.jison';
|
||||||
import db from './blockDB.js';
|
import db from './blockDB.js';
|
||||||
import renderer from './blockDiagramRenderer.js';
|
import renderer from './blockRenderer.js';
|
||||||
import { prepareTextForParsing } from './blockDiagramUtils.js';
|
import { prepareTextForParsing } from './blockUtils.js';
|
||||||
|
|
||||||
const originalParse = parser.parse.bind(parser);
|
const originalParse = parser.parse.bind(parser);
|
||||||
parser.parse = (text: string) => originalParse(prepareTextForParsing(text));
|
parser.parse = (text: string) => originalParse(prepareTextForParsing(text));
|
5
packages/mermaid/src/diagrams/block/blockTypes.ts
Normal file
5
packages/mermaid/src/diagrams/block/blockTypes.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import type { DiagramDB } from '../../diagram-api/types.js';
|
||||||
|
|
||||||
|
export interface BlockDB extends DiagramDB {
|
||||||
|
clear: () => void;
|
||||||
|
}
|
@ -27,7 +27,7 @@ CRLF \u000D\u000A
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
"blockDiagram-beta" { return 'BLOCK_DIAGRAM_KEY'; }
|
"block-beta" { return 'BLOCK_DIAGRAM_KEY'; }
|
||||||
// \s*\%\%.* { yy.getLogger().info('Found comment',yytext); }
|
// \s*\%\%.* { yy.getLogger().info('Found comment',yytext); }
|
||||||
[\s]+ { yy.getLogger().info('.', yytext); /* skip all whitespace */ }
|
[\s]+ { yy.getLogger().info('.', yytext); /* skip all whitespace */ }
|
||||||
[\n]+ {yy.getLogger().info('_', yytext); /* skip all whitespace */ }
|
[\n]+ {yy.getLogger().info('_', yytext); /* skip all whitespace */ }
|
@ -1,58 +1,58 @@
|
|||||||
// @ts-ignore: jison doesn't export types
|
// @ts-ignore: jison doesn't export types
|
||||||
import blockDiagram from './blockDiagram.jison';
|
import block from './block.jison';
|
||||||
import db from '../blockDB.js';
|
import db from '../blockDB.js';
|
||||||
import { cleanupComments } from '../../../diagram-api/comments.js';
|
import { cleanupComments } from '../../../diagram-api/comments.js';
|
||||||
import { prepareTextForParsing } from '../blockDiagramUtils.js';
|
import { prepareTextForParsing } from '../blockUtils.js';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
describe('Sankey diagram', function () {
|
describe('Sankey diagram', function () {
|
||||||
describe('when parsing an block diagram graph it should handle > ', function () {
|
describe('when parsing an block diagram graph it should handle > ', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
blockDiagram.parser.yy = db;
|
block.parser.yy = db;
|
||||||
blockDiagram.parser.yy.clear();
|
block.parser.yy.clear();
|
||||||
blockDiagram.parser.yy.getLogger = () => console;
|
block.parser.yy.getLogger = () => console;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('a diagram with a node', async () => {
|
it('a diagram with a node', async () => {
|
||||||
const str = `blockDiagram-beta
|
const str = `block-beta
|
||||||
id
|
id
|
||||||
`;
|
`;
|
||||||
|
|
||||||
blockDiagram.parse(str);
|
block.parse(str);
|
||||||
});
|
});
|
||||||
it('a diagram with multiple nodes', async () => {
|
it('a diagram with multiple nodes', async () => {
|
||||||
const str = `blockDiagram-beta
|
const str = `block-beta
|
||||||
id1
|
id1
|
||||||
id2
|
id2
|
||||||
`;
|
`;
|
||||||
|
|
||||||
blockDiagram.parse(str);
|
block.parse(str);
|
||||||
});
|
});
|
||||||
it('a node with a square shape and a label', async () => {
|
it('a node with a square shape and a label', async () => {
|
||||||
const str = `blockDiagram-beta
|
const str = `block-beta
|
||||||
id["A label"]
|
id["A label"]
|
||||||
id2`;
|
id2`;
|
||||||
|
|
||||||
blockDiagram.parse(str);
|
block.parse(str);
|
||||||
});
|
});
|
||||||
it('a diagram with multiple nodes with edges', async () => {
|
it('a diagram with multiple nodes with edges', async () => {
|
||||||
const str = `blockDiagram-beta
|
const str = `block-beta
|
||||||
id1["first"] --> id2["second"]
|
id1["first"] --> id2["second"]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
blockDiagram.parse(str);
|
block.parse(str);
|
||||||
});
|
});
|
||||||
// it('a diagram with column statements', async () => {
|
// it('a diagram with column statements', async () => {
|
||||||
// const str = `blockDiagram-beta
|
// const str = `block-beta
|
||||||
// columns 1
|
// columns 1
|
||||||
// block1["Block 1"]
|
// block1["Block 1"]
|
||||||
// `;
|
// `;
|
||||||
|
|
||||||
// blockDiagram.parse(str);
|
// block.parse(str);
|
||||||
// });
|
// });
|
||||||
// it('a diagram with block hierarchies', async () => {
|
// it('a diagram with block hierarchies', async () => {
|
||||||
// const str = `blockDiagram-beta
|
// const str = `block-beta
|
||||||
// columns 1
|
// columns 1
|
||||||
// block1[Block 1]
|
// block1[Block 1]
|
||||||
|
|
||||||
@ -63,10 +63,10 @@ describe('Sankey diagram', function () {
|
|||||||
// end %% End the compound block
|
// end %% End the compound block
|
||||||
// `;
|
// `;
|
||||||
|
|
||||||
// blockDiagram.parse(str);
|
// block.parse(str);
|
||||||
// });
|
// });
|
||||||
// it('a diagram with differernt column values in different blocks', async () => {
|
// it('a diagram with differernt column values in different blocks', async () => {
|
||||||
// const str = `blockDiagram-beta
|
// const str = `block-beta
|
||||||
// columns 1
|
// columns 1
|
||||||
// block1[Block 1]
|
// block1[Block 1]
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ describe('Sankey diagram', function () {
|
|||||||
// end %% End the compound block
|
// end %% End the compound block
|
||||||
// `;
|
// `;
|
||||||
|
|
||||||
// blockDiagram.parse(str);
|
// block.parse(str);
|
||||||
|
|
||||||
// // Todo check that the different blocks have different column values
|
// // Todo check that the different blocks have different column values
|
||||||
// });
|
// });
|
Loading…
x
Reference in New Issue
Block a user