From c5584fb5b41a67704bcad4178a5420377b6988ab Mon Sep 17 00:00:00 2001 From: John McLear Date: Sun, 7 Jun 2020 09:51:12 +0100 Subject: [PATCH] editor: outdent on ol removal (#4088) --- src/static/js/ace2_inner.js | 28 +++++++++++++++++++++----- tests/frontend/travis/remote_runner.js | 2 +- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js index 787aaaf94..ef8dc8247 100644 --- a/src/static/js/ace2_inner.js +++ b/src/static/js/ace2_inner.js @@ -5166,6 +5166,14 @@ function Ace2Inner(){ var t = ''; var level = 0; var listType = /([a-z]+)([0-9]+)/.exec(getLineListType(n)); + + // Used to outdent if ol is removed + if(allLinesAreList){ + var togglingOn = false; + }else{ + var togglingOn = true; + } + if (listType) { t = listType[1]; @@ -5173,12 +5181,22 @@ 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; + + if(togglingOn){ + mods.push([n, allLinesAreList ? 'indent' + level : (t ? type + level : type + '1')]); + }else{ + // 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 + setLineListType(n, "indent"+level); // in/outdent + } + } - mods.push([n, allLinesAreList ? 'indent' + level : (t ? type + level : type + '1')]); } _.each(mods, function(mod){ diff --git a/tests/frontend/travis/remote_runner.js b/tests/frontend/travis/remote_runner.js index 27573355e..1e04b2a0d 100644 --- a/tests/frontend/travis/remote_runner.js +++ b/tests/frontend/travis/remote_runner.js @@ -70,7 +70,7 @@ var sauceTestWorker = async.queue(function (testSettings, callback) { }, 10000); -}, 1); //run 4 tests in parrallel +}, 1); //run 1 test in parrallel // 1) Firefox on Linux sauceTestWorker.push({