当状态变化时,反应可调的光标会跳到结束
我正在使用此库反应可触摸的
我有一个文本编辑区域,当状态在Redux中变化时,光标会跳到末尾。我希望光标留在编辑停止的位置,
<div className={classes.speaker} ref={myRef}>
<ContentEditable
key={position}
style={{
flex: 1,
display: 'flex',
flexWrap: 'wrap',
alignItems: 'center'
}}
innerRef={contentEditable}
html={html} // innerHTML of the editable div
disabled={!editMode} // use true to disable editing
className={holdingCtrlKey ? 'cursor-pointer' : ''}
onChange={e => {
autoSave(e);
}}
onClick={e => {
if (editMode) {
setEditingNow(true);
setStartingPoint({ ...e.target.dataset });
}
handleClick(e);
}}
tagName="div" // Use a custom HTML tag (uses a div by default)
/>
</div>
我可以在每个跨越中保存数据位置的跨度位置。 如何将光标保持在编辑停止的位置
您在图像中看到的,它会在状态更改后跳到末端
I am working with this Library react-contenteditable
I have a text editing area where when the state changes in the redux the cursor jumps to the end. i want the cursor to stay where editing stops
<div className={classes.speaker} ref={myRef}>
<ContentEditable
key={position}
style={{
flex: 1,
display: 'flex',
flexWrap: 'wrap',
alignItems: 'center'
}}
innerRef={contentEditable}
html={html} // innerHTML of the editable div
disabled={!editMode} // use true to disable editing
className={holdingCtrlKey ? 'cursor-pointer' : ''}
onChange={e => {
autoSave(e);
}}
onClick={e => {
if (editMode) {
setEditingNow(true);
setStartingPoint({ ...e.target.dataset });
}
handleClick(e);
}}
tagName="div" // Use a custom HTML tag (uses a div by default)
/>
</div>
i can get the position of the span as im saving data-position in every span.
How can i keep the cursor where editing stops
As you can see in the image it jumps to the end as soon as the state changes
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论