How to get the complete HTML text from document, rather than the fragments?

Hello,

I feed some HTML text directly from a database into the document while creating the EditorState:

    const state = EditorState.create({
        doc: this.parser.parse(this.htmlToElement(this.html)),
        plugins: plugins,
    });

When pushing the save button I want to get the complete HTML text from the document. Currently I only get the latest bit of the content, by using the following:

    getHtmlValue() {
            const fragment = DOMSerializer.fromSchema(schema).serializeFragment(this.view.state.doc.content);
            return new XMLSerializer().serializeToString(fragment)
    }

When i examine the this.view.state.doc.content object it appears to contain fragments for the complete document of which the prosemirror is just a part, how do I easily get just the content in the prosemirror itself?

Mazzel,

Martijn.

This is what I do for tiptap.

3 Likes

state.doc.content should be the entire editor content. I can’t quite figure out what you mean when you say it’s just a fragment.