lovasoa / react-contenteditable

React component for a div with editable contents
http://npmjs.com/package/react-contenteditable
Apache License 2.0
1.63k stars 218 forks source link

expose props API to enable selection range get & set #256

Open ibarapascal opened 2 years ago

ibarapascal commented 2 years ago

as title

current

currently, I guess it's not supported to customize the selectionRange to the contentEditable element.

ref.current.setSelectionRange(4, 6);

there are some cases like inserting some text to replace the current cursor's selected content as well as keeping the after cursor position at the addition end programmatically (controlled, bound with onChange handler).

enhancement

since we do have the method to manually get & set the range via the API, it would be much more convenient to do so with an exposed props API with the related function included.

related QA: https://stackoverflow.com/questions/6249095/how-to-set-the-caret-cursor-position-in-a-contenteditable-element-div

mahmedmushtaq commented 2 years ago

@team please add this feature