Skip to content

Commit

Permalink
fix: make input elements editable
Browse files Browse the repository at this point in the history
  • Loading branch information
sibiraj-s committed Jun 11, 2021
1 parent a87fbe1 commit c408d17
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,46 @@ export class FloatingMenuComponent implements OnInit, OnDestroy {
activeItems: TBItems[] = [];

@HostListener('document:mousedown', ['$event']) onMouseDown(e: MouseEvent): void {
if (this.el.nativeElement.contains(e.target as Node)) {
const target = e.target as Node

if (this.el.nativeElement.contains(target) && target.nodeName !== 'INPUT') {
e.preventDefault();
return;
}

this.dragging = true;
}

@HostListener('document:keydown') onKeyDown(): void {
@HostListener('document:keydown', ['$event']) onKeyDown(e: KeyboardEvent): void {
const target = e.target as Node

if (target.nodeName === 'INPUT') {
return;
}

this.dragging = true;
this.hide();
}

@HostListener('document:mouseup') onMouseUp(): void {
@HostListener('document:mouseup', ['$event']) onMouseUp(e: MouseEvent): void {
const target = e.target as Node

if (this.el.nativeElement.contains(target) || target.nodeName === 'INPUT') {
e.preventDefault();
return
}

this.dragging = false;
this.useUpdate();
}

@HostListener('document:keyup') onKeyUp(): void {
@HostListener('document:keyup', ['$event']) onKeyUp(e: KeyboardEvent): void {
const target = e.target as Node

if (target.nodeName === 'INPUT') {
return;
}

this.dragging = false;
this.useUpdate();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<div class="NgxEditor__MenuItem--IconContainer" [innerHTML]="icon | sanitizeHtml" (mousedown)="onMouseDown($event)" [title]="getLabel('insertImage')">
<div class="NgxEditor__MenuItem--IconContainer" [innerHTML]="icon | sanitizeHtml" (mousedown)="onMouseDown($event)"
[title]="getLabel('insertImage')">
</div>

<!-- popup -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ export class ImageComponent implements OnInit, OnDestroy {
private el: ElementRef,
private ngxeService: NgxEditorService,
private menuService: MenuService
) {

}
) { }

@HostBinding('class.NgxEditor__MenuItem--Active') get valid(): boolean {
return this.isActive || this.showPopup;
Expand Down Expand Up @@ -73,8 +71,6 @@ export class ImageComponent implements OnInit, OnDestroy {
}

onMouseDown(e: MouseEvent): void {
e.preventDefault();

if (e.button !== 0) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<div class="NgxEditor__MenuItem--IconContainer" [innerHTML]="icon | sanitizeHtml" (mousedown)="onMouseDown($event)" [title]="title">
<div class="NgxEditor__MenuItem--IconContainer" [innerHTML]="icon | sanitizeHtml" (mousedown)="onMouseDown($event)"
[title]="title">
</div>

<!-- popup -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class LinkComponent implements OnInit, OnDestroy {
private el: ElementRef,
private ngxeService: NgxEditorService,
private menuService: MenuService
) { }
) { }

@HostBinding('class.NgxEditor__MenuItem--Active') get valid(): boolean {
return this.isActive || this.showPopup;
Expand Down Expand Up @@ -84,8 +84,6 @@ export class LinkComponent implements OnInit, OnDestroy {
}

onMouseDown(e: MouseEvent): void {
e.preventDefault();

if (e.button !== 0) {
return;
}
Expand Down

0 comments on commit c408d17

Please sign in to comment.