I have a nested ordered list and I’d like to update attributes (list style type) but only for the nested level. When I put the cursor into any item in the nested level and call tiptap’s editor.updateAttributes(), it updates the list style type but for all the levels, not only the nested one. updateAttributes
is based on nodesBetween
as follows:
const from = range.$from.pos
const to = range.$to.pos
state.doc.nodesBetween(from, to, (node, pos) => {
if (nodeType && nodeType === node.type) {
tr.setNodeMarkup(pos, undefined, {
...node.attrs,
...attributes,
})
}
if (markType && node.marks.length) {
node.marks.forEach(mark => {
if (markType === mark.type) {
const trimmedFrom = Math.max(pos, from)
const trimmedTo = Math.min(pos + node.nodeSize, to)
tr.addMark(
trimmedFrom,
trimmedTo,
markType.create({
...mark.attrs,
...attributes,
}),
)
}
})
When I put the cursor inside the main level (not nested), then only atrtibutes of that level are updated. So theoretically I can first update attributes on nested level (which updates attribute of main level too) and then update attributes on main level, but its not elegant. What should I change?