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

Commit

Permalink
Merge pull request #808 from deckgo/clean-slide-slots
Browse files Browse the repository at this point in the history
fix: missing clean footer and header and correct regexp
  • Loading branch information
peterpeterparker authored Jul 23, 2020
2 parents 39f0ab8 + 2b7d80c commit d89d865
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions studio/src/app/handlers/editor/events/deck/deck-events.handler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -767,14 +767,23 @@ export class DeckEventsHandler {

let result: string = await cleanContent(content);

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

resolve(result);
});
}

private async cleanSlideCustomSlots(slide: HTMLElement, content: string, customAttribute: 'background' | 'header' | 'footer'): Promise<string> {
if (!slide.hasAttribute(`custom-${customAttribute}`)) {
const regex: RegExp = new RegExp(`<div slot="${customAttribute}"(.*?)<\/div>`, 'g');
content = content.replace(regex, '');
}

return content;
}

private filterSlideContentSlots(slide: HTMLElement): Promise<string> {
return new Promise<string>((resolve) => {
if (!slide || !document) {
Expand Down

0 comments on commit d89d865

Please sign in to comment.