Hello there!
I have a schema with some list nodes similar to the following:
const schema = new Schema({
nodes: {
doc: {
content: "editorHeader editorBody"
},
editorHeader: {
// ...
},
editorBody: {
content: "body+",
defining: true,
isolating: true,
toDOM: () => ['article', 0],
parseDOM: [{ tag: 'article' }]
},
// Some other probably unrelated stuff in between
paragraph: {
content: "inline*",
group: "body",
toDOM: () => ["p", 0],
parseDOM: [{ tag: "p" }]
},
ordered_list: {
group: "body",
content: "list_item+",
attrs: { order: { default: 1 } },
parseDOM: [{
tag: "ol", getAttrs(dom: HTMLElement) {
return { order: dom.hasAttribute("start") ? +dom.getAttribute("start") : 1 };
}
}],
toDOM(node) {
return node.attrs.order == 1 ? ["ol", 0] : ["ol", { start: node.attrs.order }, 0];
}
},
bullet_list: {
group: "body",
content: "list_item+",
parseDOM: [{ tag: "ul" }],
toDOM() { return ["ul", 0]; }
},
list_item: {
content: "paragraph (ordered_list | bullet_list)*",
parseDOM: [{ tag: "li" }],
toDOM() { return ["li", 0]; },
defining: true
},
Now, attempting wrap some text in any list node with this schema results in the following error:
index.js:3284 Uncaught TypeError: this.nodes[node.type.name] is not a function
at _DOMSerializer.serializeNodeInner (index.js:3284:99)
at index.js:3276:34
at _Fragment.forEach (index.js:255:13)
at _DOMSerializer.serializeFragment (index.js:3250:18)
at nodeToElement (utils.ts:156:52)
at update (leaf.editor.svelte:225:39)
at LeafNodeView.update (leaf.nodeview.ts:170:34)
at CustomNodeViewDesc.update (index.js:1500:36)
at ViewTreeUpdater.updateNextNode (index.js:1809:37)
at index.js:1305:30
However replacing doc
’s content property with editorHeader body+
corrects the issue and works as expected. I don’t mind using this approach, the main issue I face is that I have a custom NodeView for editorBody
which includes some custom rendering for the children of that node and some styles and I wouldn’t want to get rid of all of that without exhausting all other possible solutions.
All other input rules for blockquotes, paragraph etc., nodes work just fine, it’s just list nodes which have this issue.
I would appreciate any help fixing the issue, thank you!