I have an editor that is supposed to have entities with the props name, color, start, end
. In the editor the text in positions denoted by start
and end
will be subsistuted by name
, and it will be rendered by a custom component with contentEditable=false
.
This works great with draftjs in general but there are a couple of issues:
- When moving the cursor with the keyboard arrows, the entities are skipped over, which is good. But when an entity is at the very end of the input and I try to move rightwards past it (either just with right arrow or with option or cmd + right) the cursor disappears and doesn't come back when I move left again.
- If I go right to the left of an entity and push shift + option + right arrow, the entity is selected as expected. But if I then press left arrow the cursor is also lost.
I could fix this by making sure there is always a whitespace after such a last entity, but that seems hacky and probably has edge cases.
Another option is to not use contentEditable=false
, but that creates other issues with my actual app, which has a more complicated entity component including a dropdown, and I will have to manually make sure the user can't change text inside the entities etc.
Here is a reproduction of the issue: https://codesandbox.io/s/competent-surf-st77i
Any ideas?
user-select: none
. You can make the childcolor: transparent
too, andcaret-color: black
to fix selection bhvr. – Raphaelraphaela