You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-08-13 22:12:50 +02:00
All: Display icon next to resources and allow downloading them from Electron client
This commit is contained in:
@@ -292,7 +292,7 @@ class NoteTextComponent extends React.Component {
|
||||
|
||||
const menu = new Menu()
|
||||
|
||||
if (itemType === 'image') {
|
||||
if (itemType === "image" || itemType === "link") {
|
||||
const resource = await Resource.load(arg0.resourceId);
|
||||
const resourcePath = Resource.fullPath(resource);
|
||||
|
||||
|
@@ -181,7 +181,11 @@
|
||||
});
|
||||
|
||||
document.addEventListener('contextmenu', function(event) {
|
||||
const element = event.target;
|
||||
let element = event.target;
|
||||
|
||||
// To handle right clicks on resource icons
|
||||
if (element && !element.getAttribute('data-resource-id')) element = element.parentElement;
|
||||
|
||||
if (element && element.getAttribute('data-resource-id')) {
|
||||
ipcRenderer.sendToHost('contextMenu', {
|
||||
type: element.getAttribute('src') ? 'image' : 'link',
|
||||
|
@@ -134,13 +134,17 @@ class MdToHtml {
|
||||
// Ideally they should be opened in the user's browser.
|
||||
return '<span style="opacity: 0.5">(Resource not yet supported: '; //+ htmlentities(text) + ']';
|
||||
} else {
|
||||
let resourceIdAttr = "";
|
||||
let icon = "";
|
||||
if (isResourceUrl) {
|
||||
const resourceId = Resource.pathToId(href);
|
||||
href = "joplin://" + resourceId;
|
||||
resourceIdAttr = "data-resource-id='" + resourceId + "'";
|
||||
icon = '<span class="resource-icon"></span>';
|
||||
}
|
||||
|
||||
const js = options.postMessageSyntax + "(" + JSON.stringify(href) + "); return false;";
|
||||
let output = "<a title='" + htmlentities(title) + "' href='#' onclick='" + js + "'>";
|
||||
let output = "<a " + resourceIdAttr + " title='" + htmlentities(title) + "' href='#' onclick='" + js + "'>" + icon;
|
||||
return output;
|
||||
}
|
||||
}
|
||||
@@ -393,8 +397,7 @@ class MdToHtml {
|
||||
let loopCount = 0;
|
||||
while (renderedBody.indexOf("mJOPm") >= 0) {
|
||||
renderedBody = renderedBody.replace(/mJOPmCHECKBOXm([A-Z]+)m(\d+)m/, function(v, type, index) {
|
||||
const js =
|
||||
options.postMessageSyntax + "('checkboxclick:" + type + ":" + index + "'); this.classList.contains('tick') ? this.classList.remove('tick') : this.classList.add('tick'); return false;";
|
||||
const js = options.postMessageSyntax + "('checkboxclick:" + type + ":" + index + "'); this.classList.contains('tick') ? this.classList.remove('tick') : this.classList.add('tick'); return false;";
|
||||
return '<a href="#" onclick="' + js + '" class="checkbox ' + (type == "NOTICK" ? "" : "tick") + '"><span>' + "" + "</span></a>";
|
||||
});
|
||||
if (loopCount++ >= 9999) break;
|
||||
@@ -457,6 +460,18 @@ class MdToHtml {
|
||||
ul {
|
||||
padding-left: 1.3em;
|
||||
}
|
||||
.resource-icon {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
top: .5em;
|
||||
text-decoration: none;
|
||||
width: 1.2em;
|
||||
height: 1.5em;
|
||||
margin-right: 0.4em;
|
||||
background-color: ` + style.htmlColor + `;
|
||||
/* Awesome Font file */
|
||||
-webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 384 512'><path d='M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM332.1 128H256V51.9l76.1 76.1zM48 464V48h160v104c0 13.3 10.7 24 24 24h104v288H48z'/></svg>");
|
||||
}
|
||||
a.checkbox {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
|
@@ -73,7 +73,7 @@
|
||||
],
|
||||
"settings": {
|
||||
"js_prettier": {
|
||||
"auto_format_on_save": true,
|
||||
"auto_format_on_save": false,
|
||||
"auto_format_on_save_requires_prettier_config": true,
|
||||
"additional_cli_args": {
|
||||
"--config": "prettier.config.js",
|
||||
|
@@ -1,5 +1,5 @@
|
||||
module.exports = {
|
||||
printWidth: 200,
|
||||
printWidth: 50000, // Don't need to see base64 encode data over multiple lines
|
||||
useTabs: true,
|
||||
trailingComma: "es5",
|
||||
};
|
||||
};
|
||||
|
Reference in New Issue
Block a user