Skip to content

Commit

Permalink
open relative links on click in preview, fixes atom#85
Browse files Browse the repository at this point in the history
  • Loading branch information
tlnagy committed Oct 18, 2016
1 parent ca41924 commit fcae1a2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/markdown-preview-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ class MarkdownPreviewView extends ScrollView
@css('zoom', zoomLevel - .1)
'markdown-preview:reset-zoom': =>
@css('zoom', 1)
'click': (event)=>
event.stopPropagation()
@followLink(event)

changeHandler = =>
@renderMarkdown()
Expand Down Expand Up @@ -253,6 +256,15 @@ class MarkdownPreviewView extends ScrollView

true

followLink: (event)->
return false if @loading
if event.target.tagName == 'A' && event.target.protocol == 'file:'
activeFile = @getPath()
activeFileDir = path.dirname(activeFile)
clickedFile = event.target.getAttribute('href')
clickedPath = path.join(activeFileDir, clickedFile)
atom.workspace.open clickedPath, { split: 'left' }

saveAs: ->
return if @loading

Expand Down

0 comments on commit fcae1a2

Please sign in to comment.