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.

fix: revert delta of bold

Vincent Chan8f6eb5a0d673
diff --git a/frontend/app_flowy/packages/flowy_editor/lib/src/document/attributes.dart b/frontend/app_flowy/packages/flowy_editor/lib/src/document/attributes.dart
index 4e1f39775f..39a5f4e2ff 100644
--- a/frontend/app_flowy/packages/flowy_editor/lib/src/document/attributes.dart
+++ b/frontend/app_flowy/packages/flowy_editor/lib/src/document/attributes.dart
@@ -15,7 +15,7 @@ Attributes invertAttributes(Attributes? attr, Attributes? base) {
return memo;
});
return attr.keys.fold(baseInverted, (memo, key) {
- if (attr![key] != base![key] && base.containsKey(key)) {
+ if (attr![key] != base![key] && !base.containsKey(key)) {
memo[key] = null;
}
return memo;
diff --git a/frontend/app_flowy/packages/flowy_editor/test/delta_test.dart b/frontend/app_flowy/packages/flowy_editor/test/delta_test.dart
index 3114de8dd7..48182912a3 100644
--- a/frontend/app_flowy/packages/flowy_editor/test/delta_test.dart
+++ b/frontend/app_flowy/packages/flowy_editor/test/delta_test.dart
@@ -230,14 +230,18 @@ void main() {
expect(expected, inverted);
expect(base.compose(delta).compose(inverted), base);
});
- // test('retain', () {
- // final delta = Delta().retain(2).retain(3, {'bold': true});
- // final base = Delta().insert('123456');
- // final expected = Delta().retain(2).retain(3, {'bold': null});
- // final inverted = delta.invert(base);
- // expect(expected, inverted);
- // expect(base.compose(delta).compose(inverted), base);
- // });
+ test('retain', () {
+ final delta = Delta()
+ ..retain(2)
+ ..retain(3, {'bold': true});
+ final base = Delta()..insert('123456');
+ final expected = Delta()
+ ..retain(2)
+ ..retain(3, {'bold': null});
+ final inverted = delta.invert(base);
+ expect(expected, inverted);
+ expect(base.compose(delta).compose(inverted), base);
+ });
});
group('json', () {
test('toJson()', () {