将github gists嵌入ckeditor中

时间:2017-09-18 10:36:01

标签: ckeditor embed

如何将Github Gists嵌入CKeditor?

通常如果我输入这个例如:

<script src="https://gist.github.com/ericbarnes/f8f533409af88cf35be520c101181384.js"></script>

将被忽略并删除。

Uptade:

使用的脚本............................................. ...........

<script>
  var editor_config = {
    path_absolute : "/",
    selector: "textarea.my-editor",
    plugins: [
      "advlist autolink lists link image charmap print preview hr anchor pagebreak",
      "searchreplace wordcount visualblocks visualchars code fullscreen",
      "insertdatetime media nonbreaking save table contextmenu directionality",
      "emoticons template paste textcolor colorpicker textpattern codesample"
    ],
    toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image media | emoticons charmap | code codesample | forecolor backcolor",
    relative_urls: false,
    remove_script_host: false,
    file_browser_callback : function(field_name, url, type, win) {
      var x = window.innerWidth || document.documentElement.clientWidth || document.getElementsByTagName('body')[0].clientWidth;
      var y = window.innerHeight|| document.documentElement.clientHeight|| document.getElementsByTagName('body')[0].clientHeight;

      var cmsURL = editor_config.path_absolute + 'laravel-filemanager?field_name=' + field_name;
      if (type == 'image') {
        cmsURL = cmsURL + "&type=Images";
      } else {
        cmsURL = cmsURL + "&type=Files";
      }

      tinymce.activeEditor.windowManager.open({
        file: '<?= route('elfinder.tinymce4') ?>',// use an absolute path!
        title: 'file manager',
        width: 900,
        height: 450,
        resizable: 'yes'
      }, {
        setUrl: function (url) {
          win.document.getElementById(field_name).value = url;
        }
      });
    }
  };

  tinymce.init(editor_config);
</script>

1 个答案:

答案 0 :(得分:0)

尝试添加到您的配置选项:

config.extraAllowedContent = 'script[src]';

此处提供了更多信息 - https://docs.ckeditor.com/#!/guide/dev_acf

PS。但是,请注意,允许提交脚本标签并不安全。