| 1 |
define([ |
| 2 |
"dojo", |
| 3 |
"dojox", |
| 4 |
"dojo/_base/connect", |
| 5 |
"dojo/_base/declare" |
| 6 |
], function(dojo, dojox) { |
| 7 |
|
| 8 |
var SpellCheckParser = dojo.declare("dojox.editor.plugins._SpellCheckParser", null, { |
| 9 |
lang: "english", |
| 10 |
|
| 11 |
parseIntoWords: function( text){ |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
function isCharExt(c){ |
| 21 |
var ch = c.charCodeAt(0); |
| 22 |
return 48 <= ch && ch <= 57 || 65 <= ch && ch <= 90 || 97 <= ch && ch <= 122; |
| 23 |
} |
| 24 |
var words = this.words = [], |
| 25 |
indices = this.indices = [], |
| 26 |
index = 0, |
| 27 |
length = text && text.length, |
| 28 |
start = 0; |
| 29 |
|
| 30 |
while(index < length){ |
| 31 |
var ch; |
| 32 |
|
| 33 |
while(index < length && !isCharExt(ch = text.charAt(index)) && ch != "&"){ index++; } |
| 34 |
if(ch == "&"){ |
| 35 |
while(++index < length && (ch = text.charAt(index)) != ";" && isCharExt(ch)){} |
| 36 |
}else{ |
| 37 |
start = index; |
| 38 |
while(++index < length && isCharExt(text.charAt(index))){} |
| 39 |
if(start < length){ |
| 40 |
words.push(text.substring(start, index)); |
| 41 |
indices.push(start); |
| 42 |
} |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
return words; |
| 47 |
}, |
| 48 |
|
| 49 |
getIndices: function(){ |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
return this.indices; |
| 57 |
} |
| 58 |
}); |
| 59 |
|
| 60 |
|
| 61 |
dojo.subscribe(dijit._scopeName + ".Editor.plugin.SpellCheck.getParser", null, function(sp){ |
| 62 |
if(sp.parser){ return; } |
| 63 |
sp.parser = new SpellCheckParser(); |
| 64 |
}); |
| 65 |
|
| 66 |
return SpellCheckParser; |
| 67 |
|
| 68 |
}); |