When inserting and loading embedded styles, there is always an extra newline

pull/295/head
gtyhn 4 years ago
parent 2aa577ca58
commit f8b421e2db
  1. 4
      lib/src/models/documents/document.dart

@ -219,15 +219,17 @@ class Document {
}
// Currently embed is equivalent to image and hence `is! String`
final opInsertImage = op.isInsert && op.data is! String;
if (opInsertImage) {
final nextOpIsLineBreak = i + 1 < ops.length &&
ops[i + 1].isInsert &&
ops[i + 1].data is String &&
(ops[i + 1].data as String).startsWith('\n');
if (opInsertImage && (i + 1 == ops.length - 1 || !nextOpIsLineBreak)) {
if (!nextOpIsLineBreak) {
// automatically append '\n' for image
res.push(Operation.insert('\n'));
}
}
}
Object _normalize(Object? data) {
if (data is String) {

Loading…
Cancel
Save