8
0
فهرست منبع

Rendering fix proposal.

Piotr Jasiun 7 سال پیش
والد
کامیت
e1ca12c009

+ 9 - 0
packages/ckeditor5-engine/src/controller/editingcontroller.js

@@ -73,6 +73,15 @@ export default class EditingController {
 		// Whenever model document is changed, convert those changes to the view (using model.Document#differ).
 		// Do it on 'low' priority, so changes are converted after other listeners did their job.
 		// Also convert model selection.
+		this.listenTo( this.model, '_beforeChanges', () => {
+			this.view.disabledRendering = true;
+		}, { priority: 'highest' } );
+
+		this.listenTo( this.model, '_afterChanges', () => {
+			this.view.disabledRendering = false;
+			this.view.render();
+		}, { priority: 'lowest' } );
+
 		this.listenTo( doc, 'change', () => {
 			this.view.change( writer => {
 				this.downcastDispatcher.convertChanges( doc.differ, writer );

+ 4 - 0
packages/ckeditor5-engine/src/model/model.js

@@ -370,6 +370,8 @@ export default class Model {
 	_runPendingChanges() {
 		const ret = [];
 
+		this.fire( '_beforeChanges', this._currentWriter );
+
 		while ( this._pendingChanges.length ) {
 			// Create a new writer using batch instance created for this chain of changes.
 			const currentBatch = this._pendingChanges[ 0 ].batch;
@@ -386,6 +388,8 @@ export default class Model {
 			this._currentWriter = null;
 		}
 
+		this.fire( '_afterChanges', this._currentWriter );
+
 		return ret;
 	}
 

+ 4 - 1
packages/ckeditor5-engine/src/view/view.js

@@ -358,7 +358,10 @@ export default class View {
 		this.document._callPostFixers( this._writer );
 		this._postFixersInProgress = false;
 
-		this.fire( 'render' );
+
+		if( !this.disabledRendering ) {
+			this.fire( 'render' );
+		}
 	}
 
 	/**