diff --git a/simple-mind-map/src/constants/defaultOptions.js b/simple-mind-map/src/constants/defaultOptions.js index 67eab51d..594b751f 100644 --- a/simple-mind-map/src/constants/defaultOptions.js +++ b/simple-mind-map/src/constants/defaultOptions.js @@ -223,6 +223,9 @@ export const defaultOpt = { createNodePostfixContent: null, // 禁止粘贴用户剪贴板中的数据,禁止将复制的数据写入用户的剪贴板中 disabledClipboard: false, + // 自定义超链接的跳转 + // 如果不传,默认会以新窗口的方式打开超链接,可以传递一个函数,函数接收两个参数:link(超链接的url)、node(所属节点实例),只要传递了函数,就会阻止默认的跳转 + customHyperlinkJump: null, // 【Select插件】 // 多选节点时鼠标移动到边缘时的画布移动偏移量 diff --git a/simple-mind-map/src/core/render/node/nodeCreateContents.js b/simple-mind-map/src/core/render/node/nodeCreateContents.js index ae6138e0..343e5181 100644 --- a/simple-mind-map/src/core/render/node/nodeCreateContents.js +++ b/simple-mind-map/src/core/render/node/nodeCreateContents.js @@ -254,12 +254,16 @@ function createHyperlinkNode() { if (!hyperlink) { return } + const { customHyperlinkJump } = this.mindMap.opt let iconSize = this.mindMap.themeConfig.iconSize let node = new SVG().size(iconSize, iconSize) // 超链接节点 let a = new A().to(hyperlink).target('_blank') a.node.addEventListener('click', e => { - e.stopPropagation() + if (typeof customHyperlinkJump === 'function') { + e.preventDefault() + customHyperlinkJump(hyperlink, this) + } }) if (hyperlinkTitle) { node.add(SVG(`${hyperlinkTitle}`))