facebookarchive / draft-js

A React framework for building text editors.
https://draftjs.org/
MIT License
22.57k stars 2.63k forks source link

The editor state got messed when i use decorator. #2528

Open jiel-microsoft opened 4 years ago

jiel-microsoft commented 4 years ago

Do you want to request a feature or report a bug? Bug

What is the current behavior? The editor state messed when i use decorator.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. You can use this jsfiddle to get started: https://jsfiddle.net/gmertk/e61z7nfa/. I want to create an editor with a Chinese speller. Therefore, I made a decorator to wrap the wrong characters with a dropdown, which allow the user to correct the sentence. But when it got the speller result and force update the decorate, then i input some characters, the content become unstable and messed. editor bug What might be the cause of this problem?

What is the expected behavior? The last result should be "太耗了!天气太耗了!你好", and the first two characters "太耗" should be wrapped.

Which versions of Draft.js, and which browser / OS are affected by this issue? Did this work in previous versions of Draft.js? draft-js = 0.11.4 browser = chrome OS = windows no testing for the previous versions.

camflan commented 3 years ago

I'm seeing the same mis-behavior with something much simpler. I'm using entities to add tokens into the input, using decorators to apply styling. With decorators for these entities, selection and text input become erratic and unusable. Without the decorator calling the callback for each range, everything is OK