mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-16 05:49:43 +02:00
Merge branch 'develop' into sidv/optimizeSize
* develop: chore(deps): update pnpm to v7.17.0 docs: Remove warning in readme chore(deps): update lycheeverse/lychee-action action to v1.5.4 chore: Add size shield in readme Fix example for Git diagrams Fix TS errors Add interface for DiagramDb and other minor changes Disallow leading whitespace before delimiter Add title support using YAML frontmatter
This commit is contained in:
@@ -914,6 +914,32 @@ export function getErrorMessage(error: unknown): string {
|
||||
return String(error);
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends <text> element with the given title, centered.
|
||||
*
|
||||
* @param parent - d3 svg object to append title to
|
||||
* @param cssClass - CSS class for the <text> element containing the title
|
||||
* @param titleTopMargin - Margin in pixels between title and rest of the graph
|
||||
* @param title - The title. If empty, returns immediately.
|
||||
*/
|
||||
export const insertTitle = (
|
||||
parent,
|
||||
cssClass: string,
|
||||
titleTopMargin: number,
|
||||
title?: string
|
||||
): void => {
|
||||
if (!title) {
|
||||
return;
|
||||
}
|
||||
const bounds = parent.node().getBBox();
|
||||
parent
|
||||
.append('text')
|
||||
.text(title)
|
||||
.attr('x', bounds.x + bounds.width / 2)
|
||||
.attr('y', -titleTopMargin)
|
||||
.attr('class', cssClass);
|
||||
};
|
||||
|
||||
export default {
|
||||
assignWithDepth,
|
||||
wrapLabel,
|
||||
@@ -936,4 +962,5 @@ export default {
|
||||
initIdGenerator: initIdGenerator,
|
||||
directiveSanitizer,
|
||||
sanitizeCss,
|
||||
insertTitle,
|
||||
};
|
||||
|
Reference in New Issue
Block a user