Skip to main content

Python translation of prosemirror parts needed to modify a document in Python

Project description

=====
Prosemirror-python
=====

This is an unofficial and not production ready package. Contributions and improvements are welcome.

This package does not attempt at importing all of Prosemirror in Python. It is merely trying to use those parts of
prosemirror-model and prosemirror-transform that are needed for serverside operations.


**This package has not yet been extensively tested!**

How to use it
-----------

1. Install with `pip install prosemirror`

2. In your python code, import the two included functions with:


from prosemirror import create_doc, transform_doc

3. Then create a Document object:

doc = create_doc(doc_data, spec_data) # spec_data = JSON.parse(JSON.stringify(view.state.schema.spec))


4. Thereafter create an updated Document object with the given steps applied:

updated_doc = transform_doc(steps_data, doc)

5. To get the JSON version of a Document object, simply use the builtin toJSON method:

updated_doc.toJSON()


Speed
-----------

It is not setting any speed records so far. These tests were conducted with Python 2 with the test files in the repo (applying three steps to an existing doc):

prosemirror-python: 0.024s

nodejs: 0.00013s

jsonpatch (Python): 0.00024s

So it is around 200 times slower than nodejs and 100 times slower than using jsonpatch. It is possible that it could be sped up in various ways, for example by using pypy and a vm or alike. Please let me know if you figure something out!

License questions
-----------

**Q - What license is this under?**

A - AGPL-3, check the LICENSE file.


**Q - I have spent the past month building a webbased text editing app. I am in stealth
mode as my editor is really unique and I'll be the next IT Billionaire once I
release it. Now I would like to use this library, but the AGPL requires me to share
changes I make with others! It's not fair that you are standing between me and my fortune!**

A - Right. If it is worth that much to you, you can try to pay me so that I'll put it under
a more liberal license. Secondly, you could suggest taking over maintainership of this
library and promise extra features to get me to change my mind. Thirdly - you could just
start from scratch as long as it's not much code, but then we both lose out of any fixes
either one of us makes.

We all need to live of something, I give a lot of code away for free
and the only requirement there is is that you contribute any changes you make back. Not
that expensive, if you think about it.

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-python-0.0.4.tar.gz (62.9 kB view details)

Uploaded Source

File details

Details for the file prosemirror-python-0.0.4.tar.gz.

File metadata

  • Download URL: prosemirror-python-0.0.4.tar.gz
  • Upload date:
  • Size: 62.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

File hashes

Hashes for prosemirror-python-0.0.4.tar.gz
Algorithm Hash digest
SHA256 8b60d066a749e2bc8617dd4d99232c817cadccb309adc527145581a834cdc28f
MD5 a76b6bde1aee25e22afe5f34c951b809
BLAKE2b-256 ab3e33ff3b24bfd4fb289e2086da4edcebec5b259c96bd88c47c58658e625f28

See more details on using hashes here.

Supported by

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