Browse Source

Internal: Added names to the plugins that expose a public API (see ckeditor/ckeditor5#1336).

Aleksander Nowodzinski 6 years ago
parent
commit
0b027da693

+ 7 - 0
packages/ckeditor5-media-embed/src/mediaembedediting.js

@@ -25,6 +25,13 @@ export default class MediaEmbedEditing extends Plugin {
 	/**
 	 * @inheritDoc
 	 */
+	static get pluginName() {
+		return 'MediaEmbedEditing';
+	}
+
+	/**
+	 * @inheritDoc
+	 */
 	constructor( editor ) {
 		super( editor );
 

+ 16 - 3
packages/ckeditor5-media-embed/src/mediaembedui.js

@@ -29,18 +29,31 @@ export default class MediaEmbedUI extends Plugin {
 	/**
 	 * @inheritDoc
 	 */
+	static get pluginName() {
+		return 'MediaEmbedUI';
+	}
+
+	/**
+	 * @inheritDoc
+	 */
 	init() {
 		const editor = this.editor;
 		const command = editor.commands.get( 'mediaEmbed' );
 		const registry = editor.plugins.get( MediaEmbedEditing ).registry;
 
+		/**
+		 * The form view displayed inside the drop-down.
+		 *
+		 * @member {media-embed/ui/mediaformview~MediaFormView}
+		 */
+		this.form = new MediaFormView( getFormValidators( editor.t, registry ), editor.locale );
+
 		// Setup `imageUpload` button.
 		editor.ui.componentFactory.add( 'mediaEmbed', locale => {
-			const form = new MediaFormView( getFormValidators( editor.t, registry ), locale );
 			const dropdown = createDropdown( locale );
 
-			this._setUpDropdown( dropdown, form, command, editor );
-			this._setUpForm( form, dropdown, command );
+			this._setUpDropdown( dropdown, this.form, command, editor );
+			this._setUpForm( this.form, dropdown, command );
 
 			return dropdown;
 		} );

+ 4 - 0
packages/ckeditor5-media-embed/tests/mediaembedediting.js

@@ -61,6 +61,10 @@ describe( 'MediaEmbedEditing', () => {
 		testUtils.sinon.stub( env, 'isEdge' ).get( () => false );
 	} );
 
+	it( 'should be named', () => {
+		expect( MediaEmbedEditing.pluginName ).to.equal( 'MediaEmbedEditing' );
+	} );
+
 	describe( 'constructor()', () => {
 		describe( 'configuration', () => {
 			describe( '#providers', () => {

+ 5 - 0
packages/ckeditor5-media-embed/tests/mediaembedui.js

@@ -5,6 +5,7 @@
 
 import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
 import MediaEmbed from '../src/mediaembed';
+import MediaEmbedUI from '../src/mediaembedui';
 import MediaFormView from '../src/ui/mediaformview';
 import DropdownView from '@ckeditor/ckeditor5-ui/src/dropdown/dropdownview';
 import global from '@ckeditor/ckeditor5-utils/src/dom/global';
@@ -44,6 +45,10 @@ describe( 'MediaEmbedUI', () => {
 		return editor.destroy();
 	} );
 
+	it( 'should be named', () => {
+		expect( MediaEmbedUI.pluginName ).to.equal( 'MediaEmbedUI' );
+	} );
+
 	it( 'should add the "mediaEmbed" component to the factory', () => {
 		expect( dropdown ).to.be.instanceOf( DropdownView );
 	} );