editor: ul/ol/li - outdent on ol and ul button press

pull/3877/head
John McLear 2020-06-05 20:00:21 +01:00 committed by GitHub
parent 13bd859f31
commit fc88f12bba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 5 deletions

View File

@ -5166,6 +5166,7 @@ function Ace2Inner(){
var t = '';
var level = 0;
var listType = /([a-z]+)([0-9]+)/.exec(getLineListType(n));
var togglingOn = !allLinesAreList;
if (listType)
{
t = listType[1];
@ -5173,12 +5174,24 @@ function Ace2Inner(){
}
var t = getLineListType(n);
// if already a list, deindent
if (allLinesAreList && level != 1) { level = level - 1; }
// if already indented, then add a level of indentation to the list
else if (t && !allLinesAreList) { level = level + 1; }
if(t === listType) togglingOn = false;
mods.push([n, allLinesAreList ? 'indent' + level : (t ? type + level : type + '1')]);
if(togglingOn){
mods.push([n, allLinesAreList ? 'indent' + level : (t ? type + level : type + '1')]);
}
if(!togglingOn){ // remove removing because we have
// scrap the entire indentation and list type
if(level === 1){ // if outdending but are the first item in the list then outdent
setLineListType(n, ''); // outdent
}
// else change to indented not bullet
if(level > 1){
setLineListType(n, ''); // reomve bullet
let newLevel = level+1;
setLineListType(n, "indent"+level); // outdent
}
}
}
_.each(mods, function(mod){