0
我正在玩Ritch-Text Editor的mozilla示例介紹HERE。一切似乎都很好,但是當從網頁複製/粘貼簡單的文本時,它會添加大量不必要的html標記。例如,如果複製當前頁面的最後一行;文字恐怖將複製/粘貼到JS富文本編輯器
<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>
這使得文本編輯器幾乎沒用。如何強制編輯器只粘貼主要html標籤,如<b>
,<a>
等
或者粘貼標籤剝離文本。
問題是,這必須在粘貼到文本編輯器之前完成,因爲發送表單後,html標籤將與out編輯混合。