mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
Added styling for mermaid tooltips
Adjustments of tooltip positioning for large documents Documentation of tooltips
This commit is contained in:
parent
b3fa6378bd
commit
8bc3bdd300
15
dist/mermaid.css
vendored
15
dist/mermaid.css
vendored
@ -254,7 +254,16 @@ text {
|
|||||||
font-family: 'trebuchet ms', verdana, arial;
|
font-family: 'trebuchet ms', verdana, arial;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
div.mermaidTooltip {
|
||||||
.mermaid {
|
position: absolute;
|
||||||
width: auto;
|
text-align: center;
|
||||||
|
max-width: 200px;
|
||||||
|
padding: 2px;
|
||||||
|
font-family: 'trebuchet ms', verdana, arial;
|
||||||
|
font-size: 12px;
|
||||||
|
background: #ffffde;
|
||||||
|
border: 1px solid #aaaa33;
|
||||||
|
border-radius: 2px;
|
||||||
|
pointer-events: none;
|
||||||
|
z-index: 100;
|
||||||
}
|
}
|
||||||
|
13
dist/mermaid.forest.css
vendored
13
dist/mermaid.forest.css
vendored
@ -256,3 +256,16 @@ text {
|
|||||||
font-family: 'trebuchet ms', verdana, arial;
|
font-family: 'trebuchet ms', verdana, arial;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
div.mermaidTooltip {
|
||||||
|
position: absolute;
|
||||||
|
text-align: center;
|
||||||
|
max-width: 200px;
|
||||||
|
padding: 2px;
|
||||||
|
font-family: 'trebuchet ms', verdana, arial;
|
||||||
|
font-size: 12px;
|
||||||
|
background: #cdffb2;
|
||||||
|
border: 1px solid #6eaa49;
|
||||||
|
border-radius: 2px;
|
||||||
|
pointer-events: none;
|
||||||
|
z-index: 100;
|
||||||
|
}
|
||||||
|
8
dist/mermaid.js
vendored
8
dist/mermaid.js
vendored
@ -30678,7 +30678,9 @@ module.exports={
|
|||||||
"mermaid": "./bin/mermaid.js"
|
"mermaid": "./bin/mermaid.js"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "./node_modules/.bin/gulp dist && ./node_modules/.bin/gulp test"
|
"watch": "watchify src/mermaid.js -o dist/mermaid.js",
|
||||||
|
"doc" : "rm -r build;rm -r dist/www;gulp vartree;cp dist/www/all.html ../mermaid-pages/index.html;cp dist/mermaid.js ../mermaid-pages/javascripts/lib;cp dist/mermaid.forest.css ../mermaid-pages/stylesheets",
|
||||||
|
"test" : "./node_modules/.bin/gulp dist && ./node_modules/.bin/gulp test"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -32728,7 +32730,7 @@ var setupToolTips = function(element){
|
|||||||
.style("opacity", .9);
|
.style("opacity", .9);
|
||||||
tooltipElem.html(el.attr('title'))
|
tooltipElem.html(el.attr('title'))
|
||||||
.style("left", (rect.left+(rect.right-rect.left)/2) + "px")
|
.style("left", (rect.left+(rect.right-rect.left)/2) + "px")
|
||||||
.style("top", (rect.top-28) + "px");
|
.style("top", (rect.top-14+document.body.scrollTop) + "px");
|
||||||
var el = d3.select(this);
|
var el = d3.select(this);
|
||||||
el.classed('hover',true);
|
el.classed('hover',true);
|
||||||
|
|
||||||
@ -37780,7 +37782,7 @@ exports.create = function(type, options) {
|
|||||||
* title: mermaidAPI
|
* title: mermaidAPI
|
||||||
* order: 5
|
* order: 5
|
||||||
* ---
|
* ---
|
||||||
* #mermaidAPI
|
* # mermaidAPI
|
||||||
* This is the api to be used when handling the integration with the web page instead of using the default integration
|
* This is the api to be used when handling the integration with the web page instead of using the default integration
|
||||||
* (mermaid.js).
|
* (mermaid.js).
|
||||||
*
|
*
|
||||||
|
2
dist/mermaid.min.js
vendored
2
dist/mermaid.min.js
vendored
File diff suppressed because one or more lines are too long
8
dist/mermaid.slim.js
vendored
8
dist/mermaid.slim.js
vendored
@ -21462,7 +21462,9 @@ module.exports={
|
|||||||
"mermaid": "./bin/mermaid.js"
|
"mermaid": "./bin/mermaid.js"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "./node_modules/.bin/gulp dist && ./node_modules/.bin/gulp test"
|
"watch": "watchify src/mermaid.js -o dist/mermaid.js",
|
||||||
|
"doc" : "rm -r build;rm -r dist/www;gulp vartree;cp dist/www/all.html ../mermaid-pages/index.html;cp dist/mermaid.js ../mermaid-pages/javascripts/lib;cp dist/mermaid.forest.css ../mermaid-pages/stylesheets",
|
||||||
|
"test" : "./node_modules/.bin/gulp dist && ./node_modules/.bin/gulp test"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -23512,7 +23514,7 @@ var setupToolTips = function(element){
|
|||||||
.style("opacity", .9);
|
.style("opacity", .9);
|
||||||
tooltipElem.html(el.attr('title'))
|
tooltipElem.html(el.attr('title'))
|
||||||
.style("left", (rect.left+(rect.right-rect.left)/2) + "px")
|
.style("left", (rect.left+(rect.right-rect.left)/2) + "px")
|
||||||
.style("top", (rect.top-28) + "px");
|
.style("top", (rect.top-14+document.body.scrollTop) + "px");
|
||||||
var el = d3.select(this);
|
var el = d3.select(this);
|
||||||
el.classed('hover',true);
|
el.classed('hover',true);
|
||||||
|
|
||||||
@ -28564,7 +28566,7 @@ exports.create = function(type, options) {
|
|||||||
* title: mermaidAPI
|
* title: mermaidAPI
|
||||||
* order: 5
|
* order: 5
|
||||||
* ---
|
* ---
|
||||||
* #mermaidAPI
|
* # mermaidAPI
|
||||||
* This is the api to be used when handling the integration with the web page instead of using the default integration
|
* This is the api to be used when handling the integration with the web page instead of using the default integration
|
||||||
* (mermaid.js).
|
* (mermaid.js).
|
||||||
*
|
*
|
||||||
|
2
dist/mermaid.slim.min.js
vendored
2
dist/mermaid.slim.min.js
vendored
File diff suppressed because one or more lines are too long
8
dist/mermaidAPI.js
vendored
8
dist/mermaidAPI.js
vendored
@ -30345,7 +30345,9 @@ module.exports={
|
|||||||
"mermaid": "./bin/mermaid.js"
|
"mermaid": "./bin/mermaid.js"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "./node_modules/.bin/gulp dist && ./node_modules/.bin/gulp test"
|
"watch": "watchify src/mermaid.js -o dist/mermaid.js",
|
||||||
|
"doc" : "rm -r build;rm -r dist/www;gulp vartree;cp dist/www/all.html ../mermaid-pages/index.html;cp dist/mermaid.js ../mermaid-pages/javascripts/lib;cp dist/mermaid.forest.css ../mermaid-pages/stylesheets",
|
||||||
|
"test" : "./node_modules/.bin/gulp dist && ./node_modules/.bin/gulp test"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -32395,7 +32397,7 @@ var setupToolTips = function(element){
|
|||||||
.style("opacity", .9);
|
.style("opacity", .9);
|
||||||
tooltipElem.html(el.attr('title'))
|
tooltipElem.html(el.attr('title'))
|
||||||
.style("left", (rect.left+(rect.right-rect.left)/2) + "px")
|
.style("left", (rect.left+(rect.right-rect.left)/2) + "px")
|
||||||
.style("top", (rect.top-28) + "px");
|
.style("top", (rect.top-14+document.body.scrollTop) + "px");
|
||||||
var el = d3.select(this);
|
var el = d3.select(this);
|
||||||
el.classed('hover',true);
|
el.classed('hover',true);
|
||||||
|
|
||||||
@ -37075,7 +37077,7 @@ exports.getNoteRect = function(){
|
|||||||
* title: mermaidAPI
|
* title: mermaidAPI
|
||||||
* order: 5
|
* order: 5
|
||||||
* ---
|
* ---
|
||||||
* #mermaidAPI
|
* # mermaidAPI
|
||||||
* This is the api to be used when handling the integration with the web page instead of using the default integration
|
* This is the api to be used when handling the integration with the web page instead of using the default integration
|
||||||
* (mermaid.js).
|
* (mermaid.js).
|
||||||
*
|
*
|
||||||
|
10
dist/mermaidAPI.slim.js
vendored
10
dist/mermaidAPI.slim.js
vendored
File diff suppressed because one or more lines are too long
4
dist/mermaidAPI.slim.min.js
vendored
4
dist/mermaidAPI.slim.min.js
vendored
File diff suppressed because one or more lines are too long
184
dist/www/javascripts/lib/mermaid.js
vendored
184
dist/www/javascripts/lib/mermaid.js
vendored
File diff suppressed because one or more lines are too long
@ -253,7 +253,7 @@ graph TB
|
|||||||
|
|
||||||
## Interaction
|
## Interaction
|
||||||
|
|
||||||
It is possible to bind a click event to a node:
|
It is possible to bind a click event to a node, the click can lead to either a javascript callback or to a link which will be opened in a new browser tab.
|
||||||
|
|
||||||
```
|
```
|
||||||
click nodeId callback
|
click nodeId callback
|
||||||
@ -262,6 +262,34 @@ click nodeId callback
|
|||||||
* nodeId is the id of the node
|
* nodeId is the id of the node
|
||||||
* callback is the name of a javascript function defined on the page displaying the graph, the function will be called with the nodeId as parameter.
|
* callback is the name of a javascript function defined on the page displaying the graph, the function will be called with the nodeId as parameter.
|
||||||
|
|
||||||
|
Examples of tooltip usage below:
|
||||||
|
|
||||||
|
```
|
||||||
|
<script>
|
||||||
|
var callback = function(){
|
||||||
|
alert('A callback was triggered');
|
||||||
|
}
|
||||||
|
<script>
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
graph LR;
|
||||||
|
A-->B;
|
||||||
|
click A callback "Tooltip for a callback"
|
||||||
|
click B "http://www.github.com" "This is a tooltip for a link"
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
The tooltip text is surrounded in double quotes. The styles of the tooltip are set by the class .mermaidTooltip.
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
graph LR;
|
||||||
|
A-->B;
|
||||||
|
click A callback "Tooltip"
|
||||||
|
click B "http://www.github.com" "This is a link"
|
||||||
|
```
|
||||||
|
<aside class="success">The tooltip functionality and the ability to link to urls are available from version 0.5.2.</aside>
|
||||||
|
|
||||||
## Styling and classes
|
## Styling and classes
|
||||||
|
|
||||||
### Styling links
|
### Styling links
|
||||||
|
@ -49,6 +49,9 @@
|
|||||||
$(function () {
|
$(function () {
|
||||||
setupLanguages(["shell", "javascript", "html", "css","mermaid"]);
|
setupLanguages(["shell", "javascript", "html", "css","mermaid"]);
|
||||||
});
|
});
|
||||||
|
var callback = function(){
|
||||||
|
alert('A callback was triggered');
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
@ -14,7 +14,9 @@
|
|||||||
"mermaid": "./bin/mermaid.js"
|
"mermaid": "./bin/mermaid.js"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "./node_modules/.bin/gulp dist && ./node_modules/.bin/gulp test"
|
"watch": "watchify src/mermaid.js -o dist/mermaid.js",
|
||||||
|
"doc" : "rm -r build;rm -r dist/www;gulp vartree;cp dist/www/all.html ../mermaid-pages/index.html;cp dist/mermaid.js ../mermaid-pages/javascripts/lib;cp dist/mermaid.forest.css ../mermaid-pages/stylesheets",
|
||||||
|
"test" : "./node_modules/.bin/gulp dist && ./node_modules/.bin/gulp test"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -257,7 +257,7 @@ var setupToolTips = function(element){
|
|||||||
.style("opacity", .9);
|
.style("opacity", .9);
|
||||||
tooltipElem.html(el.attr('title'))
|
tooltipElem.html(el.attr('title'))
|
||||||
.style("left", (rect.left+(rect.right-rect.left)/2) + "px")
|
.style("left", (rect.left+(rect.right-rect.left)/2) + "px")
|
||||||
.style("top", (rect.top-28) + "px");
|
.style("top", (rect.top-14+document.body.scrollTop) + "px");
|
||||||
var el = d3.select(this);
|
var el = d3.select(this);
|
||||||
el.classed('hover',true);
|
el.classed('hover',true);
|
||||||
|
|
||||||
|
@ -8,3 +8,17 @@ text {
|
|||||||
font-family: 'trebuchet ms', verdana, arial;
|
font-family: 'trebuchet ms', verdana, arial;
|
||||||
font-size:14px;
|
font-size:14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.mermaidTooltip {
|
||||||
|
position: absolute;
|
||||||
|
text-align: center;
|
||||||
|
max-width: 200px;
|
||||||
|
padding: 2px;
|
||||||
|
font-family: 'trebuchet ms', verdana, arial;
|
||||||
|
font-size: 12px;
|
||||||
|
background: @secondBkg;
|
||||||
|
border: 1px solid @border2;
|
||||||
|
border-radius: 2px;
|
||||||
|
pointer-events: none;
|
||||||
|
z-index:100;
|
||||||
|
}
|
@ -8,3 +8,17 @@ text {
|
|||||||
font-family: 'trebuchet ms', verdana, arial;
|
font-family: 'trebuchet ms', verdana, arial;
|
||||||
font-size:14px;
|
font-size:14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.mermaidTooltip {
|
||||||
|
position: absolute;
|
||||||
|
text-align: center;
|
||||||
|
max-width: 200px;
|
||||||
|
padding: 2px;
|
||||||
|
font-family: 'trebuchet ms', verdana, arial;
|
||||||
|
font-size: 12px;
|
||||||
|
background: @secondBkg;
|
||||||
|
border: 1px solid @border2;
|
||||||
|
border-radius: 2px;
|
||||||
|
pointer-events: none;
|
||||||
|
z-index:100;
|
||||||
|
}
|
@ -3,7 +3,7 @@
|
|||||||
* title: mermaidAPI
|
* title: mermaidAPI
|
||||||
* order: 5
|
* order: 5
|
||||||
* ---
|
* ---
|
||||||
* #mermaidAPI
|
* # mermaidAPI
|
||||||
* This is the api to be used when handling the integration with the web page instead of using the default integration
|
* This is the api to be used when handling the integration with the web page instead of using the default integration
|
||||||
* (mermaid.js).
|
* (mermaid.js).
|
||||||
*
|
*
|
||||||
|
@ -5,39 +5,14 @@
|
|||||||
|
|
||||||
<link rel="stylesheet" href="../../dist/mermaid.css"/>
|
<link rel="stylesheet" href="../../dist/mermaid.css"/>
|
||||||
<script src="../../dist/mermaid.js"></script>
|
<script src="../../dist/mermaid.js"></script>
|
||||||
<link rel="stylesheet" href="../../dist/mermaid.css"/>
|
|
||||||
<style>
|
<style>
|
||||||
body{
|
body{
|
||||||
background-color: #2d2d22;
|
background-color: #89896f;
|
||||||
}
|
|
||||||
div.mermaidTooltip {
|
|
||||||
position: absolute;
|
|
||||||
text-align: center;
|
|
||||||
width: 60px;
|
|
||||||
height: 28px;
|
|
||||||
padding: 2px;
|
|
||||||
font: 12px sans-serif;
|
|
||||||
background: lightsteelblue;
|
|
||||||
border: 1px solid black;
|
|
||||||
border-radius: 3px;
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
function itsTime(){
|
|
||||||
|
|
||||||
function getScreenCoords(x, y, ctm) {
|
|
||||||
var xn = ctm.e + x*ctm.a;
|
|
||||||
var yn = ctm.f + y*ctm.d;
|
|
||||||
return { x: xn, y: yn };
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
setTimeout(function(){
|
|
||||||
|
|
||||||
},250);
|
|
||||||
|
|
||||||
}
|
|
||||||
function callback(id){
|
function callback(id){
|
||||||
alert(id);
|
alert(id);
|
||||||
}
|
}
|
||||||
@ -46,7 +21,7 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body onload="itsTime()">
|
<body>
|
||||||
<h1>Links to callbacks</h1>
|
<h1>Links to callbacks</h1>
|
||||||
A has a tooltip
|
A has a tooltip
|
||||||
<div class="mermaid" id="i211">
|
<div class="mermaid" id="i211">
|
||||||
@ -55,7 +30,7 @@
|
|||||||
B-->C;
|
B-->C;
|
||||||
click A callback "Tooltip"
|
click A callback "Tooltip"
|
||||||
click B "http://www.github.com" "This is a link"
|
click B "http://www.github.com" "This is a link"
|
||||||
click C callback "Tooltip C1"
|
click C callback "Tooltip quite long tooltip. So long that several rows are required... Not just two rows..."
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h1>Links to urls</h1>
|
<h1>Links to urls</h1>
|
Loading…
x
Reference in New Issue
Block a user