[英]Contenteditable prevent caret placement after a certain element
I have a certain contenteditable div, inside this div I have some tags that are immediately followed by tags so it will be like this 我有一个特定的contenteditable div,在这个div中,我有一些标签,标签后面紧跟着标签,因此它将像这样
<span class="formatting-holder"></span>
|<b></b>|
<span class="formatting-holder-close"></span>
The | | character denote the places where I need to prevent the caret from being positioned, the caret should only be placed inside the
<b></b>
but not between the <span>
and the <b>
. 字符表示我需要防止插入符号放置的位置,插入符号应仅放置在
<b></b>
而不能放置在<span>
和<b>
。
Is there a way to do this? 有没有办法做到这一点?
One of the best ways to accomplish what you're after is by using CSS which displays your "|" 达成目标的最好方法之一是使用显示“ |”的CSS characters and also prevents caret from being positioned on them
字符,还可以防止将插入符号放置在这些字符上
<span class="formatting-holder"></span>
<b></b>
<span class="formatting-holder-close"></span>
and in your CSS define this 然后在您的CSS中定义
.formatting-holder:before,
.formatting-holder:after {
content: "|";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.