Mapping forward through decorations as well as apply new decorations

According to the documentation, whenever content is edited, old.map(tr.mapping, tr.doc); preserves decorations for existing content and it does.

In my case, I’m trying to both preserve existing decorations and as well as add decorations for newly created content and add it to my old decorations and return its mapping as below

In my plugin, inside apply method

old = old.add(tr.doc, newDecos)
return old.map(tr.mapping, tr.doc);

Issue with this is newly created decos dont have ‘proseMirror-widget’ class applied and thus dont render in the editor. This class is only applied to decoration widgets when I return as such return DecorationSet.create(tr.doc, newDecos)

Do we not have an option to both preserve and apply new decorations?

That seems unlikely. All decorations go through the same rendering logic that adds that class.

You do probably want to map before adding new decorations, assuming the new decorations are positioned in terms of positions in the new document.