Skip to content

Commit

Permalink
优化幻灯片组件,确保正确处理内容并添加类型注解
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuai2144 committed Dec 18, 2024
1 parent b52c6b2 commit 440e47e
Showing 1 changed file with 32 additions and 25 deletions.
57 changes: 32 additions & 25 deletions src/Slides/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MarkdownEditor } from '@ant-design/md-editor';
import { useEffect, useRef } from 'react';
import React, { useEffect, useRef } from 'react';
import Reveal from 'reveal.js';
import 'reveal.js/dist/reveal.css';
import './white.css';
Expand Down Expand Up @@ -39,30 +39,37 @@ export function Slides(props: { initValue: string }) {
}}
>
<div className="slides">
{props.initValue?.split('\n##').map((line, index) => {
let content = line;
if (!line?.startsWith('#') && index !== 0) {
content = `##` + content;
}
return (
<section key={index}>
<MarkdownEditor
readonly
toc={false}
reportMode
style={{ height: '100%', padding: 0, margin: 0, width: '100%' }}
contentStyle={{
width: '100%',
padding: 0,
margin: 0,
height: '100%',
overflow: 'hidden',
}}
initValue={content}
/>
</section>
);
})}
{
props.initValue?.split('\n##').map((line, index) => {
let content = line;
if (!line?.startsWith('#') && index !== 0) {
content = `##` + content;
}
return (
<section key={index}>
<MarkdownEditor
readonly
toc={false}
reportMode
style={{
height: '100%',
padding: 0,
margin: 0,
width: '100%',
}}
contentStyle={{
width: '100%',
padding: 0,
margin: 0,
height: '100%',
overflow: 'hidden',
}}
initValue={content}
/>
</section>
);
}) as React.ReactNode[]
}
</div>
</div>
);
Expand Down

0 comments on commit 440e47e

Please sign in to comment.