import { AllSelection, NodeSelection, TextSelection } from 'prosemirror-state';
export const isTextSelection = (selection) => selection instanceof TextSelection;
export const isNodeSelection = (selection) => selection instanceof NodeSelection;
export const isWholeSelection = (selection) => selection instanceof AllSelection;
export const get$Cursor = (selection) => {
    return isTextSelection(selection) ? selection.$cursor : null;
};
export function get$CursorAtBlockStart(selection) {
    const $cursor = get$Cursor(selection);
    if (!$cursor || $cursor.parentOffset > 0 || $cursor.parent.isInline)
        return null;
    return $cursor;
}
export const equalNodeType = function equalNodeType(nodeType, node) {
    return (Array.isArray(nodeType) && nodeType.indexOf(node.type) > -1) || node.type === nodeType;
};
export const findSelectedNodeOfType = (nodeType) => {
    return function (selection) {
        if (isNodeSelection(selection)) {
            const node = selection.node, $from = selection.$from;
            if (equalNodeType(nodeType, node)) {
                return { node: node, pos: $from.pos, depth: $from.depth };
            }
        }
        return null;
    };
};
//# sourceMappingURL=selection.js.map
