66
77import { CodeEditor } from '@acrodata/code-editor'
88import { HttpClient } from '@angular/common/http'
9- import { Component , inject , Input , OnDestroy , OnInit , ViewEncapsulation } from '@angular/core'
9+ import { Component , inject , input , OnDestroy , OnInit , ViewEncapsulation } from '@angular/core'
1010import { FormsModule } from '@angular/forms'
1111import { LanguageDescription } from '@codemirror/language'
1212import { languages } from '@codemirror/language-data'
@@ -26,13 +26,13 @@ import { FileModel } from '../../models/file.model'
2626 }
2727 `
2828 ] ,
29- template : ` <div [style.height.px]="currentHeight">
29+ template : ` <div [style.height.px]="currentHeight() ">
3030 <code-editor [languages]="languages" [language]="currentLanguage" [ngModel]="content" [readonly]="true" [theme]="currentTheme"></code-editor>
3131 </div>`
3232} )
3333export class FilesViewerTextComponent implements OnInit , OnDestroy {
34- @ Input ( ) currentHeight : number
35- @ Input ( ) file : FileModel
34+ currentHeight = input < number > ( )
35+ file = input < FileModel > ( )
3636 protected content : string
3737 protected currentLanguage = undefined
3838 protected readonly languages : LanguageDescription [ ] = languages
@@ -43,10 +43,10 @@ export class FilesViewerTextComponent implements OnInit, OnDestroy {
4343 private readonly maxSize = 5242880 // 5MB
4444
4545 ngOnInit ( ) {
46- const language : LanguageDescription = LanguageDescription . matchFilename ( languages , this . file . name )
47- if ( language ?. name || this . file . size <= this . maxSize ) {
46+ const language : LanguageDescription = LanguageDescription . matchFilename ( languages , this . file ( ) . name )
47+ if ( language ?. name || this . file ( ) . size <= this . maxSize ) {
4848 this . currentLanguage = language ?. name
49- this . http . get ( this . file . dataUrl , { responseType : 'text' } ) . subscribe ( ( data : string ) => ( this . content = data ) )
49+ this . http . get ( this . file ( ) . dataUrl , { responseType : 'text' } ) . subscribe ( ( data : string ) => ( this . content = data ) )
5050 } else {
5151 this . content = this . layout . translateString ( 'This file contains binary data that can not be read' )
5252 }
0 commit comments