mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-07 09:36:41 +02:00
#1023 New line in transition labels, basic support
This commit is contained in:
@@ -108,6 +108,14 @@ const getLabelWidth = text => {
|
||||
return text ? text.length * conf.fontSizeFactor : 1;
|
||||
};
|
||||
|
||||
/* TODO: REMOVE DUPLICATION, SEE SHAPES */
|
||||
const getRows = s => {
|
||||
if (!s) return 1;
|
||||
let str = s.replace(/<br\/?>/gi, '#br#');
|
||||
str = str.replace(/\\n/g, '#br#');
|
||||
return str.split('#br#');
|
||||
};
|
||||
|
||||
const renderDoc = (doc, diagram, parentId) => {
|
||||
// // Layout graph, Create a new directed graph
|
||||
const graph = new graphlib.Graph({
|
||||
@@ -221,7 +229,7 @@ const renderDoc = (doc, diagram, parentId) => {
|
||||
graph.setEdge(relation.id1, relation.id2, {
|
||||
relation: relation,
|
||||
width: getLabelWidth(relation.title),
|
||||
height: conf.labelHeight,
|
||||
height: conf.labelHeight * getRows(relation.title).length,
|
||||
labelpos: 'c'
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user