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

bug: State diagram fix classes type #3798

10 changes: 8 additions & 2 deletions packages/mermaid/src/diagrams/state/stateDb.js
Expand Up @@ -31,9 +31,15 @@ const FILL_KEYWORD = 'fill';
const BG_FILL = 'bgFill';
const STYLECLASS_SEP = ',';

// Returns a new list of classes.
// In the future, this can be replaced with a class common to all diagrams.
function newClassesList() {
return {};
}

let direction = DEFAULT_DIAGRAM_DIRECTION;
let rootDoc = [];
let classes = []; // style classes defined by a classDef
let classes = newClassesList(); // style classes defined by a classDef

const newDoc = () => {
return {
Expand Down Expand Up @@ -274,7 +280,7 @@ export const clear = function (saveCommon) {

// number of start and end nodes; used to construct ids
startEndCount = 0;
classes = [];
classes = newClassesList();
if (!saveCommon) {
commonClear();
}
Expand Down
2 changes: 1 addition & 1 deletion packages/mermaid/src/mermaidAPI.ts
Expand Up @@ -32,7 +32,7 @@ import { evaluate } from './diagrams/common/common';
import { isEmpty } from 'lodash';

// diagram names that support classDef statements
const CLASSDEF_DIAGRAMS = ['graph', 'flowchart', 'flowchart-v2', 'stateDiagram'];
const CLASSDEF_DIAGRAMS = ['graph', 'flowchart', 'flowchart-v2', 'stateDiagram', 'stateDiagram-v2'];

const MAX_TEXTLENGTH_EXCEEDED_MSG =
'graph TB;a[Maximum text size in diagram exceeded];style a fill:#faa';
Expand Down