How to Realize Real-time Preservation of Rich Text Editor?

  node.js, question

The problem I am facing now is:
1. How to judge the change of content in Rich Text Editor
2. If the content of the text box changes, save it every five seconds.

My solution:
1. by comparing text.length, there is no guarantee that the characters are different.
2. By comparing strings, but if there is too much text, it will greatly affect performance.
Both of these judgments are realized through the timer setinterval.

And there is another problem:
How to get the last text and the next text? This judgment is actually always true.

As for how to monitor, the previous answer is basically the same idea. You can use a timer or monitor keyboard events.
As for how to compare strings equally or even large strings more efficiently, I think the most efficient way is probably the most primitive and simplest way provided by js, which is to judge equality a==b = B. Js String has provided you with enough capacity. Moreover, the methods or grammatical expressions provided by api inside will eventually be mapped to Rendering Engine for execution, which is fast enough.
You can refer to the answer on stackoverflow.