Skip to content

Commit 2f5e969

Browse files
committed
feature(wysiwyg): fix lint
1 parent df18403 commit 2f5e969

File tree

4 files changed

+47
-32
lines changed

4 files changed

+47
-32
lines changed

apps/codelab/src/app/admin/content/presentation-editor/reducer.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ export function reducer(
3535
getPresentation().slides.filter(({ id }) => id !== payload.id);
3636
return presentations;
3737
case 'deleteSlides':
38-
getPresentation().slides = getPresentation().slides.filter((slide, index) => !payload.selections.includes(index));
38+
getPresentation().slides = getPresentation().slides.filter(
39+
(slide, index) => !payload.selections.includes(index)
40+
);
3941

4042
return presentations;
4143
case 'reorderSlides':
@@ -58,14 +60,16 @@ export function reducer(
5860
const moveValues = normalizedIndexes.map(moveIndex => array[moveIndex]);
5961

6062
const dontMoveValues = array.filter(
61-
(item, index) => normalizedIndexes.indexOf(index) === -1,
63+
(item, index) => normalizedIndexes.indexOf(index) === -1
6264
);
6365

6466
dontMoveValues.splice(normalizedToIndex, 0, ...moveValues);
6567
return dontMoveValues;
6668
};
6769

68-
getPresentation().slides = [...arrayMoveByIndex(slides, selections, toIndex)];
70+
getPresentation().slides = [
71+
...arrayMoveByIndex(slides, selections, toIndex)
72+
];
6973

7074
return presentations;
7175

apps/codelab/src/app/admin/content/presentation-editor/side-panel/multi-selection.service.ts

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@ export function isShiftEvent(event: MouseEvent) {
1212

1313
@Injectable()
1414
export class MultiSelectionService {
15-
1615
public selections$ = new BehaviorSubject<number[]>([]);
1716
public selections: number[] = [];
1817

1918
public lastSingleSelection: number | null = null;
2019

21-
constructor() {
22-
}
20+
constructor() {}
2321

2422
isAlreadySelected(index: number): boolean {
2523
return this.selections.indexOf(index) >= 0;
@@ -45,51 +43,47 @@ export class MultiSelectionService {
4543
}
4644

4745
select(event: MouseEvent, selectedIndex: number) {
48-
const shiftSelect = isShiftEvent(event) &&
46+
const shiftSelect =
47+
isShiftEvent(event) &&
4948
(this.lastSingleSelection || this.lastSingleSelection === 0) &&
5049
this.lastSingleSelection !== selectedIndex;
5150

5251
if (this.isSelectionEmpty()) {
53-
5452
this.setSelections([selectedIndex]);
5553
this.lastSingleSelection = selectedIndex;
56-
5754
} else if (isCtrlEvent(event)) {
58-
5955
const alreadySelected = this.isAlreadySelected(selectedIndex);
6056

6157
if (alreadySelected) {
62-
const selectionsWithoutSelectedIndex = this.selections.filter((index) => index !== selectedIndex);
58+
const selectionsWithoutSelectedIndex = this.selections.filter(
59+
index => index !== selectedIndex
60+
);
6361

6462
if (selectionsWithoutSelectedIndex.length > 0) {
6563
this.setSelections(selectionsWithoutSelectedIndex);
66-
} else {
64+
} else {
6765
this.setSelections([selectedIndex]);
6866
this.lastSingleSelection = selectedIndex;
6967
}
7068
} else {
7169
this.setSelections([...this.selections, selectedIndex]);
7270
this.lastSingleSelection = selectedIndex;
7371
}
74-
7572
} else if (shiftSelect) {
76-
7773
const newSelectionBefore = selectedIndex < this.lastSingleSelection;
78-
const count = (
79-
newSelectionBefore
80-
? this.lastSingleSelection - (selectedIndex - 1)
81-
: (selectedIndex + 1) - this.lastSingleSelection
82-
);
74+
const count = newSelectionBefore
75+
? this.lastSingleSelection - (selectedIndex - 1)
76+
: selectedIndex + 1 - this.lastSingleSelection;
8377

8478
const shiftSelection = new Array(count)
8579
.fill(0)
86-
.map((_, index) => newSelectionBefore
87-
? this.lastSingleSelection - index
88-
: this.lastSingleSelection + index
80+
.map((_, index) =>
81+
newSelectionBefore
82+
? this.lastSingleSelection - index
83+
: this.lastSingleSelection + index
8984
);
9085

9186
this.setSelections([...shiftSelection]);
92-
9387
} else {
9488
this.resetSelection(selectedIndex);
9589
}
@@ -104,5 +98,4 @@ export class MultiSelectionService {
10498
selectAll(indexes: number[]) {
10599
this.setSelections(indexes);
106100
}
107-
108101
}

apps/codelab/src/app/admin/content/presentation-editor/side-panel/side-panel.component.html

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
<div class="slides-wrapper">
22
<button (click)="addSlide()">Add</button>
33

4-
<div (cdkDropListDropped)="droppedIntoList($event)" [class.dragging]="dragging" cdkDropList>
4+
<div
5+
(cdkDropListDropped)="droppedIntoList($event)"
6+
[class.dragging]="dragging"
7+
cdkDropList
8+
>
59
<div
610
(cdkDragDropped)="dropped()"
711
(cdkDragEnded)="dragEnded()"
812
(cdkDragStarted)="dragStarted($event)"
913
(click)="select($event, index)"
10-
*ngFor="let slide of slides; let index = index; trackBy: trackBySlideId;"
14+
*ngFor="let slide of slides; let index = index; trackBy: trackBySlideId"
1115
[class.selected]="multiSelectionService.selections.includes(index)"
1216
[class.current]="index == currentSlideIndex"
1317
cdkDragLockAxis="y"
@@ -19,7 +23,9 @@
1923
<div *ngFor="let sel of multiSelectionService.selections"></div>
2024
</div>
2125
<div *cdkDragPlaceholder>
22-
<div style="background: #00a4ff; height: 1px; width: 100%; margin: 2px 0"></div>
26+
<div
27+
style="background: #00a4ff; height: 1px; width: 100%; margin: 2px 0"
28+
></div>
2329
</div>
2430

2531
<div class="slide">

apps/codelab/src/app/admin/content/presentation-editor/side-panel/side-panel.component.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1-
import { Component, ElementRef, HostListener, Input, OnInit } from '@angular/core';
1+
import {
2+
Component,
3+
ElementRef,
4+
HostListener,
5+
Input,
6+
OnInit
7+
} from '@angular/core';
28
import { Location } from '@angular/common';
39
import { CdkDragDrop, CdkDragStart, DragRef } from '@angular/cdk/drag-drop';
410
import { ActivatedRoute, Router } from '@angular/router';
511

612
import { ContentService } from '../services/content.service';
713
import { NavigationService } from '../services/navigation.service';
814
import { ContentSlide } from '../types';
9-
import { isCtrlEvent, isShiftEvent, MultiSelectionService } from './multi-selection.service';
15+
import {
16+
isCtrlEvent,
17+
isShiftEvent,
18+
MultiSelectionService
19+
} from './multi-selection.service';
1020

1121
@Component({
1222
selector: 'slides-side-panel',
@@ -32,7 +42,7 @@ export class SidePanelComponent implements OnInit {
3242
) {}
3343

3444
ngOnInit() {
35-
this.multiSelectionService.selections$.subscribe((selections) => {
45+
this.multiSelectionService.selections$.subscribe(selections => {
3646
console.log({ selections });
3747
});
3848

@@ -81,7 +91,10 @@ export class SidePanelComponent implements OnInit {
8191

8292
event.preventDefault();
8393
} else if (event.key === 'Delete') {
84-
this.contentService.deleteSlides(this.presentationId, this.multiSelectionService.selections);
94+
this.contentService.deleteSlides(
95+
this.presentationId,
96+
this.multiSelectionService.selections
97+
);
8598
this.multiSelectionService.resetSelection(this.currentSlideIndex);
8699

87100
event.preventDefault();
@@ -126,5 +139,4 @@ export class SidePanelComponent implements OnInit {
126139
this.navigationService.goToSlide(this.presentationId, index);
127140
}
128141
}
129-
130142
}

0 commit comments

Comments
 (0)