This commit is contained in:
adityachandelgit
2025-04-23 15:48:56 -06:00
parent dbfc20e63f
commit c01db47754
2 changed files with 18 additions and 12 deletions
@@ -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 }"
@@ -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,