@taufik-nurrohman/text-editor.source 2.2.9 → 2.2.10

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.
Files changed (3) hide show
  1. package/index.js +84 -84
  2. package/index.mjs +60 -60
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -141,11 +141,11 @@
141
141
  var CTRL_PREFIX = 'Control-';
142
142
  var SHIFT_PREFIX = 'Shift-';
143
143
 
144
- function canKeyDown(map, that) {
144
+ function canKeyDown(map, of) {
145
145
  var charAfter,
146
146
  charBefore,
147
- charIndent = that.state.source.tab || that.state.tab || '\t',
148
- charPairs = that.state.source.pairs || {},
147
+ charIndent = of.state.source.tab || of.state.tab || '\t',
148
+ charPairs = of.state.source.pairs || {},
149
149
  charPairsValues = toObjectValues(charPairs),
150
150
  key = map.key,
151
151
  queue = map.queue,
@@ -155,42 +155,42 @@
155
155
  return true;
156
156
  }
157
157
  if (' ' === keyValue) {
158
- var _that$$ = that.$(),
159
- _after = _that$$.after,
160
- _before = _that$$.before,
161
- _value = _that$$.value;
158
+ var _of$$ = of.$(),
159
+ _after = _of$$.after,
160
+ _before = _of$$.before,
161
+ _value = _of$$.value;
162
162
  charAfter = charPairs[charBefore = _before.slice(-1)];
163
163
  if (!_value && charAfter && charBefore && charAfter === _after[0]) {
164
- that.wrap(' ', ' ');
164
+ of.wrap(' ', ' ');
165
165
  return false;
166
166
  }
167
167
  return true;
168
168
  }
169
169
  if ('Enter' === keyValue) {
170
- var _that$$2 = that.$(),
171
- _after2 = _that$$2.after,
172
- _before2 = _that$$2.before,
173
- _value2 = _that$$2.value,
170
+ var _of$$2 = of.$(),
171
+ _after2 = _of$$2.after,
172
+ _before2 = _of$$2.before,
173
+ _value2 = _of$$2.value,
174
174
  lineBefore = _before2.split('\n').pop(),
175
175
  lineMatch = lineBefore.match(/^(\s+)/),
176
176
  lineMatchIndent = lineMatch && lineMatch[1] || "";
177
177
  if (!_value2) {
178
178
  if (_after2 && _before2 && (charAfter = charPairs[charBefore = _before2.slice(-1)]) && charAfter === _after2[0]) {
179
- that.wrap('\n' + lineMatchIndent + (charBefore !== charAfter ? charIndent : ""), '\n' + lineMatchIndent).record();
179
+ of.wrap('\n' + lineMatchIndent + (charBefore !== charAfter ? charIndent : ""), '\n' + lineMatchIndent).record();
180
180
  return false;
181
181
  }
182
182
  if (lineMatchIndent) {
183
- that.insert('\n' + lineMatchIndent, -1).record();
183
+ of.insert('\n' + lineMatchIndent, -1).record();
184
184
  return false;
185
185
  }
186
186
  }
187
187
  return true;
188
188
  }
189
189
  if ('Backspace' === keyValue) {
190
- var _that$$3 = that.$(),
191
- _after3 = _that$$3.after,
192
- _before3 = _that$$3.before,
193
- _value3 = _that$$3.value;
190
+ var _of$$3 = of.$(),
191
+ _after3 = _of$$3.after,
192
+ _before3 = _of$$3.before,
193
+ _value3 = _of$$3.value;
194
194
  _after3.split('\n')[0];
195
195
  var _lineBefore = _before3.split('\n').pop(),
196
196
  _lineMatch = _lineBefore.match(/^(\s+)/),
@@ -202,7 +202,7 @@
202
202
  }
203
203
  if (_value3) {
204
204
  if (_after3 && _before3 && charAfter && charAfter === _after3[0] && !_before3.endsWith('\\' + charBefore)) {
205
- that.record().peel(charBefore, charAfter).record();
205
+ of.record().peel(charBefore, charAfter).record();
206
206
  return false;
207
207
  }
208
208
  return true;
@@ -211,29 +211,29 @@
211
211
  if (charAfter && charBefore) {
212
212
  if (_after3.startsWith(' ' + charAfter) && _before3.endsWith(charBefore + ' ') || _after3.startsWith('\n' + _lineMatchIndent + charAfter) && _before3.endsWith(charBefore + '\n' + _lineMatchIndent)) {
213
213
  // Collapse bracket(s)
214
- that.trim("", "").record();
214
+ of.trim("", "").record();
215
215
  return false;
216
216
  }
217
217
  }
218
218
  // Outdent
219
219
  if (_lineBefore.endsWith(charIndent)) {
220
- that.pull(charIndent).record();
220
+ of.pull(charIndent).record();
221
221
  return false;
222
222
  }
223
223
  if (_after3 && _before3 && !_before3.endsWith('\\' + charBefore)) {
224
224
  if (charAfter === _after3[0] && charBefore === _before3.slice(-1)) {
225
225
  // Peel pair
226
- that.peel(charBefore, charAfter).record();
226
+ of.peel(charBefore, charAfter).record();
227
227
  return false;
228
228
  }
229
229
  }
230
230
  return true;
231
231
  }
232
- var _that$$4 = that.$(),
233
- after = _that$$4.after,
234
- before = _that$$4.before,
235
- start = _that$$4.start,
236
- value = _that$$4.value;
232
+ var _of$$4 = of.$(),
233
+ after = _of$$4.after,
234
+ before = _of$$4.before,
235
+ start = _of$$4.start,
236
+ value = _of$$4.value;
237
237
  // Do nothing on escape
238
238
  if ('\\' === (charBefore = before.slice(-1))) {
239
239
  return true;
@@ -243,7 +243,7 @@
243
243
  if (!value && after && before && charAfter && key === charAfter) {
244
244
  // Move to the next character
245
245
  // `}|`
246
- that.select(start + 1).record();
246
+ of.select(start + 1).record();
247
247
  return false;
248
248
  }
249
249
  for (charBefore in charPairs) {
@@ -252,7 +252,7 @@
252
252
  if (key === charBefore && charAfter) {
253
253
  // Wrap pair or selection
254
254
  // `{|}` `{|aaa|}`
255
- that.wrap(charBefore, charAfter).record();
255
+ of.wrap(charBefore, charAfter).record();
256
256
  return false;
257
257
  }
258
258
  // `|}`
@@ -260,7 +260,7 @@
260
260
  if (value) {
261
261
  // Wrap selection
262
262
  // `{|aaa|}`
263
- that.record().wrap(charBefore, charAfter).record();
263
+ of.record().wrap(charBefore, charAfter).record();
264
264
  return false;
265
265
  }
266
266
  break;
@@ -269,34 +269,34 @@
269
269
  return true;
270
270
  }
271
271
 
272
- function canKeyDownDent(map, that) {
273
- var charIndent = that.state.source.tab || that.state.tab || '\t';
272
+ function canKeyDownDent(map, of) {
273
+ var charIndent = of.state.source.tab || of.state.tab || '\t';
274
274
  map.key;
275
275
  map.queue;
276
276
  var keyValue = map + "";
277
277
  // Indent with `⎈]`
278
278
  if (CTRL_PREFIX + ']' === keyValue) {
279
- that.push(charIndent).record();
279
+ of.push(charIndent).record();
280
280
  return false;
281
281
  }
282
282
  // Outdent with `⎈[`
283
283
  if (CTRL_PREFIX + '[' === keyValue) {
284
- that.pull(charIndent).record();
284
+ of.pull(charIndent).record();
285
285
  return false;
286
286
  }
287
287
  return true;
288
288
  }
289
289
 
290
- function canKeyDownEnter(map, that) {
290
+ function canKeyDownEnter(map, of) {
291
291
  map.key;
292
292
  var queue = map.queue;
293
293
  if (queue.Control && queue.Enter) {
294
- var _that$$5 = that.$(),
295
- after = _that$$5.after,
296
- before = _that$$5.before,
297
- end = _that$$5.end,
298
- start = _that$$5.start,
299
- value = _that$$5.value,
294
+ var _of$$5 = of.$(),
295
+ after = _of$$5.after,
296
+ before = _of$$5.before,
297
+ end = _of$$5.end,
298
+ start = _of$$5.start,
299
+ value = _of$$5.value,
300
300
  lineAfter = after.split('\n').shift(),
301
301
  lineBefore = before.split('\n').pop(),
302
302
  lineMatch = lineBefore.match(/^(\s+)/),
@@ -304,44 +304,44 @@
304
304
  if (before || after) {
305
305
  if (queue.Shift) {
306
306
  // Insert line over with `⎈⇧↵`
307
- return that.select(start - toCount(lineBefore)).wrap(lineMatchIndent, '\n').insert(value).record(), false;
307
+ return of.select(start - toCount(lineBefore)).wrap(lineMatchIndent, '\n').insert(value).record(), false;
308
308
  }
309
309
  // Insert line below with `⎈↵`
310
- return that.select(end + toCount(lineAfter)).wrap('\n' + lineMatchIndent, "").insert(value).record(), false;
310
+ return of.select(end + toCount(lineAfter)).wrap('\n' + lineMatchIndent, "").insert(value).record(), false;
311
311
  }
312
312
  }
313
313
  return true;
314
314
  }
315
315
 
316
- function canKeyDownHistory(map, that) {
316
+ function canKeyDownHistory(map, of) {
317
317
  var keyValue = map + "";
318
318
  // Redo with `⎈y`
319
319
  if (CTRL_PREFIX + 'y' === keyValue) {
320
- return that.redo(), false;
320
+ return of.redo(), false;
321
321
  }
322
322
  // Undo with `⎈z`
323
323
  if (CTRL_PREFIX + 'z' === keyValue) {
324
- return that.undo(), false;
324
+ return of.undo(), false;
325
325
  }
326
326
  return true;
327
327
  }
328
328
 
329
- function canKeyDownMove(map, that) {
329
+ function canKeyDownMove(map, of) {
330
330
  map.key;
331
331
  var queue = map.queue,
332
332
  keyValue = map + "";
333
333
  if (!queue.Control) {
334
334
  return true;
335
335
  }
336
- var _that$$6 = that.$(),
337
- after = _that$$6.after,
338
- before = _that$$6.before,
339
- end = _that$$6.end,
340
- start = _that$$6.start,
341
- value = _that$$6.value,
336
+ var _of$$6 = of.$(),
337
+ after = _of$$6.after,
338
+ before = _of$$6.before,
339
+ end = _of$$6.end,
340
+ start = _of$$6.start,
341
+ value = _of$$6.value,
342
342
  charPair,
343
343
  charPairValue,
344
- charPairs = that.state.source.pairs || {},
344
+ charPairs = of.state.source.pairs || {},
345
345
  boundaries = [],
346
346
  m;
347
347
  if (value) {
@@ -356,17 +356,17 @@
356
356
  boundaries.push('[\\s\\S]'); // Last try!
357
357
  if (CTRL_PREFIX + 'ArrowLeft' === keyValue) {
358
358
  if (m = before.match(toPattern('(' + boundaries.join('|') + ')$', ""))) {
359
- that.insert("").select(start - toCount(m[0])).insert(value);
360
- return that.record(), false;
359
+ of.insert("").select(start - toCount(m[0])).insert(value);
360
+ return of.record(), false;
361
361
  }
362
- return that.select(), false;
362
+ return of.select(), false;
363
363
  }
364
364
  if (CTRL_PREFIX + 'ArrowRight' === keyValue) {
365
365
  if (m = after.match(toPattern('^(' + boundaries.join('|') + ')', ""))) {
366
- that.insert("").select(end + toCount(m[0]) - toCount(value)).insert(value);
367
- return that.record(), false;
366
+ of.insert("").select(end + toCount(m[0]) - toCount(value)).insert(value);
367
+ return of.record(), false;
368
368
  }
369
- return that.select(), false;
369
+ return of.select(), false;
370
370
  }
371
371
  }
372
372
  var lineAfter = after.split('\n').shift(),
@@ -379,57 +379,57 @@
379
379
  value = lineBefore + value + lineAfter;
380
380
  if (CTRL_PREFIX + 'ArrowUp' === keyValue) {
381
381
  if (!hasValue('\n', before)) {
382
- return that.select(), false;
382
+ return of.select(), false;
383
383
  }
384
- that.insert("");
385
- that.replace(/^([^\n]*?)(\n|$)/, '$2', 1);
386
- that.replace(/(^|\n)([^\n]*?)$/, "", -1);
387
- var $ = that.$();
384
+ of.insert("");
385
+ of.replace(/^([^\n]*?)(\n|$)/, '$2', 1);
386
+ of.replace(/(^|\n)([^\n]*?)$/, "", -1);
387
+ var $ = of.$();
388
388
  before = $.before;
389
389
  start = $.start;
390
390
  lineBefore = before.split('\n').pop();
391
- that.select(start = start - toCount(lineBefore)).wrap(value, '\n');
392
- that.select(start, start + toCount(value));
393
- return that.record(), false;
391
+ of.select(start = start - toCount(lineBefore)).wrap(value, '\n');
392
+ of.select(start, start + toCount(value));
393
+ return of.record(), false;
394
394
  }
395
395
  if (CTRL_PREFIX + 'ArrowDown' === keyValue) {
396
396
  if (!hasValue('\n', after)) {
397
- return that.select(), false;
397
+ return of.select(), false;
398
398
  }
399
- that.insert("");
400
- that.replace(/^([^\n]*?)(\n|$)/, "", 1);
401
- that.replace(/(^|\n)([^\n]*?)$/, '$1', -1);
402
- var _$ = that.$();
399
+ of.insert("");
400
+ of.replace(/^([^\n]*?)(\n|$)/, "", 1);
401
+ of.replace(/(^|\n)([^\n]*?)$/, '$1', -1);
402
+ var _$ = of.$();
403
403
  after = _$.after;
404
404
  end = _$.end;
405
405
  lineAfter = after.split('\n').shift();
406
- that.select(end = end + toCount(lineAfter)).wrap('\n', value);
406
+ of.select(end = end + toCount(lineAfter)).wrap('\n', value);
407
407
  end += 1;
408
- that.select(end, end + toCount(value));
409
- return that.record(), false;
408
+ of.select(end, end + toCount(value));
409
+ return of.record(), false;
410
410
  }
411
411
  return true;
412
412
  }
413
413
 
414
- function canKeyDownTab(map, that) {
415
- var charIndent = that.state.source.tab || that.state.tab || '\t',
414
+ function canKeyDownTab(map, of) {
415
+ var charIndent = of.state.source.tab || of.state.tab || '\t',
416
416
  keyValue = map + "";
417
417
  // Indent with `⇥`
418
418
  if ('Tab' === keyValue) {
419
- return that.push(charIndent).record(), false;
419
+ return of.push(charIndent).record(), false;
420
420
  }
421
421
  // Outdent with `⇧+⇥`
422
422
  if (SHIFT_PREFIX + 'Tab' === keyValue) {
423
- return that.pull(charIndent).record(), false;
423
+ return of.pull(charIndent).record(), false;
424
424
  }
425
425
  return true;
426
426
  }
427
- var bounce = debounce(function (that) {
428
- return that.record();
427
+ var bounce = debounce(function (of) {
428
+ return of.record();
429
429
  }, 100);
430
430
 
431
- function canKeyUp(map, that) {
432
- return bounce(that), true;
431
+ function canKeyUp(map, of) {
432
+ return bounce(of), true;
433
433
  }
434
434
  var state = defaults;
435
435
  exports.canKeyDown = canKeyDown;
package/index.mjs CHANGED
@@ -67,11 +67,11 @@ const ALT_PREFIX = 'Alt-';
67
67
  const CTRL_PREFIX = 'Control-';
68
68
  const SHIFT_PREFIX = 'Shift-';
69
69
 
70
- export function canKeyDown(map, that) {
70
+ export function canKeyDown(map, of) {
71
71
  let charAfter,
72
72
  charBefore,
73
- charIndent = that.state.source.tab || that.state.tab || '\t',
74
- charPairs = that.state.source.pairs || {},
73
+ charIndent = of.state.source.tab || of.state.tab || '\t',
74
+ charPairs = of.state.source.pairs || {},
75
75
  charPairsValues = toObjectValues(charPairs),
76
76
  {key, queue} = map,
77
77
  keyValue = map + "";
@@ -80,33 +80,33 @@ export function canKeyDown(map, that) {
80
80
  return true;
81
81
  }
82
82
  if (' ' === keyValue) {
83
- let {after, before, value} = that.$();
83
+ let {after, before, value} = of.$();
84
84
  charAfter = charPairs[charBefore = before.slice(-1)];
85
85
  if (!value && charAfter && charBefore && charAfter === after[0]) {
86
- that.wrap(' ', ' ');
86
+ of.wrap(' ', ' ');
87
87
  return false;
88
88
  }
89
89
  return true;
90
90
  }
91
91
  if ('Enter' === keyValue) {
92
- let {after, before, value} = that.$(),
92
+ let {after, before, value} = of.$(),
93
93
  lineBefore = before.split('\n').pop(),
94
94
  lineMatch = lineBefore.match(/^(\s+)/),
95
95
  lineMatchIndent = lineMatch && lineMatch[1] || "";
96
96
  if (!value) {
97
97
  if (after && before && (charAfter = charPairs[charBefore = before.slice(-1)]) && charAfter === after[0]) {
98
- that.wrap('\n' + lineMatchIndent + (charBefore !== charAfter ? charIndent : ""), '\n' + lineMatchIndent).record();
98
+ of.wrap('\n' + lineMatchIndent + (charBefore !== charAfter ? charIndent : ""), '\n' + lineMatchIndent).record();
99
99
  return false;
100
100
  }
101
101
  if (lineMatchIndent) {
102
- that.insert('\n' + lineMatchIndent, -1).record();
102
+ of.insert('\n' + lineMatchIndent, -1).record();
103
103
  return false;
104
104
  }
105
105
  }
106
106
  return true;
107
107
  }
108
108
  if ('Backspace' === keyValue) {
109
- let {after, before, value} = that.$(),
109
+ let {after, before, value} = of.$(),
110
110
  lineAfter = after.split('\n')[0],
111
111
  lineBefore = before.split('\n').pop(),
112
112
  lineMatch = lineBefore.match(/^(\s+)/),
@@ -118,7 +118,7 @@ export function canKeyDown(map, that) {
118
118
  }
119
119
  if (value) {
120
120
  if (after && before && charAfter && charAfter === after[0] && !before.endsWith('\\' + charBefore)) {
121
- that.record().peel(charBefore, charAfter).record();
121
+ of.record().peel(charBefore, charAfter).record();
122
122
  return false;
123
123
  }
124
124
  return true;
@@ -130,25 +130,25 @@ export function canKeyDown(map, that) {
130
130
  after.startsWith('\n' + lineMatchIndent + charAfter) && before.endsWith(charBefore + '\n' + lineMatchIndent)
131
131
  ) {
132
132
  // Collapse bracket(s)
133
- that.trim("", "").record();
133
+ of.trim("", "").record();
134
134
  return false;
135
135
  }
136
136
  }
137
137
  // Outdent
138
138
  if (lineBefore.endsWith(charIndent)) {
139
- that.pull(charIndent).record();
139
+ of.pull(charIndent).record();
140
140
  return false;
141
141
  }
142
142
  if (after && before && !before.endsWith('\\' + charBefore)) {
143
143
  if (charAfter === after[0] && charBefore === before.slice(-1)) {
144
144
  // Peel pair
145
- that.peel(charBefore, charAfter).record();
145
+ of.peel(charBefore, charAfter).record();
146
146
  return false;
147
147
  }
148
148
  }
149
149
  return true;
150
150
  }
151
- let {after, before, start, value} = that.$();
151
+ let {after, before, start, value} = of.$();
152
152
  // Do nothing on escape
153
153
  if ('\\' === (charBefore = before.slice(-1))) {
154
154
  return true;
@@ -158,7 +158,7 @@ export function canKeyDown(map, that) {
158
158
  if (!value && after && before && charAfter && key === charAfter) {
159
159
  // Move to the next character
160
160
  // `}|`
161
- that.select(start + 1).record();
161
+ of.select(start + 1).record();
162
162
  return false;
163
163
  }
164
164
  for (charBefore in charPairs) {
@@ -167,7 +167,7 @@ export function canKeyDown(map, that) {
167
167
  if (key === charBefore && charAfter) {
168
168
  // Wrap pair or selection
169
169
  // `{|}` `{|aaa|}`
170
- that.wrap(charBefore, charAfter).record();
170
+ of.wrap(charBefore, charAfter).record();
171
171
  return false;
172
172
  }
173
173
  // `|}`
@@ -175,7 +175,7 @@ export function canKeyDown(map, that) {
175
175
  if (value) {
176
176
  // Wrap selection
177
177
  // `{|aaa|}`
178
- that.record().wrap(charBefore, charAfter).record();
178
+ of.record().wrap(charBefore, charAfter).record();
179
179
  return false;
180
180
  }
181
181
  break;
@@ -184,27 +184,27 @@ export function canKeyDown(map, that) {
184
184
  return true;
185
185
  }
186
186
 
187
- export function canKeyDownDent(map, that) {
188
- let charIndent = that.state.source.tab || that.state.tab || '\t',
187
+ export function canKeyDownDent(map, of) {
188
+ let charIndent = of.state.source.tab || of.state.tab || '\t',
189
189
  {key, queue} = map,
190
190
  keyValue = map + "";
191
191
  // Indent with `⎈]`
192
192
  if (CTRL_PREFIX + ']' === keyValue) {
193
- that.push(charIndent).record();
193
+ of.push(charIndent).record();
194
194
  return false;
195
195
  }
196
196
  // Outdent with `⎈[`
197
197
  if (CTRL_PREFIX + '[' === keyValue) {
198
- that.pull(charIndent).record();
198
+ of.pull(charIndent).record();
199
199
  return false;
200
200
  }
201
201
  return true;
202
202
  }
203
203
 
204
- export function canKeyDownEnter(map, that) {
204
+ export function canKeyDownEnter(map, of) {
205
205
  let {key, queue} = map;
206
206
  if (queue.Control && queue.Enter) {
207
- let {after, before, end, start, value} = that.$(),
207
+ let {after, before, end, start, value} = of.$(),
208
208
  lineAfter = after.split('\n').shift(),
209
209
  lineBefore = before.split('\n').pop(),
210
210
  lineMatch = lineBefore.match(/^(\s+)/),
@@ -212,37 +212,37 @@ export function canKeyDownEnter(map, that) {
212
212
  if (before || after) {
213
213
  if (queue.Shift) {
214
214
  // Insert line over with `⎈⇧↵`
215
- return that.select(start - toCount(lineBefore)).wrap(lineMatchIndent, '\n').insert(value).record(), false;
215
+ return of.select(start - toCount(lineBefore)).wrap(lineMatchIndent, '\n').insert(value).record(), false;
216
216
  }
217
217
  // Insert line below with `⎈↵`
218
- return that.select(end + toCount(lineAfter)).wrap('\n' + lineMatchIndent, "").insert(value).record(), false;
218
+ return of.select(end + toCount(lineAfter)).wrap('\n' + lineMatchIndent, "").insert(value).record(), false;
219
219
  }
220
220
  }
221
221
  return true;
222
222
  }
223
223
 
224
- export function canKeyDownHistory(map, that) {
224
+ export function canKeyDownHistory(map, of) {
225
225
  let keyValue = map + "";
226
226
  // Redo with `⎈y`
227
227
  if (CTRL_PREFIX + 'y' === keyValue) {
228
- return that.redo(), false;
228
+ return of.redo(), false;
229
229
  }
230
230
  // Undo with `⎈z`
231
231
  if (CTRL_PREFIX + 'z' === keyValue) {
232
- return that.undo(), false;
232
+ return of.undo(), false;
233
233
  }
234
234
  return true;
235
235
  }
236
236
 
237
- export function canKeyDownMove(map, that) {
237
+ export function canKeyDownMove(map, of) {
238
238
  let {key, queue} = map,
239
239
  keyValue = map + "";
240
240
  if (!queue.Control) {
241
241
  return true;
242
242
  }
243
- let {after, before, end, start, value} = that.$(),
243
+ let {after, before, end, start, value} = of.$(),
244
244
  charPair, charPairValue,
245
- charPairs = that.state.source.pairs || {},
245
+ charPairs = of.state.source.pairs || {},
246
246
  boundaries = [], m;
247
247
  if (value) {
248
248
  for (charPair in charPairs) {
@@ -256,17 +256,17 @@ export function canKeyDownMove(map, that) {
256
256
  boundaries.push('[\\s\\S]'); // Last try!
257
257
  if (CTRL_PREFIX + 'ArrowLeft' === keyValue) {
258
258
  if (m = before.match(toPattern('(' + boundaries.join('|') + ')$', ""))) {
259
- that.insert("").select(start - toCount(m[0])).insert(value);
260
- return that.record(), false;
259
+ of.insert("").select(start - toCount(m[0])).insert(value);
260
+ return of.record(), false;
261
261
  }
262
- return that.select(), false;
262
+ return of.select(), false;
263
263
  }
264
264
  if (CTRL_PREFIX + 'ArrowRight' === keyValue) {
265
265
  if (m = after.match(toPattern('^(' + boundaries.join('|') + ')', ""))) {
266
- that.insert("").select(end + toCount(m[0]) - toCount(value)).insert(value);
267
- return that.record(), false;
266
+ of.insert("").select(end + toCount(m[0]) - toCount(value)).insert(value);
267
+ return of.record(), false;
268
268
  }
269
- return that.select(), false;
269
+ return of.select(), false;
270
270
  }
271
271
  }
272
272
  let lineAfter = after.split('\n').shift(),
@@ -279,56 +279,56 @@ export function canKeyDownMove(map, that) {
279
279
  value = lineBefore + value + lineAfter;
280
280
  if (CTRL_PREFIX + 'ArrowUp' === keyValue) {
281
281
  if (!hasValue('\n', before)) {
282
- return that.select(), false;
282
+ return of.select(), false;
283
283
  }
284
- that.insert("");
285
- that.replace(/^([^\n]*?)(\n|$)/, '$2', 1);
286
- that.replace(/(^|\n)([^\n]*?)$/, "", -1);
287
- let $ = that.$();
284
+ of.insert("");
285
+ of.replace(/^([^\n]*?)(\n|$)/, '$2', 1);
286
+ of.replace(/(^|\n)([^\n]*?)$/, "", -1);
287
+ let $ = of.$();
288
288
  before = $.before;
289
289
  start = $.start;
290
290
  lineBefore = before.split('\n').pop();
291
- that.select(start = start - toCount(lineBefore)).wrap(value, '\n');
292
- that.select(start, start + toCount(value));
293
- return that.record(), false;
291
+ of.select(start = start - toCount(lineBefore)).wrap(value, '\n');
292
+ of.select(start, start + toCount(value));
293
+ return of.record(), false;
294
294
  }
295
295
  if (CTRL_PREFIX + 'ArrowDown' === keyValue) {
296
296
  if (!hasValue('\n', after)) {
297
- return that.select(), false;
297
+ return of.select(), false;
298
298
  }
299
- that.insert("");
300
- that.replace(/^([^\n]*?)(\n|$)/, "", 1);
301
- that.replace(/(^|\n)([^\n]*?)$/, '$1', -1);
302
- let $ = that.$();
299
+ of.insert("");
300
+ of.replace(/^([^\n]*?)(\n|$)/, "", 1);
301
+ of.replace(/(^|\n)([^\n]*?)$/, '$1', -1);
302
+ let $ = of.$();
303
303
  after = $.after;
304
304
  end = $.end;
305
305
  lineAfter = after.split('\n').shift();
306
- that.select(end = end + toCount(lineAfter)).wrap('\n', value);
306
+ of.select(end = end + toCount(lineAfter)).wrap('\n', value);
307
307
  end += 1;
308
- that.select(end, end + toCount(value));
309
- return that.record(), false;
308
+ of.select(end, end + toCount(value));
309
+ return of.record(), false;
310
310
  }
311
311
  return true;
312
312
  }
313
313
 
314
- export function canKeyDownTab(map, that) {
315
- let charIndent = that.state.source.tab || that.state.tab || '\t',
314
+ export function canKeyDownTab(map, of) {
315
+ let charIndent = of.state.source.tab || of.state.tab || '\t',
316
316
  keyValue = map + "";
317
317
  // Indent with `⇥`
318
318
  if ('Tab' === keyValue) {
319
- return that.push(charIndent).record(), false;
319
+ return of.push(charIndent).record(), false;
320
320
  }
321
321
  // Outdent with `⇧+⇥`
322
322
  if (SHIFT_PREFIX + 'Tab' === keyValue) {
323
- return that.pull(charIndent).record(), false;
323
+ return of.pull(charIndent).record(), false;
324
324
  }
325
325
  return true;
326
326
  }
327
327
 
328
- let bounce = debounce(that => that.record(), 100);
328
+ let bounce = debounce(of => of.record(), 100);
329
329
 
330
- export function canKeyUp(map, that) {
331
- return bounce(that), true;
330
+ export function canKeyUp(map, of) {
331
+ return bounce(of), true;
332
332
  }
333
333
 
334
334
  export const state = defaults;
package/package.json CHANGED
@@ -49,5 +49,5 @@
49
49
  "scripts": {
50
50
  "pack": "pack --clean=false --from=.github/factory --js-format=umd --js-name=TE.Source --js-top='%(js.license)' --mjs=true --to=."
51
51
  },
52
- "version": "2.2.9"
52
+ "version": "2.2.10"
53
53
  }