|
|
@@ -278,6 +278,21 @@ export default class Document {
|
|
|
this._postFixers.add( postFixer );
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * A custom `toJSON()` method to solve child-parent circular dependencies.
|
|
|
+ *
|
|
|
+ * @returns {Object} A clone of this object with the document property changed to a string.
|
|
|
+ */
|
|
|
+ toJSON() {
|
|
|
+ const json = clone( this );
|
|
|
+
|
|
|
+ // Due to circular references we need to remove parent reference.
|
|
|
+ json.selection = '[engine.model.DocumentSelection]';
|
|
|
+ json.model = '[engine.model.Model]';
|
|
|
+
|
|
|
+ return json;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Check if there were any changes done on document, and if so, call post-fixers,
|
|
|
* fire `change` event for features and conversion and then reset the differ.
|
|
|
@@ -289,7 +304,7 @@ export default class Document {
|
|
|
* @param {module:engine/model/writer~Writer writer} writer The writer on which post-fixers will be called.
|
|
|
*/
|
|
|
_runPostFixersAndResetDiffer( writer ) {
|
|
|
- if ( this._hasDocumentChangedFromTheLastChangeBlock() ) {
|
|
|
+ if ( this._hasDocumentChanged() ) {
|
|
|
this._callPostFixers( writer );
|
|
|
|
|
|
if ( this.differ.hasDataChanges() ) {
|
|
|
@@ -310,27 +325,12 @@ export default class Document {
|
|
|
* or {@link module:engine/model/model~Model#change `change()` block}.
|
|
|
*
|
|
|
* @protected
|
|
|
- * @returns {Boolean} Returns `true` when document has changed from the last change block.
|
|
|
+ * @returns {Boolean} Returns `true` if document has changed from the differ's reset.
|
|
|
*/
|
|
|
- _hasDocumentChangedFromTheLastChangeBlock() {
|
|
|
+ _hasDocumentChanged() {
|
|
|
return !this.differ.isEmpty || this._hasSelectionChangedFromTheLastChangeBlock;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * A custom `toJSON()` method to solve child-parent circular dependencies.
|
|
|
- *
|
|
|
- * @returns {Object} A clone of this object with the document property changed to a string.
|
|
|
- */
|
|
|
- toJSON() {
|
|
|
- const json = clone( this );
|
|
|
-
|
|
|
- // Due to circular references we need to remove parent reference.
|
|
|
- json.selection = '[engine.model.DocumentSelection]';
|
|
|
- json.model = '[engine.model.Model]';
|
|
|
-
|
|
|
- return json;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Returns the default root for this document which is either the first root that was added to the document using
|
|
|
* {@link #createRoot} or the {@link #graveyard graveyard root} if no other roots were created.
|