perf: 模板参数输入: 删除多余的空格. error details: Param text cannot have new-line/tab characters or more than 4 consecutive spaces

dev/timezone
Lei OT 2 years ago
parent 31bc8ef139
commit cd0a1597fa

@ -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) => {

@ -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 } };
});

Loading…
Cancel
Save