Bläck StudioPlugin SDK v1.0.0 · API 10
Contents

Start

Building

Beyond Bläck Studio

How it runs

Sharing

Look up

Suggestions as you type

addSuggester shows a list of suggestions under the caret. The list appears when the writer types a trigger character at the start of a word: @ for people, # for tags, : for emoji…

this.addSuggester({
  id: 'tags',
  trigger: '#',
  find: (query) =>
    this.tags
      .filter((tag) => tag.startsWith(query.toLowerCase()))
      .map((tag) => ({ label: tag, insert: `#${tag}`, detail: 'tag' })),
})

This is how it behaves:

  • What find gets: the text typed after the trigger so far. Bläck Studio calls find again as the writer types, after a 60 ms pause. Keep it quick, and prepare whatever it searches beforehand. find may be async. If its answer arrives after the writer has typed more, Bläck Studio drops it.
  • What it returns: suggestions, each with a label, an optional detail shown beside it, and an optional insert. When the writer picks a suggestion, its insert (or its label, if there is no insert) replaces the trigger and everything typed after it.
  • The keys: up and down choose a suggestion, Enter or Tab takes it, and Escape hides the list until the writer moves on.
  • Limits: Bläck Studio shows at most 12 suggestions, counting every suggester with the same trigger. A trigger in the middle of a word (e@mail) offers nothing.

Suggesters work in sandboxed plugins too.