Skip to content

Commit 9e50967

Browse files
committed
Merge pull request #231 from jtlebi/origin/shift-tab
(de)indent behaviour enhancement
2 parents c8bfd21 + 2cc4721 commit 9e50967

File tree

4 files changed

+43
-16
lines changed

4 files changed

+43
-16
lines changed

static/css/iframe_editor.css

+17
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,23 @@ ul.list-bullet6 { list-style-type: square; }
3232
ul.list-bullet7 { list-style-type: disc; }
3333
ul.list-bullet8 { list-style-type: circle; }
3434

35+
ul.list-indent1 { margin-left: 1.5em; }
36+
ul.list-indent2 { margin-left: 3em; }
37+
ul.list-indent3 { margin-left: 4.5em; }
38+
ul.list-indent4 { margin-left: 6em; }
39+
ul.list-indent5 { margin-left: 7.5em; }
40+
ul.list-indent6 { margin-left: 9em; }
41+
ul.list-indent7 { margin-left: 10.5em; }
42+
ul.list-indent8 { margin-left: 12em; }
43+
44+
ul.list-indent1 { list-style-type: none; }
45+
ul.list-indent2 { list-style-type: none; }
46+
ul.list-indent3 { list-style-type: none; }
47+
ul.list-indent4 { list-style-type: none; }
48+
ul.list-indent5 { list-style-type: none; }
49+
ul.list-indent6 { list-style-type: none; }
50+
ul.list-indent7 { list-style-type: none; }
51+
ul.list-indent8 { list-style-type: none; }
3552

3653
body {
3754
margin: 0;

static/js/ace2_inner.js

+23-13
Original file line numberDiff line numberDiff line change
@@ -3534,7 +3534,8 @@ function OUTER(gscope)
35343534

35353535
function doIndentOutdent(isOut)
35363536
{
3537-
if (!(rep.selStart && rep.selEnd))
3537+
if (!(rep.selStart && rep.selEnd) ||
3538+
((rep.selStart[0] == rep.selEnd[0]) && (rep.selStart[1] == rep.selEnd[1]) && rep.selEnd[1] > 1))
35383539
{
35393540
return false;
35403541
}
@@ -3544,33 +3545,33 @@ function OUTER(gscope)
35443545
lastLine = Math.max(firstLine, rep.selEnd[0] - ((rep.selEnd[1] == 0) ? 1 : 0));
35453546

35463547
var mods = [];
3547-
var foundLists = false;
35483548
for (var n = firstLine; n <= lastLine; n++)
35493549
{
35503550
var listType = getLineListType(n);
3551+
var t = 'indent';
3552+
var level = 0;
35513553
if (listType)
35523554
{
35533555
listType = /([a-z]+)([12345678])/.exec(listType);
35543556
if (listType)
35553557
{
3556-
foundLists = true;
3557-
var t = listType[1];
3558-
var level = Number(listType[2]);
3559-
var newLevel = Math.max(1, Math.min(MAX_LIST_LEVEL, level + (isOut ? -1 : 1)));
3560-
if (level != newLevel)
3561-
{
3562-
mods.push([n, t + newLevel]);
3563-
}
3558+
t = listType[1];
3559+
level = Number(listType[2]);
35643560
}
35653561
}
3562+
var newLevel = Math.max(0, Math.min(MAX_LIST_LEVEL, level + (isOut ? -1 : 1)));
3563+
if (level != newLevel)
3564+
{
3565+
mods.push([n, (newLevel > 0) ? t + newLevel : '']);
3566+
}
35663567
}
35673568

35683569
if (mods.length > 0)
35693570
{
35703571
setLineListTypes(mods);
35713572
}
35723573

3573-
return foundLists;
3574+
return true;
35743575
}
35753576
editorInfo.ace_doIndentOutdent = doIndentOutdent;
35763577

@@ -5231,7 +5232,8 @@ function OUTER(gscope)
52315232
var allLinesAreList = true;
52325233
for (var n = firstLine; n <= lastLine; n++)
52335234
{
5234-
if (!getLineListType(n))
5235+
var listType = getLineListType(n);
5236+
if (!listType || listType.slice(0, 'bullet'.length) != 'bullet')
52355237
{
52365238
allLinesAreList = false;
52375239
break;
@@ -5241,8 +5243,16 @@ function OUTER(gscope)
52415243
var mods = [];
52425244
for (var n = firstLine; n <= lastLine; n++)
52435245
{
5246+
var t = '';
5247+
var level = 0;
5248+
var listType = /([a-z]+)([12345678])/.exec(getLineListType(n));
5249+
if (listType)
5250+
{
5251+
t = listType[1];
5252+
level = Number(listType[2]);
5253+
}
52445254
var t = getLineListType(n);
5245-
mods.push([n, allLinesAreList ? '' : (t ? t : 'bullet1')]);
5255+
mods.push([n, allLinesAreList ? 'indent' + level : (t ? 'bullet' + level : 'bullet1')]);
52465256
}
52475257
setLineListTypes(mods);
52485258
}

static/js/contentcollector.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, class
473473
if (tname == "ul")
474474
{
475475
var type;
476-
var rr = cls && /(?:^| )list-(bullet[12345678])\b/.exec(cls);
476+
var rr = cls && /(?:^| )list-([a-z]+[12345678])\b/.exec(cls);
477477
type = rr && rr[1] || "bullet" + String(Math.min(_MAX_LIST_LEVEL, (state.listNesting || 0) + 1));
478478
oldListTypeOrNull = (_enterList(state, type) || 'none');
479479
}

static/pad.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@
5050
</a>
5151
</li>
5252
<li onClick="window.pad&&pad.editbarClick('indent');return false;" >
53-
<a title="Indent List">
53+
<a title="Indent">
5454
<div class="buttonicon" style="background-position:0px -52px"></div>
5555
</a>
5656
</li>
5757
<li onClick="window.pad&&pad.editbarClick('outdent');return false;" >
58-
<a title="Unindent List">
58+
<a title="Unindent">
5959
<div class="buttonicon" style="background-position:0px -134px"></div>
6060
</a>
6161
</li>

0 commit comments

Comments
 (0)