Revert "fix order list numbering (#988)"

This reverts commit ee1775349c.
pull/1002/head
X Code 2 years ago
parent 503f66dd2b
commit 7d4a0b0303
  1. 55
      lib/src/widgets/style_widgets/number_point.dart

@ -27,40 +27,51 @@ class QuillNumberPoint extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final olString = _getOlString(); var s = index.toString();
int? level = 0;
if (!attrs.containsKey(Attribute.indent.key) &&
!indentLevelCounts.containsKey(1)) {
indentLevelCounts.clear();
return Container( return Container(
alignment: AlignmentDirectional.topEnd, alignment: AlignmentDirectional.topEnd,
width: width, width: width,
padding: EdgeInsetsDirectional.only(end: padding), padding: EdgeInsetsDirectional.only(end: padding),
child: Text('$olString${withDot ? '.' : ''}', style: style), child: Text(withDot ? '$s.' : s, style: style),
); );
} }
if (attrs.containsKey(Attribute.indent.key)) {
String _getOlString() { level = attrs[Attribute.indent.key]!.value;
final int indentLevel = attrs[Attribute.indent.key]?.value ?? 0; } else {
// first level but is back from previous indent level
if (indentLevelCounts.containsKey(indentLevel + 1)) { // supposed to be "2."
indentLevelCounts[0] = 1;
}
if (indentLevelCounts.containsKey(level! + 1)) {
// last visited level is done, going up // last visited level is done, going up
indentLevelCounts.remove(indentLevel + 1); indentLevelCounts.remove(level + 1);
} }
final count = (indentLevelCounts[level] ?? 0) + 1;
final count = (indentLevelCounts[indentLevel] ?? 0) + 1; indentLevelCounts[level] = count;
indentLevelCounts[indentLevel] = count;
s = count.toString();
final numberingMode = indentLevel % 3; if (level % 3 == 1) {
if (numberingMode == 1) { // a. b. c. d. e. ...
// a. b. c. s = _toExcelSheetColumnTitle(count);
return _intToAlpha(count); } else if (level % 3 == 2) {
} else if (numberingMode == 2) { // i. ii. iii. ...
// i. ii. iii. s = _intToRoman(count);
return _intToRoman(count);
} }
// level % 3 == 0 goes back to 1. 2. 3.
return count.toString(); return Container(
alignment: AlignmentDirectional.topEnd,
width: width,
padding: EdgeInsetsDirectional.only(end: padding),
child: Text(withDot ? '$s.' : s, style: style),
);
} }
String _intToAlpha(int n) { String _toExcelSheetColumnTitle(int n) {
final result = StringBuffer(); final result = StringBuffer();
while (n > 0) { while (n > 0) {
n--; n--;

Loading…
Cancel
Save