Skip to content

Commit 62e91c4

Browse files
committed
Electron: Fixes #346: Make sure links have an address when exporting to PDF
1 parent e4ec4ae commit 62e91c4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

ReactNativeClient/lib/MdToHtml.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,19 +135,24 @@ class MdToHtml {
135135
if (isResourceUrl && !this.supportsResourceLinks_) {
136136
// In mobile, links to local resources, such as PDF, etc. currently aren't supported.
137137
// Ideally they should be opened in the user's browser.
138-
return '<span style="opacity: 0.5">(Resource not yet supported: '; //+ htmlentities(text) + ']';
138+
return '<span style="opacity: 0.5">(Resource not yet supported: ';
139139
} else {
140140
let resourceIdAttr = "";
141141
let icon = "";
142+
let hrefAttr = '#';
142143
if (isResourceUrl) {
143144
const resourceId = Resource.pathToId(href);
144145
href = "joplin://" + resourceId;
145146
resourceIdAttr = "data-resource-id='" + resourceId + "'";
146147
icon = '<span class="resource-icon"></span>';
148+
} else {
149+
// If the link is a plain URL (as opposed to a resource link), set the href to the actual
150+
// link. This allows the link to be exported too when exporting to PDF.
151+
hrefAttr = href;
147152
}
148153

149154
const js = options.postMessageSyntax + "(" + JSON.stringify(href) + "); return false;";
150-
let output = "<a " + resourceIdAttr + " title='" + htmlentities(title) + "' href='#' onclick='" + js + "'>" + icon;
155+
let output = "<a " + resourceIdAttr + " title='" + htmlentities(title) + "' href='" + hrefAttr + "' onclick='" + js + "'>" + icon;
151156
return output;
152157
}
153158
}

0 commit comments

Comments
 (0)