springload / draftail

📝🍸 A configurable rich text editor built with Draft.js

Home Page:https://www.draftail.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Investigate whether changing selection on entity edit is good or bad

thibaudcolas opened this issue · comments

This comes from the early days of Draftail, and I've never been sure whether this is a terrible source of bugs or a positive addition.

if (!entityType.block) {
// TODO It seems strange to update the selection state when requesting an edit.
const entitySelection = DraftUtils.getEntitySelection(
editorState,
entityKey,
);
const nextState = EditorState.acceptSelection(
editorState,
entitySelection,
);
this.onChange(nextState);
}

Without this, there is a risk that editing an entity would only edit the few (or single) characters within the selection. So this is officially good!.