From b365c186a15bad4d8b55ac7e6d4e58dbab128c5e Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 11 May 2020 19:38:14 +0200 Subject: [PATCH 1/4] fixed clicking on links in read only view --- .../a2c75661-f9e2-478f-a69f-6a9409e69997.xml | 692 ------------------ .../storage_v2/_src_/schema/main.uQUzAA.meta | 2 - src/public/app/services/link.js | 5 +- 3 files changed, 3 insertions(+), 696 deletions(-) delete mode 100644 .idea/dataSources/a2c75661-f9e2-478f-a69f-6a9409e69997.xml delete mode 100644 .idea/dataSources/a2c75661-f9e2-478f-a69f-6a9409e69997/storage_v2/_src_/schema/main.uQUzAA.meta diff --git a/.idea/dataSources/a2c75661-f9e2-478f-a69f-6a9409e69997.xml b/.idea/dataSources/a2c75661-f9e2-478f-a69f-6a9409e69997.xml deleted file mode 100644 index d76c47f86..000000000 --- a/.idea/dataSources/a2c75661-f9e2-478f-a69f-6a9409e69997.xml +++ /dev/null @@ -1,692 +0,0 @@ - - - - - 3.16.1 - - - 1 - - - - - -
-
-
-
-
-
-
-
-
-
- 1 -
- - 1 -
- - - 1 - TEXT|0s - 1 - - - 2 - TEXT|0s - 1 - - - 3 - TEXT|0s - 1 - - - 4 - INT|0s - 1 - 0 - - - 5 - TEXT|0s - 1 - "" - - - 1 - apiTokenId - - 1 - - - apiTokenId - 1 - sqlite_autoindex_api_tokens_1 - - - 1 - TEXT|0s - 1 - - - 2 - TEXT|0s - 1 - - - 3 - TEXT|0s - 1 - - - 4 - TEXT|0s - 1 - - - 5 - TEXT|0s - 1 - '' - - - 6 - INT|0s - 1 - 0 - - - 7 - TEXT|0s - 1 - - - 8 - TEXT|0s - 1 - - - 9 - INT|0s - 1 - - - 10 - TEXT|0s - NULL - - - 11 - TEXT|0s - 1 - "" - - - 12 - int|0s - 0 - - - 1 - attributeId - - 1 - - - noteId - - - - name -value - - - - value - - - - attributeId - 1 - sqlite_autoindex_attributes_1 - - - 1 - TEXT|0s - 1 - - - 2 - TEXT|0s - 1 - - - 3 - TEXT|0s - 1 - - - 4 - INTEGER|0s - 1 - - - 5 - TEXT|0s - - - 6 - INTEGER|0s - 1 - 0 - - - 7 - INTEGER|0s - 1 - 0 - - - 8 - TEXT|0s - NULL - - - 9 - TEXT|0s - 1 - - - 10 - TEXT|0s - 1 - - - 11 - TEXT|0s - 1 - "" - - - 1 - branchId - - 1 - - - noteId -parentNoteId - - - - parentNoteId - - - - branchId - 1 - sqlite_autoindex_branches_1 - - - 1 - TEXT|0s - 1 - - - 2 - TEXT|0s - NULL - - - 3 - TEXT|0s - 1 - "" - - - 4 - TEXT|0s - 1 - - - 1 - noteId - - 1 - - - noteId - 1 - sqlite_autoindex_note_contents_1 - - - 1 - TEXT|0s - 1 - - - 2 - TEXT|0s - - - 3 - TEXT|0s - 1 - '' - - - 4 - TEXT|0s - 1 - - - 1 - noteRevisionId - - 1 - - - noteRevisionId - 1 - sqlite_autoindex_note_revision_contents_1 - - - 1 - TEXT|0s - 1 - - - 2 - TEXT|0s - 1 - - - 3 - TEXT|0s - - - 4 - INT|0s - 1 - - - 5 - INT|0s - 1 - 0 - - - 6 - INT|0s - 1 - 0 - - - 7 - TEXT|0s - 1 - - - 8 - TEXT|0s - 1 - - - 9 - TEXT|0s - 1 - - - 10 - TEXT|0s - 1 - - - 11 - TEXT|0s - 1 - - - 12 - TEXT|0s - 1 - '' - - - 13 - TEXT|0s - 1 - '' - - - 14 - TEXT|0s - 1 - '' - - - 1 - noteRevisionId - - 1 - - - noteId - - - - utcDateLastEdited - - - - utcDateCreated - - - - dateLastEdited - - - - dateCreated - - - - noteRevisionId - 1 - sqlite_autoindex_note_revisions_1 - - - 1 - TEXT|0s - 1 - - - 2 - TEXT|0s - 1 - "note" - - - 3 - INT|0s - 1 - - - 4 - INT|0s - 1 - 0 - - - 5 - TEXT|0s - 1 - 'text' - - - 6 - TEXT|0s - 1 - 'text/html' - - - 7 - TEXT|0s - 1 - "" - - - 8 - INT|0s - 1 - 0 - - - 9 - TEXT|0s - NULL - - - 10 - INT|0s - 1 - 0 - - - 11 - TEXT|0s - 1 - - - 12 - TEXT|0s - 1 - - - 13 - TEXT|0s - 1 - - - 14 - TEXT|0s - 1 - - - 1 - noteId - - 1 - - - title - - - - type - - - - isDeleted - - - - dateCreated - - - - dateModified - - - - utcDateCreated - - - - utcDateModified - - - - noteId - 1 - sqlite_autoindex_notes_1 - - - 1 - TEXT|0s - 1 - - - 2 - TEXT|0s - - - 3 - INTEGER|0s - 1 - 0 - - - 4 - TEXT|0s - 1 - "" - - - 5 - TEXT|0s - 1 - - - 6 - TEXT|0s - 1 - - - 1 - name - - 1 - - - name - 1 - sqlite_autoindex_options_1 - - - 1 - TEXT|0s - 1 - - - 2 - TEXT|0s - 1 - - - 3 - TEXT|0s - 1 - "" - - - 4 - TEXT|0s - 1 - - - 5 - INT|0s - - - 1 - noteId - - 1 - - - noteId - 1 - sqlite_autoindex_recent_notes_1 - - - 1 - TEXT|0s - 1 - - - 2 - TEXT|0s - 1 - - - 1 - sourceId - - 1 - - - utcDateCreated - - - - sourceId - 1 - sqlite_autoindex_source_ids_1 - - - 1 - text|0s - - - 2 - text|0s - - - 3 - text|0s - - - 4 - integer|0s - - - 5 - text|0s - - - 1 - - - 2 - - - 1 - INTEGER|0s - 1 - 1 - - - 2 - TEXT|0s - 1 - - - 3 - TEXT|0s - 1 - - - 4 - TEXT|0s - 1 - - - 5 - INTEGER|0s - 1 - 0 - - - 6 - TEXT|0s - 1 - - - entityName -entityId - - 1 - - - utcSyncDate - - - - id - 1 - - - \ No newline at end of file diff --git a/.idea/dataSources/a2c75661-f9e2-478f-a69f-6a9409e69997/storage_v2/_src_/schema/main.uQUzAA.meta b/.idea/dataSources/a2c75661-f9e2-478f-a69f-6a9409e69997/storage_v2/_src_/schema/main.uQUzAA.meta deleted file mode 100644 index 8dab49c6b..000000000 --- a/.idea/dataSources/a2c75661-f9e2-478f-a69f-6a9409e69997/storage_v2/_src_/schema/main.uQUzAA.meta +++ /dev/null @@ -1,2 +0,0 @@ -#n:main -! [0, 0, null, null, -2147483648, -2147483648] diff --git a/src/public/app/services/link.js b/src/public/app/services/link.js index 9a32f3e6c..f35d2912a 100644 --- a/src/public/app/services/link.js +++ b/src/public/app/services/link.js @@ -155,7 +155,8 @@ $(document).on('mousedown', '.note-detail-text a', function (e) { $(document).on('mousedown', '.note-detail-book a', goToLink); $(document).on('mousedown', '.note-detail-render a', goToLink); -$(document).on('mousedown', '.note-detail-text.ck-read-only a,.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', goToLink); $(document).on('mousedown', 'a.ck-link-actions__preview', goToLink); $(document).on('click', 'a.ck-link-actions__preview', e => { e.preventDefault(); @@ -172,4 +173,4 @@ export default { getNotePathFromUrl, createNoteLink, goToLink -}; \ No newline at end of file +}; From 88e8eb7e9ca5c1ff16994cd8094a32a0db362e34 Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 11 May 2020 20:08:55 +0200 Subject: [PATCH 2/4] fixed context menu positioning when scaling is active --- src/public/app/desktop.js | 9 +++++--- src/public/app/services/app_context.js | 6 +++--- src/public/app/services/link.js | 30 +++++++++++++++----------- src/public/app/services/zoom.js | 20 +++++++++++------ 4 files changed, 40 insertions(+), 25 deletions(-) diff --git a/src/public/app/desktop.js b/src/public/app/desktop.js index 774cd3f2c..a40aef397 100644 --- a/src/public/app/desktop.js +++ b/src/public/app/desktop.js @@ -8,6 +8,7 @@ import contextMenu from "./services/context_menu.js"; import DesktopMainWindowLayout from "./layouts/desktop_main_window_layout.js"; import glob from "./services/glob.js"; import DesktopExtraWindowLayout from "./layouts/desktop_extra_window_layout.js"; +import zoomService from './services/zoom.js'; glob.setupGlobs(); @@ -133,9 +134,11 @@ if (utils.isElectron()) { return; } + const zoomLevel = zoomService.getCurrentZoom(); + contextMenu.show({ - x: params.x, - y: params.y, + x: params.x / zoomLevel, + y: params.y / zoomLevel, items, selectMenuItemHandler: ({command, spellingSuggestion}) => { if (command === 'replaceMisspelling') { @@ -144,4 +147,4 @@ if (utils.isElectron()) { } }); }); -} \ No newline at end of file +} diff --git a/src/public/app/services/app_context.js b/src/public/app/services/app_context.js index 9cdbfb955..238db11d3 100644 --- a/src/public/app/services/app_context.js +++ b/src/public/app/services/app_context.js @@ -4,7 +4,7 @@ import DialogCommandExecutor from "./dialog_command_executor.js"; import Entrypoints from "./entrypoints.js"; import options from "./options.js"; import utils from "./utils.js"; -import ZoomService from "./zoom.js"; +import zoomService from "./zoom.js"; import TabManager from "./tab_manager.js"; import treeService from "./tree.js"; import Component from "../widgets/component.js"; @@ -73,7 +73,7 @@ class AppContext extends Component { } if (utils.isElectron()) { - this.child(new ZoomService()); + this.child(zoomService); } this.triggerEvent('initialRenderComplete'); @@ -134,4 +134,4 @@ $(window).on('hashchange', function() { } }); -export default appContext; \ No newline at end of file +export default appContext; diff --git a/src/public/app/services/link.js b/src/public/app/services/link.js index f35d2912a..224e16dbe 100644 --- a/src/public/app/services/link.js +++ b/src/public/app/services/link.js @@ -81,24 +81,29 @@ function goToLink(e) { } else if (e.which === 1) { const activeTabContext = appContext.tabManager.getActiveTabContext(); - activeTabContext.setNote(notePath) + activeTabContext.setNote(notePath); } else { return false; } } else { - const address = $link.attr('href'); + if (e.which === 1) { + const address = $link.attr('href'); - if (address && address.startsWith('http')) { - window.open(address, '_blank'); + if (address && address.startsWith('http')) { + window.open(address, '_blank'); + } + } + else { + return false; } } return true; } -function newTabContextMenu(e) { +function linkContextMenu(e) { const $link = $(e.target).closest("a"); const notePath = getNotePathFromLink($link); @@ -113,7 +118,7 @@ function newTabContextMenu(e) { x: e.pageX, y: e.pageY, items: [ - {title: "Open note in new tab", command: "openNoteInNewTab", uiIcon: "arrow-up-right"}, + {title: "Open note in new tab", command: "openNoteInNewTab", uiIcon: "empty"}, {title: "Open note in new window", command: "openNoteInNewWindow", uiIcon: "window-open"} ], selectMenuItemHandler: ({command}) => { @@ -156,18 +161,19 @@ $(document).on('mousedown', '.note-detail-text a', function (e) { $(document).on('mousedown', '.note-detail-book 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-readonly-text a', goToLink); +$(document).on('mousedown', '.note-detail-readonly-text a', goToLink); $(document).on('mousedown', 'a.ck-link-actions__preview', goToLink); $(document).on('click', 'a.ck-link-actions__preview', e => { e.preventDefault(); e.stopPropagation(); }); -$(document).on('contextmenu', 'a.ck-link-actions__preview', newTabContextMenu); -$(document).on('contextmenu', '.note-detail-text a', newTabContextMenu); -$(document).on('contextmenu', "a[data-action='note']", newTabContextMenu); -$(document).on('contextmenu', ".note-detail-render a", newTabContextMenu); -$(document).on('contextmenu', ".note-paths-widget a", newTabContextMenu); +$(document).on('contextmenu', 'a.ck-link-actions__preview', linkContextMenu); +$(document).on('contextmenu', '.note-detail-text a', linkContextMenu); +$(document).on('contextmenu', '.note-detail-readonly-text a', linkContextMenu); +$(document).on('contextmenu', "a[data-action='note']", linkContextMenu); +$(document).on('contextmenu', ".note-detail-render a", linkContextMenu); +$(document).on('contextmenu', ".note-paths-widget a", linkContextMenu); export default { getNotePathFromUrl, diff --git a/src/public/app/services/zoom.js b/src/public/app/services/zoom.js index d94066a80..ad7faa08b 100644 --- a/src/public/app/services/zoom.js +++ b/src/public/app/services/zoom.js @@ -5,31 +5,33 @@ import utils from "../services/utils.js"; const MIN_ZOOM = 0.5; const MAX_ZOOM = 2.0; -export default class ZoomService extends Component { +class ZoomService extends Component { constructor() { super(); - this.setZoomFactor(options.getFloat('zoomFactor')); + options.initializedPromise.then(() => { + this.setZoomFactor(options.getFloat('zoomFactor')); + }); } setZoomFactor(zoomFactor) { zoomFactor = parseFloat(zoomFactor); - + const webFrame = utils.dynamicRequire('electron').webFrame; webFrame.setZoomFactor(zoomFactor); } - + async setZoomFactorAndSave(zoomFactor) { if (zoomFactor >= MIN_ZOOM && zoomFactor <= MAX_ZOOM) { this.setZoomFactor(zoomFactor); - + await options.save('zoomFactor', zoomFactor); } else { console.log(`Zoom factor ${zoomFactor} outside of the range, ignored.`); } } - + getCurrentZoom() { return utils.dynamicRequire('electron').webFrame.getZoomFactor(); } @@ -45,4 +47,8 @@ export default class ZoomService extends Component { setZoomFactorAndSaveEvent({zoomFactor}) { this.setZoomFactorAndSave(zoomFactor); } -} \ No newline at end of file +} + +const zoomService = new ZoomService(); + +export default zoomService; From 940a70adc5be55c31e72365dd4b2081c1fa702ec Mon Sep 17 00:00:00 2001 From: Naveen M V <30305957+naviji@users.noreply.github.com> Date: Tue, 12 May 2020 01:36:22 +0530 Subject: [PATCH 3/4] Fix regex bug (#1005) (cherry picked from commit 9a662f76da2348449524a01a7d02b6183d488866) --- src/services/parse_filters.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/parse_filters.js b/src/services/parse_filters.js index 412c9b527..e21b67c09 100644 --- a/src/services/parse_filters.js +++ b/src/services/parse_filters.js @@ -1,6 +1,6 @@ const dayjs = require("dayjs"); -const filterRegex = /(\b(AND|OR)\s+)?@(!?)([\p{L}\p{Number}_]+|"[^"]+")\s*((=|!=|<|<=|>|>=|!?\*=|!?=\*|!?\*=\*)\s*([^\s=*]+|"[^"]+"))?/igu; +const filterRegex = /(\b(AND|OR)\s+)?@(!?)([\p{L}\p{Number}_]+|"[^"]+")\s*((=|!=|<|<=|>|>=|!?\*=|!?=\*|!?\*=\*)\s*([^\s=*"]+|"[^"]+"))?/igu; const smartValueRegex = /^(NOW|TODAY|WEEK|MONTH|YEAR) *([+\-] *\d+)?$/i; function calculateSmartValue(v) { From e541abbd60c29556aab3363f6110fc54ac6a417e Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 11 May 2020 22:44:10 +0200 Subject: [PATCH 4/4] disable hiding the body to not hide the noscript element --- package-lock.json | 6 +++--- package.json | 2 +- src/public/app/services/ws.js | 4 ++-- src/views/desktop.ejs | 6 +----- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index ab50152f5..53df9ab4b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3345,9 +3345,9 @@ } }, "electron": { - "version": "9.0.0-beta.22", - "resolved": "https://registry.npmjs.org/electron/-/electron-9.0.0-beta.22.tgz", - "integrity": "sha512-dfqAf+CXXTKcNDj7DU7mYsmx+oZQcXOvJnZ8ZsgAHjrE9Tv8zsYUgCP3JlO4Z8CIazgleKXYmgh6H2stdK7fEA==", + "version": "9.0.0-beta.24", + "resolved": "https://registry.npmjs.org/electron/-/electron-9.0.0-beta.24.tgz", + "integrity": "sha512-25L3XMqm/1CCaV5CgU5ZkhKXw9830WeipJrTW0+VC5XTKp/3xHwhxyQ5G1kQnOTJd7IGwOamvw237D6e1YKnng==", "dev": true, "requires": { "@electron/get": "^1.0.1", diff --git a/package.json b/package.json index 7e36d93f4..ef0690863 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,7 @@ "yazl": "^2.5.1" }, "devDependencies": { - "electron": "9.0.0-beta.22", + "electron": "9.0.0-beta.24", "electron-builder": "22.6.0", "electron-packager": "14.2.1", "electron-rebuild": "1.10.1", diff --git a/src/public/app/services/ws.js b/src/public/app/services/ws.js index d06cac0fb..89fcdebcc 100644 --- a/src/public/app/services/ws.js +++ b/src/public/app/services/ws.js @@ -170,7 +170,7 @@ function connectWebSocket() { async function sendPing() { if (Date.now() - lastPingTs > 30000) { - console.log(utils.now(), "Lost websocket connection to the backend"); + console.log(utils.now(), "Lost websocket connection to the backend. If you keep having this issue repeatedly, you might want to check your reverse proxy (nginx, apache) configuration and allow/unblock WebSocket."); } if (ws.readyState === ws.OPEN) { @@ -374,4 +374,4 @@ export default { subscribeToMessages, waitForSyncId, waitForMaxKnownSyncId -}; \ No newline at end of file +}; diff --git a/src/views/desktop.ejs b/src/views/desktop.ejs index dd387edf2..b6f0c4938 100644 --- a/src/views/desktop.ejs +++ b/src/views/desktop.ejs @@ -5,7 +5,7 @@ Trilium Notes - +
@@ -83,9 +83,5 @@ - -