Просмотр исходного кода

apply isEnabledLinebreaksInComments

kaori 3 лет назад
Родитель
Сommit
9d03d22a65

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

@@ -542,8 +542,6 @@ function injectServerConfigurations(context: GetServerSidePropsContext, props: P
   props.isAllReplyShown = configManager.getConfig('crowi', 'customize:isAllReplyShown');
   props.isAllReplyShown = configManager.getConfig('crowi', 'customize:isAllReplyShown');
   props.isContainerFluid = configManager.getConfig('crowi', 'customize:isContainerFluid');
   props.isContainerFluid = configManager.getConfig('crowi', 'customize:isContainerFluid');
   props.isEnabledStaleNotification = configManager.getConfig('crowi', 'customize:isEnabledStaleNotification');
   props.isEnabledStaleNotification = configManager.getConfig('crowi', 'customize:isEnabledStaleNotification');
-  // props.isEnabledLinebreaks = configManager.getConfig('markdown', 'markdown:isEnabledLinebreaks');
-  // props.isEnabledLinebreaksInComments = configManager.getConfig('markdown', 'markdown:isEnabledLinebreaksInComments');
   props.disableLinkSharing = configManager.getConfig('crowi', 'security:disableLinkSharing');
   props.disableLinkSharing = configManager.getConfig('crowi', 'security:disableLinkSharing');
   props.editorConfig = {
   props.editorConfig = {
     upload: {
     upload: {

+ 10 - 2
packages/app/src/services/renderer/renderer.tsx

@@ -208,7 +208,12 @@ export const generateTocOptions = (config: RendererConfig, tocNode: HtmlElementN
   return options;
   return options;
 };
 };
 
 
-export const generateSimpleViewOptions = (config: RendererConfig, pagePath: string, highlightKeywords?: string | string[]): RendererOptions => {
+export const generateSimpleViewOptions = (
+    config: RendererConfig,
+    pagePath: string,
+    highlightKeywords?: string | string[],
+    overrideIsEnabledLinebreaks?: boolean,
+): RendererOptions => {
   const options = generateCommonOptions(pagePath);
   const options = generateCommonOptions(pagePath);
 
 
   const { remarkPlugins, rehypePlugins, components } = options;
   const { remarkPlugins, rehypePlugins, components } = options;
@@ -222,7 +227,10 @@ export const generateSimpleViewOptions = (config: RendererConfig, pagePath: stri
     lsxGrowiPlugin.remarkPlugin,
     lsxGrowiPlugin.remarkPlugin,
     table.remarkPlugin,
     table.remarkPlugin,
   );
   );
-  if (config.isEnabledLinebreaks) {
+
+  const isEnabledLinebreaks = overrideIsEnabledLinebreaks ?? config.isEnabledLinebreaks;
+
+  if (isEnabledLinebreaks) {
     remarkPlugins.push(breaks);
     remarkPlugins.push(breaks);
   }
   }
 
 

+ 12 - 2
packages/app/src/stores/renderer.tsx

@@ -92,9 +92,19 @@ export const useCommentForCurrentPageOptions = (): SWRResponse<RendererOptions,
 
 
   return useSWRImmutable<RendererOptions, Error>(
   return useSWRImmutable<RendererOptions, Error>(
     key,
     key,
-    (rendererId, rendererConfig, currentPagePath) => generateSimpleViewOptions(rendererConfig, currentPagePath),
+    (rendererId, rendererConfig, currentPagePath) => generateSimpleViewOptions(
+      rendererConfig,
+      currentPagePath,
+      undefined,
+      rendererConfig.isEnabledLinebreaksInComments,
+    ),
     {
     {
-      fallbackData: isAllDataValid ? generateSimpleViewOptions(rendererConfig, currentPagePath) : undefined,
+      fallbackData: isAllDataValid ? generateSimpleViewOptions(
+        rendererConfig,
+        currentPagePath,
+        undefined,
+        rendererConfig.isEnabledLinebreaksInComments,
+      ) : undefined,
     },
     },
   );
   );
 };
 };