From d3367834d0b2bbec83395059f7cf4804579dd89d Mon Sep 17 00:00:00 2001 From: Aaron Raimist Date: Fri, 21 Feb 2020 21:53:51 -0600 Subject: [PATCH 1/4] Fix redo keyboard shortcut on macOS I added the correct macOS shortcut for redo which is Cmd+Shift+Z. I had to reorder the if statement so redo is checked first, otherwise it would detect the undo first and never check that I was actually trying to redo. Signed-off-by: Aaron Raimist --- .../views/rooms/BasicMessageComposer.js | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/components/views/rooms/BasicMessageComposer.js b/src/components/views/rooms/BasicMessageComposer.js index a2a01f4444..2b0f9a7554 100644 --- a/src/components/views/rooms/BasicMessageComposer.js +++ b/src/components/views/rooms/BasicMessageComposer.js @@ -370,6 +370,17 @@ export default class BasicMessageEditor extends React.Component { } else if (modKey && event.key === Key.GREATER_THAN) { this._onFormatAction("quote"); handled = true; + // redo + } else if ((modKey && event.key === Key.Y) || + (IS_MAC && event.shiftKey && event.key === Key.Z)) { + debugger; + if (this.historyManager.canRedo()) { + const {parts, caret} = this.historyManager.redo(); + // pass matching inputType so historyManager doesn't push echo + // when invoked from rerender callback. + model.reset(parts, caret, "historyRedo"); + } + handled = true; // undo } else if (modKey && event.key === Key.Z) { if (this.historyManager.canUndo()) { @@ -379,15 +390,6 @@ export default class BasicMessageEditor extends React.Component { model.reset(parts, caret, "historyUndo"); } handled = true; - // redo - } else if (modKey && event.key === Key.Y) { - if (this.historyManager.canRedo()) { - const {parts, caret} = this.historyManager.redo(); - // pass matching inputType so historyManager doesn't push echo - // when invoked from rerender callback. - model.reset(parts, caret, "historyRedo"); - } - handled = true; // insert newline on Shift+Enter } else if (event.key === Key.ENTER && (event.shiftKey || (IS_MAC && event.altKey))) { this._insertText("\n"); From 42c6818f952af0dbb159eb56d41dc621d6ca5e67 Mon Sep 17 00:00:00 2001 From: Aaron Raimist Date: Fri, 21 Feb 2020 21:59:43 -0600 Subject: [PATCH 2/4] Remove debugger; Signed-off-by: Aaron Raimist --- src/components/views/rooms/BasicMessageComposer.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/views/rooms/BasicMessageComposer.js b/src/components/views/rooms/BasicMessageComposer.js index 2b0f9a7554..dd6addd062 100644 --- a/src/components/views/rooms/BasicMessageComposer.js +++ b/src/components/views/rooms/BasicMessageComposer.js @@ -373,7 +373,6 @@ export default class BasicMessageEditor extends React.Component { // redo } else if ((modKey && event.key === Key.Y) || (IS_MAC && event.shiftKey && event.key === Key.Z)) { - debugger; if (this.historyManager.canRedo()) { const {parts, caret} = this.historyManager.redo(); // pass matching inputType so historyManager doesn't push echo From 550ee216c64bace5a4b728e77a705d745a5e9cc1 Mon Sep 17 00:00:00 2001 From: Aaron Raimist Date: Mon, 24 Feb 2020 18:22:07 -0600 Subject: [PATCH 3/4] Apply suggestions from code review Co-Authored-By: David Baker --- src/components/views/rooms/BasicMessageComposer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/views/rooms/BasicMessageComposer.js b/src/components/views/rooms/BasicMessageComposer.js index dd6addd062..52947aa6e2 100644 --- a/src/components/views/rooms/BasicMessageComposer.js +++ b/src/components/views/rooms/BasicMessageComposer.js @@ -371,8 +371,8 @@ export default class BasicMessageEditor extends React.Component { this._onFormatAction("quote"); handled = true; // redo - } else if ((modKey && event.key === Key.Y) || - (IS_MAC && event.shiftKey && event.key === Key.Z)) { + } else if ((!IS_MAC && modKey && event.key === Key.Y) || + (IS_MAC && modkey && event.shiftKey && event.key === Key.Z)) { if (this.historyManager.canRedo()) { const {parts, caret} = this.historyManager.redo(); // pass matching inputType so historyManager doesn't push echo From 84a8ca69828a5934e5ea077c86d83b8e0e4806e9 Mon Sep 17 00:00:00 2001 From: Aaron Raimist Date: Tue, 17 Mar 2020 13:18:22 -0500 Subject: [PATCH 4/4] Fix typo Signed-off-by: Aaron Raimist --- src/components/views/rooms/BasicMessageComposer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/rooms/BasicMessageComposer.js b/src/components/views/rooms/BasicMessageComposer.js index 52947aa6e2..3c5c698f51 100644 --- a/src/components/views/rooms/BasicMessageComposer.js +++ b/src/components/views/rooms/BasicMessageComposer.js @@ -372,7 +372,7 @@ export default class BasicMessageEditor extends React.Component { handled = true; // redo } else if ((!IS_MAC && modKey && event.key === Key.Y) || - (IS_MAC && modkey && event.shiftKey && event.key === Key.Z)) { + (IS_MAC && modKey && event.shiftKey && event.key === Key.Z)) { if (this.historyManager.canRedo()) { const {parts, caret} = this.historyManager.redo(); // pass matching inputType so historyManager doesn't push echo