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

Start

Building

Beyond Bläck Studio

How it runs

Sharing

Look up

Dialogs

this.app.ui asks the writer, in dialogs Bläck Studio draws:

const name = await this.app.ui.prompt({ title: 'Name the scene', label: 'Title', value: 'Untitled' })
if (name === null) return                                  // cancelled

const kind = await this.app.ui.choose({
  title: 'Export as',
  options: [
    { value: 'odt', label: 'OpenDocument', detail: '.odt' },
    { value: 'tex', label: 'LaTeX', detail: '.tex' },
  ],
})

if (await this.app.ui.confirm('Replace every em dash?', 'In every scene.', 'Replace')) { … }
  • prompt and choose resolve with the answer, or null if the writer cancels.
  • confirm asks yes or no, and resolves with true or false. The dialog says it's your plugin asking.
  • notify(message, action?) shows a notice, with a button if you give it one.

All of these work sandboxed too, except that a sandboxed plugin's notice can't have a button.

openModal({ title, render, wide?, onClose? }) shows a dialog of your own drawing (window only). render is given a close function, and openModal returns one too. onClose hears when it's gone: 'closed' by the writer (Escape, ✕) or by close, or 'replaced' by another dialog opened over it.

const close = this.app.ui.openModal({
  title: 'Word of the day',
  render: (close) => (
    <div>
      <p className="insp-hint">{word}</p>
      <button className="btn primary" onClick={close}>Thanks</button>
    </div>
  ),
})