I thought of using the code for bulleted_list or ordered_list, and applying a <dt> tag for even and a <dd> tag for odd entries. This would work similar to other lists in the editor. Is this possible to achieve in the parseDom/toDom function in the schema? Has anyone done similar things?
I wouldn’t recommend going that way. A new node type with actual dedicated term and description child nodes is probably going to require less hacks (and avoids the problem where, if you remove a child, all the nodes below it change meaning).
if (type = schema.nodes.description_list) {
let dl = type
r.wrapDescriptionList = new MenuItem({
title: "Add description list",
icon: icons.desriptionList,
enable(state) { return canInsert(state, dl) },
run(state, dispatch) { dispatch(state.tr.replaceSelectionWith(dl.createAndFill())) }
})
}
This renders perfectly and empty
<dl>
<dt></dt>
<dd></dd>
</dl>
structure.
My next big thing is now the Enter binding. Enter within <dt> should jump to <dd>, Enter within <dd> should add a new empty <dt></dt><dd></dd> structure if not empty. If empty it should leave the parent <dl> Structure and add a new node (paragraph). I’m looking into the splitListItem Function in prosemirror-schema-list, but I’m not very lucky. I would be very happy to know some ideas in which direction to search (examples? commands?). Any help very appreciated, thanks!