Bläck StudioPlugin SDK v1.0.0 · API 10
Contents

Start

Building

Beyond Bläck Studio

How it runs

Sharing

Look up

Versions, and the moments the app waits for

A plugin can keep versions of the project. The app draws the list, so this works in a sandboxed plugin too:

this.addVersionHistory({
  id: 'versions',
  list: async (file) => [{ id: 'v2', label: 'Chapter one done', at: '2026-11-07T10:00:00Z' }],
  read: async (version, file) => '<p>The text then.</p>',
  save: async (message) => true,     // false if nothing has changed since the last one
  status: async () => ({ text: 'The last backup failed.', problem: true }),   // or null
})
this.versionsChanged()               // the app reloads the list

The list shows in Book → Versions & Backups and in a document's history. file is a path in the project's folder. There's no call for restoring. The writer restores a document from the list, and the app reads its text with read, keeps a snapshot of the document first, and then replaces it.

this.during(event, handler) registers a handler for a moment when the app waits for plugins, up to a time limit:

  • 'copy-due': the writing timer is due and something has changed, or a new book was created (info.reason says which). 30 seconds.
  • 'project-closing': a book is closing, or the app is quitting (then info.quitting is set). 30 seconds.
  • 'session-end': a writing session ended, after 30 minutes without writing or because the book is closing. 10 seconds.

The handler receives { words, changed }. After the limit the app carries on, so a plugin can't stop anything from closing. A plugin has one handler per event: calling during again for the same event replaces it. app.project.flush() resolves once the project's files are all saved, and app.project.getProjectData() and setProjectData(value) store data with the project, on this device.