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-tabpanels>
|
||||||
<p-tabpanel value="editor">
|
<p-tabpanel value="editor">
|
||||||
<form [formGroup]="metadataForm">
|
<form [formGroup]="metadataForm">
|
||||||
<p-editor #quillEditor formControlName="description" [style]="{ height: '230px' }">
|
<p-editor #quillEditor formControlName="description" [readonly]="quillDisabled()" [style]="{ height: '230px' }">
|
||||||
<ng-template #header>
|
<ng-template #header>
|
||||||
<span class="ql-formats">
|
<span class="ql-formats">
|
||||||
<button class="ql-bold" aria-label="Bold"></button>
|
<button class="ql-bold" aria-label="Bold"></button>
|
||||||
@@ -285,6 +285,7 @@
|
|||||||
<textarea
|
<textarea
|
||||||
class="w-full p-2"
|
class="w-full p-2"
|
||||||
rows="11.5"
|
rows="11.5"
|
||||||
|
[disabled]="quillDisabled()"
|
||||||
[ngModel]="htmlTextarea"
|
[ngModel]="htmlTextarea"
|
||||||
(ngModelChange)="onHtmlTextareaChange($event)"
|
(ngModelChange)="onHtmlTextareaChange($event)"
|
||||||
[ngModelOptions]="{ standalone: true }"
|
[ngModelOptions]="{ standalone: true }"
|
||||||
|
|||||||
+16
-11
@@ -59,17 +59,6 @@ export class MetadataEditorComponent implements OnInit {
|
|||||||
isLoading = false;
|
isLoading = false;
|
||||||
htmlTextarea = '';
|
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() {
|
constructor() {
|
||||||
this.metadataForm = new FormGroup({
|
this.metadataForm = new FormGroup({
|
||||||
title: new FormControl(''),
|
title: new FormControl(''),
|
||||||
@@ -124,6 +113,7 @@ export class MetadataEditorComponent implements OnInit {
|
|||||||
|
|
||||||
if (this.quillEditor && this.quillEditor.quill) {
|
if (this.quillEditor && this.quillEditor.quill) {
|
||||||
this.quillEditor.quill.root.innerHTML = metadata.description;
|
this.quillEditor.quill.root.innerHTML = metadata.description;
|
||||||
|
this.quillDisabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.metadataForm.patchValue({
|
this.metadataForm.patchValue({
|
||||||
@@ -249,6 +239,21 @@ export class MetadataEditorComponent implements OnInit {
|
|||||||
this.updateMetadata(false);
|
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) {
|
private buildMetadata(shouldLockAllFields: boolean | undefined) {
|
||||||
const updatedBookMetadata: BookMetadata = {
|
const updatedBookMetadata: BookMetadata = {
|
||||||
bookId: this.currentBookId,
|
bookId: this.currentBookId,
|
||||||
|
|||||||
Reference in New Issue
Block a user