diff --git a/components/SettingsUI/BehaviourSettings.tsx b/components/SettingsUI/BehaviourSettings.tsx index 00aea38..65a2b8f 100644 --- a/components/SettingsUI/BehaviourSettings.tsx +++ b/components/SettingsUI/BehaviourSettings.tsx @@ -103,6 +103,19 @@ export const BehaviourSettings: React.FC = ({ settings, onChange }) => { /> + + + onChange("writeMappedTagsToDefault", e.target.checked) + } + /> + + { + if (mapping.scope === "status") { + return ( + mapping.statusName === scoped.name && + (mapping.templateId || null) === (scoped.templateId || null) + ); + } + if (mapping.scope === "template") { + return ( + Boolean(scoped.templateId) && + mapping.templateId === scoped.templateId + ); + } + return false; + }); + } + protected getStatusMetadataKeys(): string[] { return [settingsService.settings.tagPrefix]; } @@ -196,8 +234,9 @@ export class NoteStatusService extends BaseNoteStatusService { settingsService.settings, { isMarkdownFile: true }, ); - const defaultKey = settingsService.settings.tagPrefix; + const mappingMatched = this.hasExplicitMappingForStatus(status); + if ( resolved.length === 1 && resolved[0] === defaultKey && @@ -206,6 +245,15 @@ export class NoteStatusService extends BaseNoteStatusService { resolved = [frontmatterTagName]; } + if ( + mappingMatched && + settingsService.settings.writeMappedTagsToDefault && + defaultKey && + this.isMarkdownFile() + ) { + resolved = [...resolved, defaultKey]; + } + if (options?.includeSourceKey && frontmatterTagName) { resolved = [...resolved, frontmatterTagName]; } diff --git a/types/pluginSettings.ts b/types/pluginSettings.ts index 896999a..0c8ccfb 100644 --- a/types/pluginSettings.ts +++ b/types/pluginSettings.ts @@ -67,5 +67,6 @@ export type PluginSettings = { editorToolbarButtonDisplay: "all-notes" | "active-only"; // Whether to show button in all notes or only active one applyStatusRecursivelyToSubfolders: boolean; // Whether to show recursive folder context option statusFrontmatterMappings: StatusFrontmatterMapping[]; // Custom mappings between templates/statuses and frontmatter keys + writeMappedTagsToDefault: boolean; // Whether mapped tags should also write to the default tag [key: string]: unknown; };