From c1ffbb4c510c10230aab15ce3edaa286e6eb20b0 Mon Sep 17 00:00:00 2001 From: chris <kokosias@yahoo.gr> Date: Wed, 17 Apr 2019 16:02:00 +0300 Subject: [PATCH] add file --- .../config/classes/createSchema.js | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 wax-prosemirror-core/config/classes/createSchema.js diff --git a/wax-prosemirror-core/config/classes/createSchema.js b/wax-prosemirror-core/config/classes/createSchema.js new file mode 100644 index 000000000..2b3005b14 --- /dev/null +++ b/wax-prosemirror-core/config/classes/createSchema.js @@ -0,0 +1,33 @@ +import { Schema } from "prosemirror-model"; + +class createSchema { + constructor(schema) { + if (!schema) { + throw new Error("schema is mandatory"); + } + const { nodes, marks } = schema; + + if (!nodes || !marks) { + throw new Error("no nodes or marks found"); + } + + this.nodes = nodes; + this.marks = marks; + return this.initSchema(); + } + + initSchema() { + return new Schema(this.toJSON()); + } + + toJSON() { + return { + nodes: this.nodes, + marks: this.marks + }; + } + + setDefaultSchema() {} +} + +export default createSchema; -- GitLab