notesy::sections
A section of the sidebar, under notesy's notes and tags: a tree of the
plugin's own (bookmarks, tasks, a list from somewhere), drawn like the
vault's and folded the same way. Its script adds it; takes the ui
permission.
rustuse notesy::{events, sections, Event};
pub fn ready() {
let pinned = sections::add("pinned", "Pinned");
pinned.set([
#{ id: "plan", name: "Launch plan", icon: "pin", note: "Projects/Launch plan.md" },
#{ id: "reading", name: "Reading", children: [
#{ id: "book", name: "The book", note: "Reading/The book.md", detail: "p. 120" },
] },
]);
events::on(Event::SidebarItem, |event| { /* event.section, event.item */ });
// Right-click an item: "Unpin". `item` is the id of the one it was opened on.
pinned.menu("unpin", #{ title: "Unpin", icon: "pin" }, |item| { /* unpin it */ });
}
| Function | What it does |
|---|---|
sections::add(key, options) |
Adds a section, empty until it's set, and returns it. options is its title, or #{ title }. |
section.set(items) |
Replaces what it shows. |
section.action(key, options, run) |
Adds a button to its heading, and returns it: options as a menu item's (#{ title, icon }, notesy::menus), the title its tip; run() when it's clicked. |
sections::action(section, key, options, run) |
The same on one of notesy's own sections' headings: Sidebar::Notes or Sidebar::Tags (Names: Icon, Color, Tone, Side, Method, Command, Menu, Sidebar, Event). |
section.menu(key, options, run) |
Adds an item to its items' right-click menu, and returns it: options as a menu item's (notesy::menus), and run(item) gets the id of the item the menu was opened on. |
section.remove() |
Takes it away. |
key names it for good (lowercase letters, digits, -, _ and .,
starting with a letter): notesy remembers which of its folders are open
by it.
An item is #{ id, name } and any of:
| Field | What it is |
|---|---|
icon |
Its icon, by name (notesy::view). |
detail |
Faint text at its right, like a count. |
note |
A note (relative to the vault) a click opens. |
command |
A command a click runs, instead: a command's id(), or notesy's own. |
children |
Items inside it: it's a folder. |
menu |
Which of its section's menu items its right-click menu has, by key (["unpin"]); every one unless it says, and none for []. |
Ids are unique within the section: they say which item was clicked, and
which folders stay open. The plugin hears every click as the
sidebar.item event, whatever the item opens (notesy::events).
A heading's buttons show at its right while the pointer's on it: notesy's
own first (Notes has New note, New folder and Close every folder), then
plugins', at most 4 of a plugin's on one heading. remove() on what
action returned takes a button away.
An item that opens a note has "Open in new tab" in its menu too, before the section's own items. At most 500 items at the top, nested 8 deep. Whatever a script added goes when it stops.
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