Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text clipping #6121

Closed
liu-huitao opened this issue Dec 10, 2024 · 0 comments
Closed

Text clipping #6121

liu-huitao opened this issue Dec 10, 2024 · 0 comments
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect

Comments

@liu-huitao
Copy link

Description

The SVG graphic obtained by executing the following method has text clipping issues:
const { svg, bindFunctions } = await mermaid.render(id, code);
As shown below:
image

Steps to reproduce

import elkLayouts from "@mermaid-js/layout-elk";
import zenuml from "@mermaid-js/mermaid-zenuml";
import mermaid from "mermaid";
mermaid.registerLayoutLoaders(elkLayouts);

const initMermaid = mermaid.registerExternalDiagrams([zenuml]);

const compileMermaid = async (code: string) => {
	const compiledContainer = document.querySelector(`.compiled-container`) as HTMLDivElement;
	await initMermaid;
	// Initialize mermaid with the global configuration (optional)
	mermaid.initialize({
		// securityLevel: "loose",
		startOnLoad: false, // Automatically render on page load
		theme: "default" // Example theme
		// logLevel: "warn"
		// htmlLabels: false
	});
	// Render the diagram
	try {
		const id = _uniqueId("mermaid-");
		await mermaid.parse(code);
		const { svg, bindFunctions } = await mermaid.render(id, code);
		if (svg.length > 0) {
			compiledContainer.innerHTML = `
			<div class="mermaid-view-wrapper" id="${id}">${svg as any}</div>
			`;

			const graphDiv = document.querySelector<SVGSVGElement>(`#${id}`);
			if (!graphDiv) {
				throw new Error(`${id} not found`);
			}

			graphDiv.setAttribute("height", "100%");
			graphDiv.style.maxWidth = "100%";
			if (bindFunctions) {
				bindFunctions(graphDiv);
			}
		}
	} catch (error) {
		throw error;
	}
};

Screenshots

No response

Code Sample

No response

Setup

  • Mermaid version:
  • Browser and Version: [Chrome, Edge, Firefox]

Suggested Solutions

No response

Additional Context

No response

@liu-huitao liu-huitao added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

No branches or pull requests

1 participant