Skip to content

Commit

Permalink
fix: cross blocks format not reflected on the float toolbar (#971)
Browse files Browse the repository at this point in the history
* fix: cross blocks format not reflected on the float toolbar

* test: cross blocks format not reflected on the float toolbar
  • Loading branch information
LucasXu0 authored Nov 25, 2024
1 parent 16a7287 commit 6009429
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/src/extensions/node_extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ extension NodesExtensions<T extends Node> on List<T> {
for (var i = 0; i < nodes.length; i++) {
final node = nodes[i];
var delta = node.delta;
if (delta == null) {
if (delta == null || delta.isEmpty) {
continue;
}

Expand Down
38 changes: 38 additions & 0 deletions test/new/extensions/node_extension_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -193,5 +193,43 @@ void main() async {
});
expect(result, false);
});

test('2 non-empty nodes with 1 empty node', () {
final document = Document.blank()
..addParagraph(
builder: (index) => Delta()
..insert(
'Hello',
attributes: {AppFlowyRichTextKeys.bold: true},
),
)
..addParagraph(
builder: (index) => Delta(),
)
..addParagraph(
builder: (index) => Delta()
..insert(
'World',
attributes: {
AppFlowyRichTextKeys.bold: true,
},
),
);
final editorState = EditorState(document: document);
final selection = Selection(
start: Position(path: [0], offset: 0),
end: Position(path: [2], offset: 5),
);
final nodes = editorState.getNodesInSelection(selection);
final isHighlight = nodes.allSatisfyInSelection(
selection,
(delta) =>
delta.isNotEmpty &&
delta.everyAttributes(
(attr) => attr[AppFlowyRichTextKeys.bold] == true,
),
);
expect(isHighlight, true);
});
});
}

0 comments on commit 6009429

Please sign in to comment.