Skip to content

Commit

Permalink
feat(List/Matrix View): ✨ Setting to open matrixView in left or right…
Browse files Browse the repository at this point in the history
… side onLoad
  • Loading branch information
SkepticMystic committed Aug 10, 2021
1 parent fa323b8 commit c56d3dc
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
22 changes: 21 additions & 1 deletion src/BreadcrumbsSettingTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ import {
PluginSettingTab,
Setting,
} from "obsidian";
import { ALLUNLINKED, REAlCLOSED, RELATIONS, VISTYPES } from "src/constants";
import {
ALLUNLINKED,
REAlCLOSED,
RELATIONS,
VIEW_TYPE_BREADCRUMBS_MATRIX,
VISTYPES,
} from "src/constants";
import type { Relations, visTypes } from "src/interfaces";
import type BreadcrumbsPlugin from "src/main";
import { isInVault, splitAndTrim } from "src/sharedFunctions";
Expand Down Expand Up @@ -158,6 +164,20 @@ export class BreadcrumbsSettingTab extends PluginSettingTab {
})
);

new Setting(MLViewDetails)
.setName("Open View in Right or Left side")
.setDesc(
"When loading the matrix view, should it open on the left or right side leaf? On = Right, Off = Left."
)
.addToggle((toggle) =>
toggle.setValue(plugin.settings.rlLeaf).onChange(async (value) => {
plugin.settings.rlLeaf = value;
await plugin.saveSettings();
await plugin.getActiveMatrixView()?.onClose();
await plugin.initMatrixView(VIEW_TYPE_BREADCRUMBS_MATRIX);
})
);

const trailDetails: HTMLDetailsElement = containerEl.createEl("details");
trailDetails.createEl("summary", { text: "Trail/Grid" });

Expand Down
1 change: 1 addition & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface BreadcrumbsSettings {
defaultView: boolean;
showNameOrType: boolean;
showRelationType: boolean;
rlLeaf: boolean;
showTrail: boolean;
trailOrTable: 1 | 2 | 3;
gridDots: boolean;
Expand Down
16 changes: 12 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const DEFAULT_SETTINGS: BreadcrumbsSettings = {
defaultView: true,
showNameOrType: true,
showRelationType: true,
rlLeaf: true,
showTrail: true,
trailOrTable: 3,
gridDots: false,
Expand Down Expand Up @@ -417,10 +418,17 @@ export default class BreadcrumbsPlugin extends Plugin {
await leaf.setViewState({ type: "empty" });
break;
}
(leaf ?? this.app.workspace.getRightLeaf(false)).setViewState({
type,
active: false,
});
if (this.settings.rlLeaf) {
(leaf ?? this.app.workspace.getRightLeaf(false)).setViewState({
type,
active: false,
});
} else {
(leaf ?? this.app.workspace.getLeftLeaf(false)).setViewState({
type,
active: false,
});
}
};

initStatsView = async (type: string): Promise<void> => {
Expand Down

0 comments on commit c56d3dc

Please sign in to comment.