diff --git a/UI/Web/src/app/book-reader/book-reader/book-reader.component.html b/UI/Web/src/app/book-reader/book-reader/book-reader.component.html index 22356d552..410ef7555 100644 --- a/UI/Web/src/app/book-reader/book-reader/book-reader.component.html +++ b/UI/Web/src/app/book-reader/book-reader/book-reader.component.html @@ -116,7 +116,7 @@
-
+
@@ -130,7 +130,7 @@  {{readingDirection === ReadingDirection.LeftToRight ? 'Previous' : 'Next'}} - +
@@ -138,7 +138,7 @@
- {{bookTitle}} + {{bookTitle}} (Incognito Mode)
diff --git a/UI/Web/src/app/cards/cover-image-chooser/cover-image-chooser.component.ts b/UI/Web/src/app/cards/cover-image-chooser/cover-image-chooser.component.ts index 3d49894c2..466769a99 100644 --- a/UI/Web/src/app/cards/cover-image-chooser/cover-image-chooser.component.ts +++ b/UI/Web/src/app/cards/cover-image-chooser/cover-image-chooser.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core'; +import { Component, EventEmitter, Inject, Input, OnDestroy, OnInit, Output } from '@angular/core'; import { FormBuilder, FormControl, FormGroup } from '@angular/forms'; import { NgxFileDropEntry, FileSystemFileEntry } from 'ngx-file-drop'; import { fromEvent, Subject } from 'rxjs'; @@ -7,6 +7,7 @@ import { ToastrService } from 'ngx-toastr'; import { ImageService } from 'src/app/_services/image.service'; import { KEY_CODES } from 'src/app/shared/_services/utility.service'; import { UploadService } from 'src/app/_services/upload.service'; +import { DOCUMENT } from '@angular/common'; @Component({ selector: 'app-cover-image-chooser', @@ -42,7 +43,8 @@ export class CoverImageChooserComponent implements OnInit, OnDestroy { mode: 'file' | 'url' | 'all' = 'all'; private readonly onDestroy = new Subject(); - constructor(public imageService: ImageService, private fb: FormBuilder, private toastr: ToastrService, private uploadService: UploadService) { } + constructor(public imageService: ImageService, private fb: FormBuilder, private toastr: ToastrService, private uploadService: UploadService, + @Inject(DOCUMENT) private document: Document) { } ngOnInit(): void { this.form = this.fb.group({ @@ -84,7 +86,7 @@ export class CoverImageChooserComponent implements OnInit, OnDestroy { const img = new Image(); img.crossOrigin = 'Anonymous'; img.src = this.imageService.getCoverUploadImage(filename); - img.onload = (e) => this.handleUrlImageAdd(e); + img.onload = (e) => this.handleUrlImageAdd(img); img.onerror = (e) => { this.toastr.error('The image could not be fetched due to server refusing request. Please download and upload from file instead.'); this.form.get('coverImageUrl')?.setValue(''); @@ -97,6 +99,8 @@ export class CoverImageChooserComponent implements OnInit, OnDestroy { changeMode(mode: 'url') { this.mode = mode; this.setupEnterHandler(); + + setTimeout(() => (this.document.querySelector('#load-image') as HTMLInputElement)?.focus(), 10); } public dropped(files: NgxFileDropEntry[]) { @@ -125,10 +129,8 @@ export class CoverImageChooserComponent implements OnInit, OnDestroy { this.selectedBase64Url.emit(e.target.result); } - handleUrlImageAdd(e: any) { - if (e.path === null || e.path.length === 0) return; - - const url = this.getBase64Image(e.path[0]); + handleUrlImageAdd(img: HTMLImageElement) { + const url = this.getBase64Image(img); this.imageUrls.push(url); this.imageUrlsChange.emit(this.imageUrls);