diff --git a/content/plus/chat/index-en-US.md b/content/plus/chat/index-en-US.md index 8c92323222..59858657e2 100644 --- a/content/plus/chat/index-en-US.md +++ b/content/plus/chat/index-en-US.md @@ -1641,6 +1641,7 @@ render(DefaultChat); | topSlot | top slot for chat | React.ReactNode | - | | uploadProps | Upload component properties, refer to details [Upload](/en-US/input/upload#API%20%E5%8F%82%E8%80%83) | UploadProps | - | | uploadTipProps | Upload component prompt attribute, refer to details [Tooltip](/en-US/show/tooltip#API%20%E5%8F%82%E8%80%83) | TooltipProps | - | +| allowSend | Whether to allow sending text and files in the input box, controlled prop, default true | boolean | true | #### RoleConfig @@ -1692,4 +1693,4 @@ render(DefaultChat); ## Design Token - \ No newline at end of file + diff --git a/content/plus/chat/index.md b/content/plus/chat/index.md index 8ebf51aa37..1233495e30 100644 --- a/content/plus/chat/index.md +++ b/content/plus/chat/index.md @@ -1632,6 +1632,7 @@ render(DefaultChat); | onInputChange | 输入区域信息变化时触发 | (props: { value?: string, attachment?: FileItem[] }) => void; | - | | onMessageBadFeedback | 消息负向反馈时触发 | (message: Message) => void | - | | onMessageCopy | 复制消息时触发 | (message: Message) => void | - | +| allowSend | 是否允许输入框发送文本和文件,受控属性,默认 true | boolean | true | | onMessageDelete | 删除消息时触发 | (message: Message) => void | - | | onMessageGoodFeedback | 消息正向反馈时触发 | (message: Message) => void | - | | onMessageReset | 重置消息时触发 | (message: Message) => void | - | diff --git a/packages/semi-ui/chat/index.tsx b/packages/semi-ui/chat/index.tsx index dffbf3bec6..6277a1538e 100644 --- a/packages/semi-ui/chat/index.tsx +++ b/packages/semi-ui/chat/index.tsx @@ -66,6 +66,11 @@ class Chat extends BaseComponent { uploadTipProps: PropTypes.object, mode: PropTypes.string, markdownRenderProps: PropTypes.object, + /** + * 是否允许输入框发送文字消息和文件 + * 默认true,受控属性 + */ + allowSend: PropTypes.bool, }; static defaultProps = getDefaultPropsFromGlobalConfig(Chat.__SemiComponentName__, { @@ -386,6 +391,7 @@ class Chat extends BaseComponent { )} {/* input area */} { inputAreaRef: React.RefObject; @@ -64,7 +65,7 @@ class InputBox extends BaseComponent { } renderUploadButton = () => { - const { uploadProps, uploadRef, uploadTipProps, clickUpload } = this.props; + const { uploadProps, uploadRef, uploadTipProps, clickUpload, allowSend = true } = this.props; if (!clickUpload) { return null; } @@ -76,6 +77,7 @@ class InputBox extends BaseComponent { [className]: className }), onChange: this.foundation.onAttachmentAdd, + disabled: !allowSend, }; const uploadNode = { className={`${PREFIX_INPUT_BOX}-uploadButton`} icon={} theme='borderless' + disabled={!allowSend} />} ; return (uploadTipProps ? {uploadNode} : uploadNode); @@ -129,9 +132,10 @@ class InputBox extends BaseComponent { renderSendButton = () => { const disabledSend = this.foundation.getDisableSend(); + const { allowSend = true } = this.props; return (