Skip to content

Commit 4766d02

Browse files
committed
3.0.2b
1 parent 0f653c7 commit 4766d02

File tree

2 files changed

+26
-22
lines changed

2 files changed

+26
-22
lines changed

main.js

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ class ContinuousModePlugin extends obsidian.Plugin {
281281
if ( this.settings.disableScrollRootItemsIntoView === true ) { return }
282282
let offset = 0;
283283
switch(true) {
284-
case ( /metadata-/.test(el?.className) ): // scroll metadata/properties
284+
case ( /metadata-/.test(el?.className) ): // scroll metadata/properties
285285
case ( /metadata-/.test(e.target.className) ): // scroll metadata/properties
286286
getActiveEditor().containerEl.querySelector('.cm-active')?.classList.remove('cm-active'); // deselect editor active line
287287
switch(true) {
@@ -336,7 +336,7 @@ class ContinuousModePlugin extends obsidian.Plugin {
336336
},0);
337337
/*-----------------------------------------------*/
338338
// ARROW NAVIGATION between open leaves
339-
const leafArrowNavigation = (e) => { e.preventDefault();
339+
const leafArrowNavigation = (e) => { //e.preventDefault();
340340
let active_leaf = getActiveLeaf(), activeTabGroupChildren = workspace.activeTabGroup.children, active_el = document.activeElement, el = null;
341341
let active_editor = getActiveEditor(), cursor_anchor = active_editor?.getCursor('anchor');
342342
let is_compact_mode = isCompactMode();
@@ -355,7 +355,7 @@ class ContinuousModePlugin extends obsidian.Plugin {
355355
case e.target.querySelector('.canvas-node.is-focused') && /Arrow/.test(e.key): // editing canvas
356356
case e.target.querySelector('.workspace-leaf-content[data-set="graph"]') && /Arrow/.test(e.key) && e.shiftKey: return; // graph active; use shift key to move graph
357357
}
358-
if ( active_el?.classList.contains('cm-scroller') || !active_editor?.hasFocus() ) { active_editor?.focus(); }
358+
if ( (active_el?.classList.contains('cm-scroller') || !active_editor?.hasFocus()) && !/metadata-/.test(active_el.className) ) { active_editor?.focus(); }
359359
switch(e.key) {
360360
case 'ArrowUp': case 'ArrowLeft':
361361
switch(true) {
@@ -484,21 +484,21 @@ class ContinuousModePlugin extends obsidian.Plugin {
484484
);
485485
// warnings:
486486
switch(true) {
487-
case (/replace/.test(action)) && this.settings.disableWarnings !== true:
488-
return !window.confirm('You are about to replace all items in the active split. Are you sure you want to do this?'); // confirm replace open notes
487+
case (/replace/.test(action)) && this.settings.disableWarnings !== true
488+
&& !window.confirm('You are about to replace all items in the active split. Are you sure you want to do this?'): return; // confirm replace open notes
489489
case items.length > 99 && !window.confirm('You are about to open '+ items.length +'. Are you sure you want to do this?'): return; // warn on opening > 99 notes
490490
case items.length === 0: return alert(type === 'document links' ? 'No document links found.' : 'No readable files found.'); // alert no items found
491491
}
492492
switch(true) {
493493
case ( /replace/i.test(action) ): // close all leaves in active tab group only
494494
workspace.setActiveLeaf(recent_leaf,{focus:true});
495-
workspace.activeTabGroup.children.forEach( child => {
496-
sleep(10).then( () => { child.setPinned(false); child.detach(); });
495+
workspace.activeTabGroup.children.forEach( child => {
496+
sleep(50).then( () => { child.setPinned(false); child.detach(); });
497497
}); break;
498498
case ( /append/.test(action) ): // append folder items to active tab group
499499
if ( type === 'file' ) {
500-
open_leaves.forEach( leaf => { if ( leaf.getViewState().type === 'empty') { leaf.detach() } }); // remove empty leaf
501-
findDuplicateLeaves(open_leaves).forEach( leaf => sleep(10).then( () => { workspace.getLeafById(leaf.id)?.detach(); }) ); // close dupe notes
500+
open_leaves.forEach( leaf => { if ( leaf.getViewState().type === 'empty') { sleep(50).then( () => leaf.detach() )} }); // remove empty leaf
501+
findDuplicateLeaves(open_leaves).forEach( leaf => sleep(50).then( () => { workspace.getLeafById(leaf.id)?.detach(); }) ); // close dupe notes
502502
}
503503
items = items.filter( item => !open_files.includes(item) ); // no dupe notes
504504
workspace.iterateAllLeaves( child => { sleep(10).then( () => { child.setPinned(false); }); });
@@ -564,8 +564,8 @@ class ContinuousModePlugin extends obsidian.Plugin {
564564
}
565565
if ( /append|replace/.test(action) ) {
566566
sleep(100).then( () => {
567-
/compact/.test(action) ? workspace.rootSplit.children[0].children[0].containerEl?.click() : appended_leaf?.containerEl?.click();
568-
}) // click leaf
567+
/compact/.test(action) ? workspace.rootSplit.children[0].children[0].containerEl?.click() : appended_leaf?.containerEl?.click(); // click leaf
568+
});
569569
}
570570
resetPinnedLeaves(); // reset pinned status
571571
});
@@ -621,14 +621,15 @@ class ContinuousModePlugin extends obsidian.Plugin {
621621
let compact_mode_group = workspace.activeTabGroup?.children?.find(child => child?.tabHeaderEl?.className?.includes('is-active')) || workspace.rootSplit.children[0];
622622
let action = this.settings.allowSingleClickOpenFolderAction, path = '', items = null, active_leaf, active_compact_leaf;
623623
switch(true) {
624-
case e.target.classList.contains('continuous_mode_open_links_button'): // nobreak
625-
case e.target.closest('.continuous_mode_open_links_button') !== null: showLinksMenu(e); break; // open links in continuous mode
624+
case e.target.className.includes('metadata-'): break;
625+
case e.target.classList.contains('continuous_mode_open_links_button'): // nobreak
626+
case e.target.closest('.continuous_mode_open_links_button') !== null: showLinksMenu(e); break; // open links in continuous mode
626627
case e.target.closest('.workspace-tabs.is_compact_mode') !== null // compact mode: open in right split on tab click
627628
&& e.target.closest('.workspace-tab-header-new-tab') === null && e.target.closest('.workspace-tab-header-tab-list') === null:
628-
active_compact_leaf = workspace.getActiveViewOfType(obsidian.View)?.leaf;
629-
if ( active_compact_leaf.parent.containerEl.classList.contains('is_compact_mode') ) { openInRightSplit(e,active_compact_leaf?.view?.file); }
630-
scrollItemsIntoView(e);
631-
workspace.setActiveLeaf(active_compact_leaf,{focus:true})
629+
active_compact_leaf = workspace.getActiveViewOfType(obsidian.View)?.leaf;
630+
if ( active_compact_leaf.parent.containerEl.classList.contains('is_compact_mode') ) { openInRightSplit(e,active_compact_leaf?.view?.file); }
631+
scrollItemsIntoView(e);
632+
workspace.setActiveLeaf(active_compact_leaf,{focus:true})
632633
break;
633634
case ( e.target.closest('.nav-file.tree-item') !== null && this.settings.allowSingleClickOpenFolder === true ) // open file explorer files on single click
634635
&& !e.altKey && !e.ctrlKey && !e.shiftKey && e.button !== 2
@@ -652,7 +653,8 @@ class ContinuousModePlugin extends obsidian.Plugin {
652653
}); // nobreak
653654
case ( e.target.closest('.workspace-leaf')?.classList.contains('mod-active') && e.target.closest('.workspace-tabs')?.classList.contains('is_continuous_mode') ):
654655
case ( /workspace-tab-header|nav-header|view-header-title-container/.test(e.target.className) && workspace.activeTabGroup.containerEl.classList.contains('is_continuous_mode') ):
655-
workspace.setActiveLeaf(getActiveLeaf(),{focus:true}); scrollItemsIntoView(e); break; // click tab, scroll into view
656+
workspace.setActiveLeaf(getActiveLeaf(),{focus:true});
657+
scrollItemsIntoView(e); break; // click tab, scroll into view
656658
}
657659
});
658660
this.registerDomEvent(window,'mousedown', (e) => {
@@ -708,7 +710,7 @@ class ContinuousModePlugin extends obsidian.Plugin {
708710
continuous_mode_open_links_button.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-chevron-down"><path d="m6 9 6 6 6-6"/></svg>';
709711
}
710712
});
711-
this.registerDomEvent(document,'keydown', (e) => {
713+
this.registerDomEvent(window,'keydown', (e) => {
712714
if ( /Arrow/.test(e.key) && !e.altKey && !e.ctrlKey && !e.metaKey && !e.shiftKey ) {
713715
leafArrowNavigation(e);
714716
}
@@ -833,12 +835,14 @@ class ContinuousModePlugin extends obsidian.Plugin {
833835
.addItem((item6) => {
834836
item6.setTitle('Open or append '+type+' in active tab group')
835837
.setIcon('appendFolder')
836-
.onClick(async () => { openItemsInContinuousMode(file,'append',type); })
838+
.onClick(async () => {
839+
openItemsInContinuousMode(file,'append',type); })
837840
})
838841
.addItem((item7) => {
839842
item7.setTitle('Replace active tab group with '+type)
840843
.setIcon('replaceFolder')
841-
.onClick(async () => { openItemsInContinuousMode(file,'replace',type) })
844+
.onClick(async () => {
845+
openItemsInContinuousMode(file,'replace',type) })
842846
})
843847
.addSeparator()
844848
.addItem((item2) => {

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "continuous-mode",
33
"name": "Continuous Mode",
4-
"version": "3.0.1b",
4+
"version": "3.0.2b",
55
"minAppVersion": "0.15.0",
66
"description": "Displays all open notes in a tab group as if they were a continuous scrollable document (sometimes called \"Scrivenings mode\"). Open all notes in Continuous Mode from a folder, search results, or links in a file or Dataview/query block; use arrow keys to navigate between notes; display notes in “Compact Mode” similar to Evernote or Bear; reorder notes via tab header drag-and-drop, sorting, more.",
77
"author": "Michael Schrauzer",

0 commit comments

Comments
 (0)