import classnames from "classnames";
import React, { Component } from "react";
import styles from "./statics/styles/in-plugin-input-scss.js";
class InPluginInput 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();
      }
    };
    this.onChange = (e) => this.props.onChange?.(e.target.value);
  }
  render() {
    const className = classnames(styles.inPluginInput, this.props.className);
    return /* @__PURE__ */ React.createElement(
      "textarea",
      {
        className,
        value: this.props.value,
        onChange: this.onChange,
        onFocus: this.handleFocus,
        onBlur: this.handleBlur,
        onKeyPress: this.handleKeyPress,
        dir: "auto",
        rows: 1
      }
    );
  }
}
InPluginInput.defaultProps = {
  setInPluginEditingMode: () => false,
  setFocusToBlock: () => false
};
export {
  InPluginInput
};
//# sourceMappingURL=in-plugin-input.js.map
