Revert "Revert "outdent on ol""

This reverts commit e0fd8f8523.
outdent-ol-on-click
John McLear 2020-06-06 22:54:27 +00:00
parent d292ed6678
commit 34ea1e0438
1 changed files with 28 additions and 5 deletions

View File

@ -5166,6 +5166,16 @@ function Ace2Inner(){
var t = ''; var t = '';
var level = 0; var level = 0;
var listType = /([a-z]+)([0-9]+)/.exec(getLineListType(n)); var listType = /([a-z]+)([0-9]+)/.exec(getLineListType(n));
var togglineOn = false;
// Used to outdent if ol is removed
if(allLinesAreList){
togglingOn = false;
}else{
togglingOn = true;
}
if (listType) if (listType)
{ {
t = listType[1]; t = listType[1];
@ -5173,12 +5183,25 @@ function Ace2Inner(){
} }
var t = getLineListType(n); var t = getLineListType(n);
// if already a list, deindent if(t === listType) togglingOn = false;
if (allLinesAreList && level != 1) { level = level - 1; }
// if already indented, then add a level of indentation to the list if(togglingOn){
else if (t && !allLinesAreList) { level = level + 1; } mods.push([n, allLinesAreList ? 'indent' + level : (t ? type + level : type + '1')]);
}
if(!togglingOn){
// 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, ''); // remove bullet
let newLevel = level+1;
setLineListType(n, "indent"+level); // outdent
}
}
mods.push([n, allLinesAreList ? 'indent' + level : (t ? type + level : type + '1')]);
} }
_.each(mods, function(mod){ _.each(mods, function(mod){