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 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-smart-editor

v1.0.66

Published

React rich text editor with track changes functionality

Readme

React Smart Editor

A modern React editor with change tracking capabilities, built on top of Slate.js.

Features

  • Rich text formatting
  • Change tracking (additions and deletions)
  • Personal change tracking for each user
  • Change approval/rejection system
  • Serialization support for database storage
  • Full TypeScript support
  • Modern React (hooks-based)
  • Custom styles support
  • Responsive design

Requirements

  • React 18 or higher
  • TypeScript 5.0 or higher
  • Support for modern browsers (Chrome, Firefox, Safari, Edge)

Installation

npm install react-smart-editor
# or
yarn add react-smart-editor

Usage

Basic Usage

import {
  ReactSmartEditor,
  Document,
  User,
  serializeDocument,
  deserializeDocument,
} from 'react-smart-editor'
import 'react-smart-editor/dist/index.css'

const MyEditor = () => {
  const [document, setDocument] = useState<Document>({
    content: [
      {
        type: 'paragraph',
        children: [{ text: 'Start editing...' }],
      },
    ],
    changes: [],
  })

  const user: User = {
    id: 'userId',
    name: 'John Doe',
    color: '#ff0000',
    role: 'editor',
  }

  const handleChange = (newDocument: Document) => {
    setDocument(newDocument)
    // Optional: serialization for storage
    const serialized = serializeDocument(newDocument)
    // Save to database...
  }

  const handleAutoSave = (newDocument: Document) => {
    console.log('Auto save', newDocument)
  }

  return (
    <ReactSmartEditor
      initialContent={document}
      user={user}
      onChange={handleChange}
      onAutoSave={handleAutoSave}
      onApprove={(changeId) => {
        console.log('Change approved:', changeId)
      }}
      onReject={(changeId) => {
        console.log('Change rejected:', changeId)
      }}
    />
  )
}

Customizing Styles

import 'react-smart-editor/dist/index.css'
import './custom-styles.css'

// custom-styles.css
.editor-container {
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 16px;
}

.toolbar {
  background: #f5f5f5;
  border-bottom: 1px solid #ddd;
}

API

TrackChangesEditor Props

| Prop | Type | Required | Description | | ---------------------------- | ---------------------------- | -------- | ----------------------------------------------------------------- | | initialContent | Document | Yes | Initial document content and changes | | user | User | Yes | Current user information | | readOnly | boolean | No | Read-only mode | | placeholder | string | No | Placeholder for empty editor | | formattingToolbarTop | number | No | Sticky top distance value | | hideFormattingToolbarActions | boolean | No | Hides all formatting actions except approve and reject for owner | | showOwnerChanges | boolean | No | By default true. if false - owner changes will not be highlighted | | onChange | (document: Document) => void | No | Called when document unfocused | | onAutoSave | (document: Document) => void | No | Called every 3 sec when document changes | | onApprove | (changeId: string) => void | No | Called when a change is approved | | onReject | (changeId: string) => void | No | Called when a change is rejected | | onFocus | () => void | No | Called when document focused | | onBlur | () => void | No | Called when document unfocused |

Types

interface Document {
  content: Descendant[] // Slate nodes
  changes: ChangeMetadata[]
  hasOwnerChanges: boolean
}

interface User {
  id: string
  name: string
  color: string
  role: 'editor' | 'owner'
}

interface ChangeMetadata {
  id: string
  userId: string
  userName: string
  userColor: string
  userRole: 'editor' | 'owner'
  date: string
  type: 'insert' | 'delete'
  description: string
  content: string
  status: 'pending' | 'accepted' | 'rejected'
}

Utilities

  • serializeDocument(document: Document): SerializedDocument - Serialization for storage
  • deserializeDocument(serialized: SerializedDocument): Document - Deserialization from storage

License

MIT