import { useLexicalComposerContext } from "./LexicalComposerContext";
import { useLexicalEditable } from "./useLexicalEditable";
import { useCanShowPlaceholder } from "./shared/useCanShowPlaceholder";
import { useDecorators } from "./shared/useDecorators";
import { useRichTextSetup } from "./shared/useRichTextSetup";
import { Show, createMemo } from "solid-js";
import { untrack } from "solid-js";
export function RichTextPlugin(props) {
    const [editor] = useLexicalComposerContext();
    const decorators = useDecorators(editor, props.errorBoundary);
    useRichTextSetup(editor);
    return (<>
      {props.contentEditable}
      <Placeholder content={props.placeholder}/>
      {decorators}
    </>);
}
// TODO remove
function Placeholder(props) {
    const [editor] = useLexicalComposerContext();
    const showPlaceholder = useCanShowPlaceholder(editor);
    const editable = useLexicalEditable();
    const content = createMemo(() => props.content);
    return (<Show when={showPlaceholder()}>
      <Show when={typeof content() === "function"} fallback={content()}>
        {untrack(() => content()(editable()))}
      </Show>
    </Show>);
}
