Skip to content

Commit 1e38639

Browse files
Allow to select files for the code editor
1 parent cf6c06a commit 1e38639

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

apps/codelab/src/app/admin/content/presentation-editor/slide-editor/action-bar/action-bar.component.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ export class ActionBarComponent {
1717
code: { 'app.ts': '// Type your code here!' }
1818
},
1919
angularApp: {
20-
code: { 'app.ts': '// Angular app!!' }
20+
code: {
21+
'app.ts': '// Angular app!!',
22+
'component.ts': '// C',
23+
'module.ts': '// M'
24+
}
2125
}
2226
};
2327

Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1+
<mat-form-field *ngIf="files.length > 1">
2+
<mat-label>Selected File</mat-label>
3+
<mat-select [(ngModel)]="selectedFiles" multiple (ngModelChange)="update()">
4+
<mat-option *ngFor="let file of files" [value]="file">
5+
{{ file }}
6+
</mat-option>
7+
</mat-select>
8+
</mat-form-field>
9+
110
<code-demo
211
[allowSwitchingFiles]="false"
312
[(ngModel)]="code"
413
(ngModelChange)="update()"
5-
[files]="files"
14+
[files]="selectedFiles"
615
[ui]="ui"
716
[bootstrap]="false"
817
></code-demo>

apps/codelab/src/app/admin/content/presentation-editor/wrappers/custom-component-editors/codelab-code-demo-console/codelab-code-demo-console.component.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, Input, OnInit } from '@angular/core';
1+
import { Component, Input } from '@angular/core';
22
import { ContentService } from '../../../services/content.service';
33
import { ContentSlide, CustomBlock } from '../../../types';
44

@@ -8,20 +8,25 @@ import { ContentSlide, CustomBlock } from '../../../types';
88
styleUrls: ['./codelab-code-demo-console.component.css']
99
})
1010
export class CodelabCodeDemoConsoleComponent {
11-
@Input() files = ['app.ts'];
11+
files = ['app.ts'];
1212
@Input() code = {};
1313
@Input() ui = 'browser';
1414
@Input() block!: CustomBlock;
1515
@Input() slide!: ContentSlide;
1616
@Input() presentationId!: string;
17+
@Input() selectedFiles = [];
1718

1819
constructor(private readonly contentService: ContentService) {}
1920

2021
update() {
22+
this.files = Object.keys(this.code);
23+
this.selectedFiles =
24+
this.selectedFiles.length === 0 ? [this.files[0]] : this.selectedFiles;
2125
this.contentService.updateBlock(this.presentationId, this.slide.id, {
2226
...this.block,
2327
props: {
24-
code: this.code
28+
code: this.code,
29+
selectedFiles: this.selectedFiles
2530
}
2631
});
2732
}

0 commit comments

Comments
 (0)