Skip to main content

Python bindings for prosemirror-rs: a Rust implementation of ProseMirror's document model and transform pipeline

Project description

prosemirror-rs — Python bindings

Python bindings for prosemirror, a Rust implementation of ProseMirror's document model and transform pipeline.

Installation

pip install prosemirror-rs

Design goals

  • Zero unnecessary copies. The schema and document live entirely in Rust memory. Only JSON strings cross the Python/Rust boundary.
  • Wire-efficient. Steps arriving as JSON (e.g. from a WebSocket) can be passed directly to apply_steps_json() without any Python-level parsing.
  • Database-efficient. doc_json() serializes the document in Rust and returns a plain Python str, ready to write to a database with no intermediate Python objects.

Quick start

from prosemirror_rs import Editor
import json

schema_json = json.dumps({
    "nodes": {
        "doc":       {"content": "paragraph+"},
        "paragraph": {"content": "text*", "group": "block"},
        "text":      {"group": "inline"},
    },
    "marks": {"strong": {}, "em": {}},
})

doc_json = json.dumps({
    "type": "doc",
    "content": [{"type": "paragraph", "content": [{"type": "text", "text": "Hello"}]}],
})

editor = Editor(schema_json, doc_json)
print(editor.version)   # 0

# Typical server loop: steps arrive as raw JSON from a client
async def on_message(raw: str):
    data = json.loads(raw)                          # parse envelope only
    results = editor.apply_steps_json(              # steps stay as JSON string
        json.dumps(data["steps"])
    )
    if all(results):
        doc = editor.doc_json()                     # serialised in Rust
        await db.execute("UPDATE docs SET body = $1", doc)

API reference

Editor(schema_json, doc_json)

Create an editor. Both arguments are JSON strings (schema spec and initial document). Raises ValueError on malformed input.

editor.apply_step(step_json) -> bool

Apply one step supplied as a JSON string. Returns True on success, False if the step cannot be applied (document is left unchanged). Raises ValueError on invalid JSON.

editor.apply_steps_json(steps_json, *, stop_on_failure=True) -> list[bool]

Preferred method for incoming network data. Accepts a JSON array of steps as a single string — passed directly to Rust and parsed there, so nothing touches Python's JSON machinery. Returns one bool per step.

editor.apply_steps(steps, *, stop_on_failure=True) -> list[bool]

Convenience method for when steps are constructed or modified in Python. Each element of steps is a JSON string for one step. All steps are parsed before any are applied, so a bad JSON string raises ValueError without mutating the document. Returns one bool per step.

editor.doc_json() -> str

Return the current document as a compact JSON string. Serialized entirely in Rust; only the final string is handed to Python — suitable for direct database writes with no intermediate objects.

editor.version (int, read-only property)

Number of steps successfully applied since construction. Use as a document version counter in collaborative-editing protocols.

Credits

The underlying Rust library was originally written by Daniel Seiler (Xiphoseer, me@dseiler.eu), who designed and implemented the document model, transform pipeline, and runtime schema system. Mustafa J (mustafa.0x@gmail.com) has made substantial contributions to the core Rust implementation. Currently maintained by Johannes Wilm (FidusWriter, johannes@fiduswriter.org).

ProseMirror is by Marijn Haverbeke and contributors — see prosemirror.net.

The Python test suite used for cross-implementation validation is taken from prosemirror-py, a Python port of ProseMirror originally created by Shen Li and maintained by Samuel Cormier-Iijima, Patrick Gingras, and others at Fellow Insights Inc.

License

MIT — see LICENSE.

