import { $isRootTextContentEmptyCurry } from "@lexical/text";
import { createEffect, createSignal, onCleanup } from "solid-js";
import { resolve } from "./utils";
export function useLexicalIsTextContentEmpty(editor, trim) {
    const [isEmpty, setIsEmpty] = createSignal(editor
        .getEditorState()
        .read($isRootTextContentEmptyCurry(editor.isComposing(), resolve(trim))));
    createEffect(() => {
        const cleanup = editor.registerUpdateListener(({ editorState }) => {
            const isComposing = editor.isComposing();
            const currentIsEmpty = editorState.read($isRootTextContentEmptyCurry(isComposing, resolve(trim)));
            setIsEmpty(currentIsEmpty);
        });
        onCleanup(cleanup);
    });
    return isEmpty;
}
