GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing help.noteplan.co — Create Plugins - NotePlan Knowledge Base Create PluginsJump ahead to:
You can write custom Javascript plugins and share them with the community by submitting a pull request to our official GitHub repo. Find example of other plugins in the same repo. This article walks you through how to start creating a plugin. Plugin SetupA plugin is made up of at least two files: The The All plugin files have to be inside NotePlan's database folder. Here is an example of the folder structure:
The easiest way to find the folder is to open it from the plugin preferences by clicking on "Open Plugin Folder". plugin.jsonHere is an example of a minimal {
"noteplan.minAppVersion": "3.0.21",
"macOS.minVersion": "10.15.7",
"iOS.minVersion": "14",
"plugin.id": "eduardme.move",
"plugin.name": "Move selected note to another folder",
"plugin.description": "Move a note from the current folder into another.",
"plugin.author": "Eduard Metzger",
"plugin.url": "https://…",
"plugin.version": "0.0.2",
"plugin.dependencies": [ ],
"plugin.script": "script.js",
"plugin.lastUpdateInfo": "",
"plugin.requiredFiles": "",
"plugin.commands": [
{
"name": "move",
"alias": ["m", "mv"],
"description": "Moves note to another folder",
"jsFunction": "moveNote",
"arguments": ["note title", "heading"],
"sidebarView": {
"windowID": "my-custom-id",
"title": "My Plugin",
"icon": "calendar",
"iconColor": "blue-500"
}
},
],
"plugin.settings": []
}
plugin.script ("script.js")This is the Javascript file containing the actual code NotePlan will run. It consists of at least one or more functions which will be called by NotePlan after the user has executed the referenced function moveNote() {
console.log("Hello World")
}
The function name Installing Your PluginOnce you've written your basic plugin, you need to put it somewhere that NotePlan can find it. Go to NotePlan > Preferences > Plugins and click the button "Open Plugins Folder":
Create a new folder in that directory (you can name it whatever you want), and drop the files you created (script.js and plugin.json) into that folder. The next time you open the Command Bar and type "/", your new plugin will be loaded and you should see and be able to select your new command (whatever you put for "plugin.command" in the plugin.json). More Complex / Efficient Plugin DevelopmentThe instructions above work fine for a basic plugin, but there is a lot of tooling in the GitHub repository that will make you more efficient in creating more complex plugins. After you've acquainted yourself with the basics of plugin development on this page, we highly recommend following the instructions on GitHub. Logging and DebuggingFor simple debugging purposes, you can use
Interfaces (Global Objects)Inside the You can find examples of how to use the interfaces in the API documentation. In the next article, we will list and explain the various global objects and how to use them. Javascript PromisesPromises are supported and you need to use them in order to wait for user input for example. The preferred syntax is to use async function selectFolder() {
let folder = await CommandBar.showOptions(DataStore.folders, "Select")
// Use folder.value or folder.index [...]
}
FetchUse fetch to get data from the internet, like weather information, or connect to the API of another app to sync data between NotePlan and the app. Fetch supports the following options parameters: "method" (like "GET"), "headers", and "body" (which takes a string as value). Note: Fetch only works with websites that have an SSL certificate installed. This means "https://" must work. Here are examples: async function weatherFetch() {
let response = await fetch("https://api.weatherapi.com/v1/current.json?key=f4c442d67eef4574b99184324211404&q=Berlin&aqi=no")
console.log(response)
}
async function fetchWithParameters() {
const response = await fetch('https://api.ninox.com/v1/teams',
{ method: 'GET',
headers: {
'Authorization': 'Bearer cfda1581-1a36-11ec-b44d-f9d8217e4195',
'Content-Type': 'application/json'
}
})
console.log(response)
}
Syncing PluginsAvoid adding a node_modules folder or any other large folder with many files to the plugins directory. Syncing will probably max out. Additionally, NotePlan v3.3 will exclude node_modules folders from syncing it with CloudKit. Next up: Javascript Plugin API → Jump to:
|
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |