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

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

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

Loading…
Cancel
Save