wxik / react-native-rich-editor

Lightweight React Native (JavaScript, H5) rich text editor
https://wxik.github.io/react-native-rich-editor/web
MIT License
805 stars 303 forks source link

Inconsistent Editor HTML Formatting and Cursor Behavior #320

Open psalishol opened 1 year ago

psalishol commented 1 year ago

Currently experiencing formatting issue with the editor in my React Native project. I've been trying to update the editor's HTML content dynamically without the cursor restarting from the content start.

Initially, I tried the following implementation:

ref.current.sendAction('content', 'setHtml', removeTag(text));

The action successfully updates the content, it also causes the cursor to reset to the beginning of the content, which is not the desired behavior.

Steps to Reproduce:

Expected Behavior:

When updating the HTML content of the editor, the cursor should remain at its current position without resetting to the beginning of the content.

Actual Behavior:

After updating the editor's content, the cursor resets to the start of the content, which is not the desired behavior.

Environment:

React Native version: 0.70.6
React version: 18.1.0
react-native-pell-rich-editor version: 1.9.0

Additional Information:

I have attempted to find an alternative solution or workaround, but haven't been successful so far. Any assistance or guidance on how to update the content without the cursor resetting would be greatly appreciated.

@stulip

allanrlima commented 12 months ago

I'm facing the same problem, any update on this?

@psalishol were you able to find a workaround?

mmjc29 commented 7 months ago

I found this issue too

when I am change the color before start input richText.current?.setForeColor(color);

the cursor will back to start point.