Skip to content

Commit

Permalink
Open preview links on the browser, not on the preview
Browse files Browse the repository at this point in the history
related to #73
  • Loading branch information
meriadec committed Apr 21, 2017
1 parent e165a31 commit cc3fa55
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/components/FilesList/FilePreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { Component } from 'react'
import cx from 'classnames'
import { Motion, spring } from 'react-motion'
import { connect } from 'react-redux'
import { shell } from 'electron'

import Button from 'components/Button'

Expand Down Expand Up @@ -41,6 +42,16 @@ class FilePreview extends Component {
const doc = this._iframe.contentDocument
const documentElement = doc.documentElement
documentElement.innerHTML = content
const links = [...documentElement.querySelectorAll('a')]
links.forEach(link => {
link.addEventListener('click', e => {
e.preventDefault()
const href = link.getAttribute('href')
if (href) {
shell.openItem(href)
}
})
})
})
}

Expand Down

0 comments on commit cc3fa55

Please sign in to comment.