mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: update selection position after updating text node style.
This commit is contained in:
parent
35bafbaadc
commit
1166d03b75
@ -1,5 +1,7 @@
|
|||||||
import 'package:flowy_editor/document/attributes.dart';
|
import 'package:flowy_editor/document/attributes.dart';
|
||||||
import 'package:flowy_editor/document/node.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/editor_state.dart';
|
||||||
import 'package:flowy_editor/extensions/text_node_extensions.dart';
|
import 'package:flowy_editor/extensions/text_node_extensions.dart';
|
||||||
import 'package:flowy_editor/operation/transaction_builder.dart';
|
import 'package:flowy_editor/operation/transaction_builder.dart';
|
||||||
@ -46,13 +48,20 @@ bool formatTextNodes(EditorState editorState, Attributes attributes) {
|
|||||||
final builder = TransactionBuilder(editorState);
|
final builder = TransactionBuilder(editorState);
|
||||||
|
|
||||||
for (final textNode in textNodes) {
|
for (final textNode in textNodes) {
|
||||||
builder.updateNode(
|
builder
|
||||||
textNode,
|
..updateNode(
|
||||||
Attributes.fromIterable(
|
textNode,
|
||||||
StyleKey.globalStyleKeys,
|
Attributes.fromIterable(
|
||||||
value: (_) => null,
|
StyleKey.globalStyleKeys,
|
||||||
)..addAll(attributes),
|
value: (_) => null,
|
||||||
);
|
)..addAll(attributes),
|
||||||
|
)
|
||||||
|
..afterSelection = Selection.collapsed(
|
||||||
|
Position(
|
||||||
|
path: textNode.path,
|
||||||
|
offset: textNode.toRawString().length,
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.commit();
|
builder.commit();
|
||||||
|
Loading…
Reference in New Issue
Block a user