Skip to content

Commit

Permalink
Fix append \n for image in _transform
Browse files Browse the repository at this point in the history
  • Loading branch information
singerdmx committed Dec 27, 2020
1 parent ce77729 commit 1d900af
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/models/documents/document.dart
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ class Document {
Delta res = Delta();
for (Operation op in delta.toList()) {
res.push(op);
if (op.isInsert && op.data is! String) {
// This case is 'insert embed'
// automatically append '\n' for image
res.push(Operation.insert('\n', null));
}
}
return res;
}
Expand Down Expand Up @@ -202,12 +207,6 @@ class Document {
final data = _normalize(op.data);
_root.insert(offset, data, style);
offset += op.length;
if (data is! String) {
// This case is 'insert embed'
// automatically append '\n' for image
_root.insert(offset, '\n', null);
offset++;
}
}
final node = _root.last;
if (node is Line &&
Expand Down

0 comments on commit 1d900af

Please sign in to comment.