How do I add data attributes to a node without changing it's tag (div, p, span)?)

I am pretty new to the prose-mirror. How can I add data attributes to selected nodes without chaning anything in that node. just add data attributes?

setNodeAttribute is the method you want. Read the guide section on transforms to understand fully what it does.