Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:AFK surf Open agent Editor Container Assembly

From Leeroopedia
Knowledge Sources
Domains Editor, Web_Components, BlockSuite
Last Updated 2026-10-25 00:00 GMT

Overview

Pattern of instantiating an editor custom element, assigning a loaded doc store, and assembling per-scope extension lists from a view manager and common extensions.

Description

The BlockSuite editor is a Lit custom element (affine-editor-container) whose behavior is composed from two extension lists: pageSpecs (page-mode rendering) and edgelessSpecs (whiteboard-mode rendering). Each list is the concatenation of scope-specific extensions from a ViewExtensionManager.get(scope) and a shared common extension list (font config, editor setting, parse-doc-url, DocModeProvider override, code-block preview). The editor is bound to a doc store (editor.doc = store) and a collection (for doc-link jumping). Interactive providers like RefNodeSlotsProvider subscribe to signals (e.g. docLinkClicked) to drive navigation. Feature flags gate advanced behaviors. This composition lets the same editor instance render very different surfaces just by swapping the spec list.

Usage

Apply this principle whenever you instantiate a BlockSuite editor or any web-components editor whose behavior is composed from extension lists. Keep scope-specific and common extensions separate so they can be reused and tested independently.

Theoretical Basis

The editor is an extension-composition container: specs = scopeExtensions ⊕ commonExtensions. The view manager resolves scope extensions per mode ('page', 'edgeless'); the common list provides cross-cutting services. DI providers (e.g. DocModeProvider) are overridden by passing a setup object that mutates the container.

Pseudo-code:

const editor = document.createElement('affine-editor-container');
editor.doc = store;
const common = getCommonExtensions(editor);
editor.pageSpecs = [...viewManager.get('page'), ...common];
editor.edgelessSpecs = [...viewManager.get('edgeless'), ...common];

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment