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

@editora/light-code-editor

v1.0.3

Published

Lightweight, extensible code editor for the web — syntax highlighting, line numbers, code folding, and a plugin-friendly API. Ideal for embedding in docs, demos, and web apps.

Readme

Light Code Editor

A lightweight, modular code editor library inspired by CodeMirror, optimized for embedding inside rich text editors.

Features

Self-Contained Library - Everything needed (including CSS) is bundled within the library ✅ Modular Architecture - Extension-based system for maximum flexibility ✅ Syntax Highlighting - HTML syntax highlighting with VS Code-style colors ✅ Themes - Light and dark theme support ✅ Line Numbers - Optional line number gutter ✅ Search - Find and highlight functionality ✅ Bracket Matching - Automatic bracket pair highlighting ✅ Code Folding - Collapse/expand code sections ✅ Read-Only Mode - Prevent text modifications ✅ TypeScript Support - Full TypeScript definitions ✅ Zero Dependencies - Pure JavaScript implementation

Installation

npm install @editora/light-code-editor

Quick Start

<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" href="node_modules/@editora/light-code-editor/dist/light-code-editor.css">
</head>
<body>
  <div id="editor"></div>

  <script type="module">
    import { createEditor, LineNumbersExtension, SyntaxHighlightingExtension } from '@editora/light-code-editor';

    const editor = createEditor(document.getElementById('editor'), {
      value: '<div class="hello">Hello World</div>',
      theme: 'dark',
      extensions: [
        new LineNumbersExtension(),
        new SyntaxHighlightingExtension()
      ]
    });

    // Get current content
    console.log(editor.getValue());

    // Listen for changes
    editor.on('change', (changes) => {
      console.log('Content changed:', changes);
    });
  </script>
</body>
</html>

API

createEditor(container, config)

Factory function to create a new editor instance.

Parameters

  • container: HTMLElement - The DOM element to attach the editor to
  • config: EditorConfig - Configuration options

EditorConfig

interface EditorConfig {
  value?: string;                    // Initial content
  theme?: 'light' | 'dark';          // Theme
  readOnly?: boolean;                // Read-only mode
  extensions?: EditorExtension[];    // Extensions to load
  keymap?: Record<string, string>;   // Custom key bindings
}

Editor Methods

interface EditorAPI {
  // Content
  getValue(): string;
  setValue(value: string): void;

  // Focus & Selection
  focus(): void;
  hasFocus(): boolean;

  // Theme & Appearance
  setTheme(theme: 'light' | 'dark'): void;

  // Read-only mode
  setReadOnly(readOnly: boolean): void;

  // Extensions
  registerCommand(name: string, handler: Function): void;

  // Events
  on(event: string, handler: Function): void;
  off(event: string, handler: Function): void;
}

Extensions

Core Extensions

LineNumbersExtension

Adds line numbers to the left gutter.

import { LineNumbersExtension } from '@editora/light-code-editor';

const editor = createEditor(container, {
  extensions: [new LineNumbersExtension()]
});

SyntaxHighlightingExtension

Provides HTML syntax highlighting.

import { SyntaxHighlightingExtension } from '@editora/light-code-editor';

const editor = createEditor(container, {
  extensions: [new SyntaxHighlightingExtension()]
});

ThemeExtension

Enables theme switching.

import { ThemeExtension } from '@editora/light-code-editor';

const editor = createEditor(container, {
  extensions: [new ThemeExtension()]
});

ReadOnlyExtension

Adds read-only mode functionality.

import { ReadOnlyExtension } from '@editora/light-code-editor';

const editor = createEditor(container, {
  extensions: [new ReadOnlyExtension()]
});

SearchExtension

Provides search and replace functionality.

import { SearchExtension } from '@editora/light-code-editor';

const editor = createEditor(container, {
  extensions: [new SearchExtension()]
});

BracketMatchingExtension

Highlights matching brackets.

import { BracketMatchingExtension } from '@editora/light-code-editor';

const editor = createEditor(container, {
  extensions: [new BracketMatchingExtension()]
});

CodeFoldingExtension

Enables code folding functionality.

import { CodeFoldingExtension } from '@editora/light-code-editor';

const editor = createEditor(container, {
  extensions: [new CodeFoldingExtension()]
});

Custom Extensions

Create your own extensions by implementing the EditorExtension interface:

import { EditorExtension, EditorAPI } from '@editora/light-code-editor';

class MyExtension implements EditorExtension {
  public readonly name = 'my-extension';

  setup(editor: EditorAPI): void {
    // Initialize your extension
    editor.registerCommand('my-command', () => {
      console.log('My command executed!');
    });
  }

  destroy(): void {
    // Cleanup
  }
}

Styling

The library includes its own CSS file that provides complete styling. Include it in your HTML:

<link rel="stylesheet" href="dist/light-code-editor.css">

CSS Classes

  • .rte-light-editor - Main editor container
  • .rte-light-editor-content - Textarea element
  • .rte-light-editor-gutter - Line numbers gutter
  • .rte-syntax-highlight-overlay - Syntax highlighting overlay
  • .rte-light-editor.dark - Dark theme
  • .rte-light-editor.light - Light theme

Architecture

The editor follows a modular, extension-first architecture:

EditorCore
├── TextModel (content management)
├── View (DOM rendering)
├── Extension Registry
├── Command System
└── Event System

Design Principles

  1. Self-Contained - Everything needed is included
  2. Extension-First - All features are extensions
  3. Zero Dependencies - Pure JavaScript
  4. Type-Safe - Full TypeScript support
  5. Performant - Optimized for large documents

Browser Support

  • Chrome 60+
  • Firefox 60+
  • Safari 12+
  • Edge 79+

Contributing

This library follows the CodeMirror architecture principles and is designed to be maintainable and extensible. When adding features:

  1. Implement as extensions, not core modifications
  2. Maintain TypeScript types
  3. Include comprehensive tests
  4. Update documentation

License

MIT License - see LICENSE file for details.

Author

Ajay Kumar [email protected]