From 0adb1e274e4433ea7cc50be3fbfcefa01efb518c Mon Sep 17 00:00:00 2001
From: chris <kokosias@yahoo.gr>
Date: Thu, 19 Dec 2019 21:13:54 +0200
Subject: [PATCH] more inline services

---
 .../src/AnnotationService/tools/index.js      |  3 ---
 .../StrikeThroughService}/StrikeThrough.js    |  3 ++-
 .../StrikeThroughService.js                   | 18 ++++++++++++++++++
 .../SuperscriptService}/Superscript.js        |  0
 .../SuperscriptService/SuperscriptService.js  | 18 ++++++++++++++++++
 .../src/InlineAnnotations/index.js            |  6 +++++-
 wax-prosemirror-schema/index.js               | 10 ++++++++++
 wax-prosemirror-schema/src/editoria/marks.js  | 18 ------------------
 .../src/marks/smallcapsMark.js                | 19 +++++++++++++++++++
 .../src/marks/strikethroughMark.js            | 18 ++++++++++++++++++
 .../src/marks/superscriptMark.js              | 10 ++++++++++
 .../src/marks/underlineMark.js                | 14 ++++++++++++++
 12 files changed, 114 insertions(+), 23 deletions(-)
 rename wax-prosemirror-plugins/src/{AnnotationService/tools => InlineAnnotations/StrikeThroughService}/StrikeThrough.js (83%)
 create mode 100644 wax-prosemirror-plugins/src/InlineAnnotations/StrikeThroughService/StrikeThroughService.js
 rename wax-prosemirror-plugins/src/{AnnotationService/tools => InlineAnnotations/SuperscriptService}/Superscript.js (100%)
 create mode 100644 wax-prosemirror-plugins/src/InlineAnnotations/SuperscriptService/SuperscriptService.js
 create mode 100644 wax-prosemirror-schema/src/marks/smallcapsMark.js
 create mode 100644 wax-prosemirror-schema/src/marks/strikethroughMark.js
 create mode 100644 wax-prosemirror-schema/src/marks/superscriptMark.js
 create mode 100644 wax-prosemirror-schema/src/marks/underlineMark.js

diff --git a/wax-prosemirror-plugins/src/AnnotationService/tools/index.js b/wax-prosemirror-plugins/src/AnnotationService/tools/index.js
index af913b544..64e441543 100644
--- a/wax-prosemirror-plugins/src/AnnotationService/tools/index.js
+++ b/wax-prosemirror-plugins/src/AnnotationService/tools/index.js
@@ -1,8 +1,5 @@
 export { default as Blockquote } from "./Blockquote";
 export { default as SmallCaps } from "./SmallCaps";
-export { default as StrikeThrough } from "./StrikeThrough";
-// export { default as Subscript } from "./Subscript";
-export { default as Superscript } from "./Superscript";
 export { default as Underline } from "./Underline";
 export { default as Table } from "./Table";
 export { default as TableDropDownOptions } from "./TableDropDownOptions";
diff --git a/wax-prosemirror-plugins/src/AnnotationService/tools/StrikeThrough.js b/wax-prosemirror-plugins/src/InlineAnnotations/StrikeThroughService/StrikeThrough.js
similarity index 83%
rename from wax-prosemirror-plugins/src/AnnotationService/tools/StrikeThrough.js
rename to wax-prosemirror-plugins/src/InlineAnnotations/StrikeThroughService/StrikeThrough.js
index ef38b0a08..c89a7d66f 100644
--- a/wax-prosemirror-plugins/src/AnnotationService/tools/StrikeThrough.js
+++ b/wax-prosemirror-plugins/src/InlineAnnotations/StrikeThroughService/StrikeThrough.js
@@ -17,7 +17,8 @@ export default class StrikeThrough extends Tools {
 
   get active() {
     return state => {
-      return markActive(state.config.schema.marks.strikethrough)(state);
+      console.log(state.config);
+      // return markActive(state.config.schema.marks.strikethrough)(state);
     };
   }
 }
