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

Development: Change the online code editor for students to monaco #8130

Merged
merged 117 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
06dec38
Add monaco dependency; define MonacoEnvironment
pzdr7 Mar 3, 2024
276357c
Configure Monaco on startup
pzdr7 Mar 3, 2024
6fa6170
Implement basic component for monaco editor
pzdr7 Mar 3, 2024
8f138e1
Show monaco editor in UI of online code editor
pzdr7 Mar 3, 2024
e04dcff
Experimental: change builder to application, keeping the output path …
pzdr7 Mar 6, 2024
30cafd1
Force monaco editor to resize itself when its container shrinks
pzdr7 Mar 6, 2024
ff37251
Create basic code editor component with monaco
pzdr7 Mar 6, 2024
ad779e0
Allow changing text / model; embed in grid
pzdr7 Mar 6, 2024
0343773
Allow submitting / saving after editing files
pzdr7 Mar 6, 2024
b6b947c
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Mar 6, 2024
f697df8
Add button for switching between editors
pzdr7 Mar 6, 2024
8549d24
Fix styling in builds
pzdr7 Mar 7, 2024
6d7619e
Adapt monaco theme to Artemis theme
pzdr7 Mar 8, 2024
2e8ffc7
Dispose models when editor is destroyed
pzdr7 Mar 8, 2024
2d65e9d
Add codicons dependency
pzdr7 Mar 8, 2024
2be169e
Add build log annotations to editor
pzdr7 Mar 8, 2024
162ea8a
Fix build log errors not being matched properly
pzdr7 Mar 8, 2024
cd68073
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Mar 9, 2024
9c822b8
Add function to add viewZone+overlayWidget to monaco editor
pzdr7 Mar 9, 2024
b44e431
Render tutor feedback in monaco editor
pzdr7 Mar 9, 2024
ce7e8b8
Provide feedback and course to monaco code editor
pzdr7 Mar 9, 2024
8e3697c
Prevent editing tutor-assessed submissions
pzdr7 Mar 9, 2024
be1a290
Fix alignment of build annotations in monaco
pzdr7 Mar 9, 2024
8002ff5
Redesign build annotations (WIP)
pzdr7 Mar 9, 2024
d2edd83
Remove overlay widgets when model changes
pzdr7 Mar 9, 2024
1a5a4b8
Add helper class for handling build annotations
pzdr7 Mar 10, 2024
1654b6d
Add helper class for handling line widgets
pzdr7 Mar 10, 2024
4a60ade
Hide editor when no file is selected
pzdr7 Mar 10, 2024
57a04f0
Allow changing, editing, and renaming files
pzdr7 Mar 10, 2024
0884df3
Adjust build log model again - entries are not parsed correctly
pzdr7 Mar 10, 2024
fdeb561
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Mar 10, 2024
25eb86c
Fix dependency versions
pzdr7 Mar 10, 2024
7796a3a
Remove css import
pzdr7 Mar 10, 2024
468783a
Use localStorage for annotations (see code-editor-ace)
pzdr7 Mar 10, 2024
df58c63
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Mar 11, 2024
7aee53f
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Mar 11, 2024
cf31d4d
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Mar 12, 2024
017155f
Experimental: support for client testing with Monaco
pzdr7 Mar 12, 2024
25f60b1
Move CodeEditorSwitchEditorButton to code editor module; fix test
pzdr7 Mar 12, 2024
f7f1946
Mark build annotations as outdated on unclean repo
pzdr7 Mar 14, 2024
b371750
Change readOnly to input; remove unused functions
pzdr7 Mar 15, 2024
a7a2547
Add tests for MonacoEditorComponent
pzdr7 Mar 15, 2024
4fd0dd8
Set ID of build annotation DOM node
pzdr7 Mar 15, 2024
6c39cad
Fix naming
pzdr7 Mar 15, 2024
38a1dcc
Basic tests for CodeEditorMonacoComponent
pzdr7 Mar 15, 2024
d14f605
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Mar 15, 2024
522b681
Add more tests for the MonacoEditorComponent
pzdr7 Mar 16, 2024
4746961
Use ngOnDestroy instead of destroy
pzdr7 Mar 16, 2024
556d8d6
Add test for empty model
pzdr7 Mar 16, 2024
10994ff
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Mar 20, 2024
0ba893b
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Mar 22, 2024
72473e7
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Mar 24, 2024
f658720
Update resize observer mock
pzdr7 Mar 24, 2024
fef25d0
Reintroduce header; add ability to hide options menu
pzdr7 Mar 24, 2024
792c96e
Add tests for file content changes and loading
pzdr7 Mar 24, 2024
8117a6b
Improve naming of stubs
pzdr7 Mar 24, 2024
b6d2fe9
Remove unnecessary(?) check for selecting file
pzdr7 Mar 24, 2024
209f14a
Add tests for create, rename, delete file
pzdr7 Mar 24, 2024
7b329b8
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Mar 24, 2024
2780a29
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Mar 26, 2024
44981e2
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Mar 27, 2024
1e1c063
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Mar 27, 2024
06f6bdd
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Mar 27, 2024
e14bd1d
Move switch editor button
pzdr7 Mar 29, 2024
e2ea4ed
Add experimental new classes for inline widgets
pzdr7 Mar 30, 2024
5df4508
Add experimental new classes for annotations
pzdr7 Mar 30, 2024
fb2f848
Add colors for glyph annotations / background color
pzdr7 Mar 31, 2024
d767858
Add behavior for outdated build annotations
pzdr7 Mar 31, 2024
4434852
Remove old widget / annotation classes
pzdr7 Mar 31, 2024
82970de
Fix tests
pzdr7 Mar 31, 2024
9894aae
Refactor: rearrange methods
pzdr7 Mar 31, 2024
05637ff
Handle visibility of overlay widgets with css class
pzdr7 Mar 31, 2024
8da29af
Remove redundant editor option
pzdr7 Mar 31, 2024
93714d2
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Mar 31, 2024
ac8647d
Add explanatory comments to editor models
pzdr7 Mar 31, 2024
a6ace0e
Add comments; remove unused import; refactor array syntax
pzdr7 Mar 31, 2024
6e21ee3
Add comments; remove unused import and method
pzdr7 Mar 31, 2024
fa5102f
Refactor: inlinewidget -> linewidget
pzdr7 Mar 31, 2024
f4821dd
Remove unused button class
pzdr7 Mar 31, 2024
1709a4f
Add explanatory comments for test setup
pzdr7 Mar 31, 2024
ceda65a
Remove unnecessary type definition; import instead
pzdr7 Mar 31, 2024
82c84b1
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Apr 1, 2024
cfa6f8e
Revert changes to build log model
pzdr7 Apr 1, 2024
ca6f1ee
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Apr 1, 2024
1c24b95
Fix refreshing and conflict resolution
pzdr7 Apr 1, 2024
8d4d292
Fix model dispose test
pzdr7 Apr 1, 2024
46e50a9
Cover new cases with tests
pzdr7 Apr 1, 2024
6ae53ca
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Apr 1, 2024
d75ce43
Revert "Revert changes to build log model"
pzdr7 Apr 1, 2024
c562746
Assign unique ID to monaco code editor
pzdr7 Apr 1, 2024
a4ff696
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Apr 1, 2024
24d585c
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Apr 2, 2024
7e1cdf9
Prevent switching editor while editor is unclean
pzdr7 Apr 3, 2024
abab373
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Apr 4, 2024
a31a1cf
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Apr 5, 2024
03645ad
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Apr 5, 2024
cc5e825
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Apr 5, 2024
6c7bb05
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Apr 5, 2024
69039b3
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Apr 6, 2024
59bcc11
e2e: reduce frequency of refreshes for opening programming exercises
pzdr7 Apr 6, 2024
e9aa359
allowSwitchEditor -> useMonacoEditor; remove switch button
pzdr7 Apr 6, 2024
7bde76a
Access Monaco from within Cypress
pzdr7 Apr 6, 2024
460fa2c
Fix integration test
pzdr7 Apr 6, 2024
7eecff4
E2E: Fix student assessment view (feedback no longer restricted to ace)
pzdr7 Apr 6, 2024
294c6bb
E2E: Fix student assessment view
pzdr7 Apr 6, 2024
c249f30
Remove "should initialize" test cases
pzdr7 Apr 6, 2024
a56984f
Move exposed types to top; change string | undefined to string?
pzdr7 Apr 6, 2024
9f87287
Change more | undefined to optional
pzdr7 Apr 6, 2024
cf09129
Mark aceEditor as potentially undefined; make (deprecated) usages rob…
pzdr7 Apr 6, 2024
7527e54
Update code-editor-container.integration tests
pzdr7 Apr 6, 2024
8c824ed
Rework playwright E2E tests to work with Monaco
pzdr7 Apr 7, 2024
e455fb5
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Apr 8, 2024
aaf10d4
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Apr 8, 2024
c7bbbcc
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Apr 8, 2024
07fb3e9
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Apr 8, 2024
c194f9f
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Apr 8, 2024
70b676a
Merge branch 'develop' into feature/programming-exercises/code-editor…
pzdr7 Apr 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
"base": "build/resources/main/static/",
"browser": ""
},
"loader": {
".ttf": "file"
},
"index": "src/main/webapp/index.html",
"browser": "src/main/webapp/app/app.main.ts",
"polyfills": [
Expand Down Expand Up @@ -108,6 +111,11 @@
"glob": "**/*",
"input": "src/main/webapp/swagger-ui/",
"output": "swagger-ui"
},
{
"glob": "**/*",
"input": "./node_modules/monaco-editor/min/vs",
"output": "vs"
}
],
"styles": [
Expand All @@ -116,7 +124,8 @@
"bundleName": "theme-dark",
"input": "src/main/webapp/content/scss/themes/theme-dark.scss",
"inject": false
}
},
"node_modules/monaco-editor/min/vs/editor/editor.main.css"
],
"scripts": []
},
Expand Down
3 changes: 3 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const esModules = [
'franc-min',
'internmap',
'lodash-es',
'monaco-editor',
'n-gram',
'ngx-device-detector',
'ngx-infinite-scroll',
Expand Down Expand Up @@ -148,5 +149,7 @@ module.exports = {
'@state/(.*)': '<rootDir>/src/app/state/$1',
'^lodash-es$': 'lodash',
'@sentry/angular-ivy': '<rootDir>/node_modules/@sentry/angular-ivy/bundles/sentry-angular-ivy.umd.js',
'\\.css$': '<rootDir>/stub.js',
'^monaco-editor$': '<rootDir>/node_modules/monaco-editor/esm/vs/editor/editor.api.js',
},
};
12 changes: 12 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"@sentry/types": "7.109.0",
"@swimlane/ngx-charts": "20.5.0",
"@swimlane/ngx-graph": "8.3.0",
"@vscode/codicons": "0.0.35",
"ace-builds": "1.32.9",
"bootstrap": "5.3.3",
"brace": "0.11.1",
Expand All @@ -60,6 +61,7 @@
"jszip": "3.10.1",
"lodash-es": "4.17.21",
"mobile-drag-drop": "3.0.0-rc.0",
"monaco-editor": "0.46.0",
"ngx-infinite-scroll": "17.0.0",
"ngx-webstorage": "13.0.1",
"papaparse": "5.4.1",
Expand Down
3 changes: 3 additions & 0 deletions src/main/webapp/app/app.main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'app/shared/util/string.extension';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { ProdConfig } from './core/config/prod.config';
import { ArtemisAppModule } from './app.module';
import { MonacoConfig } from 'app/core/config/monaco.config';

