fix: minor issues
This commit is contained in:
parent
3525230f9a
commit
20e8685152
2 changed files with 11 additions and 11 deletions
|
|
@ -2,14 +2,14 @@ import 'package:appflowy_editor/appflowy_editor.dart';
|
|||
|
||||
abstract class Operation {
|
||||
factory Operation.fromJson(Map<String, dynamic> map) {
|
||||
String t = map["type"] as String;
|
||||
if (t == "insert-operation") {
|
||||
String t = map["op"] as String;
|
||||
if (t == "insert") {
|
||||
return InsertOperation.fromJson(map);
|
||||
} else if (t == "update-operation") {
|
||||
} else if (t == "update") {
|
||||
return UpdateOperation.fromJson(map);
|
||||
} else if (t == "delete-operation") {
|
||||
} else if (t == "delete") {
|
||||
return DeleteOperation.fromJson(map);
|
||||
} else if (t == "text-edit-operation") {
|
||||
} else if (t == "text-edit") {
|
||||
return TextEditOperation.fromJson(map);
|
||||
}
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ class InsertOperation extends Operation {
|
|||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
"type": "insert-operation",
|
||||
"op": "insert",
|
||||
"path": path.toList(),
|
||||
"nodes": nodes.map((n) => n.toJson()),
|
||||
};
|
||||
|
|
@ -95,7 +95,7 @@ class UpdateOperation extends Operation {
|
|||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
"type": "update-operation",
|
||||
"op": "update",
|
||||
"path": path.toList(),
|
||||
"attributes": {...attributes},
|
||||
"oldAttributes": {...oldAttributes},
|
||||
|
|
@ -132,7 +132,7 @@ class DeleteOperation extends Operation {
|
|||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
"type": "delete-operation",
|
||||
"op": "delete",
|
||||
"path": path.toList(),
|
||||
"nodes": nodes.map((n) => n.toJson()),
|
||||
};
|
||||
|
|
@ -171,7 +171,7 @@ class TextEditOperation extends Operation {
|
|||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
"type": "text-edit-operation",
|
||||
"op": "text-edit",
|
||||
"path": path.toList(),
|
||||
"delta": delta.toJson(),
|
||||
"invert": inverted.toJson(),
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ void main() {
|
|||
expect(transaction.toJson(), {
|
||||
"operations": [
|
||||
{
|
||||
"type": "insert-operation",
|
||||
"op": "insert",
|
||||
"path": [0],
|
||||
"nodes": [item1.toJson()],
|
||||
}
|
||||
|
|
@ -107,7 +107,7 @@ void main() {
|
|||
expect(transaction.toJson(), {
|
||||
"operations": [
|
||||
{
|
||||
"type": "delete-operation",
|
||||
"op": "delete",
|
||||
"path": [0],
|
||||
"nodes": [item1.toJson()],
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue