From 7f93d584dbd356f61c39cfe6c95647e4df003948 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Sat, 12 Dec 2020 19:22:46 -0500
Subject: fixed hitting Esc in text to turn off text options in menu

---
 .../views/nodes/formattedText/FormattedTextBox.tsx | 25 +++++++++++-----------
 1 file changed, 13 insertions(+), 12 deletions(-)

(limited to 'src/client/views/nodes/formattedText/FormattedTextBox.tsx')

diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
index 4be49ca47..0beea2bcd 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
@@ -1530,24 +1530,25 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp
         if (state.selection.empty || !this._rules!.EnteringStyle) {
             this._rules!.EnteringStyle = false;
         }
+        e.stopPropagation();
         if (e.key === "Escape") {
             this._editorView!.dispatch(state.tr.setSelection(TextSelection.create(state.doc, state.selection.from, state.selection.from)));
             (document.activeElement as any).blur?.();
             SelectionManager.DeselectAll();
-        }
-        e.stopPropagation();
-        if (e.key === "Tab" || e.key === "Enter") {
-            if (e.key === "Enter" && this.layoutDoc._timeStampOnEnter) {
-                this.insertTime();
+            RichTextMenu.Instance.updateMenu(undefined, undefined, undefined);
+        } else {
+            if (e.key === "Tab" || e.key === "Enter") {
+                if (e.key === "Enter" && this.layoutDoc._timeStampOnEnter) {
+                    this.insertTime();
+                }
+                e.preventDefault();
             }
-            e.preventDefault();
-        }
-        if (e.key === " " || this._lastTimedMark?.attrs.userid !== Doc.CurrentUserEmail) {
-            const mark = schema.marks.user_mark.create({ userid: Doc.CurrentUserEmail, modified: Math.floor(Date.now() / 1000) });
-            this._editorView!.dispatch(this._editorView!.state.tr.removeStoredMark(schema.marks.user_mark.create({})).addStoredMark(mark));
+            if (e.key === " " || this._lastTimedMark?.attrs.userid !== Doc.CurrentUserEmail) {
+                const mark = schema.marks.user_mark.create({ userid: Doc.CurrentUserEmail, modified: Math.floor(Date.now() / 1000) });
+                this._editorView!.dispatch(this._editorView!.state.tr.removeStoredMark(schema.marks.user_mark.create({})).addStoredMark(mark));
+            }
+            this.startUndoTypingBatch();
         }
-
-        this.startUndoTypingBatch();
     }
 
     ondrop = (eve: React.DragEvent) => {
-- 
cgit v1.2.3-70-g09d2

