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

Commit ff26cd9

Browse files
feat: add slide gif
1 parent 2613346 commit ff26cd9

File tree

5 files changed

+91
-7
lines changed

5 files changed

+91
-7
lines changed

studio/src/app/components/editor/app-editor-toolbar/app-editor-toolbar.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {OverlayEventDetail} from '@ionic/core';
33

44
import {Subscription} from 'rxjs';
55

6-
import {EditorUtils, SlotType} from '../../../utils/editor-utils';
6+
import {SlotType} from '../../../utils/editor-utils';
77

88
import {DeckBusyService} from '../../../services/deck/deck-busy.service';
99

@@ -46,6 +46,8 @@ export class AppEditorToolbar {
4646
@State()
4747
private deckBusy: boolean = false;
4848

49+
private originalPlaceHolder: Node;
50+
4951
constructor() {
5052
this.deckBusyService = DeckBusyService.getInstance();
5153
}
@@ -135,7 +137,7 @@ export class AppEditorToolbar {
135137

136138
if (selected.classList && selected.classList.contains('deckgo-untouched')) {
137139
if (selected.firstChild) {
138-
selected.removeChild(selected.firstChild);
140+
this.originalPlaceHolder = selected.removeChild(selected.firstChild);
139141
}
140142

141143
selected.classList.remove('deckgo-untouched');
@@ -155,8 +157,8 @@ export class AppEditorToolbar {
155157
unSelect(): Promise<void> {
156158
return new Promise<void>(async (resolve) => {
157159
if (this.selectedElement) {
158-
if (this.selectedElement.classList && !this.selectedElement.classList.contains('deckgo-untouched') && !this.selectedElement.firstChild) {
159-
this.selectedElement.appendChild(document.createTextNode(this.selectedElement.nodeName && this.selectedElement.nodeName.toLowerCase() === 'h1' ? EditorUtils.DEFAULT_TITLE : EditorUtils.DEFAULT_CONTENT));
160+
if (this.originalPlaceHolder && this.selectedElement.classList && !this.selectedElement.classList.contains('deckgo-untouched') && !this.selectedElement.firstChild) {
161+
this.selectedElement.appendChild(this.originalPlaceHolder);
160162
this.selectedElement.classList.add('deckgo-untouched');
161163
}
162164

studio/src/app/modals/editor/app-gif/app-gif.scss

Whitespace-only changes.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import {Component, Element, Listen} from '@stencil/core';
2+
3+
@Component({
4+
tag: 'app-gif',
5+
styleUrl: 'app-gif.scss'
6+
})
7+
export class AppGif {
8+
9+
@Element() el: HTMLElement;
10+
11+
async componentDidLoad() {
12+
history.pushState({modal: true}, null);
13+
}
14+
15+
@Listen('window:popstate')
16+
async handleHardwareBackButton(_e: PopStateEvent) {
17+
await this.closeModal();
18+
}
19+
20+
async closeModal() {
21+
await (this.el.closest('ion-modal') as HTMLIonModalElement).dismiss();
22+
}
23+
24+
render() {
25+
return [
26+
<ion-header>
27+
<ion-toolbar color="primary">
28+
<ion-buttons slot="start">
29+
<ion-button onClick={() => this.closeModal()}>
30+
<ion-icon name="close"></ion-icon>
31+
</ion-button>
32+
</ion-buttons>
33+
<ion-title class="ion-text-uppercase">Ready to publish?</ion-title>
34+
</ion-toolbar>
35+
</ion-header>,
36+
<ion-content padding>
37+
Find cool Gifs
38+
</ion-content>
39+
];
40+
}
41+
42+
}

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

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ export enum SlotType {
99

1010
export class EditorUtils {
1111

12-
static DEFAULT_TITLE: string = 'Click to add title';
13-
static DEFAULT_CONTENT: string = 'Click to add content';
12+
private static DEFAULT_TITLE: string = 'Click to add title';
13+
private static DEFAULT_CONTENT: string = 'Click to add content';
14+
private static DEFAULT_CAPTION: string = 'Click to add a caption';
1415

1516
static createSlide(template: SlideTemplate): Promise<any> {
1617
return new Promise<any>(async (resolve) => {
@@ -25,6 +26,8 @@ export class EditorUtils {
2526
resolve(await this.createSlideContent());
2627
} else if (template === SlideTemplate.SPLIT) {
2728
resolve(await this.createSlideSplit());
29+
} else if (template === SlideTemplate.GIF) {
30+
resolve(await this.createSlideGif());
2831
} else {
2932
resolve(null);
3033
}
@@ -103,4 +106,28 @@ export class EditorUtils {
103106
});
104107
}
105108

109+
private static createSlideGif(): Promise<any> {
110+
return new Promise<any>((resolve) => {
111+
if (!document) {
112+
resolve();
113+
return;
114+
}
115+
116+
const title = <h1 slot="header" class="deckgo-untouched" contenteditable>
117+
{this.DEFAULT_CAPTION}
118+
</h1>;
119+
120+
const content = <h2 slot="footer" class="deckgo-untouched" contenteditable>
121+
{this.DEFAULT_CAPTION}
122+
</h2>;
123+
124+
const slide: any = <deckgo-slide-gif src="./assets/img/example.gif" fullscreen={true}>
125+
{title}
126+
{content}
127+
</deckgo-slide-gif>;
128+
129+
resolve(slide);
130+
});
131+
}
132+
106133
}

studio/src/components.d.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
import '@stencil/core';
99

1010
import '@ionic/core';
11+
import 'ionicons';
1112
import 'deckdeckgo';
1213
import 'deckdeckgo-inline-editor';
13-
import 'ionicons';
1414
import {
1515
EventEmitter,
1616
} from '@stencil/core';
@@ -119,6 +119,9 @@ export namespace Components {
119119
'publication'?: Date;
120120
}
121121

122+
interface AppGif {}
123+
interface AppGifAttributes extends StencilHTMLAttributes {}
124+
122125
interface AppPublish {
123126
'caption': string;
124127
'description': string;
@@ -195,6 +198,7 @@ declare global {
195198
'AppPopular': Components.AppPopular;
196199
'AppFeedCardContent': Components.AppFeedCardContent;
197200
'AppFeedCard': Components.AppFeedCard;
201+
'AppGif': Components.AppGif;
198202
'AppPublish': Components.AppPublish;
199203
'AppSlideNavigate': Components.AppSlideNavigate;
200204
'AppAbout': Components.AppAbout;
@@ -225,6 +229,7 @@ declare global {
225229
'app-popular': Components.AppPopularAttributes;
226230
'app-feed-card-content': Components.AppFeedCardContentAttributes;
227231
'app-feed-card': Components.AppFeedCardAttributes;
232+
'app-gif': Components.AppGifAttributes;
228233
'app-publish': Components.AppPublishAttributes;
229234
'app-slide-navigate': Components.AppSlideNavigateAttributes;
230235
'app-about': Components.AppAboutAttributes;
@@ -320,6 +325,12 @@ declare global {
320325
new (): HTMLAppFeedCardElement;
321326
};
322327

328+
interface HTMLAppGifElement extends Components.AppGif, HTMLStencilElement {}
329+
var HTMLAppGifElement: {
330+
prototype: HTMLAppGifElement;
331+
new (): HTMLAppGifElement;
332+
};
333+
323334
interface HTMLAppPublishElement extends Components.AppPublish, HTMLStencilElement {}
324335
var HTMLAppPublishElement: {
325336
prototype: HTMLAppPublishElement;
@@ -418,6 +429,7 @@ declare global {
418429
'app-popular': HTMLAppPopularElement
419430
'app-feed-card-content': HTMLAppFeedCardContentElement
420431
'app-feed-card': HTMLAppFeedCardElement
432+
'app-gif': HTMLAppGifElement
421433
'app-publish': HTMLAppPublishElement
422434
'app-slide-navigate': HTMLAppSlideNavigateElement
423435
'app-about': HTMLAppAboutElement
@@ -448,6 +460,7 @@ declare global {
448460
'app-popular': HTMLAppPopularElement;
449461
'app-feed-card-content': HTMLAppFeedCardContentElement;
450462
'app-feed-card': HTMLAppFeedCardElement;
463+
'app-gif': HTMLAppGifElement;
451464
'app-publish': HTMLAppPublishElement;
452465
'app-slide-navigate': HTMLAppSlideNavigateElement;
453466
'app-about': HTMLAppAboutElement;

0 commit comments

Comments
 (0)