mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-21 06:53:17 +08:00
Small cleanup
This commit is contained in:
parent
791e67641e
commit
fee2b244a1
@ -1,6 +1,7 @@
|
||||
// TODO: This was auto generated from defaultConfig. Needs to be verified.
|
||||
|
||||
import DOMPurify from 'dompurify';
|
||||
import { BlockConfig } from './diagrams/block/blockTypes.js';
|
||||
|
||||
export interface MermaidConfig {
|
||||
theme?: string;
|
||||
@ -33,7 +34,7 @@ export interface MermaidConfig {
|
||||
gitGraph?: GitGraphDiagramConfig;
|
||||
c4?: C4DiagramConfig;
|
||||
sankey?: SankeyDiagramConfig;
|
||||
block?: BlockDiagramConfig;
|
||||
block?: BlockConfig;
|
||||
dompurifyConfig?: DOMPurify.Config;
|
||||
wrap?: boolean;
|
||||
fontSize?: number;
|
||||
@ -422,9 +423,6 @@ export interface SankeyDiagramConfig extends BaseDiagramConfig {
|
||||
linkColor?: SankeyLinkColor | string;
|
||||
nodeAlignment?: SankeyNodeAlignment;
|
||||
}
|
||||
export interface BlockDiagramConfig extends BaseDiagramConfig {
|
||||
padding?: number;
|
||||
}
|
||||
|
||||
export interface FontConfig {
|
||||
fontSize?: string | number;
|
||||
|
@ -1,12 +1,14 @@
|
||||
import type { BlockDB } from './blockTypes.js';
|
||||
|
||||
import * as configApi from '../../config.js';
|
||||
import common from '../common/common.js';
|
||||
// import common from '../common/common.js';
|
||||
import {
|
||||
setAccTitle,
|
||||
getAccTitle,
|
||||
getAccDescription,
|
||||
setAccDescription,
|
||||
setDiagramTitle,
|
||||
getDiagramTitle,
|
||||
// setAccTitle,
|
||||
// getAccTitle,
|
||||
// getAccDescription,
|
||||
// setAccDescription,
|
||||
// setDiagramTitle,
|
||||
// getDiagramTitle,
|
||||
clear as commonClear,
|
||||
} from '../../commonDb.js';
|
||||
|
||||
@ -14,7 +16,6 @@ type Block = {
|
||||
ID: string;
|
||||
};
|
||||
|
||||
// Array of nodes guarantees their order
|
||||
let blocks: Block[] = [];
|
||||
|
||||
const clear = (): void => {
|
||||
@ -22,14 +23,16 @@ const clear = (): void => {
|
||||
commonClear();
|
||||
};
|
||||
|
||||
export default {
|
||||
const db: BlockDB = {
|
||||
getConfig: () => configApi.getConfig().block,
|
||||
|
||||
getAccTitle,
|
||||
setAccTitle,
|
||||
getAccDescription,
|
||||
setAccDescription,
|
||||
getDiagramTitle,
|
||||
setDiagramTitle,
|
||||
// getAccTitle,
|
||||
// setAccTitle,
|
||||
// getAccDescription,
|
||||
// setAccDescription,
|
||||
// getDiagramTitle,
|
||||
// setDiagramTitle,
|
||||
clear,
|
||||
};
|
||||
|
||||
export default db;
|
@ -9,18 +9,14 @@ import {
|
||||
|
||||
import { configureSvgSize } from '../../setupGraphViewbox.js';
|
||||
import { Uid } from '../../rendering-util/uid.js';
|
||||
import type { SankeyLinkColor, SankeyNodeAlignment } from '../../config.type.js';
|
||||
|
||||
export const draw = function (text: string, id: string, _version: string, diagObj: Diagram): void {
|
||||
// Get the config
|
||||
const { securityLevel, sankey: conf } = configApi.getConfig();
|
||||
const defaultSankeyConfig = configApi!.defaultConfig!.blockDiagram!;
|
||||
|
||||
// TODO:
|
||||
// This code repeats for every diagram
|
||||
// Figure out what is happening there, probably it should be separated
|
||||
// The main thing is svg object that is a d3 wrapper for svg operations
|
||||
//
|
||||
const { securityLevel } = configApi.getConfig();
|
||||
let sandboxElement: any;
|
||||
if (securityLevel === 'sandbox') {
|
||||
sandboxElement = d3select('#i' + id);
|
||||
@ -44,11 +40,6 @@ export const draw = function (text: string, id: string, _version: string, diagOb
|
||||
// Prepare data for construction based on diagObj.db
|
||||
// This must be a mutable object with `nodes` and `links` properties:
|
||||
//
|
||||
// {
|
||||
// "nodes": [ { "id": "Alice" }, { "id": "Bob" }, { "id": "Carol" } ],
|
||||
// "links": [ { "source": "Alice", "target": "Bob", "value": 23 }, { "source": "Bob", "target": "Carol", "value": 43 } ]
|
||||
// }
|
||||
//
|
||||
// @ts-ignore TODO: db type
|
||||
const graph = diagObj.db.getGraph();
|
||||
|
||||
|
@ -1,5 +1,11 @@
|
||||
import type { DiagramDB } from '../../diagram-api/types.js';
|
||||
import type { BaseDiagramConfig } from '../../config.type.js';
|
||||
|
||||
export interface BlockConfig extends BaseDiagramConfig {
|
||||
padding?: number;
|
||||
}
|
||||
|
||||
export interface BlockDB extends DiagramDB {
|
||||
clear: () => void;
|
||||
getConfig: () => BlockConfig | undefined;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user