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

属性

属性类型默认值说明
acceptstring"image/*"`accept` of the attach button's file picker. Pasted and dropped files are passed on unfiltered.
attachmentsKunChatAttachment[][]Photos being uploaded for this message, shown above the input.
disabledbooleanfalseReplace the input with `disabledText`, e.g. for a deleted peer.
disabledTextstring""Why sending is not possible, shown in place of the input.
editingKunChatMessage | nullnullThe 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`.
enterToSendboolean | "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.
maxLengthnumber4096Longest message, counted on the parsed text. The counter shows in the last 200.
maxRowsnumber8Growth limit of the input, in lines, before it scrolls.
modelValuestring""The input as typed, shortcuts included. Keep a draft as `parseKunChatMarkdown(value)` and restore it with `formatKunChatMarkdown`.
placeholderstringlocale chatComposer.placeholderPlaceholder text.
quoteKunChatReplyQuote | nullnullThe quoted part of `replyTo`, from the message menu's `quote`.
replyToKunChatMessage | nullnullThe message being replied to; the bar above the input shows it. Cleared on send and on cancel.
usersKunChatUser[][]Users, to name whoever a reply is to.

事件

事件回调参数说明
attachfiles: File[]Files were picked, pasted or dropped: upload them and list them in `attachments`.
editmessage: KunChatFormattedText, target: KunChatMessageSave 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-attachmentkey: stringThe × of an attachment was clicked.
retry-attachmentkey: stringA failed attachment (`error`) was clicked: upload it again.
sendmessage: KunChatFormattedTextSend 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:editingvalue: KunChatMessage | null
update:modelValuevalue: string
update:quotevalue: KunChatReplyQuote | null
update:replyTovalue: KunChatMessage | null

插槽

插槽作用域说明
#prefixanyBefore the input, after the attach button, e.g. an emoji button.
#suffixanyAfter the input, before the send button.