CKEditor删除特定实例的样式

时间:2015-06-09 12:06:29

标签: javascript css ckeditor

如何删除特定CK编辑器实例的样式。 我的页面中有两个CKEditors。一个限制为摘要,一个限制为内容。

对于摘要,我不能允许复制粘贴样式,因为这会弄乱我们的设计。

我尝试了这个解决方案:

        CKEDITOR.config.forcePasteAsPlainText = true;
    CKEDITOR.replace( id, {
        // Define the toolbar groups as it is a more accessible solution.
        toolbarGroups: [
            {"name":"basicstyles","groups":["basicstyles"]},
            {"name":"links","groups":["links"]}
        ],
        // Remove the redundant buttons from toolbar groups defined above.
        removeButtons: 'Strike,Subscript,Superscript,Anchor,Styles,Specialchar'
    } );

这会删除样式,但也会从内容中删除。

所以我的问题是如何在粘贴摘要时删除样式,以及在粘贴内容时如何保持样式。

1 个答案:

答案 0 :(得分:0)

在您的代码段中,我可以看到:

CKEDITOR.config.forcePasteAsPlainText = true;

这不是设置配置选项的正确方法。这将更改所有现有编辑器的此设置。您要做的是将此设置移至CKEDITOR.replace()

CKEDITOR.replace( 'content', {
     // some options for the "content" editor.
} );

CKEDITOR.replace( 'summary', {
    forcePasteAsPlainText: true,
    // some other options for the "summary" editor.
} );

setting configuration中阅读更多内容。

相关问题