mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-26 10:49:38 +02:00
Fixed lint and used selectSvgElement
This commit is contained in:
@@ -26,7 +26,7 @@ import {
|
||||
} from './chartBuilder/Interfaces.js';
|
||||
import { getThemeVariables } from '../../themes/theme-default.js';
|
||||
|
||||
export type SVGGType = Selection<SVGGElement, unknown, HTMLElement, any>;
|
||||
export type SVGGType = Selection<SVGGElement, unknown, Element | null, unknown>;
|
||||
|
||||
const defaultThemeVariables = getThemeVariables();
|
||||
|
||||
|
@@ -10,6 +10,7 @@ import {
|
||||
TextVerticalPos,
|
||||
} from './chartBuilder/Interfaces.js';
|
||||
import XYChartDB from './xychartDb.js';
|
||||
import { selectSvgElement } from '../../rendering-util/selectSvgElement.js';
|
||||
|
||||
export const draw = (txt: string, id: string, _version: string, diagObj: Diagram) => {
|
||||
function getDominantBaseLine(horizontalPos: TextHorizontalPos) {
|
||||
@@ -23,20 +24,10 @@ export const draw = (txt: string, id: string, _version: string, diagObj: Diagram
|
||||
function getTextTransformation(data: TextElem) {
|
||||
return `translate(${data.x}, ${data.y}) rotate(${data.rotation || 0})`;
|
||||
}
|
||||
const conf = configApi.getConfig();
|
||||
|
||||
log.debug('Rendering xychart chart\n' + txt);
|
||||
|
||||
const securityLevel = conf.securityLevel;
|
||||
// Handle root and Document for when rendering in sandbox mode
|
||||
let sandboxElement;
|
||||
if (securityLevel === 'sandbox') {
|
||||
sandboxElement = select('#i' + id);
|
||||
}
|
||||
const root = sandboxElement ? sandboxElement : select('body');
|
||||
|
||||
const svg = root.select(`[id="${id}"]`);
|
||||
|
||||
const svg = selectSvgElement(id);
|
||||
const group = svg.append('g').attr('class', 'main');
|
||||
|
||||
const width = 700;
|
||||
|
@@ -76,14 +76,7 @@ function computeWidthOfText(parentNode: any, lineHeight: number, line: MarkdownL
|
||||
return textLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the width of rendered text
|
||||
* @param {object} parentNode
|
||||
* @param {number} lineHeight
|
||||
* @param {string} text
|
||||
* @returns {{width: number, height: number}}
|
||||
*/
|
||||
export function computeDimensionOfText(parentNode, lineHeight, text) {
|
||||
export function computeDimensionOfText(parentNode: any, lineHeight: number, text: string) {
|
||||
const testElement = parentNode.append('text');
|
||||
const testSpan = createTspan(testElement, 1, lineHeight);
|
||||
updateTextContentAndStyles(testSpan, [{ content: text, type: 'normal' }]);
|
||||
|
Reference in New Issue
Block a user