mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
feat: registered architecture diagram
This commit is contained in:
parent
5a4d4972e2
commit
346ae22108
@ -26,6 +26,7 @@ const MERMAID_CONFIG_DIAGRAM_KEYS = [
|
||||
'c4',
|
||||
'sankey',
|
||||
'block',
|
||||
'architecture'
|
||||
] as const;
|
||||
|
||||
/**
|
||||
|
@ -54,6 +54,7 @@ const MERMAID_CONFIG_DIAGRAM_KEYS = [
|
||||
'gitGraph',
|
||||
'c4',
|
||||
'sankey',
|
||||
'architecture'
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -165,6 +165,7 @@ export interface MermaidConfig {
|
||||
quadrantChart?: QuadrantChartConfig;
|
||||
xyChart?: XYChartConfig;
|
||||
requirement?: RequirementDiagramConfig;
|
||||
architecture?: ArchitectureDiagramConfig;
|
||||
mindmap?: MindmapDiagramConfig;
|
||||
gitGraph?: GitGraphDiagramConfig;
|
||||
c4?: C4DiagramConfig;
|
||||
@ -629,6 +630,16 @@ export interface RequirementDiagramConfig extends BaseDiagramConfig {
|
||||
rect_padding?: number;
|
||||
line_height?: number;
|
||||
}
|
||||
/**
|
||||
* The object containing configurations specific for architecture diagrams
|
||||
*
|
||||
* This interface was referenced by `MermaidConfig`'s JSON-Schema
|
||||
* via the `definition` "ArchitectureDiagramConfig".
|
||||
*/
|
||||
export interface ArchitectureDiagramConfig extends BaseDiagramConfig {
|
||||
padding?: number;
|
||||
maxNodeWidth?: number;
|
||||
}
|
||||
/**
|
||||
* The object containing configurations specific for mindmap diagrams
|
||||
*
|
||||
|
@ -21,6 +21,7 @@ import timeline from '../diagrams/timeline/detector.js';
|
||||
import mindmap from '../diagrams/mindmap/detector.js';
|
||||
import sankey from '../diagrams/sankey/sankeyDetector.js';
|
||||
import block from '../diagrams/block/blockDetector.js';
|
||||
import architecture from '../diagrams/architecture/architectureDetector.js'
|
||||
import { registerLazyLoadedDiagrams } from './detectType.js';
|
||||
import { registerDiagram } from './diagramAPI.js';
|
||||
|
||||
@ -89,6 +90,7 @@ export const addDiagrams = () => {
|
||||
quadrantChart,
|
||||
sankey,
|
||||
xychart,
|
||||
block
|
||||
block,
|
||||
architecture
|
||||
);
|
||||
};
|
||||
|
@ -0,0 +1,24 @@
|
||||
import type {
|
||||
DiagramDetector,
|
||||
DiagramLoader,
|
||||
ExternalDiagramDefinition,
|
||||
} from '../../diagram-api/types.js';
|
||||
|
||||
const id = 'architecture';
|
||||
|
||||
const detector: DiagramDetector = (txt) => {
|
||||
return /^\s*architecture/.test(txt);
|
||||
};
|
||||
|
||||
const loader: DiagramLoader = async () => {
|
||||
const { diagram } = await import('./architectureDiagram.js');
|
||||
return { id, diagram };
|
||||
};
|
||||
|
||||
const architecture: ExternalDiagramDefinition = {
|
||||
id,
|
||||
detector,
|
||||
loader,
|
||||
};
|
||||
|
||||
export default architecture;
|
@ -45,6 +45,7 @@ required:
|
||||
- quadrantChart
|
||||
- xyChart
|
||||
- requirement
|
||||
- architecture
|
||||
- mindmap
|
||||
- gitGraph
|
||||
- c4
|
||||
@ -217,6 +218,8 @@ properties:
|
||||
$ref: '#/$defs/XYChartConfig'
|
||||
requirement:
|
||||
$ref: '#/$defs/RequirementDiagramConfig'
|
||||
architecture:
|
||||
$ref: '#/$defs/ArchitectureDiagramConfig'
|
||||
mindmap:
|
||||
$ref: '#/$defs/MindmapDiagramConfig'
|
||||
gitGraph:
|
||||
@ -853,6 +856,24 @@ $defs: # JSON Schema definition (maybe we should move these to a separate file)
|
||||
type: number
|
||||
default: 20
|
||||
|
||||
ArchitectureDiagramConfig:
|
||||
title: Architecture Diagram Config
|
||||
allOf: [{ $ref: '#/$defs/BaseDiagramConfig'}]
|
||||
description: The object containing configurations specific for architecture diagrams
|
||||
type: object
|
||||
unevaluatedProperties: false
|
||||
required:
|
||||
- useMaxWidth
|
||||
- padding
|
||||
- maxNodeWidth
|
||||
properties:
|
||||
padding:
|
||||
type: number
|
||||
default: 10
|
||||
maxNodeWidth:
|
||||
type: number
|
||||
default: 200
|
||||
|
||||
MindmapDiagramConfig:
|
||||
title: Mindmap Diagram Config
|
||||
allOf: [{ $ref: '#/$defs/BaseDiagramConfig' }]
|
||||
|
Loading…
x
Reference in New Issue
Block a user