Hello, I’m trying to mount ProseMirror to a single paragraph element to allow for basic styling (strong, em, anchors, br etc) without inserting child <p>
nodes.
This is what I’ve come up with so far:
<p id="editor">
Some initial content <span>with spans</span><br>
and <strong>bold text</strong>.
</p>
const element = document.getElementById('editor')
const schema = new Schema({
nodes: {
text: {
group: "inline",
},
paragraph: {
group: "block",
content: "inline*",
toDOM() {
return ['', 0] // Trying to prevent child <p> nodes.
},
parseDOM: [{
tag: "p"
}],
},
doc: {
content: 'paragraph',
},
}
})
const editorState = EditorState.create({
doc: DOMParser.fromSchema(schema).parse(element),
})
let view = new EditorView(
{ mount: element! },
{
state: editorState,
}
)
This throws the exception:
Uncaught DOMException: String contains an invalid character
Is this the correct approach? I feel like I’m close, but missing some understanding.
The editing functionality appears to be working, the use of the text
node type works well but strips inline tags and does not allow for line-breaks which lead me to try the paragraph
type.