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

UndoManager and a max length plugin #516

@muratpurc

Description

@muratpurc

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions