import { TemplateDesc, CellValue, GenerateResult } from '../template-editor.interface'; import { InputConverter } from './input-converter.service'; export declare class GenerateService { private inputConverter; constructor(inputConverter: InputConverter); /** * 转义字符串 * @description * 转义是为了防止用户输入了占位符与模板中的占位符混淆 * 首先向用户输入添加转义字符,当完成全部替换操作后统一转义结果字符串 * 转义规则:(注释中加入的反斜杠是为了在注释中转义,请查看预览效果) * 1. \@\@ -> \@ * 2. \@$ -> $ * @param str 字符串 * @returns 转义后的字符串 */ private escape; /** * 向字符串中添加转义字符 * @param str 字符串 * @returns 处理后的字符串 */ private antiEscape; /** * 判断对象是否为片段类型 * @param obj 对象 * @returns 是否片段 */ isFragmentItem(obj: Object): boolean; /** * 推断编辑值的类型 * @description * 如果某个单元格只接受一种类型的值,那么其对应的值就一定是那种类型 */ inferItemType(curValue: CellValue): void; /** * 生成保存版本的当前编辑值 * @param curValue 当前编辑值 * @description 砍掉编辑器配置等不需要保存的部分 */ private reduceCurValue; /** * 执行生成替换 * @param template 当前模板 * @param templateDesc 当前模板描述 * @param curValue 当前编辑值 * @returns 生成结果 */ generate(template: string, templateDesc: TemplateDesc, curValue: CellValue): GenerateResult; /** * 进行片段占位符的替换 * @param html 待替换片段 * @param id 占位符标识 * @param item 编辑值 * @returns 替换后的新片段 */ private replaceFragmentItem; /** * 进行值占位符的替换 * @param html 待替换片段 * @param id 占位符标识 * @param item 编辑值 * @returns 替换后的新片段 */ private replaceValueItem; /** * 检查是否必填非法 * @description * 如果存在默认值且必填且用户未填写,则使用默认值 * @param item 编辑值 * @returns 若合法则返回null,否则返回错误信息 */ private checkRequired; }