Explorar o código

Move restriction enforcing related commands to private method.

Maciej Gołaszewski %!s(int64=6) %!d(string=hai) anos
pai
achega
9cd1191282

+ 9 - 4
packages/ckeditor5-restricted-editing/src/restrictededitingmodeediting.js

@@ -76,6 +76,7 @@ export default class RestrictedEditingModeEditing extends Plugin {
 
 
 		this._setupConversion();
 		this._setupConversion();
 		this._setupCommandsToggling();
 		this._setupCommandsToggling();
+		this._setupRestrictions();
 
 
 		// Commands & keystrokes that allow navigation in the content.
 		// Commands & keystrokes that allow navigation in the content.
 		editor.commands.add( 'goToPreviousRestrictedEditingException', new RestrictedEditingNavigationCommand( editor, 'backward' ) );
 		editor.commands.add( 'goToPreviousRestrictedEditingException', new RestrictedEditingNavigationCommand( editor, 'backward' ) );
@@ -162,8 +163,14 @@ export default class RestrictedEditingModeEditing extends Plugin {
 		doc.registerPostFixer( extendMarkerOnTypingPostFixer( editor ) );
 		doc.registerPostFixer( extendMarkerOnTypingPostFixer( editor ) );
 		doc.registerPostFixer( resurrectCollapsedMarkerPostFixer( editor ) );
 		doc.registerPostFixer( resurrectCollapsedMarkerPostFixer( editor ) );
 
 
-		this.listenTo( model, 'deleteContent', restrictDeleteContent( editor ), { priority: 'high' } );
-		this.listenTo( model, 'applyOperation', restrictAttributeOperation( editor ), { priority: 'high' } );
+		setupExceptionHighlighting( editor );
+	}
+
+	_setupRestrictions() {
+		const editor = this.editor;
+
+		this.listenTo( editor.model, 'deleteContent', restrictDeleteContent( editor ), { priority: 'high' } );
+		this.listenTo( editor.model, 'applyOperation', restrictAttributeOperation( editor ), { priority: 'high' } );
 
 
 		const inputCommand = this.editor.commands.get( 'input' );
 		const inputCommand = this.editor.commands.get( 'input' );
 
 
@@ -172,8 +179,6 @@ export default class RestrictedEditingModeEditing extends Plugin {
 		if ( inputCommand ) {
 		if ( inputCommand ) {
 			this.listenTo( inputCommand, 'execute', restrictInputRangeOption( editor ), { priority: 'high' } );
 			this.listenTo( inputCommand, 'execute', restrictInputRangeOption( editor ), { priority: 'high' } );
 		}
 		}
-
-		setupExceptionHighlighting( editor );
 	}
 	}
 
 
 	/**
 	/**