MCPcopy Create free account
hub / github.com/angular/angular / EmbeddedEditor

Class EmbeddedEditor

adev/src/app/editor/embedded-editor.component.ts:61–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59 providers: [EditorUiState],
60})
61export class EmbeddedEditor {
62 // Prevents from adding, removing or renaming files
63 readonly restrictedMode = input<boolean>(false);
64
65 readonly editorContainer = viewChild<ElementRef<HTMLDivElement>>('editorContainer');
66 readonly matTabGroup = viewChild(MatTabGroup);
67
68 private readonly platformId = inject(PLATFORM_ID);
69 private readonly destroyRef = inject(DestroyRef);
70
71 private readonly diagnosticsState = inject(DiagnosticsState);
72 readonly editorUiState = inject(EditorUiState);
73 private readonly nodeRuntimeState = inject(NodeRuntimeState);
74 private readonly nodeRuntimeSandbox = inject(NodeRuntimeSandbox);
75
76 protected readonly splitDirection = signal<'horizontal' | 'vertical'>('vertical');
77
78 readonly MAX_RECOMMENDED_WEBCONTAINERS_INSTANCES = MAX_RECOMMENDED_WEBCONTAINERS_INSTANCES;
79
80 protected readonly TerminalType = TerminalType;
81 protected readonly displayOnlyTerminal = computed(
82 () => this.editorUiState.tutorialType() === TutorialType.CLI,
83 );
84 protected readonly displayPreviewInMatTabGroup = signal<boolean>(true);
85 protected readonly selectedTabIndex = linkedSignal({
86 source: () => this.displayPreviewInMatTabGroup(),
87 computation: () => 0,
88 });
89
90 protected readonly shouldEnableReset = computed(
91 () =>
92 this.nodeRuntimeState.loadingStep() > LoadingStep.BOOT &&
93 !this.nodeRuntimeState.isResetting(),
94 );
95
96 private readonly errorsCount$ = this.diagnosticsState.diagnostics$.pipe(
97 map((diagnosticsItem) => diagnosticsItem.filter((item) => item.severity === 'error').length),
98 );
99 protected readonly errorsCount = toSignal(this.errorsCount$, {initialValue: 0});
100
101 constructor() {
102 if (!isPlatformBrowser(this.platformId)) {
103 return;
104 }
105
106 const ref = afterRenderEffect({
107 read: () => {
108 const container = this.editorContainer()?.nativeElement;
109 if (!container) {
110 return;
111 }
112 this.setResizeObserver(container);
113 ref.destroy();
114 },
115 });
116 }
117
118 protected async reset(): Promise<void> {

Callers

nothing calls this directly

Calls 7

injectFunction · 0.90
signalFunction · 0.90
computedFunction · 0.90
linkedSignalFunction · 0.90
toSignalFunction · 0.90
inputFunction · 0.85
filterMethod · 0.45

Tested by

no test coverage detected