Yuki Takei 3 лет назад
Родитель
Сommit
8b6703b8b1

+ 12 - 0
packages/app/src/client/services/activate-plugin.ts

@@ -0,0 +1,12 @@
+import { CustomWindow } from '~/interfaces/global';
+
+export class ActivatePluginService {
+
+  static activateAll(): void {
+    const { activators } = window as CustomWindow;
+    Object.entries(activators).forEach(([, activator]) => {
+      activator.activate();
+    });
+  }
+
+}

+ 10 - 4
packages/app/src/interfaces/global.ts

@@ -5,7 +5,13 @@ import { GrowiFacade } from '@growi/core';
 import { IGraphViewer } from './graph-viewer';
 
 export type CustomWindow = Window
-                         & typeof globalThis
-                         & { growiFacade: GrowiFacade }
-                         & { globalEmitter: EventEmitter }
-                         & { GraphViewer: IGraphViewer };
+                        & typeof globalThis
+                        & { activators: {
+                          [key: string]: {
+                            activate: () => void,
+                            deactivate: () => void,
+                          },
+                        } }
+                        & { growiFacade: GrowiFacade }
+                        & { globalEmitter: EventEmitter }
+                        & { GraphViewer: IGraphViewer };

+ 5 - 0
packages/app/src/pages/_app.page.tsx

@@ -11,6 +11,7 @@ import '~/styles/style-themes.scss';
 
 import * as nextI18nConfig from '^/config/next-i18next.config';
 
+import { ActivatePluginService } from '~/client/services/activate-plugin';
 import { NextThemesProvider } from '~/stores/use-next-themes';
 
 import { useI18nextHMR } from '../services/i18next-hmr';
@@ -37,6 +38,10 @@ function GrowiApp({ Component, pageProps }: GrowiAppProps): JSX.Element {
     import('bootstrap/dist/js/bootstrap');
   }, []);
 
+  useEffect(() => {
+    ActivatePluginService.activateAll();
+  }, []);
+
   const commonPageProps = pageProps as CommonProps;
   // useInterceptorManager(new InterceptorManager());
   useAppTitle(commonPageProps.appTitle);