npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-lexical-editor

v0.1.3

Published

A rich text editor library for React using Lexical

Readme

React Lexical Editor

A rich text editor library for React built on top of Lexical, Meta's extensible text editor framework.

NPM Version CI License: MIT

Features

  • 📝 Rich text editing (bold, italic, underline, headings, etc.)
  • 🖼️ Image support with captions
  • 🔗 Links with custom editing UI
  • 🧰 Customizable toolbar
  • 📱 Responsive design
  • 🔄 History (undo/redo)
  • 🔌 Extensible plugin architecture
  • 📦 Lightweight and optimized bundle

Installation

# npm
npm install react-lexical-editor

# yarn
yarn add react-lexical-editor

# pnpm
pnpm add react-lexical-editor

Quick Start

import React from 'react';
import { LexicalEditor } from 'react-lexical-editor';

function MyEditor() {
  return (
    <LexicalEditor
      placeholder="Start typing..."
      onChange={(editorState, editor) => {
        console.log(JSON.stringify(editorState.toJSON()));
      }}
    />
  );
}

Documentation

LexicalEditor Props

| Prop | Type | Default | Description | | -------------------------- | --------------------------------------------------------------- | ---------------------- | ---------------------------------------- | | initialState | string | undefined | Initial editor state as JSON string | | placeholder | string | 'Enter some text...' | Placeholder text when editor is empty | | theme | Record<string, any> | {} | Override theme styles | | onChange | (editorState: EditorState, editor: LexicalEditorType) => void | undefined | Callback when content changes | | editorConfig | Partial<InitialConfigType> | {} | Additional Lexical editor configuration | | contentEditableClassName | string | '' | Class name for ContentEditable component | | children | ReactNode | undefined | Additional plugins or editor components | | className | string | '' | Class name for editor container | | readOnly | boolean | false | Set editor to read-only mode | | showToolbar | boolean | true | Show/hide the toolbar | | enableImages | boolean | true | Enable image insertion and handling | | enableLinks | boolean | true | Enable link creation and editing |

Available Plugins

ImagePlugin

The ImagePlugin allows inserting and managing images in the editor.

import { ImagePlugin } from 'react-lexical-editor';

// Used internally when enableImages={true}
<ImagePlugin captionsEnabled={true} />;

Props:

  • captionsEnabled: Boolean to enable/disable image captions (default: true)

LinkPlugin

Enhanced link editing capabilities beyond the standard Lexical LinkPlugin.

import { LinkPlugin } from 'react-lexical-editor';

// Used internally when enableLinks={true}
<LinkPlugin />;

ToolbarPlugin

Provides a rich formatting toolbar for the editor.

import { ToolbarPlugin } from 'react-lexical-editor';

// Used internally when showToolbar={true} and !readOnly
<ToolbarPlugin />;

Working with Editor State

You can save and restore editor state using the onChange prop and initialState:

const [editorState, setEditorState] = useState('');

// Save state when content changes
const handleEditorChange = state => {
  setEditorState(JSON.stringify(state.toJSON()));
};

// Later, restore the state
<LexicalEditor initialState={editorState} onChange={handleEditorChange} />;

Advanced Usage

Custom Plugins

You can add custom plugins by including them as children:

import { LexicalEditor } from 'react-lexical-editor';
import { AutoLinkPlugin } from '@lexical/react/LexicalAutoLinkPlugin';

function MyEditorWithAutoLink() {
  const MATCHERS = [
    {
      trigger: 'https://',
      url: 'https://{text}',
    },
  ];

  return (
    <LexicalEditor>
      <AutoLinkPlugin matchers={MATCHERS} />
    </LexicalEditor>
  );
}

Custom Theming

import { LexicalEditor } from 'react-lexical-editor';

const customTheme = {
  paragraph: 'my-paragraph-class',
  heading: {
    h1: 'my-h1-class',
    h2: 'my-h2-class',
  },
  text: {
    bold: 'my-bold-class',
    italic: 'my-italic-class',
  },
};

<LexicalEditor theme={customTheme} />;

Examples

Read-Only Editor

<LexicalEditor initialState={savedContent} readOnly={true} showToolbar={false} />

Editor with Custom Configuration

<LexicalEditor
  placeholder="Write your story..."
  editorConfig={{
    namespace: 'my-custom-editor',
    onError: error => {
      console.error('Custom error handler:', error);
    },
  }}
  contentEditableClassName="my-editor-styles"
/>

API Documentation

Detailed API documentation is available in the docs directory. The documentation is generated using TypeDoc and includes:

  • Complete interface definitions
  • Component props and methods
  • Plugin APIs
  • Exported variables and constants

To generate the latest documentation:

npm run docs

Development

# Install dependencies
npm install

# Start development playground
npm run playground

# Run tests
npm test

# Build for production
npm run build

Contributing

Contributions are welcome! Please check out our contributing guidelines.

License

MIT © Zaid Omar