|
|
@@ -5,6 +5,8 @@
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
+import clone from '../../lib/lodash/clone.js';
|
|
|
+
|
|
|
/**
|
|
|
* Abstract base operation class.
|
|
|
*
|
|
|
@@ -71,4 +73,19 @@ export default class Operation {
|
|
|
* property containing changed nodes. May have additional properties depending on the operation type.
|
|
|
*/
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Custom toJSON method to solve child-parent circular dependencies.
|
|
|
+ *
|
|
|
+ * @method core.treeModel.operation.Operation#toJSON
|
|
|
+ * @returns {Object} Clone of this object with the delta property replaced with string.
|
|
|
+ */
|
|
|
+ toJSON() {
|
|
|
+ const json = clone( this );
|
|
|
+
|
|
|
+ // Due to circular references we need to remove parent reference.
|
|
|
+ json.delta = this.delta ? '[core.treeModel.Delta]' : null;
|
|
|
+
|
|
|
+ return json;
|
|
|
+ }
|
|
|
}
|