Bladeren bron

Using document#changesDone event to update command's value.

Szymon Kupś 9 jaren geleden
bovenliggende
commit
90f33917ed
1 gewijzigde bestanden met toevoegingen van 2 en 5 verwijderingen
  1. 2 5
      packages/ckeditor5-heading/src/headingcommand.js

+ 2 - 5
packages/ckeditor5-heading/src/headingcommand.js

@@ -39,8 +39,8 @@ export default class HeadingCommand extends Command {
 		 */
 		this.set( 'value', this.defaultFormat );
 
-		// Listen on selection change and set current command's format to format in the current selection.
-		this.listenTo( editor.document.selection, 'change', () => this._updateValue() );
+		// Update current value each time changes are done on document.
+		this.listenTo( editor.document, 'changesDone', () => this._updateValue() );
 	}
 
 	/**
@@ -118,9 +118,6 @@ export default class HeadingCommand extends Command {
 			// If range's selection start/end is placed directly in renamed block - we need to restore it's position
 			// after renaming, because renaming puts new element there.
 			doc.selection.setRanges( ranges, isSelectionBackward );
-
-			// Update command's value after change.
-			this._updateValue();
 		} );
 	}