Skip to content
Snippets Groups Projects
Commit 18780d67 authored by jojohoch's avatar jojohoch
Browse files

[player] Refactor parameters of `TextMarker.applySelection`

parent d794e7ea
No related branches found
No related tags found
No related merge requests found
......@@ -6,12 +6,12 @@ export class TextMarker {
static applySelection(
mode: 'mark' | 'delete',
color: string,
element: HTMLElement,
textComponent: TextComponent
): void {
const selection = window.getSelection();
if (selection && TextMarker.isSelectionValid(selection) && selection.rangeCount > 0) {
const range = selection.getRangeAt(0);
const element = textComponent.textContainerRef.nativeElement;
if (TextMarker.isRangeInside(range, element)) {
TextMarker.applyRange(range, selection, mode === 'delete', color);
textComponent.elementValueChanged.emit({
......
......@@ -22,5 +22,5 @@
[overlayOrigin]="overlayOrigin"
[positions]="positions"
[isMarkingBarOpen]="isMarkingBarOpen"
(applySelection)="apply($event.mode, $event.color)">
(applySelection)="applySelectiontoText($event.mode, $event.color)">
</app-floating-marking-bar>
......@@ -102,12 +102,11 @@ export class ElementContainerComponent implements OnInit {
this.subscribeForKeyboardEvents(this.elementComponent as TextFieldComponent | TextAreaComponent);
}
apply(mode: 'mark' | 'delete', color: string): void {
applySelectiontoText(mode: 'mark' | 'delete', color: string): void {
TextMarker
.applySelection(
mode,
color,
(this.elementComponent as TextComponent).textContainerRef.nativeElement,
this.elementComponent as TextComponent
);
this.isMarkingBarOpen = false;
......@@ -220,7 +219,7 @@ export class ElementContainerComponent implements OnInit {
(mouseUp.ctrlKey)) {
selection.removeAllRanges();
} else if (this.selectedMode && this.selectedColor) {
this.apply(this.selectedMode, this.selectedColor);
this.applySelectiontoText(this.selectedMode, this.selectedColor);
} else if (!this.isMarkingBarOpen) {
this.openMarkingBar(mouseUp, mouseDown, elementComponent);
}
......@@ -259,7 +258,7 @@ export class ElementContainerComponent implements OnInit {
if (selection.active) {
this.selectedColor = selection.color;
this.selectedMode = selection.mode;
this.apply(selection.mode, selection.color);
this.applySelectiontoText(selection.mode, selection.color);
} else {
this.selectedColor = null;
this.selectedMode = null;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment