diff --git a/package.json b/package.json index 01c422df..4c643536 100644 --- a/package.json +++ b/package.json @@ -74,6 +74,7 @@ "dependencies": { "@eeacms/volto-matomo": "6.0.0", "@microsoft/fetch-event-source": "2.0.1", + "dequal": "2.0.3", "fast-json-patch": "3.1.1", "highlight.js": "11.10.0", "luxon": "3.5.0", @@ -83,6 +84,10 @@ "react-textarea-autosize": "^8.5.3", "rehype-prism-plus": "1.6.0", "remark-gfm": "3.0.1", + "unist-util-visit": "5.0.0", "uuid": "10.0.0" + }, + "peerDependencies": { + "@plone/volto": ">18.0.0 < 19.0.0" } } diff --git a/src/ChatBlock/AutoResizeTextarea.jsx b/src/ChatBlock/AutoResizeTextarea.jsx index d1912040..32651960 100644 --- a/src/ChatBlock/AutoResizeTextarea.jsx +++ b/src/ChatBlock/AutoResizeTextarea.jsx @@ -7,12 +7,22 @@ import { SVGIcon } from './utils'; import SendIcon from './../icons/send.svg'; export default React.forwardRef(function AutoResizeTextarea(props, ref) { - const { onSubmit, isStreaming, enableMatomoTracking, persona, ...rest } = - props; + const { + onSubmit, + onFocus, + onChange = () => {}, + disableSubmit, + enableMatomoTracking, + persona, + ...rest + } = props; const [input, setInput] = React.useState(''); const handleSubmit = (e) => { e.preventDefault(); + if (disableSubmit) { + return + } const trimmedInput = input.trim(); if (trimmedInput) { if (enableMatomoTracking) { @@ -30,8 +40,13 @@ export default React.forwardRef(function AutoResizeTextarea(props, ref) { return ( <> setInput(e.target.value)} + onFocus={onFocus} + onChange={(e) => { + onChange(e); + setInput(e.target.value); + }} onKeyDown={(e) => { if (e.key === 'Enter' && !e.shiftKey) { handleSubmit(e); @@ -46,7 +61,7 @@ export default React.forwardRef(function AutoResizeTextarea(props, ref) {