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

@veltmanj/wysiwyg-editor

v1.0.0

Published

A configurable rich text editor component with a customizable toolbar

Readme

WYSIWYG Editor

A lightweight, zero-dependency rich text editor component for the browser with a fully configurable toolbar.

Features

  • Configurable toolbar — include only the actions you need, in any order
  • Text formatting — bold, italic, underline, strikethrough, subscript, superscript
  • Font controls — font family, font size, headings (H1–H6)
  • Colors — font color and highlight color via native color picker
  • Alignment — left, center, right, justify
  • Lists & indentation — ordered/unordered lists, indent/outdent (Tab/Shift+Tab)
  • Inserts — links, images, horizontal rules, blockquotes, code blocks
  • History — undo/redo
  • Utilities — remove formatting, print
  • Status bar — live word and character count
  • No runtime dependencies — only dev dependencies for the build step

Installation

npm install wysiwyg-editor

Or with yarn:

yarn add wysiwyg-editor

CDN / Script Tag

Use the UMD build directly in the browser:

<link
  rel="stylesheet"
  href="node_modules/wysiwyg-editor/dist/wysiwyg-editor.css"
/>
<script src="node_modules/wysiwyg-editor/dist/wysiwyg-editor.umd.js"></script>
<script>
  const editor = new WYSIWYGEditor.WYSIWYGEditor("#editor");
</script>

ES Module

import { WYSIWYGEditor } from "wysiwyg-editor";
import "wysiwyg-editor/dist/wysiwyg-editor.css";

const editor = new WYSIWYGEditor("#editor");

Quick Start

<div id="editor"></div>

<script type="module">
  import { WYSIWYGEditor } from "wysiwyg-editor";

  const editor = new WYSIWYGEditor("#editor", {
    placeholder: "Start typing…",
    onChange: (html) => console.log(html),
  });
</script>

Configuration

Pass an options object as the second argument to the constructor:

const editor = new WYSIWYGEditor("#editor", {
  toolbar: [
    "bold",
    "italic",
    "underline",
    "|",
    "heading",
    "fontFamily",
    "fontSize",
  ],
  placeholder: "Write something…",
  initialContent: "<p>Hello world</p>",
  minHeight: 300,
  onChange: (html) => saveToServer(html),
});

Options

| Option | Type | Default | Description | | ---------------- | ---------- | ----------- | --------------------------------------------------------------- | | toolbar | string[] | all actions | Toolbar items to display (action names or '\|' for separator) | | placeholder | string | '' | Placeholder text shown when the editor is empty | | initialContent | string | '' | Initial HTML content | | minHeight | number | 200 | Minimum editor height in pixels | | onChange | function | null | Callback invoked with the HTML string on every change |

Toolbar Actions

Use these names in the toolbar array. Add '|' between items to insert a separator.

Text formatting:

bold · italic · underline · strikethrough · subscript · superscript

Headings & fonts:

heading · fontFamily · fontSize

Colors:

fontColor · highlight

Alignment:

alignLeft · alignCenter · alignRight · alignJustify

Lists & indentation:

orderedList · unorderedList · indent · outdent

Inserts:

link · image · horizontalRule · blockquote · codeBlock

History:

undo · redo

Utilities:

removeFormat · print

Example: Minimal Toolbar

new WYSIWYGEditor("#editor", {
  toolbar: ["bold", "italic", "|", "orderedList", "unorderedList"],
});

Example: Document-Style Toolbar

new WYSIWYGEditor("#editor", {
  toolbar: [
    "heading",
    "fontFamily",
    "fontSize",
    "|",
    "bold",
    "italic",
    "underline",
    "fontColor",
    "|",
    "alignLeft",
    "alignCenter",
    "alignRight",
    "|",
    "orderedList",
    "unorderedList",
    "|",
    "link",
    "image",
    "blockquote",
    "|",
    "undo",
    "redo",
  ],
});

API

| Method | Returns | Description | | ---------------------------- | --------- | -------------------------------------------------------- | | getHTML() | string | Get the editor content as HTML | | setHTML(html) | void | Replace the editor content with the given HTML | | getText() | string | Get the editor content as plain text | | clear() | void | Clear all editor content | | focus() | void | Focus the editor | | exec(command, value?) | void | Execute a document command (e.g. 'bold', 'fontSize') | | queryCommandState(command) | boolean | Check if a command is active (e.g. is text bold?) | | queryCommandValue(command) | string | Get the current value of a command (e.g. font name) | | destroy() | void | Remove the editor from the DOM and clean up |

Framework Integration

Angular

A fully scaffolded Angular application is available in the editor/ folder. It includes a reusable WYSIWYGEditorComponent wrapper. See editor/ to run it, or demo/angular/ for standalone component files and usage instructions.

cd editor
npm install
./node_modules/.bin/ng serve

React

A reusable React wrapper component is in demo/react/. Copy WYSIWYGEditor.jsx into your project:

import WYSIWYGEditor from "./WYSIWYGEditor";

function App() {
  return (
    <WYSIWYGEditor
      toolbar={["bold", "italic", "|", "heading", "fontSize"]}
      placeholder="Write here…"
      onChange={(html) => console.log(html)}
    />
  );
}

Vanilla HTML

Open demo/index.html in a browser (serve via a local HTTP server):

npx serve demo

Project Structure

WYSIWYG-Editor/
  src/
    index.js       – entry point (exports + CSS import)
    editor.js      – WYSIWYGEditor class
    toolbar.js     – Toolbar rendering and state management
    actions.js     – action registry (all toolbar items)
    styles.css     – editor styles
  dist/            – built output
    wysiwyg-editor.js      – ES module
    wysiwyg-editor.umd.js  – UMD bundle (for script tags)
    wysiwyg-editor.min.js  – minified ES module
    wysiwyg-editor.css     – extracted stylesheet
  demo/
    index.html     – vanilla HTML demo
    angular/       – Angular wrapper component + demo
    react/         – React wrapper component + demo
  editor/          – fully scaffolded Angular application
  rollup.config.js – build configuration

Building from Source

npm install
npm run build

This produces the dist/ folder with ES, UMD, and minified bundles plus the extracted CSS.

To rebuild on file changes:

npm run dev

License

MIT