Get AI summaries of any video or article — Sign up free
The Introduction of BlockSuite and Database Block thumbnail

The Introduction of BlockSuite and Database Block

AFFiNE·
5 min read

Based on AFFiNE's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.

TL;DR

BlockSuite is built for local-first collaborative apps using CRDT state management (built on Yjs) to handle conflicts automatically.

Briefing

BlockSuite is positioned as a local-first, block-based application framework built around CRDT state management—aiming to make rich collaborative editing feel as simple as working with local data, while also unlocking new ways to structure content. The core shift is that BlockSuite treats every update as an incremental, conflict-resilient operation, then layers a provider-based database backend on top so state changes can be stored locally or synced to the cloud without forcing developers to adopt complex editor-specific transformation models.

At the heart of the architecture is a CRDT data model (built on Yjs). CRDT records the full history of operations and automatically resolves conflicts during real-time collaboration. That design removes the need to learn framework-specific concepts like transformation commands or serialized action formats that many collaborative editors require for undo/redo. Instead, BlockSuite exposes simple block-level APIs—add, update, and delete blocks—so editing becomes closer to manipulating a list or map. Because CRDTs have stable serialized formats and can encode partial updates, changes can be distributed efficiently across network and local storage, with the underlying provider handling the I/O details.

BlockSuite also changes how rich text is modeled. Traditional editors often rely on a single contenteditable region, which limits control over how the browser mutates the DOM and makes it harder to implement consistent, block-level collaboration. BlockSuite replaces that approach with many discrete text blocks: a document becomes a collection of blocks (e.g., one per paragraph), and each block is a standalone text editor instance that only handles text. Non-text elements like images and tables no longer need to be embedded inside a contenteditable container, because the block store can manage them as separate block types.

That block store is a prerequisite for the architecture, and it enables both performance and extensibility. The editor logic inside each text block can stay small, which makes it feasible to build a custom text editor called “Virgo” quickly and iterate on it independently of the rest of the system. For extensibility, BlockSuite defines blocks using web components, so third-party blocks can be built with any UI framework by packaging them as web components. It also supports multiple “container blocks” so the same underlying data can be presented in different layouts and selection states—enabling collaborative apps like kanban boards, documents, or forms that share a common model but differ in view.

Rendering is treated as modular too. Instead of requiring a DOM-based renderer, BlockSuite includes an experimental canvas renderer for whiteboards, where the top-level canvas view is driven by block state. Finally, the framework’s direction extends beyond editing: a prototype “Database Block” is introduced. It can convert regular blocks (paragraphs, lists, etc.) into database-ready blocks, transform between “Virgo” and database representations, and preserve column information across the workspace. It also supports switching among multiple database views—kanban, timeline, schedule, list—and includes a third-party plugin system for custom data types and custom “wheels” from the community.

Cornell Notes

BlockSuite is a local-first, block-based framework built on CRDT state management (via Yjs) to make collaborative editing work like local development. CRDT history enables automatic conflict resolution and efficient incremental updates, so developers can use simple block APIs (add/update/delete) rather than editor-specific transformation DSLs. Rich content is modeled as many discrete blocks (e.g., one text block per paragraph) instead of a single contenteditable region, giving better control over DOM behavior and collaboration. Blocks are extensible through web components, container blocks enable multiple views over the same data model, and rendering can be swapped (including an experimental canvas renderer). A prototype Database Block adds database features like sorting/filtering and view switching (kanban/timeline/schedule/list) with support for custom data types via plugins.

How does BlockSuite’s CRDT approach change what developers must learn for collaboration and undo/redo?

Instead of modeling user actions as framework-specific serialized operations (often tied to transform commands or action formats), BlockSuite relies on CRDT’s built-in operation traceability. Each update to text/arrays/maps is already a traceable operation, so undo/redo and conflict handling can be achieved without learning a special DSL for transforms. The practical result is that editing state is done through straightforward block APIs—addBlock, updateBlock, and deleteBlock—similar to manipulating a to-do list rather than orchestrating complex editor internals.

