"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.InlineRichTextEdit = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = tslib_1.__importStar(require("react"));
const RichTextEditor_1 = require("./RichTextEditor");
const core_1 = require("@material-ui/core");
exports.InlineRichTextEdit = react_1.default.forwardRef((props, ref) => {
    const [editing, setEditing] = (0, react_1.useState)(false);
    const [editValue, setEditValue] = (0, react_1.useState)(props.value || "");
    const [placeholder] = (0, react_1.useState)(props.placeholder);
    let clickAway = () => {
        setEditing(false);
    };
    let handleClick = () => {
        setEditing(true);
    };
    return ((0, jsx_runtime_1.jsx)(core_1.ClickAwayListener, { onClickAway: clickAway, children: (0, jsx_runtime_1.jsx)("div", { onClick: handleClick, children: (0, jsx_runtime_1.jsx)(RichTextEditor_1.RichTextEditor, { value: editValue, placeholder: placeholder, updateCallback: (value) => {
                    setEditValue(value);
                    if (props.updateCallback) {
                        props.updateCallback(value);
                    }
                }, readOnly: !editing, hideTools: !editing && props.showToolsOnFocus, hideBorder: !editing, exportFileName: props.exportFileName, ref: ref }) }) }));
});
//# sourceMappingURL=InlineRichTextEdit.js.map