mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 15:36:16 -04:00
[fix] Have one setting for each shortcut to create ordered list
This is an adjustment to #2891.
This commit is contained in:
parent
97038c2183
commit
0cb8d31e95
4 changed files with 96 additions and 8 deletions
|
@ -91,6 +91,7 @@
|
||||||
"cmd5" : true, /* strike through */
|
"cmd5" : true, /* strike through */
|
||||||
"cmdShiftL" : true, /* unordered list */
|
"cmdShiftL" : true, /* unordered list */
|
||||||
"cmdShiftN" : true, /* ordered list */
|
"cmdShiftN" : true, /* ordered list */
|
||||||
|
"cmdShift1" : true, /* ordered list */
|
||||||
"cmdShiftC" : true, /* clear authorship */
|
"cmdShiftC" : true, /* clear authorship */
|
||||||
"cmdH" : true, /* backspace */
|
"cmdH" : true, /* backspace */
|
||||||
"ctrlHome" : true, /* scroll to top of pad */
|
"ctrlHome" : true, /* scroll to top of pad */
|
||||||
|
|
|
@ -122,6 +122,7 @@ exports.padShortcutEnabled = {
|
||||||
"cmd5" : true,
|
"cmd5" : true,
|
||||||
"cmdShiftL" : true,
|
"cmdShiftL" : true,
|
||||||
"cmdShiftN" : true,
|
"cmdShiftN" : true,
|
||||||
|
"cmdShift1" : true,
|
||||||
"cmdShiftC" : true,
|
"cmdShiftC" : true,
|
||||||
"cmdH" : true,
|
"cmdH" : true,
|
||||||
"ctrlHome" : true,
|
"ctrlHome" : true,
|
||||||
|
|
|
@ -3939,9 +3939,9 @@ function Ace2Inner(){
|
||||||
doInsertUnorderedList()
|
doInsertUnorderedList()
|
||||||
specialHandled = true;
|
specialHandled = true;
|
||||||
}
|
}
|
||||||
if ((!specialHandled) && isTypeForCmdKey && (String.fromCharCode(which).toLowerCase() == "n" || String.fromCharCode(which) == 1) && (evt.metaKey || evt.ctrlKey) && evt.shiftKey && padShortcutEnabled.cmdShiftN)
|
if ((!specialHandled) && isTypeForCmdKey && ((String.fromCharCode(which).toLowerCase() == "n" && padShortcutEnabled.cmdShiftN) || (String.fromCharCode(which) == 1 && padShortcutEnabled.cmdShift1)) && (evt.metaKey || evt.ctrlKey) && evt.shiftKey)
|
||||||
{
|
{
|
||||||
// cmd-shift-N (orderedlist)
|
// cmd-shift-N and cmd-shift-1 (orderedlist)
|
||||||
fastIncorp(9);
|
fastIncorp(9);
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
doInsertOrderedList()
|
doInsertOrderedList()
|
||||||
|
|
|
@ -5,8 +5,8 @@ describe("assign ordered list", function(){
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("insert ordered list text", function(done){
|
it("inserts ordered list text", function(done){
|
||||||
var inner$ = helper.padInner$;
|
var inner$ = helper.padInner$;
|
||||||
var chrome$ = helper.padChrome$;
|
var chrome$ = helper.padChrome$;
|
||||||
|
|
||||||
var $insertorderedlistButton = chrome$(".buttonicon-insertorderedlist");
|
var $insertorderedlistButton = chrome$(".buttonicon-insertorderedlist");
|
||||||
|
@ -17,8 +17,72 @@ describe("assign ordered list", function(){
|
||||||
}).done(done);
|
}).done(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
context('when user presses Ctrl+Shift+N', function() {
|
||||||
|
context('and pad shortcut is enabled', function() {
|
||||||
|
beforeEach(function() {
|
||||||
|
makeSureShortcutIsEnabled('cmdShiftN');
|
||||||
|
triggerCtrlShiftShortcut('N');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('inserts unordered list', function(done) {
|
||||||
|
helper.waitFor(function() {
|
||||||
|
return helper.padInner$('div').first().find('ol li').length === 1;
|
||||||
|
}).done(done);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
context('and pad shortcut is disabled', function() {
|
||||||
|
beforeEach(function() {
|
||||||
|
makeSureShortcutIsDisabled('cmdShiftN');
|
||||||
|
triggerCtrlShiftShortcut('N');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not insert unordered list', function(done) {
|
||||||
|
helper.waitFor(function() {
|
||||||
|
return helper.padInner$('div').first().find('ol li').length === 1;
|
||||||
|
}).done(function() {
|
||||||
|
expect().fail(function() { return 'Unordered list inserted, should ignore shortcut' });
|
||||||
|
}).fail(function() {
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
context('when user presses Ctrl+Shift+1', function() {
|
||||||
|
context('and pad shortcut is enabled', function() {
|
||||||
|
beforeEach(function() {
|
||||||
|
makeSureShortcutIsEnabled('cmdShift1');
|
||||||
|
triggerCtrlShiftShortcut('1');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('inserts unordered list', function(done) {
|
||||||
|
helper.waitFor(function() {
|
||||||
|
return helper.padInner$('div').first().find('ol li').length === 1;
|
||||||
|
}).done(done);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
context('and pad shortcut is disabled', function() {
|
||||||
|
beforeEach(function() {
|
||||||
|
makeSureShortcutIsDisabled('cmdShift1');
|
||||||
|
triggerCtrlShiftShortcut('1');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not insert unordered list', function(done) {
|
||||||
|
helper.waitFor(function() {
|
||||||
|
return helper.padInner$('div').first().find('ol li').length === 1;
|
||||||
|
}).done(function() {
|
||||||
|
expect().fail(function() { return 'Unordered list inserted, should ignore shortcut' });
|
||||||
|
}).fail(function() {
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
xit("issue #1125 keeps the numbered list on enter for the new line - EMULATES PASTING INTO A PAD", function(done){
|
xit("issue #1125 keeps the numbered list on enter for the new line - EMULATES PASTING INTO A PAD", function(done){
|
||||||
var inner$ = helper.padInner$;
|
var inner$ = helper.padInner$;
|
||||||
var chrome$ = helper.padChrome$;
|
var chrome$ = helper.padChrome$;
|
||||||
|
|
||||||
var $insertorderedlistButton = chrome$(".buttonicon-insertorderedlist");
|
var $insertorderedlistButton = chrome$(".buttonicon-insertorderedlist");
|
||||||
|
@ -26,9 +90,9 @@ describe("assign ordered list", function(){
|
||||||
|
|
||||||
//type a bit, make a line break and type again
|
//type a bit, make a line break and type again
|
||||||
var $firstTextElement = inner$("div span").first();
|
var $firstTextElement = inner$("div span").first();
|
||||||
$firstTextElement.sendkeys('line 1');
|
$firstTextElement.sendkeys('line 1');
|
||||||
$firstTextElement.sendkeys('{enter}');
|
$firstTextElement.sendkeys('{enter}');
|
||||||
$firstTextElement.sendkeys('line 2');
|
$firstTextElement.sendkeys('line 2');
|
||||||
$firstTextElement.sendkeys('{enter}');
|
$firstTextElement.sendkeys('{enter}');
|
||||||
|
|
||||||
helper.waitFor(function(){
|
helper.waitFor(function(){
|
||||||
|
@ -44,4 +108,26 @@ describe("assign ordered list", function(){
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var triggerCtrlShiftShortcut = function(shortcutChar) {
|
||||||
|
var inner$ = helper.padInner$;
|
||||||
|
if(inner$(window)[0].bowser.firefox || inner$(window)[0].bowser.modernIE) { // if it's a mozilla or IE
|
||||||
|
var evtType = "keypress";
|
||||||
|
}else{
|
||||||
|
var evtType = "keydown";
|
||||||
|
}
|
||||||
|
var e = inner$.Event(evtType);
|
||||||
|
e.ctrlKey = true;
|
||||||
|
e.shiftKey = true;
|
||||||
|
e.which = shortcutChar.toString().charCodeAt(0);
|
||||||
|
inner$("#innerdocbody").trigger(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
var makeSureShortcutIsDisabled = function(shortcut) {
|
||||||
|
helper.padChrome$.window.clientVars.padShortcutEnabled[shortcut] = false;
|
||||||
|
}
|
||||||
|
var makeSureShortcutIsEnabled = function(shortcut) {
|
||||||
|
helper.padChrome$.window.clientVars.padShortcutEnabled[shortcut] = true;
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue