generated from obsidianmd/obsidian-sample-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from danielo515/fix-remove-textinputsuggest
Fix-remove-textinputsuggest
- Loading branch information
Showing
8 changed files
with
80 additions
and
317 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,6 @@ | |
"typescript": "^5.2.2" | ||
}, | ||
"dependencies": { | ||
"@popperjs/core": "^2.11.8", | ||
"fuse.js": "^6.6.2" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,38 @@ | ||
// Credits go to Liam's Periodic Notes Plugin: https://github.com/liamcain/obsidian-periodic-notes | ||
import { App, TAbstractFile, TFolder } from "obsidian"; | ||
import { TextInputSuggest } from "./suggest"; | ||
import { AbstractInputSuggest, App, TAbstractFile, TFolder } from "obsidian"; | ||
|
||
export class FolderSuggest extends TextInputSuggest<TFolder> { | ||
export class FolderSuggest extends AbstractInputSuggest<TFolder> { | ||
|
||
constructor( | ||
public inputEl: HTMLInputElement, | ||
protected app: App, | ||
) { | ||
super(app, inputEl); | ||
console.log('FolderSuggest constructor'); | ||
} | ||
getSuggestions(inputStr: string): TFolder[] { | ||
const abstractFiles = this.app.vault.getAllLoadedFiles(); | ||
const lowerCaseInputStr = inputStr.toLowerCase(); | ||
constructor( | ||
public inputEl: HTMLInputElement, | ||
public app: App, | ||
) { | ||
super(app, inputEl); | ||
} | ||
getSuggestions(inputStr: string): TFolder[] { | ||
const abstractFiles = this.app.vault.getAllLoadedFiles(); | ||
const lowerCaseInputStr = inputStr.toLowerCase(); | ||
|
||
const folders: TFolder[] = abstractFiles.reduce((acc, folder: TAbstractFile) => { | ||
if ( | ||
folder instanceof TFolder && | ||
folder.path.toLowerCase().contains(lowerCaseInputStr) | ||
) { | ||
acc.push(folder) | ||
} | ||
return acc | ||
}, [] as TFolder[]); | ||
const folders: TFolder[] = abstractFiles.reduce((acc, folder: TAbstractFile) => { | ||
if ( | ||
folder instanceof TFolder && | ||
folder.path.toLowerCase().contains(lowerCaseInputStr) | ||
) { | ||
acc.push(folder) | ||
} | ||
return acc | ||
}, [] as TFolder[]); | ||
|
||
return folders; | ||
} | ||
return folders; | ||
} | ||
|
||
renderSuggestion(file: TFolder, el: HTMLElement): void { | ||
el.setText(file.path); | ||
} | ||
renderSuggestion(file: TFolder, el: HTMLElement): void { | ||
el.setText(file.path); | ||
} | ||
|
||
selectSuggestion(file: TFolder): void { | ||
this.inputEl.value = file.path; | ||
this.inputEl.trigger("input"); | ||
this.close(); | ||
} | ||
selectSuggestion(file: TFolder): void { | ||
this.inputEl.value = file.path; | ||
this.inputEl.trigger("input"); | ||
this.close(); | ||
} | ||
} |
Oops, something went wrong.