-
Notifications
You must be signed in to change notification settings - Fork 21
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
Updates and the Cursor #1
Comments
So, this is only happening when html is being injected as the value, but works fine when the value={} is receiving just a string: http://g.recordit.co/HRoovYVz1K.gif Here's an example repo: https://github.com/acomito/collab-editor |
I have had the same problem. I decided to remove onChange for every change and fire it only when user press a Save button. But it can be applied to your situation as I understand. So, we need to find a way to move cursor inside a text box after every onChange. I recommend you to look into trymbowyg component. In mean time, I'll explore possibilities to move cursor via jQuery. |
Thanks @sochix. If it's helpful, I found it the same example app worked fine with react-medium-editor even with html as the value. I haven't had a chance to dig in and compare |
Yop ! |
The problem with cursor is deep inside trymbowyg core. So need time to investogate further |
Okay thanks for checking it out @sochix |
Nope. I don't have the time to work on Trumbowyg for now. |
@bhattjay I explored it a bit. The problem is deep inside the core of Trumbowyg. |
So on edit I populate the data props from incoming container component props and init my internal state value. On change I update the internal state value with the rich text (html) value - which does nothing to the cursor position since the data value is originally coming from props and state updates have no impact. When user hits save I take the value from state, since that is always up to date due to being sync'd with the onChanged event, and use that to update the DB. I am not sure if this is what @acomito meant but it works pretty well so far. |
Any update on this? |
Hey @acomito what did you end up doing. This is the best editor I found but this bug makes it unusable. I am looking for rich text editing plus View Source feature |
I managed an ugly workaround for this (which I'm hiding in this wrapper):
|
@tmoody460 |
I also had this issue and this was my solution:
The important part is in the data-prop |
@andreas0607 I don't understand what we achieve by assigning Cheers. |
@evg1n I don't remember exactly why I used this solution. In hindsight I should've written a reason for doing it that way, BUT what I imagine was the reason was probably mutations of the parent component causing rerenders of trumbowyg. |
I'm using this to build a collaborative editor. I am saving the document on every
onChange
that fires. This is all working well, when user #1 makes a change, it shows up on user #2's screen instantly (and vice versa). It's working great albeit one problem: whenever the component updates with new text, the cursor is sent back to the front of the input:http://g.recordit.co/j9VeyvM0ka.gif
Any idea how to avoid this but still have the text/contents update? I'll post an example repo shortly...
The text was updated successfully, but these errors were encountered: