Closed geedys closed 3 weeks ago
我项目中在electron环境中,预览md文档时,由于a元素没有target属性,默认会在electron窗口中打开。 如果target=“_blank”, 则可以由外部浏览器打开链接。
//electron: 以下调用需要页面中超链接的 target 属性为 _blank mainWindow.webContents.setWindowOpenHandler((details) => { shell.openExternal(details.url) return {action: 'deny'} })
目前的解决方案:
<MdEditor :sanitize="replaceLink"/>
const replaceLink = (html) => { return html.replace(/<a/g, '<a target="_blank"') }
参考这个:https://github.com/imzbf/md-editor-v3/issues/496#issuecomment-2076109854
A great idea
我项目中在electron环境中,预览md文档时,由于a元素没有target属性,默认会在electron窗口中打开。 如果target=“_blank”, 则可以由外部浏览器打开链接。
目前的解决方案: