mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-15 14:29:25 +02:00
refactor: use parseFontSize()
Handle `NaN` values by using `parseFontSize()`. Suggested-by: https://github.com/mermaid-js/mermaid/pull/5974#discussion_r1810570967
This commit is contained in:
@@ -2,8 +2,9 @@ import { createText } from '../../createText.js';
|
||||
import type { Node } from '../../types.js';
|
||||
import { getConfig } from '../../../diagram-api/diagramAPI.js';
|
||||
import { select } from 'd3';
|
||||
import defaultConfig from '../../../defaultConfig.js';
|
||||
import { evaluate, sanitizeText } from '../../../diagrams/common/common.js';
|
||||
import { decodeEntities, handleUndefinedAttr } from '../../../utils.js';
|
||||
import { decodeEntities, handleUndefinedAttr, parseFontSize } from '../../../utils.js';
|
||||
import type { D3Selection, Point } from '../../../types.js';
|
||||
|
||||
export const labelHelper = async <T extends SVGGraphicsElement>(
|
||||
@@ -77,10 +78,7 @@ export const labelHelper = async <T extends SVGGraphicsElement>(
|
||||
? getConfig().fontSize
|
||||
: window.getComputedStyle(document.body).fontSize;
|
||||
const enlargingFactor = 5;
|
||||
const parsedBodyFontSize =
|
||||
typeof bodyFontSize === 'number'
|
||||
? bodyFontSize
|
||||
: parseInt(bodyFontSize ?? '', 10);
|
||||
const [parsedBodyFontSize = defaultConfig.fontSize] = parseFontSize(bodyFontSize);
|
||||
const width = parsedBodyFontSize * enlargingFactor + 'px';
|
||||
img.style.minWidth = width;
|
||||
img.style.maxWidth = width;
|
||||
|
Reference in New Issue
Block a user