Esta página se muestra en inglés. Una traducción al español está en curso.
SkillsApr 11, 2026·2 min de lectura

Lexical — Extensible Rich Text Editor Framework by Meta

Lexical is an extensible text editor framework from Meta providing excellent reliability, accessibility, and performance. Powers Facebook posts, comments, and messaging — designed for modern collaborative editing.

Listo para agents

Instalación lista para agent

Este activo puede instalarse después de elegir el runtime, revisar el plan y ejecutar el comando correspondiente.

Native · 98/100Política: permitir
Superficie agent
Cualquier agent MCP/CLI
Tipo
Skill
Instalación
Single
Confianza
Confianza: Established
Entrada
step-1.md
Comando de instalación directa
npx -y tokrepo@latest install 89ca3d82-356f-11f1-9bc6-00163e2b0d79 --target codex

Ejecutar después de confirmar el plan con dry-run.

TL;DR
Lexical is Meta's extensible text editor framework providing reliability, accessibility, and performance for modern web apps.
§01

What it is

Lexical is an extensible text editor framework from Meta. It provides the core editor engine and a plugin system for building rich text editors with excellent reliability, accessibility, and performance. Lexical powers Facebook posts, comments, and messaging. It is designed around an immutable state model that makes collaborative editing and undo/redo straightforward.

Lexical is designed for frontend developers building rich text editing experiences in React or vanilla JavaScript applications.

§02

How it saves time or tokens

Building a rich text editor from scratch is one of the hardest frontend challenges: content editable behavior is inconsistent across browsers, accessibility requirements are complex, and collaborative editing needs a solid state model. Lexical provides all of this as a framework. The plugin system lets you add features (mentions, hashtags, tables, embeds) incrementally without modifying the core editor. A production-quality editor that would take months to build from scratch can be assembled from Lexical plugins in days.

§03

How to use

  1. Install Lexical with React bindings:
npm install lexical @lexical/react
  1. Create a basic rich text editor:
import { LexicalComposer } from '@lexical/react/LexicalComposer';
import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin';
import { ContentEditable } from '@lexical/react/LexicalContentEditable';
import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin';
import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';

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

export function Editor() {
  return (
    <LexicalComposer initialConfig={initialConfig}>
      <RichTextPlugin
        contentEditable={<ContentEditable />}
        ErrorBoundary={LexicalErrorBoundary}
      />
      <HistoryPlugin />
    </LexicalComposer>
  );
}
  1. Add plugins for additional features (toolbar, mentions, tables, etc.).
§04

Example

Adding a toolbar with bold, italic, and link formatting:

import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
import { FORMAT_TEXT_COMMAND } from 'lexical';

function ToolbarPlugin() {
  const [editor] = useLexicalComposerContext();

  return (
    <div className='toolbar'>
      <button onClick={() => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'bold')}>
        Bold
      </button>
      <button onClick={() => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'italic')}>
        Italic
      </button>
    </div>
  );
}
§05

Related on TokRepo

§06

Common pitfalls

  • Trying to access the DOM directly instead of using Lexical's state model. Lexical manages the DOM through its editor state. Direct DOM manipulation will break the editor's state synchronization.
  • Not wrapping plugins inside LexicalComposer. All Lexical plugins must be children of the LexicalComposer component. Plugins outside the composer cannot access the editor instance.
  • Ignoring accessibility from the start. Lexical provides excellent accessibility primitives, but you must use them correctly in custom plugins. Test with screen readers during development, not as an afterthought.

Preguntas frecuentes

How does Lexical compare to Slate.js?+

Both are extensible editor frameworks. Lexical uses an immutable state model with a command-based architecture, making it more predictable for complex features. Slate uses a mutable model with transforms. Lexical is backed by Meta and powers Facebook's editors; Slate has a longer community history.

Can Lexical work without React?+

Yes. Lexical's core (the lexical package) is framework-agnostic. The @lexical/react package provides React-specific bindings. You can use Lexical with vanilla JavaScript or other frameworks.

Does Lexical support collaborative editing?+

Lexical's immutable state model is designed to support collaborative editing. You integrate a CRDT or OT library (like Yjs) with Lexical's state updates to enable real-time collaboration.

Is Lexical production-ready?+

Yes. Lexical powers Facebook posts, comments, and Messenger. It handles billions of editor interactions daily. The framework is battle-tested at Meta's scale.

Can I build a Notion-like editor with Lexical?+

Yes. Lexical's plugin system supports blocks, embeds, tables, mentions, and custom node types. Building a Notion-like experience requires significant custom development, but Lexical provides the right foundation.

Referencias (3)

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados