2016-07-04 19 views

Antwort

2

Hier ist die Zusammenfassung: (von https://codemirror.net/doc/manual.html#addon_javascript-hint)

Dies wird einfach die Umwelt JavaScript verwenden, dass der Editor als Quelle von Informationen läuft in über Objekte und deren Eigenschaften.

und damit verbundene Quellcode:

var found = [], start = token.string, global = options && options.globalScope || window; 

und

function gatherCompletions(obj) { 
    if (typeof obj == "string") forEach(stringProps, maybeAdd); 
    else if (obj instanceof Array) forEach(arrayProps, maybeAdd); 
    else if (obj instanceof Function) forEach(funcProps, maybeAdd); 
    for (var name in obj) maybeAdd(name);//important 
} 

(von https://mikethedj4.github.io/kodeWeave/editor/libraries/codemirror/addon/hint/javascript-hint.js)

In dem objglobal ist.

Also, wenn Sie wollen einige der globalen Variablen entfernen , ändern Sie einfach die globalScope param.

Ändern Sie diese Zeile:

CodeMirror.commands.autocomplete(cm,null, {completeSingle: false}); 

zu

var scope={}; 
var preventList=['StyleFix', 'PrefixFree', 'Html2Jade','alert'];// map is better 
for(var i in window){ 
    if(preventList.indexOf(i)===-1){ 
    scope[i]=window[i] 
    } 
} 
CodeMirror.commands.autocomplete(cm,null, {completeSingle: false,globalScope:scope}); 

Live-Demo hier: https://mikethedj4.github.io/kodeWeave/editor/#cf4c4aa884b6ddb30c4ac79dd8bf3997

Verwandte Themen