The doc of my editor has a required custom node editorTitleView. Here is how i wrote its definition
nodes.doc.content = ‘editorTitleView selectMenu? block+’;
The editorTitleView’s parseDOM requires not only editor-title as a tagName but also editorTitleCls as its class.
parseDOM: [
{
tag: 'editor-title[class]',
getAttrs(dom) {
const classList = dom.getAttribute('class');
if (classList && !classList.includes('editorTitleCls')) {
return false;
}
return {
class: classList,
};
},
},
],
Now this is how i parse the initial content and i create the doc that will be passed to the editor’s view state later on
const initialContentDiv = document.createElement('div');
initialContentDiv.innerHTML = 'This is an initial simple string content to be passed to the editor';
const doc = DOMParser.fromSchema(ProsemirrorEditorSchema).parse(initialContentDiv);
new EditorView(pmEditor, {
state: EditorState.create({
schema: ProsemirrorEditorSchema,
doc,
plugins,
}),
});
The problem i always get is that simple string passed to the doc will be always taken as the editorTitleView’s own content while it’s supposed to be appended to the doc content (in its own pragraph) just after the required editorTitleView node which itself should be empty: This is the doc structure just after its creation :
{
"type": "doc",
"content": [{
"type": "editorTitleView",
"content": [{
"type": "paragraph",
"content": [{
"type": "text",
"text": "This is an initial simple string content to be passed to the editor"
}]
}]
}, {
"type": "paragraph"
}]
}
Why does it happen and how i can prevent this ?