From 59838f584552b53cdf5afb7f1eb155892a83e3ee Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Sun, 7 Aug 2022 21:46:42 +0800 Subject: [PATCH] feat: customizes checkbox text style --- .../lib/render/rich_text/checkbox_text.dart | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/frontend/app_flowy/packages/flowy_editor/lib/render/rich_text/checkbox_text.dart b/frontend/app_flowy/packages/flowy_editor/lib/render/rich_text/checkbox_text.dart index d6eeb65c3d..ee64084901 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/render/rich_text/checkbox_text.dart +++ b/frontend/app_flowy/packages/flowy_editor/lib/render/rich_text/checkbox_text.dart @@ -86,6 +86,7 @@ class _CheckboxNodeWidgetState extends State key: _richTextKey, placeholderText: 'To-do', textNode: widget.textNode, + textSpanDecorator: _textSpanDecorator, editorState: widget.editorState, ) ], @@ -121,4 +122,24 @@ class _CheckboxNodeWidgetState extends State ], ); } + + TextSpan _textSpanDecorator(TextSpan textSpan) { + return TextSpan( + children: textSpan.children + ?.whereType() + .map( + (span) => TextSpan( + text: span.text, + style: widget.textNode.attributes.check + ? span.style?.copyWith( + color: Colors.grey, + decoration: TextDecoration.lineThrough, + ) + : span.style, + recognizer: span.recognizer, + ), + ) + .toList(), + ); + } }