Hey there,
I’m writing a plugin to add decorations to the bullet of listItem
in a list. It’s very basic, it’ll get the color
mark on the very first inline node it finds inside listItem
then adds a NodeDecoration
on the listItem
which sets the color of bullet through style
. Everything works on the init
part where I set the initial decoration.
I’ve followed the documentation guide for doing this, however I’m a little bit confused. In the Ref docs, I can see that AddMarkStep
and RemoveMarkStep
are supposed to expose from
and to
positions. I need them because in the apply
method of my plugin I intend to watch for changes in the marks to Add/Remove decorations on my bullet listItems
. The thing is however that we’re using TS and the types don’t really expose from
and to
from these two extended classes of Step
.
Check it out here:
I’ve tried watching these steps with step.getMap()
by doing so:
const currDoc = tr.docs[stepIndex + 1] || tr.doc
const currentStepMap = step.getMap()
currentStepMap.forEach((oldStart, oldEnd, newStart, newEnd) => {
// Walk through changed nodes
})
But I guess this would only work with steps that actually change ranges in the document and not MarkStep
s? So my question is if it’d be ok to directly access from
and to
from Step
or maybe I should be listening to mark changes differently?