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

@type-editor/model

v0.0.3

Published

This is a refactored version of the ProseMirror's 'model' module. Original: https://github.com/ProseMirror/prosemirror-model

Readme

@type-editor/model

This is a refactored version of the prosemirror-model module.

This module defines ProseMirror's content model, the data structures used to represent and work with documents. It provides the foundation for building rich-text editors by implementing the document tree structure, schemas that define valid document content, and utilities for parsing and serializing DOM content.

Installation

npm install @type-editor/model

Document Structure

A ProseMirror document is a tree. At each level, a node describes the type of the content, and holds a fragment containing its children.

Nodes are persistent data structures. Instead of changing them, you create new ones with the content you want. Old ones keep pointing at the old document shape. This is made cheaper by sharing structure between the old and new data as much as possible.

Do not directly mutate the properties of a Node object. See the guide for more information.

Resolved Positions

Positions in a document can be represented as integer offsets. But you'll often want to use a more convenient representation that provides context information about the position within the document tree.

A resolved position knows its parent node, its position within that parent, and provides access to ancestor nodes at any depth.

Document Schema

Every ProseMirror document conforms to a schema, which describes the set of nodes and marks that it is made out of, along with the relations between those, such as which node may occur as a child node of which other nodes.

The schema defines:

  • Node types: Block elements (paragraphs, headings, lists) and inline elements (text)
  • Mark types: Formatting that can be applied to inline content (bold, italic, links)
  • Content expressions: Rules for what content each node type can contain
  • Attributes: Custom data that can be attached to nodes and marks

DOM Representation

Because representing a document as a tree of DOM nodes is central to the way ProseMirror operates, DOM parsing and serializing is integrated with the model.

The DOMParser converts HTML/DOM content into ProseMirror documents, while DOMSerializer converts ProseMirror documents back to DOM nodes.

(Note that you do not need to have a DOM implementation loaded to use the core parts of this module.)

Usage Examples

Creating a Schema

import { Schema } from '@type-editor/model';

const schema = new Schema({
  nodes: {
    doc: { content: 'block+' },
    paragraph: { 
      content: 'inline*', 
      group: 'block',
      toDOM: () => ['p', 0]
    },
    text: { group: 'inline' }
  },
  marks: {
    bold: {
      toDOM: () => ['strong', 0],
      parseDOM: [{ tag: 'strong' }, { tag: 'b' }]
    }
  }
});

Creating Document Nodes

// Create a text node
const textNode = schema.text('Hello, world!');

// Create a paragraph with text
const paragraph = schema.nodes.paragraph.create(null, textNode);

// Create a document
const doc = schema.nodes.doc.create(null, paragraph);

Working with Positions

// Resolve a position to get context
const $pos = doc.resolve(5);

// Access parent node
const parent = $pos.parent;

// Get depth in the tree
const depth = $pos.depth;

// Navigate to ancestors
const grandparent = $pos.node(depth - 1);

Parsing and Serializing DOM

import { DOMParser, DOMSerializer } from '@type-editor/model';

// Parse HTML into a document
const parser = DOMParser.fromSchema(schema);
const doc = parser.parse(domElement);

// Serialize document to DOM
const serializer = DOMSerializer.fromSchema(schema);
const domNode = serializer.serializeFragment(doc.content);

API Reference

For detailed API documentation, see the ProseMirror Reference Manual.

License

MIT