mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-02-04 07:13:25 +08:00
Merge pull request #6006 from yari-dewalt/fix-note-non-html-text
Fix note non html text
This commit is contained in:
commit
ece3b254db
@ -39,6 +39,7 @@ export function markdownToLines(markdown: string, config: MermaidConfig = {}): M
|
|||||||
lines.push([]);
|
lines.push([]);
|
||||||
}
|
}
|
||||||
textLine.split(' ').forEach((word) => {
|
textLine.split(' ').forEach((word) => {
|
||||||
|
word = word.replace(/'/g, `'`);
|
||||||
if (word) {
|
if (word) {
|
||||||
lines[currentLine].push({ content: word, type: parentType });
|
lines[currentLine].push({ content: word, type: parentType });
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import intersect from '../intersect/index.js';
|
|||||||
import { styles2String, userNodeOverrides } from './handDrawnShapeStyles.js';
|
import { styles2String, userNodeOverrides } from './handDrawnShapeStyles.js';
|
||||||
import { getNodeClasses, labelHelper, updateNodeBounds } from './util.js';
|
import { getNodeClasses, labelHelper, updateNodeBounds } from './util.js';
|
||||||
import type { D3Selection } from '../../../types.js';
|
import type { D3Selection } from '../../../types.js';
|
||||||
|
import { getConfig } from '../../../config.js';
|
||||||
|
|
||||||
export async function note<T extends SVGGraphicsElement>(
|
export async function note<T extends SVGGraphicsElement>(
|
||||||
parent: D3Selection<T>,
|
parent: D3Selection<T>,
|
||||||
@ -12,16 +13,16 @@ export async function note<T extends SVGGraphicsElement>(
|
|||||||
) {
|
) {
|
||||||
const { labelStyles, nodeStyles } = styles2String(node);
|
const { labelStyles, nodeStyles } = styles2String(node);
|
||||||
node.labelStyle = labelStyles;
|
node.labelStyle = labelStyles;
|
||||||
|
const useHtmlLabels = node.useHtmlLabels || getConfig().htmlLabels;
|
||||||
|
if (!useHtmlLabels) {
|
||||||
|
node.centerLabel = true;
|
||||||
|
}
|
||||||
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node));
|
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node));
|
||||||
const totalWidth = Math.max(bbox.width + (node.padding ?? 0) * 2, node?.width ?? 0);
|
const totalWidth = Math.max(bbox.width + (node.padding ?? 0) * 2, node?.width ?? 0);
|
||||||
const totalHeight = Math.max(bbox.height + (node.padding ?? 0) * 2, node?.height ?? 0);
|
const totalHeight = Math.max(bbox.height + (node.padding ?? 0) * 2, node?.height ?? 0);
|
||||||
const x = -totalWidth / 2;
|
const x = -totalWidth / 2;
|
||||||
const y = -totalHeight / 2;
|
const y = -totalHeight / 2;
|
||||||
const { cssStyles } = node;
|
const { cssStyles } = node;
|
||||||
const useHtmlLabels = node.useHtmlLabels;
|
|
||||||
if (!useHtmlLabels) {
|
|
||||||
node.centerLabel = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// add the rect
|
// add the rect
|
||||||
// @ts-ignore TODO: Fix rough typings
|
// @ts-ignore TODO: Fix rough typings
|
||||||
|
@ -14,7 +14,7 @@ export const labelHelper = async <T extends SVGGraphicsElement>(
|
|||||||
_shapeSvg?: D3Selection<T>
|
_shapeSvg?: D3Selection<T>
|
||||||
) => {
|
) => {
|
||||||
let cssClasses;
|
let cssClasses;
|
||||||
const useHtmlLabels = node.useHtmlLabels || evaluate(getConfig()?.flowchart?.htmlLabels);
|
const useHtmlLabels = node.useHtmlLabels || evaluate(getConfig()?.htmlLabels);
|
||||||
if (!_classes) {
|
if (!_classes) {
|
||||||
cssClasses = 'node default';
|
cssClasses = 'node default';
|
||||||
} else {
|
} else {
|
||||||
@ -55,7 +55,7 @@ export const labelHelper = async <T extends SVGGraphicsElement>(
|
|||||||
let bbox = text.getBBox();
|
let bbox = text.getBBox();
|
||||||
const halfPadding = (node?.padding ?? 0) / 2;
|
const halfPadding = (node?.padding ?? 0) / 2;
|
||||||
|
|
||||||
if (evaluate(getConfig().flowchart?.htmlLabels)) {
|
if (useHtmlLabels) {
|
||||||
const div = text.children[0];
|
const div = text.children[0];
|
||||||
const dv = select(text);
|
const dv = select(text);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user