I’m defining the following custom node in my schema (i’m using tiptap syntax but whatever, it’s just a lib on top of prosemirror)
{
name: "editorTitleNode",
content:'text',
priority: 1000,
isBlock: true,
isTextblock: true,
draggable: false,
group: "block",
parseHTML() {
return [{ tag: "p[class='editor-title-node']" }];
},
renderHTML({ node, HTMLAttributes }: any) {
const { firstChild } = node;
if (firstChild) {
return ["p", mergeAttributes(HTMLAttributes, { class: "editor-title-node" }), 0];
} else {
const domEl = document.createElement("p");
domEl.setAttribute("class", "editor-title-node");
// domEl.setAttribute("contenteditable", "true");
domEl.textContent = "Default Page Title";
return domEl;
}
}
}
My document has that node compulsory :
content: "editorTitleNode block+"
So if initially the editorTitleNode doesn’t have any content , then it will inject the text “Default Page Title” inside the paragraph but then once i try to edit it i’m getting the error :
handleKeyDown : error : RangeError: Position -1 outside of fragment (<editorTitleNode, paragraph>)
Isn’t it possible to just make such as custom node and not a custom node view and make it editable ? Why do i get that error when i try edit the paragraph ?!