Skip to content
FrameworkJavaScript

Paragraph block: Blok's default text block

The default text block. Supports rich inline formatting (bold, italic, links, colour). Empty top-level paragraphs are excluded from saved output unless `preserveBlank` is enabled; empty paragraphs nested inside another block (callout, toggle, column, …) are always kept.

Import

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

Configuration

OptionTypeDefaultDescription
placeholderstring"Write something or press / to select a tool" (localised)Placeholder text shown when the block is empty and focused.
preserveBlankbooleanfalseWhen true, empty paragraph blocks are kept in the saved output. Exception: a document consisting of a single empty block of the default tool always saves as `blocks: []`, regardless of this option.
styles.sizestringundefinedCustom CSS font-size override (e.g. "18px", "1.25rem").
styles.lineHeightstringundefinedCustom CSS line-height override (e.g. "1.8", "28px").
styles.marginTopstringundefinedCustom CSS margin-top override (e.g. "12px", "0.75rem").
styles.marginBottomstringundefinedCustom CSS margin-bottom override.

Save Data

TypeScript
interface ParagraphData {
  text: string;             // HTML string (may include <b>, <i>, <a>, <mark>)
  textColor?: string;       // Block colour preset, present when set
  backgroundColor?: string; // Block background colour preset, present when set
}
JSON
{
  "id": "abc123",
  "type": "paragraph",
  "data": {
    "text": "Hello <b>world</b>"
  }
}

Usage Example

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

const editor = new Blok({
  holder: 'editor',
  tools: {
    paragraph: {
      class: Paragraph,
      placeholder: 'Start writing…',
      preserveBlank: false,
    },
  },
});