Search code examples
draftjs

Draft.js: Can I modify an existing entity without applying it as new one?


I'm trying to use Draft.js for a rich text editor, where the requirement is to be able to edit a link's url. In all examples I've seen, you can apply an entity to a selection range, but the entity already exists. I'd just like to change its value.

If it is impossible to change the url without re-applying, is there a good way to get the entity re-applied to the same range it is currently applied to?

Any help would be appreciated.


Solution

  • Modifier.applyEntity() does what you need. https://draftjs.org/docs/api-reference-modifier#applyentity