瀏覽代碼

feat: lineThrough and underline can coexist

Lucas.Xu 2 年之前
父節點
當前提交
06d11a91d1

+ 7 - 4
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

+ 0 - 5
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);
 }