From 7274886d76e67c4b24b09e3e862214b546f633f3 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Thu, 11 Jul 2019 22:43:18 +0000 Subject: [PATCH] Add undo/redo keys --- Editor.js | 12 ++++++++++++ EditorHelp.js | 10 ++++++++++ EditorLabel.js | 2 +- EditorNode.js | 2 +- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Editor.js b/Editor.js index a8fda1d..3dc952a 100644 --- a/Editor.js +++ b/Editor.js @@ -194,6 +194,18 @@ class Editor extends List { } return; + case 'u': + history.back(); + e.stopPropagation(); + e.preventDefault(); + return; + + case 'U': + history.forward(); + e.stopPropagation(); + e.preventDefault(); + return; + case '?': if (this.addHelpAfter()) { e.stopPropagation(); diff --git a/EditorHelp.js b/EditorHelp.js index f3e3ea5..561f105 100644 --- a/EditorHelp.js +++ b/EditorHelp.js @@ -53,6 +53,16 @@ class EditorHelp extends EditorEntryBase { this.addLine(); this.addKey('f'); this.addText('Flip link '); + + this.addLine(); + this.addKey('u'); + this.addText('Undo '); + + this.addLine(); + this.addKey('⇧'); + this.addText('+'); + this.addKey('u'); + this.addText('Redo '); } addLine() { diff --git a/EditorLabel.js b/EditorLabel.js index a5f54fd..bb0a376 100644 --- a/EditorLabel.js +++ b/EditorLabel.js @@ -13,7 +13,7 @@ class EditorLabel extends EditorEntryBase { this.listen(this.input_, 'blur', (e) => this.onBlur(e)); this.elem_.appendChild(this.input_); - this.lastSnapshotLabel_ = null; + this.lastSnapshotLabel_ = ''; } afterDomAdd() { diff --git a/EditorNode.js b/EditorNode.js index 748ca23..5d20ac4 100644 --- a/EditorNode.js +++ b/EditorNode.js @@ -12,7 +12,7 @@ class EditorNode extends EditorEntryBase { this.listen(this.input_, 'blur', (e) => this.onBlur(e)); this.elem_.appendChild(this.input_); - this.lastSnapshotLabel_ = null; + this.lastSnapshotLabel_ = ''; if (label) { this.setLabel(label);