API Feature Request: Expose tag and link autocomplete to developers

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.

2 Likes

Moved this to developer API. Isn’t there already fuzzymodal for this?

As far as I understand, fuzzy modal is pretty generic. IE: it doesn’t provide the built in logic for searching tags or pages/aliases/headers/blocks. It’s also a modal, which isn’t ideal for UX. To be clear, I’m talking about these: