|
|
@@ -53,6 +53,12 @@ export default class ComponentFactory {
|
|
|
*/
|
|
|
add( name, callback ) {
|
|
|
if ( this._components.get( name ) ) {
|
|
|
+ /**
|
|
|
+ * The item already exists in the component factory.
|
|
|
+ *
|
|
|
+ * @error componentfactory-item-exists
|
|
|
+ * @param {String} name The name of the component.
|
|
|
+ */
|
|
|
throw new CKEditorError(
|
|
|
'componentfactory-item-exists: The item already exists in the component factory.', { name }
|
|
|
);
|
|
|
@@ -68,6 +74,20 @@ export default class ComponentFactory {
|
|
|
* @returns {module:ui/view~View} The instantiated component view.
|
|
|
*/
|
|
|
create( name ) {
|
|
|
- return this._components.get( name )( this.editor.locale );
|
|
|
+ const component = this._components.get( name );
|
|
|
+
|
|
|
+ if ( !component ) {
|
|
|
+ /**
|
|
|
+ * There is no such UI component in the factory.
|
|
|
+ *
|
|
|
+ * @error componentfactory-item-missing
|
|
|
+ * @param {String} name The name of the missing component.
|
|
|
+ */
|
|
|
+ throw new CKEditorError(
|
|
|
+ 'componentfactory-item-missing: There is no such UI component in the factory.', { name }
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ return component( this.editor.locale );
|
|
|
}
|
|
|
}
|