Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chat: add fullscreen toggle (fixes #7227) #7228

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/app/chat/chat.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
<button mat-icon-button (click)="goBack()"><mat-icon>arrow_back</mat-icon></button>
<span i18n>Chat Prompts</span>
<span class="toolbar-fill"></span>
<button mat-icon-button (click)="toggleFullScreen()">
<mat-icon>{{ isFullscreen ? 'fullscreen_exit' : 'fullscreen' }}</mat-icon>
</button>
</mat-toolbar>

<div class="space-container">
<div class="space-container" [ngClass]="{'fullscreen': isFullscreen}">
<div class="chat-container" #chat>
<div *ngFor="let conversation of conversations">
<div class="conversation">
Expand Down
22 changes: 22 additions & 0 deletions src/app/chat/chat.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,25 @@ textarea:focus {
border-color: #007bff;
box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
}

.fullscreen {
.space-container {
height: 100vh;
}

.form-container {
display: none;
}

.chat-container {
flex-grow: 1;
overflow-y: auto;
margin: 0;
}

textarea {
border: 1px solid #ccc;
border-radius: 5px;
box-shadow: none;
}
}
27 changes: 16 additions & 11 deletions src/app/chat/chat.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { ChatService } from '../shared/chat.service';
})
export class ChatComponent implements OnInit {
spinnerOn = true;
isFullscreen = false;
promptForm: FormGroup;
messages: any[] = [];
conversations: any[] = [];
Expand Down Expand Up @@ -83,17 +84,21 @@ export class ChatComponent implements OnInit {
);
}

sanitizeText(text: string): string {
// Replace newline characters with <br> tags
const textWithLineBreaks = text.replace(/\n/g, '<br>');
sanitizeText(text: string): string {
// Replace newline characters with <br> tags
const textWithLineBreaks = text.replace(/\n/g, '<br>');

// Replace code block markers with <code> tags
const codeBlockStart = /```/g;
const codeBlockEnd = /```/g;
const textWithCodeBlocks = textWithLineBreaks
.replace(codeBlockStart, '<code>')
.replace(codeBlockEnd, '</code>');
// Replace code block markers with <code> tags
const codeBlockStart = /```/g;
const codeBlockEnd = /```/g;
const textWithCodeBlocks = textWithLineBreaks
.replace(codeBlockStart, '<code>')
.replace(codeBlockEnd, '</code>');

return textWithCodeBlocks;
}
return textWithCodeBlocks;
}

toggleFullScreen() {
this.isFullscreen = !this.isFullscreen;
}
}