Skip to content

Commit

Permalink
1.5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
gasparschott committed Apr 23, 2024
1 parent 5a6f4f1 commit 615633a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
data.json
data.json
changelog.txt
assets/main.js
30 changes: 9 additions & 21 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,6 @@ class ContinuousModePlugin extends obsidian.Plugin {
this.addSettingTab(new ContinuousModeSettings(this.app, this));
/* ----------------------- */
// HELPERS
const OLDgetAllTabGroups = () => {
let root_tab_children = this.app.workspace.rootSplit?.children, root_tab_groups = []; // get rootSplit children
root_tab_children?.forEach( child => {
if ( child.type === 'split' ) { root_tab_groups.push(...child.children) } else { root_tab_groups.push(child) } // get rootSplit tab groups
});
let floating_windows = this.app.workspace.floatingSplit?.children || [], floating_window_tab_groups = []; // get floating windows
floating_windows?.forEach(floating_window => {
floating_window.children?.forEach( child => {
if ( child.type === 'split' ) { floating_window_tab_groups.push(...child.children) } else { floating_window_tab_groups.push(child) } // get floating tab groups
});
});
let all_tab_groups = floating_window_tab_groups.concat(root_tab_groups);
all_tab_groups = [...new Set(all_tab_groups)].filter(Boolean);
return all_tab_groups;
}
const getAllTabGroups = () => {
let nodes = (this.app.workspace.floatingSplit?.children || []).concat(this.app.workspace.rootSplit?.children || []);
let all_tab_groups = [];
Expand All @@ -49,8 +34,11 @@ class ContinuousModePlugin extends obsidian.Plugin {
}
return all_tab_groups;
}


const getAllLeaves = () => {
let all_leaves = [];
getAllTabGroups().forEach(tab_group => { all_leaves.push(...tab_group.children) })
return all_leaves;
}
const this_workspace = this.app.workspace;
const getActiveTabGroup = () => { return this_workspace.activeTabGroup; }
const getTabGroupByDataId = (id) => { return getAllTabGroups()?.find( tab_group => tab_group.containerEl.dataset.tab_group_id === id ); }
Expand Down Expand Up @@ -234,7 +222,7 @@ class ContinuousModePlugin extends obsidian.Plugin {
case items.every( item => ( !included_extensions.test(item.extension) || this.settings.excludedNames.some( name => { return RegExp(name,'m').test(item.name) } ) ) ):
return alert('No readable files in folder.'); // no readable files
}
this_workspace.iterateRootLeaves( leaf => { // pin tabs to prevent tab reuse, i.e., coerce new tab creation
getAllLeaves().forEach( leaf => { // pin tabs to prevent tab reuse, i.e., coerce new tab creation
if ( leaf.pinned === true ) { pinned_tabs.push(leaf.id) } else { leaf.setPinned(true) } // make list of already pinned tabs or pin all unpinned tabs
});
switch(true) {
Expand Down Expand Up @@ -275,7 +263,7 @@ class ContinuousModePlugin extends obsidian.Plugin {
active_split.setPinned(true); // pin new tab/leaf to prevent Obsidian reusing it to open next file in loop
}
});
this_workspace.iterateRootLeaves( leaf => {
getAllLeaves().forEach( leaf => {
if ( !pinned_tabs.includes(leaf.id) ) { leaf.setPinned(false); } // unpin all tabs, except for originally pinned tabs
});
getActiveTabGroup().containerEl.dataset.sort_order = sort_order;
Expand All @@ -295,7 +283,7 @@ class ContinuousModePlugin extends obsidian.Plugin {
case 'byCreatedTime': sorted = items.toSorted((a,b) => b.view.file.stat.ctime - a.view.file.stat.ctime); break;
case 'byCreatedTimeReverse': sorted = items.toSorted((a,b) => a.view.file.stat.ctime - b.view.file.stat.ctime); break;
}
this_workspace.iterateRootLeaves( leaf => { // pin tabs to prevent tab reuse, i.e., coerce new tab creation
getAllLeaves().forEach( leaf => { // pin tabs to prevent tab reuse, i.e., coerce new tab creation
if ( leaf.pinned === true ) { pinned_tabs.push(leaf.id) } else { leaf.setPinned(true) } // make list of already pinned tabs or pin all unpinned tabs
});
this_workspace.setActiveLeaf(active_tab_group.children[0],{focus:true});
Expand All @@ -310,7 +298,7 @@ class ContinuousModePlugin extends obsidian.Plugin {
active_split.openFile(item.view.file); // open file
active_split.setPinned(true); // pin new tab/leaf to prevent Obsidian reusing it to open next file in loop
});
this_workspace.iterateRootLeaves( leaf => {
getAllLeaves().forEach( leaf => {
if ( !pinned_tabs.includes(leaf.id) ) { leaf.setPinned(false); } // unpin all tabs, except for originally pinned tabs
});
active_tab_group.containerEl.dataset.sort_order = sort_order;
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": "1.5.4",
"version": "1.5.5",
"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\"). Features include open all notes in a folder, arrow navigation between notes, reorder notes via tab header drag-and-drop, sorting, more.",
"author": "Michael Schrauzer",
Expand Down
4 changes: 4 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,8 @@
{
content:'• ';
color:var(--text-normal);
}
/* hide conditionally displayed menu items */
div.menu-item:has(.menu-item-title:empty) {
display:none !important;
}

0 comments on commit 615633a

Please sign in to comment.