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')) { … }promptandchooseresolve with the answer, ornullif the writer cancels.confirmasks yes or no, and resolves withtrueorfalse. 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>
),
})