相关疑难解决方法(0)

在CKEditor中保留SCRIPT标记(以及更多)

是否可以在CKEditor中创建一个代码块,编辑器本身不会触及该代码块,并且在用户明确更改之前将保持其预期状态?我一直在尝试输入javascript变量(绑定在脚本标签中)和随后的flash电影,但CKEditor继续重写我粘贴的代码/标记,这样做会破坏我的代码.

我正在使用以下设置:

<script type="text/javascript">
  var editor = CKEDITOR.replace("content", {
    height : "500px",
    width : "680px",
    resize_maxWidth : "680px",
    resize_minWidth : "680px",
    toolbar :
    [
      ['Source','-','Save','Preview'],
      ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],
      ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
      ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
      ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
      ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
      ['Link','Unlink','Anchor'],
      ['Image','Table','HorizontalRule','SpecialChar']
    ]
  });
  CKFinder.SetupCKEditor( editor, "<?php print url::base(); ?>assets/ckfinder" );
</script>
Run Code Online (Sandbox Code Playgroud)

我认为最理想的解决方案是保留任何包含class="preserve"比有限独占更多功能的标签的内容.

更新:我正在考虑解决这个问题的方法CKEDITOR.config.protectedSource(),但我的常规表达经验证明太少了,无法处理这个问题.我如何免除CKEditor触及的所有包含"保留"类的标签?

javascript regex exception source-code-protection ckeditor

10
推荐指数
3
解决办法
3万
查看次数