Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move commonDb into diagrams/common/commonDb #4802

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 0 additions & 47 deletions packages/mermaid/src/commonDb.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/mermaid/src/diagram-api/diagramAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { sanitizeText as _sanitizeText } from '../diagrams/common/common.js';
import { setupGraphViewbox as _setupGraphViewbox } from '../setupGraphViewbox.js';
import { addStylesForDiagram } from '../styles.js';
import type { DiagramDefinition, DiagramDetector } from './types.js';
import * as _commonDb from '../commonDb.js';
import * as _commonDb from '../diagrams/common/commonDb.js';
import { parseDirective as _parseDirective } from '../directiveUtils.js';

/*
Expand Down
7 changes: 6 additions & 1 deletion packages/mermaid/src/diagrams/c4/c4Db.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import mermaidAPI from '../../mermaidAPI.js';
import * as configApi from '../../config.js';
import { sanitizeText } from '../common/common.js';
import { setAccTitle, getAccTitle, getAccDescription, setAccDescription } from '../../commonDb.js';
import {
setAccTitle,
getAccTitle,
getAccDescription,
setAccDescription,
} from '../common/commonDb.js';

let c4ShapeArray = [];
let boundaryParseStack = [''];
Expand Down
2 changes: 1 addition & 1 deletion packages/mermaid/src/diagrams/class/classDb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
clear as commonClear,
setDiagramTitle,
getDiagramTitle,
} from '../../commonDb.js';
} from '../common/commonDb.js';
import { ClassMember } from './classTypes.js';
import type {
ClassRelation,
Expand Down
32 changes: 32 additions & 0 deletions packages/mermaid/src/diagrams/common/commonDb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { sanitizeText as _sanitizeText } from './common.js';
import { getConfig } from '../../config.js';

let accTitle = '';
let diagramTitle = '';
let accDescription = '';

const sanitizeText = (txt: string): string => _sanitizeText(txt, getConfig());

export const clear = (): void => {
accTitle = '';
accDescription = '';
diagramTitle = '';
};

export const setAccTitle = (txt: string): void => {
accTitle = sanitizeText(txt).replace(/^\s+/g, '');
};

export const getAccTitle = (): string => accTitle;

export const setAccDescription = (txt: string): void => {
accDescription = sanitizeText(txt).replace(/\n\s+/g, '\n');
};

Check warning on line 24 in packages/mermaid/src/diagrams/common/commonDb.ts

View check run for this annotation

Codecov / codecov/patch

packages/mermaid/src/diagrams/common/commonDb.ts#L23-L24

Added lines #L23 - L24 were not covered by tests

export const getAccDescription = (): string => accDescription;

export const setDiagramTitle = (txt: string): void => {
diagramTitle = sanitizeText(txt);
};

Check warning on line 30 in packages/mermaid/src/diagrams/common/commonDb.ts

View check run for this annotation

Codecov / codecov/patch

packages/mermaid/src/diagrams/common/commonDb.ts#L29-L30

Added lines #L29 - L30 were not covered by tests

export const getDiagramTitle = (): string => diagramTitle;
2 changes: 1 addition & 1 deletion packages/mermaid/src/diagrams/er/erDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
clear as commonClear,
setDiagramTitle,
getDiagramTitle,
} from '../../commonDb.js';
} from '../common/commonDb.js';

let entities = {};
let relationships = [];
Expand Down
2 changes: 1 addition & 1 deletion packages/mermaid/src/diagrams/flowchart/flowDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
clear as commonClear,
setDiagramTitle,
getDiagramTitle,
} from '../../commonDb.js';
} from '../common/commonDb.js';

const MERMAID_DOM_ID_PREFIX = 'flowchart-';
let vertexCounter = 0;
Expand Down
2 changes: 1 addition & 1 deletion packages/mermaid/src/diagrams/gantt/ganttDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
clear as commonClear,
setDiagramTitle,
getDiagramTitle,
} from '../../commonDb.js';
} from '../common/commonDb.js';

dayjs.extend(dayjsIsoWeek);
dayjs.extend(dayjsCustomParseFormat);
Expand Down
2 changes: 1 addition & 1 deletion packages/mermaid/src/diagrams/git/gitGraphAst.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
clear as commonClear,
setDiagramTitle,
getDiagramTitle,
} from '../../commonDb.js';
} from '../common/commonDb.js';

let mainBranchName = getConfig().gitGraph.mainBranchName;
let mainBranchOrder = getConfig().gitGraph.mainBranchOrder;
Expand Down
2 changes: 1 addition & 1 deletion packages/mermaid/src/diagrams/pie/pieDb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
getAccDescription,
setAccDescription,
clear as commonClear,
} from '../../commonDb.js';
} from '../common/commonDb.js';
import type { ParseDirectiveDefinition } from '../../diagram-api/types.js';
import type { PieFields, PieDB, Sections } from './pieTypes.js';
import type { RequiredDeep } from 'type-fest';
Expand Down
2 changes: 1 addition & 1 deletion packages/mermaid/src/diagrams/quadrant-chart/quadrantDb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
getAccDescription,
setAccDescription,
clear as commonClear,
} from '../../commonDb.js';
} from '../common/commonDb.js';
import { QuadrantBuilder } from './quadrantBuilder.js';

const config = configApi.getConfig();
Expand Down
2 changes: 1 addition & 1 deletion packages/mermaid/src/diagrams/requirement/requirementDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
getAccDescription,
setAccDescription,
clear as commonClear,
} from '../../commonDb.js';
} from '../common/commonDb.js';

let relations = [];
let latestRequirement = {};
Expand Down
2 changes: 1 addition & 1 deletion packages/mermaid/src/diagrams/sankey/sankeyDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
setDiagramTitle,
getDiagramTitle,
clear as commonClear,
} from '../../commonDb.js';
} from '../common/commonDb.js';

// Sankey diagram represented by nodes and links between those nodes
let links: SankeyLink[] = [];
Expand Down
2 changes: 1 addition & 1 deletion packages/mermaid/src/diagrams/sequence/sequenceDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
getAccDescription,
setAccDescription,
clear as commonClear,
} from '../../commonDb.js';
} from '../common/commonDb.js';

let prevActor = undefined;
let actors = {};
Expand Down
2 changes: 1 addition & 1 deletion packages/mermaid/src/diagrams/state/stateDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
clear as commonClear,
setDiagramTitle,
getDiagramTitle,
} from '../../commonDb.js';
} from '../common/commonDb.js';

import {
DEFAULT_DIAGRAM_DIRECTION,
Expand Down
2 changes: 0 additions & 2 deletions packages/mermaid/src/diagrams/timeline/timeline.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { parser as timeline } from './parser/timeline.jison';
import * as timelineDB from './timelineDb.js';
// import { injectUtils } from './mermaidUtils.js';
import * as _commonDb from '../../commonDb.js';
import { parseDirective as _parseDirective } from '../../directiveUtils.js';

import {
Expand All @@ -18,7 +17,6 @@ import {
// getConfig,
// sanitizeText,
// setupGraphViewBox,
// _commonDb,
// _parseDirective
// );

Expand Down
2 changes: 1 addition & 1 deletion packages/mermaid/src/diagrams/timeline/timelineDb.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { parseDirective as _parseDirective } from '../../directiveUtils.js';
import * as commonDb from '../../commonDb.js';
import * as commonDb from '../common/commonDb.js';
let currentSection = '';
let currentTaskId = 0;

Expand Down
2 changes: 1 addition & 1 deletion packages/mermaid/src/diagrams/user-journey/journeyDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
getAccDescription,
setAccDescription,
clear as commonClear,
} from '../../commonDb.js';
} from '../common/commonDb.js';

let currentSection = '';

Expand Down
Loading