ComponentFactory (ui)
@ckeditor/ckeditor5-ui/src/componentfactory
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 locale is passed to the factory
function when create
is called.
Filtering
Properties
-
The editor instance that the factory belongs to.
-
_components : Map
private
Registered component factories.
Methods
-
constructor( editor )
Creates an instance of the factory.
Parameters
editor : Editor
The editor instance.
-
add( name, callback )
Registers a component factory function that will be used by the create method and called with the editor locale as an argument, allowing localization of the view.
Parameters
name : String
The name of the component.
callback : function
The callback that returns the component.
-
Creates an instance of a component registered in the factory under a specific name.
When called, the editor locale is passed to the previously added factory function, allowing localization of the view.
Parameters
name : String
The name of the component.
Returns
View
The instantiated component view.
-
has( name ) → Boolean
Checks if a component of a given name is registered in the factory.
Parameters
name : String
The name of the component.
Returns
Boolean
-
names() → Iterable.<String>
Returns an iterator of registered component names. Names are returned in lower case.
Returns
Iterable.<String>
Every day, we work hard to keep our documentation complete. Have you spotted an outdated information? Is something missing? Please report it via our issue tracker.