Update the decorators in componentDidUpdate
See original GitHub issueDescribe the feature
For now, the decorators are set in componentDidMount https://github.com/draft-js-plugins/draft-js-plugins/blob/9e97f6ce488dbc20c24a0440a6336f366003683a/packages/editor/src/Editor/index.tsx#L103
But there are not reset on update https://github.com/draft-js-plugins/draft-js-plugins/blob/9e97f6ce488dbc20c24a0440a6336f366003683a/packages/editor/src/Editor/index.tsx#L114
So there is no way to dynamically update the decorator as described in the documentation: https://draftjs.org/docs/advanced-topics-decorators#setting-new-decorators
I could be good to update the decorators also in componentDidUpdate.
What do you think?
Motivation
I am trying to implement a plugin to show the cursor of other users in the context of a collaborative editor. I have the cursor positions of the other users as SelectionState.
My cursor plugin is parametrized by these cursors and implement decorators which show these cursors in the text.
As the cursor position change over time, I need that the editor update its decorator accordingly.
Here is another example of dynamic decorator which seems not doable with draft-js-plugins (highlight search text) https://reactrocket.com/post/draft-js-search-and-replace/
Did I miss something?
Possible implementations
Related Issues
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:8 (1 by maintainers)

Top Related StackOverflow Question
I had an issue with a decorator, whose purpose is basically displaying a drop-down. When sie options change, i get a new decorator instance. But this new instance is not used because the decorators are only applied in
componentDidMount. I worked around it by replacing my decorators directly withEditorState.set, but it took me quite a long time to figure it out. For me it was not obvious, that the decorators are not updated when the props change.