Skip to content

Commit

Permalink
#3358 Review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
knsv committed Jan 30, 2024
1 parent 1023797 commit 452cb83
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 20 deletions.
18 changes: 10 additions & 8 deletions packages/mermaid/src/diagrams/block/blockDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const setCssClass = function (itemIds: string, cssClassName: string) {
});
};

const populateBlockDatabase = (_blockList: (Block[] | Block[][]), parent: Block): void => {
const populateBlockDatabase = (_blockList: Block[] | Block[][], parent: Block): void => {
const blockList = _blockList.flat();
const children = [];
for (const block of blockList) {
Expand Down Expand Up @@ -265,13 +265,14 @@ const getColumns = (blockid: string): number => {
* @returns
*/
const getBlocksFlat = () => {
const result: Block[] = [];
// log.debug('abc88 getBlocksFlat', blockDatabase);
const keys = Object.keys(blockDatabase);
for (const key of keys) {
result.push(blockDatabase[key]);
}
return result;
// const result: Block[] = [];
// // log.debug('abc88 getBlocksFlat', blockDatabase);
// const keys = Object.keys(blockDatabase);
// for (const key of keys) {
// result.push(blockDatabase[key]);
// }
// return result;
return [...Object.values(blockDatabase)];
};
/**
* Returns the the hierarchy of blocks
Expand All @@ -280,6 +281,7 @@ const getBlocksFlat = () => {
const getBlocks = () => {
return blocks || [];
};

const getEdges = () => {
return edgeList;
};
Expand Down
6 changes: 0 additions & 6 deletions packages/mermaid/src/diagrams/block/blockDiagram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ import db from './blockDB.js';
import flowStyles from './styles.js';
import renderer from './blockRenderer.js';

// TODO: do we need this?
// import { prepareTextForParsing } from './blockUtils.js';
// const originalParse = parser.parse.bind(parser);
// parser.parse = (text: string) => originalParse(prepareTextForParsing(text));
// parser.yy.getLogger = () => console;

export const diagram: DiagramDefinition = {
parser,
db,
Expand Down
7 changes: 1 addition & 6 deletions packages/mermaid/src/diagrams/block/blockRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@ import { configureSvgSize } from '../../setupGraphViewbox.js';
* @returns ClassDef - The styles
*/
export const getClasses = function (text: any, diagObj: any) {
log.debug('Extracting classes', diagObj.db.getClasses());
try {
return diagObj.db.getClasses();
} catch (e) {
return;
}
return diagObj.db.getClasses();
};

export const draw = async function (
Expand Down

0 comments on commit 452cb83

Please sign in to comment.