Open non-markdown files in default application #2396 (#2563)

This commit is contained in:
ekoster1 2021-12-22 15:21:18 -06:00 committed by GitHub
parent 53c6a39faf
commit 572ed9ee86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -419,14 +419,17 @@ ipcMain.on('mt::format-link-click', (e, { data, dirname }) => {
} }
let pathname = null let pathname = null
if (path.isAbsolute(href) && isMarkdownFile(href)) { if (path.isAbsolute(href)) {
pathname = href pathname = href
} else if (!path.isAbsolute(href) && isMarkdownFile(path.join(dirname, href))) { } else if (dirname && !path.isAbsolute(href)) {
pathname = path.join(dirname, href) pathname = path.join(dirname, href)
} }
if (pathname) {
if (pathname && isMarkdownFile(pathname)) {
const win = BrowserWindow.fromWebContents(e.sender) const win = BrowserWindow.fromWebContents(e.sender)
return openFileOrFolder(win, pathname) return openFileOrFolder(win, pathname)
} else if (pathname) {
return shell.openPath(pathname)
} }
}) })