Refactors project structure for improved modularity
Moves components and modules to more appropriate directories. This change improves project organization and maintainability by grouping related files into logical directories, enhancing code discoverability and reducing potential naming conflicts.
This commit is contained in:
16 files changed
+21
-21
No files matched your search
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Folder suggestion component for folder path inputs
|
||||
* Provides autocomplete for existing vault folders
|
||||
*/
|
||||
|
||||
import { App, AbstractInputSuggest } from 'obsidian';
|
||||
|
||||
export class FolderSuggest extends AbstractInputSuggest<string> {
|
||||
private folders: string[];
|
||||
private inputElement: HTMLInputElement;
|
||||
|
||||
constructor(app: App, inputEl: HTMLInputElement) {
|
||||
super(app, inputEl);
|
||||
this.inputElement = inputEl;
|
||||
this.folders = ["/"].concat(this.app.vault.getAllFolders().map(folder => folder.path));
|
||||
}
|
||||
|
||||
getSuggestions(inputStr: string): string[] {
|
||||
const inputLower = inputStr.toLowerCase();
|
||||
return this.folders.filter(folder =>
|
||||
folder.toLowerCase().includes(inputLower)
|
||||
);
|
||||
}
|
||||
|
||||
renderSuggestion(folder: string, el: HTMLElement): void {
|
||||
el.createEl("div", { text: folder });
|
||||
}
|
||||
|
||||
selectSuggestion(folder: string): void {
|
||||
this.inputElement.value = folder;
|
||||
this.inputElement.dispatchEvent(new Event('input'));
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user