浏览代码

Changed: Moved operation validation to a separate event in `Model`.

Szymon Cofalik 8 年之前
父节点
当前提交
53dae1989e
共有 2 个文件被更改,包括 8 次插入1 次删除
  1. 0 1
      packages/ckeditor5-engine/src/model/document.js
  2. 8 0
      packages/ckeditor5-engine/src/model/model.js

+ 0 - 1
packages/ckeditor5-engine/src/model/document.js

@@ -119,7 +119,6 @@ export default class Document {
 				);
 			}
 
-			operation._validate();
 		}, { priority: 'highest' } );
 
 		this.listenTo( model, 'applyOperation', ( evt, args ) => {

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

@@ -71,6 +71,14 @@ export default class Model {
 		[ 'insertContent', 'deleteContent', 'modifySelection', 'getSelectedContent', 'applyOperation' ]
 			.forEach( methodName => this.decorate( methodName ) );
 
+		// Adding operation validation with a highest priority, so it is called before any other feature would like
+		// to do anything with the operation. If the operation has incorrect parameters it should throw earliest moment.
+		this.on( 'applyOperation', ( evt, args ) => {
+			const operation = args[ 0 ];
+
+			operation._validate();
+		}, { priority: 'highest' } );
+
 		// Register some default abstract entities.
 		this.schema.register( '$root', {
 			isLimit: true