Copyright 2026 Johannes Wilm Copyright 2025–2026 Mustafa J Copyright 2020 Daniel Seiler Copyright 2019 Fellow Insights Inc. (prosemirror-py Python port) Copyright 2015–2026 Marijn Haverbeke and others

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prosemirror_rs-0.5.0.tar.gz (186.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

prosemirror_rs-0.5.0-cp314-cp314-win_amd64.whl (825.2 kB view details)

Uploaded CPython 3.14Windows x86-64

prosemirror_rs-0.5.0-cp314-cp314-macosx_11_0_arm64.whl (932.4 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

prosemirror_rs-0.5.0-cp314-cp314-macosx_10_12_x86_64.whl (966.6 kB view details)

Uploaded CPython 3.14macOS 10.12+ x86-64

prosemirror_rs-0.5.0-cp310-abi3-manylinux_2_28_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ x86-64

prosemirror_rs-0.5.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.0 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

File details

Details for the file prosemirror_rs-0.5.0.tar.gz.

File metadata

  • Download URL: prosemirror_rs-0.5.0.tar.gz
  • Upload date:
  • Size: 186.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for prosemirror_rs-0.5.0.tar.gz
Algorithm Hash digest
SHA256 69d3708bf5c7e26031f306ae2ba084dd89d156b8c85e7a8a1f0ea9ab27de71b3
MD5 2adff14fe58ab2f7f506de3984e754c1
BLAKE2b-256 84c65cbf7eb1f35427d9ab7bca225faeaf75bcbe0fe8ad505937fc72048400f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for prosemirror_rs-0.5.0.tar.gz:

Publisher: publish.yml on fiduswriter/prosemirror-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file prosemirror_rs-0.5.0-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for prosemirror_rs-0.5.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 13ea275953bc2dea0f5509d0bbadd393a4f27df2c6a8e16b4da92ed9b6f2c68f
MD5 952d85d48c7e3b1e680e7d343fe4a61c
BLAKE2b-256 67399fc5085f13d5eb2137b5aea747ca0f7599147d8dfe459f2fdcae775894eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for prosemirror_rs-0.5.0-cp314-cp314-win_amd64.whl:

Publisher: publish.yml on fiduswriter/prosemirror-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file prosemirror_rs-0.5.0-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for prosemirror_rs-0.5.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e76c1edd693d8401e2935f4417340dd428bf32146279222340fd42a77469bf39
MD5 152a1d7b800fae28cb03a1f6d0856d5f
BLAKE2b-256 c444c5db9b15043ca1475d7d134ff52d09b4036c1385ea7b8b57d0c26d5efb5a

See more details on using hashes here.

Provenance

The following attestation bundles were made for prosemirror_rs-0.5.0-cp314-cp314-macosx_11_0_arm64.whl:

Publisher: publish.yml on fiduswriter/prosemirror-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file prosemirror_rs-0.5.0-cp314-cp314-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for prosemirror_rs-0.5.0-cp314-cp314-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c2035768d3f2f709a54b31dbf57d48089f63ad6f7290ff82f4f3ae0a32cb9a23
MD5 fc722704650102c02f913878e8930868
BLAKE2b-256 904f10f07918b45c2cebaca06831d94107d70f6b7a6e6e6d22de69c9b4de3655

See more details on using hashes here.

Provenance

The following attestation bundles were made for prosemirror_rs-0.5.0-cp314-cp314-macosx_10_12_x86_64.whl:

Publisher: publish.yml on fiduswriter/prosemirror-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file prosemirror_rs-0.5.0-cp310-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for prosemirror_rs-0.5.0-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 be1bc43b2dc5c1c2ba54120f4caec2169d7741621eb3da9491f685a293d431f9
MD5 e9c694ac25d6bcfdf82a65007f82408a
BLAKE2b-256 3d8cd9669b0a83480edc7f39267fae1b25f6b6a0efb2d69bbecc6099da754369

See more details on using hashes here.

Provenance

The following attestation bundles were made for prosemirror_rs-0.5.0-cp310-abi3-manylinux_2_28_x86_64.whl:

Publisher: publish.yml on fiduswriter/prosemirror-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file prosemirror_rs-0.5.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for prosemirror_rs-0.5.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c0e0cf6709e0d8047312bdf3528427103d1ee89f1c4b2299b8e46df3b17a6c7a
MD5 905f26cce8ad771a8da44977918d8d1c
BLAKE2b-256 ef40ff261465717eb27b789b1ec3ed45eb83489fb9d4d97a05e49f95bc2cdeab

See more details on using hashes here.

Provenance

The following attestation bundles were made for prosemirror_rs-0.5.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish.yml on fiduswriter/prosemirror-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page