Skip to content

Commit d88d359

Browse files
committed
chore(frontend:files): align search box in CodeMirror and use Angular signals
1 parent 3294567 commit d88d359

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

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

Lines changed: 7 additions & 7 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,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
})
3333
export 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
}

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)