Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

### Web Components

- core: v8.3.0 ([CHANGELOG](https://github.com/deckgo/deckdeckgo/blob/master/webcomponents/core/CHANGELOG.md))
- core: v8.4.0 ([CHANGELOG](https://github.com/deckgo/deckdeckgo/blob/master/webcomponents/core/CHANGELOG.md))
- highlight-code: v3.3.1 ([CHANGELOG](https://github.com/deckgo/deckdeckgo/blob/master/webcomponents/highlight-code/CHANGELOG.md))

### Others
Expand Down
6 changes: 3 additions & 3 deletions studio/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"dependencies": {
"@deckdeckgo/charts": "^2.1.0",
"@deckdeckgo/color": "^4.1.0",
"@deckdeckgo/core": "^8.3.0",
"@deckdeckgo/core": "^8.4.0",
"@deckdeckgo/deck-utils": "^4.1.0",
"@deckdeckgo/demo": "^2.1.0",
"@deckdeckgo/drag-resize-rotate": "^2.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,6 @@ export class DeckEventsHandler {
}
}

await this.deleteSlideElement();

busyStore.state.deckBusy = false;

resolve();
Expand All @@ -557,11 +555,6 @@ export class DeckEventsHandler {
});
}

private async deleteSlideElement() {
const deck: HTMLDeckgoDeckElement = this.mainRef.querySelector('deckgo-deck');
await deck?.deleteActiveSlide();
}

private async getSlideAttributes(slide: HTMLElement, cleanFields: boolean): Promise<SlideAttributes> {
if (SlideUtils.slideScope(slide) !== SlideScope.DEFAULT) {
return this.getSlideUserAttributes(slide);
Expand Down
12 changes: 12 additions & 0 deletions studio/src/app/pages/editor/app-editor/app-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ import {ChartEventsHandler} from '../../../handlers/core/events/chart/chart-even
import {SlideHelper} from '../../../helpers/editor/slide.helper';

import {SlotType} from '../../../types/editor/slot-type';

import {signIn as navigateSignIn} from '../../../utils/core/signin.utils';
import {SlideUtils} from '../../../utils/editor/slide.utils';

import {AuthService} from '../../../services/auth/auth.service';
import {AnonymousService} from '../../../services/editor/anonymous/anonymous.service';
Expand Down Expand Up @@ -380,6 +382,16 @@ export class AppEditor {
await this.replaceSlide($event.detail);
}

@Listen('slideDelete', {target: 'document'})
async deleteSlide({detail: deletedSlide}: CustomEvent<HTMLElement>) {
const slideIndex: number = SlideUtils.slideIndex(deletedSlide);

this.slides = [...this.slides.filter((_slide: JSX.IntrinsicElements, index: number) => slideIndex !== index)];

// Update deck length and slide to an active slide
await this.deckRef.deleteActiveSlide(false);
}

@Listen('addSlide', {target: 'document'})
async addSlide($event: CustomEvent<JSX.IntrinsicElements>) {
if (!$event) {
Expand Down
6 changes: 6 additions & 0 deletions webcomponents/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 8.4.0 (2021-08-19)

### Features

- `deleteActiveSlide` make removal of DOM child optional

# 8.3.0 (2021-08-19)

### Features
Expand Down
2 changes: 1 addition & 1 deletion webcomponents/core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion webcomponents/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@deckdeckgo/core",
"version": "8.3.0",
"version": "8.4.0",
"description": "Add a presentation to your web application using HTML and Web Components",
"main": "dist/index.cjs.js",
"module": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion webcomponents/core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export namespace Components {
"autoSlideInterval": number;
"blockSlide": (block: boolean) => Promise<void>;
"cloneBackground": boolean;
"deleteActiveSlide": () => Promise<void>;
"deleteActiveSlide": (removeChild?: boolean) => Promise<void>;
"direction": 'horizontal' | 'vertical' | 'papyrus';
"directionMobile": 'horizontal' | 'vertical' | 'papyrus';
"doPrint": () => Promise<void>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -957,19 +957,16 @@ export class DeckdeckgoDeck {
}

@Method()
async deleteActiveSlide() {
async deleteActiveSlide(removeChild: boolean = true) {
if (this.activeIndex > this.length || this.activeIndex < 0) {
return;
}

const slide: HTMLElement = this.el.querySelector('.deckgo-slide-container:nth-child(' + (this.activeIndex + 1) + ')');

if (!slide) {
return;
if (removeChild) {
const slide: HTMLElement | null = this.el.querySelector('.deckgo-slide-container:nth-child(' + (this.activeIndex + 1) + ')');
slide?.parentElement.removeChild(slide);
}

slide.parentElement.removeChild(slide);

this.activeIndex = this.activeIndex > 0 ? this.activeIndex - 1 : 0;
this.length = this.length > 0 ? this.length - 1 : 0;

Expand Down