From 6f7ba8f0a66c94fe5071ca96d7e2a7c4a0814a06 Mon Sep 17 00:00:00 2001
From: chris <kokosias@yahoo.gr>
Date: Thu, 26 Dec 2019 11:58:45 +0200
Subject: [PATCH] feat(tables): finsish tables toolgroup

---
 editors/editoria/src/config/config.js             |  1 +
 wax-prosemirror-core/src/config/defaultConfig.js  |  8 ++++++--
 wax-prosemirror-schema/src/editoria/nodes.js      |  2 +-
 wax-prosemirror-services/index.js                 | 15 ++++++++++++---
 .../EditTableService/EditTableService.js          |  2 +-
 .../EditTableService/TableDropDownOptions.js      |  4 ++--
 .../InsertTableService/InsertTableService.js      |  1 +
 .../src/TablesService/index.js                    |  4 ++++
 .../TableToolGroupService/TableGroupService.js    | 12 ------------
 .../TableToolGroupService.js                      |  4 ++--
 .../TableToolGroupService/{Table.js => Tables.js} | 12 +++++-------
 11 files changed, 35 insertions(+), 30 deletions(-)
 delete mode 100644 wax-prosemirror-services/src/WaxToolGroups/TableToolGroupService/TableGroupService.js
 rename wax-prosemirror-services/src/WaxToolGroups/TableToolGroupService/{Table.js => Tables.js} (56%)

diff --git a/editors/editoria/src/config/config.js b/editors/editoria/src/config/config.js
index 18946d5bf..cf386e1c9 100644
--- a/editors/editoria/src/config/config.js
+++ b/editors/editoria/src/config/config.js
@@ -13,6 +13,7 @@ export default {
       toolGroups: [
         "Annotations",
         "Lists",
+        "Tables",
         { name: "RedoUndo", exclude: ["Redo"] }
       ]
     },
diff --git a/wax-prosemirror-core/src/config/defaultConfig.js b/wax-prosemirror-core/src/config/defaultConfig.js
index 55d21c234..b37c05636 100644
--- a/wax-prosemirror-core/src/config/defaultConfig.js
+++ b/wax-prosemirror-core/src/config/defaultConfig.js
@@ -12,7 +12,9 @@ import {
   InlineAnnotationsService,
   LinkService,
   ListsService,
-  ListToolGroupService
+  ListToolGroupService,
+  TablesService,
+  TableToolGroupService
 } from "wax-prosemirror-services";
 
 export default {
@@ -30,6 +32,8 @@ export default {
     new ImageService(),
     new InlineAnnotationsService(),
     new LinkService(),
-    new ListsService()
+    new ListsService(),
+    new TableToolGroupService(),
+    new TablesService()
   ]
 };
diff --git a/wax-prosemirror-schema/src/editoria/nodes.js b/wax-prosemirror-schema/src/editoria/nodes.js
index 5e90ad55d..8caedf3c1 100644
--- a/wax-prosemirror-schema/src/editoria/nodes.js
+++ b/wax-prosemirror-schema/src/editoria/nodes.js
@@ -1,4 +1,4 @@
-import { tableNodes, columnResizing, tableEditing } from "prosemirror-tables";
+import { tableNodes } from "prosemirror-tables";
 import { parseFormatList, parseTracks, blockLevelToDOM } from "./helpers";
 const pDOM = ["p", 0],
   brDOM = ["br"],
diff --git a/wax-prosemirror-services/index.js b/wax-prosemirror-services/index.js
index e884c5d7c..59fda3828 100644
--- a/wax-prosemirror-services/index.js
+++ b/wax-prosemirror-services/index.js
@@ -1,5 +1,6 @@
-export { default as LinkService } from "./src/LinkService/LinkService";
 export { default as MenuService } from "./src/MenuService/MenuService";
+export { default as LinkService } from "./src/LinkService/LinkService";
+
 export {
   default as RedoUndoService
 } from "./src/RedoUndoService/RedoUndoService";
@@ -16,12 +17,17 @@ export { default as SchemaService } from "./src/SchemaService/SchemaService";
 export {
   default as ShortCutsService
 } from "./src/ShortCutsService/ShortCutsService";
+
+export { default as Tool } from "./src/lib/Tools";
+
+/*
+All Elements services
+*/
 export {
   default as InlineAnnotationsService
 } from "./src/InlineAnnotations/InlineAnnotationsService";
 export { default as ListsService } from "./src/ListsService/ListsService";
