More of the interface
addSidebarPanel({ id, name, render }): a tab beside the navigator, drawn with React (window only).addToolbarButton({ id, title, icon, active?, run }): a button in the editor's toolbar. In the window the icon is a component. In either mode it can also be a few characters ('★').activeshows the button as pressed.addImporter({ id, name, extensions, import }): a kind of file for File → Import Documents. Bläck Studio offers it in the file dialog and passesimportthe file (name,ext,dataas bytes,text). You return the documents to create:[{ title, html }].addBookImporter({ id, name, from?, extensions, folder?, import }): imports a whole book from another app's file or folder. Usefolder: truefor a folder, as with a Scrivener project's .scriv. On a phone, the writer chooses a zip of it. The importer appears in File → Import asname, and on the welcome screen as "Import fromfrom". Bläck Studio asks the writer for the file and passes it toimport. For a file, that'sname,ext,dataandtext. For a folder, it'sfiles(every file in the folder, by its path there), plusread(path)andreadText(path)to read one of them. You return the book:- its
title, labels, statuses and storylines; - the items in each part of the navigator (
manuscript,characters,places,notes,research,trash), each with its text as HTML, synopsis, notes, keywords, label and status; - beats on the storylines.
- its
Items refer to each other (a scene's cast and place, a beat's scene) by ids that you make up for the import. Bläck Studio shows the writer what it created, and either makes it a new book or adds it to the open one. To say why a file can't be read, throw an Error. Book importers need no permission and work in sandboxed plugins. They need "apiVersion": 7. The Scrivener and Plottr imports on the list are built this way.
styles.css: if it's next to the manifest, Bläck Studio loads it with the plugin and removes it when the plugin is removed. Put your plugin's id in your class names, so they don't clash with Bläck Studio's or another plugin's.