UndoManager and a max length plugin
muratpurc opened this issue · comments
Hi,
I've implemented a simple max length plugin for scribe, the idea is to undo the last action/entry of the user, if the content of the editor has exceeded a defined max length. The state of the plugin is rudimentary yet, but it shows my current problem.
The idea is to do a max length check within the 'content-changed'
event, and it works fine so far.
But, when I write fast and the length of the editor content crosses the max length, the execution of scribe.undoManager.undo();
results in wrong position of the caret. It jumps to somewhere else, but should stay where it was before, which is usually the last position when typing.
You can see an example here:
https://codepen.io/anon/pen/eyJMKB
Just start to type something, the backround of the editor will switch to a light blue color and the caret will jump to the beginning from time to time.
This happens in latest Chrome and in latest Firefox. Any ideas how to solve this issue?