diff --git a/projects/player/src/app/classes/text-marker.ts b/projects/player/src/app/classes/text-marker.ts index 8f884f510504c3736bc04176710a0da26ba047d9..b7fac03485ff0cc450a1806c6d70c274e8dd57cf 100644 --- a/projects/player/src/app/classes/text-marker.ts +++ b/projects/player/src/app/classes/text-marker.ts @@ -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({ diff --git a/projects/player/src/app/components/element-container/element-container.component.html b/projects/player/src/app/components/element-container/element-container.component.html index 2894e6679e4ec34ea13bebe57ae6d44e09377472..256d6d35b3f10719bf01edb8cc64e0ed992baf3a 100644 --- a/projects/player/src/app/components/element-container/element-container.component.html +++ b/projects/player/src/app/components/element-container/element-container.component.html @@ -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> diff --git a/projects/player/src/app/components/element-container/element-container.component.ts b/projects/player/src/app/components/element-container/element-container.component.ts index 11f5ee7ddb299c77a558d2bfad8676577b9749f9..1c86db408eec54ead0bd8555f0b7f4b8eeca873f 100644 --- a/projects/player/src/app/components/element-container/element-container.component.ts +++ b/projects/player/src/app/components/element-container/element-container.component.ts @@ -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;