mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-07 17:46:44 +02:00
#3308 Allowing br tags in tooltips
This commit is contained in:
@@ -15,6 +15,8 @@
|
|||||||
/* font-size: 18px !important; */
|
/* font-size: 18px !important; */
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
margin-left: 20px;
|
||||||
}
|
}
|
||||||
h1 { color: grey;}
|
h1 { color: grey;}
|
||||||
.mermaid2,.mermaid3 {
|
.mermaid2,.mermaid3 {
|
||||||
@@ -31,26 +33,30 @@
|
|||||||
|
|
||||||
|
|
||||||
<div class="mermaid2" style="width: 50%;">
|
<div class="mermaid2" style="width: 50%;">
|
||||||
journey
|
flowchart LR
|
||||||
title My working day
|
classDef aPID stroke:#4e4403,fill:#fdde29,color:#4e4403,rx:5px,ry:5px;
|
||||||
section Go to work
|
classDef crm stroke:#333333,fill:#DCDCDC,color:#333333,rx:5px,ry:5px;
|
||||||
Make tea: 5: Me
|
classDef type stroke:#502604,fill:#FAB565,color:#502604,rx:20px,ry:20px;;
|
||||||
Go upstairs: 3: Me
|
|
||||||
Do work: 1: Me, Cat
|
|
||||||
section Go home
|
|
||||||
Go downstairs: 5: Me
|
|
||||||
Sit down: 5: Mee
|
|
||||||
</div>
|
|
||||||
<div class="mermaid2" style="width: 50%;">
|
|
||||||
pie
|
|
||||||
accTitle: My Pie Chart Accessibility Title
|
|
||||||
accDescr: My Pie Chart Accessibility Description
|
|
||||||
|
|
||||||
title Key elements in Product X
|
O0("Joe")
|
||||||
"Calcium" : 42.96
|
class O0 aPID;
|
||||||
"Potassium" : 50.05
|
|
||||||
"Magnesium" : 10.01
|
O1("Person")
|
||||||
"Iron" : 5
|
class O1 crm;
|
||||||
|
O0 -- has type -->O1["Person"]
|
||||||
|
|
||||||
|
O2("aat:300411314")
|
||||||
|
class O2 type;
|
||||||
|
click O2 function "Sorry the newline html tags are not being processed correctly<br/> So all of this appears on the <br/> same line."
|
||||||
|
O0 -- has type -->O2["Bug"]
|
||||||
|
click O0 function "Lots of great info about Joe<br>Lots of great info about Joe<br>burt<br>fred";
|
||||||
|
</div>
|
||||||
|
<div class="mermaid" style="width: 50%;">
|
||||||
|
classDiagram-v2
|
||||||
|
class Shape
|
||||||
|
link Shape "https://www.github.com" "This is a<br/>tooltip<br>for a link"
|
||||||
|
class Shape2
|
||||||
|
click Shape2 href "https://www.github.com" "This is a tooltip for a link"
|
||||||
</div>
|
</div>
|
||||||
<div class="mermaid2" style="width: 50%;">
|
<div class="mermaid2" style="width: 50%;">
|
||||||
gitGraph
|
gitGraph
|
||||||
@@ -217,7 +223,7 @@ class Class10 {
|
|||||||
size()
|
size()
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<div class="mermaid" style="width: 100%;">
|
<div class="mermaid2" style="width: 100%;">
|
||||||
%%{init: {'config': {'wrap': true }}}%%
|
%%{init: {'config': {'wrap': true }}}%%
|
||||||
sequenceDiagram
|
sequenceDiagram
|
||||||
participant A as Extremely utterly long line of longness which had previously overflown the actor box as it is much longer than what it should be
|
participant A as Extremely utterly long line of longness which had previously overflown the actor box as it is much longer than what it should be
|
||||||
@@ -297,47 +303,15 @@ flowchart TD
|
|||||||
// console.error('Mermaid error: ', err);
|
// console.error('Mermaid error: ', err);
|
||||||
};
|
};
|
||||||
mermaid.initialize({
|
mermaid.initialize({
|
||||||
// theme: 'dark',
|
maxTextSize: 900000,
|
||||||
// theme: 'forest',
|
startOnLoad: true,
|
||||||
// arrowMarkerAbsolute: true,
|
securityLevel: 'loose',
|
||||||
// themeCSS: '.edgePath .path {stroke: red;} .arrowheadPath {fill: red;}',
|
|
||||||
flowchart: {
|
|
||||||
nodeSpacing: 10,
|
|
||||||
curve: 'cardinal',
|
|
||||||
htmlLabels: true,
|
|
||||||
useMaxWidth: false,
|
|
||||||
// defaultRenderer: 'dagre-d3',
|
|
||||||
},
|
|
||||||
class: {
|
|
||||||
// defaultRenderer: 'dagre-d3',
|
|
||||||
htmlLabels: true,
|
|
||||||
},
|
|
||||||
sequence: {
|
|
||||||
// mirrorActors: false,'
|
|
||||||
wrap: false,
|
|
||||||
},
|
|
||||||
// gantt: { axisFormat: '%m/%d/%Y' },
|
|
||||||
// sequence: {
|
|
||||||
// actorFontFamily: 'courier',
|
|
||||||
// actorMargin: 50,
|
|
||||||
// showSequenceNumbers: false,
|
|
||||||
// // hideUnusedParticipants: true,
|
|
||||||
// // forceMenus: true,
|
|
||||||
// },
|
|
||||||
// // sequenceDiagram: { actorMargin: 300, forceMenus: false }, // deprecated
|
|
||||||
// fontFamily: '"times", sans-serif',
|
|
||||||
// fontFamily: 'courier',
|
|
||||||
state: {
|
|
||||||
nodeSpacing: 50,
|
|
||||||
rankSpacing: 50,
|
|
||||||
defaultRenderer: 'dagre-d3',
|
|
||||||
},
|
|
||||||
logLevel: 0,
|
logLevel: 0,
|
||||||
fontSize: 18,
|
flowchart: {
|
||||||
curve: 'cardinal',
|
curve: 'basis',
|
||||||
// securityLevel: 'sandbox',
|
useMaxWidth: false,
|
||||||
// themeVariables: {relationLabelColor: 'red'}
|
htmlLabels: true,
|
||||||
wrap: true,
|
},
|
||||||
});
|
});
|
||||||
function callback() {
|
function callback() {
|
||||||
alert('It worked');
|
alert('It worked');
|
||||||
|
@@ -206,7 +206,9 @@ const setTooltip = function (ids, tooltip) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
export const getTooltip = function (id) {
|
||||||
|
return classes[id].tooltip;
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* Called by parser when a link is found. Adds the URL to the vertex data.
|
* Called by parser when a link is found. Adds the URL to the vertex data.
|
||||||
*
|
*
|
||||||
@@ -337,6 +339,7 @@ const setupToolTips = function (element) {
|
|||||||
.text(el.attr('title'))
|
.text(el.attr('title'))
|
||||||
.style('left', window.scrollX + rect.left + (rect.right - rect.left) / 2 + 'px')
|
.style('left', window.scrollX + rect.left + (rect.right - rect.left) / 2 + 'px')
|
||||||
.style('top', window.scrollY + rect.top - 14 + document.body.scrollTop + 'px');
|
.style('top', window.scrollY + rect.top - 14 + document.body.scrollTop + 'px');
|
||||||
|
tooltipElem.html(tooltipElem.html().replace(/<br\/>/g, '<br/>'));
|
||||||
el.classed('hover', true);
|
el.classed('hover', true);
|
||||||
})
|
})
|
||||||
.on('mouseout', function () {
|
.on('mouseout', function () {
|
||||||
@@ -378,6 +381,7 @@ export default {
|
|||||||
setClickEvent,
|
setClickEvent,
|
||||||
setCssClass,
|
setCssClass,
|
||||||
setLink,
|
setLink,
|
||||||
|
getTooltip,
|
||||||
setTooltip,
|
setTooltip,
|
||||||
lookUpDomId,
|
lookUpDomId,
|
||||||
};
|
};
|
||||||
|
@@ -29,8 +29,10 @@ let conf = {
|
|||||||
* >} classes
|
* >} classes
|
||||||
* Object containing the vertices.
|
* Object containing the vertices.
|
||||||
* @param {SVGGElement} g The graph that is to be drawn.
|
* @param {SVGGElement} g The graph that is to be drawn.
|
||||||
|
* @param _id
|
||||||
|
* @param diagObj
|
||||||
*/
|
*/
|
||||||
export const addClasses = function (classes, g) {
|
export const addClasses = function (classes, g, _id, diagObj) {
|
||||||
// const svg = select(`[id="${svgId}"]`);
|
// const svg = select(`[id="${svgId}"]`);
|
||||||
const keys = Object.keys(classes);
|
const keys = Object.keys(classes);
|
||||||
log.info('keys:', keys);
|
log.info('keys:', keys);
|
||||||
@@ -108,6 +110,7 @@ export const addClasses = function (classes, g) {
|
|||||||
style: styles.style,
|
style: styles.style,
|
||||||
id: vertex.id,
|
id: vertex.id,
|
||||||
domId: vertex.domId,
|
domId: vertex.domId,
|
||||||
|
tooltip: diagObj.db.getTooltip(vertex.id) || '',
|
||||||
haveCallback: vertex.haveCallback,
|
haveCallback: vertex.haveCallback,
|
||||||
link: vertex.link,
|
link: vertex.link,
|
||||||
width: vertex.type === 'group' ? 500 : undefined,
|
width: vertex.type === 'group' ? 500 : undefined,
|
||||||
@@ -319,7 +322,7 @@ export const draw = function (text, id, _version, diagObj) {
|
|||||||
const relations = diagObj.db.getRelations();
|
const relations = diagObj.db.getRelations();
|
||||||
|
|
||||||
log.info(relations);
|
log.info(relations);
|
||||||
addClasses(classes, g, id);
|
addClasses(classes, g, id, diagObj);
|
||||||
addRelations(relations, g);
|
addRelations(relations, g);
|
||||||
|
|
||||||
// Add custom shapes
|
// Add custom shapes
|
||||||
|
@@ -409,6 +409,7 @@ const setupToolTips = function (element) {
|
|||||||
.text(el.attr('title'))
|
.text(el.attr('title'))
|
||||||
.style('left', window.scrollX + rect.left + (rect.right - rect.left) / 2 + 'px')
|
.style('left', window.scrollX + rect.left + (rect.right - rect.left) / 2 + 'px')
|
||||||
.style('top', window.scrollY + rect.top - 14 + document.body.scrollTop + 'px');
|
.style('top', window.scrollY + rect.top - 14 + document.body.scrollTop + 'px');
|
||||||
|
tooltipElem.html(tooltipElem.html().replace(/<br\/>/g, '<br/>'));
|
||||||
el.classed('hover', true);
|
el.classed('hover', true);
|
||||||
})
|
})
|
||||||
.on('mouseout', function () {
|
.on('mouseout', function () {
|
||||||
|
Reference in New Issue
Block a user