yuken 3 anni fa
parent
commit
f57f2232a7

+ 4 - 4
packages/app/src/components/PageAlert/PageGrantAlert.tsx

@@ -1,15 +1,15 @@
 import React from 'react';
 import { useSWRxCurrentPage } from '~/stores/page';
+import { useXss } from '~/stores/xss';
 import { useTranslation } from 'react-i18next';
-import Xss from '~/services/xss';
+
 
 export const PageGrantAlert = (): JSX.Element => {
   const { t } = useTranslation();
   const { data: pageData } = useSWRxCurrentPage();
+  const { data: xss } = useXss();
 
-  const xss = new Xss();
-
-  if ( pageData == null || pageData.grant == null || pageData.grant == 1 ) {
+  if ( pageData == null || pageData.grant == null || pageData.grant == 1 || xss == null) {
     return <></>
   }
 

+ 4 - 0
packages/app/src/pages/[[...path]].page.tsx

@@ -19,6 +19,7 @@ import { IPageWithMeta } from '~/interfaces/page';
 import { serializeUserSecurely } from '~/server/models/serializers/user-serializer';
 import { useSWRxCurrentPage, useSWRxPageInfo } from '~/stores/page';
 import loggerFactory from '~/utils/logger';
+import Xss from '~/services/xss';
 
 // import { isUserPage, isTrashPage, isSharedPage } from '~/utils/path-utils';
 
@@ -41,6 +42,8 @@ import {
   useCurrentPageId
 } from '../stores/context';
 
+import { useXss } from '../stores/xss'
+
 import { CommonProps, getServerSideCommonProps, useCustomTitle } from './commons';
 import { PageModel } from '~/server/models/page';
 import { isValidObjectId } from 'mongoose';
@@ -92,6 +95,7 @@ const GrowiPage: NextPage<Props> = (props: Props) => {
   // commons
   useAppTitle(props.appTitle);
   useSiteUrl(props.siteUrl);
+  useXss(new Xss())
   // useEditorConfig(props.editorConfig);
   useConfidential(props.confidential);
   useCsrfToken(props.csrfToken);

+ 8 - 0
packages/app/src/stores/xss.ts

@@ -0,0 +1,8 @@
+
+import { useStaticSWR } from './use-static-swr';
+import { SWRResponse } from 'swr';
+import Xss from '~/services/xss';
+
+export const useXss = (initialData?: Xss): SWRResponse<Xss, Error> => {
+  return useStaticSWR<Xss, Error>('xss', initialData);
+};