Merge branch 'feature/206-enable-quill-in-metadata-editor-and-viewer' into develop
# Conflicts: # booklore-ui/src/app/metadata/book-metadata-center/metadata-editor/metadata-editor.component.html # booklore-ui/src/app/metadata/book-metadata-center/metadata-editor/metadata-editor.component.ts
This commit is contained in:
+2
-1
@@ -250,7 +250,7 @@
|
||||
<p-tabpanels>
|
||||
<p-tabpanel value="editor">
|
||||
<form [formGroup]="metadataForm">
|
||||
<p-editor #quillEditor formControlName="description" [style]="{ height: '230px' }">
|
||||
<p-editor #quillEditor formControlName="description" [readonly]="quillDisabled()" [style]="{ height: '230px' }">
|
||||
<ng-template #header>
|
||||
<span class="ql-formats">
|
||||
<button class="ql-bold" aria-label="Bold"></button>
|
||||
@@ -285,6 +285,7 @@
|
||||
<textarea
|
||||
class="w-full p-2"
|
||||
rows="11.5"
|
||||
[disabled]="quillDisabled()"
|
||||
[ngModel]="htmlTextarea"
|
||||
(ngModelChange)="onHtmlTextareaChange($event)"
|
||||
[ngModelOptions]="{ standalone: true }"
|
||||
|
||||
+16
-11
@@ -59,17 +59,6 @@ export class MetadataEditorComponent implements OnInit {
|
||||
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({
|
||||
title: new FormControl(''),
|
||||
@@ -124,6 +113,7 @@ export class MetadataEditorComponent implements OnInit {
|
||||
|
||||
if (this.quillEditor && this.quillEditor.quill) {
|
||||
this.quillEditor.quill.root.innerHTML = metadata.description;
|
||||
this.quillDisabled();
|
||||
}
|
||||
|
||||
this.metadataForm.patchValue({
|
||||
@@ -249,6 +239,21 @@ export class MetadataEditorComponent implements OnInit {
|
||||
this.updateMetadata(false);
|
||||
}
|
||||
|
||||
quillDisabled(): boolean {
|
||||
return this.metadataForm.get('descriptionLocked')?.value === true;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private buildMetadata(shouldLockAllFields: boolean | undefined) {
|
||||
const updatedBookMetadata: BookMetadata = {
|
||||
bookId: this.currentBookId,
|
||||
|
||||
Reference in New Issue
Block a user