From a2da08dd6403d162354bf7512f3679055f255160 Mon Sep 17 00:00:00 2001
From: chris <kokosias@yahoo.gr>
Date: Tue, 7 Jun 2022 10:22:24 +0300
Subject: [PATCH] replace with oen tool

---
 editors/demo/src/Editors.js                   |  2 +-
 editors/demo/src/OEN/config/config.js         | 44 ++++++++++-
 wax-prosemirror-services/index.js             |  1 +
 .../OENContainersService.js                   |  1 +
 .../DisplayText.js                            |  1 +
 .../OENContainersToolGroupService.js          | 10 +++
 .../OENContainersToolGroupService/OENTools.js | 74 +++++++++++++++++++
 .../SpecialCharactersToolGroupService.js      |  1 -
 8 files changed, 129 insertions(+), 5 deletions(-)
 create mode 100644 wax-prosemirror-services/src/WaxToolGroups/OENContainersToolGroupService/OENContainersToolGroupService.js
 create mode 100644 wax-prosemirror-services/src/WaxToolGroups/OENContainersToolGroupService/OENTools.js

diff --git a/editors/demo/src/Editors.js b/editors/demo/src/Editors.js
index 9e14f6ac6..d429ef02d 100644
--- a/editors/demo/src/Editors.js
+++ b/editors/demo/src/Editors.js
@@ -73,7 +73,7 @@ const Editors = () => {
       case 'oen':
         return <OEN />;
       default:
-        return <HHMI />;
+        return <OEN />;
     }
   };
 
