@blueking/chat-x 0.0.5 → 0.0.7

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 (85) hide show
  1. package/dist/components/ai-selection/ai-selection.vue.d.ts +2 -2
  2. package/dist/components/index.d.ts +2 -1
  3. package/dist/index.css +1 -1
  4. package/dist/index.js +6 -6
  5. package/dist/index.js.map +1 -1
  6. package/dist/mcp/generated/docs/activity-message.md +428 -0
  7. package/dist/mcp/generated/docs/ai-image.md +227 -0
  8. package/dist/mcp/generated/docs/ai-loading.md +129 -0
  9. package/dist/mcp/generated/docs/ai-selection.md +436 -0
  10. package/dist/mcp/generated/docs/animation-text.md +199 -0
  11. package/dist/mcp/generated/docs/assistant-message.md +424 -0
  12. package/dist/mcp/generated/docs/chat-container.md +402 -0
  13. package/dist/mcp/generated/docs/chat-input.md +625 -0
  14. package/dist/mcp/generated/docs/cite-content.md +138 -0
  15. package/dist/mcp/generated/docs/code-content.md +199 -0
  16. package/dist/mcp/generated/docs/common-error-content.md +70 -0
  17. package/dist/mcp/generated/docs/constants.md +216 -0
  18. package/dist/mcp/generated/docs/content-render.md +238 -0
  19. package/dist/mcp/generated/docs/delete-tool.md +188 -0
  20. package/dist/mcp/generated/docs/desc-panel.md +139 -0
  21. package/dist/mcp/generated/docs/execution-summary.md +126 -0
  22. package/dist/mcp/generated/docs/file-content.md +300 -0
  23. package/dist/mcp/generated/docs/file-upload-btn.md +174 -0
  24. package/dist/mcp/generated/docs/flow-message.md +305 -0
  25. package/dist/mcp/generated/docs/highlight-keyword.md +144 -0
  26. package/dist/mcp/generated/docs/image-content.md +178 -0
  27. package/dist/mcp/generated/docs/image-preview-group.md +181 -0
  28. package/dist/mcp/generated/docs/image-preview.md +224 -0
  29. package/dist/mcp/generated/docs/info-message.md +124 -0
  30. package/dist/mcp/generated/docs/key-value-content.md +124 -0
  31. package/dist/mcp/generated/docs/latex-content.md +196 -0
  32. package/dist/mcp/generated/docs/loading-message.md +171 -0
  33. package/dist/mcp/generated/docs/markdown-content.md +186 -0
  34. package/dist/mcp/generated/docs/markdown-latex.md +208 -0
  35. package/dist/mcp/generated/docs/markdown-mermaid.md +250 -0
  36. package/dist/mcp/generated/docs/mermaid-content.md +185 -0
  37. package/dist/mcp/generated/docs/message-container.md +534 -0
  38. package/dist/mcp/generated/docs/message-render.md +329 -0
  39. package/dist/mcp/generated/docs/message-tools.md +376 -0
  40. package/dist/mcp/generated/docs/messages.md +472 -0
  41. package/dist/mcp/generated/docs/overflow-tips.md +209 -0
  42. package/dist/mcp/generated/docs/reasoning-message.md +233 -0
  43. package/dist/mcp/generated/docs/reference-content.md +132 -0
  44. package/dist/mcp/generated/docs/scroll-btn.md +155 -0
  45. package/dist/mcp/generated/docs/selection-footer.md +75 -0
  46. package/dist/mcp/generated/docs/shortcut-btn.md +202 -0
  47. package/dist/mcp/generated/docs/shortcut-btns.md +264 -0
  48. package/dist/mcp/generated/docs/shortcut-render.md +418 -0
  49. package/dist/mcp/generated/docs/text-content.md +74 -0
  50. package/dist/mcp/generated/docs/theme.md +388 -0
  51. package/dist/mcp/generated/docs/tool-btn.md +254 -0
  52. package/dist/mcp/generated/docs/tool-message.md +217 -0
  53. package/dist/mcp/generated/docs/toolcall-render.md +299 -0
  54. package/dist/mcp/generated/docs/use-animation-text.md +198 -0
  55. package/dist/mcp/generated/docs/use-clipboard.md +206 -0
  56. package/dist/mcp/generated/docs/use-command-selection.md +128 -0
  57. package/dist/mcp/generated/docs/use-container-scroll.md +56 -0
  58. package/dist/mcp/generated/docs/use-custom-tab.md +122 -0
  59. package/dist/mcp/generated/docs/use-global-config.md +154 -0
  60. package/dist/mcp/generated/docs/use-menu-keydown.md +164 -0
  61. package/dist/mcp/generated/docs/use-message-group.md +175 -0
  62. package/dist/mcp/generated/docs/use-observer-visible-list.md +189 -0
  63. package/dist/mcp/generated/docs/use-parent-scrolling.md +46 -0
  64. package/dist/mcp/generated/docs/user-feedback.md +229 -0
  65. package/dist/mcp/generated/docs/user-message.md +347 -0
  66. package/dist/mcp/generated/index.json +1311 -0
  67. package/dist/mcp/index.d.ts +2 -0
  68. package/dist/mcp/index.js +42 -0
  69. package/dist/mcp/index.js.map +1 -0
  70. package/dist/mcp/server.d.ts +2 -0
  71. package/dist/mcp/server.js +43 -0
  72. package/dist/mcp/server.js.map +1 -0
  73. package/dist/mcp/tools/get-component-doc.d.ts +19 -0
  74. package/dist/mcp/tools/get-component-doc.js +60 -0
  75. package/dist/mcp/tools/get-component-doc.js.map +1 -0
  76. package/dist/mcp/tools/list-components.d.ts +35 -0
  77. package/dist/mcp/tools/list-components.js +147 -0
  78. package/dist/mcp/tools/list-components.js.map +1 -0
  79. package/dist/mcp/tools/search-docs.d.ts +14 -0
  80. package/dist/mcp/tools/search-docs.js +82 -0
  81. package/dist/mcp/tools/search-docs.js.map +1 -0
  82. package/dist/mcp/utils/doc-loader.d.ts +35 -0
  83. package/dist/mcp/utils/doc-loader.js +64 -0
  84. package/dist/mcp/utils/doc-loader.js.map +1 -0
  85. package/package.json +5 -7
