dreamworld2007 2019-06-07 21:57
浏览 257

如何防止选择的文本在contenteditable中消失?

I am working on my code to select on the text in the contenteditable while I click on a button and select on a input box. I have got a problem with the selected text, because when I selected on the text and when I click on the button to display the modal and when I click on the input textbox, the selected text in the contenteditable will get disappear everytime when I click on the input textbox.

I have tried this:

user-select: none;

It didn't work so here is the full code:

<div id="quickreply" class="reply-message" hidefocus="false" aria-label="Message Body" g_editable="true" role="textbox" aria-hidden="true" aria-multiline="true" contenteditable="true" tabindex="1" style="direction: ltr;min-height: 135px;width: 840px;padding-left: 25px;font-size: 13px;user-select: none;" itacorner="6,7:1,1,0,0">Some texts goes here</div>

<div id="insert-link" class="link" command="+link" data-toggle="tooltip" data-placement="bottom" title="" role="button" unselectable="on" style="user-select: none; align-items: center; border: none; display: inline-flex; justify-content: center; width: 26px; height: 26px; cursor: pointer; line-height: 20px; list-style: none; padding: 0 0 0 12px; position: relative; outline: none; z-index: 0;" data-original-title="Insert link ‪(Ctrl-K)‬"></div>

<div id="editlink_dialog" class="Kj-JD LW-JD" tabindex="0" role="dialog" aria-labelledby=":vm" style="left: 201.5px; top: 172.5px; user-select: none; display: flex;">

    <span style="position:relative;bottom: 2px;padding-right:1px;white-space:nowrap;" id="linkdialog-text-label">Text to display:&nbsp;</span>
    <input id="linkdialog-text" aria-labelledby="linkdialog-text-label" style="user-select: none; width: 80%;border: 1px solid #a9a9a9;">
</div>

What I'm expecting to achieve is when I select on the text in the contenteditable while I click on a button and select on a input box, I want to keep selected on the text in the contenteditable so I can change the text I want.

Can you please show me an example how I could do this?

Thank you.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 使用EMD去噪处理RML2016数据集时候的原理
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
    • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
    • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
    • ¥15 如何在炒股软件中,爬到我想看的日k线
    • ¥15 seatunnel 怎么配置Elasticsearch
    • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
    • ¥15 (标签-MATLAB|关键词-多址)
    • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
    • ¥500 52810做蓝牙接受端