import { jsx } from "react/jsx-runtime";
import "react";
import { connect, mapProps, mapReadPretty } from "@tachybase/schema";
import react_quill from "react-quill";
import { isVariable } from "../../../variables/utils/isVariable.mjs";
import { ReadPretty } from "../input/index.mjs";
import { useStyles } from "./style.mjs";
const RichText = connect((props)=>{
    const { wrapSSR, hashId, componentCls } = useStyles();
    const modules = {
        toolbar: [
            [
                'bold',
                'italic',
                'underline',
                'link'
            ],
            [
                {
                    list: 'ordered'
                },
                {
                    list: 'bullet'
                }
            ],
            [
                'clean'
            ]
        ]
    };
    const formats = [
        'header',
        'bold',
        'italic',
        'underline',
        'strike',
        'blockquote',
        'list',
        'bullet',
        'indent',
        'link',
        'image'
    ];
    const { value, defaultValue, onChange, disabled } = props;
    const resultValue = isVariable(value || defaultValue) ? void 0 : value || defaultValue || '';
    return wrapSSR(/*#__PURE__*/ jsx(react_quill, {
        className: "".concat(componentCls, " ").concat(hashId),
        modules: modules,
        formats: formats,
        value: resultValue,
        onChange: onChange,
        readOnly: disabled
    }));
}, mapProps({
    initialValue: 'defaultValue'
}), mapReadPretty((props)=>/*#__PURE__*/ jsx(ReadPretty.Html, {
        ...props
    })));
export { RichText };
