CodeMirror 自定义 showHint() 调用不起作用

CodeMirror custom showHint() call doesn't work

正在尝试实现拼写检查模块的自定义 showHint 调用。我已经按照 docs 但是调用 editor.showHint 似乎什么都不做, returns undefined.

我想我缺少了一些东西。这是我要测试的沙箱代码:

editor.on('cursorActivity', function() {
    var options = {
    from: editor.getDoc().getCursor(),
    to: editor.getDoc().getCursor(),
    list: ['foo', 'bar', 'baz']
  };
  editor.showHint(options);
});

http://jsfiddle.net/3wvcudqt/3/

好的,根据文档解决了我的问题:

Finding hints is done with a hinting functions (the hint option), which is a function that take an editor instance and options object, and return a {list, from, to} object

而不是将 fromtolist 传递给 showHint(options),它们必须从传递给 [=16] 的 hint 函数返回=].

http://jsfiddle.net/3wvcudqt/4/

editor.on('cursorActivity', function() {
  var options = {
    hint: function() {
      return {
        from: editor.getDoc().getCursor(),
          to: editor.getDoc().getCursor(),
        list: ['foo', 'bar']
      }
    }
  };
  editor.showHint(options);
});