Code Monkey home page Code Monkey logo

blocksuite's Introduction

BlockSuite

BlockSuite logo and name

Codecov Checks Status Issues Closed NPM Latest Release NPM Nightly Release Open in StackBlitz Join Discord


The BlockSuite project aims to provide a toolkit for building collaborative editors. It creates a tech stack suitable for general-purpose structured content editing, and builds upon that to implement various first-party editors. By leveraging blocks as the fundamental primitive, all BlockSuite-based editors share high compatibility, and can even be dynamically switched as different view layers at runtime.

โš ๏ธ BlockSuite is already in use in the production environment of AFFiNE, but it's still under heavy development and undergoing rapid changes. Stay tuned or check out our roadmap!

Introduction

BlockSuite was originally designed for the AFFiNE knowledge base. In AFFiNE, the same piece of data can be presented in various forms including documents, whiteboards, and tables. Users can smoothly switch among these different forms with real-time collaboration support. To this end, BlockSuite focuses on utilizing blocks as its primitive element to create a standardized collaborative editing engine. This consists of the following modules:

  • โšก๏ธ CRDT-Driven Block State Management: The block tree model in BlockSuite is implemented using the Yjs CRDT library. Acting like a conflict-free Git, CRDT (conflict-free replicated data type) enables the editor to have built-in conflict resolution and time travel capabilities. By using CRDT as the single source of truth, all editors based on BlockSuite are natively collaborative. Plus, CRDT is blazingly fast.
  • โš›๏ธ Atomic Block UI Components: In BlockSuite, blocks act like molecules, which can be further assembled from other blocks or more atomic components. These atomic components include rich-text and canvas renderers. For example, in BlockSuite, 100 paragraph blocks will generate 100 instances of rich-text components, and a form block could connect to multiple rich-text components. All these rich-text instances are linked to the same CRDT block tree, ensuring the cross-block editing operations can be consistently managed. Additionally, BlockSuite editors and blocks are all defined as Web Components, making them easily integratable with other frameworks.
  • ๐ŸŽจ Adaptable Selection Manager: BlockSuite models operations on abstract selection states, allowing for the extension of various types of selections that are well-suited for multi-user collaboration.
  • ๐Ÿ’พ Content Transformation and Serialization: BlockSuite supports JSON-based document snapshots and offers extensibility for compatibility with third-party formats. It also provides auxiliary tools for managing forward and backward compatibility, as well as data validation and migration issues.
  • ๐Ÿ“ก Providers for Data Synchronization: The document state in BlockSuite can be serialized into binary and distributed through various providers, allowing for transmission via WebSocket, or storage into persistent backends like SQLite or IndexedDB. Thanks to their support for on-demand loading and incremental updates, these providers work efficiently.

Based on this framework, BlockSuite has already implemented editing capabilities for various types of structured data:

Resources

Getting Started

To learn how to start using BlockSuite, visit blocksuite.affine.pro.

Building

See BUILDING.md for instructions on how to build BlockSuite from source code.

Contributing

BlockSuite accepts pull requests on GitHub. Before you start contributing, please make sure you have read and accepted our Contributor License Agreement. To indicate your agreement, simply edit this file and submit a pull request.

License

MPL 2.0

blocksuite's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.