import React, { Component } from "react";
class EditableTextInput extends Component {
  constructor() {
    super(...arguments);
    this.handleFocus = (e) => {
      e.stopPropagation();
      this.props.setFocusToBlock();
      this.props.setInPluginEditingMode(true);
    };
    this.handleBlur = () => this.props.setInPluginEditingMode(false);
    this.handleKeyPress = (e) => {
      const { setFocusToBlock, value } = this.props;
      if (e.key === "Enter" && setFocusToBlock && value !== "") {
        this.handleBlur();
        setFocusToBlock();
      }
    };
  }
  render() {
    const { InputComponent, value, onChange } = this.props;
    const props = {
      value,
      onChange,
      onFocus: this.handleFocus,
      onBlur: this.handleBlur,
      onKeyPress: this.handleKeyPress,
      dir: "auto"
    };
    return React.cloneElement(InputComponent, props);
  }
}
export {
  EditableTextInput
};
//# sourceMappingURL=editable-input-wrapper.js.map
