Skip to content

Commit f024b44

Browse files
committed
Add notice about templater plugin
1 parent ecc8dc2 commit f024b44

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/suggesters/TemplateSuggester.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import { TAbstractFile, TFile, TFolder, Vault, AbstractInputSuggest } from 'obsi
22
import FolderNotesPlugin from '../main';
33
import { getTemplatePlugins } from 'src/template';
44
export enum FileSuggestMode {
5-
TemplateFiles,
6-
ScriptFiles,
5+
TemplateFiles,
6+
ScriptFiles,
77
}
88

99
export class TemplateSuggest extends AbstractInputSuggest<TFile> {
1010
constructor(
11-
public inputEl: HTMLInputElement,
12-
public plugin: FolderNotesPlugin
11+
public inputEl: HTMLInputElement,
12+
public plugin: FolderNotesPlugin
1313
) {
1414
super(plugin.app, inputEl);
1515
}
@@ -35,15 +35,22 @@ export class TemplateSuggest extends AbstractInputSuggest<TFile> {
3535
file.path.toLowerCase().includes(lower_input_str)
3636
);
3737
} else {
38-
let folder: TFolder;
38+
let folder: TFolder | TAbstractFile | null = null;
3939
if (templaterPlugin) {
4040
folder = this.plugin.app.vault.getAbstractFileByPath(
4141
templaterPlugin.plugin?.settings?.templates_folder as string
42-
) as TFolder;
42+
);
43+
if (!(folder instanceof TFolder)) {
44+
return [{ path: '', name: 'You need to set the Templates folder in the Templater settings first.' } as TFile];
45+
}
4346
} else {
4447
folder = this.plugin.app.vault.getAbstractFileByPath(templateFolder) as TFolder;
4548
}
4649

50+
if (!(folder instanceof TFolder)) {
51+
return [];
52+
}
53+
4754
Vault.recurseChildren(folder, (file: TAbstractFile) => {
4855
if (file instanceof TFile && file.path.toLowerCase().includes(lower_input_str)) {
4956
files.push(file);

0 commit comments

Comments
 (0)