lexical README

The project's README from github.com/facebook/lexical. As one markdown file: README.md.

Lexical

An extensible text editor framework that provides excellent reliability, accessibility and performance.

NPM Version NPM Downloads Build Status Discord

Documentation | Getting Started | Playground | Gallery


Features

Quick Start

For framework-agnostic usage, start with the Vanilla JS quick start or the Vanilla JS example.

For React applications, install Lexical with the official React bindings:

npm install lexical @lexical/react
import { $getRoot, $getSelection } from 'lexical';
import { LexicalComposer } from '@lexical/react/LexicalComposer';
import { PlainTextPlugin } from '@lexical/react/LexicalPlainTextPlugin';
import { ContentEditable } from '@lexical/react/LexicalContentEditable';
import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin';
import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';

const initialConfig = {
  namespace: 'MyEditor',
  onError: (error) => console.error(error),
};

function Editor() {
  return (
    <LexicalComposer initialConfig={initialConfig}>
      <PlainTextPlugin
        contentEditable={<ContentEditable />}
        ErrorBoundary={LexicalErrorBoundary}
      />
      <HistoryPlugin />
    </LexicalComposer>
  );
}

Try it yourself:

Development

# Install dependencies
pnpm install

# Start playground dev server
pnpm run start

# Run tests
pnpm run test-unit
pnpm run test-e2e-chromium

# Lint and type check
pnpm run ci-check

See CONTRIBUTING.md for detailed development guidelines.

Documentation

Community & Support

Browser Support

Browser Version
Chrome 86+
Firefox 115+
Safari 15+
Edge 86+

Contributors

We welcome contributions! Please read our Contributing Guide to learn about our development process and how to propose bugfixes and improvements.

License

MIT License Copyright ©2026 Meta Platforms, Inc.

lexical (facebook/lexical)

Searching Database…

这是什么?Lexical 是 Meta 出品的一个面向 Web 的可扩展文本编辑器框架,主打可靠性、无障碍访问和性能。你可以用它在浏览器里搭建自己的富文本编辑器。
它是拿来就能用的成品编辑器,还是需要在它基础上自己搭建的框架?它是一个框架,而不是开箱即用的应用:框架不绑定任何 UI,核心由你自己用插件组装成编辑器,并提供了官方的 React 绑定。
我怎么把它装进我的项目里?从 npm 安装核心包,再按你的技术栈加上对应的层——React 应用用官方的 @lexical/react 绑定,也有 Vanilla JS 的快速上手指南。文档在 lexical.dev。
用它是不是必须绑定 React?不是——核心可以配合任何 UI 框架使用;React 只是官方首选方案,其他情况都有 Vanilla JS 的路子。
在浏览器版本方面有什么需要了解的要求吗?它只支持现代浏览器:Chrome 86+、Edge 86+、Firefox 115+ 和 Safari 15+。不支持旧版浏览器。
开箱即用支持哪些内容类型?表格、列表、代码块和图片开箱即用;超出这些的需求,插件架构允许你自定义节点来实现。
撤销和重做是怎么实现的?状态是不可变的,天然支持时间回溯,所以撤销和重做是内置的,不用你自己去接线实现。
在接入我的应用之前,能不能先试用一下?可以——仓库里附带一个 playground,以及纯文本和富文本的示例编辑器,lexical.dev 上的文档也有在线示例。
它对无障碍访问做得怎么样?无障碍访问是它的招牌特性:内置支持并符合 WCAG 标准,这也是相比自己从零写编辑器、选它的一个主要理由。
What are similar projects?ckeditor5, slate, BlockNote, plate, tiptap, tui.editor, trix, editor.js
Creator
facebook
Size
144.8 MB
Stars
24K
Age
5y
Commits · 90 Days