【问题标题】:How do I get a javascript library to work inside the CKEditor module?如何让 javascript 库在 CKEditor 模块中工作?
【发布时间】:2016-02-17 17:06:48
【问题描述】:

我的内容管理员希望能够在 CKEditor 实例内的引导导航药丸之间来回切换。开箱即用,CKEditor 似乎不允许 javascript 在编辑器中运行。下面是一个示例 - 我需要能够单击不同的药丸来编辑相关内容:

我找到了一个associated question,它似乎可以回答这个问题,但我无法让它在 Drupal 中工作——我不知道如何实现代码。我会对该问题添加评论,但我没有足够的声誉点数。

【问题讨论】:

    标签: javascript drupal-7 ckeditor


    【解决方案1】:

    使用this associated question 中提供的代码,我能够让javascript nav-pills 在Drupal 7 的CKEditor 实例中工作。不幸的是,它只能在Firefox for PC 中工作。此外,我必须将以下代码添加到 ckeditor.config.js 文件中,并手动将脚本添加到管理主题的 html.tpl.php 文件中——这似乎是多余的,但只有在两个文件都有它的情况下才有效。

    CKEDITOR.on('instanceReady', function(ev) {
    var jqScript = document.createElement('script');
    var bsScript = document.createElement('script');
    
    jqScript.src = 'http://code.jquery.com/jquery-2.0.2.js';
    bsScript.src = 'http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js';
    
    var editorHead = ev.editor.document.$.head;
    editorHead.appendChild(jqScript);
    editorHead.appendChild(bsScript);
    
    jqScript.onload = function() { editorHead.appendChild(bsScript); }; 
    });
    

    【讨论】:

      猜你喜欢
      • 2017-07-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-29
      • 2020-07-25
      • 1970-01-01
      相关资源
      最近更新 更多