Explorar o código

test new components

reiji-h %!s(int64=2) %!d(string=hai) anos
pai
achega
84d04bf986

+ 21 - 0
packages/presentation/src/components/RichSlideSection.tsx

@@ -0,0 +1,21 @@
+
+import React, { ReactNode } from 'react';
+
+
+type RichSlideSectionProps = {
+  children: ReactNode,
+}
+
+export const RichSlideSection = React.memo((props: RichSlideSectionProps): JSX.Element => {
+  const { children } = props;
+
+  return (
+    <section className="shadow rounded m-2">
+      <svg viewBox="0 0 1280 720">
+        <foreignObject width="1280" height="720">
+          {children}
+        </foreignObject>
+      </svg>
+    </section>
+  );
+});

+ 7 - 25
packages/presentation/src/components/Slides.tsx

@@ -8,6 +8,8 @@ import { ReactMarkdown } from 'react-markdown/lib/react-markdown';
 import type { PresentationOptions } from '../consts';
 import * as extractSections from '../services/renderer/extract-sections';
 
+import { RichSlideSection } from './RichSlideSection';
+
 import './Slides.global.scss';
 
 export const MARP_CONTAINER_CLASS_NAME = 'marpit';
@@ -19,7 +21,7 @@ const marpSlide = new Marp({
     new Element('div', { class: 'slides' }),
   ],
   slideContainer: [
-    new Element('div', { class: 'shadow rounded', style: 'margin: 20px' }),
+    new Element('section', { class: 'shadow rounded m-2' }),
   ],
   inlineSVG: true,
   emoji: undefined,
@@ -27,29 +29,6 @@ const marpSlide = new Marp({
   math: false,
 });
 
-// TODO: to change better slide style
-// https://redmine.weseek.co.jp/issues/125680
-const marp = new Marp({
-  container: [
-    new Element('div', { class: MARP_CONTAINER_CLASS_NAME }),
-    new Element('div', { class: 'slides' }),
-  ],
-  inlineSVG: false,
-  emoji: undefined,
-  html: false,
-  math: false,
-});
-const marpSlideTheme = marp.themeSet.add(`
-    /*!
-     * @theme slide_preview
-     */
-    section {
-      max-width: 90%;
-    }
-`);
-marp.themeSet.default = marpSlideTheme;
-
-
 type Props = {
   options: PresentationOptions,
   children?: string,
@@ -87,8 +66,11 @@ export const Slides = (props: Props): JSX.Element => {
       disableSeparationByHeader,
     },
   ]);
+  if (rendererOptions.components != null) {
+    // rendererOptions.components.section = RichSlideSection;
+  }
 
-  const { css } = marp.render('', { htmlAsArray: true });
+  const { css } = marpSlide.render('', { htmlAsArray: true });
   return (
     <>
       <Head>

+ 1 - 1
packages/presentation/src/services/renderer/extract-sections.ts

@@ -18,13 +18,13 @@ function wrapWithSection(parentNode: Parent, startElem: Node, endElem: Node | nu
 
   const section = {
     type: 'section',
-    children: between,
     data: {
       hName: 'section',
       hProperties: {
         className: isDarkMode ? 'invert' : '',
       },
     },
+    children: between,
   };
 
   siblings.splice(startIndex, between.length, section);