prosemirror-py
raw JSON → 0.6.1 verified Fri May 01 auth: no python
Python implementation of core ProseMirror modules for collaborative editing. Current version 0.6.1, requires Python >=3.10. Release cadence is irregular, with major upstream syncs every few months.
pip install prosemirror Common errors
error ModuleNotFoundError: No module named 'prosemirror' ↓
cause Package not installed or installed under a different name.
fix
Run
pip install prosemirror. error ImportError: cannot import name 'Schema' from 'prosemirror' ↓
cause Trying to import Schema from the top-level package instead of subpackage.
fix
Use
from prosemirror.model import Schema. error KeyError: 'is_text_block' ↓
cause Using old attribute name `is_text_block` which was renamed in v0.5.0.
fix
Use
is_textblock instead. Warnings
gotcha Python string slicing uses Unicode codepoints, but ProseMirror positions are UTF-16 code units. This affects text_between and diff calculations. Always use UTF-16 aware functions when computing positions. ↓
fix Use the library's internal UTF-16 handling (no custom string slicing).
breaking In v0.5.0, `is_text_block` was renamed to `is_textblock` to match upstream. Old code using `is_text_block` will break. ↓
fix Replace `is_text_block` with `is_textblock`.
breaking Python 3.9 and lower are no longer supported as of v0.5.0. Install may fail on older Python versions. ↓
fix Upgrade to Python 3.10+.
gotcha Importing from `prosemirror` directly (e.g., `from prosemirror import Schema`) does not work. Use the full subpackage path. ↓
fix Import from subpackages like `prosemirror.model`.
Imports
- Schema wrong
from prosemirror import Schemacorrectfrom prosemirror.model import Schema - DOMParser
from prosemirror.model import DOMParser - Transform wrong
from prosemirror import Transformcorrectfrom prosemirror.transform import Transform - Step
from prosemirror.transform import Step - schema wrong
from prosemirror import schemacorrectfrom prosemirror.schema_basic import schema
Quickstart
from prosemirror.model import Schema, DOMParser
from prosemirror.schema_basic import schema
# Create a document from HTML
dom_parser = DOMParser.from_schema(schema)
doc = dom_parser.parse('<p>Hello, world!</p>')
print(doc.to_json())
# Output: {'type': 'doc', 'content': [{'type': 'paragraph', 'content': [{'type': 'text', 'text': 'Hello, world!'}]}]}