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

codeeditor

v1.2.4

Published

A React Code Editor component based on Draft.js

Readme

CodeEditor npm version

A generic React component for building customized code editors, based on Draft.js.

Demo

This simple C++ editor demo. exercises all the capabilities of the component, which right now are:

  • Automatic indentation inside blocks (delimited by { and }); you can set the indent size.
  • Customizable syntax highlighting.
  • Automatically closing a block and starting a new line when the user opens a block (i.e. inserting a '}' automatically).
  • Passing a callback for when the code is changed.

Usage

This is the entire code of the demo page:

<!doctype html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>CodeEditor demo</title>
    <script type="text/javascript" src="bundle.js"></script>
    <style type="text/css">
      #editor {
        width: 100%;
        height: 100%;
      }
    </style>
    <script type="text/javascript">
      function loadEditor() {
        var editor = document.getElementById("editor");
        CodeEditor.render(editor, {
          style: {
           width: '50%',
           height: '20em',
           border: '1px solid black',
           fontFamily: 'monospace',
           fontSize: '2em',
          },
          autoIndent: true,
          autoCloseBlocks: true,
          highlightingRules: [
            // Some keywords
            {
              regex: 'return|do|while|for|if|else|template|struct|class|using|namespace',
              style: {fontWeight: 'bold'},
            },
            // Some types
            {
              regex: 'int|char|void|short|unsigned|long|size_t|clock_t',
              style: {fontWeight: 'bold', color: '#000088'},
            },
            // Pre-processor lines
            {
              regex: '^#.*$',
              style: {color: 'green'},
            },
            // Strings
            {
              regex: '"[^"]*"',
              style: {color: 'red'},
            }
          ],
          initialCode: ("#include <iostream>\n" +
                        "using namespace std;\n" +
                        "int main(){\n" +
                        "    cout << \"Hello, world!\" << endl;\n" +
                        "    return 0;\n" +
                        "}\n"),
          indentSize: 4,
          onChange: function(code) { console.log("Code:===\n" + code + "\n===\n"); },
        });
      }
    </script>
  </head>
  <h1>Code Editor demo - C++ code editor</h1>
  <body onload="loadEditor();">
    <div id="editor"></div>
  </body>
</html>

Contributing

There are a number of other features that could be added without much effort:

  • Line numbers
  • Support for other indentation rules (like Python's)
  • Generic block delimiters

If you would like to implement any of these (or any other suggestions, of course), I'd be happy to review and merge your changes. Please create an issue stating what you would like to add and we can discuss it there.

License

MIT. Basically, do anything you want provided you keep the copyright notice.