I added header and tail decorations (widget type) to the specific Mark in the custom plug-in,
But because of the special effects of decoration, it doesn’t take up the content,It makes my cursor look weird
The effect I want to achieve is to add a decoration to the top of the Mark. Removing one of the decorations will clear the current Mark. The decoration can be clicked (click effect), and the decoration can be treated as a Node like Node
Your question is pretty confusing. If you could make a minimal reproduction of the problem, on something like code sandbox, we’d better understand the issue.
It will be called whenever the selection changes, and it mutates the DOM.
Where did you get the idea to do this? And why do you want to do this on a deferred schedule?
Does the same problem happen when you remove it?
As for other suggestions, I’d try extracting out that logic for building decorations and only re-running when state.doc changes. (See here for a minimal example of storing decorations in state: ProseMirror lint example)
I tried doing this a few different ways, and I think the best way to do it is to have two atom nodes (leftBracket, and rightBracket) and manage adding and removing those manually when a mark gets added to a slice of the paragraph or removed, or one of the brackets gets removed.
Thank you very much, but I don’t know much about the implementation details. For example, appendTransaction I don’t know how to use it. I wrote a bunch of code myself, I don’t know if it’s my thinking or something.
I couldn’t implement it on my own, I didn’t go back and forth with appendTransaction, I didn’t know how to tell if it was new, I didn’t have any ideas, I read a lot of articles and didn’t find out how to use it.
Decoration is only a rendering effect, it does not exist in the model. If you want to achieve this effect, you need to wrap the text with 2 nodes.(likes @moonrise-tk said)