const isCodeMark = (mark) => mark.type.spec.code;
export function isInsideCode(state) {
    if (isInsideBlockCode(state))
        return 'block';
    if (isInsideInlineCode(state))
        return 'inline';
    return false;
}
export function isInsideBlockCode(state) {
    // it is enough to check only $from
    // when pasting, the content is inserted into a block with the type from $from
    return Boolean(state.selection.$from.parent.type.spec.code);
}
export function isInsideInlineCode(state) {
    // same as for block code
    const fromHasCodeMark = state.selection.$from.marks().some(isCodeMark);
    if (state.selection.empty) {
        return fromHasCodeMark || (state.storedMarks ?? []).some(isCodeMark);
    }
    return fromHasCodeMark;
}
//# sourceMappingURL=code.js.map
