I have a schema defined like this:
const nodes = {
doc: {
content: 'section*'
},
section: {
attrs: {
id: {}
},
content: 'sectionHeader sectionContent',
},
sectionHeader: {
selectable: false,
defining: true,
isolating: true,
attrs: {
id: {default: null},
sectionId: {default: null},
text: {default: null},
dueDate: {default: null},
index: {default: null}
}
},
sectionContent: {
selectable: false,
defining: true,
isolating: true,
content: "(paragraph | heading | componentWrapper | list)*",
attrs: {
id: {default: null},
collapsed: {default: false}
},
parseDOM: [{tag: "div"}],
toDOM: node => ["div", {id: node.attrs.id, style: (node.attrs.collapsed ? 'display: none;' : 'display: block;' )}, 0]
},
componentWrapper: {
defining: true,
selectable: false,
isolating: true,
attrs: {
id: {default: null}
},
content: "component",
parseDOM: [{
tag: "div",
getAttrs: dom => ({ id: dom.getAttribute('id') })
}],
toDOM: node => ["div", {id: node.attrs.id, class: "component-wrapper"}, 0]
},
task: {
group: "component",
inline: true,
defining: true,
selectable: false,
isolating: true,
attrs: {
id: {default: null},
assigneeId: {default: null},
description: {default: ''},
isDone: {default: false},
createdBy: {default: null},
createdAt: {default: null},
dueDate: {default: null},
completedBy: {default: null},
completedAt: {default: null}
}
},
... other components
}
But for some reason when I add a component to the document an extra line break is added:
If the user puts the cursor on that line break and tries to type something nothing happens.
Is there a way to prevent that line break from being created ?
Another problem is that I am not able to delete the componentWrapper node. I try it like this:
const deleteTransaction = this.currentCanvasState.tr.delete(nodeAndPos.pos, nodeAndPos.pos + 1);
this.dispatchTransactionToCanvas(deleteTransaction);
but the delete transaction has a ReplaceStep which replaces the componentWrapper with a copy of the componentWrapper.
I assume this is a problem with my schema definition but I was not able to figure out what the problem is.