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

@tozd/prosemirror

v0.2.0

Published

ProseMirror frontend utilities for Go port of ProseMirror.

Readme

Go port of ProseMirror

pkg.go.dev NPM Go Report Card pipeline status coverage report

A Go port of ProseMirror for server-side parsing, validation, and canonical HTML serialization of documents, with a TypeScript companion (the @tozd/prosemirror NPM package) that builds the same schema in the browser from the same shareable JSON.

The components currently available:

  • model package, ported from prosemirror-model v1.25.8 – the document model: schemas, nodes, marks, content expressions, HTML fragment parsing, and canonical HTML serialization.

Each ported component mirrors the structure of its ProseMirror TypeScript source so the two can be kept in sync. See PORTING.md for the porting contract.

It is used by PeerDB, a collaborative database.

Installation

Go installation

You can add it to your project using go get:

go get gitlab.com/tozd/go/prosemirror/model

It requires Go 1.25 or newer.

TypeScript/JavaScript installation

You can add frontend utilities for Go port of ProseMirror to your project using npm:

npm install --save @tozd/prosemirror prosemirror-model

It requires node 22 or newer.

Usage

Go usage

schema, errE := model.NewSchema(schemaJSON, map[string]model.AttrValidator{
  "linkURL": validateLinkURL,
})
if errE != nil {
  // Handle the error.
}

doc, errE := model.ParseHTML(schema, `<p>Hello, <b>world</b>!</p>`, model.ParseOptions{})
if errE != nil {
  // Handle the error.
}

canonical := model.SerializeHTML(doc)

ok, errE := model.IsCanonicalHTML(schema, canonical, model.ParseOptions{})
// ok is true: serializing a parsed document always yields the canonical form.

See full package documentation with examples on pkg.go.dev.

TypeScript/JavaScript usage

The same schema JSON can be built into a ProseMirror schema in the browser:

import { buildSchema } from "@tozd/prosemirror"

const schema = buildSchema(schemaJSON, { linkURL: validateLinkURL })

buildSchema takes a parsed schema JSON object and a registry of named attribute validators and returns a prosemirror-model Schema, with parseDOM and toDOM derived from the dialect, the browser-usable counterpart of model.NewSchema. prosemirror-model is a peer dependency. The frontend and the Go backend build the same schema from one shared JSON definition.

Schema JSON dialect

Schemas are described by a single JSON document that can be shared with a ProseMirror TypeScript implementation. Functions cannot live in JSON, so attribute validators are referenced by name (resolved against a registry passed to model.NewSchema) and the HTML mapping is declarative (toHTML and parseHTML keys on nodes and marks). model.NewSchema accepts any spec in this dialect, not only the example schema shipped as a fixture: toHTML covers the declarative subset of ProseMirror's DOMOutputSpec (including nested elements such as a code block rendered as pre wrapping code), and parseHTML accepts a full CSS selector in tag (matched with cascadia), style rules keyed on an inline CSS declaration ({"style": "font-weight=bold"}), and a namespace constraint, alongside context and priority. See PORTING.md for the full specification of the dialect.

The one documented fidelity boundary is style matching: a style rule matches only an element's own inline longhand declarations and does not perform CSSOM shorthand expansion or value normalization. So style="font-weight: bold" matches a font-weight rule, but style="font: bold 12px serif" (which exposes font-weight only after shorthand expansion in a browser) does not. Everything else parses identically to the browser. Editor-only behaviors and the transform and collaboration layers are out of scope.

Related projects

  • prosemirror-go – a similar port which is somewhat stale and is licensed under AGPL.

GitHub mirror

There is also a read-only GitHub mirror available, if you need to fork the project there.

Disclaimer

Port has been fully generated and maintained by AI.

License

Licensed under the Apache License, Version 2.0 (see LICENSE). The ported packages are derivative works of the corresponding ProseMirror packages, used under the MIT license (see NOTICE).