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

text-editor-studio

v1.0.1

Published

## Installation

Downloads

14

Readme

Text Editor Studio

Installation

you should already have package.json in you project you should have module bundlers such as vite .

Install the package via npm:

npm install docs_editor_test

Using Editor Component in a React App

Note: This web component requires Remix Icon CDN in the of your HTML for proper styling and icon rendering:

<link
  href="https://cdn.jsdelivr.net/npm/[email protected]/fonts/remixicon.css"
  rel="stylesheet"
/>

Imports

import "docs_editor_test/dist/index.css";
import { Editor } from "docs_editor_test/dist/index.js";

App.jsx Example

import "docs_editor_test/dist/index.css";
import { Editor } from "docs_editor_test/dist/index.js";
import { createRoot } from "react-dom/client";

function App({
  initialState = initialValue,
  onChange,
  onSerializedChange,
  onHtmlChange,
}) {
  // Using provided handlers or empty functions if not provided
  const handleEditorChange = onChange || (() => {});
  const handleSerializedChange = onSerializedChange || (() => {});
  const handleHtmlChange = (html) => {
    if (onHtmlChange) {
      onHtmlChange(html);
    }
  };
    <Editor
      editorSerializedState={initialState}
      onSerializedChange={han return (dleSerializedChange)}
      onChange={handleEditorChange}
      onHtmlChange={handleHtmlChange}
    />
}

// Define the custom element
class ReactEditorElement extends HTMLElement {
  constructor() {
  }
    super();
    this.onChange = null;
    this.onSerializedChange = null;
    this.onHtmlChange = null;


  connectedCallback() {
    // Get initial state if provided as an attribute
    let initialState = "";
     editorStateAttr = thisconst.getAttribute("editorSerializedState");


    if (editorStateAttr && editorStateAttr !== "null") {
      try {
        initialState = JSON.parse(editorStateAttr);
      } catch (e) {
        console.error("Failed to parse editor state:", e);
      }
    }


    // Render React component
    const root = createRoot(this);
    root.render(
      <App
        initialState={initialState}
        onChange={(state) => {
          if (this.onChange) this.onChange(state);
        }}
        onSerializedChange={(state) => {
          if (this.onSerializedChange) this.onSerializedChange(state);
        }}
        onHtmlChange={(html) => {
          if (this.onHtmlChange) this.onHtmlChange(html);
        }}
      />
    );
  }
}


// Register custom element
customElements.define("react-editor", ReactEditorElement);
export default App;

index.html

<!doctype html>
<html lang="en">
  <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
 />
  <style>
    body {
      margin: 0;
      padding: 20px;
      min-height: 100vh;
    }
    .editor-container {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 20px;
      height: calc(100vh - 40px);
    }
    .editor-section, .preview-container {
      height: 94.5%;
      overflow-y: auto;
    }
    .preview-container {
      padding: 20px;
      border: 1px solid #ccc;
      border-radius: 4px;
      background: white;
    }
    .preview-content {
      max-width: none;
      font-family: 'SF Pro', sans-serif;
    }
    react-editor {
      height: 100%;
      display: block;
    }
  </style>
  </head>
  <body>
    <div class="editor-container">
      <div class="editor-section">
        <react-editor 
          id="editor"
          editorState='null'
          editorSerializedState='null'
        ></react-editor>
      </div>
<div class="preview-container">
    <h2>Preview</h2>
    <div id="preview" class="preview-content"></div>
  </div>
</div>
<script type="module" src="/src/app.jsx"></script>


<script>
  function handleEditorChange(state) {
    console.log('Editor state changed:', state);
  }
  
  function handleSerializedChange(state) {
    console.log('Serialized state changed:', state);
  }
  
  function handleHtmlChange(html) {
    console.log('HTML changed:', html);
    const previewElement = document.getElementById('preview');
    previewElement.innerHTML = html;
  }
  
  window.addEventListener('DOMContentLoaded', () => {
    const editor = document.querySelector('#editor');
    editor.onChange = handleEditorChange;
    editor.onSerializedChange = handleSerializedChange;
    editor.onHtmlChange = handleHtmlChange;
  });
</script>
  </body>
</html>

Here’s a breakdown of all available props you can use with both the React and Web Component versions:

Props

| Prop | Type | Description | |-------------------------|--------------------------|-----------------------------------------------| | editorState | EditorState | (optional) Full control editor state object | | editorSerializedState | SerializedEditorState | Initial JSON state | | onChange | function | Callback on raw state change | | onSerializedChange | function | Callback on serialized (JSON) state change | | onHtmlChange | function | Callback on HTML output change |

  • editorState – Raw EditorState instance
  • editorSerializedState – JSON-serializable state
  • onChange(state) => void fires on every update
  • onSerializedChange(json) => void Callback for when the serialized editor state changes
  • onHtmlChange(html) => void Callback for when the HTML representation of the editor content changes

you can have the data as sting using JSON.stringify(editorSerializedState)

Example Prop Usage

<Editor
  editorSerializedState={mySerializedValue}
  onSerializedChange={(val) => localStorage.setItem('doc', JSON.stringify(val))}
  onHtmlChange={(html) => setPreview(html)}
  onChange={(state) => console.log(state)}
/>

Web Component

You can use the web component directly in any plain HTML environment after download the package first in the main.jsx you should call the editor and the style

import "docs_editor_test/dist/index.css";
import { Editor } from "docs_editor_test/dist/index.js"; or import "docs_editor_test/dist/index.js";


window.addEventListener("DOMContentLoaded", () => {
  const editor = document.querySelector("#editor");
  editor.onChange = (state) => {
    console.log("Editor State", state);
  }
  editor.onSerializedChange = (serializedState) => {
    console.log("Serialized State", serializedState);
  };
  editor.onHtmlChange = (html) => {
    console.log("HTML Output", html);
    document.getElementById("preview").innerHTML = html;
  };
});
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Lexical Web Component</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <style>
      body {
        font-family: sans-serif;
        padding: 2rem;
        background: #f9f9f9;
      }

      react-editor {
        width: 100%;
        height: 400px;
        display: block;
        margin-bottom: 2rem;
      }

      #preview {
        padding: 1rem;
        background: white;
        border: 1px solid #ccc;
        border-radius: 6px;
        font-family: sans-serif;
      }
    </style>
  </head>
  <body>
    <h1>Lexical Editor Web Component</h1>

    <react-editor id="editor"></react-editor>

    <h2>Live Preview (HTML)</h2>
    <div id="preview">Start typing in the editor…</div>

    <script type="module" src="/main.js"></script>
  </body>
</html>

props use in it

<react-editor id="editor"></react-editor>
<script>
  document.getElementById("editor").onHtmlChange = (html) => {
    document.getElementById("preview").innerHTML = html;
  };
</script>