I don’t think that setNodeType solve the problem in this case.
I tried:
let {from, to, $from, $to} = state.selection
let tr=state.tr;
state.doc.nodesBetween(from, to, (node, pos, parent, index) => {
if (node.type == schema.nodes.align) {
tr=tr.setNodeType(pos, schema.nodes.align, { alignment: alignment })
} else {
tr = wrapTr(tr, state.doc.resolve(pos), state.doc.resolve(pos+node.nodeSize), schema.nodes.align, { alignment: alignment})
}
return false;
})
But this does not behave well when aligning a centered/righted block to the left.
The issue is that when aligning to the left (for example a centered block), I have to remove the alignment - that is lift
(using the code above, to left align a centered block, all lines in it will now behave as one block, for example centering one of those lines will center all of them)
I’m stuck here, any ideas welcomed …
thx!