improvements
This commit is contained in:
parent
089150b88a
commit
f5db1a8b23
@ -117,6 +117,7 @@ export class CommentBoxComponent implements MatFormFieldControl<string>, Control
|
||||
|
||||
onFocusOut(event: FocusEvent) {
|
||||
if (!this._commentInputRef.nativeElement.contains(event.relatedTarget as Element)) {
|
||||
this.cleanEmptyElements(this._commentInputRef.nativeElement);
|
||||
this.commentText = this._commentInputRef.nativeElement.innerHTML;
|
||||
this.touched = true;
|
||||
this.focused = false;
|
||||
@ -220,6 +221,7 @@ export class CommentBoxComponent implements MatFormFieldControl<string>, Control
|
||||
|
||||
// open/close menu
|
||||
let focusedMentionElement = <HTMLElement>htmlElement.querySelector(`.mention.${Cursor.focusedClassName}`);
|
||||
console.log(focusedMentionElement);
|
||||
if (focusedMentionElement) {
|
||||
// set offset for menu
|
||||
this.menuOffsetX = focusedMentionElement.offsetLeft;
|
||||
@ -326,4 +328,9 @@ export class CommentBoxComponent implements MatFormFieldControl<string>, Control
|
||||
if (focused)
|
||||
focused.remove();
|
||||
}
|
||||
|
||||
cleanEmptyElements(base: HTMLElement) {
|
||||
base.querySelectorAll("span, div").forEach(el => el.textContent === "" && el.parentNode?.removeChild(el))
|
||||
base.innerHTML = base.innerHTML.replace(/class=""/g, "");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user