Skip to content
FrameworkJavaScript

Bold: strong emphasis in Blok

Wraps selected text in <strong>. Activated with Cmd/Ctrl+B or by clicking the B button in the inline toolbar. Supports nested bold ranges and normalises overlapping markup on paste.

Import

TypeScript
import { Bold } from '@bloklabs/core/tools';

Save Data

TypeScript
// No separate data shape. Bold is a mark on a run of the block's text field:
// { "text": "world", "marks": { "bold": true } }
JSON
// Inline tools affect the text field of the containing block.
// A paragraph with bold text:
{
  "type": "paragraph",
  "data": {
    "text": [{ "text": "Hello " }, { "text": "world", "marks": { "bold": true } }]
  }
}

Usage Example

TypeScript
import { Blok } from '@bloklabs/core';
import { Bold, Paragraph } from '@bloklabs/core/tools';

const editor = new Blok({
  holder: 'editor',
  tools: {
    // Paragraph is the default block and is not bundled with the core —
    // without it the editor starts with an "unsupported block" stub.
    paragraph: Paragraph,
    bold: Bold,
    // or with a shortcut override:
    // bold: { class: Bold, shortcut: 'CMD+SHIFT+B' },
  },
});