mirror of
				https://github.com/mermaid-js/mermaid.git
				synced 2025-11-04 04:44:08 +01:00 
			
		
		
		
	Resolve merge conflicts with develop
This commit is contained in:
		@@ -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);
 | 
			
		||||
      }
 | 
			
		||||
      if (doc?.icon) {
 | 
			
		||||
        vertex.icon = doc?.icon;
 | 
			
		||||
@@ -267,7 +279,7 @@ export class FlowDB implements DiagramDB {
 | 
			
		||||
      if (edge.text.startsWith('"') && edge.text.endsWith('"')) {
 | 
			
		||||
        edge.text = edge.text.substring(1, edge.text.length - 1);
 | 
			
		||||
      }
 | 
			
		||||
      edge.labelType = linkTextObj.type;
 | 
			
		||||
      edge.labelType = this.sanitizeNodeLabelType(linkTextObj.type);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (type !== undefined) {
 | 
			
		||||
@@ -702,7 +714,7 @@ You have to call mermaid.initialize.`
 | 
			
		||||
      title: title.trim(),
 | 
			
		||||
      classes: [],
 | 
			
		||||
      dir,
 | 
			
		||||
      labelType: _title.type,
 | 
			
		||||
      labelType: this.sanitizeNodeLabelType(_title?.type),
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    log.info('Adding', subGraph.id, subGraph.nodes, subGraph.dir);
 | 
			
		||||
@@ -1012,6 +1024,7 @@ You have to call mermaid.initialize.`
 | 
			
		||||
      const baseNode = {
 | 
			
		||||
        id: vertex.id,
 | 
			
		||||
        label: vertex.text,
 | 
			
		||||
        labelType: vertex.labelType,
 | 
			
		||||
        labelStyle: '',
 | 
			
		||||
        parentId,
 | 
			
		||||
        padding: config.flowchart?.padding || 8,
 | 
			
		||||
@@ -1088,6 +1101,7 @@ You have to call mermaid.initialize.`
 | 
			
		||||
        id: subGraph.id,
 | 
			
		||||
        label: subGraph.title,
 | 
			
		||||
        labelStyle: '',
 | 
			
		||||
        labelType: subGraph.labelType,
 | 
			
		||||
        parentId: parentDB.get(subGraph.id),
 | 
			
		||||
        padding: 8,
 | 
			
		||||
        cssCompiledStyles: this.getCompiledStyles(subGraph.classes),
 | 
			
		||||
@@ -1119,6 +1133,7 @@ You have to call mermaid.initialize.`
 | 
			
		||||
        end: rawEdge.end,
 | 
			
		||||
        type: rawEdge.type ?? 'normal',
 | 
			
		||||
        label: rawEdge.text,
 | 
			
		||||
        labelType: rawEdge.labelType,
 | 
			
		||||
        labelpos: 'c',
 | 
			
		||||
        thickness: rawEdge.stroke,
 | 
			
		||||
        minlen: rawEdge.length,
 | 
			
		||||
 
 | 
			
		||||
@@ -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';
 | 
			
		||||
 
 | 
			
		||||
@@ -30,11 +30,17 @@ const rect = async (parent, node) => {
 | 
			
		||||
  // Create the label and insert it after the rect
 | 
			
		||||
  const labelEl = shapeSvg.insert('g').attr('class', 'cluster-label ');
 | 
			
		||||
 | 
			
		||||
  const text = await createText(labelEl, node.label, {
 | 
			
		||||
    style: node.labelStyle,
 | 
			
		||||
    useHtmlLabels,
 | 
			
		||||
    isNode: true,
 | 
			
		||||
  });
 | 
			
		||||
  let text;
 | 
			
		||||
  if (node.labelType === 'markdown') {
 | 
			
		||||
    text = await createText(labelEl, node.label, {
 | 
			
		||||
      style: node.labelStyle,
 | 
			
		||||
      useHtmlLabels,
 | 
			
		||||
      isNode: true,
 | 
			
		||||
    });
 | 
			
		||||
  } else {
 | 
			
		||||
    const labelElement = await createLabel(node.label, node.labelStyle, false, true);
 | 
			
		||||
    text = labelEl.node()?.appendChild(labelElement);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Get the size of the label
 | 
			
		||||
  let bbox = text.getBBox();
 | 
			
		||||
 
 | 
			
		||||
@@ -29,7 +29,7 @@ import {
 | 
			
		||||
import rough from 'roughjs';
 | 
			
		||||
import createLabel from './createLabel.js';
 | 
			
		||||
import { addEdgeMarkers } from './edgeMarker.ts';
 | 
			
		||||
import { isLabelStyle, styles2String } from './shapes/handDrawnShapeStyles.js';
 | 
			
		||||
import { isLabelStyle } from './shapes/handDrawnShapeStyles.js';
 | 
			
		||||
 | 
			
		||||
export const edgeLabels = new Map();
 | 
			
		||||
export const terminalLabels = new Map();
 | 
			
		||||
@@ -47,14 +47,16 @@ export const getLabelStyles = (styleArray) => {
 | 
			
		||||
export const insertEdgeLabel = async (elem, edge) => {
 | 
			
		||||
  let useHtmlLabels = evaluate(getConfig().flowchart.htmlLabels);
 | 
			
		||||
 | 
			
		||||
  const { labelStyles } = styles2String(edge);
 | 
			
		||||
  edge.labelStyle = labelStyles;
 | 
			
		||||
  const labelElement = await createText(elem, edge.label, {
 | 
			
		||||
    style: edge.labelStyle,
 | 
			
		||||
    useHtmlLabels,
 | 
			
		||||
    addSvgBackground: true,
 | 
			
		||||
    isNode: false,
 | 
			
		||||
  });
 | 
			
		||||
  const labelElement =
 | 
			
		||||
    edge.labelType === 'markdown'
 | 
			
		||||
      ? await createText(elem, edge.label, {
 | 
			
		||||
          style: getLabelStyles(edge.labelStyle),
 | 
			
		||||
          useHtmlLabels,
 | 
			
		||||
          addSvgBackground: true,
 | 
			
		||||
          isNode: false,
 | 
			
		||||
        })
 | 
			
		||||
      : await createLabel(edge.label, getLabelStyles(edge.labelStyle), undefined, false);
 | 
			
		||||
 | 
			
		||||
  log.info('abc82', edge, edge.labelType);
 | 
			
		||||
 | 
			
		||||
  // Create outer g, edgeLabel, this will be positioned after graph layout
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
import createLabel from '../createLabel.js';
 | 
			
		||||
import { createText } from '../../createText.js';
 | 
			
		||||
import type { Node } from '../../types.js';
 | 
			
		||||
import { getConfig } from '../../../diagram-api/diagramAPI.js';
 | 
			
		||||
@@ -13,7 +14,7 @@ export const labelHelper = async <T extends SVGGraphicsElement>(
 | 
			
		||||
  _classes?: string
 | 
			
		||||
) => {
 | 
			
		||||
  let cssClasses;
 | 
			
		||||
  const useHtmlLabels = node.useHtmlLabels || evaluate(getConfig()?.htmlLabels);
 | 
			
		||||
  const useHtmlLabels = node.useHtmlLabels || evaluate(getConfig()?.flowchart?.htmlLabels);
 | 
			
		||||
  if (!_classes) {
 | 
			
		||||
    cssClasses = 'node default';
 | 
			
		||||
  } else {
 | 
			
		||||
@@ -40,14 +41,26 @@ export const labelHelper = async <T extends SVGGraphicsElement>(
 | 
			
		||||
    label = typeof node.label === 'string' ? node.label : node.label[0];
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  const text = await createText(labelEl, sanitizeText(decodeEntities(label), getConfig()), {
 | 
			
		||||
    useHtmlLabels,
 | 
			
		||||
    width: node.width || getConfig().flowchart?.wrappingWidth,
 | 
			
		||||
    // @ts-expect-error -- This is currently not used. Should this be `classes` instead?
 | 
			
		||||
    cssClasses: 'markdown-node-label',
 | 
			
		||||
    style: node.labelStyle,
 | 
			
		||||
    addSvgBackground: !!node.icon || !!node.img,
 | 
			
		||||
  });
 | 
			
		||||
  let text;
 | 
			
		||||
  if (node.labelType === 'markdown') {
 | 
			
		||||
    text = await createText(labelEl, sanitizeText(decodeEntities(label), getConfig()), {
 | 
			
		||||
      useHtmlLabels,
 | 
			
		||||
      width: node.width || getConfig().flowchart?.wrappingWidth,
 | 
			
		||||
      // @ts-expect-error -- This is currently not used. Should this be `classes` instead?
 | 
			
		||||
      cssClasses: 'markdown-node-label',
 | 
			
		||||
      style: node.labelStyle,
 | 
			
		||||
      addSvgBackground: !!node.icon || !!node.img,
 | 
			
		||||
    });
 | 
			
		||||
  } else {
 | 
			
		||||
    const labelElement = await createLabel(
 | 
			
		||||
      sanitizeText(decodeEntities(label), getConfig()),
 | 
			
		||||
      node.labelStyle,
 | 
			
		||||
      false,
 | 
			
		||||
      true
 | 
			
		||||
    );
 | 
			
		||||
    text = labelEl.node()?.appendChild(labelElement);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Get the size of the label
 | 
			
		||||
  let bbox = text.getBBox();
 | 
			
		||||
  const halfPadding = (node?.padding ?? 0) / 2;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,7 @@
 | 
			
		||||
export interface NodeMetaData {
 | 
			
		||||
  shape?: string;
 | 
			
		||||
  label?: string;
 | 
			
		||||
  labelType?: string;
 | 
			
		||||
  icon?: string;
 | 
			
		||||
  form?: string;
 | 
			
		||||
  pos?: 't' | 'b';
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user