|
@@ -87,7 +87,7 @@ const logger = loggerFactory('growi:pages:all');
|
|
|
const {
|
|
const {
|
|
|
isPermalink: _isPermalink, isUsersHomePage, isTrashPage: _isTrashPage, isUserPage, isCreatablePage, isTopPage,
|
|
isPermalink: _isPermalink, isUsersHomePage, isTrashPage: _isTrashPage, isUserPage, isCreatablePage, isTopPage,
|
|
|
} = pagePathUtils;
|
|
} = pagePathUtils;
|
|
|
-const { removeHeadingSlash } = pathUtils;
|
|
|
|
|
|
|
+const { removeHeadingSlash, attachTitleHeader } = pathUtils;
|
|
|
|
|
|
|
|
type IPageToShowRevisionWithMeta = IDataWithMeta<IPagePopulatedToShowRevision & PageDocument, IPageInfoForEntity>;
|
|
type IPageToShowRevisionWithMeta = IDataWithMeta<IPagePopulatedToShowRevision & PageDocument, IPageInfoForEntity>;
|
|
|
type IPageToShowRevisionWithMetaSerialized = IDataWithMeta<string, string>;
|
|
type IPageToShowRevisionWithMetaSerialized = IDataWithMeta<string, string>;
|
|
@@ -163,6 +163,7 @@ type Props = CommonProps & {
|
|
|
isContainerFluid: boolean,
|
|
isContainerFluid: boolean,
|
|
|
editorConfig: EditorConfig,
|
|
editorConfig: EditorConfig,
|
|
|
isEnabledStaleNotification: boolean,
|
|
isEnabledStaleNotification: boolean,
|
|
|
|
|
+ isEnabledAttachTitleHeader: boolean,
|
|
|
// isEnabledLinebreaks: boolean,
|
|
// isEnabledLinebreaks: boolean,
|
|
|
// isEnabledLinebreaksInComments: boolean,
|
|
// isEnabledLinebreaksInComments: boolean,
|
|
|
adminPreferredIndentSize: number,
|
|
adminPreferredIndentSize: number,
|
|
@@ -251,7 +252,16 @@ const GrowiPage: NextPage<Props> = (props: Props) => {
|
|
|
useCurrentRevisionId(props.currentRevisionId);
|
|
useCurrentRevisionId(props.currentRevisionId);
|
|
|
|
|
|
|
|
const { data: currentPage } = useSWRxCurrentPage(undefined, pageWithMeta?.data ?? null); // store initial data
|
|
const { data: currentPage } = useSWRxCurrentPage(undefined, pageWithMeta?.data ?? null); // store initial data
|
|
|
- useEditingMarkdown(pageWithMeta?.data.revision?.body ?? props.templateBodyData ?? '');
|
|
|
|
|
|
|
+
|
|
|
|
|
+ let initialEditingMarkdown = '';
|
|
|
|
|
+ if (props.isEnabledAttachTitleHeader && pageWithMeta == null) {
|
|
|
|
|
+ initialEditingMarkdown += `${attachTitleHeader(props.currentPathname)}\n`;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (props.templateBodyData != null) {
|
|
|
|
|
+ initialEditingMarkdown += props.templateBodyData;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ useEditingMarkdown(pageWithMeta?.data.revision?.body ?? initialEditingMarkdown ?? '');
|
|
|
|
|
|
|
|
const { data: grantData } = useSWRxIsGrantNormalized(pageId);
|
|
const { data: grantData } = useSWRxIsGrantNormalized(pageId);
|
|
|
const { mutate: mutateSelectedGrant } = useSelectedGrant();
|
|
const { mutate: mutateSelectedGrant } = useSelectedGrant();
|
|
@@ -537,6 +547,8 @@ function injectServerConfigurations(context: GetServerSidePropsContext, props: P
|
|
|
props.adminPreferredIndentSize = configManager.getConfig('markdown', 'markdown:adminPreferredIndentSize');
|
|
props.adminPreferredIndentSize = configManager.getConfig('markdown', 'markdown:adminPreferredIndentSize');
|
|
|
props.isIndentSizeForced = configManager.getConfig('markdown', 'markdown:isIndentSizeForced');
|
|
props.isIndentSizeForced = configManager.getConfig('markdown', 'markdown:isIndentSizeForced');
|
|
|
|
|
|
|
|
|
|
+ props.isEnabledAttachTitleHeader = configManager.getConfig('crowi', 'customize:isEnabledAttachTitleHeader');
|
|
|
|
|
+
|
|
|
props.rendererConfig = {
|
|
props.rendererConfig = {
|
|
|
isEnabledLinebreaks: configManager.getConfig('markdown', 'markdown:isEnabledLinebreaks'),
|
|
isEnabledLinebreaks: configManager.getConfig('markdown', 'markdown:isEnabledLinebreaks'),
|
|
|
isEnabledLinebreaksInComments: configManager.getConfig('markdown', 'markdown:isEnabledLinebreaksInComments'),
|
|
isEnabledLinebreaksInComments: configManager.getConfig('markdown', 'markdown:isEnabledLinebreaksInComments'),
|