Why does BlockSuite avoid a single contenteditable region for rich text?

A single contenteditable region hands control of DOM mutations to the browser, which makes it harder to control how edits are applied and synchronized. BlockSuite instead splits documents into many discrete blocks—think one text block per paragraph—where each block is a standalone text editor that handles only text. Images, tables, and other non-text elements become separate blocks, so they no longer need to be embedded inside contenteditable.

What does “local-first” mean in BlockSuite’s architecture, and how does syncing work?

State updates are managed as if building a local application, whether or not the workspace syncs to the cloud. CRDT incremental updates can be distributed efficiently, and BlockSuite provides provider-based database backends that handle underlying I/O. The developer interacts with the same block state model, while the provider decides whether data ends up in local storage or a cloud backend.

How does BlockSuite support extensibility across different UI frameworks?

Blocks are defined as web components. That means third-party blocks can be built using any framework as long as they are encapsulated as web components. The FI editor is also standardized as a web component, and it can be used by installing Prosperity right now.

What is the purpose of container blocks, and how do they relate to views?

Container blocks let the same underlying data model be presented with different layout and UI selection states. BlockSuite encourages sharing one model across app types—forms, kanban, documents—while changing the view. This makes it easier to build collaborative applications that look and behave differently but still operate on the same block-based state.

What capabilities does the prototype Database Block add on top of block-based editing?

The Database Block brings database-style operations like sorting and filtering. It can convert regular blocks (paragraph blocks, list blocks, etc.) into database blocks, transform between “Virgo” and database representations, and preserve column information across the workspace. It also supports switching among multiple database views—kanban, timeline, schedule, list—and includes a third-party plugin system for custom data types and custom wheels.

Review Questions

  1. How does CRDT history enable conflict resolution and efficient incremental updates in BlockSuite, and why does that reduce the need for editor-specific transformation concepts?
  2. What architectural changes allow BlockSuite to model rich text as many blocks rather than a single contenteditable region, and how does that affect non-text elements like images and tables?
  3. In what ways do web components and container blocks work together to support third-party extensibility and multiple views over the same data model?

Key Points

  1. 1

    BlockSuite is built for local-first collaborative apps using CRDT state management (built on Yjs) to handle conflicts automatically.

  2. 2

    Editing is organized around block-level operations (add/update/delete), avoiding editor-specific transformation DSLs common in other collaborative editors.

  3. 3

    Rich content is modeled as many discrete blocks (e.g., per-paragraph text blocks) rather than a single contenteditable region, improving control over DOM behavior.

  4. 4

    A centralized block store enables separate handling of text and non-text elements like images and tables without embedding them in contenteditable.

  5. 5

    Blocks are extensible via web components, allowing third-party blocks to be authored in any UI framework and packaged consistently.

  6. 6

    Container blocks support multiple layouts and selection states over the same shared data model, enabling different app experiences from the same underlying structure.

  7. 7

    A prototype Database Block adds database features (sorting/filtering), block-to-database conversion, multi-view switching (kanban/timeline/schedule/list), and plugin support for custom data types.

Highlights

CRDT history is used as the general-purpose state mechanism, enabling automatic conflict resolution and efficient incremental updates without special middleware.
Splitting documents into many standalone text blocks avoids the unpredictability of browser-driven DOM mutations inside contenteditable.
Web components make block extensibility framework-agnostic, while container blocks let the same data power multiple collaborative views.
The Database Block prototype can transform regular blocks into database blocks and switch among kanban, timeline, schedule, and list views while preserving column data.

Topics

  • Local-First CRDT
  • Block-Based Rich Text
  • Web Components
  • Container Views
  • Database Block Prototype

Mentioned

  • CRDT
  • DOM
  • I/O
  • UI