In a text content exceeding 10M, it contains hundreds of thousands of blocks, with each block monitoring a series of events in real time (which can lead to excessive memory and CPU usage). However, there is actually room for optimization.
That is, by monitoring changes in selection to obtain the node path where the selection is located, only the blocks on the free node path execute some monitoring events.
In a text content exceeding 10M, it contains hundreds of thousands of blocks, with each block monitoring a series of events in real time (which can lead to excessive memory and CPU usage). However, there is actually room for optimization.
That is, by monitoring changes in selection to obtain the node path where the selection is located, only the blocks on the free node path execute some monitoring events.
Here is my solution: