import type { BuilderContextInterface } from '../context/types'; import type { BuilderBlock } from '../types/builder-block'; import { evaluate } from './evaluate/evaluate'; export function getBlockComponentOptions(block: BuilderBlock, context: Pick) { return { ...block.component?.options, ...(block as any).options, ...evaluateTextComponentTextOption(block, context) }; } const evaluateTextComponentTextOption = (block: BuilderBlock, context: Pick) => { if (block.component?.name === 'Text' && block.component.options?.text && typeof block.component.options.text === 'string') { return { ...block.component.options, text: block.component.options.text.replace(/{{([^}]+)}}/g, (_match: string, group: string) => (evaluate({ code: group, context, localState: context.localState, rootState: context.rootState, rootSetState: context.rootSetState }) as string)) }; } }