Skip to content
This repository has been archived by the owner on Jan 14, 2022. It is now read-only.

Commit

Permalink
fixed open link not open in default browser
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroX-DG committed Feb 14, 2019
1 parent 09bac0f commit 4864b8b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions browser/render/components/markdown-preview/markdown-preview.jsx
@@ -1,14 +1,27 @@
import React from 'react'
import marked from 'marked'
import _ from 'lodash'
import CM from 'lib/config-manager'
import './markdown-preview.sass'
import { shell } from 'electron'

const baseMarkdownCSS = require('!!css-loader!./github-markdown.css') // eslint-disable-line

class MarkdownPreview extends React.Component {
componentDidMount () {
const previewDoc = this.refs.preview.contentWindow.document
previewDoc.write(this.buildHTML())
this.initActions(previewDoc)
}

initActions (previewDoc) {
const links = previewDoc.getElementsByTagName('a')
_.forEach(links, link => {
link.onclick = e => {
e.preventDefault()
shell.openExternal(link.href)
}
})
}

getMarkdownCSSTheme () {
Expand Down

1 comment on commit 4864b8b

@bantya
Copy link
Contributor

@bantya bantya commented on 4864b8b Feb 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.