I see that it has the variable instances in DraftEntity file , which contains helper functions
var instances: Map<string, DraftEntityInstance> = Map();
I have some questions
this._save = () => {
var entityKey = this.props.block.getEntityAt(0);
Entity.mergeData(entityKey, {content: this.state.texValue});
this.setState({
invalidTeX: false,
editMode: false,
texValue: null,
}, this._finishEdit);
};
this._finishEdit = () => {
this.props.blockProps.onFinishEdit(this.props.block.getKey());
};
Yeah, I'm pretty sure it does. You have to do a hack to get it to work. I do it myself by forcing the selection with .forceSelection to whatever the current selection is, which happens to cause a re-render. Not exactly nice, but works okay.
mergeData does not mutate contentState in any way, as entities are currently stored external to it. The state is unaware of any changes to entity data. This will change when entities are being moved into the content state.
@joehua87 Multiple editor instances pose no problem, as DraftEntity has an internal counter for entity ids.
@johanneslumpe is correct, this is a KP. We've been discussing moving entity data into ContentState or ContentBlock, which will necessitate triggering onChange and make this problem go away.
@ianstormtaylor's workaround should do the job for now. Sorry about that!
Going to close this issue since the workaround exists, but I'm putting together a task roadmap, and this will be on it.
@hellendag is this still the best work around?
I currently have a placeholderimage that I update and replace once the image is loaded.
Should I just do forceselection?
Most helpful comment
Yeah, I'm pretty sure it does. You have to do a hack to get it to work. I do it myself by forcing the selection with
.forceSelectionto whatever the current selection is, which happens to cause a re-render. Not exactly nice, but works okay.