-
-export { default as Tool } from "./src/lib/Tools";
+export { default as TablesService } from "./src/TablesService/TablesService";
 
 /*
 ToolGroups
@@ -32,3 +38,6 @@ export {
 export {
   default as ListToolGroupService
 } from "./src/WaxToolGroups/ListToolGroupService/ListToolGroupService";
+export {
+  default as TableToolGroupService
+} from "./src/WaxToolGroups/TableToolGroupService/TableToolGroupService";
diff --git a/wax-prosemirror-services/src/TablesService/EditTableService/EditTableService.js b/wax-prosemirror-services/src/TablesService/EditTableService/EditTableService.js
index 12ed7228e..969a3bad1 100644
--- a/wax-prosemirror-services/src/TablesService/EditTableService/EditTableService.js
+++ b/wax-prosemirror-services/src/TablesService/EditTableService/EditTableService.js
@@ -1,5 +1,5 @@
 import Service from "wax-prosemirror-core/src/services/Service";
-import Table from "./Table";
+import TableDropDownOptions from "./TableDropDownOptions";
 
 class EditTableService extends Service {
   boot() {}
diff --git a/wax-prosemirror-services/src/TablesService/EditTableService/TableDropDownOptions.js b/wax-prosemirror-services/src/TablesService/EditTableService/TableDropDownOptions.js
index 2bd55d9c6..9deea97f4 100644
--- a/wax-prosemirror-services/src/TablesService/EditTableService/TableDropDownOptions.js
+++ b/wax-prosemirror-services/src/TablesService/EditTableService/TableDropDownOptions.js
@@ -1,7 +1,7 @@
 import React from "react";
 import { v4 as uuid } from "uuid";
-import { canInsert } from "../../../lib/Utils";
-import Tools from "../../../lib/Tools";
+import { canInsert } from "../../lib/Utils";
+import Tools from "../../lib/Tools";
 import { injectable } from "inversify";
 import { TableDropDown } from "wax-prosemirror-components";
 import { addColumnBefore } from "prosemirror-tables";
diff --git a/wax-prosemirror-services/src/TablesService/InsertTableService/InsertTableService.js b/wax-prosemirror-services/src/TablesService/InsertTableService/InsertTableService.js
index 1644a00da..f0accdee4 100644
--- a/wax-prosemirror-services/src/TablesService/InsertTableService/InsertTableService.js
+++ b/wax-prosemirror-services/src/TablesService/InsertTableService/InsertTableService.js
@@ -1,3 +1,4 @@
+import { tableNodes } from "prosemirror-tables";
 import Service from "wax-prosemirror-core/src/services/Service";
 import Table from "./Table";
 
diff --git a/wax-prosemirror-services/src/TablesService/index.js b/wax-prosemirror-services/src/TablesService/index.js
index e69de29bb..9565d0fbe 100644
--- a/wax-prosemirror-services/src/TablesService/index.js
+++ b/wax-prosemirror-services/src/TablesService/index.js
@@ -0,0 +1,4 @@
+import InsertTableService from "./InsertTableService/InsertTableService";
+import EditTableService from "./EditTableService/EditTableService";
+
+export default [new InsertTableService(), new EditTableService()];
diff --git a/wax-prosemirror-services/src/WaxToolGroups/TableToolGroupService/TableGroupService.js b/wax-prosemirror-services/src/WaxToolGroups/TableToolGroupService/TableGroupService.js
deleted file mode 100644
index 137ed227b..000000000
--- a/wax-prosemirror-services/src/WaxToolGroups/TableToolGroupService/TableGroupService.js
+++ /dev/null
@@ -1,12 +0,0 @@
-import Table from "./Table";
-import Service from "wax-prosemirror-core/src/services/Service";
-
-class TableToolGroupService extends Service {
-  name = "TableToolGroupService";
-
-  register() {
-    this.container.bind("Table").to(Table);
-  }
-}
-
-export default TableToolGroupService;
diff --git a/wax-prosemirror-services/src/WaxToolGroups/TableToolGroupService/TableToolGroupService.js b/wax-prosemirror-services/src/WaxToolGroups/TableToolGroupService/TableToolGroupService.js
index 137ed227b..10c19d7df 100644
--- a/wax-prosemirror-services/src/WaxToolGroups/TableToolGroupService/TableToolGroupService.js
+++ b/wax-prosemirror-services/src/WaxToolGroups/TableToolGroupService/TableToolGroupService.js
@@ -1,11 +1,11 @@
-import Table from "./Table";
+import Tables from "./Tables";
 import Service from "wax-prosemirror-core/src/services/Service";
 
 class TableToolGroupService extends Service {
   name = "TableToolGroupService";
 
   register() {
-    this.container.bind("Table").to(Table);
+    this.container.bind("Tables").to(Tables);
   }
 }
 
diff --git a/wax-prosemirror-services/src/WaxToolGroups/TableToolGroupService/Table.js b/wax-prosemirror-services/src/WaxToolGroups/TableToolGroupService/Tables.js
similarity index 56%
rename from wax-prosemirror-services/src/WaxToolGroups/TableToolGroupService/Table.js
rename to wax-prosemirror-services/src/WaxToolGroups/TableToolGroupService/Tables.js
index 92a774076..eff5bb286 100644
--- a/wax-prosemirror-services/src/WaxToolGroups/TableToolGroupService/Table.js
+++ b/wax-prosemirror-services/src/WaxToolGroups/TableToolGroupService/Tables.js
@@ -2,16 +2,14 @@ import { injectable, inject } from "inversify";
 import ToolGroup from "../../lib/ToolGroup";
 
 @injectable()
-class Table extends ToolGroup {
+class Tables extends ToolGroup {
   tools = [];
   constructor(
-    @inject("OrderedList") orderedlist,
-    @inject("BulletList") bulletlist,
-    @inject("JoinUp") joinup,
-    @inject("Lift") lift
+    @inject("Table") table,
+    @inject("TableDropDownOptions") tableDropDownOptions
   ) {
     super();
-    this.tools = [orderedlist, bulletlist, joinup, lift];
+    this.tools = [table, tableDropDownOptions];
   }
 
   renderTools(view) {
@@ -23,4 +21,4 @@ class Table extends ToolGroup {
   }
 }
 
-export default Table;
+export default Tables;
-- 
GitLab