Closed titocosta closed 1 year ago
@titocosta You need to get a reference to the contenteditable, and set the attribute manually. I answered how to get the reference in your previous question: https://github.com/chatscope/chat-ui-kit-react/issues/93#issuecomment-1504801333
If you already have the reference, you can set the attribute:
editorRef.current?.setAttribute("contenteditable", "plaintext-only");
However, I'm not sure if using contenteditable="plaintext-only" is a good idea because it's not supported in Firefox. Maybe it would be better to handle the "paste" event and clean pasted text by yourself? Here is how to do it: https://github.com/chatscope/chat-ui-kit-react/issues/82#issuecomment-1416852042
Also check this thread: https://github.com/chatscope/chat-ui-kit-react/issues/22#issuecomment-815653617
When I copy and paste into MessageInput, it picks up formatting and injects HTML tags into the strings. I prefer to keep the input field as text-only.
How can I inject the
contenteditable="plaintext-only"
attribute into the underlying contenteditable element?