springload / draftail

📝🍸 A configurable rich text editor built with Draft.js
https://www.draftail.org/
MIT License
612 stars 64 forks source link

How to edit the text in editor with tooltip input? #400

Closed viperfx closed 4 years ago

viperfx commented 4 years ago

I am trying to create a plugin based on the Link plugin in this repo, that add another input to the tooltip for the text label. I was able to get this working by adding a label to the entity data, and showing this entity label as the text for the entity in the editor.

However, I think the better implementation would be to editor the editortext directly and modify the text.

I was able to find the modifytext and replacetext methods on draftjs, but I struggled with tying it together.

replaceText( contentState: ContentState, rangeToReplace: SelectionState, text: string, inlineStyle?: DraftInlineStyle, entityKey?: ?string ): ContentState

How would I get the ContentState for the range matched with the Entity I am modifying?