"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = createEmptyEditorState;
exports.EMPTY_DOC_JSON = void 0;

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

var _prosemirrorState = require("prosemirror-state");

var _buildEditorPlugins = _interopRequireDefault(require("./buildEditorPlugins"));

var _convertFromJSON = _interopRequireDefault(require("./convertFromJSON"));

var _EditorSchema = _interopRequireDefault(require("./EditorSchema"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

const EMPTY_DOC_JSON = {
  type: 'doc',
  content: [{
    type: 'paragraph',
    content: [{
      type: 'text',
      text: ' '
    }]
  }]
};
exports.EMPTY_DOC_JSON = EMPTY_DOC_JSON;

function createEmptyEditorState(schema, defaultSchema, plugins, defaultPlugins) {
  const newSchema = schema || (defaultSchema ? defaultSchema : _EditorSchema.default); // TODO: Check if schema support doc and paragraph nodes.

  return (0, _convertFromJSON.default)(EMPTY_DOC_JSON, schema, defaultSchema ? defaultSchema : _EditorSchema.default, plugins, defaultPlugins ? defaultPlugins : new _buildEditorPlugins.default(newSchema).get());
}