粘贴到CKEditor时如何不继承格式? [英] How not to inherit format when pasting into CKEditor?

查看:181
本文介绍了粘贴到CKEditor时如何不继承格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:当用户从另一个网站复制一段代码并将其粘贴到CKEditor中时,它包含一系列内联样式,这些样式引用从其复制的网站上的内容样式。当粘贴的内容然后保存并显示在我的网站上,它不会使用我的风格,但复制内联的冲突。



我已经通过CKEditor的文档,说实话,我没有找到文件来缩小我正在寻找的。有一个粘贴功能,可以删除格式,但这是一个可选的按钮,而大多数用户只是张贴到主要的大面积,所以它非常没有价值。



主要问题:有没有一种方法可以设置CKEditor在粘贴时去除格式化?

解决方案

,我找到了答案:

  //应用编辑器实例设置。 
CKEDITOR.config.forcePasteAsPlainText = true;


Problem: When a user copies a load of code from another website and pastes it into CKEditor it includes a load of inline styles which refer to the style of the content on the website it was copied from. When the pasted content is then saved and shown on my website it doesn't use my styles but the copied inline ones which conflict.

I've had a look through the CKEditor documentation, and to be honest I don't find the documentation to narrow down to what I'm looking for. There is a paste function available which removes formatting but this is an optional button in the menu, whereas most users will just post into the main large area, so its pretty worthless.

Main Question: is there a way to set CKEditor to strip formatting when pasting?

解决方案

Ah, I found the answer:

// Apply editor instance settings.
CKEDITOR.config.forcePasteAsPlainText = true;

这篇关于粘贴到CKEditor时如何不继承格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