Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
API docs fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ma2ciek committed Feb 1, 2019
1 parent 40b7345 commit 5bbeb84
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
36 changes: 18 additions & 18 deletions src/model/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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() ) {
Expand All @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions src/model/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -696,8 +696,8 @@ export default class Model {
const callbackReturnValue = this._pendingChanges[ 0 ].callback( this._currentWriter );
ret.push( callbackReturnValue );

// Collect an information whether the model document has changed during from the last pending change callback.
hasModelDocumentChanged = hasModelDocumentChanged || this.document._hasDocumentChangedFromTheLastChangeBlock();
// Collect an information whether the model document has changed during from the last pending change.
hasModelDocumentChanged = hasModelDocumentChanged || this.document._hasDocumentChanged();

// Fire '_change' event before resetting differ.
this.fire( '_change', this._currentWriter );
Expand Down Expand Up @@ -740,8 +740,8 @@ export default class Model {
* @protected
* @event _afterChanges
* @param {Object} options
* @param {Boolean} options.hasModelDocumentChanged A boolean indicates whether the model document has changed during the
* {@link module:engine/model/model~Model#change} blocks.
* @param {Boolean} options.hasModelDocumentChanged `true` if the model document has changed during the
* {@link module:engine/model/model~Model#change} or {@link module:engine/model/model~Model#enqueueChange} blocks.
*/

/**
Expand Down

0 comments on commit 5bbeb84

Please sign in to comment.