优化Presentation组件,支持添加背景
This commit is contained in:
parent
a86ddfcbe3
commit
06e9867d61
@ -28,6 +28,25 @@
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
/* 带背景的幻灯片文字颜色 */
|
||||
.reveal-container .reveal .slides section[data-background] {
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
.reveal-container .reveal .slides section[data-background] h1,
|
||||
.reveal-container .reveal .slides section[data-background] h2,
|
||||
.reveal-container .reveal .slides section[data-background] h3,
|
||||
.reveal-container .reveal .slides section[data-background] h4,
|
||||
.reveal-container .reveal .slides section[data-background] h5,
|
||||
.reveal-container .reveal .slides section[data-background] h6 {
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
.reveal-container .reveal .slides section[data-background] p,
|
||||
.reveal-container .reveal .slides section[data-background] li {
|
||||
color: rgba(255, 255, 255, 0.9) !important;
|
||||
}
|
||||
|
||||
.reveal-container .reveal .slides section h1,
|
||||
.reveal-container .reveal .slides section h2,
|
||||
.reveal-container .reveal .slides section h3,
|
||||
|
||||
@ -25,7 +25,7 @@ const REVEAL_CONFIG = {
|
||||
fragmentInURL: false,
|
||||
embedded: false,
|
||||
help: true,
|
||||
showNotes: false,
|
||||
showNotes: true,
|
||||
autoPlayMedia: null,
|
||||
preloadIframes: null,
|
||||
autoSlide: 0,
|
||||
@ -99,14 +99,24 @@ export default function Presentation({ data }) {
|
||||
const trimmedSection = section.trim();
|
||||
if (!trimmedSection) return '';
|
||||
|
||||
const htmlContent = marked(trimmedSection);
|
||||
// 检查是否有背景设置
|
||||
const backgroundMatch = trimmedSection.match(/<!-- \.slide: data-background="([^"]+)"[^>]* -->/);
|
||||
let backgroundAttr = '';
|
||||
let contentWithoutBackground = trimmedSection;
|
||||
|
||||
if (backgroundMatch) {
|
||||
backgroundAttr = ` data-background="${backgroundMatch[1]}"`;
|
||||
contentWithoutBackground = trimmedSection.replace(/<!-- \.slide: data-background="[^"]+"[^>]* -->/g, '');
|
||||
}
|
||||
|
||||
const htmlContent = marked(contentWithoutBackground);
|
||||
|
||||
// 如果是第一个幻灯片且没有标题,添加标题
|
||||
if (index === 0 && !htmlContent.includes('<h1>') && data.title) {
|
||||
return `<section><h1>${data.title}</h1>${htmlContent}</section>`;
|
||||
return `<section${backgroundAttr}><h1>${data.title}</h1>${htmlContent}</section>`;
|
||||
}
|
||||
|
||||
return `<section>${htmlContent}</section>`;
|
||||
return `<section${backgroundAttr}>${htmlContent}</section>`;
|
||||
}).join('');
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user