import { useLexicalComposerContext } from "./LexicalComposerContext";
import { useLexicalEditable } from "./useLexicalEditable";
import { useCanShowPlaceholder } from "./shared/useCanShowPlaceholder";
import { useDecorators } from "./shared/useDecorators";
import { usePlainTextSetup } from "./shared/usePlainTextSetup";
import { createMemo, Show, untrack } from "solid-js";
export function PlainTextPlugin(params) {
    const [editor] = useLexicalComposerContext();
    const decorators = useDecorators(editor, params.errorBoundary);
    usePlainTextSetup(editor);
    return (<>
      {params.contentEditable}
      <Placeholder content={params.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>);
}
