how do I use several MatchDecorator at the same time


I use the MatchDecorator to replace some text if match the RegExp
now I want to use several MatchDecorator with diffenrent RegExp and diffenrent Wiget
I don’t want to create several MatchDecorator and ViewPlugin, Is there any other way?

Why not? You can have one view plugin provide multiple decoration sets if you really need to, but a given match decorator matches a single regexp.

Can you show the key point code ,i did’t find any example that one ViewPlugin with several decoration ,thanks very much

Use the provide option to provide several instances of the EditorView.decorations facet.


you mean like this?
but the customDecorator1 will not work

No, not like that—you’re returning the decorations as a value for atomicRanges. You want to return an array from provide, containing both the atomic ranges facet value and another, similar facet value for EditorView.decorations.


my code look like this,the customDecorator will work but the customDecorator1 still not work, what did I missed,by the way is there any example, thanks a lot

You’re not using it at all in the plugin, so it seems obvious that it won’t have any effect. Also, you don’t need to provide the same decoration set (this.decorations) twice, once through decorations and once through provide—that’ll just duplicate the decorations.


I refactor flow your suggest, but now two decorator will not work, what happend,please check, thanks a lot!