mirror of
https://github.com/taskgenius/taskgenius-plugin.git
synced 2026-07-22 06:40:25 +00:00
fix: quick capture path issue
This commit is contained in:
parent
8a3fda288b
commit
339f637a4c
3 changed files with 11053 additions and 4 deletions
|
|
@ -24,6 +24,10 @@ export function renderQuickCaptureSettingsTab(
|
|||
settingTab.plugin.settings.quickCapture.enableQuickCapture =
|
||||
value;
|
||||
settingTab.applySettingsUpdate();
|
||||
|
||||
setTimeout(() => {
|
||||
settingTab.display();
|
||||
}, 200);
|
||||
})
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,25 @@ import { App, getFrontMatterInfo, TFile } from "obsidian";
|
|||
import { QuickCaptureOptions } from "../editor-ext/quickCapture";
|
||||
import { moment } from "obsidian";
|
||||
|
||||
/**
|
||||
* Get template file with automatic .md extension detection
|
||||
* @param app - Obsidian app instance
|
||||
* @param templatePath - Template file path (may or may not include .md extension)
|
||||
* @returns TFile instance if found, null otherwise
|
||||
*/
|
||||
function getTemplateFile(app: App, templatePath: string): TFile | null {
|
||||
// First try the original path
|
||||
let templateFile = app.vault.getFileByPath(templatePath);
|
||||
|
||||
if (!templateFile && !templatePath.endsWith(".md")) {
|
||||
// If not found and doesn't end with .md, try adding .md extension
|
||||
const pathWithExtension = `${templatePath}.md`;
|
||||
templateFile = app.vault.getFileByPath(pathWithExtension);
|
||||
}
|
||||
|
||||
return templateFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize filename by replacing unsafe characters with safe alternatives
|
||||
* This function only sanitizes the filename part, not directory separators
|
||||
|
|
@ -128,17 +147,20 @@ export async function saveCapture(
|
|||
|
||||
// If it's a daily note and has a template, use the template
|
||||
if (targetType === "daily-note" && dailyNoteSettings?.template) {
|
||||
const templateFile = app.vault.getFileByPath(
|
||||
const templateFile = getTemplateFile(
|
||||
app,
|
||||
dailyNoteSettings.template
|
||||
);
|
||||
if (templateFile instanceof TFile) {
|
||||
try {
|
||||
initialContent = await app.vault.read(templateFile);
|
||||
// Process date templates in the template content
|
||||
initialContent = processDateTemplates(initialContent);
|
||||
} catch (e) {
|
||||
console.warn("Failed to read template file:", e);
|
||||
}
|
||||
} else {
|
||||
console.warn(
|
||||
`Template file not found: ${dailyNoteSettings.template} (tried with and without .md extension)`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
11025
styles.css
11025
styles.css
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue