Repository: mermaid-js/mermaid
File: packages/mermaid/src/diagrams/mindmap/svgDraw.ts (TypeScript)

Code before:
  elem
    .append('rect')
    .attr('id', 'node-' + node.id)
    .attr('class', 'node-bkg node-' + db.type2Str(node.type))
    .attr('height', node.height)
    .attr('rx', node.padding)
    .attr('ry', node.padding)
    .attr('width', node.width);
};

/**
 * @param db - The database
 * @param elem - The D3 dom element in which the node is to be added
 * @param node - The node to be added
 * @param fullSection - ?
 * @param conf - The configuration object
 * @returns The height nodes dom element
 */
export const drawNode = async function (
  db: MindmapDB,
  elem: D3Element,
  node: FilledMindMapNode,
  fullSection: number,
  conf: MermaidConfig
): Promise<number> {
  const htmlLabels = conf.htmlLabels ?? undefined;
  const section = fullSection % (MAX_SECTIONS - 1);
  const nodeElem = elem.append('g');
  node.section = section;
  let sectionClass = 'section-' + section;
  if (section < 0) {
    sectionClass += ' section-root';
  }
  nodeElem.attr('class', (node.class ? node.class + ' ' : '') + 'mindmap-node ' + sectionClass);
  const bkgElem = nodeElem.append('g');

  // Create the wrapped text element
  const textElem = nodeElem.append('g');
  const description = node.descr.replace(/(<br\/*>)/g, '\n');
  await createText(
    textElem,
    description,
    {
      useHtmlLabels: htmlLabels,
      width: node.width,
      classes: 'mindmap-node-label',
    },
    conf
  );

  if (!htmlLabels) {

Review comment (suggestion):
**issue**: Hmmmmm, I don't really like this.

Maybe we could set `conf.htmlLabels` to be `undefined` by default, and instead make `conf.flowchart.htmlLabels` default to `null`?

E.g. like:

```diff
diff --git a/packages/mermaid/src/schemas/config.schema.yaml b/packages/mermaid/src/schemas/config.schema.yaml
index 730077d95..c32b53ef6 100644
--- a/packages/mermaid/src/schemas/config.schema.yaml
+++ b/packages/mermaid/src/schemas/config.schema.yaml
@@ -157,10 +157,7 @@ properties:
       **Note:** Diagram-specific `htmlLabels` settings (e.g., `flowchart.htmlLabels`) are deprecated.
       Use this root-level `htmlLabels` setting instead. The root-level `htmlLabels` takes precedence
       over any diagram-specific settings.
-    type:
-      - boolean
-      - 'null'
-    default: null
+    type: boolean
   fontFamily:
     description: |
       Specifies the font to be used in the rendered diagrams.
```

As long as there's one config option with `htmlLabels` in it that has a default value, (and we can keep `config.flowchart.htmlLabels` defaulting to `null`), this should work and it means we can avoid all the `conf.htmlLabels ?? undefined` mess.

Code after:
  elem
    .append('rect')
    .attr('id', 'node-' + node.id)
    .attr('class', 'node-bkg node-' + db.type2Str(node.type))
    .attr('height', node.height)
    .attr('rx', node.padding)
    .attr('ry', node.padding)
    .attr('width', node.width);
};

/**
 * @param db - The database
 * @param elem - The D3 dom element in which the node is to be added
 * @param node - The node to be added
 * @param fullSection - ?
 * @param conf - The configuration object
 * @returns The height nodes dom element
 */
export const drawNode = async function (
  db: MindmapDB,
  elem: D3Element,
  node: FilledMindMapNode,
  fullSection: number,
  conf: MermaidConfig
): Promise<number> {
  const htmlLabels = conf.htmlLabels;
  const section = fullSection % (MAX_SECTIONS - 1);
  const nodeElem = elem.append('g');
  node.section = section;
  let sectionClass = 'section-' + section;
  if (section < 0) {
    sectionClass += ' section-root';
  }
  nodeElem.attr('class', (node.class ? node.class + ' ' : '') + 'mindmap-node ' + sectionClass);
  const bkgElem = nodeElem.append('g');

  // Create the wrapped text element
  const textElem = nodeElem.append('g');
  const description = node.descr.replace(/(<br\/*>)/g, '\n');
  await createText(
    textElem,
    description,
    {
      useHtmlLabels: htmlLabels,
      width: node.width,
      classes: 'mindmap-node-label',
    },
    conf
  );

  if (!htmlLabels) {