import { $isListItemNode } from '@lexical/list';
import { $patchStyleText } from '@lexical/selection';
import { $findMatchingParent } from '@lexical/utils';
import { $getSelection, $isRangeSelection } from 'lexical';
function isInsideListItem(node) {
    return $isListItemNode(node) || $findMatchingParent(node, (parent) => $isListItemNode(parent)) !== null;
}
export function syncListMarkerFormatStyle(editor, patch) {
    editor.update(() => {
        const selection = $getSelection();
        if (!$isRangeSelection(selection)) {
            return;
        }
        const nodes = selection.getNodes();
        const isListSelection = nodes.length > 0
            ? nodes.some((node) => isInsideListItem(node))
            : isInsideListItem(selection.anchor.getNode()) || isInsideListItem(selection.focus.getNode());
        if (!isListSelection) {
            return;
        }
        $patchStyleText(selection, patch);
    });
}
//# sourceMappingURL=list-marker-format.js.map