Rename BlockDiagram to Block

This commit is contained in:
Nikolay Rozhkov 2023-07-07 13:58:30 +03:00
parent 86e1bb38ee
commit 791e67641e
10 changed files with 35 additions and 28 deletions

View File

@ -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;

View File

@ -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
); );
}; };

View File

@ -23,7 +23,7 @@ const clear = (): void => {
}; };
export default { export default {
getConfig: () => configApi.getConfig().blockDiagram, getConfig: () => configApi.getConfig().block,
getAccTitle, getAccTitle,
setAccTitle, setAccTitle,

View File

@ -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 () => {

View File

@ -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));

View File

@ -0,0 +1,5 @@
import type { DiagramDB } from '../../diagram-api/types.js';
export interface BlockDB extends DiagramDB {
clear: () => void;
}

View File

@ -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 */ }

View File

@ -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
// }); // });