【问题标题】:CodeMirror determine the name of the modeCodeMirror 确定模式的名称
【发布时间】:2014-02-28 00:35:56
【问题描述】:

如何知道 CodeMirror 中每种语言的“模式”名称?

例如,“HTML Embedded”模式给出了这个页面:http://codemirror.net/mode/htmlembedded/index.html

在这个页面上,有一个脚本,但它没有设置模式。

  var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
    lineNumbers: true,
    matchBrackets: true,
    continueComments: "Enter",
    extraKeys: {"Ctrl-Q": "toggleComment"}
  });

我希望mode: "somemode" 出现在其中。我们怎么知道它的名字?

【问题讨论】:

    标签: codemirror


    【解决方案1】:

    加载的第一个模式成为默认模式。您可以使用editor.getMode().name 来获取在编辑器实例中加载的模式的名称。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多