Skip to main content
When a scene add-on loads, MN injects an 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: workspace or mini. Your add-on is responsible for adapting to each mode.
  • lang: the app interface language.
  • locale: the system region.
  • theme: light or dark. White, sepia, and green map to light; gray and black map to dark.
  • _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 with mn.api:
For hands-on examples, see Data exchange.

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
Here is how to call it:
For hands-on examples, see Using MN’s built-in AI.

call(name, data)

Calls a function defined in main.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
For hands-on examples, see Event system.

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 workspace or mini.
  • close(): closes the panel.
  • reload(): reloads the panel.
For hands-on examples, see Controlling the UI.

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. Image