mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-15 05:19:58 +02:00
Render nodes as real links
This commit is contained in:
@@ -181,14 +181,7 @@ const setLink = function (id, linkStr) {
|
||||
return
|
||||
}
|
||||
if (typeof vertices[id] !== 'undefined') {
|
||||
funs.push(function (element) {
|
||||
const elem = d3.select(element).select(`[id="${id}"]`)
|
||||
if (elem !== null) {
|
||||
elem.on('click', function () {
|
||||
window.open(linkStr, 'newTab')
|
||||
})
|
||||
}
|
||||
})
|
||||
vertices[id].link = linkStr
|
||||
}
|
||||
}
|
||||
export const getTooltip = function (id) {
|
||||
|
@@ -70,6 +70,9 @@ export const addVertices = function (vert, g) {
|
||||
verticeText = verticeText.replace(/fa:fa[\w-]+/g, function (s) {
|
||||
return '<i class="fa ' + s.substring(3) + '"></i>'
|
||||
})
|
||||
if (vertice.link) {
|
||||
verticeText = '<a href="' + vertice.link + '" rel="noopener">' + verticeText + '</a>'
|
||||
}
|
||||
} else {
|
||||
const svgLabel = document.createElementNS('http://www.w3.org/2000/svg', 'text')
|
||||
|
||||
@@ -85,8 +88,15 @@ export const addVertices = function (vert, g) {
|
||||
}
|
||||
|
||||
labelTypeStr = 'svg'
|
||||
if (vertice.link) {
|
||||
const link = document.createElementNS('http://www.w3.org/2000/svg', 'a')
|
||||
link.setAttributeNS('http://www.w3.org/2000/svg', 'href', vertice.link)
|
||||
link.setAttributeNS('http://www.w3.org/2000/svg', 'rel', 'noopener')
|
||||
verticeText = link
|
||||
} else {
|
||||
verticeText = svgLabel
|
||||
}
|
||||
}
|
||||
|
||||
let radious = 0
|
||||
let _shape = ''
|
||||
|
Reference in New Issue
Block a user