12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- import 'package:flowy_editor/document/path.dart';
- import 'package:flowy_editor/document/node.dart';
- import 'package:flowy_editor/document/text_delta.dart';
- import 'package:flowy_editor/document/attributes.dart';
- abstract class Operation {
- Operation invert();
- }
- class InsertOperation extends Operation {
- final Path path;
- final Node value;
- InsertOperation({
- required this.path,
- required this.value,
- });
- @override
- Operation invert() {
- return DeleteOperation(
- path: path,
- removedValue: value,
- );
- }
- }
- class UpdateOperation extends Operation {
- final Path path;
- final Attributes attributes;
- final Attributes oldAttributes;
- UpdateOperation({
- required this.path,
- required this.attributes,
- required this.oldAttributes,
- });
- @override
- Operation invert() {
- return UpdateOperation(
- path: path,
- attributes: oldAttributes,
- oldAttributes: attributes,
- );
- }
- }
- class DeleteOperation extends Operation {
- final Path path;
- final Node removedValue;
- DeleteOperation({
- required this.path,
- required this.removedValue,
- });
- @override
- Operation invert() {
- return InsertOperation(
- path: path,
- value: removedValue,
- );
- }
- }
- class TextEditOperation extends Operation {
- final Path path;
- final Delta delta;
- final Delta inverted;
- TextEditOperation({
- required this.path,
- required this.delta,
- required this.inverted,
- });
- @override
- Operation invert() {
- return TextEditOperation(path: path, delta: inverted, inverted: delta);
- }
- }
|