Implement Undo and Redo (#354)

* Implement undo and redo

* Create more save points and hook up menu entry

* Fix operation ordering

* Remove debug statement

* Fix folder changed order

* Don't store overlays in the history chain

* Keep selection
This commit is contained in:
TrueDoctor
2021-08-26 12:20:00 +02:00
committed by Keavon Chambers
parent 47fbb8d0fa
commit 0ccb181e2c
6 changed files with 133 additions and 38 deletions

View File

@@ -108,7 +108,7 @@ const menuEntries: MenuListEntries = [
children: [
[
{ label: "Undo", shortcut: ["Ctrl", "Z"], action: async () => (await wasm).undo() },
{ label: "Redo", shortcut: ["Ctrl", "⇧", "Z"] },
{ label: "Redo", shortcut: ["Ctrl", "⇧", "Z"], action: async () => (await wasm).redo() },
],
[
{ label: "Cut", shortcut: ["Ctrl", "X"] },

View File

@@ -212,6 +212,12 @@ pub fn undo() -> Result<(), JsValue> {
EDITOR_STATE.with(|editor| editor.borrow_mut().handle_message(DocumentMessage::Undo)).map_err(convert_error)
}
/// Redo history one step
#[wasm_bindgen]
pub fn redo() -> Result<(), JsValue> {
EDITOR_STATE.with(|editor| editor.borrow_mut().handle_message(DocumentMessage::Redo)).map_err(convert_error)
}
/// Select all layers
#[wasm_bindgen]
pub fn select_all_layers() -> Result<(), JsValue> {