-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Copying message copy span html instead of text #22
Comments
Is there any way I can disable html pasting |
@GhazanfarKhan Thank you for your question. If you need to sanitize data pasted to <MessageInput />, you can use onPaste event handler. Here is simple example: const [ value, setValue ] = useState("");
return <MessageInput onChange={(val) => setValue(val)} value={value} onPaste={(evt) => {
evt.preventDefault();
setValue(evt.clipboardData.getData("text"));
}} /> Useful links: |
@supersnager thanks. |
Hi @supersnager Send button is disabled when do the above steps you describe. |
Hi @supersnager, send button is disabled while do pasting but when I type something it was undisabled. |
@GhazanfarKhan Internal state of a send button is tracked by onChange internal handler. Paste event, not invokes this handler. However, as a workaround, you can use the sendDisabled property of the <MessageInput /> component to handle the state of this button yourself: const [ value, setValue ] = useState("");
const [sendDisabled, setSendDisabled] = useState(true);
useEffect(() => {
setSendDisabled(value.length===0);
},[value]);
return <MessageInput sendDisabled={sendDisabled} onChange={(val) => setValue(val)} value={value} onPaste={(evt) => {
evt.preventDefault();
setValue(evt.clipboardData.getData("text"));
}} /> |
Thanks for this workaround. |
Hi, when you copy a message from message component it will copy html not the actual text. Attaching screenshot.
The text was updated successfully, but these errors were encountered: