Enable quill in metadata editor and viewer
This commit is contained in:
Generated
+4
-4
@@ -28,7 +28,7 @@
|
||||
"ngx-infinite-scroll": "19.0.0",
|
||||
"primeicons": "7.0.0",
|
||||
"primeng": "19.0.10",
|
||||
"quill": "2.0.3",
|
||||
"quill": "2.0.2",
|
||||
"rxjs": "7.8.2",
|
||||
"showdown": "^2.1.0",
|
||||
"tailwindcss-primeui": "0.6.1",
|
||||
@@ -14396,9 +14396,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/quill": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/quill/-/quill-2.0.3.tgz",
|
||||
"integrity": "sha512-xEYQBqfYx/sfb33VJiKnSJp8ehloavImQ2A6564GAbqG55PGw1dAWUn1MUbQB62t0azawUS2CZZhWCjO8gRvTw==",
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/quill/-/quill-2.0.2.tgz",
|
||||
"integrity": "sha512-QfazNrhMakEdRG57IoYFwffUIr04LWJxbS/ZkidRFXYCQt63c1gK6Z7IHUXMx/Vh25WgPBU42oBaNzQ0K1R/xw==",
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"eventemitter3": "^5.0.1",
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
"ngx-infinite-scroll": "19.0.0",
|
||||
"primeicons": "7.0.0",
|
||||
"primeng": "19.0.10",
|
||||
"quill": "2.0.3",
|
||||
"quill": "2.0.2",
|
||||
"rxjs": "7.8.2",
|
||||
"showdown": "^2.1.0",
|
||||
"tailwindcss-primeui": "0.6.1",
|
||||
|
||||
+51
-2
@@ -241,9 +241,58 @@
|
||||
|
||||
<div class="flex flex-row w-full pb-1">
|
||||
<div class="flex flex-col gap-1 w-full">
|
||||
<label for="description">Description</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<textarea rows="14" pTextarea id="description" formControlName="description" class="w-full"></textarea>
|
||||
<p-tabs value="editor" class="w-full">
|
||||
<p-tablist>
|
||||
<p-tab value="editor">Editor</p-tab>
|
||||
<p-tab value="html">HTML</p-tab>
|
||||
</p-tablist>
|
||||
<p-tabpanels>
|
||||
<p-tabpanel value="editor">
|
||||
<form [formGroup]="metadataForm">
|
||||
<p-editor #quillEditor formControlName="description" [style]="{ height: '230px' }">
|
||||
<ng-template #header>
|
||||
<span class="ql-formats">
|
||||
<button class="ql-bold" aria-label="Bold"></button>
|
||||
<button class="ql-italic" aria-label="Italic"></button>
|
||||
<button class="ql-underline" aria-label="Underline"></button>
|
||||
<button class="ql-strike" aria-label="Strikethrough"></button>
|
||||
</span>
|
||||
<span class="ql-formats">
|
||||
<select class="ql-size" aria-label="Font Size">
|
||||
<option value="small">Small</option>
|
||||
<option selected>Normal</option>
|
||||
<option value="large">Large</option>
|
||||
<option value="huge">Huge</option>
|
||||
</select>
|
||||
</span>
|
||||
<span class="ql-formats">
|
||||
<button class="ql-list" value="ordered" aria-label="Numbered List"></button>
|
||||
<button class="ql-list" value="bullet" aria-label="Bullet List"></button>
|
||||
</span>
|
||||
<span class="ql-formats">
|
||||
<select class="ql-color" aria-label="Text Color"></select>
|
||||
<select class="ql-background" aria-label="Background Color"></select>
|
||||
</span>
|
||||
<span class="ql-formats">
|
||||
<button class="ql-clean" aria-label="Remove Formatting"></button>
|
||||
</span>
|
||||
</ng-template>
|
||||
</p-editor>
|
||||
</form>
|
||||
</p-tabpanel>
|
||||
<p-tabpanel value="html" class="w-full">
|
||||
<textarea
|
||||
class="w-full p-2"
|
||||
rows="11.5"
|
||||
[ngModel]="htmlTextarea"
|
||||
(ngModelChange)="onHtmlTextareaChange($event)"
|
||||
[ngModelOptions]="{ standalone: true }"
|
||||
placeholder="Edit raw HTML here">
|
||||
</textarea>
|
||||
</p-tabpanel>
|
||||
</p-tabpanels>
|
||||
</p-tabs>
|
||||
<p-button *ngIf="!metadata['descriptionLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('description')" severity="success"></p-button>
|
||||
<p-button *ngIf="metadata['descriptionLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('description')" severity="warn"></p-button>
|
||||
</div>
|
||||
|
||||
+39
-6
@@ -1,6 +1,5 @@
|
||||
import {Component, inject, OnInit} from '@angular/core';
|
||||
import {Component, inject, OnInit, ViewChild} from '@angular/core';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {Textarea} from 'primeng/textarea';
|
||||
import {Button} from 'primeng/button';
|
||||
import {Divider} from 'primeng/divider';
|
||||
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||
@@ -15,6 +14,9 @@ import {HttpResponse} from '@angular/common/http';
|
||||
import {BookService} from '../../../book/service/book.service';
|
||||
import {ProgressSpinner} from 'primeng/progressspinner';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {Editor} from 'primeng/editor';
|
||||
import {debounceTime} from 'rxjs/operators';
|
||||
import {Tab, TabList, TabPanel, TabPanels, Tabs} from 'primeng/tabs';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-editor',
|
||||
@@ -23,7 +25,6 @@ import {Tooltip} from 'primeng/tooltip';
|
||||
styleUrls: ['./metadata-editor.component.scss'],
|
||||
imports: [
|
||||
InputText,
|
||||
Textarea,
|
||||
Button,
|
||||
Divider,
|
||||
FormsModule,
|
||||
@@ -33,11 +34,19 @@ import {Tooltip} from 'primeng/tooltip';
|
||||
FileUpload,
|
||||
ProgressSpinner,
|
||||
NgClass,
|
||||
Tooltip
|
||||
Tooltip,
|
||||
Editor,
|
||||
Tabs,
|
||||
TabList,
|
||||
Tab,
|
||||
TabPanels,
|
||||
TabPanel
|
||||
]
|
||||
})
|
||||
export class MetadataEditorComponent implements OnInit {
|
||||
|
||||
@ViewChild(Editor) quillEditor!: Editor;
|
||||
|
||||
private metadataCenterService = inject(BookMetadataCenterService);
|
||||
private messageService = inject(MessageService);
|
||||
private bookService = inject(BookService);
|
||||
@@ -48,6 +57,18 @@ export class MetadataEditorComponent implements OnInit {
|
||||
currentBookId!: number;
|
||||
isUploading = false;
|
||||
isLoading = false;
|
||||
htmlTextarea = '';
|
||||
|
||||
onHtmlTextareaChange(value: string): void {
|
||||
this.htmlTextarea = value;
|
||||
const control = this.metadataForm.get('description');
|
||||
if (control?.value !== value) {
|
||||
control?.patchValue(value, { emitEvent: false });
|
||||
if (this.quillEditor && this.quillEditor.quill) {
|
||||
this.quillEditor.quill.root.innerHTML = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.metadataForm = new FormGroup({
|
||||
@@ -101,6 +122,10 @@ export class MetadataEditorComponent implements OnInit {
|
||||
if (metadata) {
|
||||
this.currentBookId = metadata.bookId;
|
||||
|
||||
if (this.quillEditor && this.quillEditor.quill) {
|
||||
this.quillEditor.quill.root.innerHTML = metadata.description;
|
||||
}
|
||||
|
||||
this.metadataForm.patchValue({
|
||||
title: metadata.title || null,
|
||||
subtitle: metadata.subtitle || null,
|
||||
@@ -155,8 +180,6 @@ export class MetadataEditorComponent implements OnInit {
|
||||
if (metadata.languageLocked) this.metadataForm.get('language')?.disable();
|
||||
if (metadata.isbn10Locked) this.metadataForm.get('isbn10')?.disable();
|
||||
if (metadata.isbn13Locked) this.metadataForm.get('isbn13')?.disable();
|
||||
this.metadataForm.get('reviewCount')?.disable();
|
||||
this.metadataForm.get('rating')?.disable();
|
||||
if (metadata.amazonReviewCountLocked) this.metadataForm.get('amazonReviewCount')?.disable();
|
||||
if (metadata.amazonRatingLocked) this.metadataForm.get('amazonRating')?.disable();
|
||||
if (metadata.goodreadsReviewCountLocked) this.metadataForm.get('goodreadsReviewCount')?.disable();
|
||||
@@ -166,7 +189,17 @@ export class MetadataEditorComponent implements OnInit {
|
||||
if (metadata.seriesNameLocked) this.metadataForm.get('seriesName')?.disable();
|
||||
if (metadata.seriesNumberLocked) this.metadataForm.get('seriesNumber')?.disable();
|
||||
if (metadata.seriesTotalLocked) this.metadataForm.get('seriesTotal')?.disable();
|
||||
this.metadataForm.get('reviewCount')?.disable();
|
||||
this.metadataForm.get('rating')?.disable();
|
||||
}
|
||||
|
||||
this.metadataForm.get('description')?.valueChanges
|
||||
.pipe(debounceTime(100))
|
||||
.subscribe(value => {
|
||||
if (this.htmlTextarea !== value) {
|
||||
this.htmlTextarea = value;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+7
-3
@@ -75,9 +75,13 @@
|
||||
<p-divider></p-divider>
|
||||
|
||||
<div *ngIf="metadata$ | async as metadata" class="flex-1 overflow-auto space-y-2 px-2">
|
||||
<div [ngClass]="{ 'line-clamp-5': !isExpanded, 'line-clamp-none': isExpanded }"
|
||||
class="transition-all duration-300 overflow-hidden description-container">
|
||||
<div class="description-content" [innerHTML]="metadata.description || 'No description available.'"></div>
|
||||
<div [ngClass]="{ 'line-clamp-5': !isExpanded, 'line-clamp-none': isExpanded }" class="transition-all duration-300 overflow-hidden description-container">
|
||||
<div class="readonly-editor px-2">
|
||||
<p-editor #quillEditor [readonly]="true" [style]="{height: '260px'}" [(ngModel)]="metadata.description">
|
||||
<ng-template #header>
|
||||
</ng-template>
|
||||
</p-editor>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div *ngIf="metadata.description && metadata.description.length > 100" class="text-left">
|
||||
|
||||
+17
-12
@@ -1,17 +1,22 @@
|
||||
::ng-deep .ql-toolbar.ql-snow {
|
||||
padding: 0 !important;
|
||||
::ng-deep .readonly-editor .p-editor {
|
||||
.p-editor-toolbar.ql-snow {
|
||||
padding: 0 !important;
|
||||
border: none !important;
|
||||
box-shadow: none !important;
|
||||
}
|
||||
|
||||
.p-editor-content.ql-snow {
|
||||
border: none !important;
|
||||
border-end-end-radius: 0 !important;
|
||||
border-end-start-radius: 0 !important;
|
||||
}
|
||||
|
||||
.ql-editor {
|
||||
padding: 0 !important;
|
||||
}
|
||||
}
|
||||
|
||||
::ng-deep .p-editor .p-editor-toolbar.ql-snow {
|
||||
border: 0.5px solid var(--p-editor-toolbar-border-color) !important;
|
||||
}
|
||||
|
||||
::ng-deep .p-editor .p-editor-content {
|
||||
border-end-end-radius: 0 !important;
|
||||
border-end-start-radius: 0 !important;
|
||||
}
|
||||
|
||||
::ng-deep .ql-container {
|
||||
::ng-deep .readonly-editor .ql-container {
|
||||
font-size: 14px !important;
|
||||
}
|
||||
|
||||
|
||||
+8
-2
@@ -1,4 +1,4 @@
|
||||
import {Component, DestroyRef, inject, Input, OnInit} from '@angular/core';
|
||||
import {Component, DestroyRef, inject, Input, OnInit, ViewChild} from '@angular/core';
|
||||
import {Button, ButtonDirective} from 'primeng/button';
|
||||
import {AsyncPipe, DecimalPipe, NgClass, NgForOf, NgIf} from '@angular/common';
|
||||
import {first, Observable} from 'rxjs';
|
||||
@@ -21,19 +21,22 @@ import {Tooltip} from 'primeng/tooltip';
|
||||
import {InfiniteScrollDirective} from 'ngx-infinite-scroll';
|
||||
import {BookCardComponent} from '../../../book/components/book-browser/book-card/book-card.component';
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
import {Editor} from 'primeng/editor';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-viewer',
|
||||
standalone: true,
|
||||
templateUrl: './metadata-viewer.component.html',
|
||||
styleUrl: './metadata-viewer.component.scss',
|
||||
imports: [Button, NgForOf, NgIf, AsyncPipe, Rating, FormsModule, Tag, Divider, SplitButton, NgClass, Tooltip, DecimalPipe, InfiniteScrollDirective, BookCardComponent, ButtonDirective]
|
||||
imports: [Button, NgForOf, NgIf, AsyncPipe, Rating, FormsModule, Tag, Divider, SplitButton, NgClass, Tooltip, DecimalPipe, InfiniteScrollDirective, BookCardComponent, ButtonDirective, Editor]
|
||||
})
|
||||
export class MetadataViewerComponent implements OnInit {
|
||||
|
||||
@Input() book: Book | undefined;
|
||||
@Input() recommendedBooks: BookRecommendation[] = [];
|
||||
|
||||
@ViewChild(Editor) quillEditor!: Editor;
|
||||
|
||||
private dialogService = inject(DialogService);
|
||||
private emailService = inject(EmailService);
|
||||
private messageService = inject(MessageService);
|
||||
@@ -78,6 +81,9 @@ export class MetadataViewerComponent implements OnInit {
|
||||
.subscribe((metadata) => {
|
||||
if (metadata) {
|
||||
this.getBooksInSeries(metadata.bookId);
|
||||
if (this.quillEditor && this.quillEditor.quill) {
|
||||
this.quillEditor.quill.root.innerHTML = metadata.description;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user