diff --git a/main.js b/main.js index b1cbb91..2f78e94 100644 --- a/main.js +++ b/main.js @@ -96,18 +96,16 @@ class ContinuousModePlugin extends obsidian.Plugin { // REARRANGE LEAVES on dragend const rearrangeLeaves = (e,initialTabHeaderIndex) => { let this_tab_container = e.target.closest('.workspace-tabs').querySelector('.workspace-tab-container'); // get current tab container - let leaves = Array.from(this_tab_container.querySelectorAll('.workspace-leaf')); // get current tab container leaves + let leaves = Array.from(this_tab_container.children); // get current tab container leaves let finalTabHeaderIndex = getTabHeaderIndex(e); // get final dropped tab header index - let rearranged = ''; // define rearranged leaves variable let moved = leaves.splice(initialTabHeaderIndex,1); // get the moved leave - leaves.toSpliced(finalTabHeaderIndex,0,moved[0]); // move the moved leaf into position - leaves.forEach( leaf => rearranged += leaf.outerHTML ); // compose rearranged HTML - this_tab_container.innerHTML = rearranged; // replace tab container content with rearranged leaves + let rearranged = leaves.toSpliced(finalTabHeaderIndex,0,moved[0]); // move the moved leaf into position + this_tab_container.setChildrenInPlace(rearranged); // replace tab container content with rearranged leaves getTabGroupHeaders()[finalTabHeaderIndex].click(); // confirm drag and focus leaf by clicking tab } // ARROW NAVIGATION between open leaves const leafArrowNavigation = (e) => { - if ( getActiveLeaf().containerEl.closest('.workspace-split.mod-root') === null ) { return; } // return if not in leaf editor + if ( getActiveLeaf().containerEl.closest('.workspace-split.mod-root') === null || !getActiveEditor()?.hasFocus() ) { return; } // return if not in leaf editor or editor not focussed let cursorAnchor = getActiveEditor()?.getCursor('anchor'); let activeTabGroupChildren = getActiveLeaf().workspace.activeTabGroup.children; switch(true) { diff --git a/manifest.json b/manifest.json index 00e434c..d7aeadd 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "name": "Continuous Mode", "version": "1.0.0", "minAppVersion": "0.15.0", - "description": "Displays all open notes (or \"leaves\") in a tab group as a continuous scrollable \"page\" (sometimes called \"Scrivenings mode\"). Features include arrow navigation between notes and the ability to reorder notes via tab header drag-and-drop.", + "description": "Displays all open notes (or \"leaves\") in a tab group as a continuous scrollable document (sometimes called \"Scrivenings mode\"). Features include arrow navigation between notes and the ability to reorder notes via tab header drag-and-drop.", "author": "Michael Schrauzer", "authorURL": "https://github.com/gasparschott/", "fundingUrl": "https://www.buymeacoffee.com/fiLtliTFxQ",