Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

feat: update selection position after updating text node style.

Lucas.Xu1166d03b7558
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 79e7bfe077..8e0e3e35b0 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
@@ -1,5 +1,7 @@
import 'package:flowy_editor/document/attributes.dart';
import 'package:flowy_editor/document/node.dart';
+import 'package:flowy_editor/document/position.dart';
+import 'package:flowy_editor/document/selection.dart';
import 'package:flowy_editor/editor_state.dart';
import 'package:flowy_editor/extensions/text_node_extensions.dart';
import 'package:flowy_editor/operation/transaction_builder.dart';
@@ -46,13 +48,20 @@ bool formatTextNodes(EditorState editorState, Attributes attributes) {
final builder = TransactionBuilder(editorState);
for (final textNode in textNodes) {
- builder.updateNode(
- textNode,
- Attributes.fromIterable(
- StyleKey.globalStyleKeys,
- value: (_) => null,
- )..addAll(attributes),
- );
+ builder
+ ..updateNode(
+ textNode,
+ Attributes.fromIterable(
+ StyleKey.globalStyleKeys,
+ value: (_) => null,
+ )..addAll(attributes),
+ )
+ ..afterSelection = Selection.collapsed(
+ Position(
+ path: textNode.path,
+ offset: textNode.toRawString().length,
+ ),
+ );
}
builder.commit();