在WYSIWYG编辑器中(基于 contenteditable div),我有代码确保在复制粘贴,正常输入等时不会在HTML中插入内联样式。但现在浏览器似乎想要与我更加紧密。假设我的HTML中有两个这样的段落
<p>This is the first paragraph |(cursor)</p>
<p>This is the second paragraph</p>
没有内联样式。但是,如果我现在按下&#34; 删除/退格&#34;加入这两段,Chrome决定这样做
<p>This is the first paragraph |(cursor)
<!-- Note the horrible inline styles -->
<span style="font-size: 13px; line-height: 19.53px;">
This is the second paragraph
</span>
</p>
有没有人知道如何在发生这种情况时阻止/检测?
答案 0 :(得分:2)
这是Webkit的问题。它也会影响CKEditor(http://dev.ckeditor.com/ticket/9998)。我报告了这些门票:
但是没有回应。
您无法在jsfiddle上复制此内容,因为需要将样式应用于这些段落。 E.g:
p { line-height: 1.5em; font-size: 12px; }
选中此项:http://jsfiddle.net/HHHak/2/
目前有两种可能的解决方案: