diff --git a/nwaifu-ui/src/lib/components/textarea/textarea.component.ts b/nwaifu-ui/src/lib/components/textarea/textarea.component.ts index 34d3c12..a560f69 100644 --- a/nwaifu-ui/src/lib/components/textarea/textarea.component.ts +++ b/nwaifu-ui/src/lib/components/textarea/textarea.component.ts @@ -13,7 +13,6 @@ export class NWUITextAreaComponent implements AfterViewInit { @Input() disabled = false; @Input() value = ''; @Input() contenteditable = true; - // eslint-disable-next-line @typescript-eslint/no-empty-function @Output() leave = new EventEmitter(); @ViewChild('ref') ref: ElementRef | null = null; diff --git a/src/app/components/translate_block/translate_block.component.ts b/src/app/components/translate_block/translate_block.component.ts index 002449a..8f5ea6f 100644 --- a/src/app/components/translate_block/translate_block.component.ts +++ b/src/app/components/translate_block/translate_block.component.ts @@ -1,7 +1,7 @@ import { CommonModule } from '@angular/common'; -import { Component, ElementRef, Input, OnInit, ViewChild } from '@angular/core'; +import { Component, Input, OnInit, ViewChild } from '@angular/core'; import { NWUIButtonComponent, NWUITextAreaComponent } from '@nwaifu-ui'; -import { LocalStorageKeys } from 'src/app/consts'; +import { LocalStorageKeys } from '../../consts'; import { TranslateData } from '../../dto/translate_data.dto'; import { ETranslateService } from '../../services/translate.enums'; import { TranslateService } from '../../services/translate.service'; @@ -15,7 +15,7 @@ import { TranslateService } from '../../services/translate.service'; providers: [TranslateService], }) export class TranslateBlockComponent implements OnInit { - @ViewChild('translatedText') translatedText: ElementRef | null = null; + @ViewChild('translatedText') translatedText: NWUITextAreaComponent | null = null; @Input({ required: true }) item: TranslateData = { english_text: '', translated_text: '' }; @Input({ required: true }) index = 0; translateLoading = false; @@ -61,12 +61,14 @@ export class TranslateBlockComponent implements OnInit { saveTranslate(text: string) { this.isEditing = false; + if (this.translatedText) if (this.translatedText.ref) this.translatedText.ref.nativeElement.textContent = ''; this.item.translated_text = text; this.saveChanges(); } clear() { this.item.translated_text = ''; this.isEditing = true; + if (this.translatedText) if (this.translatedText.ref) this.translatedText.ref.nativeElement.textContent = ''; this.saveChanges(); } }