-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: don't detach leaves * fix: use element.toggleClass * fix: use setHeader in settings * refactor: use AbstractInputSuggest * refactor: remove debounce * refactor: remove assign-hotkeys setting * docs: update readme * chore: update description * chore: bump version
- Loading branch information
Showing
22 changed files
with
112 additions
and
375 deletions.
There are no files selected for viewing
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,9 +1,9 @@ | ||
{ | ||
"id": "enhanced-annotations", | ||
"name": "Enhanced Annotations", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"minAppVersion": "0.15.0", | ||
"description": "Adds features to comments and highlights.", | ||
"description": "Add a sidebar view for comments and highlights.", | ||
"author": "ycnmhd", | ||
"isDesktopOnly": true | ||
} |
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 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
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 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
104 changes: 43 additions & 61 deletions
104
src/settings/settings-tab/components/note-settings/helpers/folder-suggestions.ts
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,62 +1,44 @@ | ||
/* credit: https://github.com/liamcain/obsidian-periodic-notes/blob/10fa35874d92750508967d4f1e58b3fa0eb87996/src/ui/file-suggest.ts#L1 */ | ||
import { TAbstractFile, TFile, TFolder } from "obsidian"; | ||
import { TextInputSuggest } from "./text-input-suggest"; | ||
|
||
export class FileSuggest extends TextInputSuggest<TFile> { | ||
getSuggestions(inputStr: string): TFile[] { | ||
const abstractFiles = this.app.vault.getAllLoadedFiles(); | ||
const files: TFile[] = []; | ||
const lowerCaseInputStr = inputStr.toLowerCase(); | ||
|
||
abstractFiles.forEach((file: TAbstractFile) => { | ||
if ( | ||
file instanceof TFile && | ||
file.extension === "md" && | ||
file.path.toLowerCase().contains(lowerCaseInputStr) | ||
) { | ||
files.push(file); | ||
} | ||
}); | ||
|
||
return files; | ||
} | ||
|
||
renderSuggestion(file: TFile, el: HTMLElement): void { | ||
el.setText(file.path); | ||
} | ||
|
||
selectSuggestion(file: TFile): void { | ||
this.inputEl.value = file.path; | ||
this.inputEl.trigger("input"); | ||
this.close(); | ||
} | ||
} | ||
|
||
export class FolderSuggest extends TextInputSuggest<TFolder> { | ||
getSuggestions(inputStr: string): TFolder[] { | ||
const abstractFiles = this.app.vault.getAllLoadedFiles(); | ||
const folders: TFolder[] = []; | ||
const lowerCaseInputStr = inputStr.toLowerCase(); | ||
|
||
abstractFiles.forEach((folder: TAbstractFile) => { | ||
if ( | ||
folder instanceof TFolder && | ||
folder.path.toLowerCase().contains(lowerCaseInputStr) | ||
) { | ||
folders.push(folder); | ||
} | ||
}); | ||
|
||
return folders; | ||
} | ||
|
||
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(); | ||
} | ||
import { AbstractInputSuggest, App, TFolder } from 'obsidian'; | ||
|
||
export class FolderSuggest extends AbstractInputSuggest<string> { | ||
content: Set<string>; | ||
|
||
constructor( | ||
app: App, | ||
private inputEl: HTMLInputElement, | ||
private onSelectCallback: (value: string) => void, | ||
) { | ||
super(app, inputEl); | ||
this.content = this.loadContent(); | ||
} | ||
|
||
loadContent(): Set<string> { | ||
const abstractFiles = this.app.vault.getAllLoadedFiles(); | ||
const folders: Set<string> = new Set(); | ||
|
||
for (const folder of abstractFiles) { | ||
if (folder instanceof TFolder) { | ||
folders.add(folder.path); | ||
} | ||
} | ||
|
||
return folders; | ||
} | ||
|
||
getSuggestions(inputStr: string): string[] { | ||
const lowerCaseInputStr = inputStr.toLocaleLowerCase(); | ||
return [...this.content].filter((content) => | ||
content.toLocaleLowerCase().contains(lowerCaseInputStr), | ||
); | ||
} | ||
renderSuggestion(content: string, el: HTMLElement): void { | ||
el.setText(content); | ||
} | ||
|
||
selectSuggestion(content: string): void { | ||
this.onSelectCallback(content); | ||
this.inputEl.value = content; | ||
this.inputEl.blur(); | ||
this.close(); | ||
} | ||
} |
Oops, something went wrong.