diff --git a/TagFolderViewComponent.svelte b/TagFolderViewComponent.svelte index b707ead..8b07e61 100644 --- a/TagFolderViewComponent.svelte +++ b/TagFolderViewComponent.svelte @@ -274,6 +274,9 @@ } $: isMainTree = tags.length == 0; let scrollParent: HTMLDivElement; + + const componentHash = `${Math.random()}`; + setContext("viewID", componentHash);
diff --git a/V2TreeFolderComponent.svelte b/V2TreeFolderComponent.svelte index bbc7666..934cab8 100644 --- a/V2TreeFolderComponent.svelte +++ b/V2TreeFolderComponent.svelte @@ -40,7 +40,7 @@ import { collectTreeChildren, performSortExactFirst } from "./v2codebehind"; import TreeItemItemComponent from "V2TreeItemComponent.svelte"; import OnDemandRender from "OnDemandRender.svelte"; - import { tick } from "svelte"; + import { getContext, tick } from "svelte"; // -- Props -- @@ -516,8 +516,9 @@ isUpdating = false; }); } + const viewContextID = `${getContext("viewID") ?? ""}`; $: { - const key = trailKey + (isRoot ? "-r" : "-x"); + const key = trailKey + (isRoot ? "-r" : "-x") + viewContextID; const param = { key, expandLimit, diff --git a/main.ts b/main.ts index 1dbdd07..f7a36f1 100644 --- a/main.ts +++ b/main.ts @@ -34,7 +34,8 @@ import { VIEW_TYPE_TAGFOLDER_LIST, type ViewItem, VIEW_TYPE_TAGFOLDER_LINK, - type FileCache + type FileCache, + enumShowListIn } from "types"; import { allViewItems, allViewItemsByLink, appliedFiles, currentFile, maxDepth, searchString, selectedTags, tagFolderSetting, tagInfo } from "store"; import { @@ -1109,10 +1110,21 @@ export default class TagFolderPlugin extends Plugin { // Cancel if the tagfolder has been disappeared. return; } - if (!Platform.isMobile) { - theLeaf = this.app.workspace.createLeafBySplit(parent, "horizontal", false); - } else { - theLeaf = this.app.workspace.getLeftLeaf(false); + switch (this.settings.showListIn) { + case "CURRENT_PANE": + theLeaf = this.app.workspace.getLeaf(); + break; + case "SPLIT_PANE": + theLeaf = this.app.workspace.getLeaf("split", "horizontal"); + break; + case "": + default: + if (!Platform.isMobile) { + theLeaf = this.app.workspace.createLeafBySplit(parent, "horizontal", false); + } else { + theLeaf = this.app.workspace.getLeftLeaf(false); + } + break; } } const title = tags.map((e) => @@ -1126,7 +1138,6 @@ export default class TagFolderPlugin extends Plugin { active: true, state: { tags: tags, title: title } as TagFolderListState }); - // (theLeaf.view as TagFolderList).setTreeRoot(this.root); this.app.workspace.revealLeaf( theLeaf @@ -1386,6 +1397,18 @@ class TagFolderSettingTab extends PluginSettingTab { await this.plugin.saveSettings(); }); }); + new Setting(containerEl) + .setName("Show list in") + .setDesc("This option applies to the newly opened list") + .addDropdown((dropdown) => { + dropdown + .addOptions(enumShowListIn) + .setValue(this.plugin.settings.showListIn) + .onChange(async (value) => { + this.plugin.settings.showListIn = value as keyof typeof enumShowListIn; + await this.plugin.saveSettings(); + }); + }); containerEl.createEl("h3", { text: "Arrangements" }); new Setting(containerEl) diff --git a/types.ts b/types.ts index 2a59f10..af73f2f 100644 --- a/types.ts +++ b/types.ts @@ -36,6 +36,11 @@ export type LinkParseConf = { key: string } } +export const enumShowListIn = { + "": "Sidebar", + "CURRENT_PANE": "Current pane", + "SPLIT_PANE": "New pane", +} export interface TagFolderSettings { displayMethod: DISPLAY_METHOD; @@ -80,7 +85,7 @@ export interface TagFolderSettings { linkConfig: LinkParseConf; linkShowOnlyFDR: boolean; linkCombineOtherTree: boolean; - + showListIn: keyof typeof enumShowListIn; } export const DEFAULT_SETTINGS: TagFolderSettings = { @@ -125,6 +130,7 @@ export const DEFAULT_SETTINGS: TagFolderSettings = { }, linkShowOnlyFDR: true, linkCombineOtherTree: true, + showListIn: "" }; export const VIEW_TYPE_SCROLL = "tagfolder-view-scroll";