diff --git a/constants/defaults.ts b/constants/defaults.ts index d98016f..cbe487f 100644 --- a/constants/defaults.ts +++ b/constants/defaults.ts @@ -23,6 +23,7 @@ export const DEFAULT_SETTINGS: NoteStatusSettings = { useCustomStatusesOnly: false, useMultipleStatuses: true, tagPrefix: 'obsidian-note-status', + strictStatuses: false, // Default to show all statuses from frontmatter excludeUnknownStatus: true, // Default to exclude unknown status files for better performance }; @@ -35,4 +36,4 @@ export const DEFAULT_COLORS: Record = { completed: '#00aaff', // Blue for accent dropped: '#ff0000', // Red for error unknown: '#888888' // Gray for muted -}; \ No newline at end of file +}; diff --git a/integrations/settings/settings-ui.ts b/integrations/settings/settings-ui.ts index ab166dd..33ae528 100644 --- a/integrations/settings/settings-ui.ts +++ b/integrations/settings/settings-ui.ts @@ -160,6 +160,14 @@ export class NoteStatusSettingsUI { this.callbacks.onSettingChange('tagPrefix', value.trim()); } })); + + + new Setting(containerEl) + .setName('Strict status validation') + .setDesc('Only show statuses that are defined in templates or custom statuses. ⚠️ WARNING: When enabled, any unknown statuses will be automatically removed when modifying file statuses.') + .addToggle(toggle => toggle + .setValue(settings.strictStatuses || false) + .onChange(value => this.callbacks.onSettingChange('strictStatuses', value))); } /** diff --git a/models/types.ts b/models/types.ts index 820bfc3..d1ddb48 100644 --- a/models/types.ts +++ b/models/types.ts @@ -26,6 +26,7 @@ export interface NoteStatusSettings { useCustomStatusesOnly: boolean; // Whether to use only custom statuses or include templates useMultipleStatuses: boolean; // Whether to allow multiple statuses per note tagPrefix: string; // Prefix for the status tag (default: 'status') + strictStatuses: boolean; // Whether to only show known statuses excludeUnknownStatus: boolean; // Whether to exclude files with unknown status from the status pane } @@ -39,4 +40,4 @@ export interface FileExplorerView extends View { titleEl?: HTMLElement; selfEl?: HTMLElement; }>; -} \ No newline at end of file +} diff --git a/services/status-service.ts b/services/status-service.ts index c9f6f52..e184d55 100644 --- a/services/status-service.ts +++ b/services/status-service.ts @@ -83,12 +83,22 @@ export class StatusService { if (Array.isArray(frontmatterStatus)) { for (const statusName of frontmatterStatus) { - this.addValidStatus(statusName.toString(), statuses); + if (this.settings.strictStatuses) { + this.addValidStatus(statusName.toString(), statuses); + } else { + const cleanStatus = statusName.toString().trim(); + if (cleanStatus) statuses.push(cleanStatus); + } } } else { - this.addValidStatus(frontmatterStatus.toString(), statuses); + if (this.settings.strictStatuses) { + this.addValidStatus(frontmatterStatus.toString(), statuses); + } else { + const cleanStatus = frontmatterStatus.toString().trim(); + if (cleanStatus) statuses.push(cleanStatus); + } } - + return statuses.length > 0 ? statuses : ['unknown']; } @@ -361,4 +371,4 @@ export class StatusService { } })); } -} \ No newline at end of file +}