fix ctrl+click opening the link twice/thrice, closes #1094

This commit is contained in:
zadam 2020-06-10 00:10:27 +02:00
parent 212b719ee9
commit 2d92b4931a
8 changed files with 18 additions and 19 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

8
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "trilium", "name": "trilium",
"version": "0.42.6", "version": "0.42.7",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -3345,9 +3345,9 @@
} }
}, },
"electron": { "electron": {
"version": "9.0.2", "version": "9.0.3",
"resolved": "https://registry.npmjs.org/electron/-/electron-9.0.2.tgz", "resolved": "https://registry.npmjs.org/electron/-/electron-9.0.3.tgz",
"integrity": "sha512-+a3KegLvQXVjC3b6yBWwZmtWp3tHf9ut27yORAWHO9JRFtKfNf88fi1UvTPJSW8R0sUH7ZEdzN6A95T22KGtlA==", "integrity": "sha512-rY59wy50z0oWp/q69zq0UIzvtcM5j2BJbLAwEoLfVNS3DLt9wDZqRqSIBvLEBl+xWbafCnRA9haEqi7ssM94GA==",
"dev": true, "dev": true,
"requires": { "requires": {
"@electron/get": "^1.0.1", "@electron/get": "^1.0.1",

View File

@ -78,7 +78,7 @@
"yazl": "^2.5.1" "yazl": "^2.5.1"
}, },
"devDependencies": { "devDependencies": {
"electron": "9.0.2", "electron": "9.0.3",
"electron-builder": "22.6.0", "electron-builder": "22.6.0",
"electron-packager": "14.2.1", "electron-packager": "14.2.1",
"electron-rebuild": "1.10.1", "electron-rebuild": "1.10.1",

View File

@ -49,11 +49,7 @@ function setupGlobs() {
let message = "Uncaught error: "; let message = "Uncaught error: ";
if (string.includes("Cannot read property 'defaultView' of undefined")) { if (string.includes("script error")) {
// ignore this specific error which is very common but we don't know where it comes from
// and it seems to be harmless
return true;
} else if (string.includes("script error")) {
message += 'No details available'; message += 'No details available';
} else { } else {
message += [ message += [
@ -61,8 +57,9 @@ function setupGlobs() {
'URL: ' + url, 'URL: ' + url,
'Line: ' + lineNo, 'Line: ' + lineNo,
'Column: ' + columnNo, 'Column: ' + columnNo,
'Error object: ' + JSON.stringify(error) 'Error object: ' + JSON.stringify(error),
].join(' - '); 'Stack: ' + error && error.stack
].join(', ');
} }
ws.logError(message); ws.logError(message);
@ -91,4 +88,4 @@ function setupGlobs() {
export default { export default {
setupGlobs setupGlobs
} }

View File

@ -137,7 +137,7 @@ function linkContextMenu(e) {
$(document).on('mousedown', "a[data-action='note']", goToLink); $(document).on('mousedown', "a[data-action='note']", goToLink);
$(document).on('mousedown', 'div.popover-content a, div.ui-tooltip-content a', goToLink); $(document).on('mousedown', 'div.popover-content a, div.ui-tooltip-content a', goToLink);
$(document).on('dblclick', '.note-detail-text a', goToLink); $(document).on('dblclick', '.note-detail-text a', goToLink);
$(document).on('mousedown', '.note-detail-text a', function (e) { $(document).on('mousedown', '.note-detail-text a:not(.reference-link)', function (e) {
const $link = $(e.target).closest("a"); const $link = $(e.target).closest("a");
const notePath = getNotePathFromLink($link); const notePath = getNotePathFromLink($link);
@ -161,6 +161,7 @@ $(document).on('mousedown', '.note-detail-text a', function (e) {
$(document).on('mousedown', '.note-detail-book a', goToLink); $(document).on('mousedown', '.note-detail-book a', goToLink);
$(document).on('mousedown', '.note-detail-render a', goToLink); $(document).on('mousedown', '.note-detail-render a', goToLink);
$(document).on('mousedown', '.note-detail-text a.reference-link', goToLink); $(document).on('mousedown', '.note-detail-text a.reference-link', goToLink);
$(document).on('mousedown', '.note-detail-readonly-text a.reference-link', goToLink);
$(document).on('mousedown', '.note-detail-readonly-text a', goToLink); $(document).on('mousedown', '.note-detail-readonly-text a', goToLink);
$(document).on('mousedown', 'a.ck-link-actions__preview', goToLink); $(document).on('mousedown', 'a.ck-link-actions__preview', goToLink);
$(document).on('click', 'a.ck-link-actions__preview', e => { $(document).on('click', 'a.ck-link-actions__preview', e => {

View File

@ -25,7 +25,8 @@ function logError(message) {
if (ws && ws.readyState === 1) { if (ws && ws.readyState === 1) {
ws.send(JSON.stringify({ ws.send(JSON.stringify({
type: 'log-error', type: 'log-error',
error: message error: message,
stack: new Error().stack
})); }));
} }
} }

View File

@ -36,7 +36,7 @@ function init(httpServer, sessionParser) {
const message = JSON.parse(messageJson); const message = JSON.parse(messageJson);
if (message.type === 'log-error') { if (message.type === 'log-error') {
log.error('JS Error: ' + message.error); log.info('JS Error: ' + message.error + '\r\nStack: ' + message.stack);
} }
else if (message.type === 'ping') { else if (message.type === 'ping') {
lastAcceptedSyncIds[ws.id] = message.lastSyncId; lastAcceptedSyncIds[ws.id] = message.lastSyncId;
@ -141,4 +141,4 @@ module.exports = {
syncPullInProgress, syncPullInProgress,
syncPullFinished, syncPullFinished,
sendPingToAllClients sendPingToAllClients
}; };