|
|
@@ -6,13 +6,14 @@ import Head from 'next/head';
|
|
|
|
|
|
import { BasicLayout } from '~/components/Layout/BasicLayout';
|
|
|
import { CrowiRequest } from '~/interfaces/crowi-request';
|
|
|
+import { RendererConfig } from '~/interfaces/services/renderer';
|
|
|
import { ISidebarConfig } from '~/interfaces/sidebar-config';
|
|
|
import { IUser, IUserHasId } from '~/interfaces/user';
|
|
|
import { IUserUISettings } from '~/interfaces/user-ui-settings';
|
|
|
import UserUISettings from '~/server/models/user-ui-settings';
|
|
|
import {
|
|
|
useCurrentUser,
|
|
|
- useIsSearchPage, useIsSearchScopeChildrenAsDefault, useIsSearchServiceConfigured, useIsSearchServiceReachable,
|
|
|
+ useIsSearchPage, useIsSearchScopeChildrenAsDefault, useIsSearchServiceConfigured, useIsSearchServiceReachable, useRendererConfig,
|
|
|
} from '~/stores/context';
|
|
|
import {
|
|
|
usePreferDrawerModeByUser, usePreferDrawerModeOnEditByUser, useSidebarCollapsed, useCurrentSidebarContents, useCurrentProductNavWidth,
|
|
|
@@ -33,6 +34,10 @@ type Props = CommonProps & {
|
|
|
userUISettings?: IUserUISettings
|
|
|
// Sidebar
|
|
|
sidebarConfig: ISidebarConfig,
|
|
|
+
|
|
|
+ // Render config
|
|
|
+ rendererConfig: RendererConfig,
|
|
|
+
|
|
|
};
|
|
|
|
|
|
const SearchPage: NextPage<Props> = (props: Props) => {
|
|
|
@@ -52,6 +57,9 @@ const SearchPage: NextPage<Props> = (props: Props) => {
|
|
|
useCurrentSidebarContents(userUISettings?.currentSidebarContents);
|
|
|
useCurrentProductNavWidth(userUISettings?.currentProductNavWidth);
|
|
|
|
|
|
+ // render config
|
|
|
+ useRendererConfig(props.rendererConfig);
|
|
|
+
|
|
|
const PutbackPageModal = (): JSX.Element => {
|
|
|
const PutbackPageModal = dynamic(() => import('../components/PutbackPageModal'), { ssr: false });
|
|
|
return <PutbackPageModal />;
|
|
|
@@ -87,6 +95,16 @@ const SearchPage: NextPage<Props> = (props: Props) => {
|
|
|
);
|
|
|
};
|
|
|
|
|
|
+async function injectUserUISettings(context: GetServerSidePropsContext, props: Props): Promise<void> {
|
|
|
+ const req = context.req as CrowiRequest<IUserHasId & any>;
|
|
|
+ const { user } = req;
|
|
|
+
|
|
|
+ const userUISettings = user == null ? null : await UserUISettings.findOne({ user: user._id }).exec();
|
|
|
+ if (userUISettings != null) {
|
|
|
+ props.userUISettings = userUISettings.toObject();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
function injectServerConfigurations(context: GetServerSidePropsContext, props: Props): void {
|
|
|
const req: CrowiRequest = context.req as CrowiRequest;
|
|
|
const { crowi } = req;
|
|
|
@@ -102,16 +120,22 @@ function injectServerConfigurations(context: GetServerSidePropsContext, props: P
|
|
|
isSidebarDrawerMode: configManager.getConfig('crowi', 'customize:isSidebarDrawerMode'),
|
|
|
isSidebarClosedAtDockMode: configManager.getConfig('crowi', 'customize:isSidebarClosedAtDockMode'),
|
|
|
};
|
|
|
-}
|
|
|
|
|
|
-async function injectUserUISettings(context: GetServerSidePropsContext, props: Props): Promise<void> {
|
|
|
- const req = context.req as CrowiRequest<IUserHasId & any>;
|
|
|
- const { user } = req;
|
|
|
+ props.rendererConfig = {
|
|
|
+ isEnabledLinebreaks: configManager.getConfig('markdown', 'markdown:isEnabledLinebreaks'),
|
|
|
+ isEnabledLinebreaksInComments: configManager.getConfig('markdown', 'markdown:isEnabledLinebreaksInComments'),
|
|
|
+ adminPreferredIndentSize: configManager.getConfig('markdown', 'markdown:adminPreferredIndentSize'),
|
|
|
+ isIndentSizeForced: configManager.getConfig('markdown', 'markdown:isIndentSizeForced'),
|
|
|
|
|
|
- const userUISettings = user == null ? null : await UserUISettings.findOne({ user: user._id }).exec();
|
|
|
- if (userUISettings != null) {
|
|
|
- props.userUISettings = userUISettings.toObject();
|
|
|
- }
|
|
|
+ plantumlUri: process.env.PLANTUML_URI ?? null,
|
|
|
+ blockdiagUri: process.env.BLOCKDIAG_URI ?? null,
|
|
|
+
|
|
|
+ // XSS Options
|
|
|
+ isEnabledXssPrevention: configManager.getConfig('markdown', 'markdown:xss:isEnabledPrevention'),
|
|
|
+ attrWhiteList: crowi.xssService.getAttrWhiteList(),
|
|
|
+ tagWhiteList: crowi.xssService.getTagWhiteList(),
|
|
|
+ highlightJsStyleBorder: crowi.configManager.getConfig('crowi', 'customize:highlightJsStyleBorder'),
|
|
|
+ };
|
|
|
}
|
|
|
|
|
|
export const getServerSideProps: GetServerSideProps = async(context: GetServerSidePropsContext) => {
|
|
|
@@ -134,7 +158,7 @@ export const getServerSideProps: GetServerSideProps = async(context: GetServerSi
|
|
|
|
|
|
await injectUserUISettings(context, props);
|
|
|
injectServerConfigurations(context, props);
|
|
|
-
|
|
|
+ console.log(props.rendererConfig);
|
|
|
return {
|
|
|
props,
|
|
|
};
|