A helper class implementing the UI component (view) factory.
It allows functions producing specific UI components to be registered under their unique names in the factory. A registered component can be then instantiated by providing its name. Note that names are case insensitive.
// The editor provides localization tools for the factory. const factory = new ComponentFactory( editor ); factory.add( 'foo', locale => new FooView( locale ) ); factory.add( 'bar', locale => new BarView( locale ) ); // An instance of FooView. const fooInstance = factory.create( 'foo' ); // Names are case insensitive so this is also allowed: const barInstance = factory.create( 'Bar' );
The editor instance that the factory belongs to.
_components : Map
Registered component factories.
constructor( editor )
add( name, callback )
Creates an instance of a component registered in the factory under a specific name.
has( name ) → Boolean
Checks if a component of a given name is registered in the factory.
name : String
The name of the component.
names() → Iterable.<String>
Returns an iterator of registered component names. Names are returned in lower case.