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

rte-react

v0.1.5

Published

A lightweight, fully-typed React rich text editor with a configurable toolbar. Outputs HTML. Works with React 17+.

Downloads

380

Readme

rte-react

A lightweight, fully-typed React rich text editor with a configurable toolbar. Supports HTML, Markdown, and JSON output formats. Works with React 17 and higher.

Install

npm install rte-react

Usage

import { RichEditor } from 'rte-react';
import 'rte-react/styles';

function App() {
  const [content, setContent] = useState('<p>Hello world</p>');

  return (
    <RichEditor
      value={content}
      onChange={setContent}
      placeholder="Start typing..."
    />
  );
}

Output Formats

The outputFormat prop controls the format of the value prop and the value passed to onChange. Defaults to 'html'.

HTML (default)

const [html, setHtml] = useState('<p>Hello world</p>');

<RichEditor
  outputFormat="html"
  value={html}
  onChange={(v) => setHtml(v as string)}
/>

onChange receives a string like <p>Hello <strong>world</strong></p>.

Markdown

const [md, setMd] = useState('Hello **world**');

<RichEditor
  outputFormat="md"
  value={md}
  onChange={(v) => setMd(v as string)}
/>

onChange receives a Markdown string like Hello **world**. The value prop is parsed from Markdown before being loaded into the editor.

JSON

import type { JSONContent } from 'rte-react';

const [nodes, setNodes] = useState<JSONContent[]>([]);

<RichEditor
  outputFormat="json"
  value={nodes}
  onChange={(v) => setNodes(v as JSONContent[])}
/>

onChange receives a JSONContent[] array — the raw ProseMirror content nodes from Tiptap's editor.getJSON().content.

Font Picker

Add 'fontFamily' to the toolbar prop to show the font family picker. It renders as a dropdown where each option is displayed in its own font for a live preview.

<RichEditor
  value={content}
  onChange={setContent}
  toolbar={['fontFamily', 'fontSize', 'divider', 'bold', 'italic', 'underline']}
/>

Selecting text and choosing a font wraps it in a <span style="font-family: ...">. Choosing Default removes the inline style cleanly. The dropdown always reflects the font at the current cursor position.

Default fonts

| Label | CSS value | |-------|-----------| | Default | (removes font mark) | | Arial | Arial, sans-serif | | Georgia | Georgia, serif | | Helvetica | Helvetica, Arial, sans-serif | | Times New Roman | 'Times New Roman', Times, serif | | Trebuchet MS | 'Trebuchet MS', sans-serif | | Verdana | Verdana, sans-serif | | Courier New | 'Courier New', Courier, monospace |

Custom font list

Pass a fontFamilies prop to replace the default list with your own fonts. Each entry is a { label, value } object where value is any valid CSS font-family string.

import { RichEditor, DEFAULT_FONT_FAMILIES } from 'rte-react';
import type { FontFamilyOption } from 'rte-react';

// Completely custom list
const myFonts: FontFamilyOption[] = [
  { label: 'Default',    value: '' },
  { label: 'Inter',      value: 'Inter, sans-serif' },
  { label: 'Roboto',     value: 'Roboto, sans-serif' },
  { label: 'Fira Code',  value: "'Fira Code', monospace" },
];

<RichEditor
  toolbar={['fontFamily', 'divider', 'bold', 'italic']}
  fontFamilies={myFonts}
  value={content}
  onChange={setContent}
/>

To extend the built-in list rather than replace it, spread DEFAULT_FONT_FAMILIES:

import { DEFAULT_FONT_FAMILIES } from 'rte-react';

const extendedFonts = [
  ...DEFAULT_FONT_FAMILIES,
  { label: 'Inter',     value: 'Inter, sans-serif' },
  { label: 'Fira Code', value: "'Fira Code', monospace" },
];

<RichEditor fontFamilies={extendedFonts} ... />

Note: the editor only renders the font — it does not load any font files. Make sure any custom web fonts (e.g. from Google Fonts) are loaded in your app before using them here.

fontFamily and fontSize are independent marks and can be combined freely — selecting both tools applies both font-family and font-size on the same span.

Custom Toolbar

Pass a toolbar prop to control which tools are shown and in what order:

<RichEditor
  value={content}
  onChange={setContent}
  toolbar={['bold', 'italic', 'underline', 'divider', 'bulletList', 'orderedList', 'divider', 'link']}
/>

Available Tools

| Tool | Description | |------|-------------| | bold | Bold text | | italic | Italic text | | underline | Underline text | | strikethrough | Strikethrough text | | heading1heading6 | Headings H1–H6 | | bulletList | Bullet list | | orderedList | Numbered list | | blockquote | Blockquote | | codeBlock | Fenced code block | | link | Insert or edit a hyperlink | | image | Upload and insert an image (max 10 MB) | | table | Insert a table (configurable rows × cols) | | fontSize | Font size dropdown (12–48 px) | | fontFamily | Font family picker (Arial, Georgia, Helvetica, Times New Roman, Trebuchet MS, Verdana, Courier New) | | undo | Undo | | redo | Redo | | divider | Visual separator in the toolbar |

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | value | string \| JSONContent[] | '' | Initial content. Format must match outputFormat. | | onChange | (value: string \| JSONContent[]) => void | — | Called on every content change. Receives a value in the format set by outputFormat. | | outputFormat | 'html' \| 'md' \| 'json' | 'html' | Format used for both value input and onChange output. | | toolbar | ToolbarTool[] | All tools | Tools to show in the toolbar. | | fontFamilies | FontFamilyOption[] | Built-in list | Custom font list for the fontFamily picker. Replaces the default 8 fonts entirely. | | placeholder | string | 'Start typing...' | Placeholder text shown when the editor is empty. | | editable | boolean | true | Set to false to render a read-only view (toolbar is hidden). | | className | string | — | Class added to the outer wrapper element. | | toolbarClassName | string | — | Class added to the toolbar element. | | contentClassName | string | — | Class added to the content area element. | | style | CSSProperties | — | Inline style for the outer wrapper element. |

Exported Types

import { DEFAULT_FONT_FAMILIES } from 'rte-react';
import type { RichEditorProps, ToolbarTool, OutputFormat, JSONContent, FontFamilyOption } from 'rte-react';

| Export | Kind | Description | |--------|------|-------------| | RichEditorProps | type | Full props interface for <RichEditor> | | ToolbarTool | type | Union of all valid toolbar tool names | | OutputFormat | type | 'html' \| 'md' \| 'json' | | JSONContent | type | ProseMirror node shape used for JSON format (re-exported from @tiptap/core) | | FontFamilyOption | type | { label: string; value: string } — shape of a font picker entry | | DEFAULT_FONT_FAMILIES | value | The built-in font list used when no fontFamilies prop is passed |

License

MIT