Skip to content

Commit

Permalink
Electron: Fixes #346: Make sure links have an address when exporting …
Browse files Browse the repository at this point in the history
…to PDF
  • Loading branch information
laurent22 committed May 1, 2018
1 parent e4ec4ae commit 62e91c4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ReactNativeClient/lib/MdToHtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,24 @@ class MdToHtml {
if (isResourceUrl && !this.supportsResourceLinks_) {
// In mobile, links to local resources, such as PDF, etc. currently aren't supported.
// Ideally they should be opened in the user's browser.
return '<span style="opacity: 0.5">(Resource not yet supported: '; //+ htmlentities(text) + ']';
return '<span style="opacity: 0.5">(Resource not yet supported: ';
} else {
let resourceIdAttr = "";
let icon = "";
let hrefAttr = '#';
if (isResourceUrl) {
const resourceId = Resource.pathToId(href);
href = "joplin://" + resourceId;
resourceIdAttr = "data-resource-id='" + resourceId + "'";
icon = '<span class="resource-icon"></span>';
} else {
// If the link is a plain URL (as opposed to a resource link), set the href to the actual
// link. This allows the link to be exported too when exporting to PDF.
hrefAttr = href;
}

const js = options.postMessageSyntax + "(" + JSON.stringify(href) + "); return false;";
let output = "<a " + resourceIdAttr + " title='" + htmlentities(title) + "' href='#' onclick='" + js + "'>" + icon;
let output = "<a " + resourceIdAttr + " title='" + htmlentities(title) + "' href='" + hrefAttr + "' onclick='" + js + "'>" + icon;
return output;
}
}
Expand Down

0 comments on commit 62e91c4

Please sign in to comment.