mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
Merge pull request #821 from AppFlowy-IO/fix/revert-delta-of-bold
Fix: revert delta of bold doesn't work
This commit is contained in:
commit
a2c11f96d1
@ -15,7 +15,7 @@ Attributes invertAttributes(Attributes? attr, Attributes? base) {
|
|||||||
return memo;
|
return memo;
|
||||||
});
|
});
|
||||||
return attr.keys.fold(baseInverted, (memo, key) {
|
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;
|
memo[key] = null;
|
||||||
}
|
}
|
||||||
return memo;
|
return memo;
|
||||||
|
@ -230,14 +230,18 @@ void main() {
|
|||||||
expect(expected, inverted);
|
expect(expected, inverted);
|
||||||
expect(base.compose(delta).compose(inverted), base);
|
expect(base.compose(delta).compose(inverted), base);
|
||||||
});
|
});
|
||||||
// test('retain', () {
|
test('retain', () {
|
||||||
// final delta = Delta().retain(2).retain(3, {'bold': true});
|
final delta = Delta()
|
||||||
// final base = Delta().insert('123456');
|
..retain(2)
|
||||||
// final expected = Delta().retain(2).retain(3, {'bold': null});
|
..retain(3, {'bold': true});
|
||||||
// final inverted = delta.invert(base);
|
final base = Delta()..insert('123456');
|
||||||
// expect(expected, inverted);
|
final expected = Delta()
|
||||||
// expect(base.compose(delta).compose(inverted), base);
|
..retain(2)
|
||||||
// });
|
..retain(3, {'bold': null});
|
||||||
|
final inverted = delta.invert(base);
|
||||||
|
expect(expected, inverted);
|
||||||
|
expect(base.compose(delta).compose(inverted), base);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
group('json', () {
|
group('json', () {
|
||||||
test('toJson()', () {
|
test('toJson()', () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user