From 93f15a507b9e34ab7faec2a7109ef7959a2bf807 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Thu, 10 Dec 2020 08:50:16 +0100 Subject: [PATCH] Handle old and new syntax --- cypress/platform/class.html | 2 +- cypress/platform/click_security_loose.html | 8 +- cypress/platform/interaction.html | 8 +- docs/classDiagram.md | 24 +++-- src/diagrams/class/classDb.js | 10 +- src/diagrams/class/classDiagram.spec.js | 101 ++++++++++++++++++- src/diagrams/class/parser/classDiagram.jison | 43 +++++--- src/diagrams/class/svgDraw.js | 2 +- 8 files changed, 160 insertions(+), 38 deletions(-) diff --git a/cypress/platform/class.html b/cypress/platform/class.html index 663edb610..a766639bd 100644 --- a/cypress/platform/class.html +++ b/cypress/platform/class.html @@ -69,7 +69,7 @@ int id test() } - click Class01 call callback() "A Tooltip" + callback Class01 "callback" "A Tooltip"
diff --git a/cypress/platform/click_security_loose.html b/cypress/platform/click_security_loose.html index 896962687..79c0ac2f2 100644 --- a/cypress/platform/click_security_loose.html +++ b/cypress/platform/click_security_loose.html @@ -41,16 +41,16 @@
classDiagram class ShapeLink - click ShapeLink href "http://localhost:9000/webpackUsage.html" "This is a tooltip for a link" + link ShapeLink "http://localhost:9000/webpackUsage.html" "This is a tooltip for a link" class ShapeCallback - click ShapeCallback call clickByClass() "This is a tooltip for a callback" + callback ShapeCallback "clickByClass" "This is a tooltip for a callback"
classDiagram-v2 class ShapeLink2 - click ShapeLink2 href "http://localhost:9000/webpackUsage.html" "This is a tooltip for a link" + link ShapeLink2 "http://localhost:9000/webpackUsage.html" "This is a tooltip for a link" class ShapeCallback2 - click ShapeCallback2 call clickByClass() "This is a tooltip for a callback" + callback ShapeCallback2 "clickByClass" "This is a tooltip for a callback"
diff --git a/cypress/platform/interaction.html b/cypress/platform/interaction.html index a2c76dfc2..76150c93a 100644 --- a/cypress/platform/interaction.html +++ b/cypress/platform/interaction.html @@ -30,19 +30,19 @@ classDiagram class Test class ShapeLink - click ShapeLink href "http://localhost:9000/webpackUsage.html" "This is a tooltip for a link" + link ShapeLink "http://localhost:9000/webpackUsage.html" "This is a tooltip for a link" class ShapeCallback - click ShapeCallback call clickByClass() "This is a tooltip for a callback" + callback ShapeCallback "clickByClass" "This is a tooltip for a callback"
classDiagram-v2 class ShapeCallback - click ShapeCallback call clickByClass() "This is a tooltip for a callback" + callback ShapeCallback "clickByClass" "This is a tooltip for a callback"
classDiagram-v2 class ShapeLink - click ShapeLink href "http://localhost:9000/webpackUsage.html" "This is a tooltip for a link" + link ShapeLink "http://localhost:9000/webpackUsage.html" "This is a tooltip for a link"
diff --git a/docs/classDiagram.md b/docs/classDiagram.md index 6c930437a..635bd08d9 100644 --- a/docs/classDiagram.md +++ b/docs/classDiagram.md @@ -450,11 +450,13 @@ It is possible to bind a click event to a node, the click can lead to either a j You would define these actions on a separate line after all classes have been declared. ``` +action className "reference" "tooltip" click className call callback() "tooltip" click className href "url" "tooltip" ``` - +- _action_ is either `link` or `callback`, depending on which type of interaction you want to have called - _className_ is the id of the node that the action will be associated with +- _reference_ is either the url link, or the function name for callback. - (_optional_) tooltip is a string to be displayed when hovering over element (note: The styles of the tooltip are set by the class .mermaidTooltip.) - note: callback function will be called with the nodeId as parameter. @@ -465,7 +467,9 @@ _URL Link:_ ``` classDiagram class Shape -click Shape href "http://www.github.com" "This is a tooltip for a link" +link Shape "http://www.github.com" "This is a tooltip for a link" +class Shape2 +click Shape2 href "http://www.github.com" "This is a tooltip for a link" ``` _Callback:_ @@ -473,7 +477,9 @@ _Callback:_ ``` classDiagram class Shape -click Shape call callbackFunction() "This is a tooltip for a callback" +callback Shape "callbackFunction" "This is a tooltip for a callback" +class Shape2 +click Shape2 call callbackFunction() "This is a tooltip for a callback" ``` ``` @@ -488,8 +494,12 @@ click Shape call callbackFunction() "This is a tooltip for a callback" classDiagram class Class01 class Class02 - click Class01 call callbackFunction() "Callback tooltip" - click Class02 href "http://www.github.com" "This is a link" + callback Class01 "callbackFunction" "Callback tooltip" + link Class02 "http://www.github.com" "This is a link" + class Class03 + class Class04 + click Class03 call callbackFunction() "Callback tooltip" + click Class04 href "http://www.github.com" "This is a link" ``` > **Success** The tooltip functionality and the ability to link to urls are available from version 0.5.2. @@ -521,8 +531,8 @@ Beginners tip, a full example using interactive links in an html context: +run() } - click Duck call callback() "Tooltip" - click Zebra href "http://www.github.com" "This is a link" + callback Duck callback "Tooltip" + link Zebra "http://www.github.com" "This is a link"