Declaring events
An event must be declared before the add-on can receive it; otherwise listeners for it have no effect. Declare events with theevents field in mnaddon.json:
mnaddon.json
excerpt: an excerpt was created.- Payload:
{noteid, opened}. - Creating an excerpt wakes every panel that receives matching events in
minimode.openedistruewhen the panel was actually opened, andfalsewhen opening failed or the panel was already open.
- Payload:
comments: the comments on a card changed (collapsed, expanded, added, edited, and so on).- Payload:
{noteid?, noteids}. - When the comments of an excerpt card change, both the card in the mind map and the annotation card in the document appear in
noteids, butnoteidis only the card in the mind map that changed.
- Payload:
practice: the answer sheet editor closed. The answer sheet is a full-card screenshot with annotations. ⚠️ Only fires when the answer sheet was opened by this add-on.- Payload:
{noteid, action, saved, commentId}.
- Payload:
synced: sync merging finished.- No payload.
undo: an undo or redo happened.- No payload.
imported: cards were added to a study set in bulk.- No payload.
Listening for events
Events pushed before the page finishes loading are queued and delivered together once loading completes.
Filtering excerpt events
If the user creates an excerpt while the panel is closed, MN first opens the panel inmini mode, then pushes the excerpt event, with opened set to true. If you are done, call mn.close() to dismiss the panel.
If you only care about a certain kind of excerpt, narrow it down with excerptClaim:
#VocabPending trigger the add-on’s excerpt event.
configKey is optional. When set, template configuration can override the hashtag. With the configuration above, the value comes from pluginConfigs["mn.vocab"]["pendingTag"] in the template.
If excerptClaim is omitted, every excerpt opens the add-on panel and triggers the excerpt event.
Card menu commands
cardCommand does not need to be declared in events. When the user picks a declared command from the card menu, the cardCommand event fires: