Coming from 0.10, we had the markRange API that took a “onRemove” option to handle the case where the user delete the range while typing.
The 0.12 introduced Decorations as a replacement, but I couldn’t find a straightforward way to reproduce this feature.
I understand that the way to update the decorations while the user is typing is something like :
newDecorations = prev.decorations.map(action.transform.mapping, action.transform.doc);
Which will drop decorations that are no longer in use, but won’t be verbose about it.
Is there any canonical way to track for removed decorations ?
This feature was dropped, at least in the initial version of decorations. What were you using it for, precisely? Would being able to pass a callback to
We maintain a list of user annotations (see In v0.12 what's the right for "user annotation" use case? ) along with the document.
When the annotation is removed while typing, we don’t just drop it entirely but we keep it as “resolved”.
Any mean to know which decoration is removed would be ok : a callback or a MapResult object.
I’ve implemented a callback that you can pass to
map. It only passes the decoration’s options object, since the start/end positions aren’t always in a sane state when the code decides to drop a given decoration. Does that work for you? The idea would be to store an ID or something similar in the options, and inspect that when the decoration is dropped.
That’s awesome, thanks, I’ll test this today.