From 2a27c25ac1a1f48e7ede8bf388d2d823905b4994 Mon Sep 17 00:00:00 2001
From: chris <kokosias@yahoo.gr>
Date: Fri, 16 Apr 2021 13:27:53 +0300
Subject: [PATCH] fix unmounting editor

---
 editors/demo/src/Editors.js            | 2 +-
 editors/demo/src/HHMI/config/config.js | 8 --------
 wax-prosemirror-core/src/Wax.js        | 7 +++----
 wax-prosemirror-core/src/WaxView.js    | 4 ++++
 4 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/editors/demo/src/Editors.js b/editors/demo/src/Editors.js
index dac341434..774b1d788 100644
--- a/editors/demo/src/Editors.js
+++ b/editors/demo/src/Editors.js
@@ -48,7 +48,7 @@ const Editors = () => {
       case 'ncbi':
         break;
       default:
-        return <Editoria />;
+        return <HHMI />;
     }
   };
 
diff --git a/editors/demo/src/HHMI/config/config.js b/editors/demo/src/HHMI/config/config.js
index d0e0640f5..15b33a9e8 100644
--- a/editors/demo/src/HHMI/config/config.js
+++ b/editors/demo/src/HHMI/config/config.js
@@ -13,10 +13,6 @@ import {
   TableToolGroupService,
   BaseService,
   BaseToolGroupService,
-  DisplayBlockLevelService,
-  DisplayToolGroupService,
-  TextBlockLevelService,
-  TextToolGroupService,
   DisplayTextToolGroupService,
   MathService,
   FullScreenService,
@@ -87,10 +83,6 @@ export default {
   services: [
     new MultipleChoiceQuestionService(),
     new QuestionsToolGroupService(),
-    new DisplayBlockLevelService(),
-    new DisplayToolGroupService(),
-    new TextBlockLevelService(),
-    new TextToolGroupService(),
     new ListsService(),
     new LinkService(),
     new InlineAnnotationsService(),
diff --git a/wax-prosemirror-core/src/Wax.js b/wax-prosemirror-core/src/Wax.js
index 0299c3f0f..fb4449b8c 100644
--- a/wax-prosemirror-core/src/Wax.js
+++ b/wax-prosemirror-core/src/Wax.js
@@ -53,8 +53,7 @@ const Wax = props => {
 
   const finalOnChange = schema =>
     debounce(
-      // eslint-disable-next-line no-shadow
-      value => {
+      content => {
         /* HACK  alter toDOM of footnote, because of how PM treats inline nodes
       with content */
         if (schema.nodes.footnote) {
@@ -67,10 +66,10 @@ const Wax = props => {
         }
 
         if (targetFormat === 'JSON') {
-          WaxOnchange(value);
+          WaxOnchange(content);
         } else {
           const serialize = serializer(schema);
-          WaxOnchange(serialize(value));
+          WaxOnchange(serialize(content));
         }
         if (schema.nodes.footnote) {
           const old = schema.nodes.footnote.spec.toDOM;
diff --git a/wax-prosemirror-core/src/WaxView.js b/wax-prosemirror-core/src/WaxView.js
index 7b417d092..e6faf536c 100644
--- a/wax-prosemirror-core/src/WaxView.js
+++ b/wax-prosemirror-core/src/WaxView.js
@@ -97,6 +97,10 @@ export default props => {
     [readonly],
   );
 
+  useEffect(() => {
+    return () => (view = null);
+  }, []);
+
   const dispatchTransaction = transaction => {
     const { TrackChange } = props;
     const tr =
-- 
GitLab