|
@@ -1,5 +1,6 @@
|
|
|
import 'dart:async';
|
|
|
|
|
|
+import 'package:appflowy_editor/src/commands/text_command_infra.dart';
|
|
|
import 'package:appflowy_editor/src/document/attributes.dart';
|
|
|
import 'package:appflowy_editor/src/document/node.dart';
|
|
|
import 'package:appflowy_editor/src/document/path.dart';
|
|
@@ -45,7 +46,7 @@ Future<void> updateTextNodeDeltaAttributes(
|
|
|
path: path,
|
|
|
textNode: textNode,
|
|
|
);
|
|
|
- final newSelection = _getSelection(editorState, selection: selection);
|
|
|
+ final newSelection = getSelection(editorState, selection: selection);
|
|
|
|
|
|
final completer = Completer<void>();
|
|
|
|
|
@@ -64,40 +65,3 @@ Future<void> updateTextNodeDeltaAttributes(
|
|
|
|
|
|
return completer.future;
|
|
|
}
|
|
|
-
|
|
|
-// get formatted [TextNode]
|
|
|
-TextNode getTextNodeToBeFormatted(
|
|
|
- EditorState editorState, {
|
|
|
- Path? path,
|
|
|
- TextNode? textNode,
|
|
|
-}) {
|
|
|
- assert(!(path != null && textNode != null));
|
|
|
- assert(!(path == null && textNode == null));
|
|
|
-
|
|
|
- TextNode result;
|
|
|
- if (textNode != null) {
|
|
|
- result = textNode;
|
|
|
- } else if (path != null) {
|
|
|
- result = editorState.document.nodeAtPath(path) as TextNode;
|
|
|
- } else {
|
|
|
- throw Exception('path and textNode cannot be null at the same time');
|
|
|
- }
|
|
|
- return result;
|
|
|
-}
|
|
|
-
|
|
|
-Selection _getSelection(
|
|
|
- EditorState editorState, {
|
|
|
- Selection? selection,
|
|
|
-}) {
|
|
|
- final currentSelection =
|
|
|
- editorState.service.selectionService.currentSelection.value;
|
|
|
- Selection result;
|
|
|
- if (selection != null) {
|
|
|
- result = selection;
|
|
|
- } else if (currentSelection != null) {
|
|
|
- result = currentSelection;
|
|
|
- } else {
|
|
|
- throw Exception('path and textNode cannot be null at the same time');
|
|
|
- }
|
|
|
- return result;
|
|
|
-}
|