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

Commit 56c8217

Browse files
feat: move slides title method and fix case where user add something else than text in a title
1 parent c5a79cd commit 56c8217

File tree

3 files changed

+48
-50
lines changed

3 files changed

+48
-50
lines changed

studio/src/app/modals/editor/app-slide-navigate/app-slide-navigate.tsx

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component, Listen, Element, Prop, h} from '@stencil/core';
1+
import {Component, Listen, Element, State, h} from '@stencil/core';
22

33
@Component({
44
tag: 'app-slide-navigate',
@@ -8,11 +8,13 @@ export class AppSlideNavigate {
88

99
@Element() el: HTMLElement;
1010

11-
@Prop()
11+
@State()
1212
slides: string[];
1313

1414
async componentDidLoad() {
1515
history.pushState({modal: true}, null);
16+
17+
this.slides = await this.getSlidesTitle();
1618
}
1719

1820
@Listen('popstate', { target: 'window' })
@@ -28,6 +30,47 @@ export class AppSlideNavigate {
2830
await (this.el.closest('ion-modal') as HTMLIonModalElement).dismiss(index);
2931
}
3032

33+
private getSlidesTitle(): Promise<string[]> {
34+
return new Promise<string[]>((resolve) => {
35+
if (!document) {
36+
resolve();
37+
return;
38+
}
39+
40+
const results: string[] = [];
41+
42+
const slides: NodeListOf<HTMLElement> = document.querySelectorAll('deckgo-deck > *');
43+
44+
if (slides) {
45+
for (const slide of Array.from(slides)) {
46+
if (slide.tagName && slide.tagName.toLowerCase().indexOf('deckgo-slide') > -1) {
47+
const title: HTMLElement = slide.querySelector('[slot="title"]');
48+
49+
if (title) {
50+
results.push(title.textContent);
51+
} else {
52+
const start: HTMLElement = slide.querySelector('[slot="start"]');
53+
54+
if (start) {
55+
results.push(start.textContent);
56+
} else {
57+
const end: HTMLElement = slide.querySelector('[slot="end"]');
58+
59+
if (end) {
60+
results.push(end.textContent);
61+
} else {
62+
results.push('');
63+
}
64+
}
65+
}
66+
}
67+
}
68+
}
69+
70+
resolve(results);
71+
});
72+
}
73+
3174
render() {
3275
return [
3376
<ion-header>

studio/src/app/pages/editor/app-editor/app-editor.tsx

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,8 @@ export class AppEditor {
265265
}
266266

267267
private async openSlideNavigate() {
268-
const slidesTitle: string[] = await this.getSlidesTitle();
269-
270268
const modal: HTMLIonModalElement = await IonControllerUtils.createModal({
271-
component: 'app-slide-navigate',
272-
componentProps: {
273-
slides: slidesTitle
274-
}
269+
component: 'app-slide-navigate'
275270
});
276271

277272
modal.onDidDismiss().then(async (detail: OverlayEventDetail) => {
@@ -291,42 +286,6 @@ export class AppEditor {
291286
await modal.present();
292287
}
293288

294-
private getSlidesTitle(): Promise<string[]> {
295-
return new Promise<string[]>((resolve) => {
296-
const results: string[] = [];
297-
298-
const slides: NodeListOf<HTMLElement> = this.el.querySelectorAll('deckgo-deck > *');
299-
300-
if (slides) {
301-
for (const slide of Array.from(slides)) {
302-
if (slide.tagName && slide.tagName.toLowerCase().indexOf('deckgo-slide') > -1) {
303-
const title: HTMLElement = slide.querySelector('[slot="title"]');
304-
305-
if (title) {
306-
results.push(title.innerHTML);
307-
} else {
308-
const start: HTMLElement = slide.querySelector('[slot="start"]');
309-
310-
if (start) {
311-
results.push(start.textContent);
312-
} else {
313-
const end: HTMLElement = slide.querySelector('[slot="end"]');
314-
315-
if (end) {
316-
results.push(end.textContent);
317-
} else {
318-
results.push('');
319-
}
320-
}
321-
}
322-
}
323-
}
324-
}
325-
326-
resolve(results);
327-
});
328-
}
329-
330289
private getFirstSlideContent(): Promise<string> {
331290
return new Promise<string>(async (resolve) => {
332291
let content: string = '';

studio/src/components.d.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ export namespace Components {
8888
'redirect': string;
8989
'redirectId': string;
9090
}
91-
interface AppSlideNavigate {
92-
'slides': string[];
93-
}
91+
interface AppSlideNavigate {}
9492
interface AppSlideType {}
9593
interface AppSlotType {
9694
'selectedElement': HTMLElement;
@@ -489,9 +487,7 @@ declare namespace LocalJSX {
489487
'redirect'?: string;
490488
'redirectId'?: string;
491489
}
492-
interface AppSlideNavigate extends JSXBase.HTMLAttributes<HTMLAppSlideNavigateElement> {
493-
'slides'?: string[];
494-
}
490+
interface AppSlideNavigate extends JSXBase.HTMLAttributes<HTMLAppSlideNavigateElement> {}
495491
interface AppSlideType extends JSXBase.HTMLAttributes<HTMLAppSlideTypeElement> {}
496492
interface AppSlotType extends JSXBase.HTMLAttributes<HTMLAppSlotTypeElement> {
497493
'selectedElement'?: HTMLElement;

0 commit comments

Comments
 (0)