HTML supports the HTML Drag and Drop API (https://www.w3schools.com/html/html5_draganddrop.asp). SVG does not support the Drag and Drop API.
What options do I have to combine both so that a nested SVG in a HTML website can both receive and send Drag and Drop events from and to the outside HTML website it is living in?
- Faking DnD with mousedown, mousemove and mouseup may work for the actual dragging part, but the world outside the bested SVG will not be able to receive those actions as it only listens to DnD events like dragstart, dragend, etc.
- Manual triggering of dragstart is not really possible as instantiating a DataTransfer object manually is forbidden and will always be nulled due to security reasons.
- When clicking on an SVG element, "catching" that event and generating a dummy HTML element to receive the click in order to generate a native dragstart event might not work due to timing issues?
Any other ways to marry the HTML world to the SVG world? Are there other alternatives to the Drag and Drop API?
EDIT:
<svg xmlns="http://www.w3.org/2000/svg" version="2.0" viewBox="0 0 100 100">
<rect x="10" y="10" width="80" height="80" fill="green" draggable="true" ondragstart="alert('test')" />
</svg>
As suggested by @RobertLongson I tried the above code to make a simple rect draggable with the regular HTML 5 Drag and Drop events. There is no alert happening and no such event gets triggered in an up to date Chrome.