Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit d89d865

Browse files
Merge pull request #808 from deckgo/clean-slide-slots
fix: missing clean footer and header and correct regexp
2 parents 39f0ab8 + 2b7d80c commit d89d865

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

studio/src/app/handlers/editor/events/deck/deck-events.handler.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -767,14 +767,23 @@ export class DeckEventsHandler {
767767

768768
let result: string = await cleanContent(content);
769769

770-
if (!slide.hasAttribute('custom-background')) {
771-
result = result.replace(/<div slot="background">(.*?)<\/div>/g, '');
772-
}
770+
result = await this.cleanSlideCustomSlots(slide, result, 'background');
771+
result = await this.cleanSlideCustomSlots(slide, result, 'header');
772+
result = await this.cleanSlideCustomSlots(slide, result, 'footer');
773773

774774
resolve(result);
775775
});
776776
}
777777

778+
private async cleanSlideCustomSlots(slide: HTMLElement, content: string, customAttribute: 'background' | 'header' | 'footer'): Promise<string> {
779+
if (!slide.hasAttribute(`custom-${customAttribute}`)) {
780+
const regex: RegExp = new RegExp(`<div slot="${customAttribute}"(.*?)<\/div>`, 'g');
781+
content = content.replace(regex, '');
782+
}
783+
784+
return content;
785+
}
786+
778787
private filterSlideContentSlots(slide: HTMLElement): Promise<string> {
779788
return new Promise<string>((resolve) => {
780789
if (!slide || !document) {

0 commit comments

Comments
 (0)