@redocly/theme
Version:
Shared UI components lib
22 lines • 984 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCodeWalkthroughFileText = getCodeWalkthroughFileText;
const utils_1 = require("../../core/utils");
function getCodeWalkthroughFileText(file, state, inputsState) {
var _a;
const contentChunks = (_a = file === null || file === void 0 ? void 0 : file.content.flatMap((node) => getChunkText(node, state, inputsState))) !== null && _a !== void 0 ? _a : [];
return contentChunks.join('\n');
}
function getChunkText(node, state, inputsState) {
if (typeof node === 'string') {
const replacedNode = (0, utils_1.replaceInputsWithValue)(node, inputsState);
return [replacedNode];
}
else {
if (!(0, utils_1.matchCodeWalkthroughConditions)(node.condition || {}, state)) {
return [];
}
return node.children.flatMap((child) => getChunkText(child, state, inputsState));
}
}
//# sourceMappingURL=get-code-walkthrough-file-text.js.map