Can I re-use a docoration's DOM to create a node?

I’m playing with your image upload example and the problem that I have with it is that in order to add the uploaded image to the document, I have to remove the decoration first. That may cause a layout shift because I’m removing an img tag (my decoration) and adding another img tag (node), which is not good for UX.

Can I somehow convert a widget decoration to a node without removing anything from the DOM? I mean, I want to re-use the decorations’ DOM (which is an img tag with a data-url as its src) for the new node and only change some of its attributes.

Why not, though?

No, reusing an element from a decoration for a node is not general possible.

Thanks for the response.

Well, I think we can agree that this is not good (the placeholder is an image that uses the data-url version of the uploaded image as its src + it’s blurred): 2022-06-19 21-07-41

I had implemented the same feature with tiptap using NodeView which wasn’t causing a layout shift: 2022-06-19 21-10-44

But I had problems with it so I decided to try decorations. another failure…