'use strict';

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

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

var _class, _temp2;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _RichContentInput = require('quiz-interactions/lib/components/common/components/rce/RichContentInput');

var _RichContentInput2 = _interopRequireDefault(_RichContentInput);

var _RceImageImportModal = require('./RceImageImportModal');

var _RceImageImportModal2 = _interopRequireDefault(_RceImageImportModal);

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

var RichContentInput = (_temp2 = _class = function (_Component) {
  (0, _inherits3.default)(RichContentInput, _Component);

  function RichContentInput() {
    var _ref;

    var _temp, _this, _ret;

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

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

    return _ret = (_temp = (_this = (0, _possibleConstructorReturn3.default)(this, (_ref = RichContentInput.__proto__ || Object.getPrototypeOf(RichContentInput)).call.apply(_ref, [this].concat(args))), _this), _this.focus = function () {
      _this.rce.focus();
    }, _this.renderImportModal = function (importModalId, onSuccess, onClose) {
      return _react2.default.createElement(_RceImageImportModal2.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;
    }, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);
  }

  (0, _createClass3.default)(RichContentInput, [{
    key: 'render',
    value: function render() {
      return _react2.default.createElement(_RichContentInput2.default, Object.assign({
        ref: this.handleRceRef
      }, this.props, {
        renderImportModal: this.renderImportModal,
        openImportModal: this.props.openImportModal
      }));
    }
  }]);
  RichContentInput.displayName = 'RichContentInput'
  ;
  return RichContentInput;
}(_react.Component), _class.propTypes = {
  // also allows (not listed) all props for InteractionsRCE
  importModalCloseOverride: _propTypes2.default.func,
  label: _propTypes2.default.string.isRequired,
  openImportModal: _propTypes2.default.func.isRequired,
  parentType: _propTypes2.default.string,
  parentId: _propTypes2.default.string,
  uploadPath: _propTypes2.default.string
}, _class.defaultProps = {
  importModalCloseOverride: null,
  parentType: '',
  parentId: '',
  uploadPath: null
}, _temp2);
exports.default = RichContentInput;