You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-30 23:44:55 +02:00
Electron: Handle internal anchors
This commit is contained in:
@ -595,6 +595,8 @@ class NoteTextComponent extends React.Component {
|
||||
} else {
|
||||
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 {
|
||||
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) {
|
||||
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')) {
|
||||
event.preventDefault();
|
||||
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;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user