mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-03 03:16:10 -06:00 
			
		
		
		
	Render frontend html as plain text
This commit is contained in:
		@@ -207,8 +207,8 @@
 | 
			
		||||
                <object [data]="previewUrl | safeUrl" class="preview-sticky" width="100%"></object>
 | 
			
		||||
            </ng-template>
 | 
			
		||||
        </ng-container>
 | 
			
		||||
        <ng-container *ngIf="getContentType() === 'text/plain'">
 | 
			
		||||
            <div [innerHTML]="previewHtml | safeHtml" class="preview-sticky bg-light p-3" width="100%"></div>
 | 
			
		||||
        <ng-container *ngIf="renderAsPlainText">
 | 
			
		||||
            <div [innerText]="previewText" class="preview-sticky bg-light p-3" width="100%"></div>
 | 
			
		||||
        </ng-container>
 | 
			
		||||
        <div *ngIf="requiresPassword" class="password-prompt">
 | 
			
		||||
            <form>
 | 
			
		||||
 
 | 
			
		||||
@@ -81,7 +81,7 @@ export class DocumentDetailComponent
 | 
			
		||||
  title: string
 | 
			
		||||
  titleSubject: Subject<string> = new Subject()
 | 
			
		||||
  previewUrl: string
 | 
			
		||||
  _previewHtml: string
 | 
			
		||||
  previewText: string
 | 
			
		||||
  downloadUrl: string
 | 
			
		||||
  downloadOriginalUrl: string
 | 
			
		||||
 | 
			
		||||
@@ -164,6 +164,12 @@ export class DocumentDetailComponent
 | 
			
		||||
      : this.metadata?.original_mime_type
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  get renderAsPlainText(): boolean {
 | 
			
		||||
    return ['text/plain', 'application/csv', 'text/csv'].includes(
 | 
			
		||||
      this.getContentType()
 | 
			
		||||
    )
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  get isRTL() {
 | 
			
		||||
    if (!this.metadata || !this.metadata.lang) return false
 | 
			
		||||
    else {
 | 
			
		||||
@@ -220,10 +226,10 @@ export class DocumentDetailComponent
 | 
			
		||||
          this.previewUrl = this.documentsService.getPreviewUrl(this.documentId)
 | 
			
		||||
          this.http.get(this.previewUrl, { responseType: 'text' }).subscribe({
 | 
			
		||||
            next: (res) => {
 | 
			
		||||
              this._previewHtml = res.toString()
 | 
			
		||||
              this.previewText = res.toString()
 | 
			
		||||
            },
 | 
			
		||||
            error: (err) => {
 | 
			
		||||
              this._previewHtml = $localize`An error occurred loading content: ${
 | 
			
		||||
              this.previewText = $localize`An error occurred loading content: ${
 | 
			
		||||
                err.message ?? err.toString()
 | 
			
		||||
              }`
 | 
			
		||||
            },
 | 
			
		||||
@@ -752,8 +758,4 @@ export class DocumentDetailComponent
 | 
			
		||||
      )
 | 
			
		||||
    )
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  get previewHtml(): string {
 | 
			
		||||
    return this._previewHtml
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user