From b365c186a15bad4d8b55ac7e6d4e58dbab128c5e Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 11 May 2020 19:38:14 +0200 Subject: [PATCH 01/14] 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 02/14] 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 9a662f76da2348449524a01a7d02b6183d488866 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 03/14] Fix regex bug (#1005) --- 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 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 04/14] 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 05/14] 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 @@ - - From 2e0fb8aaf1ffc2d88441d6656164c30b1b2a08ef Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 11 May 2020 23:57:39 +0200 Subject: [PATCH 06/14] fix creating new promoted attributes, closes #1008 --- package-lock.json | 80 +++++++++---------- src/entities/attribute.js | 3 +- src/entities/note.js | 6 +- src/public/app/dialogs/attributes.js | 12 +-- src/public/app/widgets/promoted_attributes.js | 5 +- src/routes/api/attributes.js | 2 +- 6 files changed, 52 insertions(+), 56 deletions(-) diff --git a/package-lock.json b/package-lock.json index 53df9ab4b..837b0d31b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1263,7 +1263,7 @@ "dependencies": { "file-type": { "version": "3.9.0", - "resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", + "resolved": "http://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", "integrity": "sha1-JXoHg4TR24CHvESdEH1SpSZyuek=" } } @@ -1539,7 +1539,7 @@ }, "uuid": { "version": "2.0.3", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.3.tgz", + "resolved": "http://registry.npmjs.org/uuid/-/uuid-2.0.3.tgz", "integrity": "sha1-Z+LoY3lyFVMN/zGOW/nc6/1Hsho=" } } @@ -1573,7 +1573,7 @@ "dependencies": { "semver": { "version": "4.3.6", - "resolved": "https://registry.npmjs.org/semver/-/semver-4.3.6.tgz", + "resolved": "http://registry.npmjs.org/semver/-/semver-4.3.6.tgz", "integrity": "sha1-MAvG4OhjdPe6YQaLWx7NV/xlMto=" } } @@ -1593,7 +1593,7 @@ }, "bl": { "version": "1.2.2", - "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.2.tgz", + "resolved": "http://registry.npmjs.org/bl/-/bl-1.2.2.tgz", "integrity": "sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA==", "requires": { "readable-stream": "^2.3.5", @@ -1853,12 +1853,12 @@ "dependencies": { "file-type": { "version": "3.9.0", - "resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", + "resolved": "http://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", "integrity": "sha1-JXoHg4TR24CHvESdEH1SpSZyuek=" }, "uuid": { "version": "2.0.3", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.3.tgz", + "resolved": "http://registry.npmjs.org/uuid/-/uuid-2.0.3.tgz", "integrity": "sha1-Z+LoY3lyFVMN/zGOW/nc6/1Hsho=" } } @@ -1973,7 +1973,7 @@ }, "readable-stream": { "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "requires": { "core-util-is": "~1.0.0", @@ -2148,7 +2148,7 @@ }, "chalk": { "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "requires": { "ansi-styles": "^2.2.1", @@ -2465,7 +2465,7 @@ }, "commander": { "version": "2.8.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.8.1.tgz", + "resolved": "http://registry.npmjs.org/commander/-/commander-2.8.1.tgz", "integrity": "sha1-Br42f+v9oMMwqh4qBy09yXYkJdQ=", "requires": { "graceful-readlink": ">= 1.0.0" @@ -3128,7 +3128,7 @@ }, "readable-stream": { "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "requires": { "core-util-is": "~1.0.0", @@ -4957,7 +4957,7 @@ }, "get-stream": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" }, "getpass": { @@ -5221,7 +5221,7 @@ }, "got": { "version": "5.7.1", - "resolved": "https://registry.npmjs.org/got/-/got-5.7.1.tgz", + "resolved": "http://registry.npmjs.org/got/-/got-5.7.1.tgz", "integrity": "sha1-X4FjWmHkplifGAVp6k44FoClHzU=", "requires": { "create-error-class": "^3.0.1", @@ -5869,7 +5869,7 @@ }, "into-stream": { "version": "3.1.0", - "resolved": "https://registry.npmjs.org/into-stream/-/into-stream-3.1.0.tgz", + "resolved": "http://registry.npmjs.org/into-stream/-/into-stream-3.1.0.tgz", "integrity": "sha1-lvsKk2wSur1v8XUqF9BWFqvQlMY=", "requires": { "from2": "^2.1.1", @@ -6021,7 +6021,7 @@ }, "is-obj": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", + "resolved": "http://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=" }, "is-object": { @@ -6621,7 +6621,7 @@ }, "load-json-file": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", + "resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", "requires": { "graceful-fs": "^4.1.2", @@ -7130,7 +7130,7 @@ }, "minimist": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" }, "minipass": { @@ -7230,7 +7230,7 @@ }, "mkdirp": { "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "requires": { "minimist": "0.0.8" @@ -7238,7 +7238,7 @@ "dependencies": { "minimist": { "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" } } @@ -7432,7 +7432,7 @@ }, "get-stream": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" }, "got": { @@ -7468,7 +7468,7 @@ }, "p-cancelable": { "version": "0.4.1", - "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-0.4.1.tgz", + "resolved": "http://registry.npmjs.org/p-cancelable/-/p-cancelable-0.4.1.tgz", "integrity": "sha512-HNa1A8LvB1kie7cERyy21VNeHb2CWJJYqyyC2o3klWFfMGlFmWv2Z7sFgZH8ZiaYL95ydToKTFVXgMV/Os0bBQ==" }, "p-event": { @@ -7592,7 +7592,7 @@ "dependencies": { "file-type": { "version": "3.9.0", - "resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", + "resolved": "http://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", "integrity": "sha1-JXoHg4TR24CHvESdEH1SpSZyuek=" } } @@ -7617,7 +7617,7 @@ "dependencies": { "get-stream": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" }, "pify": { @@ -7674,7 +7674,7 @@ }, "get-stream": { "version": "2.3.1", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-2.3.1.tgz", + "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-2.3.1.tgz", "integrity": "sha1-Xzj5PzRgCWZu4BUKBUFn+Rvdld4=", "requires": { "object-assign": "^4.0.1", @@ -7704,7 +7704,7 @@ "dependencies": { "get-stream": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" } } @@ -7744,7 +7744,7 @@ }, "pify": { "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" }, "prepend-http": { @@ -7849,7 +7849,7 @@ }, "readable-stream": { "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "requires": { "core-util-is": "~1.0.0", @@ -8227,7 +8227,7 @@ }, "onetime": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", + "resolved": "http://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=" }, "open": { @@ -8379,7 +8379,7 @@ }, "p-is-promise": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-1.1.0.tgz", + "resolved": "http://registry.npmjs.org/p-is-promise/-/p-is-promise-1.1.0.tgz", "integrity": "sha1-nJRWmJ6fZYgBewQ01WCXZ1w9oF4=" }, "p-limit": { @@ -8860,7 +8860,7 @@ }, "get-stream": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" } } @@ -9144,7 +9144,7 @@ "dependencies": { "file-type": { "version": "3.9.0", - "resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", + "resolved": "http://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", "integrity": "sha1-JXoHg4TR24CHvESdEH1SpSZyuek=" } } @@ -9169,7 +9169,7 @@ "dependencies": { "get-stream": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" }, "pify": { @@ -9207,7 +9207,7 @@ }, "get-stream": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" } } @@ -9259,7 +9259,7 @@ }, "get-stream": { "version": "2.3.1", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-2.3.1.tgz", + "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-2.3.1.tgz", "integrity": "sha1-Xzj5PzRgCWZu4BUKBUFn+Rvdld4=", "requires": { "object-assign": "^4.0.1", @@ -9289,7 +9289,7 @@ "dependencies": { "get-stream": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" } } @@ -9477,7 +9477,7 @@ }, "query-string": { "version": "5.1.1", - "resolved": "https://registry.npmjs.org/query-string/-/query-string-5.1.1.tgz", + "resolved": "http://registry.npmjs.org/query-string/-/query-string-5.1.1.tgz", "integrity": "sha512-gjWOsm2SoGlgLEdAGt7a6slVOk9mGiXmPFMqrEhLQ68rhQuBnpfs3+EmlvqKyxnCo9/PPlF+9MtY02S1aFg+Jw==", "requires": { "decode-uri-component": "^0.2.0", @@ -9616,7 +9616,7 @@ }, "readable-stream": { "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "requires": { "core-util-is": "~1.0.0", @@ -10484,7 +10484,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "requires": { "ansi-regex": "^2.0.0" @@ -10509,7 +10509,7 @@ }, "strip-dirs": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/strip-dirs/-/strip-dirs-1.1.1.tgz", + "resolved": "http://registry.npmjs.org/strip-dirs/-/strip-dirs-1.1.1.tgz", "integrity": "sha1-lgu9EoeETzl1pFWKoQOoJV4kVqA=", "requires": { "chalk": "^1.0.0", @@ -10767,7 +10767,7 @@ }, "through": { "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" }, "through2": { @@ -10786,7 +10786,7 @@ }, "readable-stream": { "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", "requires": { "core-util-is": "~1.0.0", diff --git a/src/entities/attribute.js b/src/entities/attribute.js index b401fd27e..0800d6252 100644 --- a/src/entities/attribute.js +++ b/src/entities/attribute.js @@ -105,7 +105,6 @@ class Attribute extends Entity { // cannot be static! updatePojo(pojo) { - delete pojo.isOwned; delete pojo.__note; } @@ -124,4 +123,4 @@ class Attribute extends Entity { } } -module.exports = Attribute; \ No newline at end of file +module.exports = Attribute; diff --git a/src/entities/note.js b/src/entities/note.js index 5ab002880..64708f0ab 100644 --- a/src/entities/note.js +++ b/src/entities/note.js @@ -411,10 +411,6 @@ class Note extends Entity { } }); - for (const attr of filteredAttributes) { - attr.isOwned = attr.noteId === this.noteId; - } - this.__attributeCache = filteredAttributes; } @@ -946,4 +942,4 @@ class Note extends Entity { } } -module.exports = Note; \ No newline at end of file +module.exports = Note; diff --git a/src/public/app/dialogs/attributes.js b/src/public/app/dialogs/attributes.js index 27630dd24..2cf844420 100644 --- a/src/public/app/dialogs/attributes.js +++ b/src/public/app/dialogs/attributes.js @@ -59,8 +59,8 @@ function AttributesModel() { }); }; - async function showAttributes(attributes) { - const ownedAttributes = attributes.filter(attr => attr.isOwned); + async function showAttributes(noteId, attributes) { + const ownedAttributes = attributes.filter(attr => attr.noteId === noteId); for (const attr of ownedAttributes) { attr.labelValue = attr.type === 'label' ? attr.value : ''; @@ -86,7 +86,7 @@ function AttributesModel() { addLastEmptyRow(); - const inheritedAttributes = attributes.filter(attr => !attr.isOwned); + const inheritedAttributes = attributes.filter(attr => attr.noteId !== noteId); self.inheritedAttributes(inheritedAttributes); } @@ -96,7 +96,7 @@ function AttributesModel() { const attributes = await server.get('notes/' + noteId + '/attributes'); - await showAttributes(attributes); + await showAttributes(noteId, attributes); // attribute might not be rendered immediatelly so could not focus setTimeout(() => $(".attribute-type-select:last").trigger('focus'), 1000); @@ -166,7 +166,7 @@ function AttributesModel() { const attributes = await server.put('notes/' + noteId + '/attributes', attributesToSave); - await showAttributes(attributes); + await showAttributes(noteId, attributes); toastService.showMessage("Attributes have been saved."); }; @@ -311,4 +311,4 @@ $dialog.on('focus', '.label-value', function (e) { $el: $(this), open: true }) -}); \ No newline at end of file +}); diff --git a/src/public/app/widgets/promoted_attributes.js b/src/public/app/widgets/promoted_attributes.js index 8c9e71209..58e025d07 100644 --- a/src/public/app/widgets/promoted_attributes.js +++ b/src/public/app/widgets/promoted_attributes.js @@ -19,6 +19,7 @@ const TPL = ` .promoted-attributes td, .promoted-attributes th { padding: 5px; + min-width: 50px; /* otherwise checkboxes can collapse into 0 width (if there are only checkboxes) */ } @@ -98,7 +99,7 @@ export default class PromotedAttributesWidget extends TabAwareWidget { const $labelCell = $("
").append(valueAttr.name); const $input = $("") .prop("tabindex", definitionAttr.position) - .prop("attribute-id", valueAttr.isOwned ? valueAttr.attributeId : '') // if not owned, we'll force creation of a new attribute instead of updating the inherited one + .prop("attribute-id", valueAttr.noteId === this.noteId ? valueAttr.attributeId : '') // if not owned, we'll force creation of a new attribute instead of updating the inherited one .prop("attribute-type", valueAttr.type) .prop("attribute-name", valueAttr.name) .prop("value", valueAttr.value) @@ -266,4 +267,4 @@ export default class PromotedAttributesWidget extends TabAwareWidget { $attr.prop("attribute-id", result.attributeId); } -} \ No newline at end of file +} diff --git a/src/routes/api/attributes.js b/src/routes/api/attributes.js index 25bbaaf7e..131e7a77b 100644 --- a/src/routes/api/attributes.js +++ b/src/routes/api/attributes.js @@ -199,4 +199,4 @@ module.exports = { getEffectiveNoteAttributes, createRelation, deleteRelation -}; \ No newline at end of file +}; From cb70109ee786300afa84462d5d301e6a0334184c Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 11 May 2020 23:57:39 +0200 Subject: [PATCH 07/14] fix creating new promoted attributes, closes #1008 (cherry picked from commit 2e0fb8aaf1ffc2d88441d6656164c30b1b2a08ef) --- package-lock.json | 80 +++++++++---------- src/entities/attribute.js | 3 +- src/entities/note.js | 6 +- src/public/app/dialogs/attributes.js | 12 +-- src/public/app/widgets/promoted_attributes.js | 5 +- src/routes/api/attributes.js | 2 +- 6 files changed, 52 insertions(+), 56 deletions(-) diff --git a/package-lock.json b/package-lock.json index 53df9ab4b..837b0d31b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1263,7 +1263,7 @@ "dependencies": { "file-type": { "version": "3.9.0", - "resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", + "resolved": "http://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", "integrity": "sha1-JXoHg4TR24CHvESdEH1SpSZyuek=" } } @@ -1539,7 +1539,7 @@ }, "uuid": { "version": "2.0.3", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.3.tgz", + "resolved": "http://registry.npmjs.org/uuid/-/uuid-2.0.3.tgz", "integrity": "sha1-Z+LoY3lyFVMN/zGOW/nc6/1Hsho=" } } @@ -1573,7 +1573,7 @@ "dependencies": { "semver": { "version": "4.3.6", - "resolved": "https://registry.npmjs.org/semver/-/semver-4.3.6.tgz", + "resolved": "http://registry.npmjs.org/semver/-/semver-4.3.6.tgz", "integrity": "sha1-MAvG4OhjdPe6YQaLWx7NV/xlMto=" } } @@ -1593,7 +1593,7 @@ }, "bl": { "version": "1.2.2", - "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.2.tgz", + "resolved": "http://registry.npmjs.org/bl/-/bl-1.2.2.tgz", "integrity": "sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA==", "requires": { "readable-stream": "^2.3.5", @@ -1853,12 +1853,12 @@ "dependencies": { "file-type": { "version": "3.9.0", - "resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", + "resolved": "http://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", "integrity": "sha1-JXoHg4TR24CHvESdEH1SpSZyuek=" }, "uuid": { "version": "2.0.3", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.3.tgz", + "resolved": "http://registry.npmjs.org/uuid/-/uuid-2.0.3.tgz", "integrity": "sha1-Z+LoY3lyFVMN/zGOW/nc6/1Hsho=" } } @@ -1973,7 +1973,7 @@ }, "readable-stream": { "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "requires": { "core-util-is": "~1.0.0", @@ -2148,7 +2148,7 @@ }, "chalk": { "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "requires": { "ansi-styles": "^2.2.1", @@ -2465,7 +2465,7 @@ }, "commander": { "version": "2.8.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.8.1.tgz", + "resolved": "http://registry.npmjs.org/commander/-/commander-2.8.1.tgz", "integrity": "sha1-Br42f+v9oMMwqh4qBy09yXYkJdQ=", "requires": { "graceful-readlink": ">= 1.0.0" @@ -3128,7 +3128,7 @@ }, "readable-stream": { "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "requires": { "core-util-is": "~1.0.0", @@ -4957,7 +4957,7 @@ }, "get-stream": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" }, "getpass": { @@ -5221,7 +5221,7 @@ }, "got": { "version": "5.7.1", - "resolved": "https://registry.npmjs.org/got/-/got-5.7.1.tgz", + "resolved": "http://registry.npmjs.org/got/-/got-5.7.1.tgz", "integrity": "sha1-X4FjWmHkplifGAVp6k44FoClHzU=", "requires": { "create-error-class": "^3.0.1", @@ -5869,7 +5869,7 @@ }, "into-stream": { "version": "3.1.0", - "resolved": "https://registry.npmjs.org/into-stream/-/into-stream-3.1.0.tgz", + "resolved": "http://registry.npmjs.org/into-stream/-/into-stream-3.1.0.tgz", "integrity": "sha1-lvsKk2wSur1v8XUqF9BWFqvQlMY=", "requires": { "from2": "^2.1.1", @@ -6021,7 +6021,7 @@ }, "is-obj": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", + "resolved": "http://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=" }, "is-object": { @@ -6621,7 +6621,7 @@ }, "load-json-file": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", + "resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", "requires": { "graceful-fs": "^4.1.2", @@ -7130,7 +7130,7 @@ }, "minimist": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" }, "minipass": { @@ -7230,7 +7230,7 @@ }, "mkdirp": { "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "requires": { "minimist": "0.0.8" @@ -7238,7 +7238,7 @@ "dependencies": { "minimist": { "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" } } @@ -7432,7 +7432,7 @@ }, "get-stream": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" }, "got": { @@ -7468,7 +7468,7 @@ }, "p-cancelable": { "version": "0.4.1", - "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-0.4.1.tgz", + "resolved": "http://registry.npmjs.org/p-cancelable/-/p-cancelable-0.4.1.tgz", "integrity": "sha512-HNa1A8LvB1kie7cERyy21VNeHb2CWJJYqyyC2o3klWFfMGlFmWv2Z7sFgZH8ZiaYL95ydToKTFVXgMV/Os0bBQ==" }, "p-event": { @@ -7592,7 +7592,7 @@ "dependencies": { "file-type": { "version": "3.9.0", - "resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", + "resolved": "http://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", "integrity": "sha1-JXoHg4TR24CHvESdEH1SpSZyuek=" } } @@ -7617,7 +7617,7 @@ "dependencies": { "get-stream": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" }, "pify": { @@ -7674,7 +7674,7 @@ }, "get-stream": { "version": "2.3.1", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-2.3.1.tgz", + "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-2.3.1.tgz", "integrity": "sha1-Xzj5PzRgCWZu4BUKBUFn+Rvdld4=", "requires": { "object-assign": "^4.0.1", @@ -7704,7 +7704,7 @@ "dependencies": { "get-stream": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" } } @@ -7744,7 +7744,7 @@ }, "pify": { "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" }, "prepend-http": { @@ -7849,7 +7849,7 @@ }, "readable-stream": { "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "requires": { "core-util-is": "~1.0.0", @@ -8227,7 +8227,7 @@ }, "onetime": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", + "resolved": "http://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=" }, "open": { @@ -8379,7 +8379,7 @@ }, "p-is-promise": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-1.1.0.tgz", + "resolved": "http://registry.npmjs.org/p-is-promise/-/p-is-promise-1.1.0.tgz", "integrity": "sha1-nJRWmJ6fZYgBewQ01WCXZ1w9oF4=" }, "p-limit": { @@ -8860,7 +8860,7 @@ }, "get-stream": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" } } @@ -9144,7 +9144,7 @@ "dependencies": { "file-type": { "version": "3.9.0", - "resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", + "resolved": "http://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", "integrity": "sha1-JXoHg4TR24CHvESdEH1SpSZyuek=" } } @@ -9169,7 +9169,7 @@ "dependencies": { "get-stream": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" }, "pify": { @@ -9207,7 +9207,7 @@ }, "get-stream": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" } } @@ -9259,7 +9259,7 @@ }, "get-stream": { "version": "2.3.1", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-2.3.1.tgz", + "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-2.3.1.tgz", "integrity": "sha1-Xzj5PzRgCWZu4BUKBUFn+Rvdld4=", "requires": { "object-assign": "^4.0.1", @@ -9289,7 +9289,7 @@ "dependencies": { "get-stream": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" } } @@ -9477,7 +9477,7 @@ }, "query-string": { "version": "5.1.1", - "resolved": "https://registry.npmjs.org/query-string/-/query-string-5.1.1.tgz", + "resolved": "http://registry.npmjs.org/query-string/-/query-string-5.1.1.tgz", "integrity": "sha512-gjWOsm2SoGlgLEdAGt7a6slVOk9mGiXmPFMqrEhLQ68rhQuBnpfs3+EmlvqKyxnCo9/PPlF+9MtY02S1aFg+Jw==", "requires": { "decode-uri-component": "^0.2.0", @@ -9616,7 +9616,7 @@ }, "readable-stream": { "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "requires": { "core-util-is": "~1.0.0", @@ -10484,7 +10484,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "requires": { "ansi-regex": "^2.0.0" @@ -10509,7 +10509,7 @@ }, "strip-dirs": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/strip-dirs/-/strip-dirs-1.1.1.tgz", + "resolved": "http://registry.npmjs.org/strip-dirs/-/strip-dirs-1.1.1.tgz", "integrity": "sha1-lgu9EoeETzl1pFWKoQOoJV4kVqA=", "requires": { "chalk": "^1.0.0", @@ -10767,7 +10767,7 @@ }, "through": { "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" }, "through2": { @@ -10786,7 +10786,7 @@ }, "readable-stream": { "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", "requires": { "core-util-is": "~1.0.0", diff --git a/src/entities/attribute.js b/src/entities/attribute.js index b401fd27e..0800d6252 100644 --- a/src/entities/attribute.js +++ b/src/entities/attribute.js @@ -105,7 +105,6 @@ class Attribute extends Entity { // cannot be static! updatePojo(pojo) { - delete pojo.isOwned; delete pojo.__note; } @@ -124,4 +123,4 @@ class Attribute extends Entity { } } -module.exports = Attribute; \ No newline at end of file +module.exports = Attribute; diff --git a/src/entities/note.js b/src/entities/note.js index 5ab002880..64708f0ab 100644 --- a/src/entities/note.js +++ b/src/entities/note.js @@ -411,10 +411,6 @@ class Note extends Entity { } }); - for (const attr of filteredAttributes) { - attr.isOwned = attr.noteId === this.noteId; - } - this.__attributeCache = filteredAttributes; } @@ -946,4 +942,4 @@ class Note extends Entity { } } -module.exports = Note; \ No newline at end of file +module.exports = Note; diff --git a/src/public/app/dialogs/attributes.js b/src/public/app/dialogs/attributes.js index 27630dd24..2cf844420 100644 --- a/src/public/app/dialogs/attributes.js +++ b/src/public/app/dialogs/attributes.js @@ -59,8 +59,8 @@ function AttributesModel() { }); }; - async function showAttributes(attributes) { - const ownedAttributes = attributes.filter(attr => attr.isOwned); + async function showAttributes(noteId, attributes) { + const ownedAttributes = attributes.filter(attr => attr.noteId === noteId); for (const attr of ownedAttributes) { attr.labelValue = attr.type === 'label' ? attr.value : ''; @@ -86,7 +86,7 @@ function AttributesModel() { addLastEmptyRow(); - const inheritedAttributes = attributes.filter(attr => !attr.isOwned); + const inheritedAttributes = attributes.filter(attr => attr.noteId !== noteId); self.inheritedAttributes(inheritedAttributes); } @@ -96,7 +96,7 @@ function AttributesModel() { const attributes = await server.get('notes/' + noteId + '/attributes'); - await showAttributes(attributes); + await showAttributes(noteId, attributes); // attribute might not be rendered immediatelly so could not focus setTimeout(() => $(".attribute-type-select:last").trigger('focus'), 1000); @@ -166,7 +166,7 @@ function AttributesModel() { const attributes = await server.put('notes/' + noteId + '/attributes', attributesToSave); - await showAttributes(attributes); + await showAttributes(noteId, attributes); toastService.showMessage("Attributes have been saved."); }; @@ -311,4 +311,4 @@ $dialog.on('focus', '.label-value', function (e) { $el: $(this), open: true }) -}); \ No newline at end of file +}); diff --git a/src/public/app/widgets/promoted_attributes.js b/src/public/app/widgets/promoted_attributes.js index 8c9e71209..58e025d07 100644 --- a/src/public/app/widgets/promoted_attributes.js +++ b/src/public/app/widgets/promoted_attributes.js @@ -19,6 +19,7 @@ const TPL = ` .promoted-attributes td, .promoted-attributes th { padding: 5px; + min-width: 50px; /* otherwise checkboxes can collapse into 0 width (if there are only checkboxes) */ } @@ -98,7 +99,7 @@ export default class PromotedAttributesWidget extends TabAwareWidget { const $labelCell = $("").append(valueAttr.name); const $input = $("") .prop("tabindex", definitionAttr.position) - .prop("attribute-id", valueAttr.isOwned ? valueAttr.attributeId : '') // if not owned, we'll force creation of a new attribute instead of updating the inherited one + .prop("attribute-id", valueAttr.noteId === this.noteId ? valueAttr.attributeId : '') // if not owned, we'll force creation of a new attribute instead of updating the inherited one .prop("attribute-type", valueAttr.type) .prop("attribute-name", valueAttr.name) .prop("value", valueAttr.value) @@ -266,4 +267,4 @@ export default class PromotedAttributesWidget extends TabAwareWidget { $attr.prop("attribute-id", result.attributeId); } -} \ No newline at end of file +} diff --git a/src/routes/api/attributes.js b/src/routes/api/attributes.js index 25bbaaf7e..131e7a77b 100644 --- a/src/routes/api/attributes.js +++ b/src/routes/api/attributes.js @@ -199,4 +199,4 @@ module.exports = { getEffectiveNoteAttributes, createRelation, deleteRelation -}; \ No newline at end of file +}; From 9d8b8e26a1488448a1d6119edbfa608bd05897ea Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 12 May 2020 10:28:31 +0200 Subject: [PATCH 08/14] attach extension to download file if note present --- src/routes/api/files.js | 7 +++-- src/routes/api/note_revisions.js | 10 ++----- src/services/notes.js | 5 ++-- src/services/utils.js | 49 ++++++++++++++++++++++++++++---- 4 files changed, 53 insertions(+), 18 deletions(-) diff --git a/src/routes/api/files.js b/src/routes/api/files.js index 54ba741fb..88c18354d 100644 --- a/src/routes/api/files.js +++ b/src/routes/api/files.js @@ -1,6 +1,5 @@ "use strict"; -const noteService = require('../../services/notes'); const protectedSessionService = require('../../services/protected_session'); const repository = require('../../services/repository'); const utils = require('../../services/utils'); @@ -45,7 +44,9 @@ async function downloadNoteFile(noteId, res, contentDisposition = true) { if (contentDisposition) { // (one) reason we're not using the originFileName (available as label) is that it's not // available for older note revisions and thus would be inconsistent - res.setHeader('Content-Disposition', utils.getContentDisposition(note.title || "untitled")); + const filename = utils.formatDownloadTitle(note.title, note.type, note.mime); + + res.setHeader('Content-Disposition', utils.getContentDisposition(filename)); } res.setHeader('Content-Type', note.mime); @@ -70,4 +71,4 @@ module.exports = { openFile, downloadFile, downloadNoteFile -}; \ No newline at end of file +}; diff --git a/src/routes/api/note_revisions.js b/src/routes/api/note_revisions.js index 023ba30ee..7f325f725 100644 --- a/src/routes/api/note_revisions.js +++ b/src/routes/api/note_revisions.js @@ -38,13 +38,7 @@ async function getNoteRevision(req) { * @return {string} */ function getRevisionFilename(noteRevision) { - let filename = noteRevision.title || "untitled"; - - if (noteRevision.type === 'text') { - filename += '.html'; - } else if (['relation-map', 'search'].includes(noteRevision.type)) { - filename += '.json'; - } + let filename = utils.formatDownloadTitle(noteRevision.title, noteRevision.type, noteRevision.mime); const extension = path.extname(filename); const date = noteRevision.dateCreated @@ -158,4 +152,4 @@ module.exports = { eraseAllNoteRevisions, eraseNoteRevision, restoreNoteRevision -}; \ No newline at end of file +}; diff --git a/src/services/notes.js b/src/services/notes.js index 152c72ec4..a04164ef5 100644 --- a/src/services/notes.js +++ b/src/services/notes.js @@ -13,6 +13,7 @@ const Attribute = require('../entities/attribute'); const hoistedNoteService = require('../services/hoisted_note'); const protectedSessionService = require('../services/protected_session'); const log = require('../services/log'); +const utils = require('../services/utils'); const noteRevisionService = require('../services/note_revisions'); const attributeService = require('../services/attributes'); const request = require('./request'); @@ -276,9 +277,9 @@ async function downloadImage(noteId, imageUrl) { const downloadImagePromises = {}; function replaceUrl(content, url, imageNote) { - const quoted = url.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&'); + const quotedUrl = utils.quoteRegex(url); - return content.replace(new RegExp(`\\s+src=[\"']${quoted}[\"']`, "g"), ` src="api/images/${imageNote.noteId}/${imageNote.title}"`); + return content.replace(new RegExp(`\\s+src=[\"']${quotedUrl}[\"']`, "g"), ` src="api/images/${imageNote.noteId}/${imageNote.title}"`); } async function downloadImages(noteId, content) { diff --git a/src/services/utils.js b/src/services/utils.js index 57af4218e..7cb02ae40 100644 --- a/src/services/utils.js +++ b/src/services/utils.js @@ -5,6 +5,7 @@ const randtoken = require('rand-token').generator({source: 'crypto'}); const unescape = require('unescape'); const escape = require('escape-html'); const sanitize = require("sanitize-filename"); +const mimeTypes = require('mime-types'); function newEntityId() { return randomString(12); @@ -166,10 +167,46 @@ function isStringNote(type, mime) { || STRING_MIME_TYPES.includes(mime); } -function replaceAll(string, replaceWhat, replaceWith) { - const escapedWhat = replaceWhat.replace(/([\/,!\\^${}\[\]().*+?|<>\-&])/g, "\\$&"); +function quoteRegex(url) { + return url.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&'); +} - return string.replace(new RegExp(escapedWhat, "g"), replaceWith); +function replaceAll(string, replaceWhat, replaceWith) { + const quotedReplaceWhat = quoteRegex(replaceWhat); + + return string.replace(new RegExp(quotedReplaceWhat, "g"), replaceWith); +} + +function formatDownloadTitle(filename, type, mime) { + if (!filename) { + filename = "untitled"; + } + + if (type === 'text') { + return filename + '.html'; + } else if (['relation-map', 'search'].includes(type)) { + return filename + '.json'; + } else { + if (!mime) { + return filename; + } + + mime = mime.toLowerCase(); + const filenameLc = filename.toLowerCase(); + const extensions = mimeTypes.extensions[mime]; + + if (!extensions || extensions.length === 0) { + return filename; + } + + for (const ext of extensions) { + if (filenameLc.endsWith('.' + ext)) { + return filename; + } + } + + return filename + '.' + extensions[0]; + } } module.exports = { @@ -198,5 +235,7 @@ module.exports = { sanitizeFilenameForHeader, getContentDisposition, isStringNote, - replaceAll -}; \ No newline at end of file + quoteRegex, + replaceAll, + formatDownloadTitle +}; From e08b0141a4caf55094d2900bf2ba45ba14f537ed Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 12 May 2020 10:52:07 +0200 Subject: [PATCH 09/14] when expanding/collpasing, set the flag also to the tree cache --- src/public/app/widgets/note_tree.js | 55 +++++++++++++++-------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/src/public/app/widgets/note_tree.js b/src/public/app/widgets/note_tree.js index 5c4cc4ae5..69cb8a93c 100644 --- a/src/public/app/widgets/note_tree.js +++ b/src/public/app/widgets/note_tree.js @@ -251,8 +251,8 @@ export default class NoteTreeWidget extends TabAwareWidget { this.triggerCommand('setActiveScreen', {screen:'detail'}); } }, - expand: (event, data) => this.setExpandedToServer(data.node.data.branchId, true), - collapse: (event, data) => this.setExpandedToServer(data.node.data.branchId, false), + expand: (event, data) => this.setExpanded(data.node.data.branchId, true), + collapse: (event, data) => this.setExpanded(data.node.data.branchId, false), hotkeys: utils.isMobile() ? undefined : { keydown: await this.getHotKeys() }, dnd5: { autoExpandMS: 600, @@ -929,12 +929,13 @@ export default class NoteTreeWidget extends TabAwareWidget { } } - async setExpandedToServer(branchId, isExpanded) { + async setExpanded(branchId, isExpanded) { utils.assertArguments(branchId); - const expandedNum = isExpanded ? 1 : 0; + const branch = treeCache.getBranch(branchId); + branch.isExpanded = isExpanded; - await server.put('branches/' + branchId + '/expanded/' + expandedNum); + await server.put(`branches/${branchId}/expanded/${isExpanded ? 1 : 0}`); } async reloadTreeFromCache() { @@ -994,7 +995,7 @@ export default class NoteTreeWidget extends TabAwareWidget { return false; } }; - + for (const action of actions) { for (const shortcut of action.effectiveShortcuts) { hotKeyMap[utils.normalizeShortcut(shortcut)] = node => { @@ -1019,83 +1020,83 @@ export default class NoteTreeWidget extends TabAwareWidget { async deleteNotesCommand({node}) { const branchIds = this.getSelectedOrActiveBranchIds(node); - + await branchService.deleteNotes(branchIds); this.clearSelectedNodes(); } - + moveNoteUpCommand({node}) { const beforeNode = node.getPrevSibling(); - + if (beforeNode !== null) { branchService.moveBeforeBranch([node.data.branchId], beforeNode.data.branchId); } } - + moveNoteDownCommand({node}) { const afterNode = node.getNextSibling(); if (afterNode !== null) { branchService.moveAfterBranch([node.data.branchId], afterNode.data.branchId); } } - + moveNoteUpInHierarchyCommand({node}) { branchService.moveNodeUpInHierarchy(node); } - + moveNoteDownInHierarchyCommand({node}) { const toNode = node.getPrevSibling(); - + if (toNode !== null) { branchService.moveToParentNote([node.data.branchId], toNode.data.noteId); } } - + addNoteAboveToSelectionCommand() { const node = this.getFocusedNode(); - + if (!node) { return; } - + if (node.isActive()) { node.setSelected(true); } - + const prevSibling = node.getPrevSibling(); - + if (prevSibling) { prevSibling.setActive(true, {noEvents: true}); - + if (prevSibling.isSelected()) { node.setSelected(false); } - + prevSibling.setSelected(true); } } addNoteBelowToSelectionCommand() { const node = this.getFocusedNode(); - + if (!node) { return; } - + if (node.isActive()) { node.setSelected(true); } - + const nextSibling = node.getNextSibling(); - + if (nextSibling) { nextSibling.setActive(true, {noEvents: true}); - + if (nextSibling.isSelected()) { node.setSelected(false); } - + nextSibling.setSelected(true); } } @@ -1179,4 +1180,4 @@ export default class NoteTreeWidget extends TabAwareWidget { noteCreateService.duplicateNote(node.data.noteId, branch.parentNoteId); } -} \ No newline at end of file +} From b063b4c528adb93aef8f33a124676db7bc25850c Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 12 May 2020 12:28:59 +0200 Subject: [PATCH 10/14] read only view images should not overflow --- src/public/app/widgets/type_widgets/read_only_text.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/public/app/widgets/type_widgets/read_only_text.js b/src/public/app/widgets/type_widgets/read_only_text.js index 83ae447ac..9e7641414 100644 --- a/src/public/app/widgets/type_widgets/read_only_text.js +++ b/src/public/app/widgets/type_widgets/read_only_text.js @@ -22,6 +22,10 @@ const TPL = ` .note-detail-readonly-text p:first-child, .note-detail-text::before { margin-top: 0; } + + .note-detail-readonly-text img { + max-width: 100%; + }
@@ -77,4 +81,4 @@ export default class ReadOnlyTextTypeWidget extends AbstractTextTypeWidget { this.loadIncludedNote(noteId, $(el)); }); } -} \ No newline at end of file +} From 30b9ef860491e86168beab291070cca80ab1cadc Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 12 May 2020 12:45:32 +0200 Subject: [PATCH 11/14] fix tab title of deleted note --- src/public/app/layouts/desktop_main_window_layout.js | 4 ++-- src/public/app/widgets/basic_widget.js | 7 ++++++- src/public/app/widgets/tab_row.js | 12 ++++++++---- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/public/app/layouts/desktop_main_window_layout.js b/src/public/app/layouts/desktop_main_window_layout.js index bf0e78b37..c49376e6a 100644 --- a/src/public/app/layouts/desktop_main_window_layout.js +++ b/src/public/app/layouts/desktop_main_window_layout.js @@ -24,7 +24,6 @@ import NoteRevisionsWidget from "../widgets/collapsible_widgets/note_revisions.j import SimilarNotesWidget from "../widgets/collapsible_widgets/similar_notes.js"; import WhatLinksHereWidget from "../widgets/collapsible_widgets/what_links_here.js"; import SidePaneToggles from "../widgets/side_pane_toggles.js"; -import appContext from "../services/app_context.js"; const RIGHT_PANE_CSS = `