From 215587a50703ff0e7103f3eae041e076c1aa5e57 Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Tue, 9 Aug 2022 19:37:46 +0800 Subject: [PATCH] chore: format code --- .../lib/operation/transaction_builder.dart | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/frontend/app_flowy/packages/flowy_editor/lib/operation/transaction_builder.dart b/frontend/app_flowy/packages/flowy_editor/lib/operation/transaction_builder.dart index 2898f7113a..cececec924 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/operation/transaction_builder.dart +++ b/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(