I was going through the code, and trying out the various DOM manipulation features and saw this:
// :: (Node, ?Object) → dom.Node
// Serialize this node to a DOM node. This can be useful when you
// need to serialize a part of a document, as opposed to the whole
// document. To serialize a whole document, use
// [`serializeFragment`](#model.DOMSerializer.serializeFragment) on
// its [`content`](#model.Node.content).
serializeNode(node, options = {}) {
return this.renderStructure(this.nodes[node.type.name](node), node, options)
}
now this.nodes[node.type.name] does not return a function, and thus this.nodes[node.type.name](node) returns a TypeError. Can you confirm this?
I was using a nodeView where I was calling it to serialize the content of the node
//This works fine
let {dom} = Promemirror.model.DOMSerializer.renderSpec(document, this.node.toDom(node)
//This does not
let a = new Prosemirror.model.DOMSerializer(this.node.type.schema.nodes, this.node.type.schema.marks)
let content = a.serializeNode(this.node)
You probably want DOMSerializer.fromSchema. The way you’re initializing the DOMSerializer isn’t valid – it takes object holding serializer functions, not node types (which is what you’re getting from the schema).
My “parent” has a paragraph node and a CodeMirror node as its content.
What I want is that I want a button over the CM node, which gives an option to run the given code. Thus I was using a node-view where I had made this button, but the CM node does not render according to the nodeView
Is there a way around such that I can have the CodeMirror NodeView with the Parent NodeView?
main = document.CreateElement('div')
main.innerHTLM = angularComponent
content = getDomFromNode(this.node) // from renderspec or serializeNode
main.appendChild(content)
this.dom = main
angularCompile(this.dom)
So now I want to pass the dom structure of contentDom to dom. And then I can angularize this.dom
Is this possible?