From d18a20cc06f7e0a5055281c0fc1d06a893523b7f Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 2 Jul 2019 20:28:57 +0200 Subject: [PATCH 1/3] fix focus issue from title to the text content with tab/enter --- package-lock.json | 2 +- src/public/javascripts/services/note_detail_text.js | 2 +- src/views/tabs.ejs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3fd371fc6..d5470719e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "trilium", - "version": "0.33.4", + "version": "0.33.5", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/public/javascripts/services/note_detail_text.js b/src/public/javascripts/services/note_detail_text.js index de75a1763..9c8f1204c 100644 --- a/src/public/javascripts/services/note_detail_text.js +++ b/src/public/javascripts/services/note_detail_text.js @@ -74,7 +74,7 @@ class NoteDetailText { } focus() { - this.$component.focus(); + this.$editorEl.focus(); } getEditor() { diff --git a/src/views/tabs.ejs b/src/views/tabs.ejs index 6e68f3b7b..5f0c5560e 100644 --- a/src/views/tabs.ejs +++ b/src/views/tabs.ejs @@ -11,8 +11,8 @@
-
-
+
+
From afe24866f011736dad555e003b428667c3ba924c Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 2 Jul 2019 20:35:06 +0200 Subject: [PATCH 2/3] some debug logging for duplicated nodes --- src/public/javascripts/services/tree.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/public/javascripts/services/tree.js b/src/public/javascripts/services/tree.js index 7be6bff10..3bc692afc 100644 --- a/src/public/javascripts/services/tree.js +++ b/src/public/javascripts/services/tree.js @@ -635,6 +635,8 @@ async function createNote(node, parentNoteId, target, extraOptions = {}) { }; if (target === 'after') { + console.log(`Appending node...`); // to debug duplicated nodes + await node.appendSibling(newNode).setActive(true); } else if (target === 'into') { @@ -642,6 +644,8 @@ async function createNote(node, parentNoteId, target, extraOptions = {}) { await node.setExpanded(); } + console.log(`Adding node as child...`); // to debug duplicated nodes + node.addChildren(newNode); await node.getLastChild().setActive(true); From 196264b8c2fc626e3114d65423c7110cff99ae85 Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 2 Jul 2019 21:54:37 +0200 Subject: [PATCH 3/3] use bootstrap modal to confirm note deletion which fixes #582 --- src/public/javascripts/dialogs/confirm.js | 8 ++++++++ src/public/javascripts/dialogs/info.js | 8 ++++++++ src/public/javascripts/services/branches.js | 3 ++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/public/javascripts/dialogs/confirm.js b/src/public/javascripts/dialogs/confirm.js index 5a103ca70..efbc686df 100644 --- a/src/public/javascripts/dialogs/confirm.js +++ b/src/public/javascripts/dialogs/confirm.js @@ -7,8 +7,11 @@ const $custom = $("#confirm-dialog-custom"); const DELETE_NOTE_BUTTON_ID = "confirm-dialog-delete-note"; let resolve; +let $originallyFocused; // element focused before the dialog was opened so we can return to it afterwards function confirm(message) { + $originallyFocused = $(':focus'); + $custom.hide(); glob.activeDialog = $dialog; @@ -55,6 +58,11 @@ $dialog.on("hidden.bs.modal", () => { if (resolve) { resolve(false); } + + if ($originallyFocused) { + $originallyFocused.focus(); + $originallyFocused = null; + } }); function doResolve(ret) { diff --git a/src/public/javascripts/dialogs/info.js b/src/public/javascripts/dialogs/info.js index 35e067741..5a1eb3193 100644 --- a/src/public/javascripts/dialogs/info.js +++ b/src/public/javascripts/dialogs/info.js @@ -5,8 +5,11 @@ const $infoContent = $("#info-dialog-content"); const $okButton = $("#info-dialog-ok-button"); let resolve; +let $originallyFocused; // element focused before the dialog was opened so we can return to it afterwards function info(message) { + $originallyFocused = $(':focus'); + utils.closeActiveDialog(); glob.activeDialog = $dialog; @@ -24,6 +27,11 @@ $dialog.on("hidden.bs.modal", () => { if (resolve) { resolve(); } + + if ($originallyFocused) { + $originallyFocused.focus(); + $originallyFocused = null; + } }); $okButton.click(() => $dialog.modal("hide")); diff --git a/src/public/javascripts/services/branches.js b/src/public/javascripts/services/branches.js index fc2983f9d..dbcda42cf 100644 --- a/src/public/javascripts/services/branches.js +++ b/src/public/javascripts/services/branches.js @@ -6,6 +6,7 @@ import treeCache from "./tree_cache.js"; import treeUtils from "./tree_utils.js"; import hoistedNoteService from "./hoisted_note.js"; import noteDetailService from "./note_detail.js"; +import confirmDialog from "../dialogs/confirm.js"; async function moveBeforeNode(nodesToMove, beforeNode) { nodesToMove = await filterRootNote(nodesToMove); @@ -82,7 +83,7 @@ async function moveToNode(nodesToMove, toNode) { async function deleteNodes(nodes) { nodes = await filterRootNote(nodes); - if (nodes.length === 0 || !confirm('Are you sure you want to delete select note(s) and all the sub-notes?')) { + if (nodes.length === 0 || !await confirmDialog.confirm('Are you sure you want to delete select note(s) and all the sub-notes?')) { return false; }