浏览代码

chore: format code

Lucas.Xu 2 年之前
父节点
当前提交
215587a507
共有 1 个文件被更改,包括 9 次插入8 次删除
  1. 9 8
      frontend/app_flowy/packages/flowy_editor/lib/operation/transaction_builder.dart

+ 9 - 8
frontend/app_flowy/packages/flowy_editor/lib/operation/transaction_builder.dart

@@ -106,18 +106,19 @@ class TransactionBuilder {
 
   insertText(TextNode node, int index, String content,
       [Attributes? attributes]) {
+    var newAttributes = attributes;
+    if (index != 0 && attributes == null) {
+      newAttributes = node.delta
+          .slice(max(index - 1, 0), index)
+          .operations
+          .first
+          .attributes;
+    }
     textEdit(
       node,
       () => Delta().retain(index).insert(
             content,
-            attributes ??
-                (index == 0
-                    ? null
-                    : node.delta
-                        .slice(max(index - 1, 0), index)
-                        .operations
-                        .first
-                        .attributes),
+            newAttributes,
           ),
     );
     afterSelection = Selection.collapsed(