一、div的contenteditable属性中添加一个视频后就不能编辑了,为什么?
<!DOCTYPE HTML>
<html>
<body>
<div contenteditable="true">
<p>这是一段可编辑的段落。请试着编辑该文本。</p>
<p><span> </span><video class="dd-video" allowfullscreen="true" src="https://www.runoob.com/try/demo_source/movie.mp4" width="200" height="200" poster="https://pic1.zhimg.com/v2-b3678d6f6252e11f1903affe8524dd53_im.jpg" controls="true"><span contenteditable="false"></span></video><span> </span></p>
<p><img src="https://pic1.zhimg.com/v2-b3678d6f6252e11f1903affe8524dd53_im.jpg"></img></p>
</div>
</body>
</html>
在video前后加上 亲测可用
const GUARD_TEXT = '\uFEFF';
class Embed extends EmbedBlot {
constructor(scroll, node) {
super(scroll, node);
this.contentNode = document.createElement('span');
this.contentNode.setAttribute('contenteditable', false);
Array.from(this.domNode.childNodes).forEach(childNode => {
this.contentNode.appendChild(childNode);
});
this.leftGuard = document.createTextNode(GUARD_TEXT);
this.rightGuard = document.createTextNode(GUARD_TEXT);
this.domNode.appendChild(this.leftGuard);
this.domNode.appendChild(this.contentNode);
this.domNode.appendChild(this.rightGuard);
}
\uFEFF 也可以用
- 相关评论
- 我要评论
-