Explorar el Código

Remove static method and remain error description.

Mateusz Samsel hace 6 años
padre
commit
cc7d900cc3

+ 16 - 30
packages/ckeditor5-core/src/editor/editor.js

@@ -16,8 +16,6 @@ import DataController from '@ckeditor/ckeditor5-engine/src/controller/datacontro
 import Conversion from '@ckeditor/ckeditor5-engine/src/conversion/conversion';
 import Conversion from '@ckeditor/ckeditor5-engine/src/conversion/conversion';
 import Model from '@ckeditor/ckeditor5-engine/src/model/model';
 import Model from '@ckeditor/ckeditor5-engine/src/model/model';
 import EditingKeystrokeHandler from '../editingkeystrokehandler';
 import EditingKeystrokeHandler from '../editingkeystrokehandler';
-import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
-import { isElement } from 'lodash-es';
 
 
 import ObservableMixin from '@ckeditor/ckeditor5-utils/src/observablemixin';
 import ObservableMixin from '@ckeditor/ckeditor5-utils/src/observablemixin';
 import mix from '@ckeditor/ckeditor5-utils/src/mix';
 import mix from '@ckeditor/ckeditor5-utils/src/mix';
@@ -270,34 +268,6 @@ export default class Editor {
 		this.commands.execute( ...args );
 		this.commands.execute( ...args );
 	}
 	}
 
 
-	/**
-	 * Throws `editor-wrong-element` when checked element is `<textarea>`.
-	 *
-	 * @protected
-	 * @param {HTMLElement|String} sourceElementOrData The DOM element that will be the source for the created editor
-	 * or the editor's initial data.
-	 */
-	static _assertAllowedSourceElement( sourceElementOrData ) {
-		if ( isElement( sourceElementOrData ) && sourceElementOrData.tagName.toLowerCase() === 'textarea' ) {
-			/**
-			 * This error is thrown when a user tries to use a `<textarea>` element to create a non-classic editor in it.
-			 *
-			 * Textarea element represents a plain-text and cannot be used as a editable root element with included CKEditor5.
-			 * Content of an editor should be nicely present to the user and show him how it's going to looks like. Textarea element
-			 * doesn't support such behavior.
-			 *
-			 * Only {@glink builds/guides/overview#classic-editor Classic Editor} has implemented a special system, which
-			 * **replace** DOM element and load data from it
-			 * ({@link module:editor-classic/classiceditor~ClassicEditor.create more information}). All other editors
-			 * use an existing element, load data from it and make this element editable. Details about behaviour of each editor
-			 * might be found in an associated description of a `create` method of each editor.
-			 *
-			 * @error editor-wrong-element
-			 */
-			throw new CKEditorError( 'editor-wrong-element: This type of editor cannot be initialized inside <textarea> element.' );
-		}
-	}
-
 	/**
 	/**
 	 * Creates and initializes a new editor instance.
 	 * Creates and initializes a new editor instance.
 	 *
 	 *
@@ -342,6 +312,22 @@ mix( Editor, ObservableMixin );
  * @event destroy
  * @event destroy
  */
  */
 
 
+/**
+ * This error is thrown when a user tries to use a `<textarea>` element to create a non-classic editor in it.
+ *
+ * Textarea element represents a plain-text and cannot be used as a editable root element with included CKEditor5.
+ * Content of an editor should be nicely present to the user and show him how it's going to looks like. Textarea element
+ * doesn't support such behavior.
+ *
+ * Only {@glink builds/guides/overview#classic-editor Classic Editor} has implemented a special system, which
+ * **replace** DOM element and load data from it
+ * ({@link module:editor-classic/classiceditor~ClassicEditor.create more information}). All other editors
+ * use an existing element, load data from it and make this element editable. Details about behaviour of each editor
+ * might be found in an associated description of a `create` method of each editor.
+ *
+ * @error editor-wrong-element
+ */
+
 /**
 /**
  * An array of plugins built into this editor class.
  * An array of plugins built into this editor class.
  * It is used in CKEditor 5 builds to provide a list of plugins which are later automatically initialized
  * It is used in CKEditor 5 builds to provide a list of plugins which are later automatically initialized

+ 1 - 30
packages/ckeditor5-core/tests/editor/editor.js

@@ -3,7 +3,7 @@
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
  */
 
 
-/* globals window, setTimeout, document */
+/* globals window, setTimeout */
 
 
 import Editor from '../../src/editor/editor';
 import Editor from '../../src/editor/editor';
 import Plugin from '../../src/plugin';
 import Plugin from '../../src/plugin';
@@ -773,35 +773,6 @@ describe( 'Editor', () => {
 				} );
 				} );
 		} );
 		} );
 	} );
 	} );
-
-	describe( '_assertAllowedSourceElement()', () => {
-		it( 'should pass for non-html data', () => {
-			const notThrowingFn = () => {
-				Editor._assertAllowedSourceElement( 'some initial data' );
-			};
-
-			expect( notThrowingFn ).to.not.throw();
-		} );
-
-		it( 'should pass non-textarea element', () => {
-			const element = document.createElement( 'div' );
-			const notThrowingFn = () => {
-				Editor._assertAllowedSourceElement( element );
-			};
-
-			expect( notThrowingFn ).to.not.throw();
-		} );
-
-		it( 'should throw error for textarea element', () => {
-			const element = document.createElement( 'textarea' );
-			const throwingFn = () => {
-				Editor._assertAllowedSourceElement( element );
-			};
-
-			expect( throwingFn ).to
-				.throw( CKEditorError, /^editor-wrong-element: This type of editor cannot be initialized inside <textarea> element\./ );
-		} );
-	} );
 } );
 } );
 
 
 function getPlugins( editor ) {
 function getPlugins( editor ) {