@@ -53,28 +53,37 @@ export default class BetterWordCountSettingsTab extends PluginSettingTab {
5353 . setDesc ( "Set how many words count as one \"page\"" )
5454 . addText ( ( text : TextComponent ) => {
5555 text . inputEl . type = "number" ;
56- text . setPlaceholder ( "300" ) ;
57- text . setValue ( this . plugin . settings . pageWords . toString ( ) ) ;
58- text . onChange ( async ( value : string ) => {
59- this . plugin . settings . pageWords = parseInt ( value ) ;
60- await this . plugin . saveSettings ( ) ;
56+ text
57+ . setPlaceholder ( "300" )
58+ . setValue ( String ( this . plugin . settings . pageWords ) )
59+ . onChange ( async ( value : string ) => {
60+ if ( value ) {
61+ this . plugin . settings . pageWords = parseInt ( value ) ;
62+ } else {
63+ this . plugin . settings . pageWords = 300 ;
64+ }
65+ await this . plugin . saveSettings ( ) ;
66+ } ) ;
6167 } ) ;
62- } ) ;
6368
6469 // Advanced Settings
6570 containerEl . createEl ( "h4" , { text : "Advanced Settings" } ) ;
6671 new Setting ( containerEl )
6772 . setName ( "Vault Stats File Path" )
6873 . setDesc ( "Reload required for change to take effect. The location of the vault statistics file, relative to the vault root." )
6974 . addText ( ( text : TextComponent ) => {
70- text . setPlaceholder ( ".obsidian/vault-stats.json" ) ;
71- text . setValue ( this . plugin . settings . statsPath . toString ( ) ) ;
72- text . onChange ( async ( value : string ) => {
73- this . plugin . settings . statsPath = value ;
74- await this . plugin . saveSettings ( ) ;
75+ text
76+ . setPlaceholder ( ".obsidian/vault-stats.json" )
77+ . setValue ( this . plugin . settings . statsPath )
78+ . onChange ( async ( value : string ) => {
79+ if ( value ) {
80+ this . plugin . settings . statsPath = value ;
81+ } else {
82+ this . plugin . settings . statsPath = ".obsidian/vault-stats.json" ;
83+ }
84+ await this . plugin . saveSettings ( ) ;
85+ } ) ;
7586 } ) ;
76- } ) ;
77-
7887
7988 // Status Bar Settings
8089 addStatusBarSettings ( this . plugin , containerEl ) ;
0 commit comments