yks-element 1.5.2 → 1.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/019e34e85139cfc611bf23efa096c980.js +18 -0
- package/lib/07567125b93045706d81f17f7d04e262.js +120 -0
- package/lib/0d56a1f26e052a1bafd10a87782fc74b.js +3380 -0
- package/lib/27846e85433e54a3ec0ab34d62233dc5.js +186 -0
- package/lib/2f25a4dc442bc9aebc58cae30c50c3e2.js +192 -0
- package/lib/2f55cddc8eb85b63ee5b4ce0e5488230.js +67 -0
- package/lib/2fe2904fc024afaf81732563cb83e547.js +116 -0
- package/lib/3b02cca9e95276a74f3ed2bbc7a64ce6.js +409 -0
- package/lib/70efbabef77fb217f904f41dbf7fe8bf.js +380 -0
- package/lib/7cec85e554cfaf2464511da505025098.js +74 -0
- package/lib/852f0ecd7b17e3bfd700a821ff438f7e.js +330 -0
- package/lib/88730abfeb4a23e692ac7933882f12eb.js +255 -0
- package/lib/8b8336037f074d9dcbd20eab535b803f.js +227 -0
- package/lib/9979f39c4d2773e02151a6cf1558101b.js +768 -0
- package/lib/af6e31c060c273848b5fec9fdba8814d.js +3066 -0
- package/lib/babd8df6809ef43238f1b280c2cebfe3.js +265 -0
- package/lib/bb1365c0983ce5ad50060b24788b9630.js +459 -0
- package/lib/c0a8aa1d5e0611259e47c2008cb203ee.js +197 -0
- package/lib/c530988d2b1966fd10a4d99fa3877e1b.js +9 -0
- package/lib/c8acc93023012737a3bf8fb767b66838.js +1293 -0
- package/lib/d0415105402964718010284fcfa8b2ea.js +48 -0
- package/lib/d11ab4aa7dd9123fdecb075ff5c5a748.js +790 -0
- package/lib/d1907231dc06c32481fefd6d47da973b.js +344 -0
- package/lib/d429602e0ebf3c1ec040e070e9b05b9b.js +184 -0
- package/lib/e4fc956693373117f057fe9914e983fc.js +7090 -0
- package/lib/f15362a7feef894b2e7f706252e6c510.js +45 -0
- package/lib/f666b5647087bcfdf6623f8b14d56657.js +136 -0
- package/lib/fac0ce75e0690947a9e9e6f5b35c1ea8.js +1067 -0
- package/lib/fec23c6964d6cf25681d1f3e24b076a4.js +56 -0
- package/lib/yks.js +1 -1
- package/package.json +1 -1
- package/lib/6c6d192b6860b4508a14c2d04769a35e.js +0 -15404
- package/lib/c3832579be376308fa819b04e7b0c66f.js +0 -3788
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
ace.define("ace/split",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter","ace/editor","ace/virtual_renderer","ace/edit_session"], function(require, exports, module){"use strict";
|
|
2
|
+
var oop = require("./lib/oop");
|
|
3
|
+
var lang = require("./lib/lang");
|
|
4
|
+
var EventEmitter = require("./lib/event_emitter").EventEmitter;
|
|
5
|
+
var Editor = require("./editor").Editor;
|
|
6
|
+
var Renderer = require("./virtual_renderer").VirtualRenderer;
|
|
7
|
+
var EditSession = require("./edit_session").EditSession;
|
|
8
|
+
var Split;
|
|
9
|
+
Split = function (container, theme, splits) {
|
|
10
|
+
this.BELOW = 1;
|
|
11
|
+
this.BESIDE = 0;
|
|
12
|
+
this.$container = container;
|
|
13
|
+
this.$theme = theme;
|
|
14
|
+
this.$splits = 0;
|
|
15
|
+
this.$editorCSS = "";
|
|
16
|
+
this.$editors = [];
|
|
17
|
+
this.$orientation = this.BESIDE;
|
|
18
|
+
this.setSplits(splits || 1);
|
|
19
|
+
this.$cEditor = this.$editors[0];
|
|
20
|
+
this.on("focus", function (editor) {
|
|
21
|
+
this.$cEditor = editor;
|
|
22
|
+
}.bind(this));
|
|
23
|
+
};
|
|
24
|
+
(function () {
|
|
25
|
+
oop.implement(this, EventEmitter);
|
|
26
|
+
this.$createEditor = function () {
|
|
27
|
+
var el = document.createElement("div");
|
|
28
|
+
el.className = this.$editorCSS;
|
|
29
|
+
el.style.cssText = "position: absolute; top:0px; bottom:0px";
|
|
30
|
+
this.$container.appendChild(el);
|
|
31
|
+
var editor = new Editor(new Renderer(el, this.$theme));
|
|
32
|
+
editor.on("focus", function () {
|
|
33
|
+
this._emit("focus", editor);
|
|
34
|
+
}.bind(this));
|
|
35
|
+
this.$editors.push(editor);
|
|
36
|
+
editor.setFontSize(this.$fontSize);
|
|
37
|
+
return editor;
|
|
38
|
+
};
|
|
39
|
+
this.setSplits = function (splits) {
|
|
40
|
+
var editor;
|
|
41
|
+
if (splits < 1) {
|
|
42
|
+
throw "The number of splits have to be > 0!";
|
|
43
|
+
}
|
|
44
|
+
if (splits == this.$splits) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
else if (splits > this.$splits) {
|
|
48
|
+
while (this.$splits < this.$editors.length && this.$splits < splits) {
|
|
49
|
+
editor = this.$editors[this.$splits];
|
|
50
|
+
this.$container.appendChild(editor.container);
|
|
51
|
+
editor.setFontSize(this.$fontSize);
|
|
52
|
+
this.$splits++;
|
|
53
|
+
}
|
|
54
|
+
while (this.$splits < splits) {
|
|
55
|
+
this.$createEditor();
|
|
56
|
+
this.$splits++;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
while (this.$splits > splits) {
|
|
61
|
+
editor = this.$editors[this.$splits - 1];
|
|
62
|
+
this.$container.removeChild(editor.container);
|
|
63
|
+
this.$splits--;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
this.resize();
|
|
67
|
+
};
|
|
68
|
+
this.getSplits = function () {
|
|
69
|
+
return this.$splits;
|
|
70
|
+
};
|
|
71
|
+
this.getEditor = function (idx) {
|
|
72
|
+
return this.$editors[idx];
|
|
73
|
+
};
|
|
74
|
+
this.getCurrentEditor = function () {
|
|
75
|
+
return this.$cEditor;
|
|
76
|
+
};
|
|
77
|
+
this.focus = function () {
|
|
78
|
+
this.$cEditor.focus();
|
|
79
|
+
};
|
|
80
|
+
this.blur = function () {
|
|
81
|
+
this.$cEditor.blur();
|
|
82
|
+
};
|
|
83
|
+
this.setTheme = function (theme) {
|
|
84
|
+
this.$editors.forEach(function (editor) {
|
|
85
|
+
editor.setTheme(theme);
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
this.setKeyboardHandler = function (keybinding) {
|
|
89
|
+
this.$editors.forEach(function (editor) {
|
|
90
|
+
editor.setKeyboardHandler(keybinding);
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
this.forEach = function (callback, scope) {
|
|
94
|
+
this.$editors.forEach(callback, scope);
|
|
95
|
+
};
|
|
96
|
+
this.$fontSize = "";
|
|
97
|
+
this.setFontSize = function (size) {
|
|
98
|
+
this.$fontSize = size;
|
|
99
|
+
this.forEach(function (editor) {
|
|
100
|
+
editor.setFontSize(size);
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
this.$cloneSession = function (session) {
|
|
104
|
+
var s = new EditSession(session.getDocument(), session.getMode());
|
|
105
|
+
var undoManager = session.getUndoManager();
|
|
106
|
+
s.setUndoManager(undoManager);
|
|
107
|
+
s.setTabSize(session.getTabSize());
|
|
108
|
+
s.setUseSoftTabs(session.getUseSoftTabs());
|
|
109
|
+
s.setOverwrite(session.getOverwrite());
|
|
110
|
+
s.setBreakpoints(session.getBreakpoints());
|
|
111
|
+
s.setUseWrapMode(session.getUseWrapMode());
|
|
112
|
+
s.setUseWorker(session.getUseWorker());
|
|
113
|
+
s.setWrapLimitRange(session.$wrapLimitRange.min, session.$wrapLimitRange.max);
|
|
114
|
+
s.$foldData = session.$cloneFoldData();
|
|
115
|
+
return s;
|
|
116
|
+
};
|
|
117
|
+
this.setSession = function (session, idx) {
|
|
118
|
+
var editor;
|
|
119
|
+
if (idx == null) {
|
|
120
|
+
editor = this.$cEditor;
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
editor = this.$editors[idx];
|
|
124
|
+
}
|
|
125
|
+
var isUsed = this.$editors.some(function (editor) {
|
|
126
|
+
return editor.session === session;
|
|
127
|
+
});
|
|
128
|
+
if (isUsed) {
|
|
129
|
+
session = this.$cloneSession(session);
|
|
130
|
+
}
|
|
131
|
+
editor.setSession(session);
|
|
132
|
+
return session;
|
|
133
|
+
};
|
|
134
|
+
this.getOrientation = function () {
|
|
135
|
+
return this.$orientation;
|
|
136
|
+
};
|
|
137
|
+
this.setOrientation = function (orientation) {
|
|
138
|
+
if (this.$orientation == orientation) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
this.$orientation = orientation;
|
|
142
|
+
this.resize();
|
|
143
|
+
};
|
|
144
|
+
this.resize = function () {
|
|
145
|
+
var width = this.$container.clientWidth;
|
|
146
|
+
var height = this.$container.clientHeight;
|
|
147
|
+
var editor;
|
|
148
|
+
if (this.$orientation == this.BESIDE) {
|
|
149
|
+
var editorWidth = width / this.$splits;
|
|
150
|
+
for (var i = 0; i < this.$splits; i++) {
|
|
151
|
+
editor = this.$editors[i];
|
|
152
|
+
editor.container.style.width = editorWidth + "px";
|
|
153
|
+
editor.container.style.top = "0px";
|
|
154
|
+
editor.container.style.left = i * editorWidth + "px";
|
|
155
|
+
editor.container.style.height = height + "px";
|
|
156
|
+
editor.resize();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
var editorHeight = height / this.$splits;
|
|
161
|
+
for (var i = 0; i < this.$splits; i++) {
|
|
162
|
+
editor = this.$editors[i];
|
|
163
|
+
editor.container.style.width = width + "px";
|
|
164
|
+
editor.container.style.top = i * editorHeight + "px";
|
|
165
|
+
editor.container.style.left = "0px";
|
|
166
|
+
editor.container.style.height = editorHeight + "px";
|
|
167
|
+
editor.resize();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
}).call(Split.prototype);
|
|
172
|
+
exports.Split = Split;
|
|
173
|
+
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
ace.define("ace/ext/split",["require","exports","module","ace/split"], function(require, exports, module){"use strict";
|
|
177
|
+
module.exports = require("../split");
|
|
178
|
+
|
|
179
|
+
}); (function() {
|
|
180
|
+
ace.require(["ace/ext/split"], function(m) {
|
|
181
|
+
if (typeof module == "object" && typeof exports == "object" && module) {
|
|
182
|
+
module.exports = m;
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
})();
|
|
186
|
+
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
ace.define("ace/ext/whitespace",["require","exports","module","ace/lib/lang"], function(require, exports, module){"use strict";
|
|
2
|
+
var lang = require("../lib/lang");
|
|
3
|
+
exports.$detectIndentation = function (lines, fallback) {
|
|
4
|
+
var stats = [];
|
|
5
|
+
var changes = [];
|
|
6
|
+
var tabIndents = 0;
|
|
7
|
+
var prevSpaces = 0;
|
|
8
|
+
var max = Math.min(lines.length, 1000);
|
|
9
|
+
for (var i = 0; i < max; i++) {
|
|
10
|
+
var line = lines[i];
|
|
11
|
+
if (!/^\s*[^*+\-\s]/.test(line))
|
|
12
|
+
continue;
|
|
13
|
+
if (line[0] == "\t") {
|
|
14
|
+
tabIndents++;
|
|
15
|
+
prevSpaces = -Number.MAX_VALUE;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
var spaces = line.match(/^ */)[0].length;
|
|
19
|
+
if (spaces && line[spaces] != "\t") {
|
|
20
|
+
var diff = spaces - prevSpaces;
|
|
21
|
+
if (diff > 0 && !(prevSpaces % diff) && !(spaces % diff))
|
|
22
|
+
changes[diff] = (changes[diff] || 0) + 1;
|
|
23
|
+
stats[spaces] = (stats[spaces] || 0) + 1;
|
|
24
|
+
}
|
|
25
|
+
prevSpaces = spaces;
|
|
26
|
+
}
|
|
27
|
+
while (i < max && line[line.length - 1] == "\\")
|
|
28
|
+
line = lines[i++];
|
|
29
|
+
}
|
|
30
|
+
function getScore(indent) {
|
|
31
|
+
var score = 0;
|
|
32
|
+
for (var i = indent; i < stats.length; i += indent)
|
|
33
|
+
score += stats[i] || 0;
|
|
34
|
+
return score;
|
|
35
|
+
}
|
|
36
|
+
var changesTotal = changes.reduce(function (a, b) { return a + b; }, 0);
|
|
37
|
+
var first = { score: 0, length: 0 };
|
|
38
|
+
var spaceIndents = 0;
|
|
39
|
+
for (var i = 1; i < 12; i++) {
|
|
40
|
+
var score = getScore(i);
|
|
41
|
+
if (i == 1) {
|
|
42
|
+
spaceIndents = score;
|
|
43
|
+
score = stats[1] ? 0.9 : 0.8;
|
|
44
|
+
if (!stats.length)
|
|
45
|
+
score = 0;
|
|
46
|
+
}
|
|
47
|
+
else
|
|
48
|
+
score /= spaceIndents;
|
|
49
|
+
if (changes[i])
|
|
50
|
+
score += changes[i] / changesTotal;
|
|
51
|
+
if (score > first.score)
|
|
52
|
+
first = { score: score, length: i };
|
|
53
|
+
}
|
|
54
|
+
if (first.score && first.score > 1.4)
|
|
55
|
+
var tabLength = first.length;
|
|
56
|
+
if (tabIndents > spaceIndents + 1) {
|
|
57
|
+
if (tabLength == 1 || spaceIndents < tabIndents / 4 || first.score < 1.8)
|
|
58
|
+
tabLength = undefined;
|
|
59
|
+
return { ch: "\t", length: tabLength };
|
|
60
|
+
}
|
|
61
|
+
if (spaceIndents > tabIndents + 1)
|
|
62
|
+
return { ch: " ", length: tabLength };
|
|
63
|
+
};
|
|
64
|
+
exports.detectIndentation = function (session) {
|
|
65
|
+
var lines = session.getLines(0, 1000);
|
|
66
|
+
var indent = exports.$detectIndentation(lines) || {};
|
|
67
|
+
if (indent.ch)
|
|
68
|
+
session.setUseSoftTabs(indent.ch == " ");
|
|
69
|
+
if (indent.length)
|
|
70
|
+
session.setTabSize(indent.length);
|
|
71
|
+
return indent;
|
|
72
|
+
};
|
|
73
|
+
exports.trimTrailingSpace = function (session, options) {
|
|
74
|
+
var doc = session.getDocument();
|
|
75
|
+
var lines = doc.getAllLines();
|
|
76
|
+
var min = options && options.trimEmpty ? -1 : 0;
|
|
77
|
+
var cursors = [], ci = -1;
|
|
78
|
+
if (options && options.keepCursorPosition) {
|
|
79
|
+
if (session.selection.rangeCount) {
|
|
80
|
+
session.selection.rangeList.ranges.forEach(function (x, i, ranges) {
|
|
81
|
+
var next = ranges[i + 1];
|
|
82
|
+
if (next && next.cursor.row == x.cursor.row)
|
|
83
|
+
return;
|
|
84
|
+
cursors.push(x.cursor);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
cursors.push(session.selection.getCursor());
|
|
89
|
+
}
|
|
90
|
+
ci = 0;
|
|
91
|
+
}
|
|
92
|
+
var cursorRow = cursors[ci] && cursors[ci].row;
|
|
93
|
+
for (var i = 0, l = lines.length; i < l; i++) {
|
|
94
|
+
var line = lines[i];
|
|
95
|
+
var index = line.search(/\s+$/);
|
|
96
|
+
if (i == cursorRow) {
|
|
97
|
+
if (index < cursors[ci].column && index > min)
|
|
98
|
+
index = cursors[ci].column;
|
|
99
|
+
ci++;
|
|
100
|
+
cursorRow = cursors[ci] ? cursors[ci].row : -1;
|
|
101
|
+
}
|
|
102
|
+
if (index > min)
|
|
103
|
+
doc.removeInLine(i, index, line.length);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
exports.convertIndentation = function (session, ch, len) {
|
|
107
|
+
var oldCh = session.getTabString()[0];
|
|
108
|
+
var oldLen = session.getTabSize();
|
|
109
|
+
if (!len)
|
|
110
|
+
len = oldLen;
|
|
111
|
+
if (!ch)
|
|
112
|
+
ch = oldCh;
|
|
113
|
+
var tab = ch == "\t" ? ch : lang.stringRepeat(ch, len);
|
|
114
|
+
var doc = session.doc;
|
|
115
|
+
var lines = doc.getAllLines();
|
|
116
|
+
var cache = {};
|
|
117
|
+
var spaceCache = {};
|
|
118
|
+
for (var i = 0, l = lines.length; i < l; i++) {
|
|
119
|
+
var line = lines[i];
|
|
120
|
+
var match = line.match(/^\s*/)[0];
|
|
121
|
+
if (match) {
|
|
122
|
+
var w = session.$getStringScreenWidth(match)[0];
|
|
123
|
+
var tabCount = Math.floor(w / oldLen);
|
|
124
|
+
var reminder = w % oldLen;
|
|
125
|
+
var toInsert = cache[tabCount] || (cache[tabCount] = lang.stringRepeat(tab, tabCount));
|
|
126
|
+
toInsert += spaceCache[reminder] || (spaceCache[reminder] = lang.stringRepeat(" ", reminder));
|
|
127
|
+
if (toInsert != match) {
|
|
128
|
+
doc.removeInLine(i, 0, match.length);
|
|
129
|
+
doc.insertInLine({ row: i, column: 0 }, toInsert);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
session.setTabSize(len);
|
|
134
|
+
session.setUseSoftTabs(ch == " ");
|
|
135
|
+
};
|
|
136
|
+
exports.$parseStringArg = function (text) {
|
|
137
|
+
var indent = {};
|
|
138
|
+
if (/t/.test(text))
|
|
139
|
+
indent.ch = "\t";
|
|
140
|
+
else if (/s/.test(text))
|
|
141
|
+
indent.ch = " ";
|
|
142
|
+
var m = text.match(/\d+/);
|
|
143
|
+
if (m)
|
|
144
|
+
indent.length = parseInt(m[0], 10);
|
|
145
|
+
return indent;
|
|
146
|
+
};
|
|
147
|
+
exports.$parseArg = function (arg) {
|
|
148
|
+
if (!arg)
|
|
149
|
+
return {};
|
|
150
|
+
if (typeof arg == "string")
|
|
151
|
+
return exports.$parseStringArg(arg);
|
|
152
|
+
if (typeof arg.text == "string")
|
|
153
|
+
return exports.$parseStringArg(arg.text);
|
|
154
|
+
return arg;
|
|
155
|
+
};
|
|
156
|
+
exports.commands = [{
|
|
157
|
+
name: "detectIndentation",
|
|
158
|
+
description: "Detect indentation from content",
|
|
159
|
+
exec: function (editor) {
|
|
160
|
+
exports.detectIndentation(editor.session);
|
|
161
|
+
}
|
|
162
|
+
}, {
|
|
163
|
+
name: "trimTrailingSpace",
|
|
164
|
+
description: "Trim trailing whitespace",
|
|
165
|
+
exec: function (editor, args) {
|
|
166
|
+
exports.trimTrailingSpace(editor.session, args);
|
|
167
|
+
}
|
|
168
|
+
}, {
|
|
169
|
+
name: "convertIndentation",
|
|
170
|
+
description: "Convert indentation to ...",
|
|
171
|
+
exec: function (editor, arg) {
|
|
172
|
+
var indent = exports.$parseArg(arg);
|
|
173
|
+
exports.convertIndentation(editor.session, indent.ch, indent.length);
|
|
174
|
+
}
|
|
175
|
+
}, {
|
|
176
|
+
name: "setIndentation",
|
|
177
|
+
description: "Set indentation",
|
|
178
|
+
exec: function (editor, arg) {
|
|
179
|
+
var indent = exports.$parseArg(arg);
|
|
180
|
+
indent.length && editor.session.setTabSize(indent.length);
|
|
181
|
+
indent.ch && editor.session.setUseSoftTabs(indent.ch == " ");
|
|
182
|
+
}
|
|
183
|
+
}];
|
|
184
|
+
|
|
185
|
+
}); (function() {
|
|
186
|
+
ace.require(["ace/ext/whitespace"], function(m) {
|
|
187
|
+
if (typeof module == "object" && typeof exports == "object" && module) {
|
|
188
|
+
module.exports = m;
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
})();
|
|
192
|
+
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
ace.define("ace/ext/spellcheck",["require","exports","module","ace/lib/event","ace/editor","ace/config"], function(require, exports, module){"use strict";
|
|
2
|
+
var event = require("../lib/event");
|
|
3
|
+
exports.contextMenuHandler = function (e) {
|
|
4
|
+
var host = e.target;
|
|
5
|
+
var text = host.textInput.getElement();
|
|
6
|
+
if (!host.selection.isEmpty())
|
|
7
|
+
return;
|
|
8
|
+
var c = host.getCursorPosition();
|
|
9
|
+
var r = host.session.getWordRange(c.row, c.column);
|
|
10
|
+
var w = host.session.getTextRange(r);
|
|
11
|
+
host.session.tokenRe.lastIndex = 0;
|
|
12
|
+
if (!host.session.tokenRe.test(w))
|
|
13
|
+
return;
|
|
14
|
+
var PLACEHOLDER = "\x01\x01";
|
|
15
|
+
var value = w + " " + PLACEHOLDER;
|
|
16
|
+
text.value = value;
|
|
17
|
+
text.setSelectionRange(w.length, w.length + 1);
|
|
18
|
+
text.setSelectionRange(0, 0);
|
|
19
|
+
text.setSelectionRange(0, w.length);
|
|
20
|
+
var afterKeydown = false;
|
|
21
|
+
event.addListener(text, "keydown", function onKeydown() {
|
|
22
|
+
event.removeListener(text, "keydown", onKeydown);
|
|
23
|
+
afterKeydown = true;
|
|
24
|
+
});
|
|
25
|
+
host.textInput.setInputHandler(function (newVal) {
|
|
26
|
+
if (newVal == value)
|
|
27
|
+
return '';
|
|
28
|
+
if (newVal.lastIndexOf(value, 0) === 0)
|
|
29
|
+
return newVal.slice(value.length);
|
|
30
|
+
if (newVal.substr(text.selectionEnd) == value)
|
|
31
|
+
return newVal.slice(0, -value.length);
|
|
32
|
+
if (newVal.slice(-2) == PLACEHOLDER) {
|
|
33
|
+
var val = newVal.slice(0, -2);
|
|
34
|
+
if (val.slice(-1) == " ") {
|
|
35
|
+
if (afterKeydown)
|
|
36
|
+
return val.substring(0, text.selectionEnd);
|
|
37
|
+
val = val.slice(0, -1);
|
|
38
|
+
host.session.replace(r, val);
|
|
39
|
+
return "";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return newVal;
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
var Editor = require("../editor").Editor;
|
|
46
|
+
require("../config").defineOptions(Editor.prototype, "editor", {
|
|
47
|
+
spellcheck: {
|
|
48
|
+
set: function (val) {
|
|
49
|
+
var text = this.textInput.getElement();
|
|
50
|
+
text.spellcheck = !!val;
|
|
51
|
+
if (!val)
|
|
52
|
+
this.removeListener("nativecontextmenu", exports.contextMenuHandler);
|
|
53
|
+
else
|
|
54
|
+
this.on("nativecontextmenu", exports.contextMenuHandler);
|
|
55
|
+
},
|
|
56
|
+
value: true
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
}); (function() {
|
|
61
|
+
ace.require(["ace/ext/spellcheck"], function(m) {
|
|
62
|
+
if (typeof module == "object" && typeof exports == "object" && module) {
|
|
63
|
+
module.exports = m;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
})();
|
|
67
|
+
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
ace.define("ace/ext/hardwrap",["require","exports","module","ace/range","ace/editor","ace/config"], function(require, exports, module){"use strict";
|
|
2
|
+
var Range = require("../range").Range;
|
|
3
|
+
function hardWrap(editor, options) {
|
|
4
|
+
var max = options.column || editor.getOption("printMarginColumn");
|
|
5
|
+
var allowMerge = options.allowMerge != false;
|
|
6
|
+
var row = Math.min(options.startRow, options.endRow);
|
|
7
|
+
var endRow = Math.max(options.startRow, options.endRow);
|
|
8
|
+
var session = editor.session;
|
|
9
|
+
while (row <= endRow) {
|
|
10
|
+
var line = session.getLine(row);
|
|
11
|
+
if (line.length > max) {
|
|
12
|
+
var space = findSpace(line, max, 5);
|
|
13
|
+
if (space) {
|
|
14
|
+
var indentation = /^\s*/.exec(line)[0];
|
|
15
|
+
session.replace(new Range(row, space.start, row, space.end), "\n" + indentation);
|
|
16
|
+
}
|
|
17
|
+
endRow++;
|
|
18
|
+
}
|
|
19
|
+
else if (allowMerge && /\S/.test(line) && row != endRow) {
|
|
20
|
+
var nextLine = session.getLine(row + 1);
|
|
21
|
+
if (nextLine && /\S/.test(nextLine)) {
|
|
22
|
+
var trimmedLine = line.replace(/\s+$/, "");
|
|
23
|
+
var trimmedNextLine = nextLine.replace(/^\s+/, "");
|
|
24
|
+
var mergedLine = trimmedLine + " " + trimmedNextLine;
|
|
25
|
+
var space = findSpace(mergedLine, max, 5);
|
|
26
|
+
if (space && space.start > trimmedLine.length || mergedLine.length < max) {
|
|
27
|
+
var replaceRange = new Range(row, trimmedLine.length, row + 1, nextLine.length - trimmedNextLine.length);
|
|
28
|
+
session.replace(replaceRange, " ");
|
|
29
|
+
row--;
|
|
30
|
+
endRow--;
|
|
31
|
+
}
|
|
32
|
+
else if (trimmedLine.length < line.length) {
|
|
33
|
+
session.remove(new Range(row, trimmedLine.length, row, line.length));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
row++;
|
|
38
|
+
}
|
|
39
|
+
function findSpace(line, max, min) {
|
|
40
|
+
if (line.length < max)
|
|
41
|
+
return;
|
|
42
|
+
var before = line.slice(0, max);
|
|
43
|
+
var after = line.slice(max);
|
|
44
|
+
var spaceAfter = /^(?:(\s+)|(\S+)(\s+))/.exec(after);
|
|
45
|
+
var spaceBefore = /(?:(\s+)|(\s+)(\S+))$/.exec(before);
|
|
46
|
+
var start = 0;
|
|
47
|
+
var end = 0;
|
|
48
|
+
if (spaceBefore && !spaceBefore[2]) {
|
|
49
|
+
start = max - spaceBefore[1].length;
|
|
50
|
+
end = max;
|
|
51
|
+
}
|
|
52
|
+
if (spaceAfter && !spaceAfter[2]) {
|
|
53
|
+
if (!start)
|
|
54
|
+
start = max;
|
|
55
|
+
end = max + spaceAfter[1].length;
|
|
56
|
+
}
|
|
57
|
+
if (start) {
|
|
58
|
+
return {
|
|
59
|
+
start: start,
|
|
60
|
+
end: end
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
if (spaceBefore && spaceBefore[2] && spaceBefore.index > min) {
|
|
64
|
+
return {
|
|
65
|
+
start: spaceBefore.index,
|
|
66
|
+
end: spaceBefore.index + spaceBefore[2].length
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
if (spaceAfter && spaceAfter[2]) {
|
|
70
|
+
start = max + spaceAfter[2].length;
|
|
71
|
+
return {
|
|
72
|
+
start: start,
|
|
73
|
+
end: start + spaceAfter[3].length
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function wrapAfterInput(e) {
|
|
79
|
+
if (e.command.name == "insertstring" && /\S/.test(e.args)) {
|
|
80
|
+
var editor = e.editor;
|
|
81
|
+
var cursor = editor.selection.cursor;
|
|
82
|
+
if (cursor.column <= editor.renderer.$printMarginColumn)
|
|
83
|
+
return;
|
|
84
|
+
var lastDelta = editor.session.$undoManager.$lastDelta;
|
|
85
|
+
hardWrap(editor, {
|
|
86
|
+
startRow: cursor.row, endRow: cursor.row,
|
|
87
|
+
allowMerge: false
|
|
88
|
+
});
|
|
89
|
+
if (lastDelta != editor.session.$undoManager.$lastDelta)
|
|
90
|
+
editor.session.markUndoGroup();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
var Editor = require("../editor").Editor;
|
|
94
|
+
require("../config").defineOptions(Editor.prototype, "editor", {
|
|
95
|
+
hardWrap: {
|
|
96
|
+
set: function (val) {
|
|
97
|
+
if (val) {
|
|
98
|
+
this.commands.on("afterExec", wrapAfterInput);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
this.commands.off("afterExec", wrapAfterInput);
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
value: false
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
exports.hardWrap = hardWrap;
|
|
108
|
+
|
|
109
|
+
}); (function() {
|
|
110
|
+
ace.require(["ace/ext/hardwrap"], function(m) {
|
|
111
|
+
if (typeof module == "object" && typeof exports == "object" && module) {
|
|
112
|
+
module.exports = m;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
})();
|
|
116
|
+
|