From c9071ff7246ce93e63a3d241a2f64bc5327f69a9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Mar 2020 23:07:17 +0000 Subject: [PATCH 1/4] Bump acorn from 5.7.3 to 5.7.4 Bumps [acorn](https://github.com/acornjs/acorn) from 5.7.3 to 5.7.4. - [Release notes](https://github.com/acornjs/acorn/releases) - [Commits](https://github.com/acornjs/acorn/compare/5.7.3...5.7.4) Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 6632f0b88..fc5a047b6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1681,9 +1681,9 @@ acorn-walk@^6.0.1: integrity sha512-7evsyfH1cLOCdAzZAd43Cic04yKydNx0cF+7tiA19p1XnLLPU4dpCQOqpjqwokFe//vS0QqfqqjCS2JkiIs0cA== acorn@^5.2.1, acorn@^5.5.3: - version "5.7.3" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.3.tgz#67aa231bf8812974b85235a96771eb6bd07ea279" - integrity sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw== + version "5.7.4" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.4.tgz#3e8d8a9947d0599a1796d10225d7432f4a4acf5e" + integrity sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg== acorn@^6.0.1, acorn@^6.2.1: version "6.4.0" From cbdb2e6e6fa3d7fc7b761560c70ed983e8430330 Mon Sep 17 00:00:00 2001 From: Raphael Medaer Date: Tue, 24 Mar 2020 22:14:19 +0100 Subject: [PATCH 2/4] Align left/center/right multiline messages --- docs/mermaidAPI.md | 8 ++++++ src/diagrams/sequence/sequenceRenderer.js | 34 ++++++++++++++++------- src/mermaidAPI.js | 9 ++++++ 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/docs/mermaidAPI.md b/docs/mermaidAPI.md index 7b7b68e06..ff25fd2f1 100644 --- a/docs/mermaidAPI.md +++ b/docs/mermaidAPI.md @@ -174,6 +174,14 @@ margin around notes. Space between messages. **Default value 35**. +### messageAlign + +Multiline message alignment. Possible values are: + +- left +- center **default** +- right + ### mirrorActors mirror actors under diagram. diff --git a/src/diagrams/sequence/sequenceRenderer.js b/src/diagrams/sequence/sequenceRenderer.js index b46f6873e..96f99d9c2 100644 --- a/src/diagrams/sequence/sequenceRenderer.js +++ b/src/diagrams/sequence/sequenceRenderer.js @@ -24,6 +24,8 @@ const conf = { noteMargin: 10, // Space between messages messageMargin: 35, + // Multiline message alignment + messageAlign: 'center', // mirror actors under diagram mirrorActors: false, // Depending on css styling this might need adjustment @@ -230,26 +232,38 @@ const drawMessage = function(elem, startx, stopx, verticalPos, msg, sequenceInde const g = elem.append('g'); const txtCenter = startx + (stopx - startx) / 2; - let textElem; + let textElems = []; let counterBreaklines = 0; let breaklineOffset = 17; const breaklines = msg.message.split(//gi); for (const breakline of breaklines) { - textElem = g - .append('text') // text label for the x axis - .attr('x', txtCenter) - .attr('y', verticalPos - 7 + counterBreaklines * breaklineOffset) - .style('text-anchor', 'middle') - .attr('class', 'messageText') - .text(breakline.trim()); + textElems.push( + g + .append('text') // text label for the x axis + .attr('x', txtCenter) + .attr('y', verticalPos - 7 + counterBreaklines * breaklineOffset) + .style('text-anchor', 'middle') + .attr('class', 'messageText') + .text(breakline.trim()) + ); counterBreaklines++; } const offsetLineCounter = counterBreaklines - 1; const totalOffset = offsetLineCounter * breaklineOffset; - bounds.bumpVerticalPos(totalOffset); + let textWidths = textElems.map(function(textElem) { + return (textElem._groups || textElem)[0][0].getBBox().width; + }); + let textWidth = Math.max(...textWidths); + for (const textElem of textElems) { + if (conf.messageAlign === 'left') { + textElem.attr('x', txtCenter - textWidth / 2).style('text-anchor', 'start'); + } else if (conf.messageAlign === 'right') { + textElem.attr('x', txtCenter + textWidth / 2).style('text-anchor', 'end'); + } + } - let textWidth = (textElem._groups || textElem)[0][0].getBBox().width; + bounds.bumpVerticalPos(totalOffset); let line; if (startx === stopx) { diff --git a/src/mermaidAPI.js b/src/mermaidAPI.js index 10ead65cb..4a90f8134 100644 --- a/src/mermaidAPI.js +++ b/src/mermaidAPI.js @@ -229,6 +229,14 @@ const config = { */ messageMargin: 35, + /** + * Multiline message alignment. Possible values are: + * * left + * * center **default** + * * right + */ + messageAlign: 'center', + /** * mirror actors under diagram. * **Default value true**. @@ -809,6 +817,7 @@ export default mermaidAPI; * boxTextMargin:5, * noteMargin:10, * messageMargin:35, + * messageAlign:'center', * mirrorActors:true, * bottomMarginAdj:1, * useMaxWidth:true, From e0d97d44aa2f15adf8e24093ae4900fb43a49fe6 Mon Sep 17 00:00:00 2001 From: Kathryn DiPippo Date: Sun, 29 Mar 2020 00:55:14 -0400 Subject: [PATCH 3/4] Docs workaround for failing callback() section --- docs/flowchart.md | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/docs/flowchart.md b/docs/flowchart.md index ee4f0e130..59083fece 100644 --- a/docs/flowchart.md +++ b/docs/flowchart.md @@ -425,10 +425,10 @@ Examples of tooltip usage below: ``` ``` ``` @@ -448,28 +448,30 @@ graph LR; ``` > **Success** The tooltip functionality and the ability to link to urls are available from version 0.5.2. +?> Due to limitations with how Docsify handles JavaScript callback functions, an alternate working demo for the above code can be viewed at [this jsfiddle](https://jsfiddle.net/s37cjoau/3/). + Beginners tip, a full example using interactive links in a html context: ```
graph LR; - A-->B; - click A callback "Tooltip" - click B "http://www.github.com" "This is a link" + A-->B; + click A callback "Tooltip" + click B "http://www.github.com" "This is a link"