mn instance into the context. Access its members to interact with MN.
Read-only information
The following members are read-only:- version: the add-on SDK version.
- currentMode:
workspaceormini. Your add-on is responsible for adapting to each mode. - lang: the app interface language.
- locale: the system region.
- theme:
lightordark. White, sepia, and green map tolight; gray and black map todark. - _drag: purpose not yet documented.
Methods
api(path, opts)
Performs CRUD operations on MN data. It is called the same way as the MarginNote CLI, but some endpoints are unavailable. To know exactly which endpoints are available, query the capabilities. The following code shows how to work withmn.api:
ai(noteid, taskId, params)
mn.ai lets you run tasks on MN’s built-in AI. The task id must be declared in template.json before you call it.
template.json
call(name, data)
Calls a function defined inmain.js and receives its return value.
For hands-on examples, see Beyond the panel.
on(event, cb)
mn.on listens for events sent by MN. You must first declare the events you want in mnaddon.json.
mnaddon.json
UI methods
- fit(): sets the panel height to the height of
<html>. - height(h): sets the panel height.
- size(w, h): sets the panel width and height.
- mode(m): sets the panel mode to
workspaceormini. - close(): closes the panel.
- reload(): reloads the panel.
log
Writes a log entry. Click the “Add-on” label at the top of the panel five times in a row to open the log panel.