2016-04-11 18 views
0

カスタムshowHintを実装しようとすると、スペルチェックモジュールが呼び出されます。私はdocsに従っていますが、editor.showHintを呼び出すと何も起こらず、undefinedを返します。CodeMirrorカスタムshowHint()呼び出しが機能しない

私には何かがありません。ここでは、テストに私のサンドボックスのコードは次のとおりです。

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/

答えて

2

OK、ドキュメントごとに、私の問題を考え出し:ヒントを見つける

はヒント機能(ヒントオプション)で行われていますこれは、エディタインスタンスとオプションオブジェクトを受け取り、{list、from、to}オブジェクトを返す関数です

from,to、およびlistshowHint(options)に変更する場合は、showHintに渡された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); 
}); 
関連する問題