Skip to content
This repository has been archived by the owner on Jun 15, 2021. It is now read-only.

UndoManager and a max length plugin #516

Open
muratpurc opened this issue Dec 18, 2017 · 0 comments
Open

UndoManager and a max length plugin #516

muratpurc opened this issue Dec 18, 2017 · 0 comments

Comments

@muratpurc
Copy link

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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant