Skip to content

Commit 3e6aeef

Browse files
johaven7185
authored andcommitted
chore(frontend:files): align search box in CodeMirror and use Angular signals
1 parent c5900c8 commit 3e6aeef

File tree

2 files changed

+35
-8
lines changed

2 files changed

+35
-8
lines changed

frontend/src/app/applications/files/components/viewers/files-viewer-text.component.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import { CodeEditor } from '@acrodata/code-editor'
88
import { 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'
1010
import { FormsModule } from '@angular/forms'
1111
import { LanguageDescription } from '@codemirror/language'
1212
import { languages } from '@codemirror/language-data'
@@ -26,13 +26,20 @@ import { FileModel } from '../../models/file.model'
2626
}
2727
`
2828
],
29-
template: ` <div [style.height.px]="currentHeight">
30-
<code-editor [languages]="languages" [language]="currentLanguage" [ngModel]="content" [readonly]="true" [theme]="currentTheme"></code-editor>
29+
template: ` <div [style.height.px]="currentHeight()">
30+
<code-editor
31+
[languages]="languages"
32+
[language]="currentLanguage"
33+
[ngModel]="content"
34+
[theme]="currentTheme"
35+
[readonly]="true"
36+
[lineWrapping]="true"
37+
></code-editor>
3138
</div>`
3239
})
3340
export class FilesViewerTextComponent implements OnInit, OnDestroy {
34-
@Input() currentHeight: number
35-
@Input() file: FileModel
41+
currentHeight = input<number>()
42+
file = input<FileModel>()
3643
protected content: string
3744
protected currentLanguage = undefined
3845
protected readonly languages: LanguageDescription[] = languages
@@ -43,10 +50,10 @@ export class FilesViewerTextComponent implements OnInit, OnDestroy {
4350
private readonly maxSize = 5242880 // 5MB
4451

4552
ngOnInit() {
46-
const language: LanguageDescription = LanguageDescription.matchFilename(languages, this.file.name)
47-
if (language?.name || this.file.size <= this.maxSize) {
53+
const language: LanguageDescription = LanguageDescription.matchFilename(languages, this.file().name)
54+
if (language?.name || this.file().size <= this.maxSize) {
4855
this.currentLanguage = language?.name
49-
this.http.get(this.file.dataUrl, { responseType: 'text' }).subscribe((data: string) => (this.content = data))
56+
this.http.get(this.file().dataUrl, { responseType: 'text' }).subscribe((data: string) => (this.content = data))
5057
} else {
5158
this.content = this.layout.translateString('This file contains binary data that can not be read')
5259
}

frontend/src/styles/components/_fixes.scss

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,24 @@ hr {
2525

2626
.progress-bar {
2727
overflow: visible !important;
28+
}
29+
30+
// codemirror
31+
.cm-focused {
32+
outline: none !important;
33+
}
34+
35+
.cm-panel.cm-search {
36+
display: flex;
37+
align-items: center;
38+
39+
label {
40+
display: flex;
41+
align-items: center;
42+
}
43+
44+
button[aria-label="close"] {
45+
right: 10px !important;
46+
font-size: 18px !important;
47+
}
2848
}

0 commit comments

Comments
 (0)