I am not able to delete widget on Backspace.

I am adding a Widget using the code below. I have tried different options to delete the Widget, but none of them worked. I am looking for sample code to delete the Widget near the cursor.

CodeMirror Decoration Example

Widgets that don’t replace any content cannot be deleted with backspace—the editor is just tracking text, possibly with decoration. It doesn’t consider a widget decoration to be part of the document, and thus it’s not something you can backspace out without custom scripting.

do you have any custom scripting?