You’ll probably want to define another state effect that removes decorations, and check for that as well in your loop over transaction.effects, calling value.update with a filter option that removes the appropriate range.
I am also trying to understand how this is done. I adapted the code from Decorations, which works well to apply styling to a custom range. But I am having trouble removing the styling when I am done with it. Is something like this what you had in mind with regard to applying a filter update?
That code puts a from and to in the removeStyling effect but then ignores them and removes all decorations from the set (since from what I can see they will all be using styleMark. Are you trying to clear it? In which case you can just set it to Decoration.none. Or are you trying to clear a specific range? If so, you’ll want to actually compare the ranges to the from and to values in the effect.
I do want to clear a specific range ideally. Though I am not sure how to store the range of the original effect that was used to set the style in the first place. To be clear, I am not seeking to undo the last transaction, but merely capture the range of the last transaction and remove its styling. Can I store the range in the EditorState and retrieve it later?
You can, if you define a StateField for it. But you can also iterate over the ranges in the set, if you can somehow recognize the proper one. I still have no idea what you are trying to implement so I can’t say a lot about this.
I think I figured it out. I just misunderstood the documentation. Sorry to be a bother. Basically, I was just trying to implement a styled inline suggestion that could be confirmed or rejected.