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

text-editor-studio-ts

v1.2.0

Published

A powerful mobile-responsive rich text editor built with Lexical and React

Readme

Text Editor Studio TS

A powerful, feature-rich rich text editor built with Lexical and React, optimized for TypeScript applications.

npm version License: MIT

✨ Features

  • 🎨 Rich Text Editing - Full-featured text editor with formatting options
  • 📝 Markdown Support - Write in Markdown and see live preview
  • 🖼️ Media Support - Images, videos, and embedded content
  • 📊 Tables - Create and edit tables with ease
  • 🎯 Mentions - @mentions with autocomplete
  • 😊 Emoji Picker - Built-in emoji selection
  • 📐 Equations - Mathematical expressions with KaTeX
  • 🎨 Excalidraw Integration - Draw diagrams and sketches
  • 🔗 Links - Smart link handling and validation
  • 📋 Lists - Bulleted, numbered, and check lists
  • 🎨 Code Blocks - Syntax highlighting for code
  • 📱 Responsive Design - Works on all screen sizes
  • Accessibility - WCAG compliant
  • 🌙 Theme Support - Light and dark themes
  • 🔧 TypeScript Ready - Full TypeScript support with proper type definitions

📦 Installation

npm install text-editor-studio-ts
# or
yarn add text-editor-studio-ts
# or
pnpm add text-editor-studio-ts

🔧 Required HTML Setup

Before using the editor, you need to add the following tags to your HTML <head> section:

<head>
  <meta charset="UTF-8" />
  <link rel="icon" type="image/svg+xml" href="/vite.svg" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Editor X</title>
  <link
    href="https://cdn.jsdelivr.net/npm/[email protected]/fonts/remixicon.css"
    rel="stylesheet"
  />
  <link
    rel="stylesheet"
    href="https://cdn.statically.io/gh/TORCH-Corp/SF-PRO-FONT/main/font/fonts.css"
  />
  <link
    rel="preload"
    href="https://cdn.statically.io/gh/TORCH-Corp/SF-PRO-FONT/main/font/SF-Pro.woff2"
    as="font"
    type="font/woff2"
    crossorigin
  />
</head>

These dependencies provide:

  • RemixIcon: Icon font used throughout the editor interface
  • SF Pro Font: Primary font family for better typography
  • Font preloading: Optimizes font loading performance

🚀 Quick Start

Import the editor

import { Editor, SerializedEditorState } from "text-editor-studio-ts";

Complete Example with Live Preview

"use client";

import { useState } from "react";
import { Editor, SerializedEditorState } from "text-editor-studio-ts";

const initialValue = {
  root: {
    children: [
      {
        children: [
          {
            detail: 0,
            format: 0,
            mode: "normal",
            style: "",
            text: "Hello World 🚀",
            type: "text",
            version: 1,
          },
        ],
        direction: "ltr",
        format: "",
        indent: 0,
        type: "paragraph",
        version: 1,
      },
    ],
    direction: "ltr",
    format: "",
    indent: 0,
    type: "root",
    version: 1,
  },
} as unknown as SerializedEditorState;

export default function EditorDemo() {
  const [editorState, setEditorState] =
    useState<SerializedEditorState>(initialValue);
  const [htmlContent, setHtmlContent] = useState<string>("");
  console.log("HTML Content:", htmlContent);

  return (
    <div className=" p-4">
      <div className="mb-8">
        <h2 className="text-xl font-bold mb-4">Editor</h2>
        <Editor
          editorSerializedState={editorState}
          onSerializedChange={(value) => setEditorState(value)}
          onHtmlChange={(html) => {
            console.log("HTML Content:", html);
            setHtmlContent(html);
          }}
        />
      </div>
      
      <div className="mt-8">
        <h2 className="text-xl font-bold mb-4">Rendered HTML Preview</h2>
        <div className="border rounded p-4 bg-white">
          <div
            className="max-w-none prose prose-slate"
            dangerouslySetInnerHTML={{ __html: htmlContent }}
          />
        </div>
      </div>
    </div>
  );
}

📊 Understanding Editor Data

SerializedEditorState Structure

The SerializedEditorState is a JSON-serializable representation of the editor content. It follows Lexical's node structure:

interface SerializedEditorState {
  root: {
    children: Array<SerializedNode>;
    direction: "ltr" | "rtl";
    format: string;
    indent: number;
    type: "root";
    version: number;
  };
}

Key Components:

  • root: The top-level container for all editor content
  • children: Array of paragraph, heading, list, and other block elements
  • text nodes: Individual pieces of text with formatting (bold, italic, etc.)
  • direction: Text direction (left-to-right or right-to-left)
  • version: Lexical version for compatibility

HTML Output

The editor automatically converts your content to clean HTML:

Input: "Hello World 🚀" (text node) Output: <p>Hello World 🚀</p> (HTML paragraph)

Benefits of HTML output:

  • 🎯 Ready for display - Direct rendering in your UI
  • 📱 SEO-friendly - Search engines can index the content
  • 💾 Database storage - Store both serialized state and HTML
  • 📧 Email templates - Use HTML for email content
  • 🔗 Social sharing - Clean HTML for meta descriptions

Data Flow

User Types → Editor State → SerializedEditorState → HTML Output
     ↑                                                    ↓
  Display ←────────── Your Database ←──────────── Save Both

🔧 API Reference

Editor Props

interface EditorProps {
  // Initial content (JSON format)
  editorSerializedState?: SerializedEditorState;
  
  // Callback when content changes (serialized format)
  onSerializedChange?: (state: SerializedEditorState) => void;
  
  // Callback when HTML output changes
  onHtmlChange?: (html: string) => void;
  
  // Placeholder text
  placeholder?: string;
  
  // Custom CSS class
  className?: string;
}

TypeScript Types

import type { 
  Editor,
  EditorProps, 
  SerializedEditorState 
} from 'text-editor-studio-ts';

📄 License

MIT License - see LICENSE file for details.