Javascript CodeMirror custom showHint()调用不';行不通
试图实现拼写检查模块的自定义Javascript CodeMirror custom showHint()调用不';行不通,javascript,plugins,editor,wysiwyg,codemirror,Javascript,Plugins,Editor,Wysiwyg,Codemirror,试图实现拼写检查模块的自定义showHint调用。我遵循了但是调用编辑器。showHint似乎什么也不做,并返回未定义的 我想我遗漏了一些东西。下面是我要测试的沙盒代码: editor.on('cursorActivity', function() { var options = { from: editor.getDoc().getCursor(), to: editor.getDoc().getCursor(), list: ['foo', 'bar', 'b
showHint
调用。我遵循了但是调用编辑器。showHint
似乎什么也不做,并返回未定义的
我想我遗漏了一些东西。下面是我要测试的沙盒代码:
editor.on('cursorActivity', function() {
var options = {
from: editor.getDoc().getCursor(),
to: editor.getDoc().getCursor(),
list: ['foo', 'bar', 'baz']
};
editor.showHint(options);
});
好的,根据文档解决我的问题:
查找提示是通过提示函数(提示选项)完成的,提示函数接受编辑器实例和选项对象,并返回{list,from,to}对象
不是将从
、传递到
和列表
传递到showHint(选项)
,而是必须从传递到showHint
的hint
函数返回它们
好的,根据文档,解决了我的问题:
查找提示是通过提示函数(提示选项)完成的,提示函数接受编辑器实例和选项对象,并返回{list,from,to}对象
不是将从
、传递到
和列表
传递到showHint(选项)
,而是必须从传递到showHint
的hint
函数返回它们
editor.on('cursorActivity', function() {
var options = {
hint: function() {
return {
from: editor.getDoc().getCursor(),
to: editor.getDoc().getCursor(),
list: ['foo', 'bar']
}
}
};
editor.showHint(options);
});