@@ -0,0 +1,418 @@
1
+ <!-- AI SUMMARY -->
2
+ ## 快速了解
3
+
4
+ ShortcutRender 将 Shortcut.components 声明渲染为 bkui-vue Form,支持多种控件与两列网格、必填校验及提交/取消。 通常由 ChatContainer 等布局挂载在输入区旁,formModel 与快捷指令回填联动。 与 Shortcut、ShortcutBtn 等共享同一套快捷指令数据模型。
5
+
6
+ ### 关联组件
7
+ - **shortcut-btn** — 与快捷指令 Shortcut 元数据一致,表单提交前在列表中选中入口
8
+ - **chat-input** — 提交或取消后与输入框内容与状态联动
9
+ - **chat-container** — 顶层聊天布局中承载快捷表单区域
10
+
11
+ ---
12
+ <!-- FULL DOC -->
13
+
14
+ # ShortcutRender 快捷指令渲染器
15
+
16
+ > **层级**:分子组件 · **功能域**:输入交互
17
+
18
+ 快捷指令表单渲染组件,将 `Shortcut.components` 配置自动渲染为可交互表单(基于 bkui-vue 的 `Form`),支持 8 种控件类型、两列网格布局、必填校验和内置提交/取消操作。
19
+
20
+ ## 组件结构
21
+
22
+ ```
23
+ ┌─────────────────────────────────────────────────┐
24
+ │ .shortcut-render-header(渐变左边框) │
25
+ │ ✧ ThinkingIcon 快捷指令名称 ✕ Close │
26
+ ├─────────────────────────────────────────────────┤
27
+ │ .shortcut-render-content(max-height: 424px, │
28
+ │ overflow-y: auto) │
29
+ │ ┌─────────────┬─────────────┐ │
30
+ │ │ FormItem │ FormItem │ ← 两列网格 │
31
+ │ ├─────────────┴─────────────┤ │
32
+ │ │ textarea(span 2) │ ← 独占一行 │
33
+ │ ├─────────────────────────── ┤ │
34
+ │ │ 提交 取消(sticky) │ ← 底部始终可见 │
35
+ │ └─────────────────────────── ┘ │
36
+ └─────────────────────────────────────────────────┘
37
+ ```
38
+
39
+ > 底部操作栏使用 `position: sticky; bottom: 1px`,滚动长表单时始终固定在底部可见区域。
40
+
41
+ ## 基础用法
42
+
43
+ 传入 `name` 和 `components` 即可渲染一个快捷指令表单:
44
+
45
+ ```vue
46
+ <template>
47
+ <ShortcutRender
48
+ :name="shortcut.name"
49
+ :components="shortcut.components"
50
+ @close="handleClose"
51
+ @submit="handleSubmit"
52
+ />
53
+ </template>
54
+
55
+ <script setup lang="ts">
56
+ import { ShortcutRender, type Shortcut } from '@blueking/chat-x';
57
+
58
+ const shortcut: Shortcut = {
59
+ id: 'translate',
60
+ name: '翻译',
61
+ components: [
62
+ {
63
+ type: 'select',
64
+ key: 'targetLang',
65
+ name: '目标语言',
66
+ default: 'en',
67
+ options: [
68
+ { label: '英文', value: 'en' },
69
+ { label: '中文', value: 'zh' },
70
+ { label: '日文', value: 'ja' },
71
+ ],
72
+ },
73
+ {
74
+ type: 'textarea',
75
+ key: 'content',
76
+ name: '翻译内容',
77
+ fillBack: true,
78
+ placeholder: '请输入要翻译的内容',
79
+ rows: 4,
80
+ },
81
+ ],
82
+ };
83
+
84
+ const handleClose = () => console.log('关闭');
85
+ const handleSubmit = (formModel: Record<string, unknown>) => {
86
+ // { targetLang: 'en', content: '...' }
87
+ console.log('提交:', formModel);
88
+ };
89
+ </script>
90
+ ```
91
+
92
+ **渲染效果**
93
+
94
+ ## 全部表单类型
95
+
96
+ `ShortcutRender` 支持 8 种控件类型,通过 `type` 字段指定:
97
+
98
+ ```vue
99
+ <script setup lang="ts">
100
+ import { type ShortcutComponent } from '@blueking/chat-x';
101
+
102
+ const components: ShortcutComponent[] = [
103
+ // 单行文本输入
104
+ { type: 'input', key: 'language', name: '编程语言', placeholder: '如:TypeScript、Python' },
105
+ // 数字输入(支持 min/max)
106
+ { type: 'number', key: 'maxLines', name: '最大行数', default: '50', min: 1, max: 500 },
107
+ // 下拉选择
108
+ {
109
+ type: 'select',
110
+ key: 'style',
111
+ name: '代码风格',
112
+ default: 'concise',
113
+ options: [
114
+ { label: '简洁', value: 'concise' },
115
+ { label: '详细注释', value: 'detailed' },
116
+ ],
117
+ },
118
+ // 单选组
119
+ {
120
+ type: 'radioGroup',
121
+ key: 'outputFormat',
122
+ name: '输出格式',
123
+ default: 'code',
124
+ options: [
125
+ { label: '代码块', value: 'code' },
126
+ { label: '文件', value: 'file' },
127
+ ],
128
+ },
129
+ // 多选组
130
+ {
131
+ type: 'checkboxGroup',
132
+ key: 'features',
133
+ name: '包含功能',
134
+ options: [
135
+ { label: '注释', value: 'comments' },
136
+ { label: '错误处理', value: 'error-handling' },
137
+ ],
138
+ },
139
+ // 开关
140
+ { type: 'switcher', key: 'async', name: '异步函数' },
141
+ // 多行文本(独占一行)
142
+ {
143
+ type: 'textarea',
144
+ key: 'description',
145
+ name: '功能描述',
146
+ fillBack: true,
147
+ rows: 3,
148
+ placeholder: '请详细描述需要生成的代码功能',
149
+ },
150
+ ];
151
+ </script>
152
+ ```
153
+
154
+ **渲染效果**
155
+
156
+ ## 表单初始值
157
+
158
+ ### 通过 `component.default`(推荐)
159
+
160
+ 直接在 `ShortcutComponent` 上设置 `default`,该字段在表单初始化时被优先使用:
161
+
162
+ ```typescript
163
+ const components: ShortcutComponent[] = [
164
+ {
165
+ type: 'select',
166
+ key: 'lang',
167
+ name: '语言',
168
+ default: 'zh', // ← 初始选中"中文"
169
+ options: [
170
+ { label: '中文', value: 'zh' },
171
+ { label: '英文', value: 'en' },
172
+ ],
173
+ },
174
+ ];
175
+ ```
176
+
177
+ ### 通过 `formModel` prop
178
+
179
+ `formModel` 适合传入**不在 `components` 中的额外字段**,或特殊场景下的外部初始值。
180
+
181
+ ```vue
182
+ <template>
183
+ <ShortcutRender
184
+ name="搜索"
185
+ :components="components"
186
+ :form-model="initialValues"
187
+ @submit="handleSubmit"
188
+ />
189
+ </template>
190
+
191
+ <script setup lang="ts">
192
+ const components = [
193
+ { type: 'input', key: 'keyword', name: '关键词' },
194
+ {
195
+ type: 'select',
196
+ key: 'scope',
197
+ name: '范围',
198
+ options: [
199
+ { label: '全部', value: 'all' },
200
+ { label: '标题', value: 'title' },
201
+ ],
202
+ },
203
+ ];
204
+
205
+ // formModel 中与 components 同名的 key 会被 component.default 覆盖
206
+ // 若 component 没有设置 default,对应 formModel 的值也会被 undefined 覆盖
207
+ const initialValues = { keyword: 'Vue 3', scope: 'title' };
208
+ </script>
209
+ ```
210
+
211
+ **初始化优先级(`watchEffect` 执行顺序)**:
212
+
213
+ ```
214
+ ① 先写入 formModel 中的所有 key-value
215
+ ② 再遍历 components,对每个 component.key 写入:
216
+ component.default ?? component.props?.default ?? component.props?.modelValue
217
+ ```
218
+
219
+ > **注意**:步骤 ② 会覆盖步骤 ① 的值。若某个 component 没有设置 `default`,该 key 会被写入 `undefined`,**formModel 中对应的值会丢失**。因此,当 component 和 formModel 存在同名 key 时,应在 component 上设置 `default`,而非依赖 `formModel`。
220
+
221
+ ## 必填校验(fillBack)
222
+
223
+ `fillBack: true` 将表单项映射为 bkui-vue `Form.FormItem` 的 `required: true`,提交时若为空则阻止提交并展示错误提示:
224
+
225
+ ```typescript
226
+ const components: ShortcutComponent[] = [
227
+ {
228
+ type: 'input',
229
+ key: 'title',
230
+ name: '标题',
231
+ fillBack: true, // 必填
232
+ placeholder: '请输入标题',
233
+ },
234
+ {
235
+ type: 'textarea',
236
+ key: 'content',
237
+ name: '内容',
238
+ fillBack: true, // 必填
239
+ rows: 5,
240
+ },
241
+ {
242
+ type: 'select',
243
+ key: 'category',
244
+ name: '分类', // 选填(无 fillBack)
245
+ options: [
246
+ { label: '技术', value: 'tech' },
247
+ { label: '业务', value: 'biz' },
248
+ ],
249
+ },
250
+ ];
251
+ ```
252
+
253
+ > `fillBack` 同时具有语义作用:在 `ChatInput`/`UserMessage` 场景下,标记了 `fillBack: true` 的字段内容会被回填到对话输入框中。
254
+
255
+ ## 布局规则
256
+
257
+ 表单使用 **两列网格**(`grid-template-columns: repeat(2, 1fr)`)排列:
258
+
259
+ | 情况 | 占列数 |
260
+ | --------------------------------------------------------- | ------------------------- |
261
+ | `type === 'textarea'` | 始终 `span 2`(独占一行) |
262
+ | 最后一个 item,且前面所有 item 累计列数为偶数(独占新行) | `span 2` |
263
+ | 其他 | `auto`(占 1 列) |
264
+
265
+ ```
266
+ ┌─────────────┬─────────────┐
267
+ │ input │ number │ ← 各占半行
268
+ ├─────────────┴─────────────┤
269
+ │ textarea │ ← 独占一行
270
+ ├─────────────┬─────────────┤
271
+ │ select │ switcher │ ← 各占半行
272
+ ├─────────────┴─────────────┤
273
+ │ 最后一个(奇数起新行) │ ← 自动独占
274
+ └───────────────────────────┘
275
+ ```
276
+
277
+ ## 透传底层组件 props
278
+
279
+ 通过 `component.props` 可直接透传给 bkui-vue 底层控件,`component.props.options` 优先于 `component.options`:
280
+
281
+ ```typescript
282
+ const components: ShortcutComponent[] = [
283
+ {
284
+ type: 'select',
285
+ key: 'lang',
286
+ name: '语言',
287
+ // 方式一:通过 component.options(常规)
288
+ options: [{ label: '中文', value: 'zh' }],
289
+ // 方式二:通过 component.props(优先级更高,覆盖 options)
290
+ props: {
291
+ options: [{ label: '英文', value: 'en' }], // 此处会覆盖上面的 options
292
+ clearable: true, // 透传给 bkui-vue Select 的其他 prop
293
+ },
294
+ },
295
+ {
296
+ type: 'input',
297
+ key: 'text',
298
+ name: '文本',
299
+ props: {
300
+ clearable: true, // 透传给 bkui-vue Input
301
+ maxlength: 100,
302
+ },
303
+ },
304
+ ];
305
+ ```
306
+
307
+ 通过 `component.formItemProps` 透传给 `Form.FormItem`:
308
+
309
+ ```typescript
310
+ {
311
+ type: 'input',
312
+ key: 'email',
313
+ name: '邮箱',
314
+ formItemProps: {
315
+ description: '请输入有效的邮箱地址', // bkui-vue FormItem 的 description prop
316
+ },
317
+ }
318
+ ```
319
+
320
+ ## API
321
+
322
+ ### Props
323
+
324
+ | 属性名 | 类型 | 默认值 | 说明 |
325
+ | ----------- | ------------------------- | ------ | -------------------------------------------------------------------- |
326
+ | id | `string` | — | 快捷指令唯一标识(透传,不影响表单渲染) |
327
+ | name | `string` | — | 表单标题,显示在头部栏 |
328
+ | description | `string` | — | 快捷指令描述(透传,组件内部不渲染) |
329
+ | components | `ShortcutComponent[]` | — | 表单控件配置列表 |
330
+ | formModel | `Record<string, unknown>` | — | 外部初始值;与 `components` 同名 key 时,以 `component.default` 为准 |
331
+
332
+ ### Events
333
+
334
+ | 事件名 | 参数 | 触发时机 |
335
+ | ------ | -------------------------------------- | ------------------------------------------ |
336
+ | close | — | 点击头部关闭图标 **或** 底部取消按钮时触发 |
337
+ | submit | `(formModel: Record<string, unknown>)` | 表单校验通过后点击提交按钮触发 |
338
+
339
+ ## ShortcutComponent 配置项
340
+
341
+ ### 通用字段
342
+
343
+ | 字段 | 类型 | 必填 | 说明 |
344
+ | ------------- | ------------------------------------ | ---- | ------------------------------------------------------------------------------------------ |
345
+ | type | 见[表单类型](#表单组件类型) | ✓ | 控件类型;未知类型返回 `null`,不渲染 |
346
+ | key | `string` | ✓ | 表单字段名;`submit` 事件返回对象以此为 key;同时作为校验 property |
347
+ | name | `string` | — | 表单项标签(`Form.FormItem` 的 `label`) |
348
+ | default | `string` | — | 字段初始值;优先于 `formModel`,在 `watchEffect` 中覆盖写入 |
349
+ | fillBack | `boolean` | — | `true` 时映射为 `required: true`(必填校验),同时标记回填语义 |
350
+ | placeholder | `string` | — | 占位文本(`input` / `textarea` / `number` 可用) |
351
+ | rows | `number` | — | 文本行数(`textarea` 可用) |
352
+ | min | `number` | — | 最小值(`number` 可用) |
353
+ | max | `number` | — | 最大值(`number` 可用) |
354
+ | options | `{ label: string; value: string }[]` | — | 选项列表(`select` / `radioGroup` / `checkboxGroup` 需要);`component.props.options` 优先 |
355
+ | props | `object` | — | 直接透传给底层 bkui-vue 控件的 props;`options` 优先于 `component.options` |
356
+ | formItemProps | `object` | — | 直接透传给 `Form.FormItem` 的 props |
357
+
358
+ ### 表单组件类型
359
+
360
+ | `type` | 底层控件 | 说明 |
361
+ | --------------- | ---------------------- | ---------------------------- |
362
+ | `input` | `Input` | 单行文本输入框 |
363
+ | `text` | `Input` | 同 `input`,兼容旧版写法 |
364
+ | `textarea` | `Input[type=textarea]` | 多行文本,**始终独占一行** |
365
+ | `number` | `Input[type=number]` | 数字输入,支持 `min` / `max` |
366
+ | `select` | `Select` | 下拉选择,需配置 `options` |
367
+ | `radioGroup` | `Radio.Group` | 单选组,需配置 `options` |
368
+ | `checkboxGroup` | `Checkbox.Group` | 多选组,需配置 `options` |
369
+ | `switcher` | `Switcher` | 开关,值为 `boolean` |
370
+ | 其他 | — | 返回 `null`,不渲染任何控件 |
371
+
372
+ ## 类型定义
373
+
374
+ ```typescript
375
+ import type { Shortcut, ShortcutComponent } from '@blueking/chat-x';
376
+
377
+ interface Shortcut {
378
+ id?: string;
379
+ name?: string;
380
+ description?: string;
381
+ icon?: string | VNode | ((h: typeof h) => Component | VNode);
382
+ components?: ShortcutComponent[];
383
+ formModel?: Record<string, unknown>;
384
+ }
385
+
386
+ // ShortcutComponent 是各具体类型的联合类型
387
+ type ShortcutComponent =
388
+ | InputShortcutComponent
389
+ | TextShortcutComponent
390
+ | TextareaShortcutComponent
391
+ | NumberShortcutComponent
392
+ | SelectShortcutComponent
393
+ | RadioGroupShortcutComponent
394
+ | CheckboxGroupShortcutComponent
395
+ | SwitcherShortcutComponent;
396
+
397
+ // 所有类型共有字段(BaseShortcutComponent)
398
+ interface BaseShortcutComponent {
399
+ type: string;
400
+ key: string;
401
+ name?: string;
402
+ default?: string;
403
+ fillBack?: boolean;
404
+ placeholder?: string;
405
+ rows?: number;
406
+ min?: number;
407
+ max?: number;
408
+ options?: { label: string; value: string }[];
409
+ props?: Record<string, unknown>; // 透传给底层控件
410
+ formItemProps?: Record<string, unknown>; // 透传给 Form.FormItem
411
+ }
412
+ ```
413
+
414
+ ## 关联组件
415
+
416
+ - [ShortcutBtn](../atomic/shortcut-btn.md) — 与 Shortcut 数据模型一致的入口按钮
417
+ - [ChatInput](./chat-input.md) — 输入区与快捷指令流程联动
418
+ - [ChatContainer](./chat-container.md) — 顶层布局中挂载快捷表单
@@ -0,0 +1,74 @@
1
+ <!-- AI SUMMARY -->
2
+ ## 快速了解
3
+
4
+ TextContent 用 Vue 文本插值渲染纯文本气泡,不解析 HTML,适合简单提示与用户/助手纯文案。 需要 Markdown、代码块或公式时应改用 MarkdownContent 等富文本组件。
5
+
6
+ ### 关联组件
7
+ - **markdown-content** — 需要富文本时的替代方案
8
+ - **user-message** — 用户消息中纯文本内容展示
9
+
10
+ ---
11
+ <!-- FULL DOC -->
12
+
13
+ # TextContent 文本内容
14
+
15
+ > **层级**:原子组件 · **功能域**:辅助组件
16
+
17
+ 纯文本气泡组件,使用 Vue 文本插值渲染 `content`,天然防 XSS。
18
+
19
+ ## 组件结构
20
+
21
+ ```
22
+ div.text-content
23
+ display: flex; width: fit-content
24
+ padding: 8px 12px; border-radius: 4px
25
+ background-color: #e1ecff(浅蓝色气泡)
26
+ word-break: break-all(无空格长文本按字符换行)
27
+
28
+ └── {{ content }}(文本插值,HTML 标签不被解析)
29
+ ```
30
+
31
+ > **换行说明**:组件无 `white-space: pre-wrap`,`\n` 不会渲染为视觉换行。如需保留换行,需在外层添加 `white-space: pre-wrap` 样式。
32
+
33
+ ## 基础用法
34
+
35
+ ```vue
36
+ <template>
37
+ <TextContent content="这是一条纯文本消息" />
38
+ </template>
39
+
40
+ <script setup lang="ts">
41
+ import { TextContent } from '@blueking/chat-x';
42
+ </script>
43
+ ```
44
+
45
+ ## 长文本自动换行
46
+
47
+ `word-break: break-all` 确保无空格的长字符串(如 URL、哈希值)也能在容器内正常换行:
48
+
49
+ ## XSS 安全
50
+
51
+ `content` 使用 `{{ }}` 文本插值渲染,HTML 标签会被转义,不会执行脚本:
52
+
53
+ ## API
54
+
55
+ ### Props
56
+
57
+ | 属性名 | 类型 | 必填 | 说明 |
58
+ | ------- | -------- | ---- | ---------------------------------------------- |
59
+ | content | `string` | 是 | 要显示的文本内容;空字符串时气泡仍渲染,无内容 |
60
+
61
+ ## 使用场景
62
+
63
+ `TextContent` 为极简的文本气泡,适用于**不需要 Markdown 渲染**的纯文本展示场景。如需富文本,使用 `MarkdownContent` 组件。
64
+
65
+ | 场景 | 推荐组件 |
66
+ | --------------------------------- | ----------------- |
67
+ | 纯文本气泡(用户消息、简单提示) | `TextContent` |
68
+ | 含 Markdown / 代码块 / 公式的内容 | `MarkdownContent` |
69
+ | 工具调用结果描述 | `DescPanel` |
70
+
71
+ ## 关联组件
72
+
73
+ - [MarkdownContent](./markdown-content.md) — 富文本替代
74
+ - [UserMessage](../molecular/user-message.md) — 用户消息气泡