瀏覽代碼

Remove command existence check in RestrictedEditingModeEditing.enableCommand().

Maciej Gołaszewski 5 年之前
父節點
當前提交
857a6a4b83

+ 0 - 10
packages/ckeditor5-restricted-editing/src/restrictededitingmodeediting.js

@@ -16,7 +16,6 @@ import {
 	upcastHighlightToMarker
 } from './restrictededitingmode/converters';
 import { getMarkerAtPosition, isSelectionInMarker } from './restrictededitingmode/utils';
-import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
 
 const COMMAND_FORCE_DISABLE_ID = 'RestrictedEditingMode';
 
@@ -104,15 +103,6 @@ export default class RestrictedEditingModeEditing extends Plugin {
 	enableCommand( commandName ) {
 		const command = this.editor.commands.get( commandName );
 
-		if ( !command ) {
-			/**
-			 * Trying to enable command that does not exist.
-			 *
-			 * @error restricted-editing-command-not-found
-			 */
-			throw new CKEditorError( 'restricted-editing-command-not-found: Trying to enable command that does not exist.', this );
-		}
-
 		command.clearForceDisabled( COMMAND_FORCE_DISABLE_ID );
 
 		this._alwaysEnabled.add( commandName );

+ 1 - 11
packages/ckeditor5-restricted-editing/tests/restrictededitingmodeediting.js

@@ -9,7 +9,7 @@ import { getData as getModelData, setData as setModelData } from '@ckeditor/cked
 import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
 import { getCode } from '@ckeditor/ckeditor5-utils/src/keyboard';
 import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
-import { assertEqualMarkup, expectToThrowCKEditorError } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
+import { assertEqualMarkup } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
 import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
 import BoldEditing from '@ckeditor/ckeditor5-basic-styles/src/bold/boldediting';
 import StrikethroughEditing from '@ckeditor/ckeditor5-basic-styles/src/strikethrough/strikethroughediting';
@@ -85,16 +85,6 @@ describe( 'RestrictedEditingModeEditing', () => {
 			addExceptionMarker( 4, 7, model.document.getRoot().getChild( 0 ) );
 		} );
 
-		it( 'should throw if non-existing command is being enabled', () => {
-			expectToThrowCKEditorError(
-				() => {
-					plugin.enableCommand( 'foo' );
-				},
-				/^restricted-editing-command-not-found/,
-				editor
-			);
-		} );
-
 		it( 'should enable the command globally', () => {
 			expect( command.isEnabled ).to.be.false;