Prosemirror in Python - is it stable?

Hey, the topic of how share ProseMirror steps with a Python backend has been a few times in the past. In our current version 3.8 of Fidus Writer, we are sending changes to the server both as steps (for redistribution to other clients) and as a RFC6902 json patch for the server to apply to the document that is to be saved. That is working, but obviously it brings a number of issues with it.

So for the next version I have been looking at using https://github.com/fellowinsights/prosemirror-py directly on the server. That works fine in testing and also the one major hurdle there was (loading the schema) was not that difficult to get around.

But is it stable? Is the JavaScript version of ProseMirror likely to change any time soon in a way that makes it incompatible? Does anyone have experience using the Python library?

1 Like

The parts you would be using in this situation (applying steps, not much more, right?) are unlikely to change without ProseMirror moving to a new major version (which is also unlikely to happen on the short term). I see, however, that the package also implements things like Transform.replace, which is a lot more hairy, and in fact has already been changed a bit since the port was written.

2 Likes

Posts like this make me hopeful for things like GraalVM’s polyglot functionality. Where one can – supposedly – seamlessly, run code across languages.

1 Like

Right, the ones I am currently using on the backend in my test are the equivalents of the following:

const schema = new Schema(specJSON)
let doc = Node.fromJSON(schema, docJSON)
const step = Step.fromJSON(schema, stepJSON)
const stepResult = step.apply(doc)
if (stepResult.ok) {
    doc = stepResult.doc
} else {
    // resend client entire doc as something seems to have gone extremely wrong
}

And that’s also really all I could see make sense to use on the backend.

I don’t see why we would need to use things like that on the backend ever, but it’s good to know that this is outside the limitations of what can be depended upon not to change.