"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isLineNumbersVisible = isLineNumbersVisible;
exports.processChangedCodeBlocks = processChangedCodeBlocks;
const transaction_1 = require("../../../../utils/transaction.js");
const CodeBlockSpecs_1 = require("../CodeBlockSpecs/index.js");
/** @internal */
function isLineNumbersVisible(node) {
    return node.attrs[CodeBlockSpecs_1.CodeBlockNodeAttr.ShowLineNumbers] === 'true';
}
/** @internal */
function processChangedCodeBlocks(tr, decoSet, onCodeBlock) {
    decoSet = decoSet.map(tr.mapping, tr.doc);
    (0, transaction_1.forEachChangedNode)(tr, (node, pos) => {
        if (node.type.name !== CodeBlockSpecs_1.codeBlockNodeName) {
            if (node.isTextblock) {
                // Remove stale decorations from non-code_block textblocks
                // (e.g. when a code_block is converted to a paragraph)
                decoSet = decoSet.remove(decoSet.find(pos, pos + node.nodeSize));
                return false;
            }
            return true;
        }
        decoSet = onCodeBlock(node, pos, decoSet);
        return false;
    });
    return decoSet;
}
//# sourceMappingURL=utils.js.map
