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

@b9g/crankeditable

v0.1.0

Published

A [Crank.js](https://crank.js.org) component that bridges [`@b9g/revise`](https://github.com/bikeshaving/revise) to the DOM. It handles contenteditable event wiring, undo/redo, selection preservation, and cursor scrolling so your component only needs to r

Readme

@b9g/crankeditable

A Crank.js component that bridges @b9g/revise to the DOM. It handles contenteditable event wiring, undo/redo, selection preservation, and cursor scrolling so your component only needs to render lines from state.

npm install @b9g/crankeditable @b9g/crank @b9g/revise

Usage

import {renderer} from "@b9g/crank/dom";
import {EditableState} from "@b9g/revise/state.js";
import {CrankEditable} from "@b9g/crankeditable";

function* MyEditor() {
  const state = new EditableState({value: "Hello World!\n"});

  for ({} of this) {
    const lines = state.value.split("\n");
    if (state.value.endsWith("\n")) lines.pop();

    let cursor = 0;
    yield (
      <CrankEditable state={state} onstatechange={() => this.refresh()}>
        <div contenteditable="true">
          {lines.map((line) => {
            const key = state.keyer.keyAt(cursor);
            cursor += line.length + 1;
            return <div key={key}>{line || <br />}</div>;
          })}
        </div>
      </CrankEditable>
    );
  }
}

renderer.render(<MyEditor />, document.getElementById("app"));

How it works

CrankEditable renders a <content-area> element (from @b9g/revise) wrapping your children. It listens for:

  • contentchange — Captures the browser selection, calls preventDefault() to revert the DOM mutation, applies the edit to EditableState, and dispatches a statechange event so the parent can re-render.

  • beforeinput (historyUndo/historyRedo) and keydown (Cmd/Ctrl+Z, Cmd/Ctrl+Shift+Z, Ctrl+Y) — Intercepts undo/redo and delegates to state.undo()/state.redo().

  • selectionchange — Calls state.checkpoint() when the cursor moves without editing, so undo groups break at natural boundaries.

After each render it calls contentArea.source("render") to tag the DOM update, restores the selection, and scrolls the cursor into view.

Props

| Prop | Type | Description | |------|------|-------------| | state | EditableState | The state object to read/write. Caller-owned. | | children | Children | The rendered content (keyed lines, syntax-highlighted tokens, etc.) |

Events

| Event | Bubbles | Description | |-------|---------|-------------| | statechange | Yes | Dispatched after every edit, undo, or redo. Listen with onstatechange on the component element to trigger a parent re-render. |