facebookarchive / draft-js

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

Applying entity in decorator #1762

Open vaclav-zeman opened 6 years ago

vaclav-zeman commented 6 years ago

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

What is the current behavior? Scenario: When user writes a reserved word (in this case it's %promo%) into the editor, the word should became an entity (via Modifier.applyEntity) so I can later create validations if the reserved word is inputted more than once etc.

Simplified code is here - https://jsfiddle.net/m6z0xn4r/958/ (based on draft 0.10.5)

Basically decorator is just checking if the word is already an entity and if not, it tries to apply an entity to it. The problem is that it's throwing an error - Draft.min.js:11 Uncaught TypeError: Cannot read property 'getEntity' of undefined

I'm super lost right now as I spent way too much time trying to make it work so any help will be appreciated.

What is the expected behavior? No error thrown

Which versions of Draft.js, and which browser / OS are affected by this issue? Did this work in previous versions of Draft.js? 0.10.5

ramisalem commented 5 years ago

Up

ramisalem commented 5 years ago

Did You get the answer?

jasuperior commented 4 years ago

Yeah... would be nice to have an answer to this one... There seems to be no clear way documented anywhere on how to properly navigate these decorators.

zuffik commented 3 years ago

ffs choosing draft-js was the worst choice of my programming career...