From 06d11a91d14b38fab363e95743e19ae29ba6acd0 Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Tue, 9 Aug 2022 10:44:00 +0800 Subject: [PATCH] feat: lineThrough and underline can coexist --- .../lib/render/rich_text/rich_text_style.dart | 11 +++++++---- .../format_rich_text_style.dart | 5 ----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/frontend/app_flowy/packages/flowy_editor/lib/render/rich_text/rich_text_style.dart b/frontend/app_flowy/packages/flowy_editor/lib/render/rich_text/rich_text_style.dart index cc4f6038ac..29677cdce9 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/render/rich_text/rich_text_style.dart +++ b/frontend/app_flowy/packages/flowy_editor/lib/render/rich_text/rich_text_style.dart @@ -204,12 +204,15 @@ class RichTextStyle { // underline or strikethrough TextDecoration get textDecoration { + var decorations = [TextDecoration.none]; if (attributes.underline || attributes.href != null) { - return TextDecoration.underline; - } else if (attributes.strikethrough) { - return TextDecoration.lineThrough; + decorations.add(TextDecoration.underline); + // TextDecoration.underline; } - return TextDecoration.none; + if (attributes.strikethrough) { + decorations.add(TextDecoration.lineThrough); + } + return TextDecoration.combine(decorations); } // font diff --git a/frontend/app_flowy/packages/flowy_editor/lib/service/default_text_operations/format_rich_text_style.dart b/frontend/app_flowy/packages/flowy_editor/lib/service/default_text_operations/format_rich_text_style.dart index 46c7d3278f..ce6d733d73 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/service/default_text_operations/format_rich_text_style.dart +++ b/frontend/app_flowy/packages/flowy_editor/lib/service/default_text_operations/format_rich_text_style.dart @@ -97,11 +97,6 @@ bool formatRichTextPartialStyle(EditorState editorState, String styleKey) { Attributes attributes = { styleKey: value, }; - if (styleKey == StyleKey.underline && value) { - attributes[StyleKey.strikethrough] = null; - } else if (styleKey == StyleKey.strikethrough && value) { - attributes[StyleKey.underline] = null; - } return formatRichTextStyle(editorState, attributes); }