Skip to content
Edytor
Esc
↑↓navigate↵open⌘Jpreview

Mention

The mention plugin in the repository is a reference implementation of an inline atom inserted by an operation hook, not an export of the package.

The repository contains a mentionPlugin in src/lib/plugins/mention/MentionPlugin.svelte (GitHub). It is not exported from edytor, and the package does not expose its file, so you cannot import it. It is demo-grade reference code: read it, then copy what you need into your own plugin.

It shows the two halves of an inline atom: a definition and an operation hook that inserts it.

  • It defines one inline block, mention, with a snippet and a plain form. plain exports the atom as @ followed by the first of data.label, data.name, data.title or data.id, or @mention when none is set.
  • Its onBeforeOperation refuses an insertText of @ and, in its place, inserts a mention atom (with empty data) at the caret and puts the caret right after it.

The snippet renders placeholder text (@mention) and its selected state for debugging. It does not open a picker or store who was mentioned. Inline blocks builds a usable version with a label in its data, and Operations explains the prevent(cb) pattern it uses.

For a void block with an editable caption, the other reference shape, see the image plugin, which is exported and on by default.

Was this page helpful?