How to use @deckdeckgo/deck-utils - 10 common examples

To help you get started, we’ve selected a few @deckdeckgo/deck-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github deckgo / deckdeckgo / studio / src / app / utils / editor / parse-slides.utils.tsx View on Github external
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;
github deckgo / deckdeckgo / webcomponents / core / src / components / deck / deckdeckgo-deck / deckdeckgo-deck.tsx View on Github external
}

      const filteredSlides: HTMLElement[] = await this.getDefinedFilteredSlides();

      const definedSlidesLength: number = filteredSlides ? filteredSlides.length : 0;

      // Are all slides loaded?
      if (loadedSlides.length !== definedSlidesLength) {
        resolve(null);
        return;
      }

      const orderedSlidesTagNames: DeckdeckgoSlideDefinition[] = [];

      for (const slide of Array.from(loadedSlides)) {
        const attributes: DeckdeckgoAttributeDefinition[] = await getAttributesDefinition(slide.attributes);

        orderedSlidesTagNames.push({
          template: slide.tagName ? slide.tagName.toLowerCase() : undefined,
          content: slide.innerHTML,
          attributes: attributes
        });
      }

      const attributes: DeckdeckgoAttributeDefinition[] = await getAttributesDefinition(this.el.attributes);
      const background: HTMLElement = this.el.querySelector(':scope > [slot=\'background\']');

      const deck: DeckdeckgoDeckDefinition = {
        slides: orderedSlidesTagNames,
        attributes: attributes,
        background: background ? background.innerHTML : null,
        reveal: this.reveal,
github deckgo / deckdeckgo / studio / src / app / pages / editor / app-editor / app-editor.tsx View on Github external
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();
            });
        });
github deckgo / deckdeckgo / studio / src / app / utils / editor / parse-elements.utils.tsx View on Github external
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});
        });
    }
github deckgo / deckdeckgo / remote / src / app / utils / parse-elements.utils.tsx View on Github external
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});
        });
    }
github deckgo / deckdeckgo / remote / src / app / utils / parse-attributes.utils.tsx View on Github external
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);
        })
    }
github deckgo / deckdeckgo / studio / src / app / pages / core / app-dashboard / app-dashboard.tsx View on Github external
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);
            }
        });
github deckgo / deckdeckgo / studio / src / app / handlers / editor / events / deck / deck-events.handler.tsx View on Github external
return new Promise(async (resolve) => {
            const content: string = await this.filterSlideContentSlots(slide);

            if (!content || content.length <= 0) {
                resolve(content);
                return;
            }

            let result: string = await cleanContent(content);

            if (!slide.hasAttribute('custom-background')) {
                result = result.replace(/<div slot="background">(.*?)&lt;\/div&gt;/g, '');
            }

            resolve(result);
        });
    }</div>
github deckgo / deckdeckgo / remote / src / app / utils / parse-slides.utils.tsx View on Github external
return new Promise(async (resolve) =&gt; {
            if (!slide || !slide.content || slide.content === undefined || slide.content === '')  {
                resolve(undefined);
                return;
            }

            let result: string = await cleanContent(slide.content);

            const customBackground: boolean = await this.hasCustomBackground(slide);

            if (!customBackground) {
                result = result.replace(/<div slot="background">(.*?)&lt;\/div&gt;/g, '');
            }

            result = result.replace(/<a slot="actions">/g, '');
            result = result.replace(//g, '');

            resolve(result);
        });
    }</a></div>
github deckgo / deckdeckgo / webcomponents / core / src / components / deck / deckdeckgo-deck / deckdeckgo-deck.tsx View on Github external
return new Promise(async (resolve) =&gt; {
      const slide: HTMLElement = this.el.querySelector('.deckgo-slide-container:nth-child(' + (index + 1) + ')');

      const definition: DeckdeckgoSlideDefinition | null = await getSlideDefinition(slide);

      resolve(definition);
    });
  }

@deckdeckgo/deck-utils

Utils for the DeckDeckGo presentations

MIT
Latest version published 2 years ago

Package Health Score

51 / 100
Full package analysis