1
define('ace/ext/spellcheck', ['require', 'exports', 'module' , 'ace/lib/event', 'ace/editor', 'ace/config'], function(require, exports, module) {
3
var event = require("../lib/event");
5
exports.contextMenuHandler = function(e){
7
var text = host.textInput.getElement();
8
if (!host.selection.isEmpty())
10
var c = host.getCursorPosition();
11
var r = host.session.getWordRange(c.row, c.column);
12
var w = host.session.getTextRange(r);
14
host.session.tokenRe.lastIndex = 0;
15
if (!host.session.tokenRe.test(w))
17
var PLACEHOLDER = "\x01\x01";
18
var value = w + " " + PLACEHOLDER;
20
text.setSelectionRange(w.length + 1, w.length + 1);
21
text.setSelectionRange(0, 0);
23
var afterKeydown = false;
24
event.addListener(text, "keydown", function onKeydown() {
25
event.removeListener(text, "keydown", onKeydown);
29
host.textInput.setInputHandler(function(newVal) {
30
console.log(newVal , value, text.selectionStart, text.selectionEnd)
33
if (newVal.lastIndexOf(value, 0) === 0)
34
return newVal.slice(value.length);
35
if (newVal.substr(text.selectionEnd) == value)
36
return newVal.slice(0, -value.length);
37
if (newVal.slice(-2) == PLACEHOLDER) {
38
var val = newVal.slice(0, -2);
39
if (val.slice(-1) == " ") {
41
return val.substring(0, text.selectionEnd);
42
val = val.slice(0, -1);
43
host.session.replace(r, val);
51
var Editor = require("../editor").Editor;
52
require("../config").defineOptions(Editor.prototype, "editor", {
55
var text = this.textInput.getElement();
56
text.spellcheck = !!val;
58
this.removeListener("nativecontextmenu", exports.contextMenuHandler);
60
this.on("nativecontextmenu", exports.contextMenuHandler);