ChatComposer (输入区)
聊天输入区:自动长高,Enter 发送 / Shift+Enter 换行(触屏反过来,可配置),markdown 快捷写法发出时转成 entities,回复 / 引用 / 编辑预览条,粘贴或拖入图片,接近 4096 字上限时显示计数,输入时节流发出 typing。
基础用法
草稿按 API 的形状存成 parseKunChatMarkdown(草稿),即 { text, entities }, 恢复时用 formatKunChatMarkdown 写回输入框——App 端不需要懂 markdown。
Basic.vue
回复、引用与编辑
ReplyEdit.vue
图片附件
点回形针选图,或把图片粘贴 / 拖到输入区。
Attachments.vue
长度上限
还可输入 114 字
Limit.vue
不可发送
对方已注销,无法继续发送消息
Disabled.vue
属性
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| accept | string | "image/*" | `accept` of the attach button's file picker. Pasted and dropped files are passed on unfiltered. |
| attachments | KunChatAttachment[] | [] | Photos being uploaded for this message, shown above the input. |
| disabled | boolean | false | Replace the input with `disabledText`, e.g. for a deleted peer. |
| disabledText | string | "" | Why sending is not possible, shown in place of the input. |
| editing | KunChatMessage | null | null | The message being edited. Setting it puts the message in the input (the draft is kept aside and comes back when editing ends); `edit` fires instead of `send`. |
| enterToSend | boolean | "auto" | "auto" | Enter sends and Shift+Enter breaks the line, or the reverse. `auto`: Enter sends with a fine pointer, breaks the line on a touch screen. |
| maxLength | number | 4096 | Longest message, counted on the parsed text. The counter shows in the last 200. |
| maxRows | number | 8 | Growth limit of the input, in lines, before it scrolls. |
| modelValue | string | "" | The input as typed, shortcuts included. Keep a draft as `parseKunChatMarkdown(value)` and restore it with `formatKunChatMarkdown`. |
| placeholder | string | locale chatComposer.placeholder | Placeholder text. |
| quote | KunChatReplyQuote | null | null | The quoted part of `replyTo`, from the message menu's `quote`. |
| replyTo | KunChatMessage | null | null | The message being replied to; the bar above the input shows it. Cleared on send and on cancel. |
| users | KunChatUser[] | [] | Users, to name whoever a reply is to. |
事件
| 事件 | 回调参数 | 说明 |
|---|---|---|
| attach | files: File[] | Files were picked, pasted or dropped: upload them and list them in `attachments`. |
| edit | message: KunChatFormattedText, target: KunChatMessage | Save an edit of `target`. Editing ends and the draft comes back. |
| edit-last | — | ↑ in an empty input: start editing your last message, as Telegram Desktop does. |
| remove-attachment | key: string | The × of an attachment was clicked. |
| retry-attachment | key: string | A failed attachment (`error`) was clicked: upload it again. |
| send | message: KunChatFormattedText | Send a new message. The input is cleared and the reply consumed. |
| typing | — | The user is typing: at most once per 5 s, never while editing. Send the typing notification. |
| update:editing | value: KunChatMessage | null | |
| update:modelValue | value: string | |
| update:quote | value: KunChatReplyQuote | null | |
| update:replyTo | value: KunChatMessage | null |
插槽
| 插槽 | 作用域 | 说明 |
|---|---|---|
| #prefix | any | Before the input, after the attach button, e.g. an emoji button. |
| #suffix | any | After the input, before the send button. |