【问题标题】:CKEditor Turn Off Advanced Content FilterCKEditor 关闭高级内容过滤器
【发布时间】:2015-04-09 20:47:04
【问题描述】:

我在停用高级内容过滤器时遇到了困难(config.allowedContent = true;似乎不起作用)。我已经尝试了我在论坛上阅读的所有内容,包括清除缓存并将其设为外部文件。

CKEditor 4.2.2 - allowedContent = true is not working

我什至添加了 config.protectedSource.push 行,它们在一定程度上起作用。 CKEditor 仍然会添加 div 标签并部分删除其他标签。

我正在创建一组精心设计的模板供客户使用,所以最后我根本不希望 CKEditor 触及我的代码。这是我在 config.js 中的内容。如果有人看到我做错了什么,或者知道如何让它发挥作用,请帮助这个有点压力的网络人。

谢谢, 生锈

CKEDITOR.editorConfig = function( config ) {
config.toolbarGroups = [
{ name: 'document',    groups: [ 'mode', 'document', 'doctools' ] },
{ name: 'clipboard',   groups: [ 'clipboard', 'undo' ] },
{ name: 'editing',     groups: [ 'find', 'selection', 'spellchecker' ] },
{ name: 'insert' },
{ name: 'links' },
{ name: 'others' },
'/',
{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
{ name: 'paragraph',   groups: [ 'list', 'indent', 'blocks', 'align' ] },
{ name: 'styles' },
{ name: 'colors' },
{ name: 'tools' },
{ name: 'about' }
];

// Define changes to default configuration here. For example:
// config.uiColor = '#AADC6E';
// misc options
config.allowedContent = true; // allowedContent doesn't work :-(
// Protected Source
config.protectedSource.push(/<section>[\s\S]*?<\/section>/gi); // allow <section></section>
config.protectedSource.push(/<span>[\s\S]*?<\/span>/gi); // allow <span></span>
config.protectedSource.push( /<link[\s\S]*?\>/g ); // allow <link> tag
config.protectedSource.push( /<!--[\s\S]*?\>/g ); // allow <comment> tag
config.protectedSource.push( /<br[\s\S]*?\/>/g );   // allow BR Tags
config.protectedSource.push(/<script>[\s\S]*?<\/script>/gi); // allow <script></script>
config.protectedSource.push(/<div>[\s\S]*?<\/div>/gi); // allow <div></div>

config.removeButtons = 'Anchor,Iframe';
config.format_tags = 'p;h1;h2;h3;h4;h5;h6'; // format button options
config.height = '500px'; // edit window height
config.skin = 'moono';
config.stylesSet = 'vam_styles:/templates/admin/-css/vam_styles.js'; // style button options
// Only add rules for p and span elements.
config.stylesheetParser_validSelectors = /\^(p|span\div)\.\w+/;
config.stylesheetParser_skipSelectors

};

【问题讨论】:

  • 我使用的ckEditor版本是ckEditor 4.4.7

标签: ckeditor


【解决方案1】:

我正在创建一组精心设计的模板供客户使用,所以最后我不希望 CKEditor 触及我的代码。

这是不可能的。 CKEditor 不是一个网站构建器,您可以在其中加载任何可能的 HTML。它是一个丰富的文本编辑器。所以你应该用它来编辑网站的文本部分,而不是整个布局。

例如,如果您的布局包含两列和上方的一些标题,那么最好有 3 个编辑器 - 每列一个,标题一个。当然,在这种基本情况下,CKEditor 可以一次编辑或 3 个部分,但布局越复杂,正确使用 CKEditor 越重要

附言。是 CKEditor,不是 ckEditor。

【讨论】:

    【解决方案2】:

    感谢您的回复。

    我说的不是网站设计模板,而是页面设计模板。在 CKEditor 的全功能版本上,我们已经能够增强一个模板按钮。我们现在能够让我们的客户选择几个设计良好的页面布局,这些布局可以响应不同的设计。非常有效。

    在尝试了一切之后,我找到了导致问题的罪魁祸首。我使用的是&lt;br&gt; 而不是&lt;br />。切换编辑器后,我的代码就不用管了。

    最好的祝愿! 生锈

    【讨论】:

      猜你喜欢
      • 2014-01-25
      • 1970-01-01
      • 2014-04-09
      • 1970-01-01
      • 1970-01-01
      • 2015-04-27
      • 2017-03-09
      • 1970-01-01
      • 2016-08-16
      相关资源
      最近更新 更多