How does editable div limit the number of words?

problem description

do a chat editor, you can insert pictures and text, I am using a div,contenteditable set to true, need to limit the text 5000

the environmental background of the problems and what methods you have tried

tried using keypress and keyup,keydown, but the blocking default event of these methods cannot detect Chinese characters. Input can detect Chinese characters, but can"t stop input. If you use the method of replacing the html, value, this method is not easy to implement because of the mixing of graphics and text in the editor, the html tag characters that need to be inserted into html, text and characters such as can not be parsed into HTML.

related codes

/ / Please paste the code text below (do not replace the code with pictures)

what result do you expect? What is the error message actually seen?

Apr.28,2021

only limits the total length of Chinese characters and English letters and characters?
if it is that simple, then each time input, the method of detecting the length is triggered, and the last character is not removed if the length is exceeded.
use $('- sharpyoureditor'). Val (). Length ) to judge the length of a Chinese character. In this method, the length of a Chinese character is 1

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b405b0-2c520.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b405b0-2c520.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?