diff --git a/wax-prosemirror-plugins/src/InlineAnnotations/StrikeThroughService/StrikeThroughService.js b/wax-prosemirror-plugins/src/InlineAnnotations/StrikeThroughService/StrikeThroughService.js
new file mode 100644
index 000000000..e4d8d931b
--- /dev/null
+++ b/wax-prosemirror-plugins/src/InlineAnnotations/StrikeThroughService/StrikeThroughService.js
@@ -0,0 +1,18 @@
+import Service from "wax-prosemirror-core/src/services/Service";
+import { strikethroughMark } from "wax-prosemirror-schema";
+import StrikeThrough from "./StrikeThrough";
+console.log(strikethroughMark);
+class StrikeThroughService extends Service {
+  register() {
+    this.container.bind("StrikeThrough").to(StrikeThrough);
+
+    this.container
+      .bind("schema")
+      .toConstantValue({
+        em: strikethroughMark
+      })
+      .whenTargetNamed("mark");
+  }
+}
+
+export default StrikeThroughService;
diff --git a/wax-prosemirror-plugins/src/AnnotationService/tools/Superscript.js b/wax-prosemirror-plugins/src/InlineAnnotations/SuperscriptService/Superscript.js
similarity index 100%
rename from wax-prosemirror-plugins/src/AnnotationService/tools/Superscript.js
rename to wax-prosemirror-plugins/src/InlineAnnotations/SuperscriptService/Superscript.js
diff --git a/wax-prosemirror-plugins/src/InlineAnnotations/SuperscriptService/SuperscriptService.js b/wax-prosemirror-plugins/src/InlineAnnotations/SuperscriptService/SuperscriptService.js
new file mode 100644
index 000000000..26ebd501e
--- /dev/null
+++ b/wax-prosemirror-plugins/src/InlineAnnotations/SuperscriptService/SuperscriptService.js
@@ -0,0 +1,18 @@
+import Service from "wax-prosemirror-core/src/services/Service";
+import { superscriptMark } from "wax-prosemirror-schema";
+import Superscript from "./Superscript";
+
+class SuperscriptService extends Service {
+  boot() {}
+
+  register() {
+    this.container
+      .bind("schema")
+      .toConstantValue({ superscript: superscriptMark })
+      .whenTargetNamed("mark");
+
+    this.container.bind("Superscript").to(Superscript);
+  }
+}
+
+export default SuperscriptService;
diff --git a/wax-prosemirror-plugins/src/InlineAnnotations/index.js b/wax-prosemirror-plugins/src/InlineAnnotations/index.js
index 1d9705ef1..25dec0ebd 100644
--- a/wax-prosemirror-plugins/src/InlineAnnotations/index.js
+++ b/wax-prosemirror-plugins/src/InlineAnnotations/index.js
@@ -2,9 +2,13 @@ import CodeService from "./CodeService/CodeService";
 import StrongService from "./StrongService/StrongService";
 import EmphasisService from "./EmphasisService/EmphasisService";
 import SubscriptService from "./SubscriptService/SubscriptService";
+import SuperscriptService from "./SuperscriptService/SuperscriptService";
+import StrikeThroughService from "./StrikeThroughService/StrikeThroughService";
 export default [
   new CodeService(),
   new StrongService(),
   new EmphasisService(),
-  new SubscriptService()
+  new SubscriptService(),
+  new SuperscriptService(),
+  new StrikeThroughService()
 ];
diff --git a/wax-prosemirror-schema/index.js b/wax-prosemirror-schema/index.js
index e0c547e00..dea985b30 100644
--- a/wax-prosemirror-schema/index.js
+++ b/wax-prosemirror-schema/index.js
@@ -1,8 +1,18 @@
 export { default as DefaultSchema } from "./src/DefaultSchema";
 export { default as EditoriaSchema } from "./src/editoria/EditoriaSchema";
 export { default as XpubSchema } from "./src/XpubSchema";
+
+/*
+LIST OF SUPPORTED MARKS
+*/
 export { default as codeMark } from "./src/marks/codeMark";
 export { default as strongMark } from "./src/marks/strongMark";
 export { default as linkMark } from "./src/marks/linkMark";
 export { default as emphasisMark } from "./src/marks/emphasisMark";
 export { default as subscriptMark } from "./src/marks/subscriptMark";
+export { default as superscriptMark } from "./src/marks/superscriptMark";
+export { default as strikethroughMark } from "./src/marks/strikethroughMark";
+export { default as smallcapsMark } from "./src/marks/smallcapsMark";
+/*
+LIST OF SUPPORTED NODES
+*/
diff --git a/wax-prosemirror-schema/src/editoria/marks.js b/wax-prosemirror-schema/src/editoria/marks.js
index dc5a8df67..2191cf6aa 100644
--- a/wax-prosemirror-schema/src/editoria/marks.js
+++ b/wax-prosemirror-schema/src/editoria/marks.js
@@ -3,24 +3,6 @@ const emDOM = ["em", 0],
   codeDOM = ["code", 0];
 
 const marks = {
-  superscript: {
-    excludes: "subscript",
-    parseDOM: [{ tag: "sup" }, { style: "vertical-align=super" }],
-    toDOM: () => ["sup"]
-  },
-  strikethrough: {
-    parseDOM: [
-      { tag: "strike" },
-      { style: "text-decoration:line-through" },
-      { style: "text-decoration-line:line-through" }
-    ],
-    toDOM: () => [
-      "span",
-      {
-        style: "text-decoration-line:line-through"
-      }
-    ]
-  },
   underline: {
     parseDOM: [{ tag: "u" }, { style: "text-decoration:underline" }],
     toDOM: () => [
diff --git a/wax-prosemirror-schema/src/marks/smallcapsMark.js b/wax-prosemirror-schema/src/marks/smallcapsMark.js
new file mode 100644
index 000000000..72ba1b55b
--- /dev/null
+++ b/wax-prosemirror-schema/src/marks/smallcapsMark.js
@@ -0,0 +1,19 @@
+const smallcaps = {
+  attrs: {
+    class: { default: "small-caps" }
+  },
+  // inclusive: false,
+  parseDOM: [
+    {
+      tag: "span.small-caps",
+      getAttrs(dom) {
+        return { class: dom.getAttribute("class") };
+      }
+    }
+  ],
+  toDOM(node) {
+    return ["span", node.attrs, 0];
+  }
+};
+
+export default smallcaps;
diff --git a/wax-prosemirror-schema/src/marks/strikethroughMark.js b/wax-prosemirror-schema/src/marks/strikethroughMark.js
new file mode 100644
index 000000000..e7d2c692e
--- /dev/null
+++ b/wax-prosemirror-schema/src/marks/strikethroughMark.js
@@ -0,0 +1,18 @@
+const strikethrough = {
+  parseDOM: [
+    { tag: "strike" },
+    { style: "text-decoration:line-through" },
+    { style: "text-decoration-line:line-through" }
+  ],
+  toDOM: (hook, next) => {
+    hook.value = [
+      "span",
+      {
+        style: "text-decoration-line:line-through"
+      }
+    ];
+    next();
+  }
+};
+
+export default strikethrough;
diff --git a/wax-prosemirror-schema/src/marks/superscriptMark.js b/wax-prosemirror-schema/src/marks/superscriptMark.js
new file mode 100644
index 000000000..4e4bc5328
--- /dev/null
+++ b/wax-prosemirror-schema/src/marks/superscriptMark.js
@@ -0,0 +1,10 @@
+const superscript = {
+  excludes: "subscript",
+  parseDOM: [{ tag: "sup" }, { style: "vertical-align=super" }],
+  toDOM: (hook, next) => {
+    hook.value = ["sup"];
+    next();
+  }
+};
+
+export default superscript;
diff --git a/wax-prosemirror-schema/src/marks/underlineMark.js b/wax-prosemirror-schema/src/marks/underlineMark.js
new file mode 100644
index 000000000..fe7ac335a
--- /dev/null
+++ b/wax-prosemirror-schema/src/marks/underlineMark.js
@@ -0,0 +1,14 @@
+const underline = {
+  parseDOM: [{ tag: "u" }, { style: "text-decoration:underline" }],
+  toDOM: (hook, next) => {
+    hook.value = [
+      "span",
+      {
+        style: "text-decoration:underline"
+      }
+    ];
+    next();
+  }
+};
+
+export default underline;
-- 
GitLab