Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retain caret position while dynamically changing the rendered html #250

Open
tnrich opened this issue Nov 28, 2021 · 3 comments
Open

Retain caret position while dynamically changing the rendered html #250

tnrich opened this issue Nov 28, 2021 · 3 comments

Comments

@tnrich
Copy link

tnrich commented Nov 28, 2021

Hey there,

I'm wondering if anyone has a good solution for retaining the correct caret position when the html being rendered is being changed dynamically (such as adding classes to certain elements or bolding/italicizing certain letters as the user types).

Here is the example codesandbox showing how the current library fails to retain the correct caret position as the incoming html changes:

https://codesandbox.io/s/simple-rich-text-editor-in-react-forked-q83ue?file=/src/index.js

In this example I'm modifying the class="yay" to add a 1 in front of it each time something changes. This causes the caret to jump to the end of the text.

Thanks for the help!

@GodAlmighty990
Copy link

Did you find a solution for this?

@khangt1k25
Copy link

I am facing exactly this problem: the caret jump to the end when typing. Did you find some ways to fix this?

@tybro0103
Copy link

bump

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

No branches or pull requests

4 participants