Skip to content

Commit

Permalink
feat: add option to open new file template in new pane
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinzent03 committed Apr 28, 2021
1 parent d31ee0e commit 500d24b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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 => {
Expand Down

0 comments on commit 500d24b

Please sign in to comment.