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. Currently maintained by Johannes Wilm (FidusWriter, johannes@fiduswriter.org).

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

License

MIT — see LICENSE.

Copyright 2026 Johannes Wilm Copyright 2020 Daniel Seiler 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.3.7.tar.gz (82.3 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.3.7-cp314-cp314-win_amd64.whl (378.0 kB view details)

Uploaded CPython 3.14Windows x86-64

prosemirror_rs-0.3.7-cp314-cp314-macosx_11_0_arm64.whl (477.5 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

prosemirror_rs-0.3.7-cp314-cp314-macosx_10_12_x86_64.whl (495.9 kB view details)

Uploaded CPython 3.14macOS 10.12+ x86-64

prosemirror_rs-0.3.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (547.1 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

prosemirror_rs-0.3.7-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (532.7 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

File details

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

File metadata

  • Download URL: prosemirror_rs-0.3.7.tar.gz
  • Upload date:
  • Size: 82.3 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.3.7.tar.gz
Algorithm Hash digest
SHA256 596f359142b63b8a61f146621ab67f21fa8659643b9b26bba347386a1bfe6d9a
MD5 81927c495f774c7dfc4347be58d9d251
BLAKE2b-256 30e8aaea35c98ecae0a5b30ffbeb62821455f1a3c97ddb212ac54c24ff3de5ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for prosemirror_rs-0.3.7.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.3.7-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for prosemirror_rs-0.3.7-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 b647019852a707cd0608c646098db4b0c7e4f3b0a47557a7b37b087caaed7fa8
MD5 a909fa41dc43b8f3168e745d5614a52b
BLAKE2b-256 0239071f3a5354390e19e7a40ae877e403140b2c6babab415f5e2f380ccb75d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for prosemirror_rs-0.3.7-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.3.7-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for prosemirror_rs-0.3.7-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 de7b327dfac733f0226c19af291831ec97896a40222a2c5bc5c29bc03605bcb6
MD5 3a19c364ad53b2200ae1ce9ea0820dbe
BLAKE2b-256 8fdf548108eee1b098fd94bd9d70a57c7c1c6d3b3633d1e6f000a46287ba1938

See more details on using hashes here.

Provenance

The following attestation bundles were made for prosemirror_rs-0.3.7-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.3.7-cp314-cp314-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for prosemirror_rs-0.3.7-cp314-cp314-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a7bde0f3769f59e2e71cf8c21176b0c1843fbc3134791c8d1dc62e80d4bd9e99
MD5 d94cd0003ab3c4a5d01f4e7990770e82
BLAKE2b-256 cf4ad92a25db2d0e92d9d7bc31bde911f45bc438ec92fe2d085fc723cefb7ac2

See more details on using hashes here.

Provenance

The following attestation bundles were made for prosemirror_rs-0.3.7-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.3.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for prosemirror_rs-0.3.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 36e2f2b63e02d237537acaf75e067374c0bb8941c9f1350ca4a5703db07b3ca0
MD5 4147cb040d77fe145c33dd252143ee60
BLAKE2b-256 029ad60f982d2125b8f7cfa2225c9c0512a3199fb5246f71bedb64b97936ef76

See more details on using hashes here.

Provenance

The following attestation bundles were made for prosemirror_rs-0.3.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_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.3.7-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for prosemirror_rs-0.3.7-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1bf71dcb0aea6c48ff487b1109f84582ad6b2fe4ee21e47db5fd7c2a672d14db
MD5 20364b6cc33f28235603022b09b6144b
BLAKE2b-256 4e43f379b32996f9683e2b07d65cb4b7fbfc8572dbbc8a9fc5547a238e1c4587

See more details on using hashes here.

Provenance

The following attestation bundles were made for prosemirror_rs-0.3.7-cp38-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