Build plugins for notesy
Build plugins for notesy: small Rune scripts that add panels, commands and more, and do only what the user allows.
The API
Basics
log: Lines for its log on the Plugins pageevents: Hearing what happens, and every eventcommands: Adding commands, and running notesy'sstore: Keeping its own datasettings: Reading its settingssecrets: Keys and tokens, in the system keychain
Notes and files
notes: Reading and changing the vault's noteseditor: The note in frontfiles: A folder of its ownlinks: Opening pages in the browserclipboard: Copying and pasting
Interface
view: What panels, tabs and sections showpanels: Adding side panels and tabssections: Sidebar sectionsmenus: Items in notesy's right-click menusstatus: Status bar itemsnotices: Noticesdialogs: Asking in a dialog, notesy's kinds or its owncards: Its part of the tree's hover cardsboards: Boards' cards and arrows, and kinds of card of its ownblocks: Drawing its fenced blocksicons: Drawing its own icons
The web
Data and helpers
json: Reading and writing JSONtoml: Reading and writing TOMLyaml: Reading and writing YAML, and a note's front mattertime: Now, written in the user's time zone, dates read, how long agomath: Trigonometry and the like, for drawingnames: Notesy's names as enums
Tools
How plugins work
A notesy plugin is a folder with a plugin.toml in it. Some plugins only
add looks (themes, icon packs, syntax, colors, code languages): notesy reads
what they declare and does it itself, and they run nothing. Others run a script, written in
Rune, which notesy runs in a sandbox of its
own after the user has said yes to what the plugin asks for.
Plugins are a walled garden. A plugin does only what its manifest declares and the user approved; it reaches only the web hosts it names, through notesy's own fetch; it hears only the events its permissions cover. A script has no files, sockets, processes or native code, only notesy's modules.
#A first plugin
Make a folder called you.saves anywhere you like, with two files, then
load it: Settings, Plugins, "Load a plugin folder". notesy links it in as
it is (nothing to pack) and reloads it each time you save.
plugin.toml:
tomlid = "you.saves"
name = "Saves"
version = "0.1.0"
author = "You"
license = "MIT"
main = "main.rn"
permissions = ["notes.read"]
main.rn:
rustuse notesy::{events, log, store, Event};
pub fn ready() {
events::on(Event::NoteSaved, |event| {
let saves = store::get("saves").unwrap_or(0) + 1;
store::set("saves", saves);
log::info(`${event.path} saved; ${saves} saves so far`);
});
}
Open the Plugins page: the plugin asks to read your notes. Say yes, and each time a note is saved, its log (under it on the Plugins page) says so.
#An example to start from
examples/plugins/example.tasks is
a whole plugin: a Tasks panel beside the note (its - [ ] lines, what's
left and done), a status bar item saying how many are left, and a command.
Copy its folder into your plugins folder to try it.
#Folder layout
plugins/
you.saves/ one folder per plugin, named after its id
plugin.toml
main.rn its script, when it has one
grants.toml what the user allowed each plugin (notesy's own)
plugin-data/
you.saves/
store.toml its settings' values and what it keeps (see api/store.md)
plugin-data is kept apart from plugins so updating a plugin keeps its data.
Every page
- Overview
- plugin.toml: Every field of plugin.toml
- Permissions: What a plugin can ask for, when notesy asks, and what changes it
- Scripts: How a script runs: its lifecycle, events, limits and errors
- Packing and installing: Making, checking, signing, packing and installing
- notesy::log: Lines for its log on the Plugins page
- notesy::events: Hearing what happens, and every event
- notesy::commands: Adding commands, and running notesy's
- notesy::store: Keeping its own data
- notesy::settings: Reading its settings
- notesy::secrets: Keys and tokens, in the system keychain
- notesy::notes: Reading and changing the vault's notes
- notesy::editor: The note in front
- notesy::files: A folder of its own
- notesy::links: Opening pages in the browser
- notesy::clipboard: Copying and pasting
- notesy::view: What panels, tabs and sections show
- notesy::panels and notesy::views: Adding side panels and tabs
- notesy::sections: Sidebar sections
- notesy::menus: Items in notesy's right-click menus
- notesy::status: Status bar items
- notesy::notices: Notices
- notesy::dialogs: Asking in a dialog, notesy's kinds or its own
- notesy::cards: Its part of the tree's hover cards
- notesy::boards: Boards' cards and arrows, and kinds of card of its own
- notesy::blocks: Drawing its fenced blocks
- notesy::icons: Drawing its own icons
- notesy::net: Requests to the sites it names
- notesy::accounts: Signing in to a service
- notesy::json: Reading and writing JSON
- notesy::toml: Reading and writing TOML
- notesy::yaml: Reading and writing YAML, and a note's front matter
- notesy::time: Now, written in the user's time zone, dates read, how long ago
- notesy::math: Trigonometry and the like, for drawing
- Names: Icon, Color, Tone, Side, Method, Command, Menu, Sidebar, Event: Notesy's names as enums
- notesy::preview: Its own screens for notesy preview
- notesy::perf: Timing its own work
- notesy::tex: Math macros for every note's formulas