diff --git a/src/BreadcrumbsSettingTab.ts b/src/BreadcrumbsSettingTab.ts index 16d467ad..ee9e98b2 100644 --- a/src/BreadcrumbsSettingTab.ts +++ b/src/BreadcrumbsSettingTab.ts @@ -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"; @@ -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" }); diff --git a/src/interfaces.ts b/src/interfaces.ts index 18b0fa6e..48169b78 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -10,6 +10,7 @@ export interface BreadcrumbsSettings { defaultView: boolean; showNameOrType: boolean; showRelationType: boolean; + rlLeaf: boolean; showTrail: boolean; trailOrTable: 1 | 2 | 3; gridDots: boolean; diff --git a/src/main.ts b/src/main.ts index dcd41c9f..b991251b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -36,6 +36,7 @@ const DEFAULT_SETTINGS: BreadcrumbsSettings = { defaultView: true, showNameOrType: true, showRelationType: true, + rlLeaf: true, showTrail: true, trailOrTable: 3, gridDots: false, @@ -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 => {