mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: checkbox + underline doesn’t work when the checkbox is checked
This commit is contained in:
parent
a7681f86e5
commit
ad26f9c86d
@ -72,8 +72,8 @@ class _CheckboxNodeWidgetState extends State<CheckboxNodeWidget>
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
|
key: iconKey,
|
||||||
child: FlowySvg(
|
child: FlowySvg(
|
||||||
key: iconKey,
|
|
||||||
size: Size.square(_iconSize),
|
size: Size.square(_iconSize),
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
top: topPadding, right: _iconRightPadding),
|
top: topPadding, right: _iconRightPadding),
|
||||||
@ -149,7 +149,11 @@ class _CheckboxNodeWidgetState extends State<CheckboxNodeWidget>
|
|||||||
style: widget.textNode.attributes.check
|
style: widget.textNode.attributes.check
|
||||||
? span.style?.copyWith(
|
? span.style?.copyWith(
|
||||||
color: Colors.grey,
|
color: Colors.grey,
|
||||||
decoration: TextDecoration.lineThrough,
|
decoration: TextDecoration.combine([
|
||||||
|
TextDecoration.lineThrough,
|
||||||
|
if (span.style?.decoration != null)
|
||||||
|
span.style!.decoration!
|
||||||
|
]),
|
||||||
)
|
)
|
||||||
: span.style,
|
: span.style,
|
||||||
recognizer: span.recognizer,
|
recognizer: span.recognizer,
|
||||||
|
@ -47,13 +47,11 @@ class EditorWidgetTester {
|
|||||||
insert(TextNode.empty());
|
insert(TextNode.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void insertTextNode(String? text, {Attributes? attributes}) {
|
void insertTextNode(String? text, {Attributes? attributes, Delta? delta}) {
|
||||||
insert(
|
insert(
|
||||||
TextNode(
|
TextNode(
|
||||||
type: 'text',
|
type: 'text',
|
||||||
delta: Delta(
|
delta: delta ?? Delta([TextInsert(text ?? 'Test')]),
|
||||||
[TextInsert(text ?? 'Test')],
|
|
||||||
),
|
|
||||||
attributes: attributes,
|
attributes: attributes,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -0,0 +1,73 @@
|
|||||||
|
import 'package:flowy_editor/flowy_editor.dart';
|
||||||
|
import 'package:flowy_editor/src/render/rich_text/default_selectable.dart';
|
||||||
|
import 'package:flowy_editor/src/render/rich_text/rich_text_style.dart';
|
||||||
|
import 'package:flowy_editor/src/extensions/text_node_extensions.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import '../../infra/test_editor.dart';
|
||||||
|
|
||||||
|
void main() async {
|
||||||
|
setUpAll(() {
|
||||||
|
TestWidgetsFlutterBinding.ensureInitialized();
|
||||||
|
});
|
||||||
|
|
||||||
|
group('delete_text_handler.dart', () {
|
||||||
|
testWidgets('Presses backspace key in empty document', (tester) async {
|
||||||
|
// Before
|
||||||
|
//
|
||||||
|
// [BIUS]Welcome to Appflowy 😁[BIUS]
|
||||||
|
//
|
||||||
|
// After
|
||||||
|
//
|
||||||
|
// [checkbox]Welcome to Appflowy 😁
|
||||||
|
//
|
||||||
|
const text = 'Welcome to Appflowy 😁';
|
||||||
|
final editor = tester.editor
|
||||||
|
..insertTextNode(
|
||||||
|
'',
|
||||||
|
attributes: {
|
||||||
|
StyleKey.subtype: StyleKey.checkbox,
|
||||||
|
StyleKey.checkbox: false,
|
||||||
|
},
|
||||||
|
delta: Delta([
|
||||||
|
TextInsert(text, {
|
||||||
|
StyleKey.bold: true,
|
||||||
|
StyleKey.italic: true,
|
||||||
|
StyleKey.underline: true,
|
||||||
|
StyleKey.strikethrough: true,
|
||||||
|
}),
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
await editor.startTesting();
|
||||||
|
await editor.updateSelection(
|
||||||
|
Selection.single(path: [0], startOffset: 0),
|
||||||
|
);
|
||||||
|
|
||||||
|
final selection =
|
||||||
|
Selection.single(path: [0], startOffset: 0, endOffset: text.length);
|
||||||
|
var node = editor.nodeAtPath([0]) as TextNode;
|
||||||
|
var state = node.key?.currentState as DefaultSelectable;
|
||||||
|
var checkboxWidget = find.byKey(state.iconKey!);
|
||||||
|
await tester.tap(checkboxWidget);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
expect(node.attributes.check, true);
|
||||||
|
|
||||||
|
expect(node.allSatisfyBoldInSelection(selection), true);
|
||||||
|
expect(node.allSatisfyItalicInSelection(selection), true);
|
||||||
|
expect(node.allSatisfyUnderlineInSelection(selection), true);
|
||||||
|
expect(node.allSatisfyStrikethroughInSelection(selection), true);
|
||||||
|
|
||||||
|
node = editor.nodeAtPath([0]) as TextNode;
|
||||||
|
state = node.key?.currentState as DefaultSelectable;
|
||||||
|
await tester.ensureVisible(find.byKey(state.iconKey!));
|
||||||
|
await tester.tap(find.byKey(state.iconKey!));
|
||||||
|
await tester.pump();
|
||||||
|
|
||||||
|
expect(node.attributes.check, false);
|
||||||
|
expect(node.allSatisfyBoldInSelection(selection), true);
|
||||||
|
expect(node.allSatisfyItalicInSelection(selection), true);
|
||||||
|
expect(node.allSatisfyUnderlineInSelection(selection), true);
|
||||||
|
expect(node.allSatisfyStrikethroughInSelection(selection), true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user