ProdConfig();

Expand All @@ -15,6 +16,8 @@ if (module['hot']) {
}
}

MonacoConfig();

platformBrowserDynamic()
.bootstrapModule(ArtemisAppModule, { preserveWhitespaces: true })
.then(() => {})
Expand Down
19 changes: 19 additions & 0 deletions src/main/webapp/app/core/config/monaco.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Sets up the MonacoEnvironment for the monaco editor's service worker.
*/
export function MonacoConfig() {
self.MonacoEnvironment = {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
getWorkerUrl: function (workerId: string, label: string) {
/*
* This is the AMD-based service worker, which comes bundled with a few special workers for selected languages.
* (e.g.: javascript, typescript, html, css)
*
* It is also possible to use an ESM-based approach, which requires a little more setup and case distinctions in this method.
* At the moment, it seems that the ESM-based approaches are incompatible with the Artemis client, as they would require custom builders.
* Support for custom builders was removed in #6546.
*/
return 'vs/base/worker/workerMain.js';
},
};
}
2 changes: 1 addition & 1 deletion src/main/webapp/app/entities/build-log.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class BuildLogEntryArray extends Array<BuildLogEntry> {
return Array.from(
this
// Parse build logs
.map(({ log, time }) => ({ log: log.match(errorLogRegex), time }))
.map(({ log, time }) => ({ log: log.split('\n', 1)[0].trim().match(errorLogRegex), time }))
// Remove entries that could not be parsed, are too short or not errors
.filter(({ log }: { log: ParsedLogEntry | null; time: string }) => {
// Java logs do not always contain "ERROR"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ <h4 class="mb-0 me-1">Online Code Editor</h4>
}
</div>
<jhi-code-editor-container
[useMonacoEditor]="true"
[editable]="!repositoryIsLocked"
[participation]="studentParticipation"
[showEditorInstructions]="showEditorInstructions"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ export class CodeEditorTutorAssessmentContainerComponent implements OnInit, OnDe
* @param selectedFile name of the file which is currently displayed
*/
onFileLoad(selectedFile: string): void {
if (selectedFile && this.codeEditorContainer?.selectedFile) {
if (selectedFile && this.codeEditorContainer?.selectedFile && this.codeEditorContainer.aceEditor) {
// When the selectedFile is not part of the template, then this is a new file and all lines in code editor are highlighted
if (!this.templateFileSession[selectedFile]) {
const lastLine = this.codeEditorContainer.aceEditor.editorSession.getLength() - 1;
Expand Down Expand Up @@ -337,7 +337,9 @@ export class CodeEditorTutorAssessmentContainerComponent implements OnInit, OnDe
}

private highlightLines(firstLine: number, lastLine: number) {
this.codeEditorContainer.aceEditor.highlightLines(firstLine, lastLine, 'diff-newLine', 'gutter-diff-newLine');
if (this.codeEditorContainer?.aceEditor) {
this.codeEditorContainer.aceEditor.highlightLines(firstLine, lastLine, 'diff-newLine', 'gutter-diff-newLine');
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class CodeEditorInstructorAndEditorContainerComponent extends CodeEditorI
for (const path of reloadPaths) {
this.codeEditorContainer.fileBrowser.handleFileChange(new CreateFileChange(FileType.FILE, path));
}
this.codeEditorContainer.aceEditor.forceReloadAll(reloadPaths);
this.codeEditorContainer.aceEditor?.forceReloadAll(reloadPaths);
}
}
const widget = this.chatbotButton?.dialogRef?.componentRef?.instance; // Access the widget via the button even if it is not open
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
}
@if (!loadingParticipation && !participationCouldNotBeFetched) {
<jhi-code-editor-container
[useMonacoEditor]="true"
[editable]="!repositoryIsLocked"
[participation]="participation"
[showEditorInstructions]="showEditorInstructions"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { TreeviewModule } from 'app/exercises/programming/shared/code-editor/treeview/treeview.module';
import { CodeEditorHeaderComponent } from 'app/exercises/programming/shared/code-editor/header/code-editor-header.component';
import { CodeEditorFileBrowserBadgeComponent } from 'app/exercises/programming/shared/code-editor/file-browser/code-editor-file-browser-badge.component';
import { MonacoEditorModule } from 'app/shared/monaco-editor/monaco-editor.module';
import { CodeEditorMonacoComponent } from 'app/exercises/programming/shared/code-editor/monaco/code-editor-monaco.component';
import { ArtemisSharedComponentModule } from 'app/shared/components/shared-component.module';

@NgModule({
imports: [
Expand All @@ -33,6 +36,8 @@ import { CodeEditorFileBrowserBadgeComponent } from 'app/exercises/programming/s
TreeviewModule.forRoot(),
ArtemisProgrammingExerciseInstructionsEditorModule,
ArtemisProgrammingManualAssessmentModule,
MonacoEditorModule,
ArtemisSharedComponentModule,
],
declarations: [
CodeEditorGridComponent,
Expand All @@ -52,6 +57,7 @@ import { CodeEditorFileBrowserBadgeComponent } from 'app/exercises/programming/s
CodeEditorConfirmRefreshModalComponent,
CodeEditorContainerComponent,
CodeEditorHeaderComponent,
CodeEditorMonacoComponent,
],
exports: [
CodeEditorGridComponent,
Expand All @@ -63,6 +69,7 @@ import { CodeEditorFileBrowserBadgeComponent } from 'app/exercises/programming/s
CodeEditorBuildOutputComponent,
CodeEditorContainerComponent,
CodeEditorHeaderComponent,
CodeEditorMonacoComponent,
],
providers: [],
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,43 @@ <h4 class="editor-title"><ng-content select="[editorTitle]" /></h4>
(onError)="onError($event)"
(onToggleCollapse)="onToggleCollapse($event, CollapsableCodeEditorElement.FileBrowser)"
/>
<jhi-code-editor-ace
editorCenter
[selectedFile]="selectedFile!"
[sessionId]="participation?.id ?? 'test'"
[annotations]="annotations"
[commitState]="commitState"
[editorState]="editorState"
[feedbacks]="participation?.results?.[0]?.feedbacks ?? []"
[feedbackSuggestions]="feedbackSuggestions"
[readOnlyManualFeedback]="readOnlyManualFeedback"
[isTutorAssessment]="isTutorAssessment"
[highlightDifferences]="highlightDifferences"
[course]="course"
[disableActions]="!editable"
(onFileContentChange)="onFileContentChange($event)"
(onUpdateFeedback)="onUpdateFeedback.emit($event)"
(onAcceptSuggestion)="onAcceptSuggestion.emit($event)"
(onDiscardSuggestion)="onDiscardSuggestion.emit($event)"
(onError)="onError($event)"
(onFileLoad)="fileLoad($event)"
/>
<ng-container editorCenter>
@if (!useMonacoEditor) {
<jhi-code-editor-ace
[selectedFile]="selectedFile!"
[sessionId]="participation?.id ?? 'test'"
[annotations]="annotations"
[commitState]="commitState"
[editorState]="editorState"
[feedbacks]="participation?.results?.[0]?.feedbacks ?? []"
[feedbackSuggestions]="feedbackSuggestions"
[readOnlyManualFeedback]="readOnlyManualFeedback"
[isTutorAssessment]="isTutorAssessment"
[highlightDifferences]="highlightDifferences"
[course]="course"
[disableActions]="!editable"
(onFileContentChange)="onFileContentChange($event)"
(onUpdateFeedback)="onUpdateFeedback.emit($event)"
(onAcceptSuggestion)="onAcceptSuggestion.emit($event)"
(onDiscardSuggestion)="onDiscardSuggestion.emit($event)"
(onError)="onError($event)"
(onFileLoad)="fileLoad($event)"
/>
} @else {
<jhi-code-editor-monaco
#codeEditorMonaco
[commitState]="commitState"
[editorState]="editorState"
[course]="course"
[feedbacks]="participation?.results?.[0]?.feedbacks ?? []"
[isTutorAssessment]="isTutorAssessment"
[selectedFile]="selectedFile"
[buildAnnotations]="annotations"
[sessionId]="participation?.id ?? 'test'"
(onFileContentChange)="onFileContentChange($event)"
/>
}
</ng-container>
<ng-container editorSidebarRight>
@if (showEditorInstructions) {
<jhi-code-editor-instructions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { CodeEditorInstructionsComponent } from 'app/exercises/programming/share
import { Feedback } from 'app/entities/feedback.model';
import { Course } from 'app/entities/course.model';
import { ConnectionError } from 'app/exercises/programming/shared/code-editor/service/code-editor-repository.service';
import { CodeEditorMonacoComponent } from 'app/exercises/programming/shared/code-editor/monaco/code-editor-monaco.component';

export enum CollapsableCodeEditorElement {
FileBrowser,
Expand All @@ -40,13 +41,15 @@ export enum CollapsableCodeEditorElement {
})
export class CodeEditorContainerComponent implements OnChanges, ComponentCanDeactivate {
readonly CommitState = CommitState;
readonly EditorState = EditorState;
readonly CollapsableCodeEditorElement = CollapsableCodeEditorElement;
@ViewChild(CodeEditorGridComponent, { static: false }) grid: CodeEditorGridComponent;

@ViewChild(CodeEditorFileBrowserComponent, { static: false }) fileBrowser: CodeEditorFileBrowserComponent;
@ViewChild(CodeEditorActionsComponent, { static: false }) actions: CodeEditorActionsComponent;
@ViewChild(CodeEditorBuildOutputComponent, { static: false }) buildOutput: CodeEditorBuildOutputComponent;
@ViewChild(CodeEditorAceComponent, { static: false }) aceEditor: CodeEditorAceComponent;
@ViewChild(CodeEditorAceComponent, { static: false }) aceEditor?: CodeEditorAceComponent;
@ViewChild('codeEditorMonaco', { static: false }) monacoEditor?: CodeEditorMonacoComponent;
@ViewChild(CodeEditorInstructionsComponent, { static: false }) instructions: CodeEditorInstructionsComponent;

@Input()
Expand All @@ -67,6 +70,8 @@ export class CodeEditorContainerComponent implements OnChanges, ComponentCanDeac
highlightDifferences: boolean;
@Input()
disableAutoSave = false;
@Input()
useMonacoEditor = false;

@Output()
onResizeEditorInstructions = new EventEmitter<void>();
Expand Down Expand Up @@ -196,7 +201,9 @@ export class CodeEditorContainerComponent implements OnChanges, ComponentCanDeac
if (_isEmpty(this.unsavedFiles) && this.editorState === EditorState.UNSAVED_CHANGES) {
this.editorState = EditorState.CLEAN;
}
this.aceEditor.onFileChange(fileChange);
this.monacoEditor?.onFileChange(fileChange);
this.aceEditor?.onFileChange(fileChange);

this.onFileChanged.emit();
}

Expand All @@ -218,7 +225,8 @@ export class CodeEditorContainerComponent implements OnChanges, ComponentCanDeac
if (errorFiles.length) {
this.onError('saveFailed');
}
this.aceEditor.storeAnnotations(savedFiles);
this.aceEditor?.storeAnnotations(savedFiles);
this.monacoEditor?.storeAnnotations(savedFiles);
}

/**
Expand Down Expand Up @@ -280,7 +288,7 @@ export class CodeEditorContainerComponent implements OnChanges, ComponentCanDeac
if (type === ResizeType.SIDEBAR_RIGHT || type === ResizeType.MAIN_BOTTOM) {
this.onResizeEditorInstructions.emit();
}
if (type === ResizeType.SIDEBAR_LEFT || type === ResizeType.SIDEBAR_RIGHT || type === ResizeType.MAIN_BOTTOM) {
if (this.aceEditor && (type === ResizeType.SIDEBAR_LEFT || type === ResizeType.SIDEBAR_RIGHT || type === ResizeType.MAIN_BOTTOM)) {
this.aceEditor.editor.getEditor().resize();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ <h3 class="mt-1 card-title">
<fa-icon [icon]="faCircleNotch" [spin]="true" class="ms-2" title="{{ 'artemisApp.editor.loadingFile' | artemisTranslate }}" />
}
</h3>
<div ngbDropdown class="ms-2" placement="bottom-end auto" [autoClose]="'outside'" aria-label="Code Editor Settings">
<button ngbDropdownToggle class="btn btn-sm btn-primary" type="button" id="dropdownCodeEditorSettings" aria-expanded="false">
<fa-icon [icon]="faGear" />
</button>
<div ngbDropdownMenu aria-labelledby="dropdownCodeEditorSettings">
<div ngbDropdownItem class="d-flex">
<span class="dropdown-item" jhiTranslate="artemisApp.editor.tabSize"></span>
<input class="form-control-sm" type="number" min="1" [max]="MAX_TAB_SIZE" step="1" size="1" [(ngModel)]="tabSize" (change)="validateTabSize()" />
@if (showTabSizeSelector) {
<div ngbDropdown class="ms-2" placement="bottom-end auto" [autoClose]="'outside'" aria-label="Code Editor Settings">
<button ngbDropdownToggle class="btn btn-sm btn-primary" type="button" id="dropdownCodeEditorSettings" aria-expanded="false">
<fa-icon [icon]="faGear" />
</button>
<div ngbDropdownMenu aria-labelledby="dropdownCodeEditorSettings">
<div ngbDropdownItem class="d-flex">
<span class="dropdown-item" jhiTranslate="artemisApp.editor.tabSize"></span>
<input class="form-control-sm" type="number" min="1" [max]="MAX_TAB_SIZE" step="1" size="1" [(ngModel)]="tabSize" (change)="validateTabSize()" />
</div>
</div>
</div>
</div>
}
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export class CodeEditorHeaderComponent {
@Input()
isLoading: boolean;

@Input()
showTabSizeSelector = true;

@Output()
tabSizeChanged = new EventEmitter<number>();

Expand Down
Loading
Loading