From 135e8323071f1deaefe8cac974d38c38a67b0699 Mon Sep 17 00:00:00 2001
From: chris <kokosias@yahoo.gr>
Date: Fri, 24 Feb 2023 13:13:37 +0200
Subject: [PATCH] move plugin to core

---
 wax-prosemirror-core/src/WaxView.js            | 18 ------------------
 .../src}/plugins/FakeCursorPlugin.js           | 15 +++++++++++++--
 .../src/plugins/defaultPlugins.js              |  3 ++-
 wax-prosemirror-core/src/styles/styles.css     |  7 ++++++-
 .../src/TablesService/TablesService.js         |  7 -------
 .../src/TablesService/table.css                |  5 -----
 6 files changed, 21 insertions(+), 34 deletions(-)
 rename {wax-prosemirror-services/src/TablesService => wax-prosemirror-core/src}/plugins/FakeCursorPlugin.js (66%)

diff --git a/wax-prosemirror-core/src/WaxView.js b/wax-prosemirror-core/src/WaxView.js
index f5998e3ec..48d986259 100644
--- a/wax-prosemirror-core/src/WaxView.js
+++ b/wax-prosemirror-core/src/WaxView.js
@@ -84,24 +84,6 @@ const WaxView = forwardRef((props, ref) => {
             attributes: {
               spellcheck: browserSpellCheck ? 'true' : 'false',
             },
-            handleDOMEvents: {
-              blur: (editorView, event) => {
-                if (view && event.relatedTarget === null) {
-                  view.focus();
-                } else {
-                  const fakeCursor = document.getElementsByTagName(
-                    'fakecursor',
-                  );
-                  if (fakeCursor && fakeCursor[0])
-                    fakeCursor[0].style.display = 'inline';
-                }
-              },
-              focus: (editorView, event) => {
-                const fakeCursor = document.getElementsByTagName('fakecursor');
-                if (fakeCursor && fakeCursor[0])
-                  fakeCursor[0].style.display = 'none';
-              },
-            },
           },
         );
 
diff --git a/wax-prosemirror-services/src/TablesService/plugins/FakeCursorPlugin.js b/wax-prosemirror-core/src/plugins/FakeCursorPlugin.js
similarity index 66%
rename from wax-prosemirror-services/src/TablesService/plugins/FakeCursorPlugin.js
rename to wax-prosemirror-core/src/plugins/FakeCursorPlugin.js
index e6770b617..607ab2c58 100644
--- a/wax-prosemirror-services/src/TablesService/plugins/FakeCursorPlugin.js
+++ b/wax-prosemirror-core/src/plugins/FakeCursorPlugin.js
@@ -31,8 +31,19 @@ export default props => {
           return fakeCursorPluginState.createDecoration;
       },
       handleDOMEvents: {
-        focus: (view, _event) => {},
-        blur: (view, _event) => {},
+        focus: (view, event) => {
+          const fakeCursor = document.getElementsByTagName('fakecursor');
+          if (fakeCursor && fakeCursor[0]) fakeCursor[0].style.display = 'none';
+        },
+        blur: (view, event) => {
+          if (view && event.relatedTarget === null) {
+            view.focus();
+          } else {
+            const fakeCursor = document.getElementsByTagName('fakecursor');
+            if (fakeCursor && fakeCursor[0])
+              fakeCursor[0].style.display = 'inline';
+          }
+        },
       },
     },
   });
diff --git a/wax-prosemirror-core/src/plugins/defaultPlugins.js b/wax-prosemirror-core/src/plugins/defaultPlugins.js
index 88158c86b..eb6227920 100644
--- a/wax-prosemirror-core/src/plugins/defaultPlugins.js
+++ b/wax-prosemirror-core/src/plugins/defaultPlugins.js
@@ -1,5 +1,6 @@
 import { history } from 'prosemirror-history';
 import { dropCursor } from 'prosemirror-dropcursor';
 import { gapCursor } from 'prosemirror-gapcursor';
+import FakeCursorPlugin from './FakeCursorPlugin';
 
-export default [dropCursor(), gapCursor(), history()];
+export default [dropCursor(), gapCursor(), history(), FakeCursorPlugin()];
diff --git a/wax-prosemirror-core/src/styles/styles.css b/wax-prosemirror-core/src/styles/styles.css
index 670f3b37c..a36bcdc70 100644
--- a/wax-prosemirror-core/src/styles/styles.css
+++ b/wax-prosemirror-core/src/styles/styles.css
@@ -225,4 +225,9 @@ img.ProseMirror-separator {
  .ProseMirror *::selection{
    background-color: #C5D7FE;
   color: #000;
-}
\ No newline at end of file
+}
+
+fakecursor {
+   border-right: 1px solid black;
+   display: none;
+  }
\ No newline at end of file
diff --git a/wax-prosemirror-services/src/TablesService/TablesService.js b/wax-prosemirror-services/src/TablesService/TablesService.js
index 0d2656054..84f3d0207 100644
--- a/wax-prosemirror-services/src/TablesService/TablesService.js
+++ b/wax-prosemirror-services/src/TablesService/TablesService.js
@@ -1,15 +1,8 @@
 import { Service } from 'wax-prosemirror-core';
 import TablesServices from './index';
-import FakeCursorPlugin from './plugins/FakeCursorPlugin';
 import './table.css';
 
 class TablesService extends Service {
-  boot() {
-    this.app.PmPlugins.add(
-      'fakeCursorPlugin',
-      FakeCursorPlugin('fakeCursorPlugin'),
-    );
-  }
   dependencies = TablesServices;
 }
 
diff --git a/wax-prosemirror-services/src/TablesService/table.css b/wax-prosemirror-services/src/TablesService/table.css
index e5a5cef6d..1737e4ac5 100644
--- a/wax-prosemirror-services/src/TablesService/table.css
+++ b/wax-prosemirror-services/src/TablesService/table.css
@@ -52,9 +52,4 @@
     right: 0;
     top: 0;
     z-index: 2;
-  }
-
-  fakecursor {
-    border-right: 1px solid black;
-    display: none;
   }
\ No newline at end of file
-- 
GitLab