I've added a delete example - which in my case removes a block - this also need to keep a reference to the original block (object) for undo (and redo). This is bit more complex and has some specifics for my visual editor
function removeBlock(elem, parent_node, next_sibling) {
let id = elem.dataset.quandoId
let option_parents = []
if (id) { // Store any references to this option - for undo
option_parents = _get_parent_options(id)
_populateLists()
}
elem.classList.remove("gu-hide") // To reveal the element if undone later
let _undo = () => {
parent_node.insertBefore(elem, next_sibling)
_populateLists()
_restore_options(id, option_parents)
}
let _redo = () => {
parent_node.removeChild(elem)
_populateLists()
}
undo.done(_undo, _redo, "Delete Block")
}
I hope this helps.