Skip to content

Commit

Permalink
Create MediaFormView for each dropdown instance separately. Fixes #6333
Browse files Browse the repository at this point in the history
  • Loading branch information
tomalec committed May 4, 2020
1 parent 887c6a5 commit 1189a50
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
14 changes: 5 additions & 9 deletions packages/ckeditor5-media-embed/src/mediaembedui.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,15 @@ export default class MediaEmbedUI extends Plugin {
const command = editor.commands.get( 'mediaEmbed' );
const registry = editor.plugins.get( MediaEmbedEditing ).registry;

/**
* The form view displayed inside the drop-down.
*
* @member {module: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 dropdown = createDropdown( locale );

this._setUpDropdown( dropdown, this.form, command, editor );
this._setUpForm( this.form, dropdown, command );
// Prepare custom view for dropdown's panel.
const mediaForm = new MediaFormView( getFormValidators( editor.t, registry ), editor.locale );

this._setUpDropdown( dropdown, mediaForm, command, editor );
this._setUpForm( mediaForm, dropdown, command );

return dropdown;
} );
Expand Down
6 changes: 6 additions & 0 deletions packages/ckeditor5-media-embed/tests/mediaembedui.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ describe( 'MediaEmbedUI', () => {
expect( dropdown ).to.be.instanceOf( DropdownView );
} );

it( 'should allow creating two instances', () => {
expect( function createSecondInstance() {
editor.ui.componentFactory.create( 'mediaEmbed' );
} ).not.to.throw();
} );

describe( 'dropdown', () => {
it( 'should bind #isEnabled to the command', () => {
const command = editor.commands.get( 'mediaEmbed' );
Expand Down

0 comments on commit 1189a50

Please sign in to comment.