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