newsletter-builder
  • Type to search the documentation.

Components

Document model

The serialisable NewsletterDocument, block types, themes and factory helpers.

NewsletterDocument

A document is JSON. Nothing in it is a function, class instance or DOM node, so it round-trips through JSON.stringify and any database.

shape
interface NewsletterDocument {
  version: 1
  subject: string      // merge tags allowed
  preheader: string    // inbox preview text
  theme: NewsletterTheme
  blocks: NewsletterBlock[]
}

Block types

Blocks are a discriminated union on type. columns is the only container and can only live at the root; its cells hold leaf blocks.

Blocks

Theme

NewsletterTheme

Factories and tree helpers

creating documents
import {
  createBlankDocument,
  createWelcomeTemplate,
  createProductUpdateTemplate,
  createBlock,
  createColumns,
  insertBlock,
} from 'newsletter-builder-react'

const doc = createBlankDocument()
const withButton = {
  ...doc,
  blocks: insertBlock(doc.blocks, createBlock('button'), { parentId: null, index: 0 }),
}