Skip to content

Commit

Permalink
2.1.2
Browse files Browse the repository at this point in the history
Minor fixes.
  • Loading branch information
gasparschott committed Jul 30, 2024
1 parent 4113b41 commit c48238b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
20 changes: 9 additions & 11 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ class ContinuousModePlugin extends obsidian.Plugin {
// SCROLL ACTIVE LEAF INTO VIEW
const scrollActiveLeafIntoView = obsidian.debounce( (bool) => {
let active_leaf = getActiveLeaf();
if ( !active_leaf || active_leaf.containerEl.closest('.is_continuous_mode') === null ) { return }
if ( bool === false || this.settings.disableScrollActiveLeafIntoView === false ) {
if ( !active_leaf || !active_leaf?.containerEl?.closest('.is_continuous_mode') ) { return }
if ( !bool || !this.settings.disableScrollActiveLeafIntoView ) {
active_leaf.containerEl.closest('.workspace-tab-container')
.scrollTo({top:Number(active_leaf.containerEl?.offsetTop) - Number(active_leaf.containerEl.querySelector('.view-header')?.offsetHeight) - 2,behavior:'smooth'});
active_leaf.tabHeaderEl.scrollIntoView({ behavior:"instant", inline:"nearest" });
Expand All @@ -172,7 +172,8 @@ class ContinuousModePlugin extends obsidian.Plugin {
// ARROW NAVIGATION between open leaves
const leafArrowNavigation = (e) => {
switch(true) { // Ignore arrow navigation function in these cases:
case ( /input|textarea/.test(document.activeElement.tagName.toLowerCase())): // input or textarea
case !getActiveLeaf()?.containerEl?.closest('.workspace-tabs')?.classList.contains('is_continuous_mode'):
case ( /input|textarea/.test(document?.activeElement?.tagName?.toLowerCase())): // input or textarea
case getActiveLeaf()?.containerEl?.closest('.mod-root') === null && !getActiveEditor()?.hasFocus(): // not in leaf editor or editor not focussed
case e.target.querySelector('.canvas-node.is-focused') && /Arrow/.test(e.key): // editing canvas
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
Expand Down Expand Up @@ -201,7 +202,6 @@ class ContinuousModePlugin extends obsidian.Plugin {
if ( active_leaf.containerEl.previousSibling !== null ) { // ignore if first leaf
workspace.setActiveLeaf(activeTabGroupChildren[activeTabGroupChildren.indexOf(active_leaf) - 1],{focus:true}); // make previous leaf active
getActiveEditor()?.setCursor({line:getActiveEditor().lastLine(),ch:getActiveEditor().lastLine().length - 1}); // select last char
scrollActiveLeafIntoView(false);
}
break;
}
Expand All @@ -221,13 +221,12 @@ class ContinuousModePlugin extends obsidian.Plugin {
case active_leaf.getViewState().state.mode === 'preview': // leaf is in preview mode
case (!/markdown/.test(active_leaf.getViewState().type)): // make next leaf active
workspace.setActiveLeaf((activeTabGroupChildren[activeTabGroupChildren.indexOf(active_leaf) + 1] || active_leaf),{focus:true});
scrollActiveLeafIntoView(false);
break;
}
break;
}
const pos = { line:getActiveEditor()?.getCursor().line, ch:getActiveEditor()?.getCursor().ch } || { line:0,ch:0 };
if ( e.target?.cmView && this.settings.disableScrollActiveLeafIntoView === true ) { return } else { getActiveEditor()?.scrollIntoView({to:pos,from:pos},true); }
if ( e.target?.cmView && this.settings.disableScrollActiveLeafIntoView === true ) { return } else { getActiveEditor()?.scrollIntoView({to:pos,from:pos},true); } // "typewriter scroll"
}
// PDF PAGE NAVIGATION
function pdfPageNavigation(e) {
Expand Down Expand Up @@ -317,7 +316,6 @@ class ContinuousModePlugin extends obsidian.Plugin {
case 'byCreatedTimeReverse': items.sort((a,b) => a?.stat.ctime - b?.stat.ctime); break;
case 'none': break; // no sort
}
console.log(items.forEach(item => console.log(item.name)))
// open sorted items:
for ( let i = 0; i < maximumItemsToOpen && i < items.length; i++ ) { // limit number of items to open
active_split = workspace.getLeaf(); // open new tab/leaf
Expand Down Expand Up @@ -432,7 +430,7 @@ console.log(items.forEach(item => console.log(item.name)))
}
});
this.registerDomEvent(document,'keydown', (e) => {
if ( /Arrow/.test(e.key) && !e.altKey && !e.ctrlKey && !e.metaKey && !e.shiftKey && workspace.getActiveViewOfType(obsidian.View).getViewType() !== 'file-explorer' && getActiveLeaf().containerEl.closest('.workspace-tabs')?.classList.contains('is_continuous_mode') ) {
if ( /Arrow/.test(e.key) && !e.altKey && !e.ctrlKey && !e.metaKey && !e.shiftKey ) {
leafArrowNavigation(e);
}
});
Expand Down Expand Up @@ -590,7 +588,7 @@ console.log(items.forEach(item => console.log(item.name)))
this.app.workspace.on('editor-menu', (menu,editor/*,info*/) => { // on editor-menu
menu.addItem((item) => {
let links = getDocumentLinks('document links',editor.editorComponent.view.file,editor.editorComponent.view.leaf), files = getFilesFromLinks(links);
addContinuousModeMenuItem(item,editor?.containerEl?.closest('.workspace-tabs').dataset.tab_group_id) // add continuous mode items
addContinuousModeMenuItem(item,editor?.containerEl?.closest('.workspace-tabs')?.dataset?.tab_group_id) // add continuous mode items
openItemsInContinuousModeMenuItems(item,files,'document links') // add open document links items
});
})
Expand Down Expand Up @@ -623,7 +621,7 @@ console.log(items.forEach(item => console.log(item.name)))
default:
menu.addItem((item) => { // file menu
links = getDocumentLinks('document links',file,leaf), files = getFilesFromLinks(links);
addContinuousModeMenuItem(item,leaf?.containerEl?.closest('.workspace-tabs').dataset.tab_group_id, leaf, links) // add continuous mode items
addContinuousModeMenuItem(item,leaf?.containerEl?.closest('.workspace-tabs')?.dataset?.tab_group_id, leaf, links) // add continuous mode items
openItemsInContinuousModeMenuItems(item,files,'document links'); // add open document links items
}); break;
}
Expand All @@ -639,7 +637,7 @@ console.log(items.forEach(item => console.log(item.name)))
)
this.registerEvent(
this.app.workspace.on('tab-group-menu', (menu,tab_group) => { // on tab-group-menu
menu.addItem((item) => { addContinuousModeMenuItem(item,tab_group.containerEl?.dataset.tab_group_id) });
menu.addItem((item) => { addContinuousModeMenuItem(item,tab_group?.containerEl?.dataset?.tab_group_id) });
})
);
this.registerEvent(
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "continuous-mode",
"name": "Continuous Mode",
"version": "2.1.1",
"version": "2.1.2",
"minAppVersion": "0.15.0",
"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; reorder notes via tab header drag-and-drop, sorting, more.",
"author": "Michael Schrauzer",
Expand Down
1 change: 1 addition & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
.workspace-tabs.is_continuous_mode:not(.mod-stacked) .workspace-leaf:has(div[data-type="canvas"]),
.workspace-tabs.is_continuous_mode:not(.mod-stacked) .workspace-leaf:has(div[data-type="graph"]),
.workspace-tabs.is_continuous_mode:not(.mod-stacked) .workspace-leaf:has(div[data-type="html-view"]),
.workspace-tabs.is_continuous_mode:not(.mod-stacked) .workspace-leaf:has(div[data-type="surfing-view"]),
.workspace-tabs.is_continuous_mode:not(.mod-stacked) .workspace-leaf:has(div[data-type="pdf"]),
.workspace-tabs.is_continuous_mode:not(.mod-stacked) .workspace-leaf-content[data-type="pdf"],
.workspace-tabs.is_continuous_mode:not(.mod-stacked) .pdf-container,
Expand Down

0 comments on commit c48238b

Please sign in to comment.