mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: fromJson
This commit is contained in:
parent
2e2de29789
commit
5e86b83eee
@ -2,6 +2,16 @@ import 'package:flowy_editor/document/attributes.dart';
|
|||||||
import 'package:flowy_editor/flowy_editor.dart';
|
import 'package:flowy_editor/flowy_editor.dart';
|
||||||
|
|
||||||
abstract class Operation {
|
abstract class Operation {
|
||||||
|
factory Operation.fromJson(Map<String, dynamic> map) {
|
||||||
|
String t = map["type"] as String;
|
||||||
|
if (t == "insert-operation") {
|
||||||
|
final path = map["path"] as List<int>;
|
||||||
|
final value = Node.fromJson(map["value"]);
|
||||||
|
return InsertOperation(path: path, value: value);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw ArgumentError('unexpected type $t');
|
||||||
|
}
|
||||||
final Path path;
|
final Path path;
|
||||||
Operation({required this.path});
|
Operation({required this.path});
|
||||||
Operation copyWithPath(Path path);
|
Operation copyWithPath(Path path);
|
||||||
|
Loading…
Reference in New Issue
Block a user