An attemp to fix bug #1480

pull/1602/head
Ellet 1 year ago
parent df493afb52
commit cb510267e8
No known key found for this signature in database
GPG Key ID: C488CC70BBCEF0D1
  1. 12
      lib/src/utils/string.dart
  2. 7
      lib/src/widgets/quill/text_block.dart
  3. 5
      lib/src/widgets/style_widgets/bullet_point.dart
  4. 4
      lib/src/widgets/style_widgets/number_point.dart

@ -1,4 +1,4 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/widgets.dart' show Alignment, TextAlign;
Map<String, String> parseKeyValuePairs(String s, Set<String> targetKeys) {
final result = <String, String>{};
@ -51,3 +51,13 @@ Alignment getAlignment(String? cssAlignment) {
Alignment.bottomRight
][index];
}
TextAlign? getTextAlign(String value) {
return switch (value) {
'center' => TextAlign.center,
'right' => TextAlign.right,
'left' => TextAlign.left,
'justify' => null,
Object() => null,
};
}

@ -7,6 +7,7 @@ import '../../models/documents/nodes/block.dart';
import '../../models/documents/nodes/line.dart';
import '../../models/structs/vertical_spacing.dart';
import '../../utils/delta.dart';
import '../../utils/string.dart';
import '../editor/editor.dart';
import '../others/box.dart';
import '../others/cursor.dart';
@ -222,10 +223,14 @@ class EditableTextBlock extends StatelessWidget {
.attributes?[Attribute.color.key],
)
: null;
// final textAlign = line.style.attributes['align']?.value != null
// ? getTextAlign(line.style.attributes['align']?.value)
// : null;
if (attrs[Attribute.list.key] == Attribute.ol) {
return QuillEditorNumberPoint(
index: index,
// textAlign: textAlign,
indentLevelCounts: indentLevelCounts,
count: count,
style: defaultStyles.leading!.style.copyWith(
@ -253,6 +258,7 @@ class EditableTextBlock extends StatelessWidget {
),
width: fontSize * 2,
padding: fontSize / 2,
// textAlign: textAlign,
);
}
@ -278,6 +284,7 @@ class EditableTextBlock extends StatelessWidget {
attrs: attrs,
padding: fontSize,
withDot: false,
// textAlign: textAlign,
);
}
return null;

@ -1,4 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
class QuillEditorBulletPoint extends StatelessWidget {
const QuillEditorBulletPoint({
@ -6,6 +6,7 @@ class QuillEditorBulletPoint extends StatelessWidget {
required this.width,
this.padding = 0,
this.backgroundColor,
this.textAlign,
super.key,
});
@ -13,6 +14,7 @@ class QuillEditorBulletPoint extends StatelessWidget {
final double width;
final double padding;
final Color? backgroundColor;
final TextAlign? textAlign;
@override
Widget build(BuildContext context) {
@ -24,6 +26,7 @@ class QuillEditorBulletPoint extends StatelessWidget {
child: Text(
'',
style: style,
textAlign: textAlign,
),
);
}

@ -11,6 +11,7 @@ class QuillEditorNumberPoint extends StatelessWidget {
required this.style,
required this.width,
required this.attrs,
this.textAlign,
this.withDot = true,
this.padding = 0.0,
super.key,
@ -26,6 +27,7 @@ class QuillEditorNumberPoint extends StatelessWidget {
final bool withDot;
final double padding;
final Color? backgroundColor;
final TextAlign? textAlign;
@override
Widget build(BuildContext context) {
@ -42,6 +44,7 @@ class QuillEditorNumberPoint extends StatelessWidget {
child: Text(
withDot ? '$s.' : s,
style: style,
textAlign: textAlign,
),
);
}
@ -77,6 +80,7 @@ class QuillEditorNumberPoint extends StatelessWidget {
child: Text(
withDot ? '$s.' : s,
style: style,
textAlign: textAlign,
),
);
}

Loading…
Cancel
Save