From 500d24b7df593354a9083c15ae3c9c076884e72a Mon Sep 17 00:00:00 2001 From: Vinzent Date: Wed, 28 Apr 2021 07:32:39 +0200 Subject: [PATCH] feat: add option to open new file template in new pane --- src/main.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main.ts b/src/main.ts index 091a1d5..6a21503 100644 --- a/src/main.ts +++ b/src/main.ts @@ -14,12 +14,15 @@ interface HotkeysForTemplateSettings { files: string[], templaterFiles: string[], newFileTemplates: NewFileTemplate[]; + openNewFileTemplateInNewPane: boolean; } const DEFAULT_SETTINGS: HotkeysForTemplateSettings = { files: [], templaterFiles: [], - newFileTemplates: [] + newFileTemplates: [], + openNewFileTemplateInNewPane: true, + }; export default class HotkeysForTemplates extends Plugin { @@ -148,7 +151,7 @@ export default class HotkeysForTemplates extends Plugin { return; } const file = await (this.app.fileManager as any).createNewMarkdownFile(folder); - await this.app.workspace.getLeaf().openFile(file, { + await this.app.workspace.getLeaf(this.settings.openNewFileTemplateInNewPane).openFile(file, { active: true, state: { mode: "source" @@ -287,6 +290,16 @@ class SettingsTab extends PluginSettingTab { text: "Create a new file in a specified folder with a specified template" }); + new Setting(containerEl) + .setName("Open in new pane") + .addToggle(cb => { + cb.setValue(this.plugin.settings.openNewFileTemplateInNewPane); + cb.onChange(value => { + this.plugin.settings.openNewFileTemplateInNewPane = value; + this.plugin.saveSettings(); + }); + }); + new Setting(containerEl) .setName("Add new text field") .addButton(cb => {