mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Electron: Handle internal anchors
This commit is contained in:
parent
c72f92e22f
commit
dfcf1193dc
@ -595,6 +595,8 @@ class NoteTextComponent extends React.Component {
|
|||||||
} else {
|
} else {
|
||||||
require('electron').shell.openExternal(msg);
|
require('electron').shell.openExternal(msg);
|
||||||
}
|
}
|
||||||
|
} else if (msg.indexOf('#') === 0) {
|
||||||
|
// This is an internal anchor, which is handled by the WebView so skip this case
|
||||||
} else {
|
} else {
|
||||||
bridge().showErrorMessageBox(_('Unsupported link or message: %s', msg));
|
bridge().showErrorMessageBox(_('Unsupported link or message: %s', msg));
|
||||||
}
|
}
|
||||||
|
@ -276,12 +276,24 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Prevent URLs added via <a> tags from being opened within the application itself
|
|
||||||
document.addEventListener('click', function(event) {
|
document.addEventListener('click', function(event) {
|
||||||
const t = event.target;
|
const t = event.target;
|
||||||
|
|
||||||
|
// Prevent URLs added via <a> tags from being opened within the application itself
|
||||||
if (t && t.nodeName === 'A' && !t.hasAttribute('data-from-md')) {
|
if (t && t.nodeName === 'A' && !t.hasAttribute('data-from-md')) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
ipcProxySendToHost(t.getAttribute('href'));
|
ipcProxySendToHost(t.getAttribute('href'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// IF this is an internal link, jump to the anchor directly
|
||||||
|
if (t && t.nodeName === 'A' && t.hasAttribute('data-from-md')) {
|
||||||
|
const href = t.getAttribute('href');
|
||||||
|
if (href.indexOf('#') === 0) {
|
||||||
|
event.preventDefault();
|
||||||
|
location.hash = href;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user