Reaching the editor instance
The methods below run on the editor you created with new Blok(). They are available once editor.isReady resolves.
// 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
tools.getBlockTools()
BlockToolAdapter[]Get all available block tool adapters. Each adapter exposes `name` plus tool metadata, including `assetKind` — set to `'image' | 'video' | 'audio' | 'file'` on media tools that store an uploaded asset URL at `data.url`, and `undefined` otherwise. Use it to discover the media-bearing tool set at runtime (instead of hardcoding each tool's data shape) and reconcile a saved document's `data.url`s against your CDN — e.g. to garbage-collect orphaned uploads.
When to use
Enumerate the registered block tools at runtime — handy for a custom block picker or debugging tool config.
const blockTools = editor.tools.getBlockTools();
blockTools.forEach(tool => {
console.log('Available tool:', tool.name);
});
// Discover which block types hold uploaded media, then collect their URLs
const mediaTypes = new Set(
editor.tools.getBlockTools().filter(t => t.assetKind).map(t => t.name)
);
const referenced = (await editor.save()).blocks
.filter(b => mediaTypes.has(b.type))
.map(b => b.data.url);tools.update(name, config)
voidShallow-merge new configuration into an installed tool at runtime — no editor recreation. A `toolbox` key is treated as the tool-level setting (same as `toolbox` in the `tools` map): pass `toolbox: false` to hide the tool from every insertion surface (existing blocks keep rendering) or a toolbox object to (re)show it — permission gating without rebuilding the editor. Under the React adapter this is automatic: change the `toolbox` value in the `tools` prop and `useBlok`/`BlokEditor` applies it in place.
// Swap a config value (e.g. an uploader) at runtime
editor.tools.update('image', { uploader: { uploadByFile } });
// Permission flip: hide the tool from the + / slash / convert menus.
// Existing goodsList blocks still render; insertion is gated.
editor.tools.update('goodsList', { toolbox: false });
// Re-enable it later
editor.tools.update('goodsList', { toolbox: { title: 'Goods List' } });tools.setInlineToolbar(config)
voidRuntime setter for the global `inlineToolbar` config. Re-assigns inline tools for every block tool and recomposes the memoized sanitize configs — so paste-time sanitization follows the new set immediately, and the inline toolbar reflects it on the next selection. Tool-scoped `inlineToolbar` settings (arrays and opt-outs) stay authoritative. Pass `true` for all inline tools, `false` for none, or an ordered list of inline tool names. If you render saved content through @bloklabs/core/view, note that a viewSchema is composed from the inlineToolbar value it was defined with — after a runtime setInlineToolbar involving custom inline tools, recompose it with defineBlokSchema before calling blocksToHtml.
When to use
Takes effect on the next selection; paste-time sanitization is recomposed immediately, so pasted content follows the new inline-tool set right away. If you render saved content through @bloklabs/core/view, note that a viewSchema is composed from the inlineToolbar value it was defined with — after a runtime setInlineToolbar involving custom inline tools, recompose it with defineBlokSchema before calling blocksToHtml.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
config | boolean | string[] | Required | — | true enables every registered inline tool, false disables the inline toolbar, an array restricts it to the listed inline tools in that order. |
// Restrict inline formatting to bold and italic at runtime
editor.tools.setInlineToolbar(['bold', 'italic']);
// Disable the inline toolbar entirely
editor.tools.setInlineToolbar(false);
// Back to every registered inline tool
editor.tools.setInlineToolbar(true);tools.isInstalled(name)
booleanReturns true when a tool with the given name is installed and available on this editor instance — block, inline or tune. Public introspection over the installed tool set, e.g. as a guard before `tools.update(name, config)`, which throws for unknown names.
When to use
Guard runtime tool calls — tools.update() throws for names that are not installed.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
name | string | Required | — | Registered tool name to look up. |
if (editor.tools.isInstalled('image')) {
editor.tools.update('image', { uploader: { uploadByFile } });
}