Use case or problem
As a plugin author, I want to utilize the tag and link autocomplete capabilities built into the Obsidian editor, but I want to use it in other input fields. This would allow me to offer users all of Obsidian’s complex autocomplete functionality, especially when it comes to searching/inserting links to headers and block embeds.
Proposed solution
Obsidian could offer an API to display the tag/link autocomplete at a given set of coordinates and an input. The API could also accept navigation commands, such as prev()
/next()
, so developers can utilize keyboard navigation.
As a quick pseudocode example, something like this would be really helpful:
class LinkAutocomplete {
constructor(
pos: DOMRect, // With a dom rect, positioning could be taken care of on obsidian's end
initialInput: string,
onSelect: (result: SomeResultObject) => void,
onCancel: () => void
) {
...
}
updateInput(input: string) {...}
updatePosition(pos: DOMRect) {...}
navigateUp() {...}
navigateDown() {...}
}
Current workaround (optional)
Currently I have to roll my own, which requires a lot of work, and will never be able to compete with Obsidian’s autocomplete.