Default to markdown for nodes from metadata

This commit is contained in:
Anthony Juckel
2025-03-02 21:26:43 -06:00
parent 560abf4218
commit 37269b47b5
3 changed files with 15 additions and 2 deletions

View File

@@ -85,6 +85,17 @@ export class FlowDB implements DiagramDB {
return common.sanitizeText(txt, this.config);
}
private sanitizeNodeLabelType(labelType: string) {
switch (labelType) {
case 'markdown':
case 'string':
case 'text':
return labelType;
default:
return 'markdown';
}
}
/**
* Function to lookup domId from id in the graph definition.
*
@@ -208,6 +219,7 @@ export class FlowDB implements DiagramDB {
if (doc?.label) {
vertex.text = doc?.label;
vertex.labelType = this.sanitizeNodeLabelType(doc?.labelType ?? 'markdown');
}
if (doc?.icon) {
vertex.icon = doc?.icon;

View File

@@ -29,7 +29,7 @@ export interface FlowVertex {
domId: string;
haveCallback?: boolean;
id: string;
labelType: 'text';
labelType: 'markdown' | 'string' | 'text';
link?: string;
linkTarget?: string;
props?: any;
@@ -62,7 +62,7 @@ export interface FlowEdge {
style?: string[];
length?: number;
text: string;
labelType: 'text';
labelType: 'markdown' | 'string' | 'text';
classes: string[];
id?: string;
animation?: 'fast' | 'slow';

View File

@@ -1,6 +1,7 @@
export interface NodeMetaData {
shape?: string;
label?: string;
labelType?: string;
icon?: string;
form?: string;
pos?: 't' | 'b';