2025-07-15 15:30:17 +00:00
import { PluginSettings } from "@/types/pluginSettings" ;
2026-03-18 18:38:17 +00:00
import React , { useMemo } from "react" ;
2025-07-15 15:30:17 +00:00
import { SettingItem } from "./SettingItem" ;
2025-11-21 16:10:10 +00:00
import { FrontmatterMappingsSettings } from "./FrontmatterMappingsSettings" ;
2026-03-18 18:38:17 +00:00
import { BaseNoteStatusService } from "@/core/noteStatusService" ;
2025-07-15 15:30:17 +00:00
export type Props = {
settings : PluginSettings ;
onChange : ( key : keyof PluginSettings , value : unknown ) = > void ;
} ;
export const BehaviourSettings : React.FC < Props > = ( { settings , onChange } ) = > {
2026-03-18 18:38:17 +00:00
const availableStatuses = useMemo ( ( ) = > {
return BaseNoteStatusService . getAllAvailableStatuses ( ) ;
} , [
settings . templates ,
settings . customStatuses ,
settings . enabledTemplates ,
] ) ;
2025-07-15 15:30:17 +00:00
return (
< div >
< h3 > Status tag < / h3 >
2026-03-18 18:38:17 +00:00
< SettingItem
name = "Default status for new notes"
description = "Automatically apply this status to newly created notes."
>
< select
value = { settings . defaultStatusForNewNotes || "" }
onChange = { ( e ) = > {
const value = e . target . value ;
onChange (
"defaultStatusForNewNotes" ,
value === "" ? null : value ,
) ;
} }
>
< option value = "" > None < / option >
{ availableStatuses . map ( ( status ) = > {
const identifier =
BaseNoteStatusService . formatStatusIdentifier ( {
templateId : status.templateId ,
name : status.name ,
} ) ;
const displayName = status . templateId
? ` ${ status . name } ( ${ status . templateId } ) `
: status . name ;
return (
< option key = { identifier } value = { identifier } >
{ displayName }
< / option >
) ;
} ) }
< / select >
< / SettingItem >
2025-07-15 15:30:17 +00:00
< SettingItem
name = "Enable multiple statuses"
description = "Allow notes to have multiple statuses at the same time"
>
< input
type = "checkbox"
checked = { settings . useMultipleStatuses }
onChange = { ( e ) = >
onChange ( "useMultipleStatuses" , e . target . checked )
}
/ >
< / SettingItem >
2025-11-18 17:48:58 +00:00
< SettingItem
name = "Single status format"
description = "Choose how the status frontmatter value is stored when multiple statuses are disabled. String format improves compatibility with plugins like TaskNotes."
>
< select
disabled = { settings . useMultipleStatuses }
value = { settings . singleStatusStorageMode || "list" }
onChange = { ( e ) = >
onChange (
"singleStatusStorageMode" ,
e . target
. value as PluginSettings [ "singleStatusStorageMode" ] ,
)
}
>
< option value = "list" > List ( status : [ in - progress ] ) < / option >
< option value = "string" > String ( status : in - progress ) < / option >
< / select >
< / SettingItem >
2025-11-18 17:18:43 +00:00
< SettingItem
name = "Apply status recursively to subfolders"
description = "Show a folder context menu option that also processes notes inside nested folders."
>
< input
type = "checkbox"
checked = {
settings . applyStatusRecursivelyToSubfolders || false
}
onChange = { ( e ) = >
onChange (
"applyStatusRecursivelyToSubfolders" ,
e . target . checked ,
)
}
/ >
< / SettingItem >
2025-07-15 15:30:17 +00:00
< SettingItem
name = "Status tag prefix"
2025-07-20 18:52:10 +00:00
description = "YAML frontmatter tag name for status (default: obsidian-note-status)"
2025-07-15 15:30:17 +00:00
>
< input
type = "text"
value = { settings . tagPrefix }
onChange = { ( e ) = > {
if ( e . target . value . trim ( ) ) {
onChange ( "tagPrefix" , e . target . value . trim ( ) ) ;
}
} }
/ >
< / SettingItem >
< SettingItem
name = "Strict status validation"
description = "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."
>
< input
type = "checkbox"
checked = { settings . strictStatuses || false }
onChange = { ( e ) = >
onChange ( "strictStatuses" , e . target . checked )
}
/ >
< / SettingItem >
2025-07-21 19:11:10 +00:00
2025-11-21 16:10:10 +00:00
< SettingItem
name = "Frontmatter mappings"
description = "Map templates or individual statuses to specific YAML keys. These mappings only apply to Markdown files with frontmatter."
vertical
>
< FrontmatterMappingsSettings
settings = { settings }
onChange = { onChange }
/ >
< / SettingItem >
2025-11-21 17:54:03 +00:00
< SettingItem
name = "Write mapped tags to default status tag"
description = "When enabled, statuses mapped to custom frontmatter keys are also written to the default status tag."
>
< input
type = "checkbox"
checked = { settings . writeMappedTagsToDefault || false }
onChange = { ( e ) = >
onChange ( "writeMappedTagsToDefault" , e . target . checked )
}
/ >
< / SettingItem >
2025-07-21 19:11:10 +00:00
< SettingItem
name = "Vault size limit"
description = "Disable dashboard and grouped view for vaults with more notes than this limit to improve performance. Set to 0 to disable this feature."
>
< input
type = "number"
min = "0"
value = { settings . vaultSizeLimit || 15000 }
onChange = { ( e ) = > {
const value = parseInt ( e . target . value ) || 15000 ;
onChange ( "vaultSizeLimit" , value ) ;
} }
/ >
< / SettingItem >
2025-07-15 15:30:17 +00:00
< / div >
) ;
} ;