From b7d02ec188ecf043300ed858fdb68148b3e52a71 Mon Sep 17 00:00:00 2001
From: Sam Wilkins <abdullah_ahmed@brown.edu>
Date: Tue, 9 Apr 2019 17:24:11 -0400
Subject: exploring in-editor undo-redo

---
 src/client/views/nodes/FormattedTextBox.tsx | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

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

diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx
index 512ad7d70..be534099c 100644
--- a/src/client/views/nodes/FormattedTextBox.tsx
+++ b/src/client/views/nodes/FormattedTextBox.tsx
@@ -15,6 +15,7 @@ import { Decoration, DecorationSet } from 'prosemirror-view'
 import { TooltipTextMenu } from "../../util/TooltipTextMenu"
 import { ContextMenu } from "../../views/ContextMenu";
 import { inpRules } from "../../util/RichTextRules";
+import { Schema } from "prosemirror-model";
 const { buildMenuItems } = require("prosemirror-example-setup");
 const { menuBar } = require("prosemirror-menu");
 
@@ -61,6 +62,12 @@ export class FormattedTextBox extends React.Component<FieldViewProps> {
         }
     }
 
+    undo = <S extends Schema = any>(state: EditorState<S>, dispatch?: (tr: Transaction<S>) => void): boolean => {
+        console.log(state);
+        console.log(dispatch);
+        return true;
+    }
+
     componentDidMount() {
         let state: EditorState;
         const config = {
@@ -68,7 +75,7 @@ export class FormattedTextBox extends React.Component<FieldViewProps> {
             inpRules, //these currently don't do anything, but could eventually be helpful
             plugins: [
                 history(),
-                keymap({ "Mod-z": undo, "Mod-y": redo }),
+                keymap({ "Mod-z": this.undo, "Mod-y": redo }),
                 keymap(baseKeymap),
                 this.tooltipMenuPlugin()
             ]
@@ -151,7 +158,7 @@ export class FormattedTextBox extends React.Component<FieldViewProps> {
         e.stopPropagation();
     }
 
-    tooltipMenuPlugin() {
+    tooltipMenuPlugin(): Plugin<any, any> {
         return new Plugin({
             view(_editorView) {
                 return new TooltipTextMenu(_editorView)
-- 
cgit v1.2.3-70-g09d2

