What a plugin can do
Everything is in index.d.ts. The plugins on Bläck Studio's list are written this way too, and each shows a part of the API:
| Plugin | Shows |
|---|---|
filter-words | sandboxed: marks in the text, settings, a status bar item, events |
markdown-export | sandboxed: a format in Compile |
name-generator | in the window: a view, an inspector tab, a menu entry, a TipTap shortcut, changing the book |
pomodoro | in the window: React in the status bar, a hotkey |
cast-suggest | sandboxed: suggestions as you type, kept up to date as the navigator changes |
pandoc-export | sandboxed: running a program in its temporary folder, with formats that follow its settings |
continue-writing, today, book-progress, writing-calendar, series-overview, recent-activity | in the window: cards on the welcome screen's dashboard, built from the writer's library; starting a sprint |
dictation | in the window: the microphone, speech turned into text on the device (app.speech), a toolbar button, a hotkey, a secret setting, a request to a service using the writer's own key |
In short:
| Method | Adds |
|---|---|
addCommand | a command in the palette (Ctrl+K) and the Plugins menu, with a hotkey if you like |
addView | a view beside the corkboard and outliner (window only) |
addInspectorTab | a tab in the inspector, for the items you choose (window only) |
addStatusBarItem | an item in the status bar, drawn with React or as text you change |
addEditorMenuItem | an entry in the text's right-click menu |
addBinderMenuItem | an entry in the navigator's right-click menu |
addExporter | a format in Compile |
addHighlighter | marks in the text, found one paragraph at a time and never saved |
registerEditorExtension | TipTap extensions: marks, nodes, input rules, shortcuts (window only) |
addSidebarPanel | a tab beside the navigator (window only) |
addToolbarButton | a button in the editor's toolbar |
addSuggester | suggestions under the caret after a trigger: @ for characters, # for tags… |
addImporter | a kind of file for File → Import Documents |
addBookImporter | a whole book from another app's file or folder, in File → Import and on the welcome screen (API 7) |
addSettings | settings that Bläck Studio draws for you in Settings → Plugins |
addSettingsPanel | settings that you draw yourself (window only) |
on | project-open, project-close, selection-change, doc-change, nodes-change |
loadData, saveData | your plugin's data, stored on this computer |
You read settings declared with addSettings from this.settings. Bläck Studio keeps only the values the writer changed. So if a new version of your plugin has a better default, everyone who hadn't changed that setting gets it. updateSettings({ key: undefined }) puts a setting back to its default.
this.app gives you the rest, each part described below:
app.project: the book.app.editor: the selection, comments on it, typing at the caret, and, in the window, the editor itself.app.ui: notices and dialogs.app.net: the internet, limited to the hosts you asked for.app.files: files and folders the writer chose.app.exec: the programs you named.
If your plugin has a styles.css next to its manifest, Bläck Studio loads it with the plugin.
In the window, react, react/jsx-runtime, @tiptap/core and @tiptap/pm/* are Bläck Studio's copies. The build leaves them out of your script. Your interface follows the theme if you use Bläck Studio's classes: btn, input, insp-section, sb-btn and so on.