Hello,
I am extremely knew to Prosemirror.
However am trying to get a flow working where
-
I have the Prosemirror document json (generated by a schema + Node Views)
-
I have schema (without the Node views)
-
I need to Generate HTML from this json - done and working
const state: EditorState = EditorState.create({ schema, doc: Node.fromJSON(schema, documentJson.content), }); const html = DOMSerializer.fromSchema(schema).serializeFragment(state.doc.content, {document}); div.appendChild(html);
-
Need to edit the HTML for some content and then convert it back to Prosemirror JSON where all elements must match. Using a parser like so DOMParser.fromSchema(schema).parse(element);
**** Step 4 is where am blocked. The generated json is not the same as the original json (which was constructed using Schema + custom Node views) and is missing some elements/content in the json
What do I need to do to apply the same Node Views?
It looks like the parseDOM in schema is unable to access the domNode: That is one of the problems.
getAttrs(domNode: HTMLSpanElement) { return { condition: domNode.getAttribute(‘data-condition’), };
Any help is appreciated! Thank you!