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

@emergence-engineering/prosemirror-who-wrote-what

v0.1.0

Published

Track text authorship in collaborative ProseMirror editors using Yjs — highlights which user wrote which text with colored inline decorations

Readme

@emergence-engineering/prosemirror-who-wrote-what

logo

Made by Emergence Engineering

Track text authorship in collaborative ProseMirror editors using Yjs. Highlights which user wrote which text with colored inline decorations.

Features

  • Colored inline decorations showing who wrote what
  • Automatic Yjs clientID-to-userId mapping via shared YMap
  • Adaptive debounce that scales with document size
  • Customizable color palette and decoration factory
  • Toggle visibility on/off at runtime
  • Works with any ProseMirror schema — no schema changes needed

Installation

npm install @emergence-engineering/prosemirror-who-wrote-what

Peer dependencies

npm install prosemirror-state prosemirror-view yjs y-prosemirror

Quick Start

import { EditorState } from "prosemirror-state";
import { EditorView } from "prosemirror-view";
import { ySyncPlugin } from "y-prosemirror";
import * as Y from "yjs";
import {
  createWhoWroteWhatPlugin,
  setWhoWroteWhatVisibility,
} from "@emergence-engineering/prosemirror-who-wrote-what";

const ydoc = new Y.Doc();
const yXmlFragment = ydoc.getXmlFragment("default");

const view = new EditorView(document.getElementById("editor")!, {
  state: EditorState.create({
    plugins: [
      ySyncPlugin(yXmlFragment),
      createWhoWroteWhatPlugin({ userId: "alice" }),
    ],
  }),
});

// Toggle authorship highlighting on/off
setWhoWroteWhatVisibility(view, false);
setWhoWroteWhatVisibility(view, true);

Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | colors | string[] | 16 built-in colors | Color palette for author highlights. Cycles through sequentially. | | userMapKey | string | "userMap" | Key for the shared YMap storing clientID-to-userId mappings. | | startVisible | boolean | true | Whether decorations are visible when the plugin initializes. | | debounceFactor | number | 1.5 | Multiplier for adaptive debounce. Debounce delay = lastComputeMs * debounceFactor. Set to 0 to disable. | | createDecoration | (from, to, color, userId) => Decoration | inline with background-color | Custom decoration factory for full control over how authorship is displayed. |

API

| Export | Type | Description | |--------|------|-------------| | createWhoWroteWhatPlugin | (options: WhoWroteWhatOptions) => Plugin | Creates the authorship tracking plugin. | | setWhoWroteWhatVisibility | (view: EditorView, visible: boolean) => void | Toggles decoration visibility at runtime. | | whoWroteWhatPluginKey | PluginKey | Plugin key for reading plugin state. | | DEFAULT_COLORS | string[] | The 16 built-in pastel colors. | | createColorAssigner | (colors: string[]) => (userId) => string | Creates a function that assigns colors to user IDs. | | WhoWroteWhatMetaType | enum | Meta transaction types (SetVisibility). |

How It Works

  1. The plugin observes the Yjs XML fragment and user map for changes.
  2. On each change, it writes the current user's clientID -> userId mapping to a shared YMap.
  3. It walks the Yjs document tree, resolves each text item's author via the user map, and creates colored inline decorations.
  4. Decorations are dispatched to the ProseMirror plugin state and rendered by the editor.
  5. An adaptive debounce mechanism scales the recomputation delay with document complexity to keep the editor responsive.

TipTap

Register the plugin via TipTap's extension API:

import { Extension } from "@tiptap/core";
import { createWhoWroteWhatPlugin } from "@emergence-engineering/prosemirror-who-wrote-what";

const WhoWroteWhat = Extension.create({
  name: "whoWroteWhat",
  addProseMirrorPlugins() {
    return [createWhoWroteWhatPlugin({ userId: "current-user" })];
  },
});

Playground

See the interactive demo in the monorepo playground.

License

MIT