Ver código fonte

Prevent of creating balloon editor inside textarea.

Mateusz Samsel 6 anos atrás
pai
commit
d0a58d817c
1 arquivos alterados com 24 adições e 25 exclusões
  1. 24 25
      packages/ckeditor5-editor-balloon/src/ballooneditor.js

+ 24 - 25
packages/ckeditor5-editor-balloon/src/ballooneditor.js

@@ -195,31 +195,30 @@ export default class BalloonEditor extends Editor {
 	 * @returns {Promise} A promise resolved once the editor is ready. The promise resolves with the created editor instance.
 	 */
 	static create( sourceElementOrData, config = {} ) {
-		return new Promise( resolve => {
-			const editor = new this( sourceElementOrData, config );
-
-			resolve(
-				editor.initPlugins()
-					.then( () => {
-						editor.ui.init();
-					} )
-					.then( () => {
-						if ( !isElement( sourceElementOrData ) && config.initialData ) {
-							// Documented in core/editor/editorconfig.jdoc.
-							throw new CKEditorError(
-								'editor-create-initial-data: ' +
-								'The config.initialData option cannot be used together with initial data passed in Editor.create().'
-							);
-						}
-
-						const initialData = config.initialData || getInitialData( sourceElementOrData );
-
-						return editor.data.init( initialData );
-					} )
-					.then( () => editor.fire( 'ready' ) )
-					.then( () => editor )
-			);
-		} );
+		let editor;
+		return Editor.allowedElement( sourceElementOrData )
+			.then( () => {
+				editor = new this( sourceElementOrData, config );
+			} )
+			.then( () => editor.initPlugins() )
+			.then( () => {
+				editor.ui.init();
+			} )
+			.then( () => {
+				if ( !isElement( sourceElementOrData ) && config.initialData ) {
+					// Documented in core/editor/editorconfig.jdoc.
+					throw new CKEditorError(
+						'editor-create-initial-data: ' +
+						'The config.initialData option cannot be used together with initial data passed in Editor.create().'
+					);
+				}
+
+				const initialData = config.initialData || getInitialData( sourceElementOrData );
+
+				return editor.data.init( initialData );
+			} )
+			.then( () => editor.fire( 'ready' ) )
+			.then( () => editor );
 	}
 }