diff --git a/editors/demo/src/OEN/config/config.js b/editors/demo/src/OEN/config/config.js
index 79590eeab..801b97414 100644
--- a/editors/demo/src/OEN/config/config.js
+++ b/editors/demo/src/OEN/config/config.js
@@ -23,7 +23,7 @@ import {
   CommentsService,
   CodeBlockService,
   CodeBlockToolGroupService,
-  DisplayTextToolGroupService,
+  // DisplayTextToolGroupService,
   MathService,
   FindAndReplaceService,
   EditingSuggestingService,
@@ -44,6 +44,7 @@ import {
   CustomTagBlockToolGroupService,
   CustomTagService,
   OENContainersService,
+  OENContainersToolGroupService,
 } from 'wax-prosemirror-services';
 
 import { EditoriaSchema } from 'wax-prosemirror-utilities';
@@ -103,7 +104,7 @@ export default {
     },
     {
       templateArea: 'leftSideBar',
-      toolGroups: ['DisplayText'],
+      toolGroups: ['OENTools'],
     },
     {
       templateArea: 'commentTrackToolBar',
@@ -119,6 +120,42 @@ export default {
   // OrderedListService: { subList: false },
   // BulletListService: { subList: false },
   // JoinUpService: { subList: false },
+  OENContainersService: [
+    {
+      groupHeader: 'Core Elements',
+      items: [
+        {
+          displayName: 'Section',
+          headingLevel: 2,
+          nestedHeadingLevel: null,
+          className: 'section',
+        },
+        {
+          displayName: 'Section 1',
+          headingLevel: 2,
+          nestedHeadingLevel: null,
+          className: 'section-1',
+        },
+      ],
+    },
+    {
+      groupHeader: 'Core Elements 1',
+      items: [
+        {
+          displayName: 'Section 2-1',
+          headingLevel: 2,
+          nestedHeadingLevel: null,
+          className: 'section',
+        },
+        {
+          displayName: 'Section 2-2',
+          headingLevel: 2,
+          nestedHeadingLevel: null,
+          className: 'section-1',
+        },
+      ],
+    },
+  ],
   SpecialCharactersService: CharactersList,
   SchemaService: EditoriaSchema,
   TitleService: { updateTitle },
@@ -154,6 +191,7 @@ export default {
 
   services: [
     new OENContainersService(),
+    new OENContainersToolGroupService(),
     new CustomTagService(),
     new DisplayBlockLevelService(),
     new DisplayToolGroupService(),
@@ -177,7 +215,7 @@ export default {
     new CodeBlockService(),
     new CodeBlockToolGroupService(),
     new EditingSuggestingService(),
-    new DisplayTextToolGroupService(),
+    // new DisplayTextToolGroupService(),
     new MathService(),
     new FindAndReplaceService(),
     new TrackingAndEditingToolGroupService(),
diff --git a/wax-prosemirror-services/index.js b/wax-prosemirror-services/index.js
index fadcf73d3..0b461ea15 100644
--- a/wax-prosemirror-services/index.js
+++ b/wax-prosemirror-services/index.js
@@ -83,3 +83,4 @@ export { default as MultipleChoiceDropDownToolGroupService } from './src/WaxTool
 export { default as EssayToolGroupService } from './src/WaxToolGroups/EssayToolGroupService/EssayToolGroupService';
 export { default as MatchingToolGroupService } from './src/WaxToolGroups/MatchingToolGroupService/MatchingToolGroupService';
 export { default as MultipleDropDownToolGroupService } from './src/WaxToolGroups/MultipleDropDownToolGroupService/MultipleDropDownToolGroupService';
+export { default as OENContainersToolGroupService } from './src/WaxToolGroups/OENContainersToolGroupService/OENContainersToolGroupService';
diff --git a/wax-prosemirror-services/src/OENContainersService/OENContainersService.js b/wax-prosemirror-services/src/OENContainersService/OENContainersService.js
index b082eaa13..5c45cded5 100644
--- a/wax-prosemirror-services/src/OENContainersService/OENContainersService.js
+++ b/wax-prosemirror-services/src/OENContainersService/OENContainersService.js
@@ -8,6 +8,7 @@ class OENContainersService extends Service {
   boot() {}
 
   register() {
+    console.log(this.config);
     const createNode = this.container.get('CreateNode');
 
     Object.keys(OenNodes).forEach(node => {
diff --git a/wax-prosemirror-services/src/WaxToolGroups/DisplayTextToolGroupService/DisplayText.js b/wax-prosemirror-services/src/WaxToolGroups/DisplayTextToolGroupService/DisplayText.js
index 29543d517..c8b805f05 100644
--- a/wax-prosemirror-services/src/WaxToolGroups/DisplayTextToolGroupService/DisplayText.js
+++ b/wax-prosemirror-services/src/WaxToolGroups/DisplayTextToolGroupService/DisplayText.js
@@ -1,3 +1,4 @@
+/* eslint-disable no-underscore-dangle */
 import React, { useMemo } from 'react';
 import { injectable, inject } from 'inversify';
 import { BlockLevelTools, Tabs } from 'wax-prosemirror-components';
diff --git a/wax-prosemirror-services/src/WaxToolGroups/OENContainersToolGroupService/OENContainersToolGroupService.js b/wax-prosemirror-services/src/WaxToolGroups/OENContainersToolGroupService/OENContainersToolGroupService.js
new file mode 100644
index 000000000..99617a275
--- /dev/null
+++ b/wax-prosemirror-services/src/WaxToolGroups/OENContainersToolGroupService/OENContainersToolGroupService.js
@@ -0,0 +1,10 @@
+import Service from '../../Service';
+import OENTools from './OENTools';
+
+class OENContainersToolGroupService extends Service {
+  register() {
+    this.container.bind('OENTools').to(OENTools);
+  }
+}
+
+export default OENContainersToolGroupService;
diff --git a/wax-prosemirror-services/src/WaxToolGroups/OENContainersToolGroupService/OENTools.js b/wax-prosemirror-services/src/WaxToolGroups/OENContainersToolGroupService/OENTools.js
new file mode 100644
index 000000000..f080f08fa
--- /dev/null
+++ b/wax-prosemirror-services/src/WaxToolGroups/OENContainersToolGroupService/OENTools.js
@@ -0,0 +1,74 @@
+/* eslint-disable no-underscore-dangle */
+import React, { useMemo } from 'react';
+import { injectable, inject } from 'inversify';
+import { BlockLevelTools, Tabs } from 'wax-prosemirror-components';
+import { isEmpty } from 'lodash';
+import styled from 'styled-components';
+import { v4 as uuidv4 } from 'uuid';
+import ToolGroup from '../../lib/ToolGroup';
+
+const Empty = styled.div`
+  background: khaki;
+  height: 100%;
+`;
+
+@injectable()
+class OENTools extends ToolGroup {
+  tools = [];
+  toolGroups = [];
+
+  constructor(
+    @inject('Display') display,
+    @inject('Text') text,
+    @inject('CustomTagBlockToolGroup') blockTag,
+  ) {
+    super();
+    this.toolGroups = [
+      {
+        name: 'TabA',
+        groups: [display, text, blockTag],
+      },
+    ];
+  }
+
+  renderTools(view) {
+    if (isEmpty(view)) return null;
+
+    const first = {
+      id: '1',
+      title: 'block level tools',
+      icon: 'title',
+      disabled: false,
+      component: (
+        <BlockLevelTools
+          groups={this._toolGroups[0].groups.map(group => ({
+            groupName:
+              group.title === 'Custom Block'
+                ? group.title
+                : group.title.props.title,
+            items: group._tools,
+          }))}
+          view={view}
+        />
+      ),
+    };
+
+    const second = {
+      id: '2',
+      disabled: true,
+      title: 'chapter list',
+      icon: 'chapterList',
+      component: <Empty />,
+    };
+
+    const tabList = [first, second];
+
+    const TabsComponent = useMemo(
+      () => <Tabs key={uuidv4()} tabList={tabList} />,
+      [],
+    );
+    return TabsComponent;
+  }
+}
+
+export default OENTools;
diff --git a/wax-prosemirror-services/src/WaxToolGroups/SpecialCharactersToolGroupService/SpecialCharactersToolGroupService.js b/wax-prosemirror-services/src/WaxToolGroups/SpecialCharactersToolGroupService/SpecialCharactersToolGroupService.js
index 7ad79f944..7a9a6995f 100644
--- a/wax-prosemirror-services/src/WaxToolGroups/SpecialCharactersToolGroupService/SpecialCharactersToolGroupService.js
+++ b/wax-prosemirror-services/src/WaxToolGroups/SpecialCharactersToolGroupService/SpecialCharactersToolGroupService.js
@@ -1,4 +1,3 @@
-/* eslint-disable */
 import Service from '../../Service';
 import SpecialCharacters from './SpecialCharacters';
 
-- 
GitLab