add tiny to viewer

This commit is contained in:
Peter Maquiran
2024-02-22 15:42:04 +01:00
parent 7583bf5306
commit e778039632
9 changed files with 185 additions and 40 deletions
@@ -217,7 +217,7 @@ export class DespachoPage implements OnInit {
let object = {
"ApplicationId": "",
"Assunto": resd.data.description,
"DocDate": "",
"DocDate":resd?.createdAt,
"DocId": resd.data.id,
"DocNumber": "",
"FolderId": "",
@@ -7,15 +7,17 @@ import { IonicModule } from '@ionic/angular';
import { ViewerAttachmentPageRoutingModule } from './viewer-attachment-routing.module';
import { ViewerAttachmentPage } from './viewer-attachment.page';
import { EditorModule } from '@tinymce/tinymce-angular';
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
ViewerAttachmentPageRoutingModule
ViewerAttachmentPageRoutingModule,
EditorModule
],
declarations: [ViewerAttachmentPage],
declarations: [ViewerAttachmentPage, ],
exports: [ViewerAttachmentPage],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
@@ -1,10 +1,10 @@
<div class="height-100 d-flex flex-column overflow-hidden width-100">
<div class="overflow-x-auto d-flex pa-10 attachment-list" style="background-color: #d9d9d9;" *ngIf="!DeviceService.isDesktop()">
<div class="overflow-x-auto d-flex pa-10 attachment-list" style="background-color: #d9d9d9;" *ngIf="showAttachmentList">
<div *ngFor="let attachment of taskViewerAttachment; let i = index"
class="ion-no-margin ion-no-padding cursor-pointer attachment-list" class="pa-10 mx-10 card-text"
[ngClass]="{'selected-card': i === selectedIndex}">
[ngClass]="{'selected-card': i === selectedIndex}" >
<div (click)="clickDocument(attachment, i )">
<div *ngIf="attachment.Assunto" class="attach-title-item tex-left">
@@ -20,9 +20,35 @@
</div>
<div #iframeContainer class="height-100 flex-1" >
<div [ngClass]="{'d-none': taskViewerAttachment[selectedIndex].content != ''}" #iframeContainer class="height-100 flex-1" >
</div>
<editor
*ngIf="taskViewerAttachment[selectedIndex].content"
class="container-img height-100"
apiKey="wr5dk69kive0qr9ig6y5spqvlj3a0tsiwnzdsexnz241k69p"
[(ngModel)]="editorContent"
[init]="{
save_onsavecallback: 'onSaveContent',
language: 'pt_PT',
height: '100%',
menubar: false,
autosave_interval:'3s',
plugins: [
'advlist autolink autosave lists link image charmap print preview anchor',
'searchreplace visualblocks code fullscreen',
'insertdatetime media table paste code help wordcount print'
],
toolbar:
'undo redo | formatselect | bold italic backcolor | \
alignleft aligncenter alignright alignjustify | \
bullist numlist outdent indent | removeformat | print | save | help ' }"
initialValue='{{content}}'
[(ngModel)]="content"
(ngModelChange)="onEditorContentChange()"
></editor>
</div>
@@ -31,17 +31,3 @@ iframe {
.selected-attachment {
border: 2px solid #3498db; /* You can customize the border style and color */
}
@media screen and (orientation:portrait) {
.attachment-list {
}
}
@media screen and (orientation:landscape) {
.attachment-list {
display: none !important;
}
}
@@ -10,11 +10,15 @@ import { DeviceService } from "src/app/services/device.service"
})
export class ViewerAttachmentPage implements OnInit {
@Input() showAttachmentList = true;
@Input() selectedIndex = 0;
swiperModules = [IonicSlides];
@Input() taskViewerAttachment: ViewerAttachment[];
viewer: {[key: string]: HTMLDivElement} = {}
@ViewChild('iframeContainer') iframeContainer: ElementRef<HTMLDivElement>;
editorContent: "";
content: ""
private saveTimeout: any;
constructor(
public middlewareRepositoryService: MiddlewareRepositoryService,
@@ -87,4 +91,24 @@ export class ViewerAttachmentPage implements OnInit {
this.clickDocument(task, this.selectedIndex)
}
somefunction() {
console.log('Saved tinymce')
}
onEditorContentChange() {
console.log('Autosave successful! Content saved to local storage1.');
if (this.saveTimeout) {
clearTimeout(this.saveTimeout);
}
this.saveTimeout = setTimeout(() => {
this.saveDraft();
clearTimeout(this.saveTimeout);
}, 5000);
}
saveDraft() {}
}