Is there a way to apply decorations directly through an editor method?
For example, let’s say my application knows that it wants to make everything from position 123 to position 456 purple. Assuming the EditorView object is called “editor,” what I’d really like to do is something as simple as:
editor.applyDecoration(Decoration.inline(123, 456, {style: "color: purple"})
Is there any way to do it as simple as that? If not, what’s the simplest way to go about it?
(Apologies if this is a basic question. From the documentation on decorations, I can see how to set them relative to things already in ProseMirror’s state, such as the current selection, but I couldn’t find any simple example of how to invoke them on the fly based on business logic sitting outside of ProseMirror.)
EDIT: I wrote an example plugin + helper method to enact the behavior I describe here, code is below.