diff --git a/src/utils/commons.js b/src/utils/commons.js index 687cdc1..c6d548d 100644 --- a/src/utils/commons.js +++ b/src/utils/commons.js @@ -425,7 +425,10 @@ export const debounce = (func, wait, immediate) => { export const removeFormattingChars = (str) => { const regex = /[\r\n\t\v\f]/g; - return str.replace(regex, ' '); + str = str.replace(regex, ' '); + // Replace more than four consecutive spaces with a single space + str = str.replace(/\s{4,}/g, ' '); + return str; } export const olog = (text, ...args) => { diff --git a/src/views/Conversations/Online/Input/Template.jsx b/src/views/Conversations/Online/Input/Template.jsx index 3670aac..588553e 100644 --- a/src/views/Conversations/Online/Input/Template.jsx +++ b/src/views/Conversations/Online/Input/Template.jsx @@ -97,7 +97,7 @@ const InputTemplate = ({ mobile, disabled = false, invokeSendMessage }) => { const [activeInput, setActiveInput] = useState({}); const onInput = (tempItem, key, val, initObj) => { - const _val = removeFormattingChars(val); + const _val = removeFormattingChars(val); // Param text cannot have new-line/tab characters or more than 4 consecutive spaces setActiveInput((prev) => { return { ...prev, [tempItem.name]: { ...initObj, ...prev[tempItem.name], [key]: _val } }; });