In the previous article, we introduced the basic concepts of rich text and its development history. In this article, we will explore the currently mainstream open-source rich text editor engines. The most widely used rich text editor currently is the L1
rich text editor, which can meet the needs of the vast majority of use cases. As a result, many excellent open-source rich text engines have been born. These include standalone engine editors such as Slate.js
, partially out-of-the-box functional editors like Quill.js
, and secondary development based on these engines such as Plate.js
. This article mainly introduces three editing engines: Slate.js
, Quill.js
, and Draft.js
.
Slate
is a rich text core
that only provides an engine. Simply put, it does not provide various rich text editing functions by itself, and all rich text features need to be implemented through its provided API
. Even its plugin mechanism needs to be expanded by oneself, so using Slate
to build a rich text editor can be highly customizable. Although the documentation for Slate
is not particularly detailed, its examples are very rich. The documentation also provides a tutorial as a starting point, which is quite friendly for beginners. Speaking of which, if only an engine is provided, no one knows how to use it, haha.
In the Slate
documentation, there are descriptions of the design principles of the framework:
Slate
is that plugins are first-class citizen entities, which means you can completely customize the editing experience to build complex editors like Medium
or Dropbox
without struggling with the default settings of the library.schema
core. The core logic of Slate
imposes very few presets on the structure of your edited data. This means that when you build complex use cases, you will not be hindered by any pre-existing content.Slate
documents is a nested, recursive tree, just like DOM
. This means that for advanced use cases, it is possible to build complex components such as tables or nested references. Of course, you can also use a single-level structure to keep it simple.DOM
, Slate
's data model is based on DOM
. The document is a nested tree, using text selections and ranges, and exposes all standard event handling functions. This means that advanced features such as tables or nested references that can be done in DOM
can also be done in Slate
.Slate
documents execute commands to edit. It is designed to be advanced and very intuitive for editing and reading, so that customized features are as expressive as possible, greatly improving your understanding of the code.Slate
, especially how operations are applied to the document, is designed to allow collaborative editing at the highest level, so if you decide to implement collaborative editing, you don't have to consider a complete refactor.The data structure of a text sample looks like this:
JSON
structure similar to DOM
, making it intuitive and easy to understand.Beta
stage, there may be major API
changes. For example, version 0.50
was completely refactored.OT
or CRDT
algorithms for transformation operations.Slate
does not have a schema
, which means that Normalize
needs to be implemented independently.slate
can be found at https://docs.slatejs.org/
.slate
official website at https://www.slatejs.org/examples/richtext
.slate
can be accessed at https://github.com/WindrunnerMax/DocEditor
.slate
at https://plate.udecode.io/docs/playground
.OT
with slate
, visit https://github.com/solidoc/slate-ot
.https://github.com/pubuzhixing8/ottype-slate
for OTTypes
reference for slate
.CRDT
for slate
at https://github.com/humandx/slate-automerge
.slate
with YJS
collaboration, refer to https://github.com/BitPhinix/slate-yjs
.slate
can be found at https://github.com/yoyoyohamapi/book-slate-editor-design
.Quill
is a modern rich text editor with excellent compatibility and powerful extensibility, offering some out-of-the-box features. It was open-sourced in 2012
and brought many new features to the rich text editor, making it one of the most popular open-source editors with a rich ecosystem. You can find numerous examples, including comprehensive collaborative instances, on platforms like Github
.
The design principles of the framework are described in the documentation:
Quill's
features are implemented through the API and data changes can be intuitively obtained through the API. It is built on a text-centric API, eliminating the need to parse HTML
or DIFF DOM
trees, making its functionality more flexible and highly extensible.Quill
provides its document model as a powerful abstraction of the DOM, allowing for expansion and customization, with data structures such as Blots
, Parchment
, and Delta
taking center stage.Quill
has excellent compatibility and can run in the same way on older browser versions, ensuring consistent views and interactions across different browsers, as well as desktop and mobile devices.Quill
comes with some out-of-the-box features that are sufficient if customization is not required. Additionally, it offers high extensibility for customizing various functions.The data structure for a piece of text is as follows:
Vue
or React
.Delta
to describe data structures, implementing logic for operation transformation and facilitating collaboration.Delta
data structure is flat, making it cumbersome to implement features like tables.Quill 2.0
has been in development for a long time and has not been formally released yet. The current version, 1.3.7
, has not been updated for many years.Quill
comes with a rich set of features, this also results in a larger package size.Quill
can be found at https://quilljs.com/docs/quickstart/
.Quill
official website at https://quilljs.com/standalone/full/
.Delta
design and implementation in Quill
, refer to https://quilljs.com/docs/delta/
.OTTypes
reference for collaborative implementation with Quill
at https://github.com/ottypes/rich-text
.OT
with Quill
can be found at https://github.com/share/sharedb/tree/master/examples/rich-text
.CRDT-yjs
for Quill
, refer to https://github.com/yjs/y-quill
.Draft
is a framework for building rich text editors in React
, providing a powerful API for creating and customizing text editors. It aims to be easy to extend and integrate with other libraries. Combining it with React
allows developers to develop editors without directly manipulating the DOM or learning a separate UI building paradigm. Instead, they can directly write React
components to implement the editor's UI. The overall concept of draft
aligns very well with React
. For example, it uses state management to store data structures, leverages the immutable.js
library, delegates most data structure modifications to the browser's default behavior, and modifies rich text data through state management.
The README
of draft
describes the framework's design principles:
Scalable and customizable, providing building blocks to create various rich text editing experiences, from basic text styles to support for embedded media.
Declarative rich text, seamlessly integrating with React
using a declarative API
familiar to React
users, abstracting the details of rendering, selection, and input behavior.
Immutable editor state. The draft
model is built using immutable.js
, providing an API for functional state updates and actively utilizing data persistence to achieve scalable memory usage.
The data structure of a piece of text with emphasis is as follows.
React
for the UI layer and data management, making it user-friendly for React
users.React
as the UI layer, making it difficult to use with other UI frameworks.draft
has been heavily optimized for performance, it still exhibits lag when rendering a large amount of content.draft
documentation: https://draftjs.org/docs/overview
.draft
examples: https://draftjs.org/
.draft
codesandbox
example: https://codesandbox.io/s/github/gupta-piyush19/Draft-JS-Editor
.