Do you have any idea how I could do that?
Nope. Nothing easy and portable comes to mind.
Writing myself routines for proper selection handling, mixing it with dnd, ensuring that it works smoothly and doesn’t break browser behaviours, is imho big time overkill. Would rather prefer to use something ready and maintained.