diff --git a/manifest.json b/manifest.json index d99ed3e..6ca0f61 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "quickadd", "name": "QuickAdd", - "version": "0.1.6", + "version": "0.1.7", "minAppVersion": "0.12.00", "description": "Quickly add new pages or content to your vault.", "author": "Christian B. B. Houmann", diff --git a/package.json b/package.json index 1ec459f..d1509cc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "quickadd", - "version": "0.1.6", + "version": "0.1.7", "description": "Quickly add new pages or content to your vault.", "main": "main.js", "scripts": { diff --git a/src/engine/CaptureChoiceEngine.ts b/src/engine/CaptureChoiceEngine.ts index 2772a29..a3b733d 100644 --- a/src/engine/CaptureChoiceEngine.ts +++ b/src/engine/CaptureChoiceEngine.ts @@ -44,6 +44,8 @@ export class CaptureChoiceEngine extends QuickAddChoiceEngine { await this.app.vault.modify(file, newFileContent); } else { const formattedContent = await this.formatter.formatContent(content, this.choice); + if (!formattedContent) return; + const createdFile = await this.createFileWithInput(filePath, formattedContent); if (!createdFile) { @@ -56,7 +58,7 @@ export class CaptureChoiceEngine extends QuickAddChoiceEngine { appendToCurrentLine(`[[${filePath.replace(MARKDOWN_FILE_EXTENSION_REGEX, '')}]]`, this.app); } catch (e) { - log.logError(e); + log.logMessage(e); } } @@ -86,6 +88,7 @@ export class CaptureChoiceEngine extends QuickAddChoiceEngine { content = await this.formatter.formatContent(content, this.choice); } + if (!content) return; appendToCurrentLine(content, this.app); } } \ No newline at end of file diff --git a/src/formatters/completeFormatter.ts b/src/formatters/completeFormatter.ts index dbddf71..862f220 100644 --- a/src/formatters/completeFormatter.ts +++ b/src/formatters/completeFormatter.ts @@ -4,7 +4,6 @@ import {MARKDOWN_FILE_EXTENSION_REGEX} from "../constants"; import {getNaturalLanguageDates} from "../utility"; import GenericInputPrompt from "../gui/GenericInputPrompt/genericInputPrompt"; import GenericSuggester from "../gui/GenericSuggester/genericSuggester"; -import {log} from "../logger/logManager"; import type QuickAdd from "../main"; import {SingleMacroEngine} from "../engine/SingleMacroEngine"; import {SingleTemplateEngine} from "../engine/SingleTemplateEngine"; @@ -17,21 +16,16 @@ export class CompleteFormatter extends Formatter { } protected async format(input: string): Promise { - try { - let output: string = input; - - output = this.replaceDateInString(output); - output = await this.replaceValueInString(output); - output = await this.replaceDateVariableInString(output); - output = await this.replaceVariableInString(output); - output = await this.replaceMacrosInString(output); - output = await this.replaceTemplateInString(output); - - return output; - } - catch (e) { - log.logError(e); - } + let output: string = input; + + output = this.replaceDateInString(output); + output = await this.replaceValueInString(output); + output = await this.replaceDateVariableInString(output); + output = await this.replaceVariableInString(output); + output = await this.replaceMacrosInString(output); + output = await this.replaceTemplateInString(output); + + return output; } async formatFileName(input: string, valueHeader: string): Promise { @@ -65,7 +59,7 @@ export class CompleteFormatter extends Formatter { protected async promptForValue(header?: string): Promise { if (!this.value) - this.value = await GenericInputPrompt.Prompt(this.app, this.valueHeader ?? `Enter value`); + this.value = await GenericInputPrompt.Prompt(this.app, this.valueHeader ?? `Enter value`) return this.value; } diff --git a/src/gui/ChoiceBuilder/captureChoiceBuilder.ts b/src/gui/ChoiceBuilder/captureChoiceBuilder.ts index 11e3f35..25b2c25 100644 --- a/src/gui/ChoiceBuilder/captureChoiceBuilder.ts +++ b/src/gui/ChoiceBuilder/captureChoiceBuilder.ts @@ -1,7 +1,7 @@ import {ChoiceBuilder} from "./choiceBuilder"; import type ICaptureChoice from "../../types/choices/ICaptureChoice"; import type {App} from "obsidian"; -import {SearchComponent, Setting, TextAreaComponent, TextComponent, ToggleComponent} from "obsidian"; +import {Setting, TextAreaComponent, TextComponent, ToggleComponent} from "obsidian"; import {FormatSyntaxSuggester} from "../formatSyntaxSuggester"; import {FILE_NAME_FORMAT_SYNTAX, FORMAT_SYNTAX} from "../../constants"; import {FormatDisplayFormatter} from "../../formatters/formatDisplayFormatter"; diff --git a/versions.json b/versions.json index 5980de6..be94d26 100644 --- a/versions.json +++ b/versions.json @@ -1,3 +1,3 @@ { - "0.1.6": "0.12.4" + "0.1.7": "0.12.4" }