From 713c56bd1d3975ae00dcb95545b1eda280f62959 Mon Sep 17 00:00:00 2001
From: chris <kokosias@yahoo.gr>
Date: Wed, 5 Feb 2020 17:49:07 +0200
Subject: [PATCH] remove unused service and cleanup WaxView

---
 editors/editoria/src/config/config.js |  8 ++---
 wax-prosemirror-core/src/WaxView.js   | 45 +++++++++++++++++----------
 2 files changed, 30 insertions(+), 23 deletions(-)

diff --git a/editors/editoria/src/config/config.js b/editors/editoria/src/config/config.js
index 5d1065cec..79d766a1a 100644
--- a/editors/editoria/src/config/config.js
+++ b/editors/editoria/src/config/config.js
@@ -44,12 +44,8 @@ export default {
 
   ShortCutsService: {},
 
-  PmPlugins: [
-    columnResizing(),
-    tableEditing(),
-    // TrackChangePlugin({ options: {} }),
-    invisibles([hardBreak()])
-  ],
+  PmPlugins: [columnResizing(), tableEditing(), invisibles([hardBreak()])],
+
   services: [
     new PlaceholderService(),
     new ImageService(),
diff --git a/wax-prosemirror-core/src/WaxView.js b/wax-prosemirror-core/src/WaxView.js
index 667bf8c54..e82f5b24e 100644
--- a/wax-prosemirror-core/src/WaxView.js
+++ b/wax-prosemirror-core/src/WaxView.js
@@ -15,30 +15,28 @@ import { trackedTransaction } from "wax-prosemirror-services";
 import { WaxContext } from "./ioc-react";
 
 export default props => {
-  const { readonly, onBlur, options, debug, autoFocus, user } = props;
-  const editorRef = useRef();
+  const {
+    readonly,
+    onBlur,
+    options,
+    debug,
+    autoFocus,
+    TrackChange,
+    user
+  } = props;
 
+  const editorRef = useRef();
+  let view;
   const context = useContext(WaxContext);
 
   useEffect(() => {
-    const view = new EditorView(
+    view = new EditorView(
       { mount: editorRef.current },
       {
         editable: () => !readonly,
         state: EditorState.create(options),
-        dispatchTransaction: transaction => {
-          const { TrackChange } = props;
-          const tr = TrackChange
-            ? trackedTransaction(transaction, view.state, user)
-            : transaction;
-
-          const state = view.state.apply(tr);
-          view.updateState(state);
-          context.updateView({ main: view });
-
-          props.onChange(state.doc.content);
-        },
-        handleDOMEvents: {
+        dispatchTransaction,
+        leDOMEvents: {
           blur: onBlur
             ? view => {
                 onBlur(view.state.doc.content);
@@ -48,11 +46,24 @@ export default props => {
       }
     );
     context.updateView({ main: view });
-
+    console.log("test");
     if (debug) applyDevTools(view);
     if (autoFocus) view.focus();
   }, []);
 
+  const dispatchTransaction = transaction => {
+    const { TrackChange } = props;
+    const tr = TrackChange
+      ? trackedTransaction(transaction, view.state, user)
+      : transaction;
+
+    const state = view.state.apply(tr);
+    view.updateState(state);
+    context.updateView({ main: view });
+
+    props.onChange(state.doc.content);
+  };
+
   const editor = <div ref={editorRef} />;
   return props.children({
     editor
-- 
GitLab