diff --git a/src/main.ts b/src/main.ts index 15c9ebb..bcc5bcb 100644 --- a/src/main.ts +++ b/src/main.ts @@ -181,10 +181,11 @@ export default class AutoClassifierPlugin extends Plugin { loadingIcon.addClass('loading-icon'); const loadingText = document.createElement('span'); loadingText.textContent = text; - + //@ts-ignore notice.noticeEl.empty(); loadingContainer.appendChild(loadingIcon); loadingContainer.appendChild(loadingText); + //@ts-ignore notice.noticeEl.appendChild(loadingContainer); return notice; diff --git a/src/settings.ts b/src/settings.ts index a7f4234..b0f4875 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -147,13 +147,13 @@ Assign your own shortcuts to run commands for different input types.` .setDesc('Choose the type of reference tag') .addDropdown((dropdown) => { dropdown - .addOption(ReferenceType.All, "All tags") - .addOption(ReferenceType.Filter, "Filtered tags",) - .addOption(ReferenceType.Manual, "Manual tags") - .setValue(commandOption.refType) + .addOption(String(ReferenceType.All), "All tags") + .addOption(String(ReferenceType.Filter), "Filtered tags",) + .addOption(String(ReferenceType.Manual), "Manual tags") + .setValue(String(commandOption.refType)) .onChange(async (refTye) => { - this.setRefType(refTye); - this.setRefs(refTye); + this.setRefType(parseInt(refTye)); + this.setRefs(parseInt(refTye)); this.display(); }); }); @@ -225,12 +225,12 @@ Assign your own shortcuts to run commands for different input types.` .setName('Output Tag Location') .setDesc('Specify where to put the output tag') .addDropdown((cb) => { - cb.addOption(OutLocation.FrontMatter, 'FrontMatter') - .addOption(OutLocation.Title, 'Title alternative') - .addOption(OutLocation.Cursor, 'Current cursor') - .setValue(commandOption.outLocation) + cb.addOption(String(OutLocation.FrontMatter), 'FrontMatter') + .addOption(String(OutLocation.Title), 'Title alternative') + .addOption(String(OutLocation.Cursor), 'Current cursor') + .setValue(String(commandOption.outLocation)) .onChange(async (value) => { - commandOption.outLocation = value; + commandOption.outLocation = parseInt(value); await this.plugin.saveSettings(); this.display(); }); diff --git a/src/view-manager.ts b/src/view-manager.ts index 2217159..3699b42 100644 --- a/src/view-manager.ts +++ b/src/view-manager.ts @@ -30,8 +30,8 @@ export class ViewManager { const activeView = this.app.workspace.getActiveViewOfType(MarkdownView); if (activeView) { const file = activeView.file; - const frontmatter: FrontMatterCache | undefined = this.app.metadataCache.getFileCache(file)?.frontmatter; - if (frontmatter && frontmatter.hasOwnProperty('position')) { + const frontmatter = this.app.metadataCache.getFileCache(file)?.frontmatter as Partial; + if (frontmatter?.position) { delete frontmatter.position; } return JSON.stringify(frontmatter); @@ -55,6 +55,7 @@ export class ViewManager { } async getTags(filterRegex?: string): Promise { + //@ts-ignore const tagsDict = this.app.metadataCache.getTags(); let tags = Object.keys(tagsDict); if (!tags || tags.length == 0) return null; @@ -92,6 +93,7 @@ export class ViewManager { async insertAtTitle(value: string, overwrite = false): Promise { const file = this.app.workspace.getActiveFile(); + if (!file) return; let newName = file.basename; if (overwrite) { newName = `${value}`;