@@ -16,6 +16,7 @@ export interface ChangelogSettings {
1616 changelogPath : string ;
1717 datetimeFormat : string ;
1818 maxRecentFiles : number ;
19+ excludedFolders : string [ ] ;
1920}
2021
2122// Define the default settings
@@ -24,6 +25,7 @@ export const DEFAULT_SETTINGS: ChangelogSettings = {
2425 changelogPath : "Changelog.md" ,
2526 datetimeFormat : "YYYY-MM-DD[T]HHmm" ,
2627 maxRecentFiles : 25 ,
28+ excludedFolders : [ ] ,
2729} ;
2830
2931// Define the settings tab
@@ -35,6 +37,36 @@ export class ChangelogSettingsTab extends PluginSettingTab {
3537 this . plugin = plugin ;
3638 }
3739
40+ // Helper method to render the list of excluded folders
41+ renderExcludedFolders ( container : HTMLElement ) {
42+ container . empty ( ) ;
43+
44+ if ( this . plugin . settings . excludedFolders . length === 0 ) {
45+ container . createEl ( "div" , { text : "No excluded folders" } ) ;
46+ return ;
47+ }
48+
49+ this . plugin . settings . excludedFolders . forEach ( ( folder ) => {
50+ const folderDiv = container . createDiv ( "excluded-folder-item" ) ;
51+ folderDiv . createSpan ( { text : folder } ) ;
52+
53+ const removeButton = folderDiv . createEl ( "button" , {
54+ text : "✕" ,
55+ cls : "excluded-folder-remove" ,
56+ } ) ;
57+
58+ removeButton . addEventListener ( "click" , async ( ) => {
59+ const index =
60+ this . plugin . settings . excludedFolders . indexOf ( folder ) ;
61+ if ( index > - 1 ) {
62+ this . plugin . settings . excludedFolders . splice ( index , 1 ) ;
63+ await this . plugin . saveSettings ( ) ;
64+ this . renderExcludedFolders ( container ) ;
65+ }
66+ } ) ;
67+ } ) ;
68+ }
69+
3870 display ( ) {
3971 const { containerEl } = this ;
4072 const { settings } = this . plugin ;
@@ -53,7 +85,7 @@ export class ChangelogSettingsTab extends PluginSettingTab {
5385 } else {
5486 this . plugin . disableAutoUpdate ( ) ;
5587 }
56- } )
88+ } ) ,
5789 ) ;
5890
5991 new Setting ( containerEl )
@@ -94,7 +126,7 @@ export class ChangelogSettingsTab extends PluginSettingTab {
94126 // Save valid format and persist settings
95127 settings . datetimeFormat = format ;
96128 await this . plugin . saveSettings ( ) ;
97- } )
129+ } ) ,
98130 ) ;
99131
100132 new Setting ( containerEl )
@@ -112,7 +144,45 @@ export class ChangelogSettingsTab extends PluginSettingTab {
112144 }
113145 settings . maxRecentFiles = numValue ;
114146 await this . plugin . saveSettings ( ) ;
115- } )
147+ } ) ,
116148 ) ;
149+
150+ // Excluded folders section header
151+ containerEl . createEl ( "h3" , { text : "Excluded Folders" } ) ;
152+
153+ // Create a list of currently excluded folders with delete buttons
154+ const excludedFoldersList = containerEl . createDiv (
155+ "excluded-folders-list" ,
156+ ) ;
157+ this . renderExcludedFolders ( excludedFoldersList ) ;
158+
159+ // Add a new excluded folder with path suggestions
160+ new Setting ( containerEl )
161+ . setName ( "Add excluded folder" )
162+ . setDesc ( "Folders to exclude from the changelog" )
163+ . addText ( ( text ) => {
164+ text . setPlaceholder ( "folder/path/" ) ;
165+
166+ // Add path autocompletion
167+ new PathSuggest ( this . app , text . inputEl ) ;
168+ } )
169+ . addButton ( ( button ) => {
170+ button . setButtonText ( "Add" ) . onClick ( async ( ) => {
171+ const input =
172+ button . buttonEl . parentElement ?. querySelector ( "input" ) ;
173+ if ( input ) {
174+ const folderPath = input . value ;
175+ if (
176+ folderPath &&
177+ ! settings . excludedFolders . includes ( folderPath )
178+ ) {
179+ settings . excludedFolders . push ( folderPath ) ;
180+ await this . plugin . saveSettings ( ) ;
181+ input . value = "" ;
182+ this . renderExcludedFolders ( excludedFoldersList ) ;
183+ }
184+ }
185+ } ) ;
186+ } ) ;
117187 }
118188}
0 commit comments