将数据从其他网站内联 CSS 粘贴到 CK 编辑器中,在 Google Chrome 中丢失,但在 IE 和 Firefox 中不丢失
Paste data into CK editor from other website inline CSS loosing in Google Chrome but not in IE an Firefox
我在我的应用程序中使用了 ckeditor。该应用程序基于 asp.net MVC。
它工作正常。
问题是当我从其他网站复制数据并粘贴到 ck 编辑器时,格式丢失了。比如颜色、下划线、粗体等
如果我从 Microsoft Word 复制内容,它工作正常。
我没有找到任何参考是否支持。
我访问过的一些链接
https://ckeditor.com/docs/ckeditor4/latest/guide/dev_allowed_content_rules.html
编辑 1
下面是我正在使用的代码
$(document).ready(function () {
CKEDITOR.replace("myckeditor",
{
height: 450,
bodyClass: 'document-editor',
contentsCss: [CKEDITOR.basePath + 'contents.css', CKEDITOR.basePath + 'pastefromword.css'],
extraPlugins: 'pastefromword,tabletools,tableresize,tableselection,colordialog',
removePlugins: 'elementspath,wsc,scayt',
});
CKEDITOR.config.scayt_sLang = "en_US";
CKEDITOR.config.pasteFromWordRemoveFontStyles = false;
CKEDITOR.config.allowedContent = true;
});
编辑 1
CKEDITOR.config.pasteFromWordRemoveFontStyles = false;
CKEDITOR.config.allowedContent = true;
CKEDITOR.config.extraAllowedContent = '*(*);*{*}';
以上是我在CK编辑器中做的额外配置
我已经从要复制和过去的数据的地方创建了一个源文件。
<html>
<head>
<title>
this is a test page
</title>
</head>
<body>
<div>
this is a normal text
<div>
<div style="color:red;">
this is red text
</div>
<body>
</html>
当我从 IE 和 Firefox 等浏览器复制数据时,颜色被复制到 CK 编辑器中。
但在 Chrome 浏览器中,如果它从 div
.
中删除样式属性,则不正确
如果需要,代码中还有一些其他功能,我也可以向您展示。
类似的问题没有帮助。
CKEditor strips inline attributes
CKEditor automatically strips classes from div
我不知道它是否是正确的解决方案,但下面的代码对我有用
config.pasteFilter = null;
参考文献:
http://origin-docs.ckeditor.com/ckeditor4/docs/?print=/api/CKEDITOR.config
我在我的应用程序中使用了 ckeditor。该应用程序基于 asp.net MVC。
它工作正常。
问题是当我从其他网站复制数据并粘贴到 ck 编辑器时,格式丢失了。比如颜色、下划线、粗体等
如果我从 Microsoft Word 复制内容,它工作正常。
我没有找到任何参考是否支持。
我访问过的一些链接
https://ckeditor.com/docs/ckeditor4/latest/guide/dev_allowed_content_rules.html
编辑 1
下面是我正在使用的代码
$(document).ready(function () {
CKEDITOR.replace("myckeditor",
{
height: 450,
bodyClass: 'document-editor',
contentsCss: [CKEDITOR.basePath + 'contents.css', CKEDITOR.basePath + 'pastefromword.css'],
extraPlugins: 'pastefromword,tabletools,tableresize,tableselection,colordialog',
removePlugins: 'elementspath,wsc,scayt',
});
CKEDITOR.config.scayt_sLang = "en_US";
CKEDITOR.config.pasteFromWordRemoveFontStyles = false;
CKEDITOR.config.allowedContent = true;
});
编辑 1
CKEDITOR.config.pasteFromWordRemoveFontStyles = false;
CKEDITOR.config.allowedContent = true;
CKEDITOR.config.extraAllowedContent = '*(*);*{*}';
以上是我在CK编辑器中做的额外配置
我已经从要复制和过去的数据的地方创建了一个源文件。
<html>
<head>
<title>
this is a test page
</title>
</head>
<body>
<div>
this is a normal text
<div>
<div style="color:red;">
this is red text
</div>
<body>
</html>
当我从 IE 和 Firefox 等浏览器复制数据时,颜色被复制到 CK 编辑器中。
但在 Chrome 浏览器中,如果它从 div
.
中删除样式属性,则不正确
如果需要,代码中还有一些其他功能,我也可以向您展示。
类似的问题没有帮助。
CKEditor strips inline attributes
CKEditor automatically strips classes from div
我不知道它是否是正确的解决方案,但下面的代码对我有用
config.pasteFilter = null;
参考文献:
http://origin-docs.ckeditor.com/ckeditor4/docs/?print=/api/CKEDITOR.config