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

presentation slide has no shadow

reiji-h 2 лет назад
Родитель
Сommit
d6e1ea74d6

+ 8 - 5
packages/presentation/src/components/GrowiSlides.tsx

@@ -5,23 +5,26 @@ import { ReactMarkdown } from 'react-markdown/lib/react-markdown';
 import type { PresentationOptions } from '../consts';
 import type { PresentationOptions } from '../consts';
 import * as extractSections from '../services/renderer/extract-sections';
 import * as extractSections from '../services/renderer/extract-sections';
 
 
-import { RichSlideSection } from './RichSlideSection';
 
 
 import './Slides.global.scss';
 import './Slides.global.scss';
+import { PresentationRichSlideSection, RichSlideSection } from './RichSlideSection';
 
 
 type Props = {
 type Props = {
   options: PresentationOptions,
   options: PresentationOptions,
   children?: string,
   children?: string,
   marpit: Marp,
   marpit: Marp,
+  presentation?: boolean,
 }
 }
 
 
 export const GrowiSlides = (props: Props): JSX.Element => {
 export const GrowiSlides = (props: Props): JSX.Element => {
-  const { options, children, marpit } = props;
+  const {
+    options, children, marpit, presentation,
+  } = props;
   const {
   const {
     rendererOptions, isDarkMode, disableSeparationByHeader,
     rendererOptions, isDarkMode, disableSeparationByHeader,
   } = options;
   } = options;
 
 
-  if (rendererOptions.remarkPlugins != null) {
+  if (rendererOptions?.remarkPlugins != null) {
     rendererOptions.remarkPlugins.push([
     rendererOptions.remarkPlugins.push([
       extractSections.remarkPlugin,
       extractSections.remarkPlugin,
       {
       {
@@ -31,8 +34,8 @@ export const GrowiSlides = (props: Props): JSX.Element => {
     ]);
     ]);
   }
   }
 
 
-  if (rendererOptions.components != null) {
-    rendererOptions.components.section = RichSlideSection;
+  if (rendererOptions?.components != null) {
+    rendererOptions.components.section = presentation ? PresentationRichSlideSection : RichSlideSection;
   }
   }
 
 
   const { css } = marpit.render('', { htmlAsArray: true });
   const { css } = marpit.render('', { htmlAsArray: true });

+ 1 - 1
packages/presentation/src/components/Presentation.tsx

@@ -59,7 +59,7 @@ export const Presentation = (props: PresentationProps): JSX.Element => {
 
 
   return (
   return (
     <div className={`grw-presentation ${styles['grw-presentation']} reveal`}>
     <div className={`grw-presentation ${styles['grw-presentation']} reveal`}>
-      <Slides options={options}>{children}</Slides>
+      <Slides options={options} presentation>{children}</Slides>
     </div>
     </div>
   );
   );
 };
 };

+ 25 - 3
packages/presentation/src/components/RichSlideSection.tsx

@@ -2,13 +2,14 @@ import React, { ReactNode } from 'react';
 
 
 type RichSlideSectionProps = {
 type RichSlideSectionProps = {
   children: ReactNode,
   children: ReactNode,
+  presentation?: boolean,
 }
 }
 
 
-export const RichSlideSection = React.memo((props: RichSlideSectionProps): JSX.Element => {
-  const { children } = props;
+const OriginalRichSlideSection = React.memo((props: RichSlideSectionProps): JSX.Element => {
+  const { children, presentation } = props;
 
 
   return (
   return (
-    <section className="shadow rounded m-2">
+    <section className={presentation ? 'm-2' : 'shadow rounded m-2'}>
       <svg data-marpit-svg="" viewBox="0 0 1280 720">
       <svg data-marpit-svg="" viewBox="0 0 1280 720">
         <foreignObject width="1280" height="720">
         <foreignObject width="1280" height="720">
           <section>
           <section>
@@ -19,3 +20,24 @@ export const RichSlideSection = React.memo((props: RichSlideSectionProps): JSX.E
     </section>
     </section>
   );
   );
 });
 });
+
+export const RichSlideSection = React.memo((props: RichSlideSectionProps): JSX.Element => {
+  const { children } = props;
+
+  return (
+    <OriginalRichSlideSection>
+      {children}
+    </OriginalRichSlideSection>
+  );
+});
+
+
+export const PresentationRichSlideSection = React.memo((props: RichSlideSectionProps): JSX.Element => {
+  const { children } = props;
+
+  return (
+    <OriginalRichSlideSection presentation>
+      {children}
+    </OriginalRichSlideSection>
+  );
+});

+ 19 - 3
packages/presentation/src/components/Slides.tsx

@@ -23,21 +23,37 @@ const marpit = new Marp({
   math: false,
   math: false,
 });
 });
 
 
+const presentationMarpit = new Marp({
+  container: [
+    new Element('div', { class: `slides ${MARP_CONTAINER_CLASS_NAME}` }),
+  ],
+  slideContainer: [
+    new Element('section', { class: 'm-2' }),
+  ],
+  inlineSVG: true,
+  emoji: undefined,
+  html: false,
+  math: false,
+});
+
 type Props = {
 type Props = {
   options: PresentationOptions,
   options: PresentationOptions,
   children?: string,
   children?: string,
   hasMarpFlag?: boolean,
   hasMarpFlag?: boolean,
+  presentation?: boolean,
 }
 }
 
 
 export const Slides = (props: Props): JSX.Element => {
 export const Slides = (props: Props): JSX.Element => {
-  const { options, children, hasMarpFlag } = props;
+  const {
+    options, children, hasMarpFlag, presentation,
+  } = props;
 
 
   if (hasMarpFlag) {
   if (hasMarpFlag) {
-    return <MarpSlides marpit={marpit}>{children}</MarpSlides>;
+    return <MarpSlides marpit={presentation ? presentationMarpit : marpit}>{children}</MarpSlides>;
   }
   }
   return (
   return (
     <div className={`slides ${MARP_CONTAINER_CLASS_NAME}`}>
     <div className={`slides ${MARP_CONTAINER_CLASS_NAME}`}>
-      <GrowiSlides options={options} marpit={marpit}>{children}</GrowiSlides>
+      <GrowiSlides options={options} marpit={presentation ? presentationMarpit : marpit} presentation={presentation}>{children}</GrowiSlides>
     </div>
     </div>
   );
   );
 };
 };