"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.schema = exports.nodes = exports.marks = void 0;

var _prosemirrorModel = require("prosemirror-model");

var blockquoteDOM = ["blockquote", 0];
var hrDOM = ["hr"];
var preDOM = ["pre", ["code", 0]];
var brDOM = ["br"]; // :: Object
// [Specs](#model.NodeSpec) for the nodes defined in this schema.

var nodes = {
  // :: NodeSpec The top level document node.
  doc: {
    content: "block+"
  },
  // :: NodeSpec A plain paragraph textblock. Represented in the DOM
  // as a `<p>` element.
  paragraph: {
    content: "inline*",
    attrs: {
      textAlign: {
        "default": 'left'
      }
    },
    group: "block",
    parseDOM: [{
      tag: "p"
    }],
    toDOM: function toDOM(node) {
      return ["p", {
        style: "text-align:".concat(node.attrs["textAlign"])
      }, 0];
    }
  },
  // :: NodeSpec A blockquote (`<blockquote>`) wrapping one or more blocks.
  blockquote: {
    content: "block+",
    group: "block",
    defining: true,
    parseDOM: [{
      tag: "blockquote"
    }],
    toDOM: function toDOM() {
      return blockquoteDOM;
    }
  },
  // :: NodeSpec A horizontal rule (`<hr>`).
  horizontal_rule: {
    group: "block",
    parseDOM: [{
      tag: "hr"
    }],
    toDOM: function toDOM() {
      return hrDOM;
    }
  },
  // :: NodeSpec A heading textblock, with a `level` attribute that
  // should hold the number 1 to 6. Parsed and serialized as `<h1>` to
  // `<h6>` elements.
  heading: {
    attrs: {
      level: {
        "default": 1
      },
      textAlign: {
        "default": 'left'
      }
    },
    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: function toDOM(node) {
      return ["h".concat(node.attrs.level), {
        style: "text-align:".concat(node.attrs["textAlign"])
      }, 0];
    }
  },
  // :: NodeSpec A code listing. Disallows marks or non-text inline
  // nodes by default. Represented as a `<pre>` element with a
  // `<code>` element inside of it.
  code_block: {
    content: "text*",
    marks: "",
    group: "block",
    code: true,
    defining: true,
    parseDOM: [{
      tag: "pre",
      preserveWhitespace: "full"
    }],
    toDOM: function toDOM() {
      return preDOM;
    }
  },
  // :: NodeSpec The text node.
  text: {
    group: "inline"
  },
  // :: NodeSpec An inline image (`<img>`) node. Supports `src`,
  // `alt`, and `href` attributes. The latter two default to the empty
  // string.
  image: {
    inline: true,
    attrs: {
      src: {},
      alt: {
        "default": null
      },
      title: {
        "default": null
      }
    },
    group: "inline",
    draggable: true,
    parseDOM: [{
      tag: "img[src]",
      getAttrs: function getAttrs(dom) {
        return {
          src: dom.getAttribute("src"),
          title: dom.getAttribute("title"),
          alt: dom.getAttribute("alt")
        };
      }
    }],
    toDOM: function toDOM(node) {
      var _node$attrs = node.attrs,
          src = _node$attrs.src,
          alt = _node$attrs.alt,
          title = _node$attrs.title;
      return ["img", {
        src: src,
        alt: alt,
        title: title
      }];
    }
  },
  // :: NodeSpec A hard line break, represented in the DOM as `<br>`.
  hard_break: {
    inline: true,
    group: "inline",
    selectable: false,
    parseDOM: [{
      tag: "br"
    }],
    toDOM: function toDOM() {
      return brDOM;
    }
  }
};
exports.nodes = nodes;
var emDOM = ["em", 0];
var strongDOM = ["strong", 0];
var codeDOM = ["code", 0]; // :: Object [Specs](#model.MarkSpec) for the marks in the schema.

var marks = {
  // :: MarkSpec A link. Has `href` and `title` attributes. `title`
  // defaults to the empty string. Rendered and parsed as an `<a>`
  // element.
  link: {
    attrs: {
      href: {},
      title: {
        "default": null
      }
    },
    inclusive: false,
    parseDOM: [{
      tag: "a[href]",
      getAttrs: function getAttrs(dom) {
        return {
          href: dom.getAttribute("href"),
          title: dom.getAttribute("title")
        };
      }
    }],
    toDOM: function toDOM(node) {
      var _node$attrs2 = node.attrs,
          href = _node$attrs2.href,
          title = _node$attrs2.title;
      return ["a", {
        href: href,
        title: title
      }, 0];
    }
  },
  // :: MarkSpec An emphasis mark. Rendered as an `<em>` element.
  // Has parse rules that also match `<i>` and `font-style: italic`.
  em: {
    parseDOM: [{
      tag: "i"
    }, {
      tag: "em"
    }, {
      style: "font-style=italic"
    }],
    toDOM: function toDOM() {
      return emDOM;
    }
  },
  // :: MarkSpec A strong mark. Rendered as `<strong>`, parse rules
  // also match `<b>` and `font-weight: bold`.
  strong: {
    parseDOM: [{
      tag: "strong"
    }, // This works around a Google Docs misbehavior where
    // pasted content will be inexplicably wrapped in `<b>`
    // tags with a font-weight normal.
    {
      tag: "b",
      getAttrs: function getAttrs(node) {
        return node.style.fontWeight !== "normal" && null;
      }
    }, {
      style: "font-weight",
      getAttrs: function getAttrs(value) {
        return /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null;
      }
    }],
    toDOM: function toDOM() {
      return strongDOM;
    }
  },
  // :: MarkSpec Code font mark. Represented as a `<code>` element.
  code: {
    parseDOM: [{
      tag: "code"
    }],
    toDOM: function toDOM() {
      return codeDOM;
    }
  },
  underLine: {
    parseDOM: [{
      tag: "span",
      getAttrs: function getAttrs(node) {
        return node.style.textDecoration == "underline" && null;
      }
    }],
    toDOM: function toDOM() {
      return ["span", {
        style: 'text-decoration:underline;'
      }, 0];
    }
  },
  deleteLine: {
    parseDOM: [{
      tag: "span",
      getAttrs: function getAttrs(node) {
        return node.style.textDecoration == "ine-through" && null;
      }
    }],
    toDOM: function toDOM() {
      return ["span", {
        style: 'text-decoration:line-through;'
      }, 0];
    }
  }
}; // :: Schema
// This schema roughly corresponds to the document schema used by
// [CommonMark](http://commonmark.org/), minus the list elements,
// which are defined in the [`prosemirror-schema-list`](#schema-list)
// module.
//
// To reuse elements from this schema, extend or read from its
// `spec.nodes` and `spec.marks` [properties](#model.Schema.spec).
// @ts-ignore

exports.marks = marks;
var schema = new _prosemirrorModel.Schema({
  nodes: nodes,
  marks: marks
});
exports.schema = schema;