|
|
@@ -1,10 +1,7 @@
|
|
|
-import loggerFactory from '~/utils/logger';
|
|
|
import { GrowiUriInjector } from './GrowiUriInjector';
|
|
|
import { GrowiUriInjectionModalDelegator } from './GrowiUriInjectionModalDelegator';
|
|
|
import { GrowiUriInjectionButtonDelegator } from './GrowiUriInjectionButtonDelegator';
|
|
|
|
|
|
-const logger = loggerFactory('growi-uri-injector:growiUriInjectorFactory');
|
|
|
-
|
|
|
export const DelegatorType = {
|
|
|
MODAL: 'modal',
|
|
|
BUTTON: 'button',
|
|
|
@@ -22,22 +19,8 @@ const TypeToDelegatorMappings:{[key in DelegatorType]:GrowiUriInjector} = {
|
|
|
*/
|
|
|
class GrowiUriInjectorFactory {
|
|
|
|
|
|
- delegator: GrowiUriInjector;
|
|
|
-
|
|
|
- initializeDelegator(type:DelegatorType) {
|
|
|
-
|
|
|
- this.delegator = TypeToDelegatorMappings[type];
|
|
|
-
|
|
|
- if (this.delegator == null) {
|
|
|
- logger.warn('Failed to initialize GrowiUriInjector delegator.');
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
getDelegator(type:DelegatorType) {
|
|
|
- if (this.delegator == null) {
|
|
|
- this.initializeDelegator(type);
|
|
|
- }
|
|
|
- return this.delegator;
|
|
|
+ return TypeToDelegatorMappings[type];
|
|
|
}
|
|
|
|
|
|
}
|