diff --git a/src/BreadcrumbsSettingTab.ts b/src/BreadcrumbsSettingTab.ts index 0024a5e7..20b899f3 100644 --- a/src/BreadcrumbsSettingTab.ts +++ b/src/BreadcrumbsSettingTab.ts @@ -937,6 +937,20 @@ export class BCSettingTab extends PluginSettingTab { }) ); + const threadingDetails = subDetails("Threading", cmdsDetails); + + threadingDetails.createDiv({ + text: "Settings for the commands `Create new from current note`", + }); + new Setting(threadingDetails) + .setName("Open new threads in new pane or current pane") + .addToggle((tog) => + tog.onChange(async (value) => { + settings.threadIntoNewPane = value; + await plugin.saveSettings(); + }) + ); + const debugDetails = details("Debugging"); new Setting(debugDetails) diff --git a/src/constants.ts b/src/constants.ts index af321a50..57bc0028 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -182,6 +182,7 @@ export const DEFAULT_SETTINGS: BCSettings = { limitJumpToFirstFields: [], showAll: false, noPathMessage: `This note has no real or implied parents`, + threadIntoNewPane: false, trailSeperator: "→", treatCurrNodeAsImpliedSibling: false, trimDendronNotes: false, diff --git a/src/interfaces.ts b/src/interfaces.ts index efd6b59e..8ef7aa49 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -57,6 +57,7 @@ export interface BCSettings { showRefreshNotice: boolean; showTrail: boolean; squareDirectionsOrder: (0 | 1 | 2 | 3 | 4)[]; + threadIntoNewPane: boolean; trailSeperator: string; treatCurrNodeAsImpliedSibling: boolean; trimDendronNotes: boolean; diff --git a/src/main.ts b/src/main.ts index 2335ac3b..ba5c1fe8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -432,7 +432,7 @@ export default class BCPlugin extends Plugin { const currFile = app.workspace.getActiveFile(); if (!currFile) return; - const newFilePath = app.fileManager.getNewFileParent(currFile.path); + const newFileParent = app.fileManager.getNewFileParent(currFile.path); const oppField = getOppFields(userHiers, field)[0] ?? @@ -440,7 +440,7 @@ export default class BCPlugin extends Plugin { const newFile = await app.vault.create( normalizePath( - `${newFilePath.path}/${field} of ${currFile.basename}.md` + `${newFileParent.path}/${field} of ${currFile.basename}.md` ), writeBCsInline ? `${oppField}:: [[${currFile.basename}]]` @@ -475,7 +475,12 @@ export default class BCPlugin extends Plugin { await app.vault.modify(currFile, content); } - app.workspace.activeLeaf.openFile(newFile); + + if (settings.threadIntoNewPane) { + const splitLeaf = app.workspace.splitActiveLeaf(); + app.workspace.setActiveLeaf(splitLeaf, false, false); + splitLeaf.openFile(newFile); + } else app.workspace.activeLeaf.openFile(newFile); }, }); });