From b227b528d53dd643ec6678b57a9d72d69bd94edf Mon Sep 17 00:00:00 2001
From: chris <kokosias@yahoo.gr>
Date: Thu, 12 Dec 2019 16:53:42 +0200
Subject: [PATCH] rules service in progress

---
 editors/editoria/src/EditorConfig.js                  |  5 +----
 editors/editoria/src/Editoria.js                      |  4 ++--
 editors/editoria/src/config/{menu.js => config.js}    |  7 +++++++
 editors/editoria/src/config/index.js                  |  2 +-
 wax-prosemirror-core/src/Wax.js                       |  7 -------
 .../src/RulesService/RulesService.js                  | 11 +++++++++--
 6 files changed, 20 insertions(+), 16 deletions(-)
 rename editors/editoria/src/config/{menu.js => config.js} (65%)

diff --git a/editors/editoria/src/EditorConfig.js b/editors/editoria/src/EditorConfig.js
index 249b80c59..9814b90e9 100644
--- a/editors/editoria/src/EditorConfig.js
+++ b/editors/editoria/src/EditorConfig.js
@@ -18,8 +18,6 @@ import {
   sinkListItem
 } from "prosemirror-schema-list";
 
-import { emDash, ellipsis } from "prosemirror-inputrules";
-
 import invisibles, {
   space,
   hardBreak,
@@ -102,6 +100,5 @@ const plugins = [
 const services = [new LinkService()];
 
 // Add Rules
-const rules = [emDash, ellipsis];
 
-export { schema, keys, plugins, rules, services };
+export { schema, keys, plugins, services };
diff --git a/editors/editoria/src/Editoria.js b/editors/editoria/src/Editoria.js
index c2f30f2cf..9c082a3e2 100644
--- a/editors/editoria/src/Editoria.js
+++ b/editors/editoria/src/Editoria.js
@@ -4,7 +4,7 @@ import { EditoriaLayout } from "wax-prosemirror-layouts";
 import { Wax } from "wax-prosemirror-core";
 
 import { schema, keys, plugins, rules, services } from "./EditorConfig";
-import { menu } from "./config";
+import { config } from "./config";
 
 import text from "./text";
 
@@ -53,7 +53,7 @@ const Editoria = () => (
   <Fragment>
     <GlobalStyle />
     <StyledWax
-      config={menu}
+      config={config}
       options={options}
       autoFocus
       placeholder="Type Something..."
diff --git a/editors/editoria/src/config/menu.js b/editors/editoria/src/config/config.js
similarity index 65%
rename from editors/editoria/src/config/menu.js
rename to editors/editoria/src/config/config.js
index b7ec904af..82fb3775f 100644
--- a/editors/editoria/src/config/menu.js
+++ b/editors/editoria/src/config/config.js
@@ -1,3 +1,5 @@
+import { emDash, ellipsis } from "prosemirror-inputrules";
+
 export default {
   MenuService: [
     {
@@ -8,5 +10,10 @@ export default {
       templateArea: "leftSideBar",
       toolGroups: ["TextStyle"]
     }
+  ],
+  RulesService: [
+    {
+      rules: [emDash, ellipsis]
+    }
   ]
 };
diff --git a/editors/editoria/src/config/index.js b/editors/editoria/src/config/index.js
index bf58df0f4..7f7956eb2 100644
--- a/editors/editoria/src/config/index.js
+++ b/editors/editoria/src/config/index.js
@@ -1 +1 @@
-export { default as menu } from "./menu";
+export { default as config } from "./config";
diff --git a/wax-prosemirror-core/src/Wax.js b/wax-prosemirror-core/src/Wax.js
index be5472eca..458970657 100644
--- a/wax-prosemirror-core/src/Wax.js
+++ b/wax-prosemirror-core/src/Wax.js
@@ -57,17 +57,10 @@ class Wax extends Component {
     //   ? keys
     //   : new CreateShortCuts({ schema: schema, shortCuts: {} });
 
-    // const WaxRules = new CreateRules({ schema: schema, rules: rules });
-
     const editorContent = value ? value : "";
 
     if (plugins) defaultPlugins.push(...plugins);
 
-    // const finalPlugins = defaultPlugins.concat([
-    //   placeholder({ content: this.props.placeholder }),
-    //   WaxShortCuts,
-    //   WaxRules
-    // ]);
     const finalPlugins = defaultPlugins.concat([
       placeholder({ content: this.props.placeholder }),
       ...this.application.getPlugins()
diff --git a/wax-prosemirror-plugins/src/RulesService/RulesService.js b/wax-prosemirror-plugins/src/RulesService/RulesService.js
index 5544a31ca..8d66b1d5c 100644
--- a/wax-prosemirror-plugins/src/RulesService/RulesService.js
+++ b/wax-prosemirror-plugins/src/RulesService/RulesService.js
@@ -1,8 +1,15 @@
 import Service from "wax-prosemirror-core/src/services/Service";
+import Rules from "./Rules";
 
 export default class RulesService extends Service {
   name = "RulesService";
-  boot() {
-    console.log("boot");
+
+  boot() {}
+
+  register() {
+    this.container.bind("Rules").toFactory(context => {
+      return new Rules(this.config[0]);
+    });
+    this.container.get("Rules");
   }
 }
-- 
GitLab