FrameworkJavaScript
Reaching the editor instance
The methods below run on the editor you created with new Blok(). They are available once editor.isReady resolves.
TypeScript
// You already hold the instance returned by the constructor.
const editor = new Blok({ holder: 'editor' });
await editor.isReady;
// Call any API method on it.
editor.caret.setToLastBlock('end');Methods
notifier.show(options)
voidShow a notification message. Supports simple, confirm, and prompt notifications.
When to use
Built-in toast for lightweight feedback. Set type: 'confirm' or 'prompt' to collect a yes/no or text response.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
options | NotifierOptions | ConfirmNotifierOptions | PromptNotifierOptions | Required | — | Notification configuration. Shape depends on type. |
options.message | string | Required | — | Notification text. May contain HTML. |
options.type | 'alert' | 'confirm' | 'prompt' | — | 'alert' | Notification type. confirm and prompt add action buttons. |
options.style | 'success' | 'error' | — | undefined | Built-in visual style for alert notifications. |
options.time | number | — | 8000 | Auto-dismiss delay in ms for every notification type (default 8000). |
options.okText | string | — | 'Confirm' / 'Ok' | Label for the confirm/submit button (confirm/prompt types only). |
options.okHandler | (event: Event) => void | (value: string) => void | — | undefined | Confirm/submit callback. Receives the click event for confirm, or the input value for prompt. Required for prompt notifications. |
options.cancelText | string | — | 'Cancel' | Label for the cancel button (confirm type only). |
options.cancelHandler | (event: Event) => void | — | undefined | Cancel/close callback (confirm type only). |
options.inputType | string | — | 'text' | HTML input type for the prompt's text field (prompt type only). |
options.placeholder | string | — | undefined | Placeholder text for the prompt's input field (prompt type only). |
options.default | string | — | undefined | Default value pre-filled in the prompt's input field (prompt type only). |
Errors
The notifier module fails to load (e.g. blocked by CSP, dynamic import failure).
[Blok] Failed to display notification. Reason: <error>
show()never throws or rejects — check the browser console, since the failure is logged rather than propagated to your call site.
TypeScript
// Simple notification
editor.notifier.show({
message: 'Changes saved',
style: 'success'
});
// → renders a toast in the corner of the editor; returns nothing to await
// Confirm notification
editor.notifier.show({
message: 'Delete this block?',
type: 'confirm',
okHandler: () => console.log('Confirmed'),
cancelHandler: () => console.log('Cancelled')
});
// Prompt notification
editor.notifier.show({
message: 'Enter a title',
type: 'prompt',
okHandler: (value) => console.log('Entered:', value)
});