import { jsx as _jsx } from "react/jsx-runtime";
import React, { useState } from "react";
import { RichTextEditor } from "./RichTextEditor";
import { ClickAwayListener } from "@material-ui/core";
export const InlineRichTextEdit = React.forwardRef((props, ref) => {
    const [editing, setEditing] = useState(false);
    const [editValue, setEditValue] = useState(props.value || "");
    const [placeholder] = useState(props.placeholder);
    let clickAway = (event) => {
        setEditing(false);
    };
    let handleClick = () => {
        setEditing(true);
    };
    return (_jsx(ClickAwayListener, Object.assign({ onClickAway: clickAway }, { children: _jsx("div", Object.assign({ onClick: handleClick }, { children: _jsx(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 }, void 0) }), void 0) }), void 0));
});
//# sourceMappingURL=InlineRichTextEdit.js.map