Skip to content
This repository has been archived by the owner on Mar 16, 2023. It is now read-only.

Plugin API

Jason Stallings edited this page Feb 3, 2015 · 4 revisions

Place JavaScript files in the /plugins/ directory in the root of the app and they'll get loaded when the app is opened.

On Mac the directory is inside the app:

Marknote.app/Contents/Resources/app.nw/plugins

Create the directory if it doesn't exist.

Events

apiready

Fired when the app has finished loading. Wait for this event before calling any Marknote functions.

noteloaded

Fired when a note has finished loading.

Arguments

Name Description
note ID of the loaded note.
previousnote ID of the previous note.

editing

Fired when the editor is loaded.

Arguments

Name Description
note ID of the note being edited.

displaying

Fired when the note is displayed (after editing).

Arguments

Name Description
note ID of the note being displayed.

Functions

displayShowing()

Returns true if a note is showing, false if the editor is showing.

getNoteTitle(id)

Generates and returns the title for a note.

createNote(content)

Creates a new note from markdown in the background.

loadNote(id, select)

Loads a note, if select is true the note is highlighted.

If select isn't defined, it defaults to true.

deleteNote(id)

Deletes a note.

duplicateNote(id)

Duplicates a note.

saveNotes()

Saves the notes to localStorage, and if syncing is enabled to the cloud.

display()

Switches to the rendered display.

edit()

Opens the markdown editor.

Examples

Log note ID on note switch.

api.on("apiready", function()
{
	api.on("noteloaded", function(e)
	{
		console.log(e.note);
	});
});