make selected indenting and outdenting work on courseware HTML, JS and Bonfires
This commit is contained in:
@@ -18,8 +18,20 @@ editor.setSize("100%", "auto");
|
|||||||
// Hijack tab key to enter two spaces intead
|
// Hijack tab key to enter two spaces intead
|
||||||
editor.setOption("extraKeys", {
|
editor.setOption("extraKeys", {
|
||||||
Tab: function(cm) {
|
Tab: function(cm) {
|
||||||
var spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
|
if (cm.somethingSelected()){
|
||||||
cm.replaceSelection(spaces);
|
cm.indentSelection("add");
|
||||||
|
} else {
|
||||||
|
var spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
|
||||||
|
cm.replaceSelection(spaces);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Shift-Tab": function(cm) {
|
||||||
|
if (cm.somethingSelected()){
|
||||||
|
cm.indentSelection("subtract");
|
||||||
|
} else {
|
||||||
|
var spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
|
||||||
|
cm.replaceSelection(spaces);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"Ctrl-Enter": function() {
|
"Ctrl-Enter": function() {
|
||||||
bonfireExecute();
|
bonfireExecute();
|
||||||
|
@@ -22,10 +22,23 @@ var editor = myCodeMirror;
|
|||||||
// Hijack tab key to insert two spaces instead
|
// Hijack tab key to insert two spaces instead
|
||||||
editor.setOption("extraKeys", {
|
editor.setOption("extraKeys", {
|
||||||
Tab: function(cm) {
|
Tab: function(cm) {
|
||||||
var spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
|
if (cm.somethingSelected()){
|
||||||
cm.replaceSelection(spaces);
|
cm.indentSelection("add");
|
||||||
|
} else {
|
||||||
|
var spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
|
||||||
|
cm.replaceSelection(spaces);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Shift-Tab": function(cm) {
|
||||||
|
if (cm.somethingSelected()){
|
||||||
|
cm.indentSelection("subtract");
|
||||||
|
} else {
|
||||||
|
var spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
|
||||||
|
cm.replaceSelection(spaces);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"Ctrl-Enter": function() {
|
"Ctrl-Enter": function() {
|
||||||
|
bonfireExecute();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -18,8 +18,20 @@ editor.setSize("100%", "auto");
|
|||||||
// Hijack tab key to enter two spaces intead
|
// Hijack tab key to enter two spaces intead
|
||||||
editor.setOption("extraKeys", {
|
editor.setOption("extraKeys", {
|
||||||
Tab: function(cm) {
|
Tab: function(cm) {
|
||||||
var spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
|
if (cm.somethingSelected()){
|
||||||
cm.replaceSelection(spaces);
|
cm.indentSelection("add");
|
||||||
|
} else {
|
||||||
|
var spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
|
||||||
|
cm.replaceSelection(spaces);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Shift-Tab": function(cm) {
|
||||||
|
if (cm.somethingSelected()){
|
||||||
|
cm.indentSelection("subtract");
|
||||||
|
} else {
|
||||||
|
var spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
|
||||||
|
cm.replaceSelection(spaces);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"Ctrl-Enter": function() {
|
"Ctrl-Enter": function() {
|
||||||
bonfireExecute();
|
bonfireExecute();
|
||||||
|
Reference in New Issue
Block a user