Skip to content
FrameworkJavaScript

Placeholder API: change the placeholder at runtime

Read and change the editor-level placeholder — the hint shown on the empty default block — without recreating the editor.

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

placeholder.get()

string | false

The current editor placeholder, or false when it is disabled.

When to use

Returns the current placeholder text, or false when it is disabled.

TypeScript
console.log(editor.placeholder.get()); // 'Type / for commands'

placeholder.set(value)

void

Sets the editor placeholder; updates existing blocks in place and applies to blocks created afterward. Pass false to disable. Available synchronously after construction — pre-ready calls are buffered and replayed.

When to use

Updates existing blocks in place and applies to blocks created afterwards; pass false to clear it.

TypeScript
const editor = new Blok({ holder: 'blok' });

// Safe before isReady — buffered and replayed once the editor boots
editor.placeholder.set('Write something…');

// Disable it
editor.placeholder.set(false);