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

open relative links on click in preview, fixes #85 #442

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 is 'A' and event.target.protocol is '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