Handling user-drawn Image Annotations

Hello, I’m using Image Annotations with Dash

I’d like to handle to the user-drawn annotations with a callback, for example I’d like to automatically erase the previously drown object once a new object is drawn. The drown objects seems to be recorded as a shape, looking at the relayoutData event, but these shapes do not seem to be stored in the figure layout like normal shapes. If the user draws more annotations, these are appended to the ‘shapes’ extension of relayoutData. You can select them and move them, and when you do so, the object is accessed using the index of the relayoutData['shapes'] list, according to the order the user drew them. You can even delete them with the eraseshape button in the widget.

So these user-drawn shapes must be stored somewhere, but I cannot find where. Anybody knows where I can directly access them? How can I delete one with a callback for example? How does the ereseshape button do it?