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

prosemirror-plugin-inspector

v0.2.2

Published

A ProseMirror plugin for inspecting and modifying nodes.

Readme

prosemirror-plugin-inspector

A web component for inspecting the currently selected ProseMirror node.

Table of Contents

Installation

npm i prosemirror-plugin-inspector

Usage

Import the inspectorPlugin() function with all of your other ProseMirror code:

import { EditorState } from "prosemirror-state";
import { EditorView } from "prosemirror-view";
import { inspectorPlugin } from "prosemirror-plugin-inspector";

const schema = new Schema(
  // SchemaSpec goes here
);

new EditorView(document.querySelector("#editor"), {
  state: EditorState.create({
    schema: schema,
    plugins: [
      // load other plugins
      inspectorPlugin({
        // see function documentation for configuration
      }),
    ],
  }),
});

Styling

The html configuration option expects a DocumentFragment that you can fill with <link> or <style> tags. The DocumentFragment will be inserted at the start of the shadow DOM.

To style the inline decorations added by the plugin, use the .placeholder class selector.

Documentation

This module exports a plugin creation function, a PluginView, and a PluginKey for attaching a node inspector to a ProseMirror editor. Additionally, the findPlaceholder() helper function allows for the discovery of decorations placed by file uploads. Type declarations for the exported items are generated from JSDoc annotations in the code.

A quick reference is below; refer to the documentation comments in the code and their corresponding type declarations for a more thorough breakdown.

Exports

InspectorView

The class for creating and updating the inspector.

inspectorPlugin()

A function that returns a plugin you can pass to the editor state. It takes an object with the following properties as an argument:

  • class?: The classes for the inspector wrapper
  • element?: Where the inspector should be adjacently inserted
  • fields: An object with node names as keys and Maps as values; the Map has section names as keys and an array of FieldSpecs as values
  • html?: A document fragment containing elements that will style the inspector or provide information about a node; it will be prepended to the inspector's shadow root. The data-path attribute is a string that specifies where to look for a value on the selected node.
    • For example, <h2 data-path="type.name">Node name</h2> will display the value of the node.type.name attribute for all nodes
  • toggle(isVisible)?: A function that runs when the visible property of the plugin's state changes; it receives a boolean value indicating whether or not the inspector should be visible
  • where?: The InsertPosition indicating where to insert the inspector relative to the element key
  • state?: An object representing the initial state of the plugin
    • visible: A boolean value indicating whether or not the inspector is visible
    • decorations: A DecorationSet of placeholders the relevant to the plugin

The fields property is required, but the rest of the properties are optional.

inspectorPluginKey

The key of the plugin created by inspectorPlugin().

ProseMirrorInspector

The class for the custom element that contains the inspector. The custom element uses shadow DOM, and it exposes elements for styling via the part attribute.

findPlaceholder()

Note: As this function is only for specific field types, we should probably remove it. Example field types will probably become a separate package, and this will be moved there.

This function accepts two arguments: an EditorState and a unique id for a Decoration. After searching through the state's decorations, it returns the from position of the first instance of the decoration, and null otherwise.