Skip to main content
added 2 characters in body
Source Link
AndyS
  • 111
  • 3

This is the undo.js module - basically four methods - done to record the custom undo/redo callbacks, undo and redo to alcall them and reset to remove all undos/redos (e.g. after loading a new file):

This is the undo.js module - basically four methods - done to record the custom undo/redo callbacks, undo and redo to al them and reset to remove all undos/redos (e.g. after loading a new file):

This is the undo.js module - basically four methods - done to record the custom undo/redo callbacks, undo and redo to call them and reset to remove all undos/redos (e.g. after loading a new file):

fixed typo
Source Link
AndyS
  • 111
  • 3

I've added a delete example - which in my case removes a block - this also needneeds 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

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

I've added a delete example - which in my case removes a block - this also needs 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

Added another (delete) example in response to comment.
Source Link
AndyS
  • 111
  • 3

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.

I hope this helps.

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.

Source Link
AndyS
  • 111
  • 3
Loading