Open pluderes opened 1 month ago
I think this is a difficult task to accomplish. Imagine that when you insert, you will have a table of ten cells with one character in each cell. Limit 8. How will Jodit decide what to delete? Cells? Entire row or table? Maybe the whole column.
In my case. I create a func in event onChange. In this func, I use for loop to check each char input value and a few var like this:
This is my func:
function truncateContent(s, maxLength) { let isTag = false; let result = ''; let charCount = 0; let isSpecialChar = false;
for (let i = 0; i < s.length; i++) {
if (s[i] === '<') {
isTag = true;
}
if (s[i] === '&' && s[i + 5] === ';') {
isSpecialChar = true;
}
if (s[i] === '>') {
isTag = false;
}
if (!isTag && !isSpecialChar && s[i] !== ' ' && s[i] !== " " && s[i] !== ">") charCount++;
if (s[i] === ';' && s[i - 5] === '&') {
isSpecialChar = false;
}
if (charCount <= maxLength) result += s[i];
if (charCount > maxLength) break;
}
if (isTag) result += '>';
return result
}
Jodit Version: 1.3.39
Browser: Chrome/IE/Safary/FF OS: Windows/Mac/Linux Is React App: True Reproduced on xdsoft.net:
Hello, thanks for created Jodit. I have an issue when i use event paste. I set limitChars = 2000. when i have 1998 chars in text editor and i want paste a string with length > 2, jodit will remove it and keep prev value
Expected behavior: Accept paste value to fit limitChars Actual behavior: Remove value want to paste, keep prev value