简体   繁体   English

复制/粘贴到JS RTF文本编辑器中

[英]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&nbsp;</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); ">&nbsp;with&nbsp;</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.

相关问题 将图像复制粘贴到JavaScript富文本编辑器中 - Copy-pasting image into JavaScript rich-text editor 创建富文本编辑器界面 - Creating a rich-text editor interface 阻止复制/粘贴将网页样式复制到RTF编辑器 - Prevent a copy/paste to copy the style of a web page to a Rich Text Editor 在包含富文本编辑器的HTML小节中限制Javascript - Restrict Javascript in subsection of HTML containing rich-text editor 在RTF编辑器中覆盖IE电子邮件自动格式化 - Override IE email auto-formatting in rich-text editor 在制作富文本/所见即所得编辑器时,Contenteditable div与iframe - Contenteditable div vs. iframe in making a rich-text/wysiwyg editor 复制和粘贴富文本编辑器使用tinymce添加了额外的标记和大字体 - Copy and Paste rich text editor adds extra markup and large fonts with tinymce 如何保存 <FORM> 里面的标签 <TEXTAREA> 使用富文本编辑器(如FCKeditor或NicEditor) - How to save <FORM> tag inside <TEXTAREA> using rich-text editor like FCKeditor or NicEditor 创建简单的Rich-Text WYSIWYG编辑器的最佳方法是什么? - What's the best method for creating a simple Rich-Text WYSIWYG editor? HTML5 文本区域内的富文本 - HTML5 rich-text inside textarea
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM