mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-25 18:30:10 +02:00
refatored code
This commit is contained in:
@@ -3,11 +3,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// default diagram direction
|
// default diagram direction
|
||||||
export const DEFAULT_DIAGRAM_DIRECTION = 'LR';
|
export const DEFAULT_DIAGRAM_DIRECTION = 'TB';
|
||||||
|
|
||||||
// default direction for any nested documents (composites)
|
// default direction for any nested documents (composites)
|
||||||
export const DEFAULT_NESTED_DOC_DIR = 'TB';
|
export const DEFAULT_NESTED_DOC_DIR = 'TB';
|
||||||
|
|
||||||
|
// parsed statement type for a direction
|
||||||
|
export const STMT_DIRECTION = 'dir';
|
||||||
|
|
||||||
// parsed statement type for a state
|
// parsed statement type for a state
|
||||||
export const STMT_STATE = 'state';
|
export const STMT_STATE = 'state';
|
||||||
// parsed statement type for a relation
|
// parsed statement type for a relation
|
||||||
|
@@ -20,6 +20,7 @@ import {
|
|||||||
DIVIDER_TYPE,
|
DIVIDER_TYPE,
|
||||||
STMT_APPLYCLASS,
|
STMT_APPLYCLASS,
|
||||||
STMT_CLASSDEF,
|
STMT_CLASSDEF,
|
||||||
|
STMT_DIRECTION,
|
||||||
STMT_RELATION,
|
STMT_RELATION,
|
||||||
STMT_STATE,
|
STMT_STATE,
|
||||||
STMT_STYLEDEF,
|
STMT_STYLEDEF,
|
||||||
@@ -79,11 +80,6 @@ export class StateDB {
|
|||||||
*/
|
*/
|
||||||
edges = [];
|
edges = [];
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
direction = DEFAULT_DIAGRAM_DIRECTION;
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {Array}
|
* @type {Array}
|
||||||
@@ -643,16 +639,16 @@ export class StateDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getDirection() {
|
getDirection() {
|
||||||
const doc = this.rootDoc.find((doc) => doc.stmt === 'dir');
|
const doc = this.rootDoc.find((doc) => doc.stmt === STMT_DIRECTION);
|
||||||
this.direction = doc ? doc.value : 'TB';
|
const direction = doc ? doc.value : DEFAULT_DIAGRAM_DIRECTION;
|
||||||
return this.direction;
|
return direction;
|
||||||
}
|
}
|
||||||
setDirection(dir) {
|
setDirection(dir) {
|
||||||
let doc = this.rootDoc.find((doc) => doc.stmt === 'dir');
|
const doc = this.rootDoc.find((doc) => doc.stmt === STMT_DIRECTION);
|
||||||
if (doc) {
|
if (doc) {
|
||||||
doc.value = dir;
|
doc.value = dir;
|
||||||
} else {
|
} else {
|
||||||
this.rootDoc.unshift({ stmt: 'dir', value: dir });
|
this.rootDoc.unshift({ stmt: STMT_DIRECTION, value: dir });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user