@ibiz-template-plugin/ai-chat 0.0.116 → 0.0.118

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/index.es.js +20814 -15578
  2. package/dist/index.legacy.js +2 -2
  3. package/dist/polyfills.legacy.js +1 -1
  4. package/dist/style.css +2 -2
  5. package/dist/types/components/chat-back-bottom/chat-back-bottom.d.ts +5 -3
  6. package/dist/types/components/chat-container/chat-container.d.ts +25 -24
  7. package/dist/types/components/chat-file-preview/components/custom-chat-file-preview/custom-chat-file-preview.d.ts +19 -0
  8. package/dist/types/components/chat-file-preview/components/default-chat-file-preview/default-chat-file-preview.d.ts +19 -0
  9. package/dist/types/components/chat-group-topics/components/selected-mode-topic/selected-mode-topic.d.ts +21 -0
  10. package/dist/types/components/chat-group-topics/components/show-hidden-setting/show-hidden-setting.d.ts +17 -0
  11. package/dist/types/components/chat-group-topics/components/topic-batch-action/topic-batch-action.d.ts +21 -0
  12. package/dist/types/components/chat-messages/chat-messages.d.ts +10 -9
  13. package/dist/types/components/chat-messages/use-message-renderer.d.ts +89 -0
  14. package/dist/types/components/chat-net-disk/file-move-panel/file-move-panel.d.ts +27 -0
  15. package/dist/types/components/common/actions/actions.d.ts +29 -0
  16. package/dist/types/components/common/context-menu/context-menu.d.ts +34 -0
  17. package/dist/types/components/common/drawer/drawer.d.ts +6 -1
  18. package/dist/types/components/common/index.d.ts +9 -0
  19. package/dist/types/components/common/inline-editor/inline-editor.d.ts +13 -0
  20. package/dist/types/components/common/lazy-list-tree/lazy-list-tree.d.ts +31 -3
  21. package/dist/types/components/common/lazy-tree/lazy-tree.d.ts +46 -5
  22. package/dist/types/components/common/modal/modal.d.ts +37 -0
  23. package/dist/types/components/flat-chat-container/flat-chat-container.d.ts +5 -1
  24. package/dist/types/components/popup/popup.d.ts +2 -1
  25. package/dist/types/constants/index.d.ts +4 -0
  26. package/dist/types/controller/ai-chat/ai-chat.controller.d.ts +12 -0
  27. package/dist/types/controller/ai-topic/ai-topic.controller.d.ts +83 -5
  28. package/dist/types/controller/file-system/file-system.controller.d.ts +68 -1
  29. package/dist/types/controller/index.d.ts +1 -0
  30. package/dist/types/controller/overlay/drawer-overlay.controller.d.ts +9 -0
  31. package/dist/types/controller/overlay/index.d.ts +1 -0
  32. package/dist/types/controller/overlay/modal-overlay.controller.d.ts +47 -0
  33. package/dist/types/controller/overlay/overlay.controller.d.ts +7 -1
  34. package/dist/types/controller/tiptap/config/file-node-config.d.ts +3 -0
  35. package/dist/types/controller/tiptap/tiptap.controller.d.ts +50 -0
  36. package/dist/types/entity/chart-topic/chart-topic.d.ts +1 -0
  37. package/dist/types/entity/chat-message/chat-message.d.ts +1 -0
  38. package/dist/types/icons/eye-svg.d.ts +1 -0
  39. package/dist/types/icons/index.d.ts +3 -0
  40. package/dist/types/icons/move-file-svg.d.ts +1 -0
  41. package/dist/types/icons/new-folder-svg.d.ts +2 -0
  42. package/dist/types/icons/system-file/archive.d.ts +8 -0
  43. package/dist/types/icons/system-file/audio.d.ts +6 -0
  44. package/dist/types/icons/system-file/excel.d.ts +4 -0
  45. package/dist/types/icons/system-file/image.d.ts +8 -0
  46. package/dist/types/icons/system-file/index.d.ts +10 -0
  47. package/dist/types/icons/system-file/other.d.ts +2 -0
  48. package/dist/types/icons/system-file/ppt.d.ts +4 -0
  49. package/dist/types/icons/system-file/program.d.ts +18 -0
  50. package/dist/types/icons/system-file/text.d.ts +21 -0
  51. package/dist/types/icons/system-file/video.d.ts +11 -0
  52. package/dist/types/icons/system-file/word.d.ts +8 -0
  53. package/dist/types/interface/i-chat-container/i-chat-container.d.ts +6 -0
  54. package/dist/types/interface/i-chat-message/i-chat-message.d.ts +6 -0
  55. package/dist/types/interface/i-chat-options/i-chat-options.d.ts +6 -0
  56. package/dist/types/interface/i-file-system-options/i-file-system-options.d.ts +156 -3
  57. package/dist/types/interface/i-remote-resource/i-remote-resource.d.ts +6 -0
  58. package/dist/types/interface/i-tiptap/i-tiptap.d.ts +51 -0
  59. package/dist/types/interface/i-topic-options/i-topic-options.d.ts +50 -5
  60. package/dist/types/interface/index.d.ts +2 -1
  61. package/dist/types/locale/en/index.d.ts +18 -1
  62. package/dist/types/locale/zh-CN/index.d.ts +18 -1
  63. package/dist/types/utils/index.d.ts +1 -0
  64. package/dist/types/utils/util/system-file.d.ts +12 -0
  65. package/dist/types/utils/util/util.d.ts +2 -1
  66. package/package.json +2 -2
  67. package/dist/types/components/chat-editor/node/mention-node.d.ts +0 -3
  68. package/dist/types/components/chat-messages/use-virtual-list.d.ts +0 -156
  69. package/dist/types/components/chat-scrollbar/chat-scrollbar.d.ts +0 -102
@@ -1,6 +1,10 @@
1
1
  import { IFileItem } from '../i-file-item/i-file-item';
2
2
 
3
- interface IFileSystemParams {
3
+ /**
4
+ * @description 查询文件列表参数
5
+ * @interface IFileSystemListParams
6
+ */
7
+ interface IFileSystemListParams {
4
8
  sessionid: string;
5
9
  srfaiagent?: string;
6
10
  srfscope?: string;
@@ -9,28 +13,132 @@ interface IFileSystemParams {
9
13
  file_path?: string;
10
14
  only_dirs?: boolean;
11
15
  }
16
+ /**
17
+ * @description 上传文件参数
18
+ * @interface IFileSystemUploadParams
19
+ */
12
20
  interface IFileSystemUploadParams {
13
21
  sessionid: string;
14
22
  file_path: string;
15
23
  srfaiagent?: string;
16
24
  srfscope?: string;
17
25
  }
26
+ /**
27
+ * @description 新建目录参数
28
+ * @interface IFileSystemCreateParams
29
+ */
30
+ interface IFileSystemCreateParams {
31
+ sessionid: string;
32
+ file_path: string;
33
+ srfaiagent?: string;
34
+ srfscope?: string;
35
+ create_parents?: boolean;
36
+ timeout?: number;
37
+ }
38
+ /**
39
+ * @description 新建文件参数
40
+ * @interface IFileSystemWriteParams
41
+ */
42
+ interface IFileSystemWriteParams {
43
+ sessionid: string;
44
+ file_path: string;
45
+ content: string;
46
+ srfaiagent?: string;
47
+ srfscope?: string;
48
+ append?: boolean;
49
+ timeout?: number;
50
+ }
51
+ /**
52
+ * @description 移动文件参数
53
+ * @interface IFileSystemMoveParams
54
+ */
55
+ interface IFileSystemMoveParams {
56
+ sessionid: string;
57
+ src: string;
58
+ dst: string;
59
+ srfaiagent?: string;
60
+ srfscope?: string;
61
+ overwrite?: boolean;
62
+ create_parents?: boolean;
63
+ timeout?: number;
64
+ }
65
+ /**
66
+ * @description 删除文件参数
67
+ * @interface IFileSystemDeleteParams
68
+ */
69
+ interface IFileSystemDeleteParams {
70
+ sessionid: string;
71
+ file_path: string;
72
+ srfaiagent?: string;
73
+ srfscope?: string;
74
+ recursive?: boolean;
75
+ timeout?: number;
76
+ }
77
+ /**
78
+ * @description 读取文件参数
79
+ * @interface IFileSystemReadParams
80
+ */
81
+ interface IFileSystemReadParams {
82
+ sessionid: string;
83
+ file_path: string;
84
+ srfaiagent?: string;
85
+ srfscope?: string;
86
+ offset?: number;
87
+ length?: number;
88
+ binary?: boolean;
89
+ timeout?: number;
90
+ }
91
+ /**
92
+ * @description 文件操作结果对象
93
+ * @interface IFileSystemResult
94
+ */
95
+ interface IFileSystemResult {
96
+ ok: boolean;
97
+ action: 'MKDIR' | 'WRITE' | 'MOVE' | 'DELETE' | 'READ';
98
+ path: string;
99
+ transport: 'native' | 'command';
100
+ content?: string;
101
+ content_length?: number;
102
+ error?: {
103
+ code: string;
104
+ message: string;
105
+ };
106
+ }
18
107
  /**
19
108
  * @description 文件系统操作参数
20
109
  * @export
21
110
  * @interface IFileSystemOptions
22
111
  */
23
112
  export interface IFileSystemOptions {
113
+ /**
114
+ * @description 文件预览模式,默认值为DEFAULT
115
+ * @type {('DEFAULT' | 'CUSTOM')}
116
+ * @memberof IFileSystemOptions
117
+ */
118
+ filePreviewMode?: 'DEFAULT' | 'CUSTOM';
119
+ /**
120
+ * @description 获取自定义文件预览url
121
+ * @param {object} ctx
122
+ * @param {object} param
123
+ * @param {{ id: string; name: string; folder: string }} file
124
+ * @returns {*} {Promise<string>}
125
+ * @memberof IFileSystemOptions
126
+ */
127
+ getCustomFilePreviewUrl?(ctx: object, param: object, file: {
128
+ id: string;
129
+ name: string;
130
+ folder: string;
131
+ }): Promise<string>;
24
132
  /**
25
133
  * @description 获取文件清单
26
134
  * @memberof IFileSystemOptions
27
135
  */
28
- getFileList: (context: object, params: object, other: IFileSystemParams) => Promise<IFileItem | undefined>;
136
+ getFileList: (ctx: object, param: object, other: IFileSystemListParams) => Promise<IFileItem | undefined>;
29
137
  /**
30
138
  * @description 上传文件
31
139
  * @memberof IFileSystemOptions
32
140
  */
33
- uploadFile: (context: object, params: object, other: IFileSystemUploadParams) => Promise<{
141
+ uploadFile: (ctx: object, param: object, other: IFileSystemUploadParams) => Promise<{
34
142
  id: string;
35
143
  name: string;
36
144
  folder: string;
@@ -57,5 +165,50 @@ export interface IFileSystemOptions {
57
165
  * @memberof IFileSystemOptions
58
166
  */
59
167
  getImgContent(ctx: object, param: object, id: string, type: string, cat: string): Promise<string>;
168
+ /**
169
+ * @description 新建文件夹
170
+ * @param {object} ctx
171
+ * @param {object} param
172
+ * @param {IFileSystemCreateParams} other
173
+ * @returns {*} {Promise<IFileSystemResult>}
174
+ * @memberof IFileSystemOptions
175
+ */
176
+ createFolder(ctx: object, param: object, other: IFileSystemCreateParams): Promise<IFileSystemResult>;
177
+ /**
178
+ * @description 新建文件
179
+ * @param {object} ctx
180
+ * @param {object} param
181
+ * @param {IFileSystemWriteParams} other
182
+ * @returns {*} {Promise<IFileSystemResult>}
183
+ * @memberof IFileSystemOptions
184
+ */
185
+ createFile(ctx: object, param: object, other: IFileSystemWriteParams): Promise<IFileSystemResult>;
186
+ /**
187
+ * @description 移动文件夹/文件,包含文件夹/文件重命名均调用此接口
188
+ * @param {object} ctx
189
+ * @param {object} param
190
+ * @param {IFileSystemMoveParams} other
191
+ * @returns {*} {Promise<IFileSystemResult>}
192
+ * @memberof IFileSystemOptions
193
+ */
194
+ move(ctx: object, param: object, other: IFileSystemMoveParams): Promise<IFileSystemResult>;
195
+ /**
196
+ * @description 删除文件夹/文件
197
+ * @param {object} ctx
198
+ * @param {object} param
199
+ * @param {IFileSystemDeleteParams} other
200
+ * @returns {*} {Promise<IFileSystemResult>}
201
+ * @memberof IFileSystemOptions
202
+ */
203
+ delete(ctx: object, param: object, other: IFileSystemDeleteParams): Promise<IFileSystemResult>;
204
+ /**
205
+ * @description 读文件内容
206
+ * @param {object} ctx
207
+ * @param {object} param
208
+ * @param {IFileSystemReadParams} other
209
+ * @returns {*} {Promise<IFileSystemResult>}
210
+ * @memberof IFileSystemOptions
211
+ */
212
+ readFile(ctx: object, param: object, other: IFileSystemReadParams): Promise<IFileSystemResult>;
60
213
  }
61
214
  export {};
@@ -34,6 +34,12 @@ export interface IRemoteSession {
34
34
  * @memberof IRemoteSession
35
35
  */
36
36
  scope: string;
37
+ /**
38
+ * @description 智能体标识
39
+ * @type {string}
40
+ * @memberof IRemoteSession
41
+ */
42
+ context_code_name: string;
37
43
  }
38
44
  /**
39
45
  * @description 远程消息接口
@@ -0,0 +1,51 @@
1
+ import { NodeConfig } from '@tiptap/core';
2
+
3
+ /**
4
+ * @description TipTap扩展节点类型
5
+ * @export
6
+ * @enum {number}
7
+ */
8
+ export declare enum TipTapNodeType {
9
+ FILE = "file"
10
+ }
11
+ /**
12
+ * @description TipTap拖拽数据
13
+ * @export
14
+ * @interface ITipTapDropData
15
+ */
16
+ export interface ITipTapDropData {
17
+ /**
18
+ * @description 拖拽类型
19
+ * @type {TipTapNodeType}
20
+ * @memberof ITipTapDropData
21
+ */
22
+ type: TipTapNodeType;
23
+ /**
24
+ * @description 数据标识
25
+ * @type {string}
26
+ * @memberof ITipTapDropData
27
+ */
28
+ id: string;
29
+ /**
30
+ * @description 数据标题
31
+ * @type {string}
32
+ * @memberof ITipTapDropData
33
+ */
34
+ label: string;
35
+ }
36
+ /**
37
+ * 扩展的节点配置:在 Tiptap NodeConfig 基础上增加清洗相关配置
38
+ */
39
+ export interface TipTapNodeConfig extends NodeConfig {
40
+ /**
41
+ * @description 节点在 getHTML() 输出中的表示
42
+ * @param el 该节点对应的 DOM 元素
43
+ * @returns 指定的html字符串
44
+ */
45
+ getHTML?: (el: Element) => string;
46
+ /**
47
+ * @description 用于定位该节点 DOM 的选择器
48
+ * 不传时默认使用 [data-type="节点名"]
49
+ */
50
+ htmlSelector?: string;
51
+ }
@@ -4,6 +4,27 @@ import { IConfigService } from '../i-config-service/i-config-service';
4
4
  /**
5
5
  * @description 业务域数据
6
6
  * @export
7
+ * @interface IScopeOption
8
+ */
9
+ export interface IScopeOption {
10
+ /**
11
+ * @description 值
12
+ * @type {(string | number)}
13
+ * @memberof IScopeOption
14
+ */
15
+ id: string | number;
16
+ /**
17
+ * @description 文本
18
+ * @type {string}
19
+ * @memberof IScopeOption
20
+ */
21
+ text: string;
22
+ }
23
+ /**
24
+ * @description 业务域项数据
25
+ * @author tony001
26
+ * @date 2026-10-20 14:10:18
27
+ * @export
7
28
  * @interface IScopeItem
8
29
  */
9
30
  export interface IScopeItem {
@@ -14,11 +35,17 @@ export interface IScopeItem {
14
35
  */
15
36
  id: string | number;
16
37
  /**
17
- * @description 文本
18
- * @type {string}
38
+ * @description 是否显示
39
+ * @type {boolean}
19
40
  * @memberof IScopeItem
20
41
  */
21
- text: string;
42
+ visible: boolean;
43
+ /**
44
+ * @description 是否置顶
45
+ * @type {boolean}
46
+ * @memberof IScopeItem
47
+ */
48
+ istop: boolean;
22
49
  }
23
50
  /**
24
51
  * 会话分组数据
@@ -71,6 +98,18 @@ export interface ITopicGroupNode {
71
98
  * 显示文本
72
99
  */
73
100
  text: string;
101
+ /**
102
+ * @description 域节点是否显示(无存储记录默认 true),显隐由 UI 层控制
103
+ * @type {boolean}
104
+ * @memberof ITopicGroupNode
105
+ */
106
+ visible: boolean;
107
+ /**
108
+ * @description 域节点是否置顶(无存储记录默认 false)
109
+ * @type {boolean}
110
+ * @memberof ITopicGroupNode
111
+ */
112
+ istop: boolean;
74
113
  /**
75
114
  * 自定义分组子节点
76
115
  */
@@ -189,6 +228,12 @@ export interface ITopic {
189
228
  * @memberof ITopic
190
229
  */
191
230
  groupid?: string;
231
+ /**
232
+ * @description 绑定智能体标识
233
+ * @type {string}
234
+ * @memberof ITopic
235
+ */
236
+ context_code_name?: string;
192
237
  /**
193
238
  * 上下文
194
239
  *
@@ -235,10 +280,10 @@ export interface ITopicOptions extends ITopic {
235
280
  disableSelectScope?: boolean;
236
281
  /**
237
282
  * @description 域列表,当工作模式为WORKSPACE时必填
238
- * @type {IScopeItem[]}
283
+ * @type {IScopeOption[]}
239
284
  * @memberof ITopicOptions
240
285
  */
241
- scopeList?: IScopeItem[];
286
+ scopeList?: IScopeOption[];
242
287
  /**
243
288
  * @description 删除之前提示
244
289
  * @param {string} title
@@ -3,7 +3,7 @@ export type { IChat, IChatOptions } from './i-chat-options/i-chat-options';
3
3
  export type { IMessageItemProvider } from './i-message-item-provider/i-message-item-provider';
4
4
  export type { IPortalAsyncAction } from './i-portal-async-action/i-portal-async-action';
5
5
  export type { IChatToolbarItem } from './i-chat-toolbar-item/i-chat-toolbar-item';
6
- export type { ITopic, ITopicOptions, IScopeItem, IGroupItem, ITopicGroupNode, } from './i-topic-options/i-topic-options';
6
+ export type { ITopic, ITopicOptions, IScopeOption, IScopeItem, IGroupItem, ITopicGroupNode, } from './i-topic-options/i-topic-options';
7
7
  export type { IContainerOptions } from './i-container-options/i-container-options';
8
8
  export type { IChatThink } from './i-chat-think/i-chat-think';
9
9
  export type { IMaterial } from './i-material/i-material';
@@ -27,4 +27,5 @@ export type { IActionPanelContentProps, TActionPanelComponent, } from './i-actio
27
27
  export type { ISpeechRecognition } from './i-speech-recognition/i-speech-recognition';
28
28
  export type { IFile, IFileItem, IFileItemParams, IFileUploadPrams, } from './i-file-item/i-file-item';
29
29
  export type { IFileSystemOptions } from './i-file-system-options/i-file-system-options';
30
+ export { TipTapNodeType, type ITipTapDropData, type TipTapNodeConfig, } from './i-tiptap/i-tiptap';
30
31
  export * from './deep-research';
@@ -36,6 +36,7 @@ export declare const EN: {
36
36
  thinkThrough: string;
37
37
  stopThinking: string;
38
38
  thinking: string;
39
+ waitingReply: string;
39
40
  requestTimeout: string;
40
41
  unsupportedMessageType: string;
41
42
  me: string;
@@ -71,6 +72,8 @@ export declare const EN: {
71
72
  backfill: string;
72
73
  pinTop: string;
73
74
  unpin: string;
75
+ showHide: string;
76
+ batchManageScope: string;
74
77
  rename: string;
75
78
  deleteTopic: string;
76
79
  jumpMainView: string;
@@ -83,6 +86,7 @@ export declare const EN: {
83
86
  newCreateConversation: string;
84
87
  searchTopics: string;
85
88
  noTopic: string;
89
+ noScope: string;
86
90
  clearSession: string;
87
91
  clearSessionConfirmTip: string;
88
92
  clearSessionWithGroupConfirmTip: string;
@@ -91,8 +95,10 @@ export declare const EN: {
91
95
  batchDeleteConversation: string;
92
96
  batchDeleteSession: string;
93
97
  batchDeleteConversationConfirmTip: string;
94
- multiSelect: string;
98
+ batchManage: string;
99
+ batchManageConversation: string;
95
100
  selectedCount: string;
101
+ selectedScopeCount: string;
96
102
  cancelMultiSelect: string;
97
103
  unclassifiedTopic: string;
98
104
  newGroup: string;
@@ -159,4 +165,15 @@ export declare const EN: {
159
165
  size: string;
160
166
  type: string;
161
167
  folder: string;
168
+ move: string;
169
+ new: string;
170
+ newFile: string;
171
+ newFolder: string;
172
+ folderName: string;
173
+ cannotEmpty: string;
174
+ moveToNone: string;
175
+ moveToSelf: string;
176
+ moveToDescendant: string;
177
+ moveToSameParent: string;
178
+ fileAlreadyExists: string;
162
179
  };
@@ -36,6 +36,7 @@ export declare const ZH_CN: {
36
36
  thinkThrough: string;
37
37
  stopThinking: string;
38
38
  thinking: string;
39
+ waitingReply: string;
39
40
  requestTimeout: string;
40
41
  unsupportedMessageType: string;
41
42
  me: string;
@@ -71,6 +72,8 @@ export declare const ZH_CN: {
71
72
  backfill: string;
72
73
  pinTop: string;
73
74
  unpin: string;
75
+ showHide: string;
76
+ batchManageScope: string;
74
77
  rename: string;
75
78
  deleteTopic: string;
76
79
  jumpMainView: string;
@@ -83,6 +86,7 @@ export declare const ZH_CN: {
83
86
  newCreateConversation: string;
84
87
  searchTopics: string;
85
88
  noTopic: string;
89
+ noScope: string;
86
90
  clearSession: string;
87
91
  clearSessionConfirmTip: string;
88
92
  clearSessionWithGroupConfirmTip: string;
@@ -91,8 +95,10 @@ export declare const ZH_CN: {
91
95
  batchDeleteConversation: string;
92
96
  batchDeleteSession: string;
93
97
  batchDeleteConversationConfirmTip: string;
94
- multiSelect: string;
98
+ batchManage: string;
99
+ batchManageConversation: string;
95
100
  selectedCount: string;
101
+ selectedScopeCount: string;
96
102
  cancelMultiSelect: string;
97
103
  unclassifiedTopic: string;
98
104
  newGroup: string;
@@ -159,4 +165,15 @@ export declare const ZH_CN: {
159
165
  size: string;
160
166
  type: string;
161
167
  folder: string;
168
+ move: string;
169
+ new: string;
170
+ newFile: string;
171
+ newFolder: string;
172
+ folderName: string;
173
+ cannotEmpty: string;
174
+ moveToNone: string;
175
+ moveToSelf: string;
176
+ moveToDescendant: string;
177
+ moveToSameParent: string;
178
+ fileAlreadyExists: string;
162
179
  };
@@ -12,3 +12,4 @@ export { ChatStepParser } from './util/chat-step-parser';
12
12
  export { ChatUIActionParser } from './util/chat-ui-action-parser';
13
13
  export { ContentProtector } from './util/content-protector';
14
14
  export { TextUtil } from './util/util';
15
+ export { FileIcon, FolderIcon } from './util/system-file';
@@ -0,0 +1,12 @@
1
+ import { FunctionComponent } from 'preact';
2
+ import { folder } from '../../icons/system-file';
3
+
4
+ export { folder as FolderIcon };
5
+ /**
6
+ * 通用渲染组件:直接传入文件名渲染对应图标
7
+ *
8
+ * 用法:<FileIcon fileName="report.csv" />
9
+ */
10
+ export declare const FileIcon: FunctionComponent<{
11
+ fileName: string;
12
+ }>;
@@ -67,7 +67,8 @@ export declare function md2html(md: string): string;
67
67
  *
68
68
  * 支持嵌套 Map({key=value})、List([a, b])结构;true/false/null 还原为对应类型;
69
69
  * 纯数字还原为 number,但前导零(如 000000)视为原始字符串;
70
- * 值本身为合法 JSON 时(如 avatar=[{"name":"xx"}])优先按 JSON 解析。
70
+ * 值本身为合法 JSON 时(如 avatar=[{"name":"xx"}])优先按 JSON 解析;
71
+ * 值内包含成对 {...} 片段或英文逗号时做容错(整体保留在值中),避免结构错位丢数据。
71
72
  *
72
73
  * @param str - 待转换的原始字符串
73
74
  * @returns 解析后的 JavaScript 对象,格式非法时返回空对象
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibiz-template-plugin/ai-chat",
3
- "version": "0.0.116",
3
+ "version": "0.0.118",
4
4
  "description": "iBiz AI交互框插件",
5
5
  "type": "module",
6
6
  "main": "dist/index.es.js",
@@ -29,7 +29,7 @@
29
29
  "publish:local": "npm run build && npm publish --access public --registry=http://172.16.240.221:8081/repository/local/"
30
30
  },
31
31
  "dependencies": {
32
- "@ibiz-template-plugin/ibiz-file-previewer": "^0.0.26",
32
+ "@ibiz-template-plugin/ibiz-file-previewer": "^0.0.27",
33
33
  "@ibiz-template/scss-utils": "^0.0.2",
34
34
  "@preact/signals": "^1.2.1",
35
35
  "@tiptap/core": "^3.11.1",
@@ -1,3 +0,0 @@
1
- import { Node } from '@tiptap/core';
2
-
3
- export declare const MentionNode: Node<any, any>;
@@ -1,156 +0,0 @@
1
- import { RefObject } from 'preact';
2
- import { ReadonlySignal, Signal } from '@preact/signals';
3
-
4
- /**
5
- * 虚拟列表项
6
- *
7
- * @author zpc
8
- * @date 2026-09-20
9
- */
10
- export interface VirtualItem {
11
- /**
12
- * 数据源中的实际索引
13
- *
14
- * @type {number}
15
- */
16
- index: number;
17
- /**
18
- * 稳定 key(如 messageid),用于测量缓存
19
- *
20
- * @type {string}
21
- */
22
- key: string;
23
- /**
24
- * 该项在列表中的 top 偏移(累计高度)
25
- *
26
- * @type {number}
27
- */
28
- start: number;
29
- /**
30
- * 当前高度(实测或预估)
31
- *
32
- * @type {number}
33
- */
34
- size: number;
35
- /**
36
- * 绑定到项包裹元素的 ref,用于 ResizeObserver 实测高度
37
- *
38
- * @type {(el: HTMLElement | null) => void}
39
- */
40
- measureRef: (el: HTMLElement | null) => void;
41
- }
42
- export interface UseVirtualListOptions {
43
- /**
44
- * 总条数
45
- *
46
- * @type {number}
47
- */
48
- count: number;
49
- /**
50
- * 根据索引返回稳定 key(用于按 key 缓存实测高度,避免前插/删除时按下标错位)
51
- *
52
- * @type {(index: number) => string}
53
- */
54
- getItemKey: (index: number) => string;
55
- /**
56
- * 未渲染项的预估高度
57
- *
58
- * @type {(index: number) => number}
59
- */
60
- estimateSize: (index: number) => number;
61
- /**
62
- * 可视区上下各多渲染的条数
63
- *
64
- * @type {number}
65
- */
66
- overscan?: number;
67
- }
68
- export interface UseVirtualListResult {
69
- /**
70
- * 挂到滚动容器上的 ref
71
- *
72
- * @type {RefObject<HTMLDivElement>}
73
- */
74
- containerRef: RefObject<HTMLDivElement>;
75
- /**
76
- * 当前可视区内的虚拟项
77
- *
78
- * @type {VirtualItem[]}
79
- */
80
- virtualItems: VirtualItem[];
81
- /**
82
- * 整个列表的总高度(spacer 高度)
83
- *
84
- * @type {number}
85
- */
86
- totalSize: number;
87
- /**
88
- * 每项起始偏移的前缀和(长度 count + 1,最后一项为总高度)
89
- *
90
- * @type {number[]}
91
- */
92
- offsets: number[];
93
- /**
94
- * 取某下标的起始偏移(供滚动锚定使用)
95
- *
96
- * @type {(index: number) => number}
97
- */
98
- getOffset: (index: number) => number;
99
- /**
100
- * @description 恢复滚动条位置
101
- * @memberof UseVirtualListResult
102
- */
103
- restoreScrollPosition: () => void;
104
- /**
105
- * 响应式总高度:依赖测量版本号(实测高度回填)与条数,供自定义滚动条订阅
106
- *
107
- * @type {ReadonlySignal<number>}
108
- */
109
- totalSizeSignal: ReadonlySignal<number>;
110
- /**
111
- * 容器 scrollTop 信号(供自定义滚动条计算 thumb 位置)
112
- *
113
- * @type {Signal<number>}
114
- */
115
- scrollTopSignal: Signal<number>;
116
- /**
117
- * 容器可视高度信号
118
- *
119
- * @type {Signal<number>}
120
- */
121
- clientHeightSignal: Signal<number>;
122
- /**
123
- * 自定义滚动条拖动状态:拖动中跳过头部前插的 scrollTop 补偿,由滚动条按指针比例重映射接管
124
- *
125
- * @type {Signal<boolean>}
126
- */
127
- isDragging: Signal<boolean>;
128
- /**
129
- * 程序化设置滚动位置:同步 scrollTop 信号 + 直接写容器 scrollTop(clamp 到当前可滚动范围)
130
- *
131
- * @type {(top: number) => void}
132
- */
133
- setScrollTop: (top: number) => void;
134
- }
135
- /**
136
- * 动态高度虚拟列表 Hook
137
- *
138
- * ## 核心思想
139
- * 消息列表里每条消息高度都不同(markdown、代码块、图片、折叠、流式增长),
140
- * 若全部渲染 DOM 节点会随消息数线性增长导致卡顿。本 Hook 只渲染「视口内 + overscan」的消息:
141
- * - 用一条 `height: totalSize` 的 spacer div 撑起可滚动总高度;
142
- * - 每条消息用 `position:absolute + transform:translateY(start)` 定位到对应偏移;
143
- * - 已渲染项用 ResizeObserver 实测真实高度,未渲染项用 `estimateSize` 预估占位。
144
- *
145
- * ## 为什么按 key 缓存而非按下标
146
- * 消息会「头部前插」(加载历史)和「删除」,导致已有消息的数组下标整体平移。
147
- * 若按下标缓存实测高度,前插后所有测量值会错位。因此用 `getItemKey`(messageid)作为测量缓存的键。
148
- *
149
- * ## 数据流
150
- * scrollTop / clientHeight / measureVersion 三个信号变化 → useMemo 重算 offsets(前缀和)
151
- * → 二分查找可视区间 → 产出 virtualItems → 组件只渲染这些项。
152
- *
153
- * @author zpc
154
- * @date 2026-09-20
155
- */
156
- export declare const useVirtualList: (options: UseVirtualListOptions) => UseVirtualListResult;