Refactor out _handleImageInsert method

pull/13/head
singerdmx 4 years ago
parent 1486e5dcae
commit 1f333f4d96
  1. 14
      lib/models/documents/document.dart

@ -173,9 +173,15 @@ class Document {
for (int i = 0; i < ops.length; i++) { for (int i = 0; i < ops.length; i++) {
Operation op = ops[i]; Operation op = ops[i];
res.push(op); res.push(op);
bool nextOpIsImage = i + 1 < ops.length && _handleImageInsert(i, ops, op, res);
ops[i + 1].isInsert && }
ops[i + 1].data is! String; return res;
}
static void _handleImageInsert(
int i, List<Operation> ops, Operation op, Delta res) {
bool nextOpIsImage =
i + 1 < ops.length && ops[i + 1].isInsert && ops[i + 1].data is! String;
if (nextOpIsImage && !(op.data as String).endsWith('\n')) { if (nextOpIsImage && !(op.data as String).endsWith('\n')) {
res.push(Operation.insert('\n', null)); res.push(Operation.insert('\n', null));
} }
@ -190,8 +196,6 @@ class Document {
res.push(Operation.insert('\n', null)); res.push(Operation.insert('\n', null));
} }
} }
return res;
}
Object _normalize(Object data) { Object _normalize(Object data) {
if (data is String) { if (data is String) {

Loading…
Cancel
Save