【问题标题】:How to add Django Language mode in CodeMirror Plugin of CKEditor?如何在CKEditor的CodeMirror插件中添加Django语言模式?
【发布时间】:2019-06-29 11:48:11
【问题描述】:

我正在使用 CKEditor wysiwyg 来创建 django 模板。因此,我遇到了使用 CKEditor 的 codemirror 插件为here。按照安装说明,以下选项可用于配置参考here

config.codemirror = {

    // Set this to the theme you wish to use (codemirror themes)
    theme: 'default',

    [.......................]

    // Define the language specific mode 'htmlmixed' for html  including (css, xml, javascript), 'application/x-httpd-php' for php mode including html, or 'text/javascript' for using java script only 
    mode: 'htmlmixed',

    [.......................]

     // Whether or not to show the showAutoCompleteButton button on the toolbar
    showAutoCompleteButton: true
};

但是,与上述模式选项一样,语言仅限于 html、javascript 和 php,我无法使用其他语言,就我而言 Django

我尝试在<path to CKEditor>/Plugins/codemirror/plugin.js 修改CKEditor 的默认代码镜像插件以添加django 语言可能的地方,但它只导致代码错误。

那么,我该如何在CKEditor的codemirror插件中添加Django语言呢?谢谢。

【问题讨论】:

    标签: django ckeditor codemirror


    【解决方案1】:

    CodeMirror 模式不限于html, javascript, and php,这里列出了所有支持的language modes

    确保您已按以下顺序加载了 Django 模式和 xml, htmlmixed 模式:


    带有嵌入式 Django 模板标记的 HTML 模式。

    mode: 'django'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-31
      • 2016-07-27
      • 1970-01-01
      相关资源
      最近更新 更多