feat: 优化内容模板变量引用与换行展示

- 内容模板直接引用上游参数并自动维护运行参数

- 支持 Enjoy 变量标签编辑及中文变量显示

- 保留试运行与聊天运行页的模板输出换行
This commit is contained in:
2026-08-11 21:41:58 +08:00
parent fe41d62b8a
commit 765006747a
12 changed files with 419 additions and 67 deletions

View File

@@ -5,6 +5,8 @@ import {
findBackspaceTokenRange,
findTokenRangeAtCursor,
flattenParameterNames,
formatParamToken,
getTokenRanges,
insertTextAtCursor,
parseTokenParts,
splitTokenDisplay,
@@ -64,18 +66,21 @@ describe('paramToken utils', () => {
expect(result).toEqual([
{
dataType: undefined,
disconnected: false,
displayName: 'input',
name: 'input',
resolved: false,
},
{
dataType: undefined,
disconnected: false,
displayName: 'docs',
name: 'docs',
resolved: true,
},
{
dataType: undefined,
disconnected: false,
displayName: 'runtimeInput',
name: 'runtimeInput',
resolved: true,
@@ -178,4 +183,20 @@ describe('paramToken utils', () => {
expect(rightBoundary?.key).toBe('docs');
expect(leftBoundary?.key).toBe('docs');
});
it('should format and parse Enjoy parameter tokens', () => {
expect(formatParamToken('申请人', 'enjoy')).toBe('#(申请人)');
expect(getTokenRanges('申请:#(申请人)', 'enjoy')).toEqual([
{
start: 3,
end: 9,
text: '#(申请人)',
key: '申请人',
},
]);
});
it('should keep complex Enjoy expressions as editable text', () => {
expect(getTokenRanges('#(申请人 ?? 被申请人)', 'enjoy')).toEqual([]);
});
});