mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Use correct direction for RTL content
This commit is contained in:
		 Michael Shamoon
					Michael Shamoon
				
			
				
					committed by
					
						 Trenton H
						Trenton H
					
				
			
			
				
	
			
			
			 Trenton H
						Trenton H
					
				
			
						parent
						
							fb20c92c51
						
					
				
				
					commit
					bc318416cf
				
			| @@ -91,7 +91,7 @@ | ||||
|                     <a ngbNavLink i18n>Content</a> | ||||
|                     <ng-template ngbNavContent> | ||||
|                         <div class="mb-3"> | ||||
|                             <textarea class="form-control" id="content" rows="20" formControlName='content'></textarea> | ||||
|                             <textarea class="form-control" id="content" rows="20" formControlName='content' [class.rtl]="isRTL"></textarea> | ||||
|                         </div> | ||||
|                     </ng-template> | ||||
|                 </li> | ||||
|   | ||||
| @@ -28,3 +28,7 @@ | ||||
|   left: 30%; | ||||
|   right: 30%; | ||||
| } | ||||
|  | ||||
| textarea.rtl { | ||||
|   direction: rtl; | ||||
| } | ||||
|   | ||||
| @@ -135,6 +135,13 @@ export class DocumentDetailComponent | ||||
|       : this.metadata?.original_mime_type | ||||
|   } | ||||
|  | ||||
|   get isRTL() { | ||||
|     if (!this.metadata || !this.metadata.lang) return false | ||||
|     else { | ||||
|       return ['ar', 'he', 'fe'].includes(this.metadata.lang) | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   ngOnInit(): void { | ||||
|     this.documentForm.valueChanges | ||||
|       .pipe(takeUntil(this.unsubscribeNotifier)) | ||||
|   | ||||
| @@ -10,4 +10,6 @@ export interface PaperlessDocumentMetadata { | ||||
|   original_filename?: string | ||||
|  | ||||
|   has_archive_version?: boolean | ||||
|  | ||||
|   lang?: string | ||||
| } | ||||
|   | ||||
| @@ -29,6 +29,7 @@ from django.views.decorators.cache import cache_control | ||||
| from django.views.generic import TemplateView | ||||
| from django_filters.rest_framework import DjangoFilterBackend | ||||
| from documents.tasks import consume_file | ||||
| from langdetect import detect | ||||
| from packaging import version as packaging_version | ||||
| from paperless import version | ||||
| from paperless.db import GnuPG | ||||
| @@ -325,6 +326,13 @@ class DocumentViewSet( | ||||
|             "original_filename": doc.original_filename, | ||||
|         } | ||||
|  | ||||
|         lang = "en" | ||||
|         try: | ||||
|             lang = detect(doc.content) | ||||
|         except Exception: | ||||
|             pass | ||||
|         meta["lang"] = lang | ||||
|  | ||||
|         if doc.has_archive_version: | ||||
|             meta["archive_size"] = self.get_filesize(doc.archive_path) | ||||
|             meta["archive_metadata"] = self.get_metadata( | ||||
|   | ||||
		Reference in New Issue
	
	Block a user