Skip to content

Commit 5446ca1

Browse files
add "Allow switching files" option to the code editor
1 parent c9e3038 commit 5446ca1

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,18 @@
2424
Show preview
2525
</mat-checkbox>
2626
</div>
27+
<div>
28+
<mat-checkbox [(ngModel)]="allowSwitchingFiles" (ngModelChange)="update()">
29+
Allow switching files
30+
</mat-checkbox>
31+
</div>
2732
</div>
2833

2934
<code-demo
3035
[showPreview]="showPreview"
31-
[allowSwitchingFiles]="false"
36+
[allowSwitchingFiles]="allowSwitchingFiles"
3237
[(ngModel)]="code"
38+
[displayFileName]="!allowSwitchingFiles"
3339
(ngModelChange)="update()"
3440
[files]="openFiles"
3541
[ui]="ui"

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export class CodelabCodeDemoConsoleEditorComponent implements OnInit {
2121
@Input() presentationId!: string;
2222
@Input() selectedFiles: SelectableFiles[] = [];
2323
@Input() showPreview = true;
24+
@Input() allowSwitchingFiles = true;
25+
@Input() displayFileName = false;
2426
readonly defaultNewFileName = 'new.ts';
2527

2628
openFiles: string[] = [];
@@ -38,7 +40,8 @@ export class CodelabCodeDemoConsoleEditorComponent implements OnInit {
3840
props: {
3941
code: this.code,
4042
selectedFiles: this.selectedFiles,
41-
showPreview: this.showPreview
43+
showPreview: this.showPreview,
44+
allowSwitchingFiles: this.allowSwitchingFiles
4245
}
4346
});
4447
}

libs/code-demos/src/lib/code-demo/code-demo.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
class="quarter"
44
[enableAutoFolding]="enableAutoFolding"
55
[files]="files"
6+
[displayFileName]="displayFileName"
67
[allowSwitchingFiles]="allowSwitchingFiles"
78
[solutions]="solutions"
89
[(ngModel)]="code"

libs/code-demos/src/lib/code-demo/code-demo.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export class CodeDemoComponent implements ControlValueAccessor, OnDestroy {
6767
@Input() files: string[];
6868
@Input() presets = ['angular'];
6969
@Input() bootstrap = 'bootstrap';
70+
@Input() displayFileName = false;
7071
@Input() solutions: Code = {};
7172
@Input() highlights: Record<string, string | RegExp> = {};
7273
@Input() allowSwitchingFiles = true;

0 commit comments

Comments
 (0)