Javascript Plugin API

NotePlan provides various global Javascript objects to give you access to your data and to prompt user input. Here is a list of available global objects:

// Interfaces
NotePlan	// Global environment information and other functions
Editor 		// Access to the markdown editor
DataStore 	// Query, read and modify notes
CommandBar 	// Prompt user input
Calendar 	// Create events and reminders
Clipboard	// Access and set the clipboard

// Helper objects (usually as return values)
ParagraphObject	// Line of text, like a task, bullet...
NoteObject	// Represents a note file
RangeObject	// Range of text like a selection
CalendarItem	// Event or reminder

// Global functions

Learn more about:


Access environment information like region code, language code, timezone.

Jump back


This refers to the markdown editor and the currently opened note. You can access the text directly from here, change the selection and even highlight parts. 

However, be careful about character positions, because NotePlan hides Markdown characters and replaces whole parts of text such as the URL in Markdown links or folded text with a single symbol. This can make calculating character positions and changing the text a bit tricky. Prefer working with the paragraph objects instead to modify text directly.

Here are the available functions you can call with the Editor object:

Jump back


With DataStore you can query, create and move notes which are cached by NotePlan. It allows you to query a set of user preferences, too.

Jump back


Use CommandBar to get user input. Either by asking the user to type in a free-form string, like a note title, or by giving him a list of choices. This list can be "fuzzy-search" filtered by the user. So, it's fine to show a long list of options, like all folders or notes or tasks in a note.

Jump back


Use Calendar to create events, reminders, and to parse dates, like "tomorrow at 8am to 10am", "today", or "1st May". See also CalendarItem if you want to create an event or reminder.

Jump back


You can get paragraphs from Editor or NoteObject. They represent blocks or lines of text (and are delimited by linebreaks = \n). A task for example is a paragraph, a list item (bullet), heading, etc. (see .type).

Jump back


Notes can be queried by DataStore. You can change the complete text of the note, which will be saved to file or query, add, remove, or modify particular paragraphs (a paragraph is a task for example). See more paragraph editing examples under Editor. NoteObject and Editor both inherit the same paragraph functions.

Jump back


Ranges are used when you deal with selections or need to know where a paragraph is in the complete text.

Jump back


The CalendarItem is used in combination with Calendar to create events or reminders.

Jump back


Access and set the data inside the current clipboard.

Jump back

Next up: Debugging Plugins →

Jump to: