Invoking parseDOM

I have a question about the following part of the documentation, which describes how to setup a basic editor:

var schema = require("prosemirror-schema-basic").schema
// ...
var state = EditorState.create({
  doc: schema.parseDOM(document.getElementById("content"))

Here, I’m getting an error saying that parseDOM is not a member of schema.

I’ve been grepping through the source code and it’s actually quite difficult to find a definition for the parseDOM function…

So perhaps somebody can help me out.

Also, I’m wondering how to set the contents of an existing editor with html (basically to swap-in a new state). Does this have to go through a transform? Or can the state be set directly? (I don’t need this operation recorded in a history, or as a part of collaborative editing). Of course, I could create a new editor/view from scratch, but perhaps there is a better way to do this.


For reference, I’ve solved the first part of my question as follows:

var domnode = document.createElement("div");
domnode.innerHTML = the_actual_html;
var parser = DOMParser.fromSchema(schema);
var opts = {};
opts.preserveWhitespace = true;
doc = parser.parse(domnode, opts);

Your solution is the proper way to do that now. Where in the docs does the example you pasted occur? I can’t find it.

Yes, if you create a new state, you can simply pass it to updateState to update your view.

Ok. Good to know, thanks!

By the way, the example comes from (and search for parseDOM)

Ah, found it (and fixed it)