I am using codemirror , I knew how I can to do autocomplete when I press “.” but I need to do autocomplete when the character before the cursor is “.” , so if I have the textarea :
test. Note : when I run then the word "test." write on codemirror , but the codemirror did not do autocomplete because I did not press the character "." this is my code : CodeMirror.commands.autocomplete = function(cm) { CodeMirror.showHint(cm, CodeMirror.hint.anyword); };var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
matchBrackets: true,
mode: "text/x-stsrc",
indentUnit: 4,
autoCloseBrackets: true,
highlightSelectionMatches: true,
styleActiveLine: true,
extraKeys: {
"Ctrl-Space": "autocomplete" ,
"Ctrl-Space":function(cm){ CodeMirror.showHint(cm, CodeMirror.hint.anyword); },
"'.'" : function(cmm){ CodeMirror.showHint(cmm, CodeMirror.hint.anyword);},
},
autohint: true,
readOnly: false,
lineWrapping: true,
});
editor.on("blur", function(codeMirror) { codeMirror.save(); });
editor.refresh();
editor.focus();
var orig = CodeMirror.hint.anyword;
CodeMirror.hint.anyword = function(cm) {
var inner = orig(cm) || { from: cm.getCursor(), to: cm.getCursor(), list: []};
inner.list.push(“mariano”);
inner.list.push(“florencia”);
inner.list.push(“zoe”);
return inner;
};
and this is my code on js : http://jsbin.com/yibesiniyu/edit?html,js,output
any help ? how I can to do autocomplete if the character before the cursor is “.” ? thanks in advance