|
|
@@ -7,7 +7,7 @@ import {
|
|
|
IDataWithMeta, IPageInfoForEntity, IPagePopulatedToShowRevision, isClient, isIPageInfoForEntity, isServer, IUser, IUserHasId, pagePathUtils, pathUtils,
|
|
|
} from '@growi/core';
|
|
|
import ExtensibleCustomError from 'extensible-custom-error';
|
|
|
-import mongoose from 'mongoose';
|
|
|
+import { model as mongooseModel } from 'mongoose';
|
|
|
import {
|
|
|
NextPage, GetServerSideProps, GetServerSidePropsContext,
|
|
|
} from 'next';
|
|
|
@@ -20,7 +20,7 @@ import superjson from 'superjson';
|
|
|
import { PageAlerts } from '~/components/PageAlert/PageAlerts';
|
|
|
import { PageComment } from '~/components/PageComment';
|
|
|
// import { useTranslation } from '~/i18n';
|
|
|
-import CommentEditorLazyRenderer from '~/components/PageComment/CommentEditorLazyRenderer';
|
|
|
+// import CommentEditorLazyRenderer from '~/components/PageComment/CommentEditorLazyRenderer';
|
|
|
import { CrowiRequest } from '~/interfaces/crowi-request';
|
|
|
// import { renderScriptTagByName, renderHighlightJsStyleTag } from '~/service/cdn-resources-loader';
|
|
|
// import { useIndentSize } from '~/stores/editor';
|
|
|
@@ -32,8 +32,7 @@ import { ISidebarConfig } from '~/interfaces/sidebar-config';
|
|
|
import { IUserUISettings } from '~/interfaces/user-ui-settings';
|
|
|
import { PageModel, PageDocument } from '~/server/models/page';
|
|
|
import { PageRedirectModel } from '~/server/models/page-redirect';
|
|
|
-import UserUISettings from '~/server/models/user-ui-settings';
|
|
|
-import Xss from '~/services/xss';
|
|
|
+import { UserUISettingsModel } from '~/server/models/user-ui-settings';
|
|
|
import { useSWRxCurrentPage, useSWRxIsGrantNormalized, useSWRxPageInfo } from '~/stores/page';
|
|
|
import {
|
|
|
usePreferDrawerModeByUser, usePreferDrawerModeOnEditByUser, useSidebarCollapsed, useCurrentSidebarContents, useCurrentProductNavWidth, useSelectedGrant,
|
|
|
@@ -45,10 +44,8 @@ import loggerFactory from '~/utils/logger';
|
|
|
// import GrowiSubNavigation from '../client/js/components/Navbar/GrowiSubNavigation';
|
|
|
// import GrowiSubNavigationSwitcher from '../client/js/components/Navbar/GrowiSubNavigationSwitcher';
|
|
|
import { DescendantsPageListModal } from '../components/DescendantsPageListModal';
|
|
|
-import ForbiddenPage from '../components/ForbiddenPage';
|
|
|
import { BasicLayout } from '../components/Layout/BasicLayout';
|
|
|
import GrowiContextualSubNavigation from '../components/Navbar/GrowiContextualSubNavigation';
|
|
|
-import { NotCreatablePage } from '../components/NotCreatablePage';
|
|
|
import DisplaySwitcher from '../components/Page/DisplaySwitcher';
|
|
|
// import { serializeUserSecurely } from '../server/models/serializers/user-serializer';
|
|
|
// import PageStatusAlert from '../client/js/components/PageStatusAlert';
|
|
|
@@ -63,7 +60,6 @@ import {
|
|
|
useCsrfToken, useIsSearchScopeChildrenAsDefault, useCurrentPageId, useCurrentPathname,
|
|
|
useIsSlackConfigured, useIsBlinkedHeaderAtBoot, useRendererConfig, useEditingMarkdown,
|
|
|
} from '../stores/context';
|
|
|
-import { useXss } from '../stores/xss';
|
|
|
|
|
|
import {
|
|
|
CommonProps, getNextI18NextConfig, getServerSideCommonProps, useCustomTitle,
|
|
|
@@ -167,6 +163,8 @@ const GrowiPage: NextPage<Props> = (props: Props) => {
|
|
|
// const { t } = useTranslation();
|
|
|
const router = useRouter();
|
|
|
|
|
|
+ const NotCreatablePage = dynamic(() => import('../components/NotCreatablePage').then(mod => mod.NotCreatablePage), { ssr: false });
|
|
|
+ const ForbiddenPage = dynamic(() => import('../components/ForbiddenPage'), { ssr: false });
|
|
|
const UnsavedAlertDialog = dynamic(() => import('./UnsavedAlertDialog'), { ssr: false });
|
|
|
const GrowiSubNavigationSwitcher = dynamic(() => import('../components/Navbar/GrowiSubNavigationSwitcher'), { ssr: false });
|
|
|
|
|
|
@@ -178,7 +176,6 @@ const GrowiPage: NextPage<Props> = (props: Props) => {
|
|
|
}
|
|
|
|
|
|
// commons
|
|
|
- useXss(new Xss());
|
|
|
// useEditorConfig(props.editorConfig);
|
|
|
useCsrfToken(props.csrfToken);
|
|
|
|
|
|
@@ -359,7 +356,7 @@ async function injectPageData(context: GetServerSidePropsContext, props: Props):
|
|
|
const { revisionId } = req.query;
|
|
|
|
|
|
const Page = crowi.model('Page') as PageModel;
|
|
|
- const PageRedirect = mongoose.model('PageRedirect') as PageRedirectModel;
|
|
|
+ const PageRedirect = mongooseModel('PageRedirect') as PageRedirectModel;
|
|
|
const { pageService } = crowi;
|
|
|
|
|
|
let currentPathname = props.currentPathname;
|
|
|
@@ -403,6 +400,7 @@ async function injectPageData(context: GetServerSidePropsContext, props: Props):
|
|
|
async function injectUserUISettings(context: GetServerSidePropsContext, props: Props): Promise<void> {
|
|
|
const req = context.req as CrowiRequest<IUserHasId & any>;
|
|
|
const { user } = req;
|
|
|
+ const UserUISettings = mongooseModel('UserUISettings') as UserUISettingsModel;
|
|
|
|
|
|
const userUISettings = user == null ? null : await UserUISettings.findOne({ user: user._id }).exec();
|
|
|
if (userUISettings != null) {
|