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

Commit

Permalink
Decorate DataController#set metohd.
Browse files Browse the repository at this point in the history
  • Loading branch information
oskarwrobel committed Mar 3, 2018
1 parent 2462d27 commit cd71a1b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/controller/datacontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ export default class DataController {
this.upcastDispatcher.on( 'text', convertText(), { priority: 'lowest' } );
this.upcastDispatcher.on( 'element', convertToModelFragment(), { priority: 'lowest' } );
this.upcastDispatcher.on( 'documentFragment', convertToModelFragment(), { priority: 'lowest' } );

this.decorate( 'set' );
}

/**
Expand Down Expand Up @@ -176,6 +178,7 @@ export default class DataController {
* This method also creates a batch with all the changes applied. If all you need is to parse data, use
* the {@link #parse} method.
*
* @fires set
* @param {String} data Input data.
* @param {String} [rootName='main'] Root name.
*/
Expand All @@ -184,8 +187,6 @@ export default class DataController {
const modelRoot = this.model.document.getRoot( rootName );

this.model.enqueueChange( 'transparent', writer => {
// Clearing selection is a workaround for ticket #569 (LiveRange loses position after removing data from document).
// After fixing it this code should be removed.
writer.setSelection( null );
writer.removeSelectionAttribute( this.model.document.selection.getAttributeKeys() );

Expand Down Expand Up @@ -236,6 +237,13 @@ export default class DataController {
* Removes all event listeners set by the DataController.
*/
destroy() {}

/**
* Event fired by decorated {@link #set} method.
* See {@link module:utils/observablemixin~ObservableMixin.decorate} for more information and samples.
*
* @event set
*/
}

mix( DataController, ObservableMixin );
Expand Down

0 comments on commit cd71a1b

Please sign in to comment.