Autocomplete 有什么库可以与codemirror一起用于自动完成?

Autocomplete 有什么库可以与codemirror一起用于自动完成?,autocomplete,codemirror,Autocomplete,Codemirror,我正在使用代码镜像编辑器。。。我想功能,如样式内的列表中的项目,显着当我做自动完成。。。所以有任何库或插件我可以使用codemirror提供给我更多的功能比codemirror。。 注意:我想将它与codemirror一起使用,而不是与codemirror一起使用。。。提前感谢是的,您可以使用自动完成。 您可以通过修改addon/hint/show hint.css来设置项目的样式。在show-hint.css中,我添加了一些css: .table.CodeMirror-hint { fon

我正在使用代码镜像编辑器。。。我想功能,如样式内的列表中的项目,显着当我做自动完成。。。所以有任何库或插件我可以使用codemirror提供给我更多的功能比codemirror。。 注意:我想将它与codemirror一起使用,而不是与codemirror一起使用。。。提前感谢

是的,您可以使用自动完成。
您可以通过修改
addon/hint/show hint.css

来设置项目的样式。在show-hint.css中,我添加了一些css:

.table.CodeMirror-hint {
  font-weight: bold;
  color: black;
}

.column.CodeMirror-hint {
  font-weight: bold;
  color: black;
}

.keyword.CodeMirror-hint {
  font-weight: bold;
  color: #BF00FF;
}

.builtin.CodeMirror-hint {
  font-weight: bold;
  color: #2E64FE;
}
在我的主网页中,我动态地将所有表/列作为对象添加到hintOptions中。对于每个表,我都喜欢这样:

        var tcobjs = []; //table columns array of object
        for (j=0; j < tablecolumns.length; j++) {
            tcobjs.push({text:tablecolumns[j],className:"column"});
        }
        hintOptions.tables[table]=tcobjs;
  var keywords;
  var builtin;

  function getKeywords(editor) {
    var mode = editor.doc.modeOption;
    if (mode === "sql") mode = "text/x-sql";
    var words = {};
    for (var w in CodeMirror.resolveMode(mode).keywords) { words[w] = CodeMirror.resolveMode(mode).keywords[w]; }
    return words;
  }

  function getBuiltin(editor) {
    var mode = editor.doc.modeOption;
    if (mode === "sql") mode = "text/x-sql";
    var words = {};
    for (var w in CodeMirror.resolveMode(mode).builtin) { words[w] = CodeMirror.resolveMode(mode).builtin[w]; }
    return words;
  }

[....]

    keywords = getKeywords(editor);
    builtin = getBuiltin(editor);

[....]

      addMatches(result, search, tables, function(w) {return {text:w,className:"table"};});
      addMatches(result, search, defaultTable, function(w) {return {text:w,className:"table"};});
      if (!disableKeywords)
        addMatches(result, search, keywords, function(w) {return {text:w.toUpperCase(),className:"keyword"};});
      addMatches(result, search, builtin, function(w) {return {text:w.toUpperCase(),className:"builtin"};});

如何在下拉列表中以不同的方式设置单个项目的样式,使所有项目的样式都不相同?@Jan如果您只是想以不同的方式设置所选(或说活动)项目的样式,您应该更改
li.codemirr hint active
内部
加载项/hint/show hint.CSS
的CSS规则。或者,如果您想以不同的方式设置每个项目的样式(我无法想象为什么),您应该传递对象而不是字符串作为提示项目,这样您就可以设置每个项目的
className
。有关详细信息,请查看。例如,如果您有一个包含表名/列名、sql函数(平均值、总和…)和sql关键字(选择、从、其中…)的下拉列表我想通过使用不同的颜色来更显著地区分它们。你能把你的解决方案放在jsbin中吗?我定义了自己的模式,所以我有自己的单词和函数。。。我没有使用sql模式