"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

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

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));

var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));

var _getPrototypeOf3 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));

var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));

var _react = _interopRequireWildcard(require("react"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _RichContentInput = _interopRequireDefault(require("@instructure/quiz-rce/lib/components/RichContentInput"));

var _RceImageImportModal = _interopRequireDefault(require("./RceImageImportModal"));

/*
 * TODO can we please merge this into quiz-rce and make something coherent out of this
 */
var RichContentInput =
/*#__PURE__*/
function (_Component) {
  (0, _inherits2.default)(RichContentInput, _Component);

  function RichContentInput() {
    var _getPrototypeOf2;

    var _this;

    (0, _classCallCheck2.default)(this, RichContentInput);

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = (0, _possibleConstructorReturn2.default)(this, (_getPrototypeOf2 = (0, _getPrototypeOf3.default)(RichContentInput)).call.apply(_getPrototypeOf2, [this].concat(args)));

    _this.focus = function () {
      _this.rce.focus();
    };

    _this.renderImportModal = function (importModalId, onSuccess, onClose) {
      return _react.default.createElement(_RceImageImportModal.default, {
        closeOverride: _this.props.importModalCloseOverride,
        importModalId: importModalId,
        onClose: onClose,
        onSuccess: onSuccess,
        parentType: _this.props.parentType,
        parentId: _this.props.parentId,
        uploadPath: _this.props.uploadPath
      });
    };

    _this.handleRceRef = function (node) {
      _this.rce = node;
    };

    return _this;
  }

  (0, _createClass2.default)(RichContentInput, [{
    key: "render",
    value: function render() {
      return _react.default.createElement(_RichContentInput.default, Object.assign({
        ref: this.handleRceRef
      }, this.props, {
        renderImportModal: this.renderImportModal,
        openImportModal: this.props.openImportModal
      }));
    }
  }]);
  RichContentInput.displayName = "RichContentInput";
  return RichContentInput;
}(_react.Component);

exports.default = RichContentInput;
RichContentInput.propTypes = {
  // also allows (not listed) all props for ActualRichContentInput
  importModalCloseOverride: _propTypes.default.func,
  label: _propTypes.default.string.isRequired,
  openImportModal: _propTypes.default.func.isRequired,
  parentType: _propTypes.default.string,
  parentId: _propTypes.default.string,
  uploadPath: _propTypes.default.string
};
RichContentInput.defaultProps = {
  importModalCloseOverride: null,
  parentType: '',
  parentId: '',
  uploadPath: null
};