-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathemmet.js
946 lines (845 loc) · 22.5 KB
/
emmet.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
/* global require WScript: true ActiveXObject FileStream System GlobalSettings */
/* global Editor emmet Scintilla alert */
/**
* jn-npp-emmet v$inline("../package.json|parse:version")
*
* Author: eight04 <[email protected]>
* Homepage: https://github.com/eight04/jn-npp-emmet
*/
require("lib/Scintilla.js");
require("lib/ECMA262.js");
require("includes/emmet/emmet-core.js");
require("includes/emmet/FileStream/FileStream.js");
(function(){
// Fake WScript env
if (typeof WScript == "undefined") {
WScript = {
CreateObject: function(name) {
return new ActiveXObject(name);
}
};
}
// Some string utils
if (typeof String.prototype.endsWith === "undefined") {
// https://github.com/emmetio/emmet/blob/8fa340dc4c7d209c3e6836ab9fe2e42d23d2cd40/lib/resolver/css.js#L832
String.prototype.endsWith = function(suffix) {
return this.lastIndexOf(suffix, this.length - suffix.length) >= 0;
};
}
var path = function(){
var fso = new ActiveXObject("Scripting.FileSystemObject");
return {
join: function(base) {
if (this.exists(base)) {
base = this.parent(base);
}
var path = Array.prototype.join.call(arguments, "\\");
return this.abs(path);
},
abs: function(path) {
return fso.GetAbsolutePathName(path);
},
parent: function(path) {
return fso.GetParentFolderName(path);
},
exists: function(path) {
return fso.FileExists(path);
},
copy: function(src, dest){
fso.CopyFile(src, dest);
},
ext: function(filename) {
return fso.GetExtensionName(filename);
},
get: function(filename) {
return fso.GetFile(filename);
}
};
}();
var io = function() {
var stream = new ActiveXObject("ADODB.Stream");
stream.Charset = "UTF-8";
return {
read: function(filename) {
var result;
stream.type = 2;
stream.Open();
try {
stream.LoadFromFile(filename);
result = stream.ReadText();
} catch (err) {
result = "";
}
stream.Close();
return result;
},
write: function(filename, value) {
stream.Open();
stream.WriteText(value),
stream.SaveToFile(filename),
stream.Close();
},
readBin: function(filename, size) {
var fs = new FileStream(filename),
buff,
result = "",
i;
if (size == null) {
size = -1;
}
fs.open();
fs.loadFromFile(filename);
buff = fs.readToString(size);
fs.close();
for (i = 0; i < buff.length; i += 2) {
result += String.fromCharCode(parseInt(buff.substr(i, 2), 16));
}
return result;
}
};
}();
var PLUGIN_DIR = (function(path){
return path.parent(System.scriptFullName);
})(path);
var DIMENSION_PROPS = ["width", "height", "left", "top"];
/**
* Create a dialog. options may contain following properties:
*
* * id: when specified, the position of the dialog would be saved to global config.
* * title: dialog title.
* * html: dialog innerHTML.
* * onresolve: resolve handler.
* * onreject: reject handler.
*/
function createDialog(options) {
var destroyed = false;
var htmlDialog = System.createDialog({
onbeforeclose: function() {
// overwrite the behavior of top right "x" button
if (!destroyed) {
reject();
return false;
}
}
});
htmlDialog.visible = false;
htmlDialog.title = options.title;
// restore position
if (options.id) {
DIMENSION_PROPS.forEach(function(prop) {
htmlDialog[prop] =
options.id && GlobalSettings.get("dialog." + options.id + "." + prop) ||
options[prop] ||
htmlDialog[prop];
});
}
// Build interface
var document = htmlDialog.document;
document.write(options.html);
document.close();
document.forms[0].onsubmit = function() {
resolve(document.getElementById("entry").value);
return false;
};
document.getElementById("cancel").onclick = function() {
reject();
};
document.onkeydown = function(e) {
e = e || document.parentWindow.event;
if (e.keyCode == 27) {
reject();
}
};
function show() {
htmlDialog.visible = true;
var autofocus = document.querySelector("[autofocus]");
if (autofocus) {
autofocus.focus();
}
if (options.onshow) {
options.onshow(htmlDialog);
}
}
function hide() {
if (options.id) {
DIMENSION_PROPS.forEach(function (prop) {
GlobalSettings.set(
"dialog." + options.id + "." + prop,
htmlDialog[prop]
);
});
}
htmlDialog.visible = false;
}
function resolve(value) {
hide();
if (options.onresolve) {
options.onresolve(value);
}
}
function reject(value) {
hide();
if (options.onreject) {
options.onreject(value);
}
}
function destroy() {
destroyed = true;
htmlDialog.close();
}
return {
show: show,
hide: hide,
resolve: resolve,
reject: reject,
destroy: destroy,
isShown: function() {
return htmlDialog.visible;
}
};
}
var emmetPrompt = (function() {
var dialog, callback;
return function(title, _callback) {
if (!dialog) {
dialog = createDialog({
id: "emmet",
title: title,
width: 409,
height: 112,
html: io.read(PLUGIN_DIR + "/includes/emmet/prompt-template.html"),
onresolve: function(value) {
if (callback) {
callback(value);
}
},
onshow: function(htmlDialog) {
htmlDialog.document.getElementById("entry").value = "";
}
});
}
if (dialog.isShown()) {
dialog.reject();
}
callback = _callback;
dialog.show();
};
})();
function createMap(list) {
var i, len, holder = {};
for (i = 0, len = list.length; i < len; i++) {
holder[list[i]] = true;
}
return holder;
}
// Default snippets and caniuse
emmet.loadSystemSnippets(io.read(PLUGIN_DIR + "/includes/emmet/system-snippets.json"));
emmet.loadCIU(io.read(PLUGIN_DIR + "/includes/emmet/caniuse.json"));
// user data
var userFileList = [
{
name: "preferences",
mandatory: false
},
{
name: "snippets",
mandatory: false
},
{
name: "syntaxProfiles",
mandatory: false
},
{
name: "keymap",
mandatory: true
},
{
name: "menu",
mandatory: true,
defaultValue: function() {
return emmet.actions.getMenu();
}
},
{
name: "settings",
mandatory: true
}
];
function readUserData() {
var data = {};
userFileList.forEach(function (file) {
var userPath = Editor.pluginConfigDir + "/emmet." + file.name + ".json";
var defaultPath = PLUGIN_DIR + "/includes/emmet/" + file.name + ".json";
if (!path.exists(userPath)) {
if (path.exists(defaultPath)) {
path.copy(defaultPath, userPath);
} else if (file.defaultValue) {
io.write(userPath, JSON.stringify(file.defaultValue(), null, "\t"));
}
}
var content = io.read(userPath);
if (!content) {
if (file.mandatory) {
alert("Failed to read " + userPath);
}
return;
}
try {
data[file.name] = JSON.parse(content);
} catch (err) {
alert("Failed to parse JSON " + userPath + "\n" + String(err));
}
});
return data;
}
// User settings
var userData = readUserData();
emmet.loadUserData(userData);
var settings = userData.settings;
if (settings.enableTabExpensionUnder) {
settings.enableTabExpensionUnder = createMap(settings.enableTabExpensionUnder);
}
function commandInsertTab() {
Editor.runMenuCmd(42008);
}
// Create emmet editor
var emmetEditor = (function(){
var context,
cacheContent,
reverse = false;
var whiteSpace = {
" ": true,
"\t": true,
"\r": true,
"\n": true
};
// Returns true if using tab character
function useTabChar() {
return (new Scintilla(context.handle)).Call("SCI_GETUSETABS", 0, 0);
}
// Returns tab width (or space length)
function tabWidth() {
return (new Scintilla(context.handle)).Call("SCI_GETTABWIDTH", 0, 0);
}
function scrollIntoView() {
return (new Scintilla(context.handle)).Call("SCI_SCROLLCARET", 0, 0);
}
/**
* Normalizes text before it goes to editor: replaces indentation
* and newlines with ones used in editor
* @param {String} text Text to normalize
* @param {Editor} editor Brackets editor instance
* @return {String}
*/
function normalize(text) {
var indentation = '\t';
if (!useTabChar()) {
indentation = '';
var units = tabWidth();
while (units--) {
indentation += ' ';
}
}
return emmet.utils.editor.normalize(text, {
indentation: indentation,
newline: '\n'
});
}
// Replace document text with value between start and end.
function replaceRange(value, start, end) {
var byteAnchor = context.byteAnchor,
bytePos = context.bytePos;
context.anchor = start;
context.pos = end;
if (value == "\t") {
commandInsertTab();
} else {
context.selection = value;
}
context.byteAnchor = byteAnchor;
context.bytePos = bytePos;
cacheContent = null;
}
return {
/**
* Setup underlying editor context. You should call this method
* <code>before</code> using any Zen Coding action.
* @param {Object} context
*/
setContext: function(ctx) {
context = ctx;
cacheContent = null;
reverse = false;
},
/**
* Returns character indexes of selected text: object with <code>start</code>
* and <code>end</code> properties. If there's no selection, should return
* object with <code>start</code> and <code>end</code> properties referring
* to current caret position
* @return {Object}
* @example
* var selection = zen_editor.getSelectionRange();
* alert(selection.start + ', ' + selection.end);
*/
getSelectionRange: function() {
var start = context.anchor,
end = context.pos;
if (start > end) {
reverse = true;
var t = start;
start = end;
end = t;
}
return {
start: start,
end: end
};
},
/**
* Creates selection from <code>start</code> to <code>end</code> character
* indexes. If <code>end</code> is ommited, this method should place caret
* and <code>start</code> index
* @param {Number} start
* @param {Number} [end]
* @example
* zen_editor.createSelection(10, 40);
*
* //move caret to 15th character
* zen_editor.createSelection(15);
*/
createSelection: function(start, end) {
if (!end) {
end = start;
}
if (reverse) {
var t = start;
start = end;
end = t;
}
context.anchor = start;
context.pos = end;
},
/**
* Returns current line's start and end indexes as object with <code>start</code>
* and <code>end</code> properties
* @return {Object}
* @example
* var range = zen_editor.getCurrentLineRange();
* alert(range.start + ', ' + range.end);
*/
getCurrentLineRange: function() {
var line = context.lines.get(context.lines.current);
return {start: line.start, end: line.end};
},
/**
* Returns current caret position
* @return {Number|null}
*/
getCaretPos: function(){
return context.pos;
},
/**
* Set new caret position
* @param {Number} pos Caret position
*/
setCaretPos: function(pos) {
context.anchor = pos;
context.pos = pos;
scrollIntoView();
},
/**
* Returns content of current line
* @return {String}
*/
getCurrentLine: function() {
return context.lines.get(context.line).text;
},
/**
* Replace editor's content or it's part (from <code>start</code> to
* <code>end</code> index). If <code>value</code> contains
* <code>caret_placeholder</code>, the editor will put caret into
* this position. If you skip <code>start</code> and <code>end</code>
* arguments, the whole target's content will be replaced with
* <code>value</code>.
*
* If you pass <code>start</code> argument only,
* the <code>value</code> will be placed at <code>start</code> string
* index of current content.
*
* If you pass <code>start</code> and <code>end</code> arguments,
* the corresponding substring of current target's content will be
* replaced with <code>value</code>.
* @param {String} value Content you want to paste
* @param {Number} [start] Start index of editor's content
* @param {Number} [end] End index of editor's content
*/
replaceContent: function(value, start, end, noIndent) {
// https://github.com/emmetio/brackets-emmet/blob/master/editor.js
if (end === undefined) {
end = start === undefined ? this.getContent().length : start;
}
if (start === undefined) {
start = 0;
}
value = normalize(value);
// indent new value
if (!noIndent) {
var pad = emmet.utils.common.getLinePaddingFromPosition(this.getContent(), start);
value = emmet.utils.common.padString(value, pad);
}
// find new caret position
var tabstopData = emmet.tabStops.extract(value, {
escape: function(ch) {
return ch;
}
});
value = tabstopData.text;
var firstTabStop = tabstopData.tabstops[0] || {start: value.length, end: value.length};
firstTabStop.start += start;
firstTabStop.end += start;
replaceRange(value, start, end);
this.createSelection(firstTabStop.start, firstTabStop.end);
},
/**
* Returns editor's content
* @return {String}
*/
getContent: function(){
if (cacheContent == null) {
cacheContent = context.text || '';
}
return cacheContent;
},
/**
* Returns current editor's syntax mode
* @return {String}
*/
getSyntax: function() {
var syntax = (Editor.langs[context.lang] || '').toLowerCase(),
caret_pos = this.getCaretPos();
if (syntax == 'html') {
// get the context tag
var result = emmet.htmlMatcher.tag(this.getContent(), caret_pos);
if (result && result.open.name == "style") {
if (result.open.range.end <= caret_pos && result.close.range.start >= caret_pos) {
syntax = "css";
}
}
}
if (!syntax) {
syntax = path.ext(this.getFilePath());
}
return syntax;
},
/**
* Returns current output profile name (see profile module).
* In most cases, this method should return <code>null</code> and let
* Emmet guess best profile name for current syntax and user data.
* In case you’re using advanced editor with access to syntax scopes
* (like Sublime Text 2), you can return syntax name for current scope.
* For example, you may return `line` profile when editor caret is inside
* string of programming language.
*
* @return {String}
*/
getProfileName: function() {
return null;
},
/**
* Ask user to enter something
* @param {String} title Dialog title
* @return {String} Entered data
* @since 0.65
*/
// FIXME: WTF a synchronized api in javascript?
prompt: function(title) { // eslint-disable-line
return '';
},
/**
* Returns current selection
* @return {String}
* @since 0.65
*/
getSelection: function() {
// var sel = this.getSelectionRange();
// return this.getContent().substring(sel.start, sel.end);
return context.selection;
},
/**
* Returns current editor's file path
* @return {String}
* @since 0.65
*/
getFilePath: function() {
return context.files[context.file];
},
// Check if the selection is collapsed
shouldExpand: function() {
// collapsed
if (context.bytePos != context.byteAnchor) {
return false;
}
// on whitespace
context.bytePos--;
var ch = context.selection;
context.bytePos++;
if (whiteSpace[ch]) {
return false;
}
// invalid lang
if (settings.enableTabExpensionByFileType) {
if (settings.enableTabExpensionUnder) {
var lang = Editor.langs[Editor.currentView.lang];
if (lang && settings.enableTabExpensionUnder[lang.toLowerCase()]) {
return true;
}
}
return false;
}
return true;
}
};
})();
var emmetFile = (function(){
return {
/**
* Read file content and return it
* @param {String} path File's relative or absolute path
* @param {Number} size Number of bytes to read, optional. If not specified,
* reads full file
* @param {Function} callback Callback function invoked when reading is
* completed
* @return {String}
*/
read: function(path, size, callback) {
if (typeof size == "function") {
callback = size;
size = null;
}
var bin = io.readBin(path, size);
if (callback) {
callback(bin == "", bin);
} else {
return bin;
}
},
/**
* Locate <code>file_name</code> file that relates to <code>editor_file</code>.
* File name may be absolute or relative path
*
* <b>Dealing with absolute path.</b>
* Many modern editors have a "project" support as information unit, but you
* should not rely on project path to find file with absolute path. First,
* it requires user to create a project before using this method (and this
* is not very convenient). Second, project path doesn't always points to
* to website's document root folder: it may point, for example, to an
* upper folder which contains server-side scripts.
*
* For better result, you should use the following algorithm in locating
* absolute resources:
* 1) Get parent folder for <code>editorFile</code> as a start point
* 2) Append required <code>fileName</code> to start point and test if
* file exists
* 3) If it doesn't exists, move start point one level up (to parent folder)
* and repeat step 2.
*
* @param {String} editorFile
* @param {String} fileName
* @return {String} Returns null if <code>fileName</code> cannot be located
*/
locateFile: function(editorFile, fileName, done) {
var folder = path.parent(editorFile),
result;
while (folder) {
result = path.join(folder, fileName);
if (path.exists(result)) {
done(result);
return;
}
folder = path.parent(folder);
}
done('');
},
/**
* Creates absolute path by concatenating <code>parent</code> and <code>file_name</code>.
* If <code>parent</code> points to file, its parent directory is used
* @param {String} parent
* @param {String} file_name
* @return {String}
*/
createPath: function(parent, fileName) {
return path.join(parent, fileName);
},
/**
* Saves <code>content</code> as <code>file</code>
* @param {String} file File's absolute path
* @param {String} content File content
*/
save: function(file, content) {
io.write(file, content);
},
/**
* Returns file extension in lower case
* @param {String} file
* @return {String}
*/
getExt: function(file) {
var m = (file || '').match(/\.([\w-]+)$/);
return m ? m[1].toLowerCase() : '';
}
};
})();
emmet.file(emmetFile);
function cancelAutoComplete() {
return (new Scintilla(Editor.currentView.handle)).Call("SCI_AUTOCCANCEL", 0, 0);
}
/**
* Zen Coding manager that runs actions
* @param {String} action_name Action to call
* @return {Boolean} Returns 'true' if action ran successfully
*/
function runAction(action_name) {
function safeRun(arg) {
if (action_name === "expand_abbreviation_with_tab" && !emmetEditor.shouldExpand()) {
commandInsertTab();
return;
}
// handle emmet error
emmet.htmlMatcher.cache(true);
try {
emmet.run(action_name, emmetEditor, arg);
} catch (err) {
alert(String(err));
}
emmet.htmlMatcher.cache(false);
// cancel autocomplete dialog
cancelAutoComplete();
}
emmetEditor.setContext(Editor.currentView);
if (action_name == 'wrap_with_abbreviation' || action_name == "update_tag") {
emmetPrompt("Enter Abbreviation", function(abbr) {
if (abbr) {
safeRun(abbr);
}
});
} else {
safeRun();
}
}
// Construct menu helper
function constructMenu(menu, list) {
var keyMap = userData.keymap;
list.forEach(function(item){
var label = item.label || item.name;
if (item.type == "submenu") {
var subMenu = menu.addMenu({
text: label
});
constructMenu(subMenu, item.items);
} else if (item.type == "separator") {
menu.addSeparator();
} else {
menu.addItem({
text: label + (keyMap[item.name] ? "\t" + keyMap[item.name] : ""),
cmd: function(){
runAction(item.name);
}
});
}
});
}
if (userData.menu.length) {
constructMenu(Editor.addMenu("Emmet"), userData.menu);
}
// Map key name to key code.
// https://msdn.microsoft.com/en-us/library/dd375731%28v=VS.85%29.aspx
var keycodeMap = {
backspace: 0x8,
tab: 0x9,
enter: 0xD,
pause: 0x13,
caps: 0x14,
esc: 0x1b,
space: 0x20,
pageup: 0x21,
pgup: 0x21,
pagedown: 0x22,
pgdn: 0x22,
end: 0x23,
home: 0x24,
left: 0x25,
up: 0x26,
right: 0x27,
down: 0x28,
printscreen: 0x2c,
printscr: 0x2c,
insert: 0x2d,
ins: 0x2d,
"delete": 0x2e,
del: 0x2e,
numpad0: 0x60,
num0: 0x60,
numpad1: 0x61,
num1: 0x61,
numpad2: 0x62,
num2: 0x62,
numpad3: 0x63,
num3: 0x63,
numpad4: 0x64,
num4: 0x64,
numpad5: 0x65,
num5: 0x65,
numpad6: 0x66,
num6: 0x66,
numpad7: 0x67,
num7: 0x67,
numpad8: 0x68,
num8: 0x68,
numpad9: 0x69,
num9: 0x69,
multiply: 0x6a,
f1: 0x70,
f2: 0x71,
f3: 0x72,
f4: 0x73,
f5: 0x74,
f6: 0x75,
f7: 0x76,
f8: 0x77,
f9: 0x78,
f10: 0x79,
f11: 0x7a,
f12: 0x7b,
numlock: 0x90,
scrolllock: 0x91
};
// Regist hotkeys.
emmet.actions.getList().forEach(function(action){
var userHotkey = userData.keymap[action.name];
if (!userHotkey) {
return;
}
var keys = userHotkey.split("+");
var cfg = {
cmd: function() {
runAction(action.name);
}
};
var i;
for (i = 0; i < keys.length; i++) {
var token = keys[i].toLowerCase().split(" ").join("");
token = keycodeMap[token] || token;
switch (token) {
case "ctrl":
case "shift":
case "alt":
cfg[token] = true;
break;
default:
cfg.key = token;
break;
}
}
Editor.addHotKey(cfg);
});
})();