"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.bpfrpt_proptype_SetStateCall = void 0;
var _prosemirrorState = require("prosemirror-state");
var _prosemirrorTransform = require("prosemirror-transform");
var _prosemirrorModel = require("prosemirror-model");
var _prosemirrorView = require("prosemirror-view");
var _reactDom = _interopRequireDefault(require("react-dom"));
var _propTypes = _interopRequireDefault(require("prop-types"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
var bpfrpt_proptype_SetStateCall = _propTypes.default.func;
exports.bpfrpt_proptype_SetStateCall = bpfrpt_proptype_SetStateCall;
class SimpleConnector {
  // This flag is used to deteremine if data passed in or not
  // If not passed in, use the data from collab server when in collab mode.
  // else use empty content.

  constructor(_editorState, setState) {
    _defineProperty(this, "_setState", void 0);
    _defineProperty(this, "_editorState", void 0);
    _defineProperty(this, "_dataDefined", void 0);
    _defineProperty(this, "onEdit", (transaction, view) => {
      _reactDom.default.unstable_batchedUpdates(() => {
        const editorState = this._editorState.apply(transaction);
        // [FS] IRAD-1236 2020-03-05
        // The state property should not be directly mutated. Use the updateState method.
        if (view) {
          view.updateState(editorState);
        }
        const state = {
          editorState,
          data: transaction.doc.toJSON()
        };
        this._setState(state, () => {
          this._editorState = editorState;
        });
      });
    });
    _defineProperty(this, "getState", () => {
      return this._editorState;
    });
    _defineProperty(this, "updateSchema", (schema, data) => {});
    _defineProperty(this, "updateContent", data => {});
    _defineProperty(this, "cleanUp", () => {});
    this._editorState = _editorState;
    this._setState = setState;
  }
}
var _default = SimpleConnector;
exports.default = _default;