[英]Copy/paste into JS rich-text editor
I am playing with the mozilla example of Ritch-Text Editor introduced HERE . 我正在玩这里介绍的Ritch-Text Editor的mozilla示例。 Everything seems to be fine, but when copying/pasting a simple text from a webpage, it will add lots of unnecessary html tags. 一切似乎都很好,但是从网页复制/粘贴简单文本时,它将添加许多不必要的html标签。 For example, if copying the last line of the present page; 例如,如果复制当前页面的最后一行; the text horribly will be 文本将可怕地是
<p><span style="color: rgb(68, 68, 68); font-family: Arial, 'Liberation Sans',
'DejaVu Sans', sans-serif; font-size: 13px; line-height: 12px; text-align: left;
background-color: rgb(119, 119, 119); ">site design / logo © 2012 stack exchange
inc; user contributions licensed under </span><a
href="http://creativecommons.org/licenses/by-sa/3.0/" rel="license" style="
margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;
padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left:
0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px;
border-left-width: 0px; border-style: initial; border-color: initial; border-image:
initial; font-size: 13px; vertical-align: baseline; background-image: initial;
background-attachment: initial; background-origin: initial; background-clip:
initial; background-color: rgb(119, 119, 119); color: rgb(68, 68, 68); cursor:
pointer; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;
line-height: 12px; text-align: left; ">cc-wiki</a><span style="color:
rgb(68, 68, 68); font-family: Arial, 'Liberation Sans', 'DejaVu Sans',
sans-serif; font-size: 13px; line-height: 12px; text-align: left; background-color:
rgb(119, 119, 119); "> with </span><a
href="http://blog.stackoverflow.com/2009/06/attribution-required/" rel="license"
style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;
padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;
border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px;
border-left-width: 0px; border-style: initial; border-color: initial;
border-image: initial; font-size: 13px; vertical-align: baseline; background-image:
initial; background-attachment: initial; background-origin: initial; background-clip:
initial; background-color: rgb(119, 119, 119); color: rgb(68, 68, 68); cursor: pointer;
font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 12px;
text-align: left; ">attribution required</a></p>
This makes the text editor practically useless. 这使得文本编辑器实际上无用。 How to force the editor to paste only main html tags like <b>
, <a>
, etc 如何强制编辑器仅粘贴主要的html标签,例如<b>
, <a>
等
Or alternatively paste tag-stripped text. 或者,粘贴标签剥离的文本。
The issue is that this must be done before pasting into the text editor, because after sending the form, the html tags will be mixed with out edit. 问题是必须在粘贴到文本编辑器之前完成此操作,因为发送表单后,html标记将与未编辑混合在一起。
Most WYSIWYG Editors have an HTML possibility ( to write in html). 大多数所见即所得的编辑器都有HTML的可能性(用html编写)。 Check if your editor has it, and if it does just paste your data through that. 检查您的编辑器是否具有它,以及是否确实通过它粘贴了数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.