Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise(async (resolve) => {
if (!document) {
resolve();
return;
}
// Create a div to parse back to JSX its children
const div = document.createElement('div');
div.innerHTML = slide.data.content;
const content = await ParseElementsUtils.parseElements(div, true, contentEditable);
const attributes = {
style: slide.data.attributes ? await convertStyle(slide.data.attributes.style) : undefined,
src: slide.data.attributes && slide.data.attributes.src ? slide.data.attributes.src : undefined,
'custom-background': slide.data.attributes && slide.data.attributes.customBackground ? slide.data.attributes.customBackground : undefined,
'img-src': slide.data.attributes && slide.data.attributes.imgSrc ? slide.data.attributes.imgSrc : undefined,
'img-alt': slide.data.attributes && slide.data.attributes.imgAlt ? slide.data.attributes.imgAlt : undefined
};
if (slide.data.template === SlideTemplate.QRCODE) {
attributes['content'] = slide.data.attributes && slide.data.attributes.content ? slide.data.attributes.content : QRCodeUtils.getPresentationUrl(deck);
attributes['custom-qrcode'] = slide.data.attributes && slide.data.attributes.content ? 'true' : undefined;
}
if (slide.data.template === SlideTemplate.CHART) {
attributes['type'] = slide.data.attributes && slide.data.attributes.type ? slide.data.attributes.type : undefined;
attributes['inner-radius'] = slide.data.attributes && slide.data.attributes.innerRadius ? slide.data.attributes.innerRadius : undefined;
attributes['animation'] = slide.data.attributes && slide.data.attributes.animation ? slide.data.attributes.animation : undefined;
attributes['date-pattern'] = slide.data.attributes && slide.data.attributes.datePattern ? slide.data.attributes.datePattern : undefined;
this.deckEditorService.watch().pipe(take(1)).subscribe(async (deck: Deck) => {
if (deck && deck.data && deck.data.attributes && deck.data.attributes.style) {
this.style = await convertStyle(deck.data.attributes.style);
} else {
this.style = undefined;
}
if (deck && deck.data && deck.data.attributes && deck.data.attributes.transition) {
this.transition = deck.data.attributes.transition;
}
this.background = await ParseBackgroundUtils.convertBackground(deck.data.background, true);
resolve();
});
});
return new Promise(async (resolve) => {
const Elem: string = element.nodeName.toLowerCase();
const attributes: any = this.getAttributes(element);
if (attributes.style) {
attributes.style = await convertStyle(attributes.style);
}
if (contentEditable && this.isContentEditable(element, attributes)) {
if (contentEditable && SlotUtils.isNodeReveal(element) && element.firstElementChild) {
element.firstElementChild.setAttribute('contenteditable', `${true}`);
} else {
attributes['contenteditable'] = true;
}
}
resolve({content});
});
}
return new Promise(async (resolve) => {
const Elem: string = element.nodeName.toLowerCase();
const attributes: any = this.getAttributes(element);
if (attributes.style) {
attributes.style = await convertStyle(attributes.style);
}
resolve({content});
});
}
return new Promise(async (resolve) => {
const attr: any = {};
if (attributes && attributes.length > 0) {
for (const def of attributes) {
if (def.name === 'style') {
attr['style'] = await convertStyle(def.value);
} else {
attr[def.name] = def.value;
}
}
}
resolve(attr);
})
}
return new Promise(async (resolve) => {
try {
const slide: Slide = await this.slideService.get(deck.id, slideId);
const element: JSX.IntrinsicElements = await ParseSlidesUtils.parseSlide(deck, slide, false);
let style: any;
if (deck.data && deck.data.attributes && deck.data.attributes.style) {
style = await convertStyle(deck.data.attributes.style);
} else {
style = undefined;
}
const background: any = await ParseBackgroundUtils.convertBackground(deck.data.background, false);
resolve({
deck: deck,
slide: element,
style: style,
background: background
});
} catch (err) {
resolve(undefined);
}
});