From 6104fd259b3bc8ac7b7d38e42479b4410000d29a Mon Sep 17 00:00:00 2001
From: chris <kokosias@yahoo.gr>
Date: Tue, 14 Jan 2020 17:08:17 +0200
Subject: [PATCH] cleanup schema

---
 wax-prosemirror-schema/index.js               |   2 -
 wax-prosemirror-schema/src/DefaultSchema.js   |  49 -----
 wax-prosemirror-schema/src/XpubSchema.js      | 205 ------------------
 .../src/editoria/helpers.js                   |  50 -----
 wax-prosemirror-schema/src/editoria/nodes.js  |   2 -
 5 files changed, 308 deletions(-)
 delete mode 100644 wax-prosemirror-schema/src/DefaultSchema.js
 delete mode 100644 wax-prosemirror-schema/src/XpubSchema.js
 delete mode 100644 wax-prosemirror-schema/src/editoria/helpers.js

diff --git a/wax-prosemirror-schema/index.js b/wax-prosemirror-schema/index.js
index 4dc71b758..0aad034c8 100644
--- a/wax-prosemirror-schema/index.js
+++ b/wax-prosemirror-schema/index.js
@@ -1,6 +1,4 @@
-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
diff --git a/wax-prosemirror-schema/src/DefaultSchema.js b/wax-prosemirror-schema/src/DefaultSchema.js
deleted file mode 100644
index 0eaa0bea8..000000000
--- a/wax-prosemirror-schema/src/DefaultSchema.js
+++ /dev/null
@@ -1,49 +0,0 @@
-import { blockLevelToDOM } from "./nodes/helpers";
-const pDOM = ["p", 0],
-  brDOM = ["br"];
-const DefaultSchema = {
-  nodes: {
-    doc: {
-      content: "block+"
-    },
-
-    text: {
-      group: "inline"
-    },
-
-    hard_break: {
-      inline: true,
-      group: "inline",
-      selectable: false,
-      parseDOM: [{ tag: "br" }],
-      toDOM() {
-        return brDOM;
-      }
-    },
-    paragraph: {
-      group: "block",
-      content: "inline*",
-      attrs: {
-        class: { default: "paragraph" },
-        track: { default: [] }
-      },
-      parseDOM: [
-        {
-          tag: "p.paragraph",
-          getAttrs(dom) {
-            return {
-              class: dom.getAttribute("class")
-            };
-          }
-        }
-      ],
-      toDOM(node) {
-        const attrs = blockLevelToDOM(node);
-        return ["p", attrs, 0];
-      }
-    }
-  },
-  marks: {}
-};
-
-export default DefaultSchema;
diff --git a/wax-prosemirror-schema/src/XpubSchema.js b/wax-prosemirror-schema/src/XpubSchema.js
deleted file mode 100644
index 77fcb1f69..000000000
--- a/wax-prosemirror-schema/src/XpubSchema.js
+++ /dev/null
@@ -1,205 +0,0 @@
-import { orderedList, bulletList, listItem } from "prosemirror-schema-list";
-import { tableNodes } from "prosemirror-tables";
-
-const pDOM = ["p", 0],
-  brDOM = ["br"];
-
-const emDOM = ["em", 0],
-  strongDOM = ["strong", 0],
-  codeDOM = ["code", 0];
-
-const XpubSchema = {
-  nodes: {
-    doc: {
-      content: "block+"
-    },
-
-    text: {
-      group: "inline"
-    },
-
-    hard_break: {
-      inline: true,
-      group: "inline",
-      selectable: false,
-      parseDOM: [{ tag: "br" }],
-      toDOM() {
-        return brDOM;
-      }
-    },
-
-    paragraph: {
-      content: "inline*",
-      group: "block",
-      parseDOM: [{ tag: "p" }],
-      toDOM() {
-        return pDOM;
-      }
-    },
-    heading: {
-      attrs: { class: { default: "ct" }, level: { default: 1 } },
-      content: "inline*",
-      group: "block",
-      defining: true,
-      parseDOM: [
-        { tag: "h1", attrs: { level: 1 } },
-        { tag: "h2", attrs: { level: 2 } },
-        { tag: "h3", attrs: { level: 3 } },
-        { tag: "h4", attrs: { level: 4 } },
-        { tag: "h5", attrs: { level: 5 } },
-        { tag: "h6", attrs: { level: 6 } }
-      ],
-      toDOM(node) {
-        if (node.attrs.level === 1) {
-          return ["h" + node.attrs.level, node.attrs, 0];
-        } else {
-          return ["h" + node.attrs.level, 0];
-        }
-      }
-    },
-    image: {
-      inline: true,
-      attrs: {
-        src: {},
-        alt: { default: null },
-        title: { default: null }
-      },
-      group: "inline",
-      draggable: true,
-      parseDOM: [
-        {
-          tag: "img[src]",
-          getAttrs(dom) {
-            return {
-              src: dom.getAttribute("src"),
-              title: dom.getAttribute("title"),
-              alt: dom.getAttribute("alt")
-            };
-          }
-        }
-      ],
-      toDOM(node) {
-        return ["img", node.attrs];
-      }
-    },
-    ordered_list: {
-      ...orderedList,
-      content: "list_item+",
-      group: "block"
-    },
-    bullet_list: {
-      ...bulletList,
-      content: "list_item+",
-      group: "block"
-    },
-    list_item: {
-      ...listItem,
-      content: "paragraph block*",
-      group: "block"
-    }
-  },
-  marks: {
-    link: {
-      attrs: {
-        href: { default: null },
-        rel: { default: "" },
-        target: { default: "blank" },
-        title: { default: null }
-      },
-      inclusive: false,
-      parseDOM: [
-        {
-          tag: "a[href]",
-          getAttrs: dom => {
-            const href = dom.getAttribute("href");
-            const target = href && href.indexOf("#") === 0 ? "" : "blank";
-            return {
-              href: dom.getAttribute("href"),
-              title: dom.getAttribute("title"),
-              target
-            };
-          }
-        }
-      ],
-      toDOM(node) {
-        return ["a", node.attrs, 0];
-      }
-    },
-    em: {
-      parseDOM: [{ tag: "i" }, { tag: "em" }, { style: "font-style=italic" }],
-      toDOM() {
-        return emDOM;
-      }
-    },
-    strong: {
-      parseDOM: [
-        { tag: "strong" },
-        {
-          tag: "b",
-          getAttrs: node => node.style.fontWeight != "normal" && null
-        },
-        {
-          style: "font-weight",
-          getAttrs: value => /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null
-        }
-      ],
-      toDOM() {
-        return strongDOM;
-      }
-    },
-    code: {
-      parseDOM: [{ tag: "code" }],
-      toDOM() {
-        return codeDOM;
-      }
-    },
-    subscript: {
-      excludes: "superscript",
-      parseDOM: [{ tag: "sub" }, { style: "vertical-align=sub" }],
-      toDOM: () => ["sub"]
-    },
-    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: () => [
-        "span",
-        {
-          style: "text-decoration:underline"
-        }
-      ]
-    },
-    source: {
-      parseDOM: [{ tag: "cite" }],
-      toDOM() {
-        return ["cite", 0];
-      }
-    }
-  }
-};
-
-const allNodes = {
-  ...XpubSchema.nodes,
-  ...tableNodes({
-    tableGroup: "block",
-    cellContent: "block+"
-  })
-};
-
-export default XpubSchema;
diff --git a/wax-prosemirror-schema/src/editoria/helpers.js b/wax-prosemirror-schema/src/editoria/helpers.js
deleted file mode 100644
index 3020008e1..000000000
--- a/wax-prosemirror-schema/src/editoria/helpers.js
+++ /dev/null
@@ -1,50 +0,0 @@
-const parseFormatList = str => {
-  if (!str) {
-    return [];
-  }
-  let formatList;
-  try {
-    formatList = JSON.parse(str);
-  } catch (error) {
-    return [];
-  }
-  if (!Array.isArray(formatList)) {
-    return [];
-  }
-  return formatList.filter(format => typeof format === "string"); // ensure there are only strings in list
-};
-
-const parseTracks = str => {
-  if (!str) {
-    return [];
-  }
-  let tracks;
-  try {
-    tracks = JSON.parse(str);
-  } catch (error) {
-    return [];
-  }
-  if (!Array.isArray(tracks)) {
-    return [];
-  }
-  return tracks.filter(
-    (
-      track // ensure required fields are present
-    ) =>
-      track.hasOwnProperty("user") &&
-      track.hasOwnProperty("username") &&
-      track.hasOwnProperty("date")
-  );
-};
-
-const blockLevelToDOM = node => {
-  const attrs = node.attrs.track.length
-    ? {
-        class: node.attrs.class,
-        "data-track": JSON.stringify(node.attrs.track)
-      }
-    : { class: node.attrs.class };
-  return attrs;
-};
-
-export { parseFormatList, parseTracks, blockLevelToDOM };
diff --git a/wax-prosemirror-schema/src/editoria/nodes.js b/wax-prosemirror-schema/src/editoria/nodes.js
index 72e283f05..32769dc16 100644
--- a/wax-prosemirror-schema/src/editoria/nodes.js
+++ b/wax-prosemirror-schema/src/editoria/nodes.js
@@ -1,5 +1,3 @@
-import { tableNodes } from "prosemirror-tables";
-import { parseFormatList, parseTracks, blockLevelToDOM } from "./helpers";
 const pDOM = ["p", 0],
   brDOM = ["br"],
   blockquoteDOM = ["blockquote", 0];
-- 
GitLab