From d3eb39b141ccfa24e39b80ac9aeaf937d0b4322e Mon Sep 17 00:00:00 2001 From: Patrik Zander Date: Fri, 30 Aug 2024 21:27:25 +0200 Subject: [PATCH 01/27] Add type aliases --- .../monaco-channel-reference.action.ts | 12 ++-- .../monaco-exercise-reference.action.ts | 12 ++-- ...aco-lecture-attachment-reference.action.ts | 12 ++-- .../monaco-user-mention.action.ts | 12 ++-- .../monaco-grading-credits.action.ts | 4 +- .../monaco-grading-criterion.action.ts | 4 +- .../monaco-grading-description.action.ts | 4 +- .../monaco-grading-feedback.action.ts | 4 +- .../monaco-grading-instruction.action.ts | 4 +- .../monaco-grading-scale.action.ts | 4 +- .../monaco-grading-usage-count.action.ts | 4 +- .../model/actions/monaco-attachment.action.ts | 4 +- .../model/actions/monaco-bold.action.ts | 6 +- .../model/actions/monaco-code-block.action.ts | 4 +- .../model/actions/monaco-code.action.ts | 4 +- .../model/actions/monaco-color.action.ts | 4 +- .../actions/monaco-editor-action.model.ts | 61 ++++++++++--------- .../monaco-editor-domain-action.model.ts | 4 +- .../model/actions/monaco-editor.util.ts | 17 ++++++ .../model/actions/monaco-formula.action.ts | 4 +- .../model/actions/monaco-fullscreen.action.ts | 4 +- .../model/actions/monaco-heading.action.ts | 4 +- .../model/actions/monaco-italic.action.ts | 6 +- .../actions/monaco-ordered-list.action.ts | 17 ++++-- .../model/actions/monaco-quote.action.ts | 4 +- .../model/actions/monaco-task.action.ts | 4 +- .../model/actions/monaco-test-case.action.ts | 5 +- .../model/actions/monaco-underline.action.ts | 6 +- .../actions/monaco-unordered-list.action.ts | 12 ++-- .../model/actions/monaco-url.action.ts | 4 +- ...o-correct-multiple-choice-answer.action.ts | 4 +- ...onaco-insert-short-answer-option.action.ts | 4 +- .../monaco-insert-short-answer-spot.action.ts | 4 +- .../quiz/monaco-quiz-explanation.action.ts | 4 +- .../actions/quiz/monaco-quiz-hint.action.ts | 4 +- ...aco-wrong-multiple-choice-answer.action.ts | 4 +- 36 files changed, 149 insertions(+), 125 deletions(-) create mode 100644 src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor.util.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts index 35f30e7e709d..417ecfea5648 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts @@ -1,11 +1,11 @@ import { faHashtag } from '@fortawesome/free-solid-svg-icons'; import { TranslateService } from '@ngx-translate/core'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; -import * as monaco from 'monaco-editor'; import { ChannelIdAndNameDTO } from 'app/entities/metis/conversation/channel.model'; import { MetisService } from 'app/shared/metis/metis.service'; import { ChannelService } from 'app/shared/metis/conversations/channel.service'; import { firstValueFrom } from 'rxjs'; +import { CompletionItemKind, DisposableEditorElement, MonacoEditorRange, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; /** * Action to insert a reference to a channel into the editor. Users that type a # will see a list of available channels to reference. @@ -15,7 +15,7 @@ export class MonacoChannelReferenceAction extends MonacoEditorAction { static readonly DEFAULT_INSERT_TEXT = '#'; cachedChannels?: ChannelIdAndNameDTO[]; - disposableCompletionProvider?: monaco.IDisposable; + disposableCompletionProvider?: DisposableEditorElement; constructor( private readonly metisService: MetisService, @@ -29,14 +29,14 @@ export class MonacoChannelReferenceAction extends MonacoEditorAction { * @param editor The editor to register the action in. * @param translateService The translate service to use for translations, e.g. the label. */ - register(editor: monaco.editor.IStandaloneCodeEditor, translateService: TranslateService) { + register(editor: MonacoEditorWithActions, translateService: TranslateService) { super.register(editor, translateService); this.disposableCompletionProvider = this.registerCompletionProviderForCurrentModel( editor, this.fetchChannels.bind(this), - (channel: ChannelIdAndNameDTO, range: monaco.IRange) => ({ + (channel: ChannelIdAndNameDTO, range: MonacoEditorRange) => ({ label: `#${channel.name}`, - kind: monaco.languages.CompletionItemKind.Constant, + kind: CompletionItemKind.Constant, insertText: `[channel]${channel.name}(${channel.id})[/channel]`, range, detail: this.label, @@ -49,7 +49,7 @@ export class MonacoChannelReferenceAction extends MonacoEditorAction { * Types the text '#' into the editor and focuses it. This will trigger the completion provider to show the available channels. * @param editor The editor to type the text into. */ - run(editor: monaco.editor.ICodeEditor) { + run(editor: MonacoEditorWithActions) { this.typeText(editor, MonacoChannelReferenceAction.DEFAULT_INSERT_TEXT); editor.focus(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action.ts index 846241c6dd94..5cb824c05842 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action.ts @@ -1,8 +1,8 @@ import { TranslateService } from '@ngx-translate/core'; -import * as monaco from 'monaco-editor'; import { MetisService } from 'app/shared/metis/metis.service'; import { MonacoEditorDomainActionWithOptions } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action-with-options.model'; import { ValueItem } from 'app/shared/markdown-editor/value-item.model'; +import { CompletionItemKind, DisposableEditorElement, MonacoEditorRange, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; /** * Action to insert a reference to an exercise into the editor. Users that type a / will see a list of available exercises to reference. @@ -11,7 +11,7 @@ export class MonacoExerciseReferenceAction extends MonacoEditorDomainActionWithO static readonly ID = 'monaco-exercise-reference.action'; static readonly DEFAULT_INSERT_TEXT = '/exercise'; - disposableCompletionProvider?: monaco.IDisposable; + disposableCompletionProvider?: DisposableEditorElement; constructor(private readonly metisService: MetisService) { super(MonacoExerciseReferenceAction.ID, 'artemisApp.metis.editor.exercise'); @@ -22,7 +22,7 @@ export class MonacoExerciseReferenceAction extends MonacoEditorDomainActionWithO * @param editor The editor to register the completion provider for. * @param translateService The translate service to use for translations. */ - register(editor: monaco.editor.IStandaloneCodeEditor, translateService: TranslateService): void { + register(editor: MonacoEditorWithActions, translateService: TranslateService): void { super.register(editor, translateService); const exercises = this.metisService.getCourse().exercises ?? []; this.setValues( @@ -35,9 +35,9 @@ export class MonacoExerciseReferenceAction extends MonacoEditorDomainActionWithO this.disposableCompletionProvider = this.registerCompletionProviderForCurrentModel( editor, () => Promise.resolve(this.getValues()), - (item: ValueItem, range: monaco.IRange) => ({ + (item: ValueItem, range: MonacoEditorRange) => ({ label: `/exercise ${item.value}`, - kind: monaco.languages.CompletionItemKind.Constant, + kind: CompletionItemKind.Constant, insertText: `[${item.type}]${item.value}(${this.metisService.getLinkForExercise(item.id)})[/${item.type}]`, range, detail: item.type!, @@ -50,7 +50,7 @@ export class MonacoExerciseReferenceAction extends MonacoEditorDomainActionWithO * Types the text '/exercise' into the editor and focuses it. This will trigger the completion provider to show the available exercises. * @param editor The editor to type the text into. */ - run(editor: monaco.editor.ICodeEditor): void { + run(editor: MonacoEditorWithActions): void { this.typeText(editor, MonacoExerciseReferenceAction.DEFAULT_INSERT_TEXT); editor.focus(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-lecture-attachment-reference.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-lecture-attachment-reference.action.ts index 67c4ca774656..a9c532dc3c15 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-lecture-attachment-reference.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-lecture-attachment-reference.action.ts @@ -1,5 +1,4 @@ import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; -import * as monaco from 'monaco-editor'; import { MetisService } from 'app/shared/metis/metis.service'; import { firstValueFrom } from 'rxjs'; import { LectureService } from 'app/lecture/lecture.service'; @@ -8,6 +7,7 @@ import { AttachmentUnit } from 'app/entities/lecture-unit/attachmentUnit.model'; import { Attachment } from 'app/entities/attachment.model'; import { Slide } from 'app/entities/lecture-unit/slide.model'; import { LectureUnitType } from 'app/entities/lecture-unit/lectureUnit.model'; +import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; interface LectureWithDetails { id: number; @@ -71,7 +71,7 @@ export class MonacoLectureAttachmentReferenceAction extends MonacoEditorAction { * @param editor The editor to insert the reference in. * @param args An object containing the item to reference and the type of reference. */ - run(editor: monaco.editor.ICodeEditor, args?: LectureAttachmentReferenceActionArgs): void { + run(editor: MonacoEditorWithActions, args?: LectureAttachmentReferenceActionArgs): void { switch (args?.reference) { case ReferenceType.LECTURE: this.insertLectureReference(editor, args.lecture); @@ -108,23 +108,23 @@ export class MonacoLectureAttachmentReferenceAction extends MonacoEditorAction { this.lecturesWithDetails = []; } - insertLectureReference(editor: monaco.editor.ICodeEditor, lecture: LectureWithDetails): void { + insertLectureReference(editor: MonacoEditorWithActions, lecture: LectureWithDetails): void { this.replaceTextAtCurrentSelection(editor, `[lecture]${lecture.title}(${this.metisService.getLinkForLecture(lecture.id.toString())})[/lecture]`); } - insertAttachmentReference(editor: monaco.editor.ICodeEditor, attachment: Attachment): void { + insertAttachmentReference(editor: MonacoEditorWithActions, attachment: Attachment): void { const shortLink = attachment.link?.split('attachments/')[1]; this.replaceTextAtCurrentSelection(editor, `[attachment]${attachment.name}(${shortLink})[/attachment]`); } - insertSlideReference(editor: monaco.editor.ICodeEditor, attachmentUnit: AttachmentUnit, slide: Slide): void { + insertSlideReference(editor: MonacoEditorWithActions, attachmentUnit: AttachmentUnit, slide: Slide): void { const shortLink = slide.slideImagePath?.split('attachments/')[1]; // Remove the trailing slash and the file name. const shortLinkWithoutFileName = shortLink?.replace(new RegExp(`[^/]*${'.png'}`), '').replace(/\/$/, ''); this.replaceTextAtCurrentSelection(editor, `[slide]${attachmentUnit.name} Slide ${slide.slideNumber}(${shortLinkWithoutFileName})[/slide]`); } - insertAttachmentUnitReference(editor: monaco.editor.ICodeEditor, attachmentUnit: AttachmentUnit): void { + insertAttachmentUnitReference(editor: MonacoEditorWithActions, attachmentUnit: AttachmentUnit): void { const shortLink = attachmentUnit.attachment?.link!.split('attachments/')[1]; this.replaceTextAtCurrentSelection(editor, `[lecture-unit]${attachmentUnit.name}(${shortLink})[/lecture-unit]`); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts index 7309715dbff0..2ff88037a6f3 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts @@ -1,18 +1,18 @@ import { faAt } from '@fortawesome/free-solid-svg-icons'; import { TranslateService } from '@ngx-translate/core'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; -import * as monaco from 'monaco-editor'; import { CourseManagementService } from 'app/course/manage/course-management.service'; import { MetisService } from 'app/shared/metis/metis.service'; import { firstValueFrom } from 'rxjs'; import { UserNameAndLoginDTO } from 'app/core/user/user.model'; +import { CompletionItemKind, DisposableEditorElement, MonacoEditorRange, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; /** * Action to insert a user mention into the editor. Users that type a @ will see a list of available users to mention. * Users will be fetched repeatedly as the user types to provide up-to-date results. */ export class MonacoUserMentionAction extends MonacoEditorAction { - disposableCompletionProvider?: monaco.IDisposable; + disposableCompletionProvider?: DisposableEditorElement; static readonly ID = 'monaco-user-mention.action'; static readonly DEFAULT_INSERT_TEXT = '@'; @@ -29,14 +29,14 @@ export class MonacoUserMentionAction extends MonacoEditorAction { * @param editor The editor to register the action in. * @param translateService The translate service to use for translations, e.g. the label. */ - register(editor: monaco.editor.IStandaloneCodeEditor, translateService: TranslateService) { + register(editor: MonacoEditorWithActions, translateService: TranslateService) { super.register(editor, translateService); this.disposableCompletionProvider = this.registerCompletionProviderForCurrentModel( editor, this.loadUsersForSearchTerm.bind(this), - (user: UserNameAndLoginDTO, range: monaco.IRange) => ({ + (user: UserNameAndLoginDTO, range: MonacoEditorRange) => ({ label: `@${user.name}`, - kind: monaco.languages.CompletionItemKind.User, + kind: CompletionItemKind.User, insertText: `[user]${user.name}(${user.login})[/user]`, range, detail: this.label, @@ -50,7 +50,7 @@ export class MonacoUserMentionAction extends MonacoEditorAction { * Types the text '@' into the editor and focuses it. This will trigger the completion provider to show the available users. * @param editor The editor to type the text into. */ - run(editor: monaco.editor.ICodeEditor) { + run(editor: MonacoEditorWithActions) { this.typeText(editor, MonacoUserMentionAction.DEFAULT_INSERT_TEXT); editor.focus(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-credits.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-credits.action.ts index 200a239de9ee..427a9776a275 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-credits.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-credits.action.ts @@ -1,5 +1,5 @@ import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; -import * as monaco from 'monaco-editor'; +import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; export class MonacoGradingCreditsAction extends MonacoEditorDomainAction { static readonly ID = 'monaco-grading-credits.action'; @@ -10,7 +10,7 @@ export class MonacoGradingCreditsAction extends MonacoEditorDomainAction { super(MonacoGradingCreditsAction.ID, 'artemisApp.assessmentInstructions.instructions.editor.addCredits', undefined, undefined, true); } - run(editor: monaco.editor.ICodeEditor): void { + run(editor: MonacoEditorWithActions): void { this.addTextWithDomainActionIdentifier(editor, MonacoGradingCreditsAction.TEXT, true, false); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-criterion.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-criterion.action.ts index 02302850bca5..3a11eb795f02 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-criterion.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-criterion.action.ts @@ -1,6 +1,6 @@ -import * as monaco from 'monaco-editor'; import { MonacoEditorDomainAction } from '../monaco-editor-domain-action.model'; import { MonacoGradingInstructionAction } from './monaco-grading-instruction.action'; +import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; export class MonacoGradingCriterionAction extends MonacoEditorDomainAction { static readonly ID = 'monaco-grading-criterion.action'; @@ -11,7 +11,7 @@ export class MonacoGradingCriterionAction extends MonacoEditorDomainAction { super(MonacoGradingCriterionAction.ID, 'artemisApp.assessmentInstructions.instructions.editor.addCriterion'); } - run(editor: monaco.editor.ICodeEditor): void { + run(editor: MonacoEditorWithActions): void { this.addTextWithDomainActionIdentifier(editor, MonacoGradingCriterionAction.TEXT, false, false); this.gradingInstructionAction.executeInCurrentEditor(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-description.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-description.action.ts index f04d861cb4d7..b255b10a9625 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-description.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-description.action.ts @@ -1,5 +1,5 @@ -import * as monaco from 'monaco-editor'; import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; +import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; export class MonacoGradingDescriptionAction extends MonacoEditorDomainAction { static readonly ID = 'monaco-grading-description.action'; @@ -10,7 +10,7 @@ export class MonacoGradingDescriptionAction extends MonacoEditorDomainAction { super(MonacoGradingDescriptionAction.ID, 'artemisApp.assessmentInstructions.instructions.editor.addDescription', undefined, undefined, true); } - run(editor: monaco.editor.ICodeEditor): void { + run(editor: MonacoEditorWithActions): void { this.addTextWithDomainActionIdentifier(editor, MonacoGradingDescriptionAction.TEXT, true, false); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-feedback.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-feedback.action.ts index 2dc1306eeffd..fa59ee235feb 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-feedback.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-feedback.action.ts @@ -1,5 +1,5 @@ -import * as monaco from 'monaco-editor'; import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; +import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; export class MonacoGradingFeedbackAction extends MonacoEditorDomainAction { static readonly ID = 'monaco-grading-feedback.action'; @@ -10,7 +10,7 @@ export class MonacoGradingFeedbackAction extends MonacoEditorDomainAction { super(MonacoGradingFeedbackAction.ID, 'artemisApp.assessmentInstructions.instructions.editor.addFeedback', undefined, undefined, true); } - run(editor: monaco.editor.ICodeEditor): void { + run(editor: MonacoEditorWithActions): void { this.addTextWithDomainActionIdentifier(editor, MonacoGradingFeedbackAction.TEXT, true, false); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-instruction.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-instruction.action.ts index fa14b18da454..2020aa74132f 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-instruction.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-instruction.action.ts @@ -1,10 +1,10 @@ -import * as monaco from 'monaco-editor'; import { MonacoEditorDomainAction } from '../monaco-editor-domain-action.model'; import { MonacoGradingCreditsAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-credits.action'; import { MonacoGradingScaleAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-scale.action'; import { MonacoGradingDescriptionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-description.action'; import { MonacoGradingFeedbackAction } from './monaco-grading-feedback.action'; import { MonacoGradingUsageCountAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-usage-count.action'; +import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; export class MonacoGradingInstructionAction extends MonacoEditorDomainAction { static readonly ID = 'monaco-grading-instruction.action'; @@ -20,7 +20,7 @@ export class MonacoGradingInstructionAction extends MonacoEditorDomainAction { super(MonacoGradingInstructionAction.ID, 'artemisApp.assessmentInstructions.instructions.editor.addInstruction'); } - run(editor: monaco.editor.ICodeEditor): void { + run(editor: MonacoEditorWithActions): void { this.addTextWithDomainActionIdentifier(editor, '', false, false); this.creditsAction.executeInCurrentEditor(); this.scaleAction.executeInCurrentEditor(); diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-scale.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-scale.action.ts index 53e1bd2b9485..276124b4fe0b 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-scale.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-scale.action.ts @@ -1,5 +1,5 @@ import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; -import * as monaco from 'monaco-editor'; +import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; export class MonacoGradingScaleAction extends MonacoEditorDomainAction { static readonly ID = 'monaco-grading-scale.action'; @@ -10,7 +10,7 @@ export class MonacoGradingScaleAction extends MonacoEditorDomainAction { super(MonacoGradingScaleAction.ID, 'artemisApp.assessmentInstructions.instructions.editor.addScale', undefined, undefined, true); } - run(editor: monaco.editor.ICodeEditor): void { + run(editor: MonacoEditorWithActions): void { this.addTextWithDomainActionIdentifier(editor, MonacoGradingScaleAction.TEXT, true, false); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-usage-count.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-usage-count.action.ts index b68700d3e094..9a001a92f406 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-usage-count.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-usage-count.action.ts @@ -1,5 +1,5 @@ -import * as monaco from 'monaco-editor'; import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; +import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; export class MonacoGradingUsageCountAction extends MonacoEditorDomainAction { static readonly ID = 'monaco-grading-usage-count.action'; @@ -10,7 +10,7 @@ export class MonacoGradingUsageCountAction extends MonacoEditorDomainAction { super(MonacoGradingUsageCountAction.ID, 'artemisApp.assessmentInstructions.instructions.editor.addUsageCount', undefined, undefined, true); } - run(editor: monaco.editor.ICodeEditor): void { + run(editor: MonacoEditorWithActions): void { this.addTextWithDomainActionIdentifier(editor, MonacoGradingUsageCountAction.TEXT, true, false); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-attachment.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-attachment.action.ts index e9bfd00184c2..2f647e526b4c 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-attachment.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-attachment.action.ts @@ -1,6 +1,6 @@ import { faImage } from '@fortawesome/free-solid-svg-icons'; -import * as monaco from 'monaco-editor'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; interface AttachmentArguments { text: string; @@ -30,7 +30,7 @@ export class MonacoAttachmentAction extends MonacoEditorAction { * @param editor The editor in which to insert the attachment. * @param args The text and url of the attachment to insert. If one or both are not provided, the default text will be inserted. */ - run(editor: monaco.editor.ICodeEditor, args?: AttachmentArguments): void { + run(editor: MonacoEditorWithActions, args?: AttachmentArguments): void { if (!args?.text || !args?.url) { this.replaceTextAtCurrentSelection(editor, MonacoAttachmentAction.DEFAULT_INSERT_TEXT); } else { diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-bold.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-bold.action.ts index e075b898259b..c859b3c889f2 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-bold.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-bold.action.ts @@ -1,6 +1,6 @@ -import * as monaco from 'monaco-editor'; import { faBold } from '@fortawesome/free-solid-svg-icons'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { KeyCode, KeyModifier, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; const BOLD_DELIMITER = '**'; @@ -11,7 +11,7 @@ export class MonacoBoldAction extends MonacoEditorAction { static readonly ID = 'monaco-bold.action'; constructor() { - super(MonacoBoldAction.ID, 'artemisApp.multipleChoiceQuestion.editor.bold', faBold, [monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyB]); + super(MonacoBoldAction.ID, 'artemisApp.multipleChoiceQuestion.editor.bold', faBold, [KeyModifier.CtrlCmd | KeyCode.KeyB]); } /** @@ -19,7 +19,7 @@ export class MonacoBoldAction extends MonacoEditorAction { * If no text is selected, the delimiter is inserted at the current cursor position. * @param editor The editor in which to toggle bold text. */ - run(editor: monaco.editor.ICodeEditor) { + run(editor: MonacoEditorWithActions) { this.toggleDelimiterAroundSelection(editor, BOLD_DELIMITER, BOLD_DELIMITER); editor.focus(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code-block.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code-block.action.ts index d6b2f1d5511d..73fb534c453f 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code-block.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code-block.action.ts @@ -1,6 +1,6 @@ -import * as monaco from 'monaco-editor'; import { faFileCode } from '@fortawesome/free-solid-svg-icons'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; const CODE_BLOCK_DELIMITER = '```'; @@ -18,7 +18,7 @@ export class MonacoCodeBlockAction extends MonacoEditorAction { * Toggles the code block delimiters around the selected text in the editor. If the selected text is already wrapped in code block delimiters, the delimiter is removed. * @param editor The editor in which to toggle code block text. */ - run(editor: monaco.editor.ICodeEditor): void { + run(editor: MonacoEditorWithActions): void { this.toggleDelimiterAroundSelection(editor, `${CODE_BLOCK_DELIMITER}${this.defaultLanguage ?? ''}\n`, `\n${CODE_BLOCK_DELIMITER}`); editor.focus(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code.action.ts index 8b870515cd8a..d373456fee06 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code.action.ts @@ -1,6 +1,6 @@ -import * as monaco from 'monaco-editor'; import { faCode } from '@fortawesome/free-solid-svg-icons'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; const CODE_DELIMITER = '`'; @@ -18,7 +18,7 @@ export class MonacoCodeAction extends MonacoEditorAction { * If no text is selected, the code delimiter is inserted at the current cursor position. * @param editor The editor in which to toggle code text. */ - run(editor: monaco.editor.ICodeEditor) { + run(editor: MonacoEditorWithActions) { this.toggleDelimiterAroundSelection(editor, CODE_DELIMITER, CODE_DELIMITER); editor.focus(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-color.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-color.action.ts index 951ccd40de09..ddef1a3718e3 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-color.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-color.action.ts @@ -1,5 +1,5 @@ -import * as monaco from 'monaco-editor'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; interface ColorArguments { color: string; @@ -30,7 +30,7 @@ export class MonacoColorAction extends MonacoEditorAction { * @param editor The editor in which to toggle color text. * @param args The color to apply to the selected text. If no color is provided, the default color red is used. */ - run(editor: monaco.editor.ICodeEditor, args?: ColorArguments) { + run(editor: MonacoEditorWithActions, args?: ColorArguments) { const openDelimiter = ``; this.toggleDelimiterAroundSelection(editor, openDelimiter, CLOSE_DELIMITER); editor.focus(); diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts index 07c6c89e4ac5..b2851b5073ee 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts @@ -2,8 +2,9 @@ import { IconDefinition } from '@fortawesome/fontawesome-svg-core'; import { TranslateService } from '@ngx-translate/core'; import * as monaco from 'monaco-editor'; import { enterFullscreen, exitFullscreen, isFullScreen } from 'app/shared/util/fullscreen.util'; +import { DisposableEditorElement, EditorPosition, MonacoEditorRange, MonacoEditorWithActions, makeEditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; -export abstract class MonacoEditorAction implements monaco.editor.IActionDescriptor, monaco.IDisposable { +export abstract class MonacoEditorAction implements monaco.editor.IActionDescriptor, DisposableEditorElement { // IActionDescriptor id: string; label: string; @@ -21,7 +22,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * The editor (if any) this action is registered in. * @private */ - private _editor?: monaco.editor.IStandaloneCodeEditor; + private _editor?: MonacoEditorWithActions; /** * Create a new action with the given id, translation key, icon, and keybindings. @@ -44,7 +45,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param editor The editor in which the action was triggered. * @param args Optional arguments that can be passed to the action. To ensure this is an object, you can use {@link executeInCurrentEditor}. */ - abstract run(editor: monaco.editor.ICodeEditor, args?: unknown): void; + abstract run(editor: MonacoEditorWithActions, args?: unknown): void; /** * Execute the action in the current editor. This is a convenience method to trigger the action in the editor without having to pass the editor instance. @@ -70,11 +71,11 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip /** * Register this action in the given editor. This is required to make the action available in the editor. Note that the action can only be registered in one editor at a time. - * @param editor The editor to register this action in. Note that its type has to be `monaco.editor.IStandaloneCodeEditor` to ensure it supports the `addAction` method. + * @param editor The editor to register this action in. * @param translateService The translation service to use for translating the action label. * @throws error if the action has already been registered in an editor. */ - register(editor: monaco.editor.IStandaloneCodeEditor, translateService: TranslateService): void { + register(editor: MonacoEditorWithActions, translateService: TranslateService): void { if (this.disposableAction) { throw new Error(`Action (id ${this.id}) already belongs to an editor. Dispose it first before registering it in another editor.`); } @@ -92,9 +93,9 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param listIncomplete Whether the list of suggestions is incomplete. If true, Monaco will keep searching for more suggestions. */ registerCompletionProviderForCurrentModel( - editor: monaco.editor.IStandaloneCodeEditor, + editor: MonacoEditorWithActions, searchFn: (searchTerm?: string) => Promise, - mapToSuggestionFn: (item: ItemType, range: monaco.IRange) => monaco.languages.CompletionItem, + mapToSuggestionFn: (item: ItemType, range: MonacoEditorRange) => monaco.languages.CompletionItem, triggerCharacter?: string, listIncomplete?: boolean, ): monaco.IDisposable { @@ -112,7 +113,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip return monaco.languages.registerCompletionItemProvider(languageId, { // We only want to trigger the completion provider if the trigger character is typed. However, we also allow numbers to trigger the completion, as they would not normally trigger it. triggerCharacters: triggerCharacter ? [triggerCharacter, ...'0123456789'] : undefined, - provideCompletionItems: async (model: monaco.editor.ITextModel, position: monaco.Position): Promise => { + provideCompletionItems: async (model: monaco.editor.ITextModel, position: EditorPosition): Promise => { if (model.id !== modelId) { return undefined; } @@ -155,7 +156,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip */ findTypedSequenceUntilPosition( model: monaco.editor.ITextModel, - position: monaco.Position, + position: EditorPosition, triggerCharacter?: string, lengthLimit = 25, ): monaco.editor.IWordAtPosition | undefined { @@ -164,7 +165,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip return model.getWordUntilPosition(position); } const scanColumn = Math.max(1, position.column - lengthLimit); - const scanRange = new monaco.Range(position.lineNumber, scanColumn, position.lineNumber, position.column); + const scanRange = makeEditorRange(position.lineNumber, scanColumn, position.lineNumber, position.column); const text = model.getValueInRange(scanRange); const triggerIndex = text.lastIndexOf(triggerCharacter); if (triggerIndex === -1) { @@ -186,7 +187,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param closeDelimiter The closing delimiter, e.g. . * @param textToInsert The text to insert between the delimiters if there is no selection. Defaults to an empty string. */ - toggleDelimiterAroundSelection(editor: monaco.editor.ICodeEditor, openDelimiter: string, closeDelimiter: string, textToInsert: string = ''): void { + toggleDelimiterAroundSelection(editor: MonacoEditorWithActions, openDelimiter: string, closeDelimiter: string, textToInsert: string = ''): void { const selection = editor.getSelection(); const selectedText = selection ? this.getTextAtRange(editor, selection)?.trim() : undefined; const position = editor.getPosition(); @@ -222,7 +223,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param editor The editor to type the text in. * @param text The text to type. */ - typeText(editor: monaco.editor.ICodeEditor, text: string): void { + typeText(editor: MonacoEditorWithActions, text: string): void { editor.trigger('keyboard', 'type', { text }); } @@ -231,7 +232,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param editor The editor to replace the text in. * @param text The text to replace the current selection with. */ - replaceTextAtCurrentSelection(editor: monaco.editor.ICodeEditor, text: string): void { + replaceTextAtCurrentSelection(editor: MonacoEditorWithActions, text: string): void { const selection = editor.getSelection(); const selectedText = selection ? this.getTextAtRange(editor, selection)?.trim() : undefined; if (selection && selectedText !== undefined) { @@ -243,7 +244,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * Gets the text of the current selection. If there is no selection, undefined is returned. * @param editor The editor to get the selection text from. */ - getSelectedText(editor: monaco.editor.ICodeEditor): string | undefined { + getSelectedText(editor: MonacoEditorWithActions): string | undefined { const selection = editor.getSelection(); return selection ? this.getTextAtRange(editor, selection) : undefined; } @@ -254,8 +255,8 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param position The position to insert the text at. * @param text The text to insert. */ - insertTextAtPosition(editor: monaco.editor.ICodeEditor, position: monaco.IPosition, text: string): void { - this.replaceTextAtRange(editor, new monaco.Range(position.lineNumber, position.column, position.lineNumber, position.column), text); + insertTextAtPosition(editor: MonacoEditorWithActions, position: EditorPosition, text: string): void { + this.replaceTextAtRange(editor, makeEditorRange(position.lineNumber, position.column, position.lineNumber, position.column), text); } /** @@ -264,7 +265,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param range The range to replace the text at. * @param text The text to replace the range with. */ - replaceTextAtRange(editor: monaco.editor.ICodeEditor, range: monaco.IRange, text: string): void { + replaceTextAtRange(editor: MonacoEditorWithActions, range: MonacoEditorRange, text: string): void { editor.executeEdits(this.id, [{ range, text }]); } @@ -273,7 +274,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param editor The editor to delete the text in. * @param range The range to delete the text at. */ - deleteTextAtRange(editor: monaco.editor.ICodeEditor, range: monaco.IRange): void { + deleteTextAtRange(editor: MonacoEditorWithActions, range: MonacoEditorRange): void { this.replaceTextAtRange(editor, range, ''); } @@ -282,7 +283,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param editor The editor to get the text from. * @param range The range to get the text from. */ - getTextAtRange(editor: monaco.editor.ICodeEditor, range: monaco.IRange): string | undefined { + getTextAtRange(editor: MonacoEditorWithActions, range: MonacoEditorRange): string | undefined { // End of line preference is important here. Otherwise, Windows may use CRLF line endings. return editor.getModel()?.getValueInRange(range, monaco.editor.EndOfLinePreference.LF); } @@ -292,7 +293,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param editor The editor to get the text from. * @param lineNumber The line number to get the text from. Line numbers start at 1. */ - getLineText(editor: monaco.editor.ICodeEditor, lineNumber: number): string | undefined { + getLineText(editor: MonacoEditorWithActions, lineNumber: number): string | undefined { return editor.getModel()?.getLineContent(lineNumber); } @@ -300,7 +301,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * Gets the number of lines in the editor. * @param editor The editor to get the line count from. */ - getLineCount(editor: monaco.editor.ICodeEditor): number { + getLineCount(editor: MonacoEditorWithActions): number { return editor.getModel()?.getLineCount() ?? 0; } @@ -308,7 +309,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * Gets the position of the last character in the editor. * @param editor The editor to get the position from. */ - getEndPosition(editor: monaco.editor.ICodeEditor): monaco.IPosition { + getEndPosition(editor: MonacoEditorWithActions): EditorPosition { return editor.getModel()?.getFullModelRange().getEndPosition() ?? { lineNumber: 1, column: 1 }; } @@ -318,14 +319,14 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param position The position to set. * @param revealLine Whether to scroll the editor to reveal the line the position is on. Defaults to false. */ - setPosition(editor: monaco.editor.ICodeEditor, position: monaco.IPosition, revealLine = false): void { + setPosition(editor: MonacoEditorWithActions, position: EditorPosition, revealLine = false): void { editor.setPosition(position); if (revealLine) { editor.revealLineInCenter(position.lineNumber); } } - getPosition(editor: monaco.editor.ICodeEditor): monaco.IPosition { + getPosition(editor: MonacoEditorWithActions): EditorPosition { return editor.getPosition() ?? { lineNumber: 1, column: 1 }; } @@ -334,7 +335,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param editor The editor to set the selection in. * @param selection The selection to set. */ - setSelection(editor: monaco.editor.ICodeEditor, selection: monaco.IRange): void { + setSelection(editor: MonacoEditorWithActions, selection: MonacoEditorRange): void { editor.setSelection(selection); editor.revealRangeInCenter(selection); } @@ -343,17 +344,17 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * Clears the current selection in the given editor, but preserves the cursor position. * @param editor The editor to clear the selection in. */ - clearSelection(editor: monaco.editor.ICodeEditor): void { + clearSelection(editor: MonacoEditorWithActions): void { const position = this.getPosition(editor); - this.setSelection(editor, new monaco.Range(position.lineNumber, position.column, position.lineNumber, position.column)); + this.setSelection(editor, makeEditorRange(position.lineNumber, position.column, position.lineNumber, position.column)); } /** * Adjusts the cursor position so it is at the end of the current line. * @param editor The editor to adjust the cursor position in. */ - moveCursorToEndOfLine(editor: monaco.editor.ICodeEditor): void { - const position: monaco.IPosition = { ...this.getPosition(editor), column: Number.POSITIVE_INFINITY }; + moveCursorToEndOfLine(editor: MonacoEditorWithActions): void { + const position: EditorPosition = { ...this.getPosition(editor), column: Number.POSITIVE_INFINITY }; this.setPosition(editor, position); } @@ -362,7 +363,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param editor The editor to toggle the fullscreen mode for. * @param element The element to toggle the fullscreen mode for. */ - toggleFullscreen(editor: monaco.editor.ICodeEditor, element?: HTMLElement): void { + toggleFullscreen(editor: MonacoEditorWithActions, element?: HTMLElement): void { const fullscreenElement = element ?? editor.getDomNode(); if (isFullScreen()) { exitFullscreen(); diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model.ts index 2a9999e96fd2..0a89bcd4ab7e 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model.ts @@ -1,5 +1,5 @@ import { MonacoEditorAction } from './monaco-editor-action.model'; -import * as monaco from 'monaco-editor'; +import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; /** * Class representing domain actions for Artemis-specific use cases. @@ -15,7 +15,7 @@ export abstract class MonacoEditorDomainAction extends MonacoEditorAction { * @param indent Whether to indent the inserted text with a tab. * @param updateSelection Whether to update the selection after inserting the text */ - addTextWithDomainActionIdentifier(editor: monaco.editor.ICodeEditor, text: string, indent = false, updateSelection = true): void { + addTextWithDomainActionIdentifier(editor: MonacoEditorWithActions, text: string, indent = false, updateSelection = true): void { this.clearSelection(editor); this.moveCursorToEndOfLine(editor); const identifierWithText = text ? `${this.getOpeningIdentifier()} ${text}` : this.getOpeningIdentifier(); diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor.util.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor.util.ts new file mode 100644 index 000000000000..6069865953a7 --- /dev/null +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor.util.ts @@ -0,0 +1,17 @@ +import * as monaco from 'monaco-editor'; + +export type DisposableEditorElement = monaco.IDisposable; +export type MonacoEditorWithActions = monaco.editor.ICodeEditor & { addAction: (action: monaco.editor.IActionDescriptor) => DisposableEditorElement }; +export type EditorPosition = monaco.IPosition; +export type MonacoEditorRange = monaco.IRange; +export const KeyModifier = monaco.KeyMod; +export const KeyCode = monaco.KeyCode; +export const CompletionItemKind = monaco.languages.CompletionItemKind; + +export function makeEditorPosition(lineNumber: number, column: number): EditorPosition { + return { lineNumber, column }; +} + +export function makeEditorRange(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number): MonacoEditorRange { + return { startLineNumber, startColumn, endLineNumber, endColumn }; +} diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-formula.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-formula.action.ts index e7d5de9d0324..93b5054fd156 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-formula.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-formula.action.ts @@ -1,5 +1,5 @@ -import * as monaco from 'monaco-editor'; import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; +import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; const FORMULA_OPEN_DELIMITER = '$$ '; const FORMULA_CLOSE_DELIMITER = ' $$'; @@ -19,7 +19,7 @@ export class MonacoFormulaAction extends MonacoEditorDomainAction { * If no text is selected, the default formula is inserted at the current cursor position. * @param editor The editor in which to toggle formula text. */ - run(editor: monaco.editor.ICodeEditor) { + run(editor: MonacoEditorWithActions) { this.toggleDelimiterAroundSelection(editor, this.getOpeningIdentifier(), FORMULA_CLOSE_DELIMITER, MonacoFormulaAction.DEFAULT_FORMULA); editor.focus(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-fullscreen.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-fullscreen.action.ts index e13d1ccfb9c6..32235042bb51 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-fullscreen.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-fullscreen.action.ts @@ -1,7 +1,7 @@ import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; -import * as monaco from 'monaco-editor'; import { faCompress } from '@fortawesome/free-solid-svg-icons'; +import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; /** * Action to toggle fullscreen mode in the editor. @@ -19,7 +19,7 @@ export class MonacoFullscreenAction extends MonacoEditorAction { * Toggles the fullscreen mode of the editor. * @param editor The editor in which to toggle fullscreen mode. */ - run(editor: monaco.editor.ICodeEditor): void { + run(editor: MonacoEditorWithActions): void { this.toggleFullscreen(editor, this.element); } } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-heading.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-heading.action.ts index 8bfbbc159f7d..c86cd9796d62 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-heading.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-heading.action.ts @@ -1,6 +1,6 @@ -import * as monaco from 'monaco-editor'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; import { faHeading } from '@fortawesome/free-solid-svg-icons'; +import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; function getTranslationKeyForLevel(level: number): string { const suffix = level === 3 ? 'Three' : level === 2 ? 'Two' : 'One'; @@ -29,7 +29,7 @@ export class MonacoHeadingAction extends MonacoEditorAction { * Toggles the heading prefix ("# ", "## ", ...) for the selected text based on the heading level. If the selected text is already a heading, the prefix is removed. * @param editor The editor in which to toggle heading text. */ - run(editor: monaco.editor.ICodeEditor) { + run(editor: MonacoEditorWithActions) { const selection = editor.getSelection(); const selectedText = selection ? this.getTextAtRange(editor, selection) : undefined; if (selection && selectedText !== undefined) { diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-italic.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-italic.action.ts index 91133f858eae..4decb19d0305 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-italic.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-italic.action.ts @@ -1,6 +1,6 @@ -import * as monaco from 'monaco-editor'; import { faItalic } from '@fortawesome/free-solid-svg-icons'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { KeyCode, KeyModifier, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; const ITALIC_DELIMITER = '*'; @@ -10,7 +10,7 @@ const ITALIC_DELIMITER = '*'; export class MonacoItalicAction extends MonacoEditorAction { static readonly ID = 'monaco-italic.action'; constructor() { - super(MonacoItalicAction.ID, 'artemisApp.multipleChoiceQuestion.editor.italic', faItalic, [monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyI]); + super(MonacoItalicAction.ID, 'artemisApp.multipleChoiceQuestion.editor.italic', faItalic, [KeyModifier.CtrlCmd | KeyCode.KeyI]); } /** @@ -18,7 +18,7 @@ export class MonacoItalicAction extends MonacoEditorAction { * If no text is selected, the delimiter is inserted at the current cursor position. * @param editor The editor in which to toggle italic text. */ - run(editor: monaco.editor.ICodeEditor): void { + run(editor: MonacoEditorWithActions): void { this.toggleDelimiterAroundSelection(editor, ITALIC_DELIMITER, ITALIC_DELIMITER); editor.focus(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-ordered-list.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-ordered-list.action.ts index 1ef25be98b0b..55aa09e47a3e 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-ordered-list.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-ordered-list.action.ts @@ -1,6 +1,6 @@ -import * as monaco from 'monaco-editor'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; import { faListOl } from '@fortawesome/free-solid-svg-icons'; +import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; const NUMBER_REGEX = /^\d+\.\s.*/; @@ -18,7 +18,7 @@ export class MonacoOrderedListAction extends MonacoEditorAction { * If no text is selected, the prefix "1. " is inserted at the current cursor position. * @param editor The editor in which to toggle the ordered list. */ - run(editor: monaco.editor.ICodeEditor): void { + run(editor: MonacoEditorWithActions): void { const selection = editor.getSelection(); if (!selection) return; @@ -36,8 +36,9 @@ export class MonacoOrderedListAction extends MonacoEditorAction { } if (allLinesEmpty) { - this.insertTextAtPosition(editor, new monaco.Position(selection.startLineNumber, 1), '1. '); - editor.setPosition(new monaco.Position(selection.startLineNumber, 1 + 3)); + this.insertTextAtPosition(editor, { lineNumber: selection.startLineNumber, column: 1 }, '1. '); + // Move the cursor to after the inserted "1. " + editor.setPosition({ lineNumber: selection.startLineNumber, column: 4 }); editor.focus(); return; } @@ -48,9 +49,13 @@ export class MonacoOrderedListAction extends MonacoEditorAction { if (isOrderedList) { const idx = lineContent.indexOf('. '); - if (idx >= 0) this.deleteTextAtRange(editor, new monaco.Range(lineNumber, 1, lineNumber, idx + 3)); + if (idx >= 0) this.deleteTextAtRange(editor, { startLineNumber: lineNumber, startColumn: 1, endLineNumber: lineNumber, endColumn: idx + 3 }); } else { - this.replaceTextAtRange(editor, new monaco.Range(lineNumber, 1, lineNumber, 1), `${lineNumber - selection.startLineNumber + 1}. `); + this.replaceTextAtRange( + editor, + { startLineNumber: lineNumber, startColumn: 1, endLineNumber: lineNumber, endColumn: 1 }, + `${lineNumber - selection.startLineNumber + 1}. `, + ); } } } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-quote.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-quote.action.ts index abc7d0c09033..ada73eb0b97c 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-quote.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-quote.action.ts @@ -1,6 +1,6 @@ import { faQuoteLeft } from '@fortawesome/free-solid-svg-icons'; -import * as monaco from 'monaco-editor'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; const QUOTE_OPEN_DELIMITER = '> '; @@ -17,7 +17,7 @@ export class MonacoQuoteAction extends MonacoEditorAction { * Toggles the quote delimiter around the selected text in the editor. If the selected text is already quoted, the delimiter is removed. * @param editor The editor in which to toggle quote text. */ - run(editor: monaco.editor.ICodeEditor): void { + run(editor: MonacoEditorWithActions): void { this.toggleDelimiterAroundSelection(editor, QUOTE_OPEN_DELIMITER, ''); editor.focus(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-task.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-task.action.ts index a55f00bd9d1d..5378e147f9c8 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-task.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-task.action.ts @@ -1,6 +1,6 @@ -import * as monaco from 'monaco-editor'; import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; import { escapeStringForUseInRegex } from 'app/shared/util/global.utils'; +import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; /** * Action to insert a task into the editor. They follow the format [task][Task Short Description](testCaseName). @@ -19,7 +19,7 @@ export class MonacoTaskAction extends MonacoEditorDomainAction { * Inserts, at the current selection, the markdown task. * @param editor The editor in which to insert the task. */ - run(editor: monaco.editor.ICodeEditor): void { + run(editor: MonacoEditorWithActions): void { this.replaceTextAtCurrentSelection(editor, `${this.getOpeningIdentifier()}${MonacoTaskAction.TEXT}`); editor.focus(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-test-case.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-test-case.action.ts index e2d48c615709..7d6fdcc82fbd 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-test-case.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-test-case.action.ts @@ -1,6 +1,7 @@ import { TranslateService } from '@ngx-translate/core'; import * as monaco from 'monaco-editor'; import { DomainActionWithOptionsArguments, MonacoEditorDomainActionWithOptions } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action-with-options.model'; +import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; /** * Action to insert a test case into the editor. It also registers a completion item provider offers all possible test cases as completion items to the user. @@ -21,7 +22,7 @@ export class MonacoTestCaseAction extends MonacoEditorDomainActionWithOptions { * @param translateService The translation service to use for translating the action label. * @throws error If the action is already registered with an editor or no model is attached to the editor. */ - register(editor: monaco.editor.IStandaloneCodeEditor, translateService: TranslateService) { + register(editor: MonacoEditorWithActions, translateService: TranslateService) { super.register(editor, translateService); const model = editor.getModel(); if (!model) { @@ -70,7 +71,7 @@ export class MonacoTestCaseAction extends MonacoEditorDomainActionWithOptions { super.executeInCurrentEditor(args); } - run(editor: monaco.editor.ICodeEditor, args?: DomainActionWithOptionsArguments) { + run(editor: MonacoEditorWithActions, args?: DomainActionWithOptionsArguments) { this.replaceTextAtCurrentSelection(editor, args?.selectedItem?.value ?? MonacoTestCaseAction.DEFAULT_INSERT_TEXT); editor.focus(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-underline.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-underline.action.ts index 66b60d0a012d..cd49aac63e94 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-underline.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-underline.action.ts @@ -1,6 +1,6 @@ -import * as monaco from 'monaco-editor'; import { faUnderline } from '@fortawesome/free-solid-svg-icons'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { KeyCode, KeyModifier, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; const UNDERLINE_OPEN_DELIMITER = ''; const UNDERLINE_CLOSE_DELIMITER = ''; @@ -11,14 +11,14 @@ const UNDERLINE_CLOSE_DELIMITER = ''; export class MonacoUnderlineAction extends MonacoEditorAction { static readonly ID = 'monaco-underline.action'; constructor() { - super(MonacoUnderlineAction.ID, 'artemisApp.multipleChoiceQuestion.editor.underline', faUnderline, [monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyU]); + super(MonacoUnderlineAction.ID, 'artemisApp.multipleChoiceQuestion.editor.underline', faUnderline, [KeyModifier.CtrlCmd | KeyCode.KeyU]); } /** * Toggles the underline delimiter around the selected text in the editor. If the selected text is already underlined, the delimiter is removed. * @param editor The editor in which to toggle underline text. */ - run(editor: monaco.editor.ICodeEditor): void { + run(editor: MonacoEditorWithActions): void { this.toggleDelimiterAroundSelection(editor, UNDERLINE_OPEN_DELIMITER, UNDERLINE_CLOSE_DELIMITER); editor.focus(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-unordered-list.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-unordered-list.action.ts index e2c6b3c1083e..204916982a50 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-unordered-list.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-unordered-list.action.ts @@ -1,6 +1,6 @@ -import * as monaco from 'monaco-editor'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; import { faListUl } from '@fortawesome/free-solid-svg-icons'; +import { MonacoEditorWithActions, makeEditorPosition, makeEditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; const LIST_BULLET = '- '; @@ -18,7 +18,7 @@ export class MonacoUnorderedListAction extends MonacoEditorAction { * If no text is selected, the prefix is inserted at the current cursor position. * @param editor The editor in which to toggle the unordered list. */ - run(editor: monaco.editor.ICodeEditor): void { + run(editor: MonacoEditorWithActions): void { const selection = editor.getSelection(); if (!selection) return; @@ -36,8 +36,8 @@ export class MonacoUnorderedListAction extends MonacoEditorAction { } if (allLinesEmpty) { - this.insertTextAtPosition(editor, new monaco.Position(selection.startLineNumber, 1), LIST_BULLET); - editor.setPosition(new monaco.Position(selection.startLineNumber, 1 + LIST_BULLET.length)); + this.insertTextAtPosition(editor, makeEditorPosition(selection.startLineNumber, 1), LIST_BULLET); + editor.setPosition(makeEditorPosition(selection.startLineNumber, 1 + LIST_BULLET.length)); editor.focus(); return; } @@ -47,9 +47,9 @@ export class MonacoUnorderedListAction extends MonacoEditorAction { if (!lineContent) continue; if (isUnorderedList) { - this.deleteTextAtRange(editor, new monaco.Range(lineNumber, 1, lineNumber, 1 + LIST_BULLET.length)); + this.deleteTextAtRange(editor, makeEditorRange(lineNumber, 1, lineNumber, 1 + LIST_BULLET.length)); } else { - this.insertTextAtPosition(editor, new monaco.Position(lineNumber, 1), LIST_BULLET); + this.insertTextAtPosition(editor, makeEditorPosition(lineNumber, 1), LIST_BULLET); } } } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-url.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-url.action.ts index 98737f2a1780..15eecc8672a6 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-url.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-url.action.ts @@ -1,6 +1,6 @@ import { faLink } from '@fortawesome/free-solid-svg-icons'; -import * as monaco from 'monaco-editor'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; interface UrlArguments { text: string; @@ -31,7 +31,7 @@ export class MonacoUrlAction extends MonacoEditorAction { * @param editor The editor in which to insert the URL. * @param args The text and url of the URL to insert. If one or both are not provided, the default text will be inserted. */ - run(editor: monaco.editor.ICodeEditor, args?: UrlArguments): void { + run(editor: MonacoEditorWithActions, args?: UrlArguments): void { if (!args?.text || !args?.url) { this.replaceTextAtCurrentSelection(editor, MonacoUrlAction.DEFAULT_INSERT_TEXT); } else { diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-correct-multiple-choice-answer.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-correct-multiple-choice-answer.action.ts index e8307539ec41..20074604f05b 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-correct-multiple-choice-answer.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-correct-multiple-choice-answer.action.ts @@ -1,5 +1,5 @@ import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; -import * as monaco from 'monaco-editor'; +import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; export class MonacoCorrectMultipleChoiceAnswerAction extends MonacoEditorDomainAction { static readonly ID = 'artemisApp.multipleChoiceQuestion.editor.addCorrectAnswerOption'; @@ -10,7 +10,7 @@ export class MonacoCorrectMultipleChoiceAnswerAction extends MonacoEditorDomainA super(MonacoCorrectMultipleChoiceAnswerAction.ID, 'artemisApp.multipleChoiceQuestion.editor.addCorrectAnswerOption'); } - run(editor: monaco.editor.ICodeEditor): void { + run(editor: MonacoEditorWithActions): void { this.addTextWithDomainActionIdentifier(editor, MonacoCorrectMultipleChoiceAnswerAction.TEXT); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-option.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-option.action.ts index 21a7ef4e0563..8886042fcf01 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-option.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-option.action.ts @@ -1,5 +1,5 @@ import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; -import * as monaco from 'monaco-editor'; +import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; interface InsertShortAnswerOptionArgs { spotNumber?: number; @@ -29,7 +29,7 @@ export class MonacoInsertShortAnswerOptionAction extends MonacoEditorAction { * @param editor The editor to insert the option in. * @param args The optional arguments for the action. Can include a spot number (will be # otherwise) and the option text (if blank/absent, the default text will be used). */ - run(editor: monaco.editor.ICodeEditor, args?: InsertShortAnswerOptionArgs): void { + run(editor: MonacoEditorWithActions, args?: InsertShortAnswerOptionArgs): void { // Note that even if the optionText is provided, it may be blank. This is why we use || instead of ?? here. const optionText = args?.optionText || MonacoInsertShortAnswerOptionAction.DEFAULT_TEXT; let insertedText: string; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-spot.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-spot.action.ts index 5aeb3c8ff314..5db46cc5f95b 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-spot.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-spot.action.ts @@ -1,6 +1,6 @@ import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; -import * as monaco from 'monaco-editor'; import { MonacoInsertShortAnswerOptionAction } from 'app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-option.action'; +import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; /** * Action to insert a short answer spot at the current cursor position. @@ -22,7 +22,7 @@ export class MonacoInsertShortAnswerSpotAction extends MonacoEditorAction { * Then, it inserts an option linked to the spot. If the selected text is not empty, it will be used as the option's text. * @param editor The editor to insert the spot in. */ - run(editor: monaco.editor.ICodeEditor): void { + run(editor: MonacoEditorWithActions): void { // Changes to the editor contents will trigger an update of the spot number. We keep it stored here to use it when inserting the spot. const number = this.spotNumber; const text = `[-spot ${number}]`; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-quiz-explanation.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-quiz-explanation.action.ts index 6cc078baa448..03b0a64a2045 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-quiz-explanation.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-quiz-explanation.action.ts @@ -1,5 +1,5 @@ import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; -import * as monaco from 'monaco-editor'; +import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; export class MonacoQuizExplanationAction extends MonacoEditorDomainAction { static readonly ID = 'monaco-quiz-explanation.action'; @@ -10,7 +10,7 @@ export class MonacoQuizExplanationAction extends MonacoEditorDomainAction { super(MonacoQuizExplanationAction.ID, 'artemisApp.multipleChoiceQuestion.editor.addExplanation'); } - run(editor: monaco.editor.ICodeEditor): void { + run(editor: MonacoEditorWithActions): void { this.addTextWithDomainActionIdentifier(editor, MonacoQuizExplanationAction.TEXT, true); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-quiz-hint.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-quiz-hint.action.ts index 29c320bf016b..cbc741efa744 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-quiz-hint.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-quiz-hint.action.ts @@ -1,5 +1,5 @@ import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; -import * as monaco from 'monaco-editor'; +import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; export class MonacoQuizHintAction extends MonacoEditorDomainAction { static readonly ID = 'monaco-quiz-hint.action'; @@ -10,7 +10,7 @@ export class MonacoQuizHintAction extends MonacoEditorDomainAction { super(MonacoQuizHintAction.ID, 'artemisApp.multipleChoiceQuestion.editor.addHint'); } - run(editor: monaco.editor.ICodeEditor): void { + run(editor: MonacoEditorWithActions): void { this.addTextWithDomainActionIdentifier(editor, MonacoQuizHintAction.TEXT, true); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-wrong-multiple-choice-answer.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-wrong-multiple-choice-answer.action.ts index 7c682072eb5a..590503cc61e1 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-wrong-multiple-choice-answer.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-wrong-multiple-choice-answer.action.ts @@ -1,5 +1,5 @@ -import * as monaco from 'monaco-editor'; import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; +import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; export class MonacoWrongMultipleChoiceAnswerAction extends MonacoEditorDomainAction { static readonly ID = 'monaco-incorrect-multiple-choice-answer.action'; @@ -10,7 +10,7 @@ export class MonacoWrongMultipleChoiceAnswerAction extends MonacoEditorDomainAct super(MonacoWrongMultipleChoiceAnswerAction.ID, 'artemisApp.multipleChoiceQuestion.editor.addInCorrectAnswerOption'); } - run(editor: monaco.editor.ICodeEditor): void { + run(editor: MonacoEditorWithActions): void { this.addTextWithDomainActionIdentifier(editor, MonacoWrongMultipleChoiceAnswerAction.TEXT); } From be49c3bc0025bdd1acfec261f6d15cb5dd689d17 Mon Sep 17 00:00:00 2001 From: Patrik Zander Date: Fri, 30 Aug 2024 22:13:20 +0200 Subject: [PATCH 02/27] Add more type aliases --- .../monaco-channel-reference.action.ts | 4 +-- .../monaco-exercise-reference.action.ts | 4 +-- .../monaco-user-mention.action.ts | 4 +-- .../actions/monaco-editor-action.model.ts | 12 ++++----- .../model/actions/monaco-editor.util.ts | 25 +++++++++++++++-- .../model/monaco-code-editor-element.model.ts | 8 +++--- .../monaco-editor-build-annotation.model.ts | 25 ++++++++++------- ...monaco-editor-glyph-margin-widget.model.ts | 13 +++++---- .../monaco-editor-inline-widget.model.ts | 5 ++-- ...tor-line-decorations-hover-button.model.ts | 27 ++++++++++++------- .../monaco-editor-line-highlight.model.ts | 21 ++++++++++----- .../monaco-editor-option-preset.model.ts | 6 ++--- .../monaco-editor-overlay-widget.model.ts | 9 +++---- .../model/monaco-editor-view-zone.model.ts | 6 ++--- .../monaco-editor-option.helper.ts | 3 ++- .../monaco-editor/monaco-editor.component.ts | 7 +++-- 16 files changed, 107 insertions(+), 72 deletions(-) diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts index 417ecfea5648..1add30cbf646 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts @@ -5,7 +5,7 @@ import { ChannelIdAndNameDTO } from 'app/entities/metis/conversation/channel.mod import { MetisService } from 'app/shared/metis/metis.service'; import { ChannelService } from 'app/shared/metis/conversations/channel.service'; import { firstValueFrom } from 'rxjs'; -import { CompletionItemKind, DisposableEditorElement, MonacoEditorRange, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { CompletionItemKind, DisposableEditorElement, EditorRange, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; /** * Action to insert a reference to a channel into the editor. Users that type a # will see a list of available channels to reference. @@ -34,7 +34,7 @@ export class MonacoChannelReferenceAction extends MonacoEditorAction { this.disposableCompletionProvider = this.registerCompletionProviderForCurrentModel( editor, this.fetchChannels.bind(this), - (channel: ChannelIdAndNameDTO, range: MonacoEditorRange) => ({ + (channel: ChannelIdAndNameDTO, range: EditorRange) => ({ label: `#${channel.name}`, kind: CompletionItemKind.Constant, insertText: `[channel]${channel.name}(${channel.id})[/channel]`, diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action.ts index 5cb824c05842..3e24ceeecf15 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action.ts @@ -2,7 +2,7 @@ import { TranslateService } from '@ngx-translate/core'; import { MetisService } from 'app/shared/metis/metis.service'; import { MonacoEditorDomainActionWithOptions } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action-with-options.model'; import { ValueItem } from 'app/shared/markdown-editor/value-item.model'; -import { CompletionItemKind, DisposableEditorElement, MonacoEditorRange, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { CompletionItemKind, DisposableEditorElement, EditorRange, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; /** * Action to insert a reference to an exercise into the editor. Users that type a / will see a list of available exercises to reference. @@ -35,7 +35,7 @@ export class MonacoExerciseReferenceAction extends MonacoEditorDomainActionWithO this.disposableCompletionProvider = this.registerCompletionProviderForCurrentModel( editor, () => Promise.resolve(this.getValues()), - (item: ValueItem, range: MonacoEditorRange) => ({ + (item: ValueItem, range: EditorRange) => ({ label: `/exercise ${item.value}`, kind: CompletionItemKind.Constant, insertText: `[${item.type}]${item.value}(${this.metisService.getLinkForExercise(item.id)})[/${item.type}]`, diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts index 2ff88037a6f3..d7149ae8bdf2 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts @@ -5,7 +5,7 @@ import { CourseManagementService } from 'app/course/manage/course-management.ser import { MetisService } from 'app/shared/metis/metis.service'; import { firstValueFrom } from 'rxjs'; import { UserNameAndLoginDTO } from 'app/core/user/user.model'; -import { CompletionItemKind, DisposableEditorElement, MonacoEditorRange, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { CompletionItemKind, DisposableEditorElement, EditorRange, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; /** * Action to insert a user mention into the editor. Users that type a @ will see a list of available users to mention. @@ -34,7 +34,7 @@ export class MonacoUserMentionAction extends MonacoEditorAction { this.disposableCompletionProvider = this.registerCompletionProviderForCurrentModel( editor, this.loadUsersForSearchTerm.bind(this), - (user: UserNameAndLoginDTO, range: MonacoEditorRange) => ({ + (user: UserNameAndLoginDTO, range: EditorRange) => ({ label: `@${user.name}`, kind: CompletionItemKind.User, insertText: `[user]${user.name}(${user.login})[/user]`, diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts index b2851b5073ee..d1174b045251 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts @@ -2,7 +2,7 @@ import { IconDefinition } from '@fortawesome/fontawesome-svg-core'; import { TranslateService } from '@ngx-translate/core'; import * as monaco from 'monaco-editor'; import { enterFullscreen, exitFullscreen, isFullScreen } from 'app/shared/util/fullscreen.util'; -import { DisposableEditorElement, EditorPosition, MonacoEditorRange, MonacoEditorWithActions, makeEditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { DisposableEditorElement, EditorPosition, EditorRange, MonacoEditorWithActions, makeEditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; export abstract class MonacoEditorAction implements monaco.editor.IActionDescriptor, DisposableEditorElement { // IActionDescriptor @@ -95,7 +95,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip registerCompletionProviderForCurrentModel( editor: MonacoEditorWithActions, searchFn: (searchTerm?: string) => Promise, - mapToSuggestionFn: (item: ItemType, range: MonacoEditorRange) => monaco.languages.CompletionItem, + mapToSuggestionFn: (item: ItemType, range: EditorRange) => monaco.languages.CompletionItem, triggerCharacter?: string, listIncomplete?: boolean, ): monaco.IDisposable { @@ -265,7 +265,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param range The range to replace the text at. * @param text The text to replace the range with. */ - replaceTextAtRange(editor: MonacoEditorWithActions, range: MonacoEditorRange, text: string): void { + replaceTextAtRange(editor: MonacoEditorWithActions, range: EditorRange, text: string): void { editor.executeEdits(this.id, [{ range, text }]); } @@ -274,7 +274,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param editor The editor to delete the text in. * @param range The range to delete the text at. */ - deleteTextAtRange(editor: MonacoEditorWithActions, range: MonacoEditorRange): void { + deleteTextAtRange(editor: MonacoEditorWithActions, range: EditorRange): void { this.replaceTextAtRange(editor, range, ''); } @@ -283,7 +283,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param editor The editor to get the text from. * @param range The range to get the text from. */ - getTextAtRange(editor: MonacoEditorWithActions, range: MonacoEditorRange): string | undefined { + getTextAtRange(editor: MonacoEditorWithActions, range: EditorRange): string | undefined { // End of line preference is important here. Otherwise, Windows may use CRLF line endings. return editor.getModel()?.getValueInRange(range, monaco.editor.EndOfLinePreference.LF); } @@ -335,7 +335,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param editor The editor to set the selection in. * @param selection The selection to set. */ - setSelection(editor: MonacoEditorWithActions, selection: MonacoEditorRange): void { + setSelection(editor: MonacoEditorWithActions, selection: EditorRange): void { editor.setSelection(selection); editor.revealRangeInCenter(selection); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor.util.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor.util.ts index 6069865953a7..643a8115bee9 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor.util.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor.util.ts @@ -1,9 +1,30 @@ import * as monaco from 'monaco-editor'; +/* + * This file contains type definitions and utility functions for the Monaco editor, which reduces the amount of imports needed in other files. + */ + +// Generic Monaco editor types export type DisposableEditorElement = monaco.IDisposable; export type MonacoEditorWithActions = monaco.editor.ICodeEditor & { addAction: (action: monaco.editor.IActionDescriptor) => DisposableEditorElement }; +export type MonacoEditorTextModel = monaco.editor.ITextModel; export type EditorPosition = monaco.IPosition; -export type MonacoEditorRange = monaco.IRange; +export type EditorRange = monaco.IRange; +export type MonacoEditorOptions = monaco.editor.IEditorOptions; +export type EditorMouseEvent = monaco.editor.IEditorMouseEvent; +// Types for elements in the editor +export type DecorationsCollection = monaco.editor.IEditorDecorationsCollection; +export type DeltaDecoration = monaco.editor.IModelDeltaDecoration; +export type GlyphMarginWidget = monaco.editor.IGlyphMarginWidget; +export type GlyphMarginLane = monaco.editor.GlyphMarginLane; +export type GlyphMarginPosition = monaco.editor.IGlyphMarginWidgetPosition; +export type OverlayWidget = monaco.editor.IOverlayWidget; +export type OverlayWidgetPosition = monaco.editor.IOverlayWidgetPosition | null; // null is used by the monaco editor API +export type ViewZone = monaco.editor.IViewZone; +export const GlyphMarginLane = monaco.editor.GlyphMarginLane; +export const TrackedRangeStickiness = monaco.editor.TrackedRangeStickiness; + +// Enums for Actions export const KeyModifier = monaco.KeyMod; export const KeyCode = monaco.KeyCode; export const CompletionItemKind = monaco.languages.CompletionItemKind; @@ -12,6 +33,6 @@ export function makeEditorPosition(lineNumber: number, column: number): EditorPo return { lineNumber, column }; } -export function makeEditorRange(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number): MonacoEditorRange { +export function makeEditorRange(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number): EditorRange { return { startLineNumber, startColumn, endLineNumber, endColumn }; } diff --git a/src/main/webapp/app/shared/monaco-editor/model/monaco-code-editor-element.model.ts b/src/main/webapp/app/shared/monaco-editor/model/monaco-code-editor-element.model.ts index f066c1c8cd68..c472c4bab839 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/monaco-code-editor-element.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/monaco-code-editor-element.model.ts @@ -1,20 +1,20 @@ -import * as monaco from 'monaco-editor'; +import { DisposableEditorElement, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; /** * Abstract class representing an element in the Monaco editor, e.g. a line widget. */ -export abstract class MonacoCodeEditorElement implements monaco.IDisposable { +export abstract class MonacoCodeEditorElement implements DisposableEditorElement { static readonly CSS_HIDDEN_CLASS = 'monaco-hidden-element'; private id: string | undefined; private visible = true; - protected readonly editor: monaco.editor.ICodeEditor; + protected readonly editor: MonacoEditorWithActions; /** * @param editor The editor to render this element in. * @param id The id of this element if available, or undefined if not. If the ID is not available at construction time, it must be set using {@link setId}. */ - protected constructor(editor: monaco.editor.ICodeEditor, id: string | undefined) { + protected constructor(editor: MonacoEditorWithActions, id: string | undefined) { this.editor = editor; this.id = id; } diff --git a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-build-annotation.model.ts b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-build-annotation.model.ts index 2478566c9fa6..edbe3a845cbe 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-build-annotation.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-build-annotation.model.ts @@ -1,7 +1,14 @@ import { MonacoCodeEditorElement } from 'app/shared/monaco-editor/model/monaco-code-editor-element.model'; import { MonacoEditorGlyphMarginWidget } from 'app/shared/monaco-editor/model/monaco-editor-glyph-margin-widget.model'; - -import * as monaco from 'monaco-editor'; +import { + DecorationsCollection, + DeltaDecoration, + DisposableEditorElement, + GlyphMarginLane, + MonacoEditorWithActions, + TrackedRangeStickiness, + makeEditorRange, +} from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; export enum MonacoEditorBuildAnnotationType { WARNING = 'warning', @@ -16,11 +23,11 @@ export enum MonacoEditorBuildAnnotationType { */ export class MonacoEditorBuildAnnotation extends MonacoCodeEditorElement { private glyphMarginWidget: MonacoEditorGlyphMarginWidget; - private decorationsCollection: monaco.editor.IEditorDecorationsCollection; + private decorationsCollection: DecorationsCollection; private outdated: boolean; private hoverMessage: string; private type: MonacoEditorBuildAnnotationType; - private updateListener: monaco.IDisposable; + private updateListener: DisposableEditorElement; /** * @param editor The editor to render this annotation in. @@ -30,7 +37,7 @@ export class MonacoEditorBuildAnnotation extends MonacoCodeEditorElement { * @param type The type of this annotation: error or warning. * @param outdated Whether this annotation is outdated and should be grayed out. Defaults to false. */ - constructor(editor: monaco.editor.ICodeEditor, id: string, lineNumber: number, hoverMessage: string, type: MonacoEditorBuildAnnotationType, outdated = false) { + constructor(editor: MonacoEditorWithActions, id: string, lineNumber: number, hoverMessage: string, type: MonacoEditorBuildAnnotationType, outdated = false) { super(editor, id); this.decorationsCollection = this.editor.createDecorationsCollection([]); this.hoverMessage = hoverMessage; @@ -39,7 +46,7 @@ export class MonacoEditorBuildAnnotation extends MonacoCodeEditorElement { const glyphMarginDomNode = document.createElement('div'); glyphMarginDomNode.id = `monaco-editor-glyph-margin-widget-${id}`; glyphMarginDomNode.className = `codicon codicon-${this.type}`; - this.glyphMarginWidget = new MonacoEditorGlyphMarginWidget(editor, id, glyphMarginDomNode, lineNumber, monaco.editor.GlyphMarginLane.Center); + this.glyphMarginWidget = new MonacoEditorGlyphMarginWidget(editor, id, glyphMarginDomNode, lineNumber, GlyphMarginLane.Center); this.setupListeners(); } @@ -47,15 +54,15 @@ export class MonacoEditorBuildAnnotation extends MonacoCodeEditorElement { * Returns an object (a delta decoration) detailing the position and styling of the annotation. * @private */ - private getAssociatedDeltaDecoration(): monaco.editor.IModelDeltaDecoration { + private getAssociatedDeltaDecoration(): DeltaDecoration { const marginClassName = this.outdated ? 'monaco-annotation-outdated' : `monaco-annotation-${this.type}`; const lineNumber = this.getLineNumber(); return { - range: new monaco.Range(lineNumber, 0, lineNumber, 0), + range: makeEditorRange(lineNumber, 0, lineNumber, 0), options: { marginClassName, isWholeLine: true, - stickiness: monaco.editor.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges, + stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges, lineNumberHoverMessage: { value: this.hoverMessage }, glyphMarginHoverMessage: { value: this.hoverMessage }, }, diff --git a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-glyph-margin-widget.model.ts b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-glyph-margin-widget.model.ts index 1c02585c9b0c..719ddd90392e 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-glyph-margin-widget.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-glyph-margin-widget.model.ts @@ -1,13 +1,11 @@ import { MonacoCodeEditorElement } from 'app/shared/monaco-editor/model/monaco-code-editor-element.model'; -import * as monaco from 'monaco-editor'; - -type GlyphMarginLane = monaco.editor.GlyphMarginLane; +import { GlyphMarginLane, GlyphMarginPosition, GlyphMarginWidget, MonacoEditorWithActions, makeEditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; /** * Class representing a glyph margin widget in the Monaco editor. * Glyph margin widgets refer to one line and can contain arbitrary DOM nodes. */ -export class MonacoEditorGlyphMarginWidget extends MonacoCodeEditorElement implements monaco.editor.IGlyphMarginWidget { +export class MonacoEditorGlyphMarginWidget extends MonacoCodeEditorElement implements GlyphMarginWidget { private readonly domNode: HTMLElement; private lineNumber: number; private readonly lane: GlyphMarginLane; @@ -19,7 +17,7 @@ export class MonacoEditorGlyphMarginWidget extends MonacoCodeEditorElement imple * @param lineNumber The line to render this widget in. * @param lane The lane (left, center, or right) to render the widget in. */ - constructor(editor: monaco.editor.ICodeEditor, id: string, domNode: HTMLElement, lineNumber: number, lane: GlyphMarginLane) { + constructor(editor: MonacoEditorWithActions, id: string, domNode: HTMLElement, lineNumber: number, lane: GlyphMarginLane) { super(editor, id); this.domNode = domNode; this.lineNumber = lineNumber; @@ -29,11 +27,12 @@ export class MonacoEditorGlyphMarginWidget extends MonacoCodeEditorElement imple getDomNode(): HTMLElement { return this.domNode; } - getPosition(): monaco.editor.IGlyphMarginWidgetPosition { + + getPosition(): GlyphMarginPosition { return { lane: this.lane, zIndex: 10, - range: new monaco.Range(this.lineNumber, 0, this.lineNumber, 0), + range: makeEditorRange(this.lineNumber, 0, this.lineNumber, 0), }; } diff --git a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-inline-widget.model.ts b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-inline-widget.model.ts index 5449eef751b3..9b703446cf94 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-inline-widget.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-inline-widget.model.ts @@ -1,8 +1,7 @@ import { MonacoCodeEditorElement } from 'app/shared/monaco-editor/model/monaco-code-editor-element.model'; import { MonacoEditorViewZone } from 'app/shared/monaco-editor/model/monaco-editor-view-zone.model'; import { MonacoEditorOverlayWidget } from 'app/shared/monaco-editor/model/monaco-editor-overlay-widget.model'; - -import * as monaco from 'monaco-editor'; +import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; /** * Class representing a line widget. @@ -21,7 +20,7 @@ export class MonacoEditorLineWidget extends MonacoCodeEditorElement { * @param contentDomNode The content to render. * @param afterLineNumber The line after which this line widget should be rendered. */ - constructor(editor: monaco.editor.ICodeEditor, overlayWidgetId: string, contentDomNode: HTMLElement, afterLineNumber: number) { + constructor(editor: MonacoEditorWithActions, overlayWidgetId: string, contentDomNode: HTMLElement, afterLineNumber: number) { super(editor, overlayWidgetId); this.overlayWidget = new MonacoEditorOverlayWidget( editor, diff --git a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-line-decorations-hover-button.model.ts b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-line-decorations-hover-button.model.ts index 3e26312b90ac..23a1a7ff15b4 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-line-decorations-hover-button.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-line-decorations-hover-button.model.ts @@ -1,5 +1,12 @@ import { MonacoCodeEditorElement } from 'app/shared/monaco-editor/model/monaco-code-editor-element.model'; -import * as monaco from 'monaco-editor'; +import { + DecorationsCollection, + DeltaDecoration, + DisposableEditorElement, + EditorMouseEvent, + MonacoEditorWithActions, + makeEditorRange, +} from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; /** * Class representing a hover button that is displayed on a specific line in the editor. @@ -8,12 +15,12 @@ import * as monaco from 'monaco-editor'; export class MonacoEditorLineDecorationsHoverButton extends MonacoCodeEditorElement { private clickCallback: (lineNumber: number) => void; private currentLineNumber = 1; - private decorationsCollection: monaco.editor.IEditorDecorationsCollection; + private decorationsCollection: DecorationsCollection; private readonly className: string; - private mouseMoveListener?: monaco.IDisposable; - private mouseDownListener?: monaco.IDisposable; - private mouseLeaveListener?: monaco.IDisposable; + private mouseMoveListener?: DisposableEditorElement; + private mouseDownListener?: DisposableEditorElement; + private mouseLeaveListener?: DisposableEditorElement; /** * @param editor The editor to which to add the button. @@ -21,7 +28,7 @@ export class MonacoEditorLineDecorationsHoverButton extends MonacoCodeEditorElem * @param className The class name of the button. This is used to uniquely identify the button in the editor. * @param clickCallback The callback to be called when the button is clicked. The line number of the button is passed as an argument. */ - constructor(editor: monaco.editor.ICodeEditor, id: string, className: string, clickCallback: (lineNumber: number) => void) { + constructor(editor: MonacoEditorWithActions, id: string, className: string, clickCallback: (lineNumber: number) => void) { super(editor, id); this.clickCallback = clickCallback; this.className = className; @@ -33,7 +40,7 @@ export class MonacoEditorLineDecorationsHoverButton extends MonacoCodeEditorElem protected setupListeners() { super.setupListeners(); - this.mouseMoveListener = this.editor.onMouseMove((editorMouseEvent: monaco.editor.IEditorMouseEvent) => { + this.mouseMoveListener = this.editor.onMouseMove((editorMouseEvent: EditorMouseEvent) => { // This is undefined e.g. when hovering over a line widget. const lineNumber = editorMouseEvent.target?.position?.lineNumber; this.moveAndUpdate(lineNumber); @@ -50,7 +57,7 @@ export class MonacoEditorLineDecorationsHoverButton extends MonacoCodeEditorElem * Checks if the button was clicked and calls the click callback with the line number as an argument. * @param editorMouseEvent The mouse event to react to. */ - onClick(editorMouseEvent: monaco.editor.IEditorMouseEvent): void { + onClick(editorMouseEvent: EditorMouseEvent): void { const lineNumber = editorMouseEvent.target?.position?.lineNumber; // We identify the button via the class name of the element. if (lineNumber && editorMouseEvent.target?.element?.classList?.contains(this.className)) { @@ -83,9 +90,9 @@ export class MonacoEditorLineDecorationsHoverButton extends MonacoCodeEditorElem this.decorationsCollection.set([this.getAssociatedDeltaDecoration()]); } - private getAssociatedDeltaDecoration(): monaco.editor.IModelDeltaDecoration { + private getAssociatedDeltaDecoration(): DeltaDecoration { return { - range: new monaco.Range(this.currentLineNumber, 1, this.currentLineNumber, 1), + range: makeEditorRange(this.currentLineNumber, 1, this.currentLineNumber, 1), options: { isWholeLine: true, linesDecorationsClassName: this.className, diff --git a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-line-highlight.model.ts b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-line-highlight.model.ts index 488f15e1fc06..9f6d97a9c8eb 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-line-highlight.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-line-highlight.model.ts @@ -1,15 +1,22 @@ import { MonacoCodeEditorElement } from 'app/shared/monaco-editor/model/monaco-code-editor-element.model'; -import * as monaco from 'monaco-editor'; +import { + DecorationsCollection, + DeltaDecoration, + EditorRange, + MonacoEditorWithActions, + TrackedRangeStickiness, + makeEditorRange, +} from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; /** * Class representing a highlighted range of lines in the Monaco editor. * The highlighted lines can have separate styles for the margin and the line. */ export class MonacoEditorLineHighlight extends MonacoCodeEditorElement { - private range: monaco.IRange; + private range: EditorRange; private className?: string; private marginClassName?: string; - private decorationsCollection: monaco.editor.IEditorDecorationsCollection; + private decorationsCollection: DecorationsCollection; /** * @param editor The editor to highlight lines in. @@ -19,22 +26,22 @@ export class MonacoEditorLineHighlight extends MonacoCodeEditorElement { * @param className The class name to use for highlighting the line. If left out, no class will be applied. * @param marginClassName The class name to use for highlighting the margin. If left out, no class will be applied. */ - constructor(editor: monaco.editor.ICodeEditor, id: string, startLine: number, endLine: number, className?: string, marginClassName?: string) { + constructor(editor: MonacoEditorWithActions, id: string, startLine: number, endLine: number, className?: string, marginClassName?: string) { super(editor, id); - this.range = new monaco.Range(startLine, 0, endLine, 0); + this.range = makeEditorRange(startLine, 0, endLine, 0); this.className = className; this.marginClassName = marginClassName; this.decorationsCollection = editor.createDecorationsCollection([]); } - private getAssociatedDeltaDecoration(): monaco.editor.IModelDeltaDecoration { + private getAssociatedDeltaDecoration(): DeltaDecoration { return { range: this.range, options: { marginClassName: this.marginClassName, className: this.className, isWholeLine: true, - stickiness: monaco.editor.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges, + stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges, }, }; } diff --git a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-option-preset.model.ts b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-option-preset.model.ts index e3470bdb6837..e1a23c5ab4d9 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-option-preset.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-option-preset.model.ts @@ -1,6 +1,4 @@ -import * as monaco from 'monaco-editor'; - -export type MonacoEditorOptions = monaco.editor.IEditorOptions; +import { MonacoEditorOptions, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; /** * A preset of Monaco Editor options that can be applied to an editor for specific use cases, e.g. short answer quiz questions. @@ -13,7 +11,7 @@ export class MonacoEditorOptionPreset { * Update the editor options with the preset options. * @param editor The editor to which the options should be applied. */ - apply(editor: monaco.editor.ICodeEditor): void { + apply(editor: MonacoEditorWithActions): void { editor.updateOptions(this.options); } } diff --git a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-overlay-widget.model.ts b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-overlay-widget.model.ts index 8ea50ee8898d..f6146a3deee3 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-overlay-widget.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-overlay-widget.model.ts @@ -1,13 +1,10 @@ import { MonacoCodeEditorElement } from 'app/shared/monaco-editor/model/monaco-code-editor-element.model'; -import * as monaco from 'monaco-editor'; - -// null is used by the monaco editor API -type OverlayWidgetPosition = monaco.editor.IOverlayWidgetPosition | null; +import { MonacoEditorWithActions, OverlayWidget, OverlayWidgetPosition } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; /** * Class representing an overlay widget floating above the editor content. */ -export class MonacoEditorOverlayWidget extends MonacoCodeEditorElement implements monaco.editor.IOverlayWidget { +export class MonacoEditorOverlayWidget extends MonacoCodeEditorElement implements OverlayWidget { private readonly domNode: HTMLElement; private readonly position: OverlayWidgetPosition; @@ -17,7 +14,7 @@ export class MonacoEditorOverlayWidget extends MonacoCodeEditorElement implement * @param domNode The content to render. The user will be able to interact with the widget. * @param position The position of the widget or null if the element is positioned by another element (e.g. a view zone). */ - constructor(editor: monaco.editor.ICodeEditor, id: string, domNode: HTMLElement, position: OverlayWidgetPosition) { + constructor(editor: MonacoEditorWithActions, id: string, domNode: HTMLElement, position: OverlayWidgetPosition) { super(editor, id); this.domNode = domNode; // Ensure that the widget reaches its maximum width. diff --git a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-view-zone.model.ts b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-view-zone.model.ts index 1eff13d83f8a..e7d6ab8fdbd1 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-view-zone.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-view-zone.model.ts @@ -1,10 +1,10 @@ import { MonacoCodeEditorElement } from 'app/shared/monaco-editor/model/monaco-code-editor-element.model'; -import * as monaco from 'monaco-editor'; +import { MonacoEditorWithActions, ViewZone } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; /** * Class representing a view zone (i.e., vertical space after a certain line) in the Monaco editor. */ -export class MonacoEditorViewZone extends MonacoCodeEditorElement implements monaco.editor.IViewZone { +export class MonacoEditorViewZone extends MonacoCodeEditorElement implements ViewZone { private linkedContentDomNode: HTMLElement; private resizeObserver: ResizeObserver; @@ -22,7 +22,7 @@ export class MonacoEditorViewZone extends MonacoCodeEditorElement implements mon * @param linkedContentDomNode The content to which this view zone should be linked. When the linked content * resizes, so does this view zone. Note that the content must be rendered elsewhere, e.g. in an {@link MonacoEditorOverlayWidget}. */ - constructor(editor: monaco.editor.ICodeEditor, afterLineNumber: number, linkedContentDomNode: HTMLElement) { + constructor(editor: MonacoEditorWithActions, afterLineNumber: number, linkedContentDomNode: HTMLElement) { // id is unavailable until the view zone is added to the editor. super(editor, undefined); this.afterLineNumber = afterLineNumber; diff --git a/src/main/webapp/app/shared/monaco-editor/monaco-editor-option.helper.ts b/src/main/webapp/app/shared/monaco-editor/monaco-editor-option.helper.ts index ea36346ec1d3..f8d309cd3608 100644 --- a/src/main/webapp/app/shared/monaco-editor/monaco-editor-option.helper.ts +++ b/src/main/webapp/app/shared/monaco-editor/monaco-editor-option.helper.ts @@ -1,4 +1,5 @@ -import { MonacoEditorOptionPreset, MonacoEditorOptions } from 'app/shared/monaco-editor/model/monaco-editor-option-preset.model'; +import { MonacoEditorOptionPreset } from 'app/shared/monaco-editor/model/monaco-editor-option-preset.model'; +import { MonacoEditorOptions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; export const SHORT_ANSWER_QUIZ_QUESTION_EDITOR_OPTIONS = new MonacoEditorOptionPreset({ // Hide the gutter diff --git a/src/main/webapp/app/shared/monaco-editor/monaco-editor.component.ts b/src/main/webapp/app/shared/monaco-editor/monaco-editor.component.ts index 0e63c2081074..253d7c04ce4b 100644 --- a/src/main/webapp/app/shared/monaco-editor/monaco-editor.component.ts +++ b/src/main/webapp/app/shared/monaco-editor/monaco-editor.component.ts @@ -10,6 +10,7 @@ import { MonacoEditorLineDecorationsHoverButton } from './model/monaco-editor-li import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; import { TranslateService } from '@ngx-translate/core'; import { MonacoEditorOptionPreset } from 'app/shared/monaco-editor/model/monaco-editor-option-preset.model'; +import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; export const MAX_TAB_SIZE = 8; export type EditorPosition = { lineNumber: number; column: number }; @@ -21,7 +22,7 @@ export type EditorPosition = { lineNumber: number; column: number }; encapsulation: ViewEncapsulation.None, }) export class MonacoEditorComponent implements OnInit, OnDestroy { - private _editor: monaco.editor.IStandaloneCodeEditor; + private _editor: MonacoEditorWithActions; private monacoEditorContainerElement: HTMLElement; themeSubscription?: Subscription; models: monaco.editor.IModel[] = []; @@ -285,9 +286,7 @@ export class MonacoEditorComponent implements OnInit, OnDestroy { } changeTheme(artemisTheme: Theme): void { - this._editor.updateOptions({ - theme: artemisTheme === Theme.DARK ? 'vs-dark' : 'vs-light', - }); + monaco.editor.setTheme(artemisTheme === Theme.DARK ? 'vs-dark' : 'vs-light'); } layout(): void { From db328a4e5e6f66a757bb505270763e505ac2893c Mon Sep 17 00:00:00 2001 From: Patrik Zander Date: Fri, 30 Aug 2024 22:46:21 +0200 Subject: [PATCH 03/27] Refactor test-case-action --- .../model/actions/monaco-editor.util.ts | 4 +- .../model/actions/monaco-test-case.action.ts | 45 ++++++------------- .../monaco-editor-action.integration.spec.ts | 6 +-- 3 files changed, 17 insertions(+), 38 deletions(-) diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor.util.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor.util.ts index 643a8115bee9..efb4e178c87d 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor.util.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor.util.ts @@ -7,7 +7,6 @@ import * as monaco from 'monaco-editor'; // Generic Monaco editor types export type DisposableEditorElement = monaco.IDisposable; export type MonacoEditorWithActions = monaco.editor.ICodeEditor & { addAction: (action: monaco.editor.IActionDescriptor) => DisposableEditorElement }; -export type MonacoEditorTextModel = monaco.editor.ITextModel; export type EditorPosition = monaco.IPosition; export type EditorRange = monaco.IRange; export type MonacoEditorOptions = monaco.editor.IEditorOptions; @@ -21,10 +20,9 @@ export type GlyphMarginPosition = monaco.editor.IGlyphMarginWidgetPosition; export type OverlayWidget = monaco.editor.IOverlayWidget; export type OverlayWidgetPosition = monaco.editor.IOverlayWidgetPosition | null; // null is used by the monaco editor API export type ViewZone = monaco.editor.IViewZone; +// Enums export const GlyphMarginLane = monaco.editor.GlyphMarginLane; export const TrackedRangeStickiness = monaco.editor.TrackedRangeStickiness; - -// Enums for Actions export const KeyModifier = monaco.KeyMod; export const KeyCode = monaco.KeyCode; export const CompletionItemKind = monaco.languages.CompletionItemKind; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-test-case.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-test-case.action.ts index 7d6fdcc82fbd..a61778e654ae 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-test-case.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-test-case.action.ts @@ -1,13 +1,13 @@ import { TranslateService } from '@ngx-translate/core'; -import * as monaco from 'monaco-editor'; import { DomainActionWithOptionsArguments, MonacoEditorDomainActionWithOptions } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action-with-options.model'; -import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { CompletionItemKind, DisposableEditorElement, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { ValueItem } from 'app/shared/markdown-editor/value-item.model'; /** * Action to insert a test case into the editor. It also registers a completion item provider offers all possible test cases as completion items to the user. */ export class MonacoTestCaseAction extends MonacoEditorDomainActionWithOptions { - disposableCompletionProvider?: monaco.IDisposable; + disposableCompletionProvider?: DisposableEditorElement; static readonly ID = 'monaco-test-case.action'; static readonly DEFAULT_INSERT_TEXT = 'testCaseName()'; @@ -24,38 +24,19 @@ export class MonacoTestCaseAction extends MonacoEditorDomainActionWithOptions { */ register(editor: MonacoEditorWithActions, translateService: TranslateService) { super.register(editor, translateService); - const model = editor.getModel(); - if (!model) { - throw new Error(`A model must be attached to the editor to use the ${this.id} action.`); - } - const languageId = model.getLanguageId(); - const modelId = model.id; - this.disposableCompletionProvider = monaco.languages.registerCompletionItemProvider(languageId, { - provideCompletionItems: (model: monaco.editor.ITextModel, position: monaco.Position): monaco.languages.CompletionList | undefined => { - if (model.id !== modelId) { - return undefined; - } - // Replace the current word with the inserted test case - const wordUntilPosition = model.getWordUntilPosition(position); - const range = { - startLineNumber: position.lineNumber, - startColumn: wordUntilPosition.startColumn, - endLineNumber: position.lineNumber, - endColumn: wordUntilPosition.endColumn, - }; - - // We can simply map all possible values here. The Monaco editor filters the items based on the user input. + this.disposableCompletionProvider = this.registerCompletionProviderForCurrentModel( + editor, + () => Promise.resolve(this.values), + (item, range) => { return { - suggestions: this.values.map((value) => ({ - label: value.value, - kind: monaco.languages.CompletionItemKind.Constant, - insertText: value.value, - range, - detail: 'Test', - })), + label: item.value, + kind: CompletionItemKind.Constant, + insertText: item.value, + range, + detail: 'Test', }; }, - }); + ); } dispose() { diff --git a/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-action.integration.spec.ts b/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-action.integration.spec.ts index 3ccaa08b5f79..ff11be7a94d1 100644 --- a/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-action.integration.spec.ts +++ b/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-action.integration.spec.ts @@ -149,7 +149,7 @@ describe('MonacoEditorActionIntegration', () => { expect(registerAction).toThrow(Error); }); - it('should provide test case completions', () => { + it('should provide test case completions', async () => { comp.changeModel('testCase', '', 'custom-md'); const model = comp.models[0]; const action = new MonacoTestCaseAction(); @@ -163,7 +163,7 @@ describe('MonacoEditorActionIntegration', () => { const completionFunction = registerCompletionProviderStub.mock.calls[0][1].provideCompletionItems; expect(completionFunction).toBeDefined(); // We do not use completionContext and cancellationToken, but they are required by the function signature. Therefore, we pass empty objects. - const completionList = completionFunction(model, new monaco.Position(1, 1), {} as monaco.languages.CompletionContext, {} as monaco.CancellationToken); + const completionList = await completionFunction(model, new monaco.Position(1, 1), {} as monaco.languages.CompletionContext, {} as monaco.CancellationToken); const suggestions = (completionList as monaco.languages.CompletionList)!.suggestions; expect(suggestions).toHaveLength(2); expect(suggestions[0].label).toBe(action.values[0].value); @@ -172,7 +172,7 @@ describe('MonacoEditorActionIntegration', () => { // The completion provider should only provide completions for the current model. comp.changeModel('other', '', 'custom-md'); const otherModel = comp.models[1]; - const completionListOther = completionFunction(otherModel, new monaco.Position(1, 1), {} as monaco.languages.CompletionContext, {} as monaco.CancellationToken); + const completionListOther = await completionFunction(otherModel, new monaco.Position(1, 1), {} as monaco.languages.CompletionContext, {} as monaco.CancellationToken); expect(completionListOther).toBeUndefined(); }); From 62226bf346d63f36ad1c9d2f87aba214efa871e5 Mon Sep 17 00:00:00 2001 From: Patrik Zander Date: Fri, 30 Aug 2024 23:03:46 +0200 Subject: [PATCH 04/27] Rename type aliases --- .../monaco/code-editor-monaco.component.ts | 5 +-- .../monaco-channel-reference.action.ts | 6 ++-- .../monaco-exercise-reference.action.ts | 6 ++-- .../monaco-user-mention.action.ts | 6 ++-- .../actions/monaco-editor-action.model.ts | 33 ++++++++----------- .../model/actions/monaco-editor.util.ts | 18 +++++----- .../model/actions/monaco-test-case.action.ts | 4 +-- .../model/monaco-code-editor-element.model.ts | 4 +-- .../monaco-editor-build-annotation.model.ts | 12 +++---- ...tor-line-decorations-hover-button.model.ts | 16 ++++----- .../monaco-editor-line-highlight.model.ts | 12 +++---- .../monaco-editor-option-preset.model.ts | 4 +-- .../monaco-editor-option.helper.ts | 4 +-- .../monaco-editor/monaco-editor.component.ts | 7 ++-- 14 files changed, 66 insertions(+), 71 deletions(-) diff --git a/src/main/webapp/app/exercises/programming/shared/code-editor/monaco/code-editor-monaco.component.ts b/src/main/webapp/app/exercises/programming/shared/code-editor/monaco/code-editor-monaco.component.ts index b16d76dc66a4..06b2fda7dcbd 100644 --- a/src/main/webapp/app/exercises/programming/shared/code-editor/monaco/code-editor-monaco.component.ts +++ b/src/main/webapp/app/exercises/programming/shared/code-editor/monaco/code-editor-monaco.component.ts @@ -3,7 +3,7 @@ import { RepositoryFileService } from 'app/exercises/shared/result/repository.se import { CodeEditorRepositoryFileService, ConnectionError } from 'app/exercises/programming/shared/code-editor/service/code-editor-repository.service'; import { CodeEditorFileService } from 'app/exercises/programming/shared/code-editor/service/code-editor-file.service'; import { LocalStorageService } from 'ngx-webstorage'; -import { EditorPosition, MonacoEditorComponent } from 'app/shared/monaco-editor/monaco-editor.component'; +import { MonacoEditorComponent } from 'app/shared/monaco-editor/monaco-editor.component'; import { firstValueFrom, timeout } from 'rxjs'; import { FEEDBACK_SUGGESTION_ACCEPTED_IDENTIFIER, FEEDBACK_SUGGESTION_IDENTIFIER, Feedback } from 'app/entities/feedback.model'; import { Course } from 'app/entities/course.model'; @@ -21,8 +21,9 @@ import { fromPairs, pickBy } from 'lodash-es'; import { CodeEditorTutorAssessmentInlineFeedbackSuggestionComponent } from 'app/exercises/programming/assess/code-editor-tutor-assessment-inline-feedback-suggestion.component'; import { MonacoEditorLineHighlight } from 'app/shared/monaco-editor/model/monaco-editor-line-highlight.model'; import { FileTypeService } from 'app/exercises/programming/shared/service/file-type.service'; +import { Position } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; -type FileSession = { [fileName: string]: { code: string; cursor: EditorPosition; loadingError: boolean } }; +type FileSession = { [fileName: string]: { code: string; cursor: Position; loadingError: boolean } }; export type Annotation = { fileName: string; row: number; column: number; text: string; type: string; timestamp: number; hash?: string }; @Component({ selector: 'jhi-code-editor-monaco', diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts index 1add30cbf646..c5689bee10db 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts @@ -5,7 +5,7 @@ import { ChannelIdAndNameDTO } from 'app/entities/metis/conversation/channel.mod import { MetisService } from 'app/shared/metis/metis.service'; import { ChannelService } from 'app/shared/metis/conversations/channel.service'; import { firstValueFrom } from 'rxjs'; -import { CompletionItemKind, DisposableEditorElement, EditorRange, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { CompletionItemKind, Disposable, MonacoEditorWithActions, Range } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; /** * Action to insert a reference to a channel into the editor. Users that type a # will see a list of available channels to reference. @@ -15,7 +15,7 @@ export class MonacoChannelReferenceAction extends MonacoEditorAction { static readonly DEFAULT_INSERT_TEXT = '#'; cachedChannels?: ChannelIdAndNameDTO[]; - disposableCompletionProvider?: DisposableEditorElement; + disposableCompletionProvider?: Disposable; constructor( private readonly metisService: MetisService, @@ -34,7 +34,7 @@ export class MonacoChannelReferenceAction extends MonacoEditorAction { this.disposableCompletionProvider = this.registerCompletionProviderForCurrentModel( editor, this.fetchChannels.bind(this), - (channel: ChannelIdAndNameDTO, range: EditorRange) => ({ + (channel: ChannelIdAndNameDTO, range: Range) => ({ label: `#${channel.name}`, kind: CompletionItemKind.Constant, insertText: `[channel]${channel.name}(${channel.id})[/channel]`, diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action.ts index 3e24ceeecf15..ce202363f323 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action.ts @@ -2,7 +2,7 @@ import { TranslateService } from '@ngx-translate/core'; import { MetisService } from 'app/shared/metis/metis.service'; import { MonacoEditorDomainActionWithOptions } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action-with-options.model'; import { ValueItem } from 'app/shared/markdown-editor/value-item.model'; -import { CompletionItemKind, DisposableEditorElement, EditorRange, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { CompletionItemKind, Disposable, MonacoEditorWithActions, Range } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; /** * Action to insert a reference to an exercise into the editor. Users that type a / will see a list of available exercises to reference. @@ -11,7 +11,7 @@ export class MonacoExerciseReferenceAction extends MonacoEditorDomainActionWithO static readonly ID = 'monaco-exercise-reference.action'; static readonly DEFAULT_INSERT_TEXT = '/exercise'; - disposableCompletionProvider?: DisposableEditorElement; + disposableCompletionProvider?: Disposable; constructor(private readonly metisService: MetisService) { super(MonacoExerciseReferenceAction.ID, 'artemisApp.metis.editor.exercise'); @@ -35,7 +35,7 @@ export class MonacoExerciseReferenceAction extends MonacoEditorDomainActionWithO this.disposableCompletionProvider = this.registerCompletionProviderForCurrentModel( editor, () => Promise.resolve(this.getValues()), - (item: ValueItem, range: EditorRange) => ({ + (item: ValueItem, range: Range) => ({ label: `/exercise ${item.value}`, kind: CompletionItemKind.Constant, insertText: `[${item.type}]${item.value}(${this.metisService.getLinkForExercise(item.id)})[/${item.type}]`, diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts index d7149ae8bdf2..23dd2f64d413 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts @@ -5,14 +5,14 @@ import { CourseManagementService } from 'app/course/manage/course-management.ser import { MetisService } from 'app/shared/metis/metis.service'; import { firstValueFrom } from 'rxjs'; import { UserNameAndLoginDTO } from 'app/core/user/user.model'; -import { CompletionItemKind, DisposableEditorElement, EditorRange, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { CompletionItemKind, Disposable, MonacoEditorWithActions, Range } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; /** * Action to insert a user mention into the editor. Users that type a @ will see a list of available users to mention. * Users will be fetched repeatedly as the user types to provide up-to-date results. */ export class MonacoUserMentionAction extends MonacoEditorAction { - disposableCompletionProvider?: DisposableEditorElement; + disposableCompletionProvider?: Disposable; static readonly ID = 'monaco-user-mention.action'; static readonly DEFAULT_INSERT_TEXT = '@'; @@ -34,7 +34,7 @@ export class MonacoUserMentionAction extends MonacoEditorAction { this.disposableCompletionProvider = this.registerCompletionProviderForCurrentModel( editor, this.loadUsersForSearchTerm.bind(this), - (user: UserNameAndLoginDTO, range: EditorRange) => ({ + (user: UserNameAndLoginDTO, range: Range) => ({ label: `@${user.name}`, kind: CompletionItemKind.User, insertText: `[user]${user.name}(${user.login})[/user]`, diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts index d1174b045251..e29a57dd91f7 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts @@ -2,9 +2,9 @@ import { IconDefinition } from '@fortawesome/fontawesome-svg-core'; import { TranslateService } from '@ngx-translate/core'; import * as monaco from 'monaco-editor'; import { enterFullscreen, exitFullscreen, isFullScreen } from 'app/shared/util/fullscreen.util'; -import { DisposableEditorElement, EditorPosition, EditorRange, MonacoEditorWithActions, makeEditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { Disposable, MonacoEditorWithActions, Position, Range, makeEditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; -export abstract class MonacoEditorAction implements monaco.editor.IActionDescriptor, DisposableEditorElement { +export abstract class MonacoEditorAction implements monaco.editor.IActionDescriptor, Disposable { // IActionDescriptor id: string; label: string; @@ -95,7 +95,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip registerCompletionProviderForCurrentModel( editor: MonacoEditorWithActions, searchFn: (searchTerm?: string) => Promise, - mapToSuggestionFn: (item: ItemType, range: EditorRange) => monaco.languages.CompletionItem, + mapToSuggestionFn: (item: ItemType, range: Range) => monaco.languages.CompletionItem, triggerCharacter?: string, listIncomplete?: boolean, ): monaco.IDisposable { @@ -113,7 +113,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip return monaco.languages.registerCompletionItemProvider(languageId, { // We only want to trigger the completion provider if the trigger character is typed. However, we also allow numbers to trigger the completion, as they would not normally trigger it. triggerCharacters: triggerCharacter ? [triggerCharacter, ...'0123456789'] : undefined, - provideCompletionItems: async (model: monaco.editor.ITextModel, position: EditorPosition): Promise => { + provideCompletionItems: async (model: monaco.editor.ITextModel, position: Position): Promise => { if (model.id !== modelId) { return undefined; } @@ -154,12 +154,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param triggerCharacter The character that triggers the sequence. If not provided, the sequence is assumed to start at the beginning of the word. * @param lengthLimit The maximum length of the sequence to find. Defaults to 25. */ - findTypedSequenceUntilPosition( - model: monaco.editor.ITextModel, - position: EditorPosition, - triggerCharacter?: string, - lengthLimit = 25, - ): monaco.editor.IWordAtPosition | undefined { + findTypedSequenceUntilPosition(model: monaco.editor.ITextModel, position: Position, triggerCharacter?: string, lengthLimit = 25): monaco.editor.IWordAtPosition | undefined { // Find the sequence of characters that was typed between the trigger character and the current position. If no trigger character is provided, we assume the sequence starts at the beginning of the word. if (!triggerCharacter) { return model.getWordUntilPosition(position); @@ -255,7 +250,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param position The position to insert the text at. * @param text The text to insert. */ - insertTextAtPosition(editor: MonacoEditorWithActions, position: EditorPosition, text: string): void { + insertTextAtPosition(editor: MonacoEditorWithActions, position: Position, text: string): void { this.replaceTextAtRange(editor, makeEditorRange(position.lineNumber, position.column, position.lineNumber, position.column), text); } @@ -265,7 +260,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param range The range to replace the text at. * @param text The text to replace the range with. */ - replaceTextAtRange(editor: MonacoEditorWithActions, range: EditorRange, text: string): void { + replaceTextAtRange(editor: MonacoEditorWithActions, range: Range, text: string): void { editor.executeEdits(this.id, [{ range, text }]); } @@ -274,7 +269,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param editor The editor to delete the text in. * @param range The range to delete the text at. */ - deleteTextAtRange(editor: MonacoEditorWithActions, range: EditorRange): void { + deleteTextAtRange(editor: MonacoEditorWithActions, range: Range): void { this.replaceTextAtRange(editor, range, ''); } @@ -283,7 +278,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param editor The editor to get the text from. * @param range The range to get the text from. */ - getTextAtRange(editor: MonacoEditorWithActions, range: EditorRange): string | undefined { + getTextAtRange(editor: MonacoEditorWithActions, range: Range): string | undefined { // End of line preference is important here. Otherwise, Windows may use CRLF line endings. return editor.getModel()?.getValueInRange(range, monaco.editor.EndOfLinePreference.LF); } @@ -309,7 +304,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * Gets the position of the last character in the editor. * @param editor The editor to get the position from. */ - getEndPosition(editor: MonacoEditorWithActions): EditorPosition { + getEndPosition(editor: MonacoEditorWithActions): Position { return editor.getModel()?.getFullModelRange().getEndPosition() ?? { lineNumber: 1, column: 1 }; } @@ -319,14 +314,14 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param position The position to set. * @param revealLine Whether to scroll the editor to reveal the line the position is on. Defaults to false. */ - setPosition(editor: MonacoEditorWithActions, position: EditorPosition, revealLine = false): void { + setPosition(editor: MonacoEditorWithActions, position: Position, revealLine = false): void { editor.setPosition(position); if (revealLine) { editor.revealLineInCenter(position.lineNumber); } } - getPosition(editor: MonacoEditorWithActions): EditorPosition { + getPosition(editor: MonacoEditorWithActions): Position { return editor.getPosition() ?? { lineNumber: 1, column: 1 }; } @@ -335,7 +330,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param editor The editor to set the selection in. * @param selection The selection to set. */ - setSelection(editor: MonacoEditorWithActions, selection: EditorRange): void { + setSelection(editor: MonacoEditorWithActions, selection: Range): void { editor.setSelection(selection); editor.revealRangeInCenter(selection); } @@ -354,7 +349,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param editor The editor to adjust the cursor position in. */ moveCursorToEndOfLine(editor: MonacoEditorWithActions): void { - const position: EditorPosition = { ...this.getPosition(editor), column: Number.POSITIVE_INFINITY }; + const position: Position = { ...this.getPosition(editor), column: Number.POSITIVE_INFINITY }; this.setPosition(editor, position); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor.util.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor.util.ts index efb4e178c87d..dc0d62654d9d 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor.util.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor.util.ts @@ -5,15 +5,15 @@ import * as monaco from 'monaco-editor'; */ // Generic Monaco editor types -export type DisposableEditorElement = monaco.IDisposable; -export type MonacoEditorWithActions = monaco.editor.ICodeEditor & { addAction: (action: monaco.editor.IActionDescriptor) => DisposableEditorElement }; -export type EditorPosition = monaco.IPosition; -export type EditorRange = monaco.IRange; -export type MonacoEditorOptions = monaco.editor.IEditorOptions; +export type Disposable = monaco.IDisposable; +export type MonacoEditorWithActions = monaco.editor.ICodeEditor & { addAction: (action: monaco.editor.IActionDescriptor) => Disposable }; +export type Position = monaco.IPosition; +export type Range = monaco.IRange; +export type EditorOptions = monaco.editor.IEditorOptions; export type EditorMouseEvent = monaco.editor.IEditorMouseEvent; // Types for elements in the editor -export type DecorationsCollection = monaco.editor.IEditorDecorationsCollection; -export type DeltaDecoration = monaco.editor.IModelDeltaDecoration; +export type EditorDecorationsCollection = monaco.editor.IEditorDecorationsCollection; +export type ModelDeltaDecoration = monaco.editor.IModelDeltaDecoration; export type GlyphMarginWidget = monaco.editor.IGlyphMarginWidget; export type GlyphMarginLane = monaco.editor.GlyphMarginLane; export type GlyphMarginPosition = monaco.editor.IGlyphMarginWidgetPosition; @@ -27,10 +27,10 @@ export const KeyModifier = monaco.KeyMod; export const KeyCode = monaco.KeyCode; export const CompletionItemKind = monaco.languages.CompletionItemKind; -export function makeEditorPosition(lineNumber: number, column: number): EditorPosition { +export function makeEditorPosition(lineNumber: number, column: number): Position { return { lineNumber, column }; } -export function makeEditorRange(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number): EditorRange { +export function makeEditorRange(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number): Range { return { startLineNumber, startColumn, endLineNumber, endColumn }; } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-test-case.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-test-case.action.ts index a61778e654ae..441a47ee1586 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-test-case.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-test-case.action.ts @@ -1,13 +1,13 @@ import { TranslateService } from '@ngx-translate/core'; import { DomainActionWithOptionsArguments, MonacoEditorDomainActionWithOptions } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action-with-options.model'; -import { CompletionItemKind, DisposableEditorElement, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { CompletionItemKind, Disposable, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; import { ValueItem } from 'app/shared/markdown-editor/value-item.model'; /** * Action to insert a test case into the editor. It also registers a completion item provider offers all possible test cases as completion items to the user. */ export class MonacoTestCaseAction extends MonacoEditorDomainActionWithOptions { - disposableCompletionProvider?: DisposableEditorElement; + disposableCompletionProvider?: Disposable; static readonly ID = 'monaco-test-case.action'; static readonly DEFAULT_INSERT_TEXT = 'testCaseName()'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/monaco-code-editor-element.model.ts b/src/main/webapp/app/shared/monaco-editor/model/monaco-code-editor-element.model.ts index c472c4bab839..b67793e2fd39 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/monaco-code-editor-element.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/monaco-code-editor-element.model.ts @@ -1,9 +1,9 @@ -import { DisposableEditorElement, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { Disposable, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; /** * Abstract class representing an element in the Monaco editor, e.g. a line widget. */ -export abstract class MonacoCodeEditorElement implements DisposableEditorElement { +export abstract class MonacoCodeEditorElement implements Disposable { static readonly CSS_HIDDEN_CLASS = 'monaco-hidden-element'; private id: string | undefined; diff --git a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-build-annotation.model.ts b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-build-annotation.model.ts index edbe3a845cbe..0e5588c2ca4d 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-build-annotation.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-build-annotation.model.ts @@ -1,10 +1,10 @@ import { MonacoCodeEditorElement } from 'app/shared/monaco-editor/model/monaco-code-editor-element.model'; import { MonacoEditorGlyphMarginWidget } from 'app/shared/monaco-editor/model/monaco-editor-glyph-margin-widget.model'; import { - DecorationsCollection, - DeltaDecoration, - DisposableEditorElement, + Disposable, + EditorDecorationsCollection, GlyphMarginLane, + ModelDeltaDecoration, MonacoEditorWithActions, TrackedRangeStickiness, makeEditorRange, @@ -23,11 +23,11 @@ export enum MonacoEditorBuildAnnotationType { */ export class MonacoEditorBuildAnnotation extends MonacoCodeEditorElement { private glyphMarginWidget: MonacoEditorGlyphMarginWidget; - private decorationsCollection: DecorationsCollection; + private decorationsCollection: EditorDecorationsCollection; private outdated: boolean; private hoverMessage: string; private type: MonacoEditorBuildAnnotationType; - private updateListener: DisposableEditorElement; + private updateListener: Disposable; /** * @param editor The editor to render this annotation in. @@ -54,7 +54,7 @@ export class MonacoEditorBuildAnnotation extends MonacoCodeEditorElement { * Returns an object (a delta decoration) detailing the position and styling of the annotation. * @private */ - private getAssociatedDeltaDecoration(): DeltaDecoration { + private getAssociatedDeltaDecoration(): ModelDeltaDecoration { const marginClassName = this.outdated ? 'monaco-annotation-outdated' : `monaco-annotation-${this.type}`; const lineNumber = this.getLineNumber(); return { diff --git a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-line-decorations-hover-button.model.ts b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-line-decorations-hover-button.model.ts index 23a1a7ff15b4..f743656c1c65 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-line-decorations-hover-button.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-line-decorations-hover-button.model.ts @@ -1,9 +1,9 @@ import { MonacoCodeEditorElement } from 'app/shared/monaco-editor/model/monaco-code-editor-element.model'; import { - DecorationsCollection, - DeltaDecoration, - DisposableEditorElement, + Disposable, + EditorDecorationsCollection, EditorMouseEvent, + ModelDeltaDecoration, MonacoEditorWithActions, makeEditorRange, } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; @@ -15,12 +15,12 @@ import { export class MonacoEditorLineDecorationsHoverButton extends MonacoCodeEditorElement { private clickCallback: (lineNumber: number) => void; private currentLineNumber = 1; - private decorationsCollection: DecorationsCollection; + private decorationsCollection: EditorDecorationsCollection; private readonly className: string; - private mouseMoveListener?: DisposableEditorElement; - private mouseDownListener?: DisposableEditorElement; - private mouseLeaveListener?: DisposableEditorElement; + private mouseMoveListener?: Disposable; + private mouseDownListener?: Disposable; + private mouseLeaveListener?: Disposable; /** * @param editor The editor to which to add the button. @@ -90,7 +90,7 @@ export class MonacoEditorLineDecorationsHoverButton extends MonacoCodeEditorElem this.decorationsCollection.set([this.getAssociatedDeltaDecoration()]); } - private getAssociatedDeltaDecoration(): DeltaDecoration { + private getAssociatedDeltaDecoration(): ModelDeltaDecoration { return { range: makeEditorRange(this.currentLineNumber, 1, this.currentLineNumber, 1), options: { diff --git a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-line-highlight.model.ts b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-line-highlight.model.ts index 9f6d97a9c8eb..c3d62c4ec55b 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-line-highlight.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-line-highlight.model.ts @@ -1,9 +1,9 @@ import { MonacoCodeEditorElement } from 'app/shared/monaco-editor/model/monaco-code-editor-element.model'; import { - DecorationsCollection, - DeltaDecoration, - EditorRange, + EditorDecorationsCollection, + ModelDeltaDecoration, MonacoEditorWithActions, + Range, TrackedRangeStickiness, makeEditorRange, } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; @@ -13,10 +13,10 @@ import { * The highlighted lines can have separate styles for the margin and the line. */ export class MonacoEditorLineHighlight extends MonacoCodeEditorElement { - private range: EditorRange; + private range: Range; private className?: string; private marginClassName?: string; - private decorationsCollection: DecorationsCollection; + private decorationsCollection: EditorDecorationsCollection; /** * @param editor The editor to highlight lines in. @@ -34,7 +34,7 @@ export class MonacoEditorLineHighlight extends MonacoCodeEditorElement { this.decorationsCollection = editor.createDecorationsCollection([]); } - private getAssociatedDeltaDecoration(): DeltaDecoration { + private getAssociatedDeltaDecoration(): ModelDeltaDecoration { return { range: this.range, options: { diff --git a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-option-preset.model.ts b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-option-preset.model.ts index e1a23c5ab4d9..843cd4701e93 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-option-preset.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-option-preset.model.ts @@ -1,11 +1,11 @@ -import { MonacoEditorOptions, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { EditorOptions, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; /** * A preset of Monaco Editor options that can be applied to an editor for specific use cases, e.g. short answer quiz questions. * Presets are defined in the file monaco-editor-option.helper.ts. */ export class MonacoEditorOptionPreset { - constructor(private options: MonacoEditorOptions) {} + constructor(private options: EditorOptions) {} /** * Update the editor options with the preset options. diff --git a/src/main/webapp/app/shared/monaco-editor/monaco-editor-option.helper.ts b/src/main/webapp/app/shared/monaco-editor/monaco-editor-option.helper.ts index f8d309cd3608..ddc632613694 100644 --- a/src/main/webapp/app/shared/monaco-editor/monaco-editor-option.helper.ts +++ b/src/main/webapp/app/shared/monaco-editor/monaco-editor-option.helper.ts @@ -1,5 +1,5 @@ import { MonacoEditorOptionPreset } from 'app/shared/monaco-editor/model/monaco-editor-option-preset.model'; -import { MonacoEditorOptions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { EditorOptions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; export const SHORT_ANSWER_QUIZ_QUESTION_EDITOR_OPTIONS = new MonacoEditorOptionPreset({ // Hide the gutter @@ -16,7 +16,7 @@ export const SHORT_ANSWER_QUIZ_QUESTION_EDITOR_OPTIONS = new MonacoEditorOptionP renderLineHighlight: 'none', }); -const defaultMarkdownOptions: MonacoEditorOptions = { +const defaultMarkdownOptions: EditorOptions = { // Sets up the layout to make the editor look more like a text field (no line numbers, margin, or highlights). lineNumbers: 'off', glyphMargin: false, diff --git a/src/main/webapp/app/shared/monaco-editor/monaco-editor.component.ts b/src/main/webapp/app/shared/monaco-editor/monaco-editor.component.ts index 253d7c04ce4b..846e44c7deff 100644 --- a/src/main/webapp/app/shared/monaco-editor/monaco-editor.component.ts +++ b/src/main/webapp/app/shared/monaco-editor/monaco-editor.component.ts @@ -10,10 +10,9 @@ import { MonacoEditorLineDecorationsHoverButton } from './model/monaco-editor-li import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; import { TranslateService } from '@ngx-translate/core'; import { MonacoEditorOptionPreset } from 'app/shared/monaco-editor/model/monaco-editor-option-preset.model'; -import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { MonacoEditorWithActions, Position } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; export const MAX_TAB_SIZE = 8; -export type EditorPosition = { lineNumber: number; column: number }; @Component({ selector: 'jhi-monaco-editor', @@ -158,11 +157,11 @@ export class MonacoEditorComponent implements OnInit, OnDestroy { } } - getPosition(): EditorPosition { + getPosition(): Position { return this._editor.getPosition() ?? { column: 0, lineNumber: 0 }; } - setPosition(position: EditorPosition) { + setPosition(position: Position) { this._editor.setPosition(position); } From a7469e3959476a20cc18b588024ecd8f444de5a6 Mon Sep 17 00:00:00 2001 From: Patrik Zander Date: Fri, 30 Aug 2024 23:10:51 +0200 Subject: [PATCH 05/27] More renaming --- .../monaco/code-editor-monaco.component.ts | 4 +-- .../monaco-channel-reference.action.ts | 4 +-- .../monaco-exercise-reference.action.ts | 4 +-- .../monaco-user-mention.action.ts | 4 +-- .../actions/monaco-editor-action.model.ts | 31 +++++++++++-------- .../model/actions/monaco-editor.util.ts | 9 +++--- .../monaco-editor-line-highlight.model.ts | 4 +-- .../monaco-diff-editor.component.ts | 5 +-- .../monaco-editor/monaco-editor.component.ts | 17 +++++----- 9 files changed, 45 insertions(+), 37 deletions(-) diff --git a/src/main/webapp/app/exercises/programming/shared/code-editor/monaco/code-editor-monaco.component.ts b/src/main/webapp/app/exercises/programming/shared/code-editor/monaco/code-editor-monaco.component.ts index 06b2fda7dcbd..3c4a12677e5d 100644 --- a/src/main/webapp/app/exercises/programming/shared/code-editor/monaco/code-editor-monaco.component.ts +++ b/src/main/webapp/app/exercises/programming/shared/code-editor/monaco/code-editor-monaco.component.ts @@ -21,9 +21,9 @@ import { fromPairs, pickBy } from 'lodash-es'; import { CodeEditorTutorAssessmentInlineFeedbackSuggestionComponent } from 'app/exercises/programming/assess/code-editor-tutor-assessment-inline-feedback-suggestion.component'; import { MonacoEditorLineHighlight } from 'app/shared/monaco-editor/model/monaco-editor-line-highlight.model'; import { FileTypeService } from 'app/exercises/programming/shared/service/file-type.service'; -import { Position } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { EditorPosition } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; -type FileSession = { [fileName: string]: { code: string; cursor: Position; loadingError: boolean } }; +type FileSession = { [fileName: string]: { code: string; cursor: EditorPosition; loadingError: boolean } }; export type Annotation = { fileName: string; row: number; column: number; text: string; type: string; timestamp: number; hash?: string }; @Component({ selector: 'jhi-code-editor-monaco', diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts index c5689bee10db..ec36ec019e9a 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts @@ -5,7 +5,7 @@ import { ChannelIdAndNameDTO } from 'app/entities/metis/conversation/channel.mod import { MetisService } from 'app/shared/metis/metis.service'; import { ChannelService } from 'app/shared/metis/conversations/channel.service'; import { firstValueFrom } from 'rxjs'; -import { CompletionItemKind, Disposable, MonacoEditorWithActions, Range } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { CompletionItemKind, Disposable, EditorRange, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; /** * Action to insert a reference to a channel into the editor. Users that type a # will see a list of available channels to reference. @@ -34,7 +34,7 @@ export class MonacoChannelReferenceAction extends MonacoEditorAction { this.disposableCompletionProvider = this.registerCompletionProviderForCurrentModel( editor, this.fetchChannels.bind(this), - (channel: ChannelIdAndNameDTO, range: Range) => ({ + (channel: ChannelIdAndNameDTO, range: EditorRange) => ({ label: `#${channel.name}`, kind: CompletionItemKind.Constant, insertText: `[channel]${channel.name}(${channel.id})[/channel]`, diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action.ts index ce202363f323..03eb439e9e54 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action.ts @@ -2,7 +2,7 @@ import { TranslateService } from '@ngx-translate/core'; import { MetisService } from 'app/shared/metis/metis.service'; import { MonacoEditorDomainActionWithOptions } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action-with-options.model'; import { ValueItem } from 'app/shared/markdown-editor/value-item.model'; -import { CompletionItemKind, Disposable, MonacoEditorWithActions, Range } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { CompletionItemKind, Disposable, EditorRange, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; /** * Action to insert a reference to an exercise into the editor. Users that type a / will see a list of available exercises to reference. @@ -35,7 +35,7 @@ export class MonacoExerciseReferenceAction extends MonacoEditorDomainActionWithO this.disposableCompletionProvider = this.registerCompletionProviderForCurrentModel( editor, () => Promise.resolve(this.getValues()), - (item: ValueItem, range: Range) => ({ + (item: ValueItem, range: EditorRange) => ({ label: `/exercise ${item.value}`, kind: CompletionItemKind.Constant, insertText: `[${item.type}]${item.value}(${this.metisService.getLinkForExercise(item.id)})[/${item.type}]`, diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts index 23dd2f64d413..740354c43da1 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts @@ -5,7 +5,7 @@ import { CourseManagementService } from 'app/course/manage/course-management.ser import { MetisService } from 'app/shared/metis/metis.service'; import { firstValueFrom } from 'rxjs'; import { UserNameAndLoginDTO } from 'app/core/user/user.model'; -import { CompletionItemKind, Disposable, MonacoEditorWithActions, Range } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { CompletionItemKind, Disposable, EditorRange, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; /** * Action to insert a user mention into the editor. Users that type a @ will see a list of available users to mention. @@ -34,7 +34,7 @@ export class MonacoUserMentionAction extends MonacoEditorAction { this.disposableCompletionProvider = this.registerCompletionProviderForCurrentModel( editor, this.loadUsersForSearchTerm.bind(this), - (user: UserNameAndLoginDTO, range: Range) => ({ + (user: UserNameAndLoginDTO, range: EditorRange) => ({ label: `@${user.name}`, kind: CompletionItemKind.User, insertText: `[user]${user.name}(${user.login})[/user]`, diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts index e29a57dd91f7..3c57500eeb69 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts @@ -2,7 +2,7 @@ import { IconDefinition } from '@fortawesome/fontawesome-svg-core'; import { TranslateService } from '@ngx-translate/core'; import * as monaco from 'monaco-editor'; import { enterFullscreen, exitFullscreen, isFullScreen } from 'app/shared/util/fullscreen.util'; -import { Disposable, MonacoEditorWithActions, Position, Range, makeEditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { Disposable, EditorPosition, EditorRange, MonacoEditorWithActions, makeEditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; export abstract class MonacoEditorAction implements monaco.editor.IActionDescriptor, Disposable { // IActionDescriptor @@ -95,7 +95,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip registerCompletionProviderForCurrentModel( editor: MonacoEditorWithActions, searchFn: (searchTerm?: string) => Promise, - mapToSuggestionFn: (item: ItemType, range: Range) => monaco.languages.CompletionItem, + mapToSuggestionFn: (item: ItemType, range: EditorRange) => monaco.languages.CompletionItem, triggerCharacter?: string, listIncomplete?: boolean, ): monaco.IDisposable { @@ -113,7 +113,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip return monaco.languages.registerCompletionItemProvider(languageId, { // We only want to trigger the completion provider if the trigger character is typed. However, we also allow numbers to trigger the completion, as they would not normally trigger it. triggerCharacters: triggerCharacter ? [triggerCharacter, ...'0123456789'] : undefined, - provideCompletionItems: async (model: monaco.editor.ITextModel, position: Position): Promise => { + provideCompletionItems: async (model: monaco.editor.ITextModel, position: EditorPosition): Promise => { if (model.id !== modelId) { return undefined; } @@ -154,7 +154,12 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param triggerCharacter The character that triggers the sequence. If not provided, the sequence is assumed to start at the beginning of the word. * @param lengthLimit The maximum length of the sequence to find. Defaults to 25. */ - findTypedSequenceUntilPosition(model: monaco.editor.ITextModel, position: Position, triggerCharacter?: string, lengthLimit = 25): monaco.editor.IWordAtPosition | undefined { + findTypedSequenceUntilPosition( + model: monaco.editor.ITextModel, + position: EditorPosition, + triggerCharacter?: string, + lengthLimit = 25, + ): monaco.editor.IWordAtPosition | undefined { // Find the sequence of characters that was typed between the trigger character and the current position. If no trigger character is provided, we assume the sequence starts at the beginning of the word. if (!triggerCharacter) { return model.getWordUntilPosition(position); @@ -250,7 +255,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param position The position to insert the text at. * @param text The text to insert. */ - insertTextAtPosition(editor: MonacoEditorWithActions, position: Position, text: string): void { + insertTextAtPosition(editor: MonacoEditorWithActions, position: EditorPosition, text: string): void { this.replaceTextAtRange(editor, makeEditorRange(position.lineNumber, position.column, position.lineNumber, position.column), text); } @@ -260,7 +265,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param range The range to replace the text at. * @param text The text to replace the range with. */ - replaceTextAtRange(editor: MonacoEditorWithActions, range: Range, text: string): void { + replaceTextAtRange(editor: MonacoEditorWithActions, range: EditorRange, text: string): void { editor.executeEdits(this.id, [{ range, text }]); } @@ -269,7 +274,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param editor The editor to delete the text in. * @param range The range to delete the text at. */ - deleteTextAtRange(editor: MonacoEditorWithActions, range: Range): void { + deleteTextAtRange(editor: MonacoEditorWithActions, range: EditorRange): void { this.replaceTextAtRange(editor, range, ''); } @@ -278,7 +283,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param editor The editor to get the text from. * @param range The range to get the text from. */ - getTextAtRange(editor: MonacoEditorWithActions, range: Range): string | undefined { + getTextAtRange(editor: MonacoEditorWithActions, range: EditorRange): string | undefined { // End of line preference is important here. Otherwise, Windows may use CRLF line endings. return editor.getModel()?.getValueInRange(range, monaco.editor.EndOfLinePreference.LF); } @@ -304,7 +309,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * Gets the position of the last character in the editor. * @param editor The editor to get the position from. */ - getEndPosition(editor: MonacoEditorWithActions): Position { + getEndPosition(editor: MonacoEditorWithActions): EditorPosition { return editor.getModel()?.getFullModelRange().getEndPosition() ?? { lineNumber: 1, column: 1 }; } @@ -314,14 +319,14 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param position The position to set. * @param revealLine Whether to scroll the editor to reveal the line the position is on. Defaults to false. */ - setPosition(editor: MonacoEditorWithActions, position: Position, revealLine = false): void { + setPosition(editor: MonacoEditorWithActions, position: EditorPosition, revealLine = false): void { editor.setPosition(position); if (revealLine) { editor.revealLineInCenter(position.lineNumber); } } - getPosition(editor: MonacoEditorWithActions): Position { + getPosition(editor: MonacoEditorWithActions): EditorPosition { return editor.getPosition() ?? { lineNumber: 1, column: 1 }; } @@ -330,7 +335,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param editor The editor to set the selection in. * @param selection The selection to set. */ - setSelection(editor: MonacoEditorWithActions, selection: Range): void { + setSelection(editor: MonacoEditorWithActions, selection: EditorRange): void { editor.setSelection(selection); editor.revealRangeInCenter(selection); } @@ -349,7 +354,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param editor The editor to adjust the cursor position in. */ moveCursorToEndOfLine(editor: MonacoEditorWithActions): void { - const position: Position = { ...this.getPosition(editor), column: Number.POSITIVE_INFINITY }; + const position: EditorPosition = { ...this.getPosition(editor), column: Number.POSITIVE_INFINITY }; this.setPosition(editor, position); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor.util.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor.util.ts index dc0d62654d9d..cefee33d7c48 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor.util.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor.util.ts @@ -7,8 +7,9 @@ import * as monaco from 'monaco-editor'; // Generic Monaco editor types export type Disposable = monaco.IDisposable; export type MonacoEditorWithActions = monaco.editor.ICodeEditor & { addAction: (action: monaco.editor.IActionDescriptor) => Disposable }; -export type Position = monaco.IPosition; -export type Range = monaco.IRange; +export type MonacoEditorTextModel = monaco.editor.ITextModel; +export type EditorPosition = monaco.IPosition; +export type EditorRange = monaco.IRange; export type EditorOptions = monaco.editor.IEditorOptions; export type EditorMouseEvent = monaco.editor.IEditorMouseEvent; // Types for elements in the editor @@ -27,10 +28,10 @@ export const KeyModifier = monaco.KeyMod; export const KeyCode = monaco.KeyCode; export const CompletionItemKind = monaco.languages.CompletionItemKind; -export function makeEditorPosition(lineNumber: number, column: number): Position { +export function makeEditorPosition(lineNumber: number, column: number): EditorPosition { return { lineNumber, column }; } -export function makeEditorRange(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number): Range { +export function makeEditorRange(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number): EditorRange { return { startLineNumber, startColumn, endLineNumber, endColumn }; } diff --git a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-line-highlight.model.ts b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-line-highlight.model.ts index c3d62c4ec55b..f8ca8ed7999e 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-line-highlight.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-line-highlight.model.ts @@ -1,9 +1,9 @@ import { MonacoCodeEditorElement } from 'app/shared/monaco-editor/model/monaco-code-editor-element.model'; import { EditorDecorationsCollection, + EditorRange, ModelDeltaDecoration, MonacoEditorWithActions, - Range, TrackedRangeStickiness, makeEditorRange, } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; @@ -13,7 +13,7 @@ import { * The highlighted lines can have separate styles for the margin and the line. */ export class MonacoEditorLineHighlight extends MonacoCodeEditorElement { - private range: Range; + private range: EditorRange; private className?: string; private marginClassName?: string; private decorationsCollection: EditorDecorationsCollection; diff --git a/src/main/webapp/app/shared/monaco-editor/monaco-diff-editor.component.ts b/src/main/webapp/app/shared/monaco-editor/monaco-diff-editor.component.ts index 4f66f4813804..1cfa742651d4 100644 --- a/src/main/webapp/app/shared/monaco-editor/monaco-diff-editor.component.ts +++ b/src/main/webapp/app/shared/monaco-editor/monaco-diff-editor.component.ts @@ -3,6 +3,7 @@ import { Theme, ThemeService } from 'app/core/theme/theme.service'; import * as monaco from 'monaco-editor'; import { Subscription } from 'rxjs'; +import { Disposable, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; export type MonacoEditorDiffText = { original: string; modified: string }; @Component({ @@ -15,7 +16,7 @@ export class MonacoDiffEditorComponent implements OnInit, OnDestroy { private _editor: monaco.editor.IStandaloneDiffEditor; monacoDiffEditorContainerElement: HTMLElement; themeSubscription?: Subscription; - listeners: monaco.IDisposable[] = []; + listeners: Disposable[] = []; resizeObserver?: ResizeObserver; @Input() @@ -185,7 +186,7 @@ export class MonacoDiffEditorComponent implements OnInit, OnDestroy { * Returns the content height of the provided editor. * @param editor The editor whose content height should be retrieved. */ - getContentHeightOfEditor(editor: monaco.editor.ICodeEditor): number { + getContentHeightOfEditor(editor: MonacoEditorWithActions): number { return editor.getContentHeight(); } diff --git a/src/main/webapp/app/shared/monaco-editor/monaco-editor.component.ts b/src/main/webapp/app/shared/monaco-editor/monaco-editor.component.ts index 846e44c7deff..0b90fefbdda8 100644 --- a/src/main/webapp/app/shared/monaco-editor/monaco-editor.component.ts +++ b/src/main/webapp/app/shared/monaco-editor/monaco-editor.component.ts @@ -10,7 +10,7 @@ import { MonacoEditorLineDecorationsHoverButton } from './model/monaco-editor-li import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; import { TranslateService } from '@ngx-translate/core'; import { MonacoEditorOptionPreset } from 'app/shared/monaco-editor/model/monaco-editor-option-preset.model'; -import { MonacoEditorWithActions, Position } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { Disposable, EditorPosition, EditorRange, MonacoEditorTextModel, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; export const MAX_TAB_SIZE = 8; @@ -24,7 +24,7 @@ export class MonacoEditorComponent implements OnInit, OnDestroy { private _editor: MonacoEditorWithActions; private monacoEditorContainerElement: HTMLElement; themeSubscription?: Subscription; - models: monaco.editor.IModel[] = []; + models: MonacoEditorTextModel[] = []; lineWidgets: MonacoEditorLineWidget[] = []; editorBuildAnnotations: MonacoEditorBuildAnnotation[] = []; lineHighlights: MonacoEditorLineHighlight[] = []; @@ -105,9 +105,9 @@ export class MonacoEditorComponent implements OnInit, OnDestroy { @Output() onBlurEditor = new EventEmitter(); - private contentHeightListener?: monaco.IDisposable; - private textChangedListener?: monaco.IDisposable; - private blurEditorWidgetListener?: monaco.IDisposable; + private contentHeightListener?: Disposable; + private textChangedListener?: Disposable; + private blurEditorWidgetListener?: Disposable; private textChangedEmitTimeout?: NodeJS.Timeout; ngOnInit(): void { @@ -157,15 +157,15 @@ export class MonacoEditorComponent implements OnInit, OnDestroy { } } - getPosition(): Position { + getPosition(): EditorPosition { return this._editor.getPosition() ?? { column: 0, lineNumber: 0 }; } - setPosition(position: Position) { + setPosition(position: EditorPosition) { this._editor.setPosition(position); } - setSelection(range: monaco.IRange): void { + setSelection(range: EditorRange): void { this._editor.setSelection(range); } @@ -209,6 +209,7 @@ export class MonacoEditorComponent implements OnInit, OnDestroy { * All elements currently rendered in the editor will be disposed. * @param fileName The name of the file to switch to. * @param newFileContent The content of the file (will be retrieved from the model if left out). + * @param languageId The language ID to use for syntax highlighting (will be inferred from the file extension if left out). */ changeModel(fileName: string, newFileContent?: string, languageId?: string) { const uri = monaco.Uri.parse(`inmemory://model/${this._editor.getId()}/${fileName}`); From d386562c120a625c370e6c1bcad60ebbf673aff5 Mon Sep 17 00:00:00 2001 From: Patrik Zander Date: Fri, 30 Aug 2024 23:12:59 +0200 Subject: [PATCH 06/27] More renaming --- .../actions/monaco-editor-action.model.ts | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts index 3c57500eeb69..5b93a4be620d 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts @@ -2,7 +2,14 @@ import { IconDefinition } from '@fortawesome/fontawesome-svg-core'; import { TranslateService } from '@ngx-translate/core'; import * as monaco from 'monaco-editor'; import { enterFullscreen, exitFullscreen, isFullScreen } from 'app/shared/util/fullscreen.util'; -import { Disposable, EditorPosition, EditorRange, MonacoEditorWithActions, makeEditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { + Disposable, + EditorPosition, + EditorRange, + MonacoEditorTextModel, + MonacoEditorWithActions, + makeEditorRange, +} from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; export abstract class MonacoEditorAction implements monaco.editor.IActionDescriptor, Disposable { // IActionDescriptor @@ -17,7 +24,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip /** * The disposable action that is returned by `editor.addAction`. This is required to unregister the action from the editor. */ - disposableAction?: monaco.IDisposable; + disposableAction?: Disposable; /** * The editor (if any) this action is registered in. * @private @@ -113,7 +120,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip return monaco.languages.registerCompletionItemProvider(languageId, { // We only want to trigger the completion provider if the trigger character is typed. However, we also allow numbers to trigger the completion, as they would not normally trigger it. triggerCharacters: triggerCharacter ? [triggerCharacter, ...'0123456789'] : undefined, - provideCompletionItems: async (model: monaco.editor.ITextModel, position: EditorPosition): Promise => { + provideCompletionItems: async (model: MonacoEditorTextModel, position: EditorPosition): Promise => { if (model.id !== modelId) { return undefined; } @@ -154,12 +161,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param triggerCharacter The character that triggers the sequence. If not provided, the sequence is assumed to start at the beginning of the word. * @param lengthLimit The maximum length of the sequence to find. Defaults to 25. */ - findTypedSequenceUntilPosition( - model: monaco.editor.ITextModel, - position: EditorPosition, - triggerCharacter?: string, - lengthLimit = 25, - ): monaco.editor.IWordAtPosition | undefined { + findTypedSequenceUntilPosition(model: MonacoEditorTextModel, position: EditorPosition, triggerCharacter?: string, lengthLimit = 25): monaco.editor.IWordAtPosition | undefined { // Find the sequence of characters that was typed between the trigger character and the current position. If no trigger character is provided, we assume the sequence starts at the beginning of the word. if (!triggerCharacter) { return model.getWordUntilPosition(position); From 40f8d4aeec0aad5eba69ada2190333b9c68b488c Mon Sep 17 00:00:00 2001 From: Patrik Zander Date: Sat, 31 Aug 2024 09:18:50 +0200 Subject: [PATCH 07/27] Basic models for Adapter pattern --- .../adapter/monaco-text-editor.adapter.ts | 86 +++++++++++++++++++ .../adapter/text-editor-adapter.model.ts | 80 +++++++++++++++++ .../adapter/text-editor-completer.model.ts | 29 +++++++ .../text-editor-completion-item.model.ts | 54 ++++++++++++ .../adapter/text-editor-model.model.ts | 1 + .../adapter/text-editor-position.model.ts | 27 ++++++ .../adapter/text-editor-range.model.ts | 35 ++++++++ 7 files changed, 312 insertions(+) create mode 100644 src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts create mode 100644 src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model.ts create mode 100644 src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-completer.model.ts create mode 100644 src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-completion-item.model.ts create mode 100644 src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-model.model.ts create mode 100644 src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-position.model.ts create mode 100644 src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-range.model.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts new file mode 100644 index 000000000000..8ee9175497d8 --- /dev/null +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts @@ -0,0 +1,86 @@ +import { TextEditorAdapter } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; +import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { Disposable } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import * as monaco from 'monaco-editor'; +import { TextEditorCompleter } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-completer.model'; +import { TextEditorModel } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-model.model'; +import { TextEditorRange, makeTextEditorRange } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-range.model'; +import { TextEditorPosition } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-position.model'; + +export class MonacoTextEditorAdapter implements TextEditorAdapter { + constructor(private editor: monaco.editor.IStandaloneCodeEditor) {} + + addAction(action: MonacoEditorAction): Disposable { + const actionDescriptor = { + id: action.id, + label: action.label, + keybindings: action.keybindings, + run: () => { + action.run(this as any); // TODO + }, + }; + return this.editor.addAction(actionDescriptor); + } + + executeAction(action: MonacoEditorAction, args?: object): void { + this.editor.trigger('MonacoTextEditorAdapter::executeAction', action.id, args); + } + + // eslint-disable-next-line @typescript-eslint/no-unused-vars + addCompleter(completer: TextEditorCompleter): Disposable { + // TODO + return { dispose: () => {} }; + } + + getModel(): TextEditorModel { + return new TextEditorModel(); // TODO + } + + layout(): void { + this.editor.layout(); + } + + focus(): void { + this.editor.focus(); + } + + getDomNode(): HTMLElement | undefined { + return this.editor.getDomNode() ?? undefined; + } + + getPosition(): TextEditorPosition { + const position = this.editor.getPosition() ?? { column: 1, lineNumber: 1 }; + return new TextEditorPosition(position.lineNumber, position.column); + } + + setPosition(position: TextEditorPosition): void { + this.editor.setPosition({ lineNumber: position.getLineNumber(), column: position.getColumn() }); + } + + getSelection(): TextEditorRange { + const selection = this.editor.getSelection() ?? { startColumn: 1, startLineNumber: 1, endColumn: 1, endLineNumber: 1 }; + return makeTextEditorRange(selection.startLineNumber, selection.startColumn, selection.endLineNumber, selection.endColumn); + } + + setSelection(selection: TextEditorRange): void { + const startPosition = selection.getStartPosition(); + const endPosition = selection.getEndPosition(); + this.editor.setSelection({ + startLineNumber: startPosition.getLineNumber(), + startColumn: startPosition.getColumn(), + endLineNumber: endPosition.getLineNumber(), + endColumn: endPosition.getColumn(), + }); + } + + revealRange(range: TextEditorRange): void { + const startPosition = range.getStartPosition(); + const endPosition = range.getEndPosition(); + this.editor.revealRangeInCenter({ + startLineNumber: startPosition.getLineNumber(), + startColumn: startPosition.getColumn(), + endLineNumber: endPosition.getLineNumber(), + endColumn: endPosition.getColumn(), + }); + } +} diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model.ts new file mode 100644 index 000000000000..64c43e26d518 --- /dev/null +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model.ts @@ -0,0 +1,80 @@ +import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { Disposable } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditorPosition } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-position.model'; +import { TextEditorRange } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-range.model'; +import { TextEditorModel } from './text-editor-model.model'; +import { TextEditorCompleter } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-completer.model'; + +export interface TextEditorAdapter { + /** + * Adds an action to the editor. An action should only be in one editor at a time. + * @param action The action to add to the editor. + * @return A disposable that can be used to remove the action from the editor. + */ + addAction(action: MonacoEditorAction): Disposable; + + /** + * Executes the given action in the editor. It must be an action that has been added to the editor. + * @param action The action to execute. + * @param args Optional arguments to pass to the action. + */ + executeAction(action: MonacoEditorAction, args?: object): void; + + /** + * Layouts the editor's content and dimensions, e.g. after a resize. + */ + layout(): void; + + /** + * Focuses the input area of the editor. + */ + focus(): void; + + /** + * Gets the DOM node associated with the editor, or undefined if no such node exists. + */ + getDomNode(): HTMLElement | undefined; + + /** + * Gets the position of the cursor in the editor. + * If no suitable position exists, the default position is returned (1, 1). + */ + getPosition(): TextEditorPosition; + + /** + * Sets the position of the cursor in the editor. + * @param position The position to set the cursor to. Line numbers and columns start at 1. + */ + setPosition(position: TextEditorPosition): void; + + /** + * Gets the range representing the current selection in the editor. + * The range may be empty, in which case it represents the position of the cursor (in this case, the start and end positions are the same). + * If no suitable range exists, the default range is returned (1, 1) to (1, 1). + */ + getSelection(): TextEditorRange; + + /** + * Sets the selection in the editor. + * @param selection The range to set the selection to. Line numbers and columns start at 1. + */ + setSelection(selection: TextEditorRange): void; + + /** + * Reveals a range of text in the center of the editor by instantly scrolling to it. + * @param range The range to reveal. + */ + revealRange(range: TextEditorRange): void; + + /** + * Gets the model of the editor. + * The model represents the content of the editor. + */ + getModel(): TextEditorModel; + + /** + * Adds a completer to the editor. + * @param completer The completer to add to the editor. + */ + addCompleter(completer: TextEditorCompleter): Disposable; +} diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-completer.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-completer.model.ts new file mode 100644 index 000000000000..e313d8692720 --- /dev/null +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-completer.model.ts @@ -0,0 +1,29 @@ +import { TextEditorCompletionItem } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-completion-item.model'; + +/** + * An interface for a completer that can be used with a text editor. + * @typeparam ItemType The type of item that the completer returns. + */ +export interface TextEditorCompleter { + /** + * The trigger characters that should cause the completer to search for completions. + */ + triggerCharacters: string[]; + + /** + * Whether the completer has more completions that can be searched for (e.g. if the results depend on a rest call). + */ + completionsAreIncomplete: boolean; + + /** + * Searches for completion items based on the given search string. + * @param searchTerm The text input to use to search for completion items. + */ + searchItems(searchTerm: string): Promise; + + /** + * Maps a completion item to a text editor completion item. + * @param item The completion item to map. + */ + mapCompletionItem(item: ItemType): TextEditorCompletionItem; +} diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-completion-item.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-completion-item.model.ts new file mode 100644 index 000000000000..62cbc2eb671f --- /dev/null +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-completion-item.model.ts @@ -0,0 +1,54 @@ +import { TextEditorRange } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-range.model'; + +export enum TextEditorCompletionItemKind { + /** + * Shows a generic icon for the completion item. + */ + Default, + /** + * Shows a user icon for the completion item. + */ + User, +} + +/** + * Represents a completion item in a text editor. + * Completion items are used to provide suggestions for the user to complete their input. + */ +export class TextEditorCompletionItem { + /** + * Creates a new text editor completion item. + * @param label The label of the completion item, i.e., the text shown in the completion list. + * @param detailText An optional detail text to display alongside the label. + * @param insertText The text to insert into the editor when the completion item is selected. + * @param kind The kind of the completion item, which determines the icon shown in the completion list. + * @param range The range in the editor where the completion item's text should be inserted. + */ + constructor( + private readonly label: string, + private readonly detailText: string | undefined, + private readonly insertText: string, + private readonly kind: TextEditorCompletionItemKind, + private readonly range: TextEditorRange, + ) {} + + getLabel(): string { + return this.label; + } + + getDetailText(): string | undefined { + return this.detailText; + } + + getInsertText(): string { + return this.insertText; + } + + getKind(): TextEditorCompletionItemKind { + return this.kind; + } + + getRange(): TextEditorRange { + return this.range; + } +} diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-model.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-model.model.ts new file mode 100644 index 000000000000..153e9cb29760 --- /dev/null +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-model.model.ts @@ -0,0 +1 @@ +export class TextEditorModel {} diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-position.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-position.model.ts new file mode 100644 index 000000000000..011f21590906 --- /dev/null +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-position.model.ts @@ -0,0 +1,27 @@ +/** + * Represents a position in a text editor consisting of 1-based line numbers and columns. + */ +export class TextEditorPosition { + constructor( + private readonly lineNumber: number, + private readonly column: number, + ) {} + + getLineNumber(): number { + return this.lineNumber; + } + + getColumn(): number { + return this.column; + } +} + +/** + * Creates a new text editor position from the given position, shifted by the given number of lines and columns. + * @param position The position to shift. + * @param lines The number of lines to shift the position by. + * @param columns The number of columns to shift the position by. + */ +export function shiftPosition(position: TextEditorPosition, lines: number, columns: number): TextEditorPosition { + return new TextEditorPosition(position.getLineNumber() + lines, position.getColumn() + columns); +} diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-range.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-range.model.ts new file mode 100644 index 000000000000..5f3784b54960 --- /dev/null +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-range.model.ts @@ -0,0 +1,35 @@ +import { TextEditorPosition } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-position.model'; + +/** + * Represents a range in a text editor consisting of 1-based line numbers and columns. + */ +export class TextEditorRange { + /** + * Creates a new text editor range. + * @param startPosition The position at which this range starts. + * @param endPosition The position at which this range ends. + */ + constructor( + private readonly startPosition: TextEditorPosition, + private readonly endPosition: TextEditorPosition, + ) {} + + getStartPosition(): TextEditorPosition { + return this.startPosition; + } + + getEndPosition(): TextEditorPosition { + return this.endPosition; + } +} + +/** + * Creates a new text editor range. Line numbers and columns start at 1. + * @param startLineNumber The line number of the start of the range. + * @param startColumn The column of the start of the range. + * @param endLineNumber The line number of the end of the range. + * @param endColumn The column of the end of the range. + */ +export function makeTextEditorRange(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number): TextEditorRange { + return new TextEditorRange(new TextEditorPosition(startLineNumber, startColumn), new TextEditorPosition(endLineNumber, endColumn)); +} From 607ca834acdfbc528077f726a95bdc8bf8deb96e Mon Sep 17 00:00:00 2001 From: Patrik Zander Date: Sat, 31 Aug 2024 10:20:28 +0200 Subject: [PATCH 08/27] Basic models for Adapter pattern --- .../model/actions/adapter/text-editor-adapter.model.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model.ts index 64c43e26d518..2bce6229f7e1 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model.ts @@ -75,6 +75,7 @@ export interface TextEditorAdapter { /** * Adds a completer to the editor. * @param completer The completer to add to the editor. + * @return A disposable that can be used to remove the completer from the editor. */ addCompleter(completer: TextEditorCompleter): Disposable; } From 512384e7199c05e5395686dd98f631a58f7a5ded Mon Sep 17 00:00:00 2001 From: Patrik Zander Date: Sat, 31 Aug 2024 10:39:58 +0200 Subject: [PATCH 09/27] Use TextEditor in Actions --- .../adapter/monaco-text-editor.adapter.ts | 4 +- .../adapter/text-editor-adapter.model.ts | 2 +- .../monaco-channel-reference.action.ts | 7 +-- .../monaco-exercise-reference.action.ts | 7 +-- ...aco-lecture-attachment-reference.action.ts | 12 ++--- .../monaco-user-mention.action.ts | 7 +-- .../monaco-grading-credits.action.ts | 4 +- .../monaco-grading-criterion.action.ts | 3 +- .../monaco-grading-description.action.ts | 4 +- .../monaco-grading-feedback.action.ts | 4 +- .../monaco-grading-instruction.action.ts | 4 +- .../monaco-grading-scale.action.ts | 4 +- .../monaco-grading-usage-count.action.ts | 4 +- .../model/actions/monaco-attachment.action.ts | 4 +- .../model/actions/monaco-bold.action.ts | 5 +- .../model/actions/monaco-code-block.action.ts | 4 +- .../model/actions/monaco-code.action.ts | 4 +- .../model/actions/monaco-color.action.ts | 4 +- .../actions/monaco-editor-action.model.ts | 52 ++++++++----------- .../monaco-editor-domain-action.model.ts | 4 +- .../model/actions/monaco-formula.action.ts | 4 +- .../model/actions/monaco-fullscreen.action.ts | 4 +- .../model/actions/monaco-heading.action.ts | 4 +- .../model/actions/monaco-italic.action.ts | 5 +- .../actions/monaco-ordered-list.action.ts | 4 +- .../model/actions/monaco-quote.action.ts | 4 +- .../model/actions/monaco-task.action.ts | 4 +- .../model/actions/monaco-test-case.action.ts | 7 +-- .../model/actions/monaco-underline.action.ts | 5 +- .../actions/monaco-unordered-list.action.ts | 5 +- .../model/actions/monaco-url.action.ts | 4 +- ...o-correct-multiple-choice-answer.action.ts | 4 +- ...onaco-insert-short-answer-option.action.ts | 4 +- .../monaco-insert-short-answer-spot.action.ts | 4 +- .../quiz/monaco-quiz-explanation.action.ts | 4 +- .../actions/quiz/monaco-quiz-hint.action.ts | 4 +- ...aco-wrong-multiple-choice-answer.action.ts | 4 +- 37 files changed, 109 insertions(+), 108 deletions(-) diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts index 8ee9175497d8..94e69c88f538 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts @@ -1,4 +1,4 @@ -import { TextEditorAdapter } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; import { Disposable } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; import * as monaco from 'monaco-editor'; @@ -7,7 +7,7 @@ import { TextEditorModel } from 'app/shared/monaco-editor/model/actions/adapter/ import { TextEditorRange, makeTextEditorRange } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-range.model'; import { TextEditorPosition } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-position.model'; -export class MonacoTextEditorAdapter implements TextEditorAdapter { +export class MonacoTextEditorAdapter implements TextEditor { constructor(private editor: monaco.editor.IStandaloneCodeEditor) {} addAction(action: MonacoEditorAction): Disposable { diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model.ts index 2bce6229f7e1..2d309b14139c 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model.ts @@ -5,7 +5,7 @@ import { TextEditorRange } from 'app/shared/monaco-editor/model/actions/adapter/ import { TextEditorModel } from './text-editor-model.model'; import { TextEditorCompleter } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-completer.model'; -export interface TextEditorAdapter { +export interface TextEditor { /** * Adds an action to the editor. An action should only be in one editor at a time. * @param action The action to add to the editor. diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts index ec36ec019e9a..f4e430978a86 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts @@ -5,7 +5,8 @@ import { ChannelIdAndNameDTO } from 'app/entities/metis/conversation/channel.mod import { MetisService } from 'app/shared/metis/metis.service'; import { ChannelService } from 'app/shared/metis/conversations/channel.service'; import { firstValueFrom } from 'rxjs'; -import { CompletionItemKind, Disposable, EditorRange, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { CompletionItemKind, Disposable, EditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; /** * Action to insert a reference to a channel into the editor. Users that type a # will see a list of available channels to reference. @@ -29,7 +30,7 @@ export class MonacoChannelReferenceAction extends MonacoEditorAction { * @param editor The editor to register the action in. * @param translateService The translate service to use for translations, e.g. the label. */ - register(editor: MonacoEditorWithActions, translateService: TranslateService) { + register(editor: TextEditor, translateService: TranslateService) { super.register(editor, translateService); this.disposableCompletionProvider = this.registerCompletionProviderForCurrentModel( editor, @@ -49,7 +50,7 @@ export class MonacoChannelReferenceAction extends MonacoEditorAction { * Types the text '#' into the editor and focuses it. This will trigger the completion provider to show the available channels. * @param editor The editor to type the text into. */ - run(editor: MonacoEditorWithActions) { + run(editor: TextEditor) { this.typeText(editor, MonacoChannelReferenceAction.DEFAULT_INSERT_TEXT); editor.focus(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action.ts index 03eb439e9e54..c43d558ba0a0 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action.ts @@ -2,7 +2,8 @@ import { TranslateService } from '@ngx-translate/core'; import { MetisService } from 'app/shared/metis/metis.service'; import { MonacoEditorDomainActionWithOptions } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action-with-options.model'; import { ValueItem } from 'app/shared/markdown-editor/value-item.model'; -import { CompletionItemKind, Disposable, EditorRange, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { CompletionItemKind, Disposable, EditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; /** * Action to insert a reference to an exercise into the editor. Users that type a / will see a list of available exercises to reference. @@ -22,7 +23,7 @@ export class MonacoExerciseReferenceAction extends MonacoEditorDomainActionWithO * @param editor The editor to register the completion provider for. * @param translateService The translate service to use for translations. */ - register(editor: MonacoEditorWithActions, translateService: TranslateService): void { + register(editor: TextEditor, translateService: TranslateService): void { super.register(editor, translateService); const exercises = this.metisService.getCourse().exercises ?? []; this.setValues( @@ -50,7 +51,7 @@ export class MonacoExerciseReferenceAction extends MonacoEditorDomainActionWithO * Types the text '/exercise' into the editor and focuses it. This will trigger the completion provider to show the available exercises. * @param editor The editor to type the text into. */ - run(editor: MonacoEditorWithActions): void { + run(editor: TextEditor): void { this.typeText(editor, MonacoExerciseReferenceAction.DEFAULT_INSERT_TEXT); editor.focus(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-lecture-attachment-reference.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-lecture-attachment-reference.action.ts index a9c532dc3c15..a74c90b95bda 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-lecture-attachment-reference.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-lecture-attachment-reference.action.ts @@ -7,7 +7,7 @@ import { AttachmentUnit } from 'app/entities/lecture-unit/attachmentUnit.model'; import { Attachment } from 'app/entities/attachment.model'; import { Slide } from 'app/entities/lecture-unit/slide.model'; import { LectureUnitType } from 'app/entities/lecture-unit/lectureUnit.model'; -import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; interface LectureWithDetails { id: number; @@ -71,7 +71,7 @@ export class MonacoLectureAttachmentReferenceAction extends MonacoEditorAction { * @param editor The editor to insert the reference in. * @param args An object containing the item to reference and the type of reference. */ - run(editor: MonacoEditorWithActions, args?: LectureAttachmentReferenceActionArgs): void { + run(editor: TextEditor, args?: LectureAttachmentReferenceActionArgs): void { switch (args?.reference) { case ReferenceType.LECTURE: this.insertLectureReference(editor, args.lecture); @@ -108,23 +108,23 @@ export class MonacoLectureAttachmentReferenceAction extends MonacoEditorAction { this.lecturesWithDetails = []; } - insertLectureReference(editor: MonacoEditorWithActions, lecture: LectureWithDetails): void { + insertLectureReference(editor: TextEditor, lecture: LectureWithDetails): void { this.replaceTextAtCurrentSelection(editor, `[lecture]${lecture.title}(${this.metisService.getLinkForLecture(lecture.id.toString())})[/lecture]`); } - insertAttachmentReference(editor: MonacoEditorWithActions, attachment: Attachment): void { + insertAttachmentReference(editor: TextEditor, attachment: Attachment): void { const shortLink = attachment.link?.split('attachments/')[1]; this.replaceTextAtCurrentSelection(editor, `[attachment]${attachment.name}(${shortLink})[/attachment]`); } - insertSlideReference(editor: MonacoEditorWithActions, attachmentUnit: AttachmentUnit, slide: Slide): void { + insertSlideReference(editor: TextEditor, attachmentUnit: AttachmentUnit, slide: Slide): void { const shortLink = slide.slideImagePath?.split('attachments/')[1]; // Remove the trailing slash and the file name. const shortLinkWithoutFileName = shortLink?.replace(new RegExp(`[^/]*${'.png'}`), '').replace(/\/$/, ''); this.replaceTextAtCurrentSelection(editor, `[slide]${attachmentUnit.name} Slide ${slide.slideNumber}(${shortLinkWithoutFileName})[/slide]`); } - insertAttachmentUnitReference(editor: MonacoEditorWithActions, attachmentUnit: AttachmentUnit): void { + insertAttachmentUnitReference(editor: TextEditor, attachmentUnit: AttachmentUnit): void { const shortLink = attachmentUnit.attachment?.link!.split('attachments/')[1]; this.replaceTextAtCurrentSelection(editor, `[lecture-unit]${attachmentUnit.name}(${shortLink})[/lecture-unit]`); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts index 740354c43da1..30f9b42de5c6 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts @@ -5,7 +5,8 @@ import { CourseManagementService } from 'app/course/manage/course-management.ser import { MetisService } from 'app/shared/metis/metis.service'; import { firstValueFrom } from 'rxjs'; import { UserNameAndLoginDTO } from 'app/core/user/user.model'; -import { CompletionItemKind, Disposable, EditorRange, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { CompletionItemKind, Disposable, EditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; /** * Action to insert a user mention into the editor. Users that type a @ will see a list of available users to mention. @@ -29,7 +30,7 @@ export class MonacoUserMentionAction extends MonacoEditorAction { * @param editor The editor to register the action in. * @param translateService The translate service to use for translations, e.g. the label. */ - register(editor: MonacoEditorWithActions, translateService: TranslateService) { + register(editor: TextEditor, translateService: TranslateService) { super.register(editor, translateService); this.disposableCompletionProvider = this.registerCompletionProviderForCurrentModel( editor, @@ -50,7 +51,7 @@ export class MonacoUserMentionAction extends MonacoEditorAction { * Types the text '@' into the editor and focuses it. This will trigger the completion provider to show the available users. * @param editor The editor to type the text into. */ - run(editor: MonacoEditorWithActions) { + run(editor: TextEditor) { this.typeText(editor, MonacoUserMentionAction.DEFAULT_INSERT_TEXT); editor.focus(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-credits.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-credits.action.ts index 427a9776a275..f695677be31f 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-credits.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-credits.action.ts @@ -1,5 +1,5 @@ import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; -import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; export class MonacoGradingCreditsAction extends MonacoEditorDomainAction { static readonly ID = 'monaco-grading-credits.action'; @@ -10,7 +10,7 @@ export class MonacoGradingCreditsAction extends MonacoEditorDomainAction { super(MonacoGradingCreditsAction.ID, 'artemisApp.assessmentInstructions.instructions.editor.addCredits', undefined, undefined, true); } - run(editor: MonacoEditorWithActions): void { + run(editor: TextEditor): void { this.addTextWithDomainActionIdentifier(editor, MonacoGradingCreditsAction.TEXT, true, false); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-criterion.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-criterion.action.ts index 3a11eb795f02..ad845c7814c6 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-criterion.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-criterion.action.ts @@ -1,6 +1,5 @@ import { MonacoEditorDomainAction } from '../monaco-editor-domain-action.model'; import { MonacoGradingInstructionAction } from './monaco-grading-instruction.action'; -import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; export class MonacoGradingCriterionAction extends MonacoEditorDomainAction { static readonly ID = 'monaco-grading-criterion.action'; @@ -11,7 +10,7 @@ export class MonacoGradingCriterionAction extends MonacoEditorDomainAction { super(MonacoGradingCriterionAction.ID, 'artemisApp.assessmentInstructions.instructions.editor.addCriterion'); } - run(editor: MonacoEditorWithActions): void { + run(editor: TextEditor): void { this.addTextWithDomainActionIdentifier(editor, MonacoGradingCriterionAction.TEXT, false, false); this.gradingInstructionAction.executeInCurrentEditor(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-description.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-description.action.ts index b255b10a9625..2fca9b89d712 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-description.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-description.action.ts @@ -1,5 +1,5 @@ import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; -import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; export class MonacoGradingDescriptionAction extends MonacoEditorDomainAction { static readonly ID = 'monaco-grading-description.action'; @@ -10,7 +10,7 @@ export class MonacoGradingDescriptionAction extends MonacoEditorDomainAction { super(MonacoGradingDescriptionAction.ID, 'artemisApp.assessmentInstructions.instructions.editor.addDescription', undefined, undefined, true); } - run(editor: MonacoEditorWithActions): void { + run(editor: TextEditor): void { this.addTextWithDomainActionIdentifier(editor, MonacoGradingDescriptionAction.TEXT, true, false); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-feedback.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-feedback.action.ts index fa59ee235feb..e498bc01b2db 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-feedback.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-feedback.action.ts @@ -1,5 +1,5 @@ import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; -import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; export class MonacoGradingFeedbackAction extends MonacoEditorDomainAction { static readonly ID = 'monaco-grading-feedback.action'; @@ -10,7 +10,7 @@ export class MonacoGradingFeedbackAction extends MonacoEditorDomainAction { super(MonacoGradingFeedbackAction.ID, 'artemisApp.assessmentInstructions.instructions.editor.addFeedback', undefined, undefined, true); } - run(editor: MonacoEditorWithActions): void { + run(editor: TextEditor): void { this.addTextWithDomainActionIdentifier(editor, MonacoGradingFeedbackAction.TEXT, true, false); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-instruction.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-instruction.action.ts index 2020aa74132f..f9fc6289dafd 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-instruction.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-instruction.action.ts @@ -4,7 +4,7 @@ import { MonacoGradingScaleAction } from 'app/shared/monaco-editor/model/actions import { MonacoGradingDescriptionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-description.action'; import { MonacoGradingFeedbackAction } from './monaco-grading-feedback.action'; import { MonacoGradingUsageCountAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-usage-count.action'; -import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; export class MonacoGradingInstructionAction extends MonacoEditorDomainAction { static readonly ID = 'monaco-grading-instruction.action'; @@ -20,7 +20,7 @@ export class MonacoGradingInstructionAction extends MonacoEditorDomainAction { super(MonacoGradingInstructionAction.ID, 'artemisApp.assessmentInstructions.instructions.editor.addInstruction'); } - run(editor: MonacoEditorWithActions): void { + run(editor: TextEditor): void { this.addTextWithDomainActionIdentifier(editor, '', false, false); this.creditsAction.executeInCurrentEditor(); this.scaleAction.executeInCurrentEditor(); diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-scale.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-scale.action.ts index 276124b4fe0b..fe5114f1f50f 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-scale.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-scale.action.ts @@ -1,5 +1,5 @@ import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; -import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; export class MonacoGradingScaleAction extends MonacoEditorDomainAction { static readonly ID = 'monaco-grading-scale.action'; @@ -10,7 +10,7 @@ export class MonacoGradingScaleAction extends MonacoEditorDomainAction { super(MonacoGradingScaleAction.ID, 'artemisApp.assessmentInstructions.instructions.editor.addScale', undefined, undefined, true); } - run(editor: MonacoEditorWithActions): void { + run(editor: TextEditor): void { this.addTextWithDomainActionIdentifier(editor, MonacoGradingScaleAction.TEXT, true, false); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-usage-count.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-usage-count.action.ts index 9a001a92f406..1e11998454c4 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-usage-count.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-usage-count.action.ts @@ -1,5 +1,5 @@ import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; -import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; export class MonacoGradingUsageCountAction extends MonacoEditorDomainAction { static readonly ID = 'monaco-grading-usage-count.action'; @@ -10,7 +10,7 @@ export class MonacoGradingUsageCountAction extends MonacoEditorDomainAction { super(MonacoGradingUsageCountAction.ID, 'artemisApp.assessmentInstructions.instructions.editor.addUsageCount', undefined, undefined, true); } - run(editor: MonacoEditorWithActions): void { + run(editor: TextEditor): void { this.addTextWithDomainActionIdentifier(editor, MonacoGradingUsageCountAction.TEXT, true, false); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-attachment.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-attachment.action.ts index 2f647e526b4c..e6120e853fd9 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-attachment.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-attachment.action.ts @@ -1,6 +1,6 @@ import { faImage } from '@fortawesome/free-solid-svg-icons'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; -import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; interface AttachmentArguments { text: string; @@ -30,7 +30,7 @@ export class MonacoAttachmentAction extends MonacoEditorAction { * @param editor The editor in which to insert the attachment. * @param args The text and url of the attachment to insert. If one or both are not provided, the default text will be inserted. */ - run(editor: MonacoEditorWithActions, args?: AttachmentArguments): void { + run(editor: TextEditor, args?: AttachmentArguments): void { if (!args?.text || !args?.url) { this.replaceTextAtCurrentSelection(editor, MonacoAttachmentAction.DEFAULT_INSERT_TEXT); } else { diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-bold.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-bold.action.ts index c859b3c889f2..34e553588dbb 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-bold.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-bold.action.ts @@ -1,6 +1,7 @@ import { faBold } from '@fortawesome/free-solid-svg-icons'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; -import { KeyCode, KeyModifier, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { KeyCode, KeyModifier } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; const BOLD_DELIMITER = '**'; @@ -19,7 +20,7 @@ export class MonacoBoldAction extends MonacoEditorAction { * If no text is selected, the delimiter is inserted at the current cursor position. * @param editor The editor in which to toggle bold text. */ - run(editor: MonacoEditorWithActions) { + run(editor: TextEditor) { this.toggleDelimiterAroundSelection(editor, BOLD_DELIMITER, BOLD_DELIMITER); editor.focus(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code-block.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code-block.action.ts index 73fb534c453f..750197137d2e 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code-block.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code-block.action.ts @@ -1,6 +1,6 @@ import { faFileCode } from '@fortawesome/free-solid-svg-icons'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; -import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; const CODE_BLOCK_DELIMITER = '```'; @@ -18,7 +18,7 @@ export class MonacoCodeBlockAction extends MonacoEditorAction { * Toggles the code block delimiters around the selected text in the editor. If the selected text is already wrapped in code block delimiters, the delimiter is removed. * @param editor The editor in which to toggle code block text. */ - run(editor: MonacoEditorWithActions): void { + run(editor: TextEditor): void { this.toggleDelimiterAroundSelection(editor, `${CODE_BLOCK_DELIMITER}${this.defaultLanguage ?? ''}\n`, `\n${CODE_BLOCK_DELIMITER}`); editor.focus(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code.action.ts index d373456fee06..ea38636c0186 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code.action.ts @@ -1,6 +1,6 @@ import { faCode } from '@fortawesome/free-solid-svg-icons'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; -import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; const CODE_DELIMITER = '`'; @@ -18,7 +18,7 @@ export class MonacoCodeAction extends MonacoEditorAction { * If no text is selected, the code delimiter is inserted at the current cursor position. * @param editor The editor in which to toggle code text. */ - run(editor: MonacoEditorWithActions) { + run(editor: TextEditor) { this.toggleDelimiterAroundSelection(editor, CODE_DELIMITER, CODE_DELIMITER); editor.focus(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-color.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-color.action.ts index ddef1a3718e3..2d7deb3a945f 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-color.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-color.action.ts @@ -1,5 +1,5 @@ import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; -import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; interface ColorArguments { color: string; @@ -30,7 +30,7 @@ export class MonacoColorAction extends MonacoEditorAction { * @param editor The editor in which to toggle color text. * @param args The color to apply to the selected text. If no color is provided, the default color red is used. */ - run(editor: MonacoEditorWithActions, args?: ColorArguments) { + run(editor: TextEditor, args?: ColorArguments) { const openDelimiter = ``; this.toggleDelimiterAroundSelection(editor, openDelimiter, CLOSE_DELIMITER); editor.focus(); diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts index 5b93a4be620d..40b0e3b0d764 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts @@ -2,14 +2,8 @@ import { IconDefinition } from '@fortawesome/fontawesome-svg-core'; import { TranslateService } from '@ngx-translate/core'; import * as monaco from 'monaco-editor'; import { enterFullscreen, exitFullscreen, isFullScreen } from 'app/shared/util/fullscreen.util'; -import { - Disposable, - EditorPosition, - EditorRange, - MonacoEditorTextModel, - MonacoEditorWithActions, - makeEditorRange, -} from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { Disposable, EditorPosition, EditorRange, MonacoEditorTextModel, makeEditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; export abstract class MonacoEditorAction implements monaco.editor.IActionDescriptor, Disposable { // IActionDescriptor @@ -29,7 +23,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * The editor (if any) this action is registered in. * @private */ - private _editor?: MonacoEditorWithActions; + private _editor?: TextEditor; /** * Create a new action with the given id, translation key, icon, and keybindings. @@ -52,7 +46,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param editor The editor in which the action was triggered. * @param args Optional arguments that can be passed to the action. To ensure this is an object, you can use {@link executeInCurrentEditor}. */ - abstract run(editor: MonacoEditorWithActions, args?: unknown): void; + abstract run(editor: TextEditor, args?: unknown): void; /** * Execute the action in the current editor. This is a convenience method to trigger the action in the editor without having to pass the editor instance. @@ -82,7 +76,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param translateService The translation service to use for translating the action label. * @throws error if the action has already been registered in an editor. */ - register(editor: MonacoEditorWithActions, translateService: TranslateService): void { + register(editor: TextEditor, translateService: TranslateService): void { if (this.disposableAction) { throw new Error(`Action (id ${this.id}) already belongs to an editor. Dispose it first before registering it in another editor.`); } @@ -100,7 +94,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param listIncomplete Whether the list of suggestions is incomplete. If true, Monaco will keep searching for more suggestions. */ registerCompletionProviderForCurrentModel( - editor: MonacoEditorWithActions, + editor: TextEditor, searchFn: (searchTerm?: string) => Promise, mapToSuggestionFn: (item: ItemType, range: EditorRange) => monaco.languages.CompletionItem, triggerCharacter?: string, @@ -189,7 +183,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param closeDelimiter The closing delimiter, e.g. . * @param textToInsert The text to insert between the delimiters if there is no selection. Defaults to an empty string. */ - toggleDelimiterAroundSelection(editor: MonacoEditorWithActions, openDelimiter: string, closeDelimiter: string, textToInsert: string = ''): void { + toggleDelimiterAroundSelection(editor: TextEditor, openDelimiter: string, closeDelimiter: string, textToInsert: string = ''): void { const selection = editor.getSelection(); const selectedText = selection ? this.getTextAtRange(editor, selection)?.trim() : undefined; const position = editor.getPosition(); @@ -225,7 +219,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param editor The editor to type the text in. * @param text The text to type. */ - typeText(editor: MonacoEditorWithActions, text: string): void { + typeText(editor: TextEditor, text: string): void { editor.trigger('keyboard', 'type', { text }); } @@ -234,7 +228,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param editor The editor to replace the text in. * @param text The text to replace the current selection with. */ - replaceTextAtCurrentSelection(editor: MonacoEditorWithActions, text: string): void { + replaceTextAtCurrentSelection(editor: TextEditor, text: string): void { const selection = editor.getSelection(); const selectedText = selection ? this.getTextAtRange(editor, selection)?.trim() : undefined; if (selection && selectedText !== undefined) { @@ -246,7 +240,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * Gets the text of the current selection. If there is no selection, undefined is returned. * @param editor The editor to get the selection text from. */ - getSelectedText(editor: MonacoEditorWithActions): string | undefined { + getSelectedText(editor: TextEditor): string | undefined { const selection = editor.getSelection(); return selection ? this.getTextAtRange(editor, selection) : undefined; } @@ -257,7 +251,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param position The position to insert the text at. * @param text The text to insert. */ - insertTextAtPosition(editor: MonacoEditorWithActions, position: EditorPosition, text: string): void { + insertTextAtPosition(editor: TextEditor, position: EditorPosition, text: string): void { this.replaceTextAtRange(editor, makeEditorRange(position.lineNumber, position.column, position.lineNumber, position.column), text); } @@ -267,7 +261,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param range The range to replace the text at. * @param text The text to replace the range with. */ - replaceTextAtRange(editor: MonacoEditorWithActions, range: EditorRange, text: string): void { + replaceTextAtRange(editor: TextEditor, range: EditorRange, text: string): void { editor.executeEdits(this.id, [{ range, text }]); } @@ -276,7 +270,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param editor The editor to delete the text in. * @param range The range to delete the text at. */ - deleteTextAtRange(editor: MonacoEditorWithActions, range: EditorRange): void { + deleteTextAtRange(editor: TextEditor, range: EditorRange): void { this.replaceTextAtRange(editor, range, ''); } @@ -285,7 +279,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param editor The editor to get the text from. * @param range The range to get the text from. */ - getTextAtRange(editor: MonacoEditorWithActions, range: EditorRange): string | undefined { + getTextAtRange(editor: TextEditor, range: EditorRange): string | undefined { // End of line preference is important here. Otherwise, Windows may use CRLF line endings. return editor.getModel()?.getValueInRange(range, monaco.editor.EndOfLinePreference.LF); } @@ -295,7 +289,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param editor The editor to get the text from. * @param lineNumber The line number to get the text from. Line numbers start at 1. */ - getLineText(editor: MonacoEditorWithActions, lineNumber: number): string | undefined { + getLineText(editor: TextEditor, lineNumber: number): string | undefined { return editor.getModel()?.getLineContent(lineNumber); } @@ -303,7 +297,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * Gets the number of lines in the editor. * @param editor The editor to get the line count from. */ - getLineCount(editor: MonacoEditorWithActions): number { + getLineCount(editor: TextEditor): number { return editor.getModel()?.getLineCount() ?? 0; } @@ -311,7 +305,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * Gets the position of the last character in the editor. * @param editor The editor to get the position from. */ - getEndPosition(editor: MonacoEditorWithActions): EditorPosition { + getEndPosition(editor: TextEditor): EditorPosition { return editor.getModel()?.getFullModelRange().getEndPosition() ?? { lineNumber: 1, column: 1 }; } @@ -321,14 +315,14 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param position The position to set. * @param revealLine Whether to scroll the editor to reveal the line the position is on. Defaults to false. */ - setPosition(editor: MonacoEditorWithActions, position: EditorPosition, revealLine = false): void { + setPosition(editor: TextEditor, position: EditorPosition, revealLine = false): void { editor.setPosition(position); if (revealLine) { editor.revealLineInCenter(position.lineNumber); } } - getPosition(editor: MonacoEditorWithActions): EditorPosition { + getPosition(editor: TextEditor): EditorPosition { return editor.getPosition() ?? { lineNumber: 1, column: 1 }; } @@ -337,7 +331,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param editor The editor to set the selection in. * @param selection The selection to set. */ - setSelection(editor: MonacoEditorWithActions, selection: EditorRange): void { + setSelection(editor: TextEditor, selection: EditorRange): void { editor.setSelection(selection); editor.revealRangeInCenter(selection); } @@ -346,7 +340,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * Clears the current selection in the given editor, but preserves the cursor position. * @param editor The editor to clear the selection in. */ - clearSelection(editor: MonacoEditorWithActions): void { + clearSelection(editor: TextEditor): void { const position = this.getPosition(editor); this.setSelection(editor, makeEditorRange(position.lineNumber, position.column, position.lineNumber, position.column)); } @@ -355,7 +349,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * Adjusts the cursor position so it is at the end of the current line. * @param editor The editor to adjust the cursor position in. */ - moveCursorToEndOfLine(editor: MonacoEditorWithActions): void { + moveCursorToEndOfLine(editor: TextEditor): void { const position: EditorPosition = { ...this.getPosition(editor), column: Number.POSITIVE_INFINITY }; this.setPosition(editor, position); } @@ -365,7 +359,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param editor The editor to toggle the fullscreen mode for. * @param element The element to toggle the fullscreen mode for. */ - toggleFullscreen(editor: MonacoEditorWithActions, element?: HTMLElement): void { + toggleFullscreen(editor: TextEditor, element?: HTMLElement): void { const fullscreenElement = element ?? editor.getDomNode(); if (isFullScreen()) { exitFullscreen(); diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model.ts index 0a89bcd4ab7e..672cc1495f8b 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model.ts @@ -1,5 +1,5 @@ +import { TextEditor } from './adapter/text-editor-adapter.model'; import { MonacoEditorAction } from './monaco-editor-action.model'; -import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; /** * Class representing domain actions for Artemis-specific use cases. @@ -15,7 +15,7 @@ export abstract class MonacoEditorDomainAction extends MonacoEditorAction { * @param indent Whether to indent the inserted text with a tab. * @param updateSelection Whether to update the selection after inserting the text */ - addTextWithDomainActionIdentifier(editor: MonacoEditorWithActions, text: string, indent = false, updateSelection = true): void { + addTextWithDomainActionIdentifier(editor: TextEditor, text: string, indent = false, updateSelection = true): void { this.clearSelection(editor); this.moveCursorToEndOfLine(editor); const identifierWithText = text ? `${this.getOpeningIdentifier()} ${text}` : this.getOpeningIdentifier(); diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-formula.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-formula.action.ts index 93b5054fd156..708732a99bc2 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-formula.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-formula.action.ts @@ -1,5 +1,5 @@ import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; -import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; const FORMULA_OPEN_DELIMITER = '$$ '; const FORMULA_CLOSE_DELIMITER = ' $$'; @@ -19,7 +19,7 @@ export class MonacoFormulaAction extends MonacoEditorDomainAction { * If no text is selected, the default formula is inserted at the current cursor position. * @param editor The editor in which to toggle formula text. */ - run(editor: MonacoEditorWithActions) { + run(editor: TextEditor) { this.toggleDelimiterAroundSelection(editor, this.getOpeningIdentifier(), FORMULA_CLOSE_DELIMITER, MonacoFormulaAction.DEFAULT_FORMULA); editor.focus(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-fullscreen.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-fullscreen.action.ts index 32235042bb51..b1470a78505e 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-fullscreen.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-fullscreen.action.ts @@ -1,7 +1,7 @@ import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; import { faCompress } from '@fortawesome/free-solid-svg-icons'; -import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; /** * Action to toggle fullscreen mode in the editor. @@ -19,7 +19,7 @@ export class MonacoFullscreenAction extends MonacoEditorAction { * Toggles the fullscreen mode of the editor. * @param editor The editor in which to toggle fullscreen mode. */ - run(editor: MonacoEditorWithActions): void { + run(editor: TextEditor): void { this.toggleFullscreen(editor, this.element); } } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-heading.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-heading.action.ts index c86cd9796d62..47104f60c06f 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-heading.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-heading.action.ts @@ -1,6 +1,6 @@ import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; import { faHeading } from '@fortawesome/free-solid-svg-icons'; -import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; function getTranslationKeyForLevel(level: number): string { const suffix = level === 3 ? 'Three' : level === 2 ? 'Two' : 'One'; @@ -29,7 +29,7 @@ export class MonacoHeadingAction extends MonacoEditorAction { * Toggles the heading prefix ("# ", "## ", ...) for the selected text based on the heading level. If the selected text is already a heading, the prefix is removed. * @param editor The editor in which to toggle heading text. */ - run(editor: MonacoEditorWithActions) { + run(editor: TextEditor) { const selection = editor.getSelection(); const selectedText = selection ? this.getTextAtRange(editor, selection) : undefined; if (selection && selectedText !== undefined) { diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-italic.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-italic.action.ts index 4decb19d0305..764e75e2f5e0 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-italic.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-italic.action.ts @@ -1,6 +1,7 @@ import { faItalic } from '@fortawesome/free-solid-svg-icons'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; -import { KeyCode, KeyModifier, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { KeyCode, KeyModifier } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from './adapter/text-editor-adapter.model'; const ITALIC_DELIMITER = '*'; @@ -18,7 +19,7 @@ export class MonacoItalicAction extends MonacoEditorAction { * If no text is selected, the delimiter is inserted at the current cursor position. * @param editor The editor in which to toggle italic text. */ - run(editor: MonacoEditorWithActions): void { + run(editor: TextEditor): void { this.toggleDelimiterAroundSelection(editor, ITALIC_DELIMITER, ITALIC_DELIMITER); editor.focus(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-ordered-list.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-ordered-list.action.ts index 55aa09e47a3e..19b64ae79151 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-ordered-list.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-ordered-list.action.ts @@ -1,6 +1,6 @@ import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; import { faListOl } from '@fortawesome/free-solid-svg-icons'; -import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from './adapter/text-editor-adapter.model'; const NUMBER_REGEX = /^\d+\.\s.*/; @@ -18,7 +18,7 @@ export class MonacoOrderedListAction extends MonacoEditorAction { * If no text is selected, the prefix "1. " is inserted at the current cursor position. * @param editor The editor in which to toggle the ordered list. */ - run(editor: MonacoEditorWithActions): void { + run(editor: TextEditor): void { const selection = editor.getSelection(); if (!selection) return; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-quote.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-quote.action.ts index ada73eb0b97c..d279f27676cc 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-quote.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-quote.action.ts @@ -1,6 +1,6 @@ import { faQuoteLeft } from '@fortawesome/free-solid-svg-icons'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; -import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; const QUOTE_OPEN_DELIMITER = '> '; @@ -17,7 +17,7 @@ export class MonacoQuoteAction extends MonacoEditorAction { * Toggles the quote delimiter around the selected text in the editor. If the selected text is already quoted, the delimiter is removed. * @param editor The editor in which to toggle quote text. */ - run(editor: MonacoEditorWithActions): void { + run(editor: TextEditor): void { this.toggleDelimiterAroundSelection(editor, QUOTE_OPEN_DELIMITER, ''); editor.focus(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-task.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-task.action.ts index 5378e147f9c8..9acfd603903d 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-task.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-task.action.ts @@ -1,6 +1,6 @@ import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; import { escapeStringForUseInRegex } from 'app/shared/util/global.utils'; -import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; /** * Action to insert a task into the editor. They follow the format [task][Task Short Description](testCaseName). @@ -19,7 +19,7 @@ export class MonacoTaskAction extends MonacoEditorDomainAction { * Inserts, at the current selection, the markdown task. * @param editor The editor in which to insert the task. */ - run(editor: MonacoEditorWithActions): void { + run(editor: TextEditor): void { this.replaceTextAtCurrentSelection(editor, `${this.getOpeningIdentifier()}${MonacoTaskAction.TEXT}`); editor.focus(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-test-case.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-test-case.action.ts index 441a47ee1586..9016698a44f2 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-test-case.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-test-case.action.ts @@ -1,7 +1,8 @@ import { TranslateService } from '@ngx-translate/core'; import { DomainActionWithOptionsArguments, MonacoEditorDomainActionWithOptions } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action-with-options.model'; -import { CompletionItemKind, Disposable, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { CompletionItemKind, Disposable } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; import { ValueItem } from 'app/shared/markdown-editor/value-item.model'; +import { TextEditor } from './adapter/text-editor-adapter.model'; /** * Action to insert a test case into the editor. It also registers a completion item provider offers all possible test cases as completion items to the user. @@ -22,7 +23,7 @@ export class MonacoTestCaseAction extends MonacoEditorDomainActionWithOptions { * @param translateService The translation service to use for translating the action label. * @throws error If the action is already registered with an editor or no model is attached to the editor. */ - register(editor: MonacoEditorWithActions, translateService: TranslateService) { + register(editor: TextEditor, translateService: TranslateService) { super.register(editor, translateService); this.disposableCompletionProvider = this.registerCompletionProviderForCurrentModel( editor, @@ -52,7 +53,7 @@ export class MonacoTestCaseAction extends MonacoEditorDomainActionWithOptions { super.executeInCurrentEditor(args); } - run(editor: MonacoEditorWithActions, args?: DomainActionWithOptionsArguments) { + run(editor: TextEditor, args?: DomainActionWithOptionsArguments) { this.replaceTextAtCurrentSelection(editor, args?.selectedItem?.value ?? MonacoTestCaseAction.DEFAULT_INSERT_TEXT); editor.focus(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-underline.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-underline.action.ts index cd49aac63e94..8378f375d998 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-underline.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-underline.action.ts @@ -1,6 +1,7 @@ import { faUnderline } from '@fortawesome/free-solid-svg-icons'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; -import { KeyCode, KeyModifier, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { KeyCode, KeyModifier } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; const UNDERLINE_OPEN_DELIMITER = ''; const UNDERLINE_CLOSE_DELIMITER = ''; @@ -18,7 +19,7 @@ export class MonacoUnderlineAction extends MonacoEditorAction { * Toggles the underline delimiter around the selected text in the editor. If the selected text is already underlined, the delimiter is removed. * @param editor The editor in which to toggle underline text. */ - run(editor: MonacoEditorWithActions): void { + run(editor: TextEditor): void { this.toggleDelimiterAroundSelection(editor, UNDERLINE_OPEN_DELIMITER, UNDERLINE_CLOSE_DELIMITER); editor.focus(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-unordered-list.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-unordered-list.action.ts index 204916982a50..eeeaabf7b187 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-unordered-list.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-unordered-list.action.ts @@ -1,6 +1,7 @@ import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; import { faListUl } from '@fortawesome/free-solid-svg-icons'; -import { MonacoEditorWithActions, makeEditorPosition, makeEditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { makeEditorPosition, makeEditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; const LIST_BULLET = '- '; @@ -18,7 +19,7 @@ export class MonacoUnorderedListAction extends MonacoEditorAction { * If no text is selected, the prefix is inserted at the current cursor position. * @param editor The editor in which to toggle the unordered list. */ - run(editor: MonacoEditorWithActions): void { + run(editor: TextEditor): void { const selection = editor.getSelection(); if (!selection) return; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-url.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-url.action.ts index 15eecc8672a6..d5b59b7d66f9 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-url.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-url.action.ts @@ -1,6 +1,6 @@ import { faLink } from '@fortawesome/free-solid-svg-icons'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; -import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; interface UrlArguments { text: string; @@ -31,7 +31,7 @@ export class MonacoUrlAction extends MonacoEditorAction { * @param editor The editor in which to insert the URL. * @param args The text and url of the URL to insert. If one or both are not provided, the default text will be inserted. */ - run(editor: MonacoEditorWithActions, args?: UrlArguments): void { + run(editor: TextEditor, args?: UrlArguments): void { if (!args?.text || !args?.url) { this.replaceTextAtCurrentSelection(editor, MonacoUrlAction.DEFAULT_INSERT_TEXT); } else { diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-correct-multiple-choice-answer.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-correct-multiple-choice-answer.action.ts index 20074604f05b..06cd831885d4 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-correct-multiple-choice-answer.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-correct-multiple-choice-answer.action.ts @@ -1,5 +1,5 @@ import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; -import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; export class MonacoCorrectMultipleChoiceAnswerAction extends MonacoEditorDomainAction { static readonly ID = 'artemisApp.multipleChoiceQuestion.editor.addCorrectAnswerOption'; @@ -10,7 +10,7 @@ export class MonacoCorrectMultipleChoiceAnswerAction extends MonacoEditorDomainA super(MonacoCorrectMultipleChoiceAnswerAction.ID, 'artemisApp.multipleChoiceQuestion.editor.addCorrectAnswerOption'); } - run(editor: MonacoEditorWithActions): void { + run(editor: TextEditor): void { this.addTextWithDomainActionIdentifier(editor, MonacoCorrectMultipleChoiceAnswerAction.TEXT); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-option.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-option.action.ts index 8886042fcf01..91df1a9c7d9a 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-option.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-option.action.ts @@ -1,5 +1,5 @@ import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; -import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; interface InsertShortAnswerOptionArgs { spotNumber?: number; @@ -29,7 +29,7 @@ export class MonacoInsertShortAnswerOptionAction extends MonacoEditorAction { * @param editor The editor to insert the option in. * @param args The optional arguments for the action. Can include a spot number (will be # otherwise) and the option text (if blank/absent, the default text will be used). */ - run(editor: MonacoEditorWithActions, args?: InsertShortAnswerOptionArgs): void { + run(editor: TextEditor, args?: InsertShortAnswerOptionArgs): void { // Note that even if the optionText is provided, it may be blank. This is why we use || instead of ?? here. const optionText = args?.optionText || MonacoInsertShortAnswerOptionAction.DEFAULT_TEXT; let insertedText: string; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-spot.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-spot.action.ts index 5db46cc5f95b..829087b4b5b5 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-spot.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-spot.action.ts @@ -1,6 +1,6 @@ import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; import { MonacoInsertShortAnswerOptionAction } from 'app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-option.action'; -import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; /** * Action to insert a short answer spot at the current cursor position. @@ -22,7 +22,7 @@ export class MonacoInsertShortAnswerSpotAction extends MonacoEditorAction { * Then, it inserts an option linked to the spot. If the selected text is not empty, it will be used as the option's text. * @param editor The editor to insert the spot in. */ - run(editor: MonacoEditorWithActions): void { + run(editor: TextEditor): void { // Changes to the editor contents will trigger an update of the spot number. We keep it stored here to use it when inserting the spot. const number = this.spotNumber; const text = `[-spot ${number}]`; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-quiz-explanation.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-quiz-explanation.action.ts index 03b0a64a2045..10ae3be03070 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-quiz-explanation.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-quiz-explanation.action.ts @@ -1,5 +1,5 @@ import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; -import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; export class MonacoQuizExplanationAction extends MonacoEditorDomainAction { static readonly ID = 'monaco-quiz-explanation.action'; @@ -10,7 +10,7 @@ export class MonacoQuizExplanationAction extends MonacoEditorDomainAction { super(MonacoQuizExplanationAction.ID, 'artemisApp.multipleChoiceQuestion.editor.addExplanation'); } - run(editor: MonacoEditorWithActions): void { + run(editor: TextEditor): void { this.addTextWithDomainActionIdentifier(editor, MonacoQuizExplanationAction.TEXT, true); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-quiz-hint.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-quiz-hint.action.ts index cbc741efa744..beb0f6861cf5 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-quiz-hint.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-quiz-hint.action.ts @@ -1,5 +1,5 @@ import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; -import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; export class MonacoQuizHintAction extends MonacoEditorDomainAction { static readonly ID = 'monaco-quiz-hint.action'; @@ -10,7 +10,7 @@ export class MonacoQuizHintAction extends MonacoEditorDomainAction { super(MonacoQuizHintAction.ID, 'artemisApp.multipleChoiceQuestion.editor.addHint'); } - run(editor: MonacoEditorWithActions): void { + run(editor: TextEditor): void { this.addTextWithDomainActionIdentifier(editor, MonacoQuizHintAction.TEXT, true); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-wrong-multiple-choice-answer.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-wrong-multiple-choice-answer.action.ts index 590503cc61e1..f665e9a05365 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-wrong-multiple-choice-answer.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-wrong-multiple-choice-answer.action.ts @@ -1,5 +1,5 @@ import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; -import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; export class MonacoWrongMultipleChoiceAnswerAction extends MonacoEditorDomainAction { static readonly ID = 'monaco-incorrect-multiple-choice-answer.action'; @@ -10,7 +10,7 @@ export class MonacoWrongMultipleChoiceAnswerAction extends MonacoEditorDomainAct super(MonacoWrongMultipleChoiceAnswerAction.ID, 'artemisApp.multipleChoiceQuestion.editor.addInCorrectAnswerOption'); } - run(editor: MonacoEditorWithActions): void { + run(editor: TextEditor): void { this.addTextWithDomainActionIdentifier(editor, MonacoWrongMultipleChoiceAnswerAction.TEXT); } From 605bcd113d360eed10197edc4eba61a334eff495 Mon Sep 17 00:00:00 2001 From: Patrik Zander Date: Sat, 31 Aug 2024 10:42:17 +0200 Subject: [PATCH 10/27] Move TextEditor interface --- .../model/actions/adapter/monaco-text-editor.adapter.ts | 2 +- .../{text-editor-adapter.model.ts => text-editor.interface.ts} | 0 .../actions/communication/monaco-channel-reference.action.ts | 2 +- .../actions/communication/monaco-exercise-reference.action.ts | 2 +- .../communication/monaco-lecture-attachment-reference.action.ts | 2 +- .../model/actions/communication/monaco-user-mention.action.ts | 2 +- .../actions/grading-criteria/monaco-grading-credits.action.ts | 2 +- .../grading-criteria/monaco-grading-description.action.ts | 2 +- .../actions/grading-criteria/monaco-grading-feedback.action.ts | 2 +- .../grading-criteria/monaco-grading-instruction.action.ts | 2 +- .../actions/grading-criteria/monaco-grading-scale.action.ts | 2 +- .../grading-criteria/monaco-grading-usage-count.action.ts | 2 +- .../monaco-editor/model/actions/monaco-attachment.action.ts | 2 +- .../shared/monaco-editor/model/actions/monaco-bold.action.ts | 2 +- .../monaco-editor/model/actions/monaco-code-block.action.ts | 2 +- .../shared/monaco-editor/model/actions/monaco-code.action.ts | 2 +- .../shared/monaco-editor/model/actions/monaco-color.action.ts | 2 +- .../monaco-editor/model/actions/monaco-editor-action.model.ts | 2 +- .../model/actions/monaco-editor-domain-action.model.ts | 2 +- .../shared/monaco-editor/model/actions/monaco-formula.action.ts | 2 +- .../monaco-editor/model/actions/monaco-fullscreen.action.ts | 2 +- .../shared/monaco-editor/model/actions/monaco-heading.action.ts | 2 +- .../shared/monaco-editor/model/actions/monaco-italic.action.ts | 2 +- .../monaco-editor/model/actions/monaco-ordered-list.action.ts | 2 +- .../shared/monaco-editor/model/actions/monaco-quote.action.ts | 2 +- .../shared/monaco-editor/model/actions/monaco-task.action.ts | 2 +- .../monaco-editor/model/actions/monaco-test-case.action.ts | 2 +- .../monaco-editor/model/actions/monaco-underline.action.ts | 2 +- .../monaco-editor/model/actions/monaco-unordered-list.action.ts | 2 +- .../app/shared/monaco-editor/model/actions/monaco-url.action.ts | 2 +- .../quiz/monaco-correct-multiple-choice-answer.action.ts | 2 +- .../actions/quiz/monaco-insert-short-answer-option.action.ts | 2 +- .../actions/quiz/monaco-insert-short-answer-spot.action.ts | 2 +- .../monaco-editor/model/actions/quiz/monaco-quiz-hint.action.ts | 2 +- .../actions/quiz/monaco-wrong-multiple-choice-answer.action.ts | 2 +- 35 files changed, 34 insertions(+), 34 deletions(-) rename src/main/webapp/app/shared/monaco-editor/model/actions/adapter/{text-editor-adapter.model.ts => text-editor.interface.ts} (100%) diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts index 94e69c88f538..4d519685db29 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts @@ -1,4 +1,4 @@ -import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; import { Disposable } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; import * as monaco from 'monaco-editor'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor.interface.ts similarity index 100% rename from src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor.interface.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts index f4e430978a86..18b355299beb 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts @@ -6,7 +6,7 @@ import { MetisService } from 'app/shared/metis/metis.service'; import { ChannelService } from 'app/shared/metis/conversations/channel.service'; import { firstValueFrom } from 'rxjs'; import { CompletionItemKind, Disposable, EditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; -import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; /** * Action to insert a reference to a channel into the editor. Users that type a # will see a list of available channels to reference. diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action.ts index c43d558ba0a0..fc6b2e7307f6 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action.ts @@ -3,7 +3,7 @@ import { MetisService } from 'app/shared/metis/metis.service'; import { MonacoEditorDomainActionWithOptions } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action-with-options.model'; import { ValueItem } from 'app/shared/markdown-editor/value-item.model'; import { CompletionItemKind, Disposable, EditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; -import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; /** * Action to insert a reference to an exercise into the editor. Users that type a / will see a list of available exercises to reference. diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-lecture-attachment-reference.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-lecture-attachment-reference.action.ts index a74c90b95bda..4e0521f39197 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-lecture-attachment-reference.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-lecture-attachment-reference.action.ts @@ -7,7 +7,7 @@ import { AttachmentUnit } from 'app/entities/lecture-unit/attachmentUnit.model'; import { Attachment } from 'app/entities/attachment.model'; import { Slide } from 'app/entities/lecture-unit/slide.model'; import { LectureUnitType } from 'app/entities/lecture-unit/lectureUnit.model'; -import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; interface LectureWithDetails { id: number; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts index 30f9b42de5c6..7100a3c5f670 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts @@ -6,7 +6,7 @@ import { MetisService } from 'app/shared/metis/metis.service'; import { firstValueFrom } from 'rxjs'; import { UserNameAndLoginDTO } from 'app/core/user/user.model'; import { CompletionItemKind, Disposable, EditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; -import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; /** * Action to insert a user mention into the editor. Users that type a @ will see a list of available users to mention. diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-credits.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-credits.action.ts index f695677be31f..2a2e719f32fc 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-credits.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-credits.action.ts @@ -1,5 +1,5 @@ import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; -import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; export class MonacoGradingCreditsAction extends MonacoEditorDomainAction { static readonly ID = 'monaco-grading-credits.action'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-description.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-description.action.ts index 2fca9b89d712..c30c18f8c90d 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-description.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-description.action.ts @@ -1,5 +1,5 @@ import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; -import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; export class MonacoGradingDescriptionAction extends MonacoEditorDomainAction { static readonly ID = 'monaco-grading-description.action'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-feedback.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-feedback.action.ts index e498bc01b2db..7ba44a0d81f5 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-feedback.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-feedback.action.ts @@ -1,5 +1,5 @@ import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; -import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; export class MonacoGradingFeedbackAction extends MonacoEditorDomainAction { static readonly ID = 'monaco-grading-feedback.action'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-instruction.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-instruction.action.ts index f9fc6289dafd..3012867e96c3 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-instruction.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-instruction.action.ts @@ -4,7 +4,7 @@ import { MonacoGradingScaleAction } from 'app/shared/monaco-editor/model/actions import { MonacoGradingDescriptionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-description.action'; import { MonacoGradingFeedbackAction } from './monaco-grading-feedback.action'; import { MonacoGradingUsageCountAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-usage-count.action'; -import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; export class MonacoGradingInstructionAction extends MonacoEditorDomainAction { static readonly ID = 'monaco-grading-instruction.action'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-scale.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-scale.action.ts index fe5114f1f50f..09e2b3c15bed 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-scale.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-scale.action.ts @@ -1,5 +1,5 @@ import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; -import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; export class MonacoGradingScaleAction extends MonacoEditorDomainAction { static readonly ID = 'monaco-grading-scale.action'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-usage-count.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-usage-count.action.ts index 1e11998454c4..055fbe6d5a64 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-usage-count.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-usage-count.action.ts @@ -1,5 +1,5 @@ import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; -import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; export class MonacoGradingUsageCountAction extends MonacoEditorDomainAction { static readonly ID = 'monaco-grading-usage-count.action'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-attachment.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-attachment.action.ts index e6120e853fd9..1053ca210af5 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-attachment.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-attachment.action.ts @@ -1,6 +1,6 @@ import { faImage } from '@fortawesome/free-solid-svg-icons'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; -import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; interface AttachmentArguments { text: string; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-bold.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-bold.action.ts index 34e553588dbb..1ada4ab2b86e 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-bold.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-bold.action.ts @@ -1,7 +1,7 @@ import { faBold } from '@fortawesome/free-solid-svg-icons'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; import { KeyCode, KeyModifier } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; -import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; const BOLD_DELIMITER = '**'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code-block.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code-block.action.ts index 750197137d2e..75633a5754e8 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code-block.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code-block.action.ts @@ -1,6 +1,6 @@ import { faFileCode } from '@fortawesome/free-solid-svg-icons'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; -import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; const CODE_BLOCK_DELIMITER = '```'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code.action.ts index ea38636c0186..0d77197d8e8f 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code.action.ts @@ -1,6 +1,6 @@ import { faCode } from '@fortawesome/free-solid-svg-icons'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; -import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; const CODE_DELIMITER = '`'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-color.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-color.action.ts index 2d7deb3a945f..beed508be135 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-color.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-color.action.ts @@ -1,5 +1,5 @@ import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; -import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; interface ColorArguments { color: string; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts index 40b0e3b0d764..7fbf56a2b49e 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts @@ -3,7 +3,7 @@ import { TranslateService } from '@ngx-translate/core'; import * as monaco from 'monaco-editor'; import { enterFullscreen, exitFullscreen, isFullScreen } from 'app/shared/util/fullscreen.util'; import { Disposable, EditorPosition, EditorRange, MonacoEditorTextModel, makeEditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; -import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; export abstract class MonacoEditorAction implements monaco.editor.IActionDescriptor, Disposable { // IActionDescriptor diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model.ts index 672cc1495f8b..4e2e2cf2e820 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model.ts @@ -1,4 +1,4 @@ -import { TextEditor } from './adapter/text-editor-adapter.model'; +import { TextEditor } from './adapter/text-editor.interface'; import { MonacoEditorAction } from './monaco-editor-action.model'; /** diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-formula.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-formula.action.ts index 708732a99bc2..451015caded1 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-formula.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-formula.action.ts @@ -1,5 +1,5 @@ import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; -import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; const FORMULA_OPEN_DELIMITER = '$$ '; const FORMULA_CLOSE_DELIMITER = ' $$'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-fullscreen.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-fullscreen.action.ts index b1470a78505e..d75ff5404a29 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-fullscreen.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-fullscreen.action.ts @@ -1,7 +1,7 @@ import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; import { faCompress } from '@fortawesome/free-solid-svg-icons'; -import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; /** * Action to toggle fullscreen mode in the editor. diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-heading.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-heading.action.ts index 47104f60c06f..a1960e35f5f6 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-heading.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-heading.action.ts @@ -1,6 +1,6 @@ import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; import { faHeading } from '@fortawesome/free-solid-svg-icons'; -import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; function getTranslationKeyForLevel(level: number): string { const suffix = level === 3 ? 'Three' : level === 2 ? 'Two' : 'One'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-italic.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-italic.action.ts index 764e75e2f5e0..863826503cca 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-italic.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-italic.action.ts @@ -1,7 +1,7 @@ import { faItalic } from '@fortawesome/free-solid-svg-icons'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; import { KeyCode, KeyModifier } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; -import { TextEditor } from './adapter/text-editor-adapter.model'; +import { TextEditor } from './adapter/text-editor.interface'; const ITALIC_DELIMITER = '*'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-ordered-list.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-ordered-list.action.ts index 19b64ae79151..d17951b50ee6 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-ordered-list.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-ordered-list.action.ts @@ -1,6 +1,6 @@ import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; import { faListOl } from '@fortawesome/free-solid-svg-icons'; -import { TextEditor } from './adapter/text-editor-adapter.model'; +import { TextEditor } from './adapter/text-editor.interface'; const NUMBER_REGEX = /^\d+\.\s.*/; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-quote.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-quote.action.ts index d279f27676cc..e5190e8f6608 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-quote.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-quote.action.ts @@ -1,6 +1,6 @@ import { faQuoteLeft } from '@fortawesome/free-solid-svg-icons'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; -import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; const QUOTE_OPEN_DELIMITER = '> '; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-task.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-task.action.ts index 9acfd603903d..9cc369b4addd 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-task.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-task.action.ts @@ -1,6 +1,6 @@ import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; import { escapeStringForUseInRegex } from 'app/shared/util/global.utils'; -import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; /** * Action to insert a task into the editor. They follow the format [task][Task Short Description](testCaseName). diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-test-case.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-test-case.action.ts index 9016698a44f2..fd581d2132c6 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-test-case.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-test-case.action.ts @@ -2,7 +2,7 @@ import { TranslateService } from '@ngx-translate/core'; import { DomainActionWithOptionsArguments, MonacoEditorDomainActionWithOptions } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action-with-options.model'; import { CompletionItemKind, Disposable } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; import { ValueItem } from 'app/shared/markdown-editor/value-item.model'; -import { TextEditor } from './adapter/text-editor-adapter.model'; +import { TextEditor } from './adapter/text-editor.interface'; /** * Action to insert a test case into the editor. It also registers a completion item provider offers all possible test cases as completion items to the user. diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-underline.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-underline.action.ts index 8378f375d998..ac62d1db136f 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-underline.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-underline.action.ts @@ -1,7 +1,7 @@ import { faUnderline } from '@fortawesome/free-solid-svg-icons'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; import { KeyCode, KeyModifier } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; -import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; const UNDERLINE_OPEN_DELIMITER = ''; const UNDERLINE_CLOSE_DELIMITER = ''; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-unordered-list.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-unordered-list.action.ts index eeeaabf7b187..11774ce8e0d9 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-unordered-list.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-unordered-list.action.ts @@ -1,7 +1,7 @@ import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; import { faListUl } from '@fortawesome/free-solid-svg-icons'; import { makeEditorPosition, makeEditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; -import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; const LIST_BULLET = '- '; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-url.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-url.action.ts index d5b59b7d66f9..1650bedc20a5 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-url.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-url.action.ts @@ -1,6 +1,6 @@ import { faLink } from '@fortawesome/free-solid-svg-icons'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; -import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; interface UrlArguments { text: string; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-correct-multiple-choice-answer.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-correct-multiple-choice-answer.action.ts index 06cd831885d4..8cf6dfb49238 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-correct-multiple-choice-answer.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-correct-multiple-choice-answer.action.ts @@ -1,5 +1,5 @@ import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; -import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; export class MonacoCorrectMultipleChoiceAnswerAction extends MonacoEditorDomainAction { static readonly ID = 'artemisApp.multipleChoiceQuestion.editor.addCorrectAnswerOption'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-option.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-option.action.ts index 91df1a9c7d9a..9849b7c2ae23 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-option.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-option.action.ts @@ -1,5 +1,5 @@ import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; -import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; interface InsertShortAnswerOptionArgs { spotNumber?: number; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-spot.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-spot.action.ts index 829087b4b5b5..dcdd53a09115 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-spot.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-spot.action.ts @@ -1,6 +1,6 @@ import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; import { MonacoInsertShortAnswerOptionAction } from 'app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-option.action'; -import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; /** * Action to insert a short answer spot at the current cursor position. diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-quiz-hint.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-quiz-hint.action.ts index beb0f6861cf5..734fe60ff7be 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-quiz-hint.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-quiz-hint.action.ts @@ -1,5 +1,5 @@ import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; -import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; export class MonacoQuizHintAction extends MonacoEditorDomainAction { static readonly ID = 'monaco-quiz-hint.action'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-wrong-multiple-choice-answer.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-wrong-multiple-choice-answer.action.ts index f665e9a05365..9f6946538af0 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-wrong-multiple-choice-answer.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-wrong-multiple-choice-answer.action.ts @@ -1,5 +1,5 @@ import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; -import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-adapter.model'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; export class MonacoWrongMultipleChoiceAnswerAction extends MonacoEditorDomainAction { static readonly ID = 'monaco-incorrect-multiple-choice-answer.action'; From bbd0fa2bc0302da2b522f9d6db6c4aa78b8f85a1 Mon Sep 17 00:00:00 2001 From: Patrik Zander Date: Sat, 31 Aug 2024 11:17:59 +0200 Subject: [PATCH 11/27] Add more methods to TextEditor interface --- .../adapter/monaco-text-editor.adapter.ts | 67 ++++++++++++++----- .../adapter/text-editor-position.model.ts | 8 +++ .../actions/adapter/text-editor.interface.ts | 36 ++++++++++ .../monaco-grading-criterion.action.ts | 1 + .../actions/monaco-editor-action.model.ts | 52 +++++++------- .../actions/monaco-ordered-list.action.ts | 18 ++--- .../actions/monaco-unordered-list.action.ts | 12 ++-- 7 files changed, 139 insertions(+), 55 deletions(-) diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts index 4d519685db29..d57a3590de54 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts @@ -44,43 +44,76 @@ export class MonacoTextEditorAdapter implements TextEditor { this.editor.focus(); } + replaceTextAtRange(range: TextEditorRange, text: string): void { + this.editor.executeEdits('MonacoTextEditorAdapter::replaceTextAtRange', [ + { + range: this.toMonacoRange(range), + text, + }, + ]); + } + getDomNode(): HTMLElement | undefined { return this.editor.getDomNode() ?? undefined; } + typeText(text: string) { + this.editor.trigger('MonacoTextEditorAdapter::typeText', 'type', { text }); + } + + getTextAtRange(range: TextEditorRange): string { + return this.editor.getModel()?.getValueInRange(this.toMonacoRange(range), monaco.editor.EndOfLinePreference.LF) ?? ''; + } + + getLineText(lineNumber: number): string { + return this.editor.getModel()?.getLineContent(lineNumber) ?? ''; + } + + getNumberOfLines(): number { + return this.editor.getModel()?.getLineCount() ?? 0; + } + + getEndPosition(): TextEditorPosition { + return this.fromMonacoPosition(this.editor.getModel()?.getFullModelRange().getEndPosition() ?? { lineNumber: 1, column: 1 }); + } + getPosition(): TextEditorPosition { const position = this.editor.getPosition() ?? { column: 1, lineNumber: 1 }; - return new TextEditorPosition(position.lineNumber, position.column); + return this.fromMonacoPosition(position); } setPosition(position: TextEditorPosition): void { - this.editor.setPosition({ lineNumber: position.getLineNumber(), column: position.getColumn() }); + this.editor.setPosition(this.toMonacoPosition(position)); } getSelection(): TextEditorRange { const selection = this.editor.getSelection() ?? { startColumn: 1, startLineNumber: 1, endColumn: 1, endLineNumber: 1 }; - return makeTextEditorRange(selection.startLineNumber, selection.startColumn, selection.endLineNumber, selection.endColumn); + return this.fromMonacoRange(selection); } setSelection(selection: TextEditorRange): void { - const startPosition = selection.getStartPosition(); - const endPosition = selection.getEndPosition(); - this.editor.setSelection({ - startLineNumber: startPosition.getLineNumber(), - startColumn: startPosition.getColumn(), - endLineNumber: endPosition.getLineNumber(), - endColumn: endPosition.getColumn(), - }); + this.editor.setSelection(this.toMonacoRange(selection)); } revealRange(range: TextEditorRange): void { + this.editor.revealRangeInCenter(this.toMonacoRange(range)); + } + + private toMonacoPosition(position: TextEditorPosition): monaco.IPosition { + return new monaco.Position(position.getLineNumber(), position.getColumn()); + } + + private fromMonacoPosition(position: monaco.IPosition): TextEditorPosition { + return new TextEditorPosition(position.lineNumber, position.column); + } + + private toMonacoRange(range: TextEditorRange): monaco.IRange { const startPosition = range.getStartPosition(); const endPosition = range.getEndPosition(); - this.editor.revealRangeInCenter({ - startLineNumber: startPosition.getLineNumber(), - startColumn: startPosition.getColumn(), - endLineNumber: endPosition.getLineNumber(), - endColumn: endPosition.getColumn(), - }); + return new monaco.Range(startPosition.getLineNumber(), startPosition.getColumn(), endPosition.getLineNumber(), endPosition.getColumn()); + } + + private fromMonacoRange(range: monaco.IRange): TextEditorRange { + return makeTextEditorRange(range.startLineNumber, range.startColumn, range.endLineNumber, range.endColumn); } } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-position.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-position.model.ts index 011f21590906..2da845767916 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-position.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-position.model.ts @@ -7,6 +7,14 @@ export class TextEditorPosition { private readonly column: number, ) {} + /** + * Creates a copy of this position with the given column. + * @param column The column of the new position. + */ + withColumn(column: number): TextEditorPosition { + return new TextEditorPosition(this.lineNumber, column); + } + getLineNumber(): number { return this.lineNumber; } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor.interface.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor.interface.ts index 2d309b14139c..8cffda7a81c9 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor.interface.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor.interface.ts @@ -30,11 +30,47 @@ export interface TextEditor { */ focus(): void; + /** + * Replaces the text in the editor at the given range with the given text. + * @param range The range to replace the text at. + * @param text The text to replace the range with. + */ + replaceTextAtRange(range: TextEditorRange, text: string): void; + /** * Gets the DOM node associated with the editor, or undefined if no such node exists. */ getDomNode(): HTMLElement | undefined; + /** + * Types the given text into the editor as if the user had typed it, e.g. to trigger a completer registered in the editor. + * @param text The text to type into the editor. + */ + typeText(text: string): void; + + /** + * Retrieves the text at the given range in the editor. + * Line endings are normalized to '\n'. If no suitable text exists, an empty string is returned. + * @param range The range to get the text from. + */ + getTextAtRange(range: TextEditorRange): string; + + /** + * Retrieves the text of the line at the given line number in the editor. + * @param lineNumber The line number to get the text from. Line numbers start at 1. + */ + getLineText(lineNumber: number): string; + + /** + * Retrieves the number of lines in the editor. + */ + getNumberOfLines(): number; + + /** + * Gets the position after the last character in the editor. + */ + getEndPosition(): TextEditorPosition; + /** * Gets the position of the cursor in the editor. * If no suitable position exists, the default position is returned (1, 1). diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-criterion.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-criterion.action.ts index ad845c7814c6..0881c3b0c711 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-criterion.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-criterion.action.ts @@ -1,5 +1,6 @@ import { MonacoEditorDomainAction } from '../monaco-editor-domain-action.model'; import { MonacoGradingInstructionAction } from './monaco-grading-instruction.action'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; export class MonacoGradingCriterionAction extends MonacoEditorDomainAction { static readonly ID = 'monaco-grading-criterion.action'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts index 7fbf56a2b49e..77baa7338b23 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts @@ -4,8 +4,10 @@ import * as monaco from 'monaco-editor'; import { enterFullscreen, exitFullscreen, isFullScreen } from 'app/shared/util/fullscreen.util'; import { Disposable, EditorPosition, EditorRange, MonacoEditorTextModel, makeEditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; +import { TextEditorRange } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-range.model'; +import { TextEditorPosition } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-position.model'; -export abstract class MonacoEditorAction implements monaco.editor.IActionDescriptor, Disposable { +export abstract class MonacoEditorAction implements Disposable { // IActionDescriptor id: string; label: string; @@ -58,7 +60,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip if (!this._editor) { throw new Error('Action is not registered in an editor.'); } - this._editor.trigger(`${this.id}::executeInCurrentEditor`, this.id, args); + this._editor.executeAction(this, args); } /** @@ -198,9 +200,9 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip // Move the cursor to the end of the inserted text. Note that the delimiters may have newlines. const textBeforeCursor = `${openDelimiter}${textToInsert}`; const lines = textBeforeCursor.split('\n'); - const newLineNumber = position.lineNumber + lines.length - 1; - const newColumn = lines.length === 1 ? position.column + lines[0].length : lines[lines.length - 1].length + 1; - editor.setPosition({ lineNumber: newLineNumber, column: newColumn }); + const newLineNumber = position.getLineNumber() + lines.length - 1; + const newColumn = lines.length === 1 ? position.getColumn() + lines[0].length : lines[lines.length - 1].length + 1; + editor.setPosition(new TextEditorPosition(newLineNumber, newColumn)); } } @@ -220,7 +222,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param text The text to type. */ typeText(editor: TextEditor, text: string): void { - editor.trigger('keyboard', 'type', { text }); + editor.typeText(text); } /** @@ -251,8 +253,8 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param position The position to insert the text at. * @param text The text to insert. */ - insertTextAtPosition(editor: TextEditor, position: EditorPosition, text: string): void { - this.replaceTextAtRange(editor, makeEditorRange(position.lineNumber, position.column, position.lineNumber, position.column), text); + insertTextAtPosition(editor: TextEditor, position: TextEditorPosition, text: string): void { + this.replaceTextAtRange(editor, new TextEditorRange(position, position), text); } /** @@ -261,8 +263,8 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param range The range to replace the text at. * @param text The text to replace the range with. */ - replaceTextAtRange(editor: TextEditor, range: EditorRange, text: string): void { - editor.executeEdits(this.id, [{ range, text }]); + replaceTextAtRange(editor: TextEditor, range: TextEditorRange, text: string): void { + editor.replaceTextAtRange(range, text); } /** @@ -270,7 +272,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param editor The editor to delete the text in. * @param range The range to delete the text at. */ - deleteTextAtRange(editor: TextEditor, range: EditorRange): void { + deleteTextAtRange(editor: TextEditor, range: TextEditorRange): void { this.replaceTextAtRange(editor, range, ''); } @@ -279,9 +281,9 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param editor The editor to get the text from. * @param range The range to get the text from. */ - getTextAtRange(editor: TextEditor, range: EditorRange): string | undefined { + getTextAtRange(editor: TextEditor, range: TextEditorRange): string | undefined { // End of line preference is important here. Otherwise, Windows may use CRLF line endings. - return editor.getModel()?.getValueInRange(range, monaco.editor.EndOfLinePreference.LF); + return editor.getTextAtRange(range); } /** @@ -290,7 +292,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param lineNumber The line number to get the text from. Line numbers start at 1. */ getLineText(editor: TextEditor, lineNumber: number): string | undefined { - return editor.getModel()?.getLineContent(lineNumber); + return editor.getLineText(lineNumber); } /** @@ -298,15 +300,15 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param editor The editor to get the line count from. */ getLineCount(editor: TextEditor): number { - return editor.getModel()?.getLineCount() ?? 0; + return editor.getNumberOfLines(); } /** * Gets the position of the last character in the editor. * @param editor The editor to get the position from. */ - getEndPosition(editor: TextEditor): EditorPosition { - return editor.getModel()?.getFullModelRange().getEndPosition() ?? { lineNumber: 1, column: 1 }; + getEndPosition(editor: TextEditor): TextEditorPosition { + return editor.getEndPosition(); } /** @@ -315,15 +317,15 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param position The position to set. * @param revealLine Whether to scroll the editor to reveal the line the position is on. Defaults to false. */ - setPosition(editor: TextEditor, position: EditorPosition, revealLine = false): void { + setPosition(editor: TextEditor, position: TextEditorPosition, revealLine = false): void { editor.setPosition(position); if (revealLine) { - editor.revealLineInCenter(position.lineNumber); + editor.revealRange(new TextEditorRange(position, position)); } } - getPosition(editor: TextEditor): EditorPosition { - return editor.getPosition() ?? { lineNumber: 1, column: 1 }; + getPosition(editor: TextEditor): TextEditorPosition { + return editor.getPosition(); } /** @@ -331,9 +333,9 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param editor The editor to set the selection in. * @param selection The selection to set. */ - setSelection(editor: TextEditor, selection: EditorRange): void { + setSelection(editor: TextEditor, selection: TextEditorRange): void { editor.setSelection(selection); - editor.revealRangeInCenter(selection); + editor.revealRange(selection); } /** @@ -342,7 +344,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip */ clearSelection(editor: TextEditor): void { const position = this.getPosition(editor); - this.setSelection(editor, makeEditorRange(position.lineNumber, position.column, position.lineNumber, position.column)); + this.setSelection(editor, new TextEditorRange(position, position)); } /** @@ -350,7 +352,7 @@ export abstract class MonacoEditorAction implements monaco.editor.IActionDescrip * @param editor The editor to adjust the cursor position in. */ moveCursorToEndOfLine(editor: TextEditor): void { - const position: EditorPosition = { ...this.getPosition(editor), column: Number.POSITIVE_INFINITY }; + const position = this.getPosition(editor).withColumn(Number.MAX_VALUE); this.setPosition(editor, position); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-ordered-list.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-ordered-list.action.ts index d17951b50ee6..c67f0a92daa4 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-ordered-list.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-ordered-list.action.ts @@ -1,6 +1,7 @@ import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; import { faListOl } from '@fortawesome/free-solid-svg-icons'; import { TextEditor } from './adapter/text-editor.interface'; +import { TextEditorPosition } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-position.model'; const NUMBER_REGEX = /^\d+\.\s.*/; @@ -22,9 +23,12 @@ export class MonacoOrderedListAction extends MonacoEditorAction { const selection = editor.getSelection(); if (!selection) return; + const startLineNumber = selection.getStartPosition().getLineNumber(); + const endLineNumber = selection.getEndPosition().getLineNumber(); + let isOrderedList = true; let allLinesEmpty = true; - for (let lineNumber = selection.startLineNumber; lineNumber <= selection.endLineNumber; lineNumber++) { + for (let lineNumber = startLineNumber; lineNumber <= endLineNumber; lineNumber++) { const lineContent = this.getLineText(editor, lineNumber); if (lineContent) { allLinesEmpty = false; @@ -36,14 +40,14 @@ export class MonacoOrderedListAction extends MonacoEditorAction { } if (allLinesEmpty) { - this.insertTextAtPosition(editor, { lineNumber: selection.startLineNumber, column: 1 }, '1. '); + this.insertTextAtPosition(editor, { lineNumber: startLineNumber, column: 1 }, '1. '); // Move the cursor to after the inserted "1. " - editor.setPosition({ lineNumber: selection.startLineNumber, column: 4 }); + editor.setPosition(new TextEditorPosition(startLineNumber, 1 + '1. '.length)); editor.focus(); return; } - for (let lineNumber = selection.startLineNumber; lineNumber <= selection.endLineNumber; lineNumber++) { + for (let lineNumber = startLineNumber; lineNumber <= endLineNumber; lineNumber++) { const lineContent = this.getLineText(editor, lineNumber); if (!lineContent) continue; @@ -51,11 +55,7 @@ export class MonacoOrderedListAction extends MonacoEditorAction { const idx = lineContent.indexOf('. '); if (idx >= 0) this.deleteTextAtRange(editor, { startLineNumber: lineNumber, startColumn: 1, endLineNumber: lineNumber, endColumn: idx + 3 }); } else { - this.replaceTextAtRange( - editor, - { startLineNumber: lineNumber, startColumn: 1, endLineNumber: lineNumber, endColumn: 1 }, - `${lineNumber - selection.startLineNumber + 1}. `, - ); + this.replaceTextAtRange(editor, { startLineNumber: lineNumber, startColumn: 1, endLineNumber: lineNumber, endColumn: 1 }, `${lineNumber - startLineNumber + 1}. `); } } } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-unordered-list.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-unordered-list.action.ts index 11774ce8e0d9..2bcaca624d45 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-unordered-list.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-unordered-list.action.ts @@ -2,6 +2,7 @@ import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monac import { faListUl } from '@fortawesome/free-solid-svg-icons'; import { makeEditorPosition, makeEditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; +import { TextEditorPosition } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-position.model'; const LIST_BULLET = '- '; @@ -23,9 +24,12 @@ export class MonacoUnorderedListAction extends MonacoEditorAction { const selection = editor.getSelection(); if (!selection) return; + const startLineNumber = selection.getStartPosition().getLineNumber(); + const endLineNumber = selection.getEndPosition().getLineNumber(); + let isUnorderedList = true; let allLinesEmpty = true; - for (let lineNumber = selection.startLineNumber; lineNumber <= selection.endLineNumber; lineNumber++) { + for (let lineNumber = startLineNumber; lineNumber <= endLineNumber; lineNumber++) { const lineContent = this.getLineText(editor, lineNumber); if (lineContent) { allLinesEmpty = false; @@ -37,13 +41,13 @@ export class MonacoUnorderedListAction extends MonacoEditorAction { } if (allLinesEmpty) { - this.insertTextAtPosition(editor, makeEditorPosition(selection.startLineNumber, 1), LIST_BULLET); - editor.setPosition(makeEditorPosition(selection.startLineNumber, 1 + LIST_BULLET.length)); + this.insertTextAtPosition(editor, makeEditorPosition(startLineNumber, 1), LIST_BULLET); + editor.setPosition(new TextEditorPosition(startLineNumber, 1 + LIST_BULLET.length)); editor.focus(); return; } - for (let lineNumber = selection.startLineNumber; lineNumber <= selection.endLineNumber; lineNumber++) { + for (let lineNumber = startLineNumber; lineNumber <= endLineNumber; lineNumber++) { const lineContent = this.getLineText(editor, lineNumber); if (!lineContent) continue; From 0ef708603351fd69abebf1fb27242a46c58ee45e Mon Sep 17 00:00:00 2001 From: Patrik Zander Date: Sat, 31 Aug 2024 11:21:16 +0200 Subject: [PATCH 12/27] Remove Model --- .../model/actions/adapter/monaco-text-editor.adapter.ts | 5 ----- .../model/actions/adapter/text-editor.interface.ts | 7 ------- 2 files changed, 12 deletions(-) diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts index d57a3590de54..bd5d6e5cad89 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts @@ -3,7 +3,6 @@ import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monac import { Disposable } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; import * as monaco from 'monaco-editor'; import { TextEditorCompleter } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-completer.model'; -import { TextEditorModel } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-model.model'; import { TextEditorRange, makeTextEditorRange } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-range.model'; import { TextEditorPosition } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-position.model'; @@ -32,10 +31,6 @@ export class MonacoTextEditorAdapter implements TextEditor { return { dispose: () => {} }; } - getModel(): TextEditorModel { - return new TextEditorModel(); // TODO - } - layout(): void { this.editor.layout(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor.interface.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor.interface.ts index 8cffda7a81c9..e9e90dca9c78 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor.interface.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor.interface.ts @@ -2,7 +2,6 @@ import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monac import { Disposable } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; import { TextEditorPosition } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-position.model'; import { TextEditorRange } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-range.model'; -import { TextEditorModel } from './text-editor-model.model'; import { TextEditorCompleter } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-completer.model'; export interface TextEditor { @@ -102,12 +101,6 @@ export interface TextEditor { */ revealRange(range: TextEditorRange): void; - /** - * Gets the model of the editor. - * The model represents the content of the editor. - */ - getModel(): TextEditorModel; - /** * Adds a completer to the editor. * @param completer The completer to add to the editor. From 29c83a88f5ad6c465afbf0c4f5e81724bb1dab4c Mon Sep 17 00:00:00 2001 From: Patrik Zander Date: Sat, 31 Aug 2024 11:48:24 +0200 Subject: [PATCH 13/27] Fix addAction --- .../model/actions/adapter/monaco-text-editor.adapter.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts index bd5d6e5cad89..c606791e6db5 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts @@ -10,12 +10,12 @@ export class MonacoTextEditorAdapter implements TextEditor { constructor(private editor: monaco.editor.IStandaloneCodeEditor) {} addAction(action: MonacoEditorAction): Disposable { - const actionDescriptor = { + const actionDescriptor: monaco.editor.IActionDescriptor = { id: action.id, label: action.label, keybindings: action.keybindings, - run: () => { - action.run(this as any); // TODO + run: (_, args) => { + action.run(this, args); }, }; return this.editor.addAction(actionDescriptor); From 891fc52c33ea0ad1bd63ab6c55703988ab745e70 Mon Sep 17 00:00:00 2001 From: Patrik Zander Date: Sat, 31 Aug 2024 12:23:38 +0200 Subject: [PATCH 14/27] Fix compile --- .../adapter/monaco-text-editor.adapter.ts | 106 +++++++++++++++++- .../adapter/text-editor-completer.model.ts | 10 +- .../actions/adapter/text-editor.interface.ts | 2 +- .../monaco-channel-reference.action.ts | 13 +-- .../monaco-exercise-reference.action.ts | 20 ++-- .../monaco-user-mention.action.ts | 13 +-- .../actions/monaco-editor-action.model.ts | 57 ++-------- .../monaco-editor-domain-action.model.ts | 11 +- .../actions/monaco-ordered-list.action.ts | 7 +- .../model/actions/monaco-test-case.action.ts | 14 +-- .../actions/monaco-unordered-list.action.ts | 8 +- ...onaco-insert-short-answer-option.action.ts | 13 ++- .../quiz/monaco-quiz-explanation.action.ts | 2 +- .../monaco-editor/monaco-editor.component.ts | 9 +- 14 files changed, 170 insertions(+), 115 deletions(-) diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts index c606791e6db5..2486c089aa2f 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts @@ -1,10 +1,11 @@ import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; -import { Disposable } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { Disposable, EditorPosition, MonacoEditorTextModel, makeEditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; import * as monaco from 'monaco-editor'; import { TextEditorCompleter } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-completer.model'; import { TextEditorRange, makeTextEditorRange } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-range.model'; import { TextEditorPosition } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-position.model'; +import { TextEditorCompletionItemKind } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-completion-item.model'; export class MonacoTextEditorAdapter implements TextEditor { constructor(private editor: monaco.editor.IStandaloneCodeEditor) {} @@ -25,10 +26,96 @@ export class MonacoTextEditorAdapter implements TextEditor { this.editor.trigger('MonacoTextEditorAdapter::executeAction', action.id, args); } - // eslint-disable-next-line @typescript-eslint/no-unused-vars - addCompleter(completer: TextEditorCompleter): Disposable { - // TODO - return { dispose: () => {} }; + addCompleter(completer: TextEditorCompleter): Disposable { + const model = this.editor.getModel(); + if (!model) { + throw new Error(`A model must be attached to the editor to register a completer.`); + } + const triggerCharacter = completer.triggerCharacter; + if (triggerCharacter !== undefined && triggerCharacter.length !== 1) { + throw new Error(`The trigger character must be a single character.`); + } + const languageId = model.getLanguageId(); + const modelId = model.id; + + // We have to subtract an offset of 1 from the start column to include the trigger character in the range that will be replaced. + const triggerCharacterOffset = triggerCharacter ? 1 : 0; + return monaco.languages.registerCompletionItemProvider(languageId, { + // We only want to trigger the completion provider if the trigger character is typed. However, we also allow numbers to trigger the completion, as they would not normally trigger it. + triggerCharacters: triggerCharacter ? [triggerCharacter, ...'0123456789'] : undefined, + provideCompletionItems: async (model: MonacoEditorTextModel, position: EditorPosition): Promise => { + if (model.id !== modelId) { + return undefined; + } + const sequenceUntilPosition = this.findTypedSequenceUntilPosition(model, position, triggerCharacter); + if (!sequenceUntilPosition) { + return undefined; + } + const range = { + startLineNumber: position.lineNumber, + startColumn: sequenceUntilPosition.startColumn - triggerCharacterOffset, + endLineNumber: position.lineNumber, + endColumn: sequenceUntilPosition.endColumn, + }; + const beforeWord = model.getValueInRange({ + startLineNumber: position.lineNumber, + startColumn: sequenceUntilPosition.startColumn - triggerCharacterOffset, + endLineNumber: position.lineNumber, + endColumn: sequenceUntilPosition.startColumn, + }); + + // We only want suggestions if the trigger character is at the beginning of the word. + if (triggerCharacter && sequenceUntilPosition.word !== triggerCharacter && beforeWord !== triggerCharacter) { + return undefined; + } + const items = (await completer.searchItems(sequenceUntilPosition.word)).map((item) => completer.mapCompletionItem(item, this.fromMonacoRange(range))); + + return { + suggestions: items.map((item) => { + return { + label: item.getLabel(), + kind: this.toMonacoCompletionKind(item.getKind()), + insertText: item.getInsertText(), + range: this.toMonacoRange(item.getRange()), + detail: item.getDetailText(), + }; + }), + incomplete: completer.incomplete, + }; + }, + }); + } + + /** + * Finds the sequence of characters that was typed between the trigger character and the current position. If no trigger character is provided, we assume the sequence starts at the beginning of the word (default Monaco behavior). + * @param model The model to find the typed sequence in. + * @param position The position until which to find the typed sequence. + * @param triggerCharacter The character that triggers the sequence. If not provided, the sequence is assumed to start at the beginning of the word. + * @param lengthLimit The maximum length of the sequence to find. Defaults to 25. + */ + private findTypedSequenceUntilPosition( + model: monaco.editor.ITextModel, + position: monaco.IPosition, + triggerCharacter?: string, + lengthLimit = 25, + ): monaco.editor.IWordAtPosition | undefined { + // Find the sequence of characters that was typed between the trigger character and the current position. If no trigger character is provided, we assume the sequence starts at the beginning of the word. + if (!triggerCharacter) { + return model.getWordUntilPosition(position); + } + const scanColumn = Math.max(1, position.column - lengthLimit); + const scanRange = makeEditorRange(position.lineNumber, scanColumn, position.lineNumber, position.column); + const text = model.getValueInRange(scanRange); + const triggerIndex = text.lastIndexOf(triggerCharacter); + if (triggerIndex === -1) { + return undefined; + } + // The word not including the trigger character. + return { + word: text.slice(triggerIndex + 1), + startColumn: scanRange.startColumn + triggerIndex + 1, + endColumn: position.column, + }; } layout(): void { @@ -111,4 +198,13 @@ export class MonacoTextEditorAdapter implements TextEditor { private fromMonacoRange(range: monaco.IRange): TextEditorRange { return makeTextEditorRange(range.startLineNumber, range.startColumn, range.endLineNumber, range.endColumn); } + + private toMonacoCompletionKind(kind: TextEditorCompletionItemKind) { + switch (kind) { + case TextEditorCompletionItemKind.User: + return monaco.languages.CompletionItemKind.User; + default: + return monaco.languages.CompletionItemKind.Constant; + } + } } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-completer.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-completer.model.ts index e313d8692720..083e6f43207a 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-completer.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-completer.model.ts @@ -1,4 +1,5 @@ import { TextEditorCompletionItem } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-completion-item.model'; +import { TextEditorRange } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-range.model'; /** * An interface for a completer that can be used with a text editor. @@ -6,14 +7,14 @@ import { TextEditorCompletionItem } from 'app/shared/monaco-editor/model/actions */ export interface TextEditorCompleter { /** - * The trigger characters that should cause the completer to search for completions. + * An optional character that, upon being typed, triggers the completer to show completion items. */ - triggerCharacters: string[]; + triggerCharacter?: string; /** * Whether the completer has more completions that can be searched for (e.g. if the results depend on a rest call). */ - completionsAreIncomplete: boolean; + incomplete: boolean; /** * Searches for completion items based on the given search string. @@ -24,6 +25,7 @@ export interface TextEditorCompleter { /** * Maps a completion item to a text editor completion item. * @param item The completion item to map. + * @param range The range in the editor where the completion item should be inserted. */ - mapCompletionItem(item: ItemType): TextEditorCompletionItem; + mapCompletionItem(item: ItemType, range: TextEditorRange): TextEditorCompletionItem; } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor.interface.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor.interface.ts index e9e90dca9c78..dfd4c67f5838 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor.interface.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor.interface.ts @@ -6,7 +6,7 @@ import { TextEditorCompleter } from 'app/shared/monaco-editor/model/actions/adap export interface TextEditor { /** - * Adds an action to the editor. An action should only be in one editor at a time. + * Adds an action to the editor. An action should only be registered in one editor at a time. * @param action The action to add to the editor. * @return A disposable that can be used to remove the action from the editor. */ diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts index 18b355299beb..e071d872f8c3 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts @@ -5,8 +5,10 @@ import { ChannelIdAndNameDTO } from 'app/entities/metis/conversation/channel.mod import { MetisService } from 'app/shared/metis/metis.service'; import { ChannelService } from 'app/shared/metis/conversations/channel.service'; import { firstValueFrom } from 'rxjs'; -import { CompletionItemKind, Disposable, EditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { Disposable } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; +import { TextEditorRange } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-range.model'; +import { TextEditorCompletionItem, TextEditorCompletionItemKind } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-completion-item.model'; /** * Action to insert a reference to a channel into the editor. Users that type a # will see a list of available channels to reference. @@ -35,13 +37,8 @@ export class MonacoChannelReferenceAction extends MonacoEditorAction { this.disposableCompletionProvider = this.registerCompletionProviderForCurrentModel( editor, this.fetchChannels.bind(this), - (channel: ChannelIdAndNameDTO, range: EditorRange) => ({ - label: `#${channel.name}`, - kind: CompletionItemKind.Constant, - insertText: `[channel]${channel.name}(${channel.id})[/channel]`, - range, - detail: this.label, - }), + (channel: ChannelIdAndNameDTO, range: TextEditorRange) => + new TextEditorCompletionItem(`#${channel.name}`, this.label, `[channel]${channel.name}(${channel.id})[/channel]`, TextEditorCompletionItemKind.Default, range), '#', ); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action.ts index fc6b2e7307f6..b2119d0d6189 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action.ts @@ -2,8 +2,10 @@ import { TranslateService } from '@ngx-translate/core'; import { MetisService } from 'app/shared/metis/metis.service'; import { MonacoEditorDomainActionWithOptions } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action-with-options.model'; import { ValueItem } from 'app/shared/markdown-editor/value-item.model'; -import { CompletionItemKind, Disposable, EditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { Disposable } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; +import { TextEditorCompletionItem, TextEditorCompletionItemKind } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-completion-item.model'; +import { TextEditorRange } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-range.model'; /** * Action to insert a reference to an exercise into the editor. Users that type a / will see a list of available exercises to reference. @@ -33,16 +35,18 @@ export class MonacoExerciseReferenceAction extends MonacoEditorDomainActionWithO type: exercise.type, })), ); + this.disposableCompletionProvider = this.registerCompletionProviderForCurrentModel( editor, () => Promise.resolve(this.getValues()), - (item: ValueItem, range: EditorRange) => ({ - label: `/exercise ${item.value}`, - kind: CompletionItemKind.Constant, - insertText: `[${item.type}]${item.value}(${this.metisService.getLinkForExercise(item.id)})[/${item.type}]`, - range, - detail: item.type!, - }), + (item: ValueItem, range: TextEditorRange) => + new TextEditorCompletionItem( + `/exercise ${item.value}`, + item.type, + `[${item.type}]${item.value}(${this.metisService.getLinkForExercise(item.id)})[/${item.type}]`, + TextEditorCompletionItemKind.Default, + range, + ), '/', ); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts index 7100a3c5f670..10e32212f9b3 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts @@ -5,8 +5,10 @@ import { CourseManagementService } from 'app/course/manage/course-management.ser import { MetisService } from 'app/shared/metis/metis.service'; import { firstValueFrom } from 'rxjs'; import { UserNameAndLoginDTO } from 'app/core/user/user.model'; -import { CompletionItemKind, Disposable, EditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { Disposable } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; +import { TextEditorRange } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-range.model'; +import { TextEditorCompletionItem, TextEditorCompletionItemKind } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-completion-item.model'; /** * Action to insert a user mention into the editor. Users that type a @ will see a list of available users to mention. @@ -35,13 +37,8 @@ export class MonacoUserMentionAction extends MonacoEditorAction { this.disposableCompletionProvider = this.registerCompletionProviderForCurrentModel( editor, this.loadUsersForSearchTerm.bind(this), - (user: UserNameAndLoginDTO, range: EditorRange) => ({ - label: `@${user.name}`, - kind: CompletionItemKind.User, - insertText: `[user]${user.name}(${user.login})[/user]`, - range, - detail: this.label, - }), + (user: UserNameAndLoginDTO, range: TextEditorRange) => + new TextEditorCompletionItem(`@${user.name}`, this.label, `[user]${user.name}(${user.login})[/user]`, TextEditorCompletionItemKind.User, range), '@', true, ); diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts index 77baa7338b23..d07584481907 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts @@ -2,10 +2,11 @@ import { IconDefinition } from '@fortawesome/fontawesome-svg-core'; import { TranslateService } from '@ngx-translate/core'; import * as monaco from 'monaco-editor'; import { enterFullscreen, exitFullscreen, isFullScreen } from 'app/shared/util/fullscreen.util'; -import { Disposable, EditorPosition, EditorRange, MonacoEditorTextModel, makeEditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { Disposable, EditorPosition, MonacoEditorTextModel, makeEditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; import { TextEditorRange } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-range.model'; import { TextEditorPosition } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-position.model'; +import { TextEditorCompletionItem } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-completion-item.model'; export abstract class MonacoEditorAction implements Disposable { // IActionDescriptor @@ -91,62 +92,22 @@ export abstract class MonacoEditorAction implements Disposable { * Registers a completion provider for the current model of the given editor. This is useful to provide completion items for a specific editor, which is not supported by the monaco API. * @param editor The editor whose model to register the completion provider for. * @param searchFn Function that returns all relevant items for the current search term. Note that Monaco also filters the items based on the user input. - * @param mapToSuggestionFn Function that maps an item to a Monaco completion suggestion. + * @param mapToCompletionItemFn Function that maps an item to a Monaco completion suggestion. * @param triggerCharacter The character that triggers the completion provider. * @param listIncomplete Whether the list of suggestions is incomplete. If true, Monaco will keep searching for more suggestions. */ registerCompletionProviderForCurrentModel( editor: TextEditor, searchFn: (searchTerm?: string) => Promise, - mapToSuggestionFn: (item: ItemType, range: EditorRange) => monaco.languages.CompletionItem, + mapToCompletionItemFn: (item: ItemType, range: TextEditorRange) => TextEditorCompletionItem, triggerCharacter?: string, listIncomplete?: boolean, ): monaco.IDisposable { - const model = editor.getModel(); - if (!model) { - throw new Error(`A model must be attached to the editor to register a completion provider.`); - } - if (triggerCharacter !== undefined && triggerCharacter.length !== 1) { - throw new Error(`The trigger character must be a single character.`); - } - const languageId = model.getLanguageId(); - const modelId = model.id; - // We have to subtract an offset of 1 from the start column to include the trigger character in the range that will be replaced. - const triggerCharacterOffset = triggerCharacter ? 1 : 0; - return monaco.languages.registerCompletionItemProvider(languageId, { - // We only want to trigger the completion provider if the trigger character is typed. However, we also allow numbers to trigger the completion, as they would not normally trigger it. - triggerCharacters: triggerCharacter ? [triggerCharacter, ...'0123456789'] : undefined, - provideCompletionItems: async (model: MonacoEditorTextModel, position: EditorPosition): Promise => { - if (model.id !== modelId) { - return undefined; - } - const sequenceUntilPosition = this.findTypedSequenceUntilPosition(model, position, triggerCharacter); - if (!sequenceUntilPosition) { - return undefined; - } - const range = { - startLineNumber: position.lineNumber, - startColumn: sequenceUntilPosition.startColumn - triggerCharacterOffset, - endLineNumber: position.lineNumber, - endColumn: sequenceUntilPosition.endColumn, - }; - const beforeWord = model.getValueInRange({ - startLineNumber: position.lineNumber, - startColumn: sequenceUntilPosition.startColumn - triggerCharacterOffset, - endLineNumber: position.lineNumber, - endColumn: sequenceUntilPosition.startColumn, - }); - - // We only want suggestions if the trigger character is at the beginning of the word. - if (triggerCharacter && sequenceUntilPosition.word !== triggerCharacter && beforeWord !== triggerCharacter) { - return undefined; - } - const items = await searchFn(sequenceUntilPosition.word); - return { - suggestions: items.map((item) => mapToSuggestionFn(item, range)), - incomplete: listIncomplete, - }; - }, + return editor.addCompleter({ + triggerCharacter, + incomplete: listIncomplete ?? false, + searchItems: searchFn, + mapCompletionItem: mapToCompletionItemFn, }); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model.ts index 4e2e2cf2e820..e2d7dd9daaf8 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model.ts @@ -1,5 +1,6 @@ import { TextEditor } from './adapter/text-editor.interface'; import { MonacoEditorAction } from './monaco-editor-action.model'; +import { makeTextEditorRange } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-range.model'; /** * Class representing domain actions for Artemis-specific use cases. @@ -24,12 +25,10 @@ export abstract class MonacoEditorDomainAction extends MonacoEditorAction { if (updateSelection) { const newPosition = this.getPosition(editor); // Set the selection to cover exactly the text part - this.setSelection(editor, { - startLineNumber: newPosition.lineNumber, - endLineNumber: newPosition.lineNumber, - startColumn: newPosition.column - text.length, - endColumn: newPosition.column, - }); + this.setSelection( + editor, + makeTextEditorRange(newPosition.getLineNumber(), newPosition.getColumn() - text.length, newPosition.getLineNumber(), newPosition.getColumn()), + ); } editor.focus(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-ordered-list.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-ordered-list.action.ts index c67f0a92daa4..5d56574e74af 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-ordered-list.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-ordered-list.action.ts @@ -2,6 +2,7 @@ import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monac import { faListOl } from '@fortawesome/free-solid-svg-icons'; import { TextEditor } from './adapter/text-editor.interface'; import { TextEditorPosition } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-position.model'; +import { makeTextEditorRange } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-range.model'; const NUMBER_REGEX = /^\d+\.\s.*/; @@ -40,7 +41,7 @@ export class MonacoOrderedListAction extends MonacoEditorAction { } if (allLinesEmpty) { - this.insertTextAtPosition(editor, { lineNumber: startLineNumber, column: 1 }, '1. '); + this.insertTextAtPosition(editor, new TextEditorPosition(startLineNumber, 1), '1. '); // Move the cursor to after the inserted "1. " editor.setPosition(new TextEditorPosition(startLineNumber, 1 + '1. '.length)); editor.focus(); @@ -53,9 +54,9 @@ export class MonacoOrderedListAction extends MonacoEditorAction { if (isOrderedList) { const idx = lineContent.indexOf('. '); - if (idx >= 0) this.deleteTextAtRange(editor, { startLineNumber: lineNumber, startColumn: 1, endLineNumber: lineNumber, endColumn: idx + 3 }); + if (idx >= 0) this.deleteTextAtRange(editor, makeTextEditorRange(lineNumber, 1, lineNumber, idx + 3)); } else { - this.replaceTextAtRange(editor, { startLineNumber: lineNumber, startColumn: 1, endLineNumber: lineNumber, endColumn: 1 }, `${lineNumber - startLineNumber + 1}. `); + this.replaceTextAtRange(editor, makeTextEditorRange(lineNumber, 1, lineNumber, 1), `${lineNumber - startLineNumber + 1}. `); } } } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-test-case.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-test-case.action.ts index fd581d2132c6..9b855643f851 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-test-case.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-test-case.action.ts @@ -1,8 +1,10 @@ import { TranslateService } from '@ngx-translate/core'; import { DomainActionWithOptionsArguments, MonacoEditorDomainActionWithOptions } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action-with-options.model'; -import { CompletionItemKind, Disposable } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { Disposable } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; import { ValueItem } from 'app/shared/markdown-editor/value-item.model'; import { TextEditor } from './adapter/text-editor.interface'; +import { TextEditorRange } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-range.model'; +import { TextEditorCompletionItem, TextEditorCompletionItemKind } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-completion-item.model'; /** * Action to insert a test case into the editor. It also registers a completion item provider offers all possible test cases as completion items to the user. @@ -28,15 +30,7 @@ export class MonacoTestCaseAction extends MonacoEditorDomainActionWithOptions { this.disposableCompletionProvider = this.registerCompletionProviderForCurrentModel( editor, () => Promise.resolve(this.values), - (item, range) => { - return { - label: item.value, - kind: CompletionItemKind.Constant, - insertText: item.value, - range, - detail: 'Test', - }; - }, + (item: ValueItem, range: TextEditorRange) => new TextEditorCompletionItem(item.value, 'Test', item.value, TextEditorCompletionItemKind.Default, range), ); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-unordered-list.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-unordered-list.action.ts index 2bcaca624d45..f7aa8b4945b8 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-unordered-list.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-unordered-list.action.ts @@ -1,8 +1,8 @@ import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; import { faListUl } from '@fortawesome/free-solid-svg-icons'; -import { makeEditorPosition, makeEditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; import { TextEditorPosition } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-position.model'; +import { makeTextEditorRange } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-range.model'; const LIST_BULLET = '- '; @@ -41,7 +41,7 @@ export class MonacoUnorderedListAction extends MonacoEditorAction { } if (allLinesEmpty) { - this.insertTextAtPosition(editor, makeEditorPosition(startLineNumber, 1), LIST_BULLET); + this.insertTextAtPosition(editor, new TextEditorPosition(startLineNumber, 1), LIST_BULLET); editor.setPosition(new TextEditorPosition(startLineNumber, 1 + LIST_BULLET.length)); editor.focus(); return; @@ -52,9 +52,9 @@ export class MonacoUnorderedListAction extends MonacoEditorAction { if (!lineContent) continue; if (isUnorderedList) { - this.deleteTextAtRange(editor, makeEditorRange(lineNumber, 1, lineNumber, 1 + LIST_BULLET.length)); + this.deleteTextAtRange(editor, makeTextEditorRange(lineNumber, 1, lineNumber, 1 + LIST_BULLET.length)); } else { - this.insertTextAtPosition(editor, makeEditorPosition(lineNumber, 1), LIST_BULLET); + this.insertTextAtPosition(editor, new TextEditorPosition(lineNumber, 1), LIST_BULLET); } } } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-option.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-option.action.ts index 9849b7c2ae23..5f3311c185f6 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-option.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-option.action.ts @@ -1,5 +1,6 @@ import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; +import { makeTextEditorRange } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-range.model'; interface InsertShortAnswerOptionArgs { spotNumber?: number; @@ -46,12 +47,12 @@ export class MonacoInsertShortAnswerOptionAction extends MonacoEditorAction { // For convenience, we want to select the option text if it is the default text if (optionText === MonacoInsertShortAnswerOptionAction.DEFAULT_TEXT) { const newEndPosition = this.getEndPosition(editor); - const selection = { - startLineNumber: newEndPosition.lineNumber, - startColumn: newEndPosition.column - MonacoInsertShortAnswerOptionAction.DEFAULT_TEXT.length, - endLineNumber: newEndPosition.lineNumber, - endColumn: newEndPosition.column, - }; + const selection = makeTextEditorRange( + newEndPosition.getLineNumber(), + newEndPosition.getColumn() - MonacoInsertShortAnswerOptionAction.DEFAULT_TEXT.length, + newEndPosition.getLineNumber(), + newEndPosition.getColumn(), + ); this.setSelection(editor, selection); } editor.focus(); diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-quiz-explanation.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-quiz-explanation.action.ts index 10ae3be03070..4079de8736bf 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-quiz-explanation.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-quiz-explanation.action.ts @@ -1,5 +1,5 @@ import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; -import { TextEditor } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; export class MonacoQuizExplanationAction extends MonacoEditorDomainAction { static readonly ID = 'monaco-quiz-explanation.action'; diff --git a/src/main/webapp/app/shared/monaco-editor/monaco-editor.component.ts b/src/main/webapp/app/shared/monaco-editor/monaco-editor.component.ts index 0b90fefbdda8..800a93c7f0cf 100644 --- a/src/main/webapp/app/shared/monaco-editor/monaco-editor.component.ts +++ b/src/main/webapp/app/shared/monaco-editor/monaco-editor.component.ts @@ -10,7 +10,8 @@ import { MonacoEditorLineDecorationsHoverButton } from './model/monaco-editor-li import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; import { TranslateService } from '@ngx-translate/core'; import { MonacoEditorOptionPreset } from 'app/shared/monaco-editor/model/monaco-editor-option-preset.model'; -import { Disposable, EditorPosition, EditorRange, MonacoEditorTextModel, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { Disposable, EditorPosition, EditorRange, MonacoEditorTextModel } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { MonacoTextEditorAdapter } from 'app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter'; export const MAX_TAB_SIZE = 8; @@ -21,7 +22,8 @@ export const MAX_TAB_SIZE = 8; encapsulation: ViewEncapsulation.None, }) export class MonacoEditorComponent implements OnInit, OnDestroy { - private _editor: MonacoEditorWithActions; + private _editor: monaco.editor.IStandaloneCodeEditor; + private textEditorAdapter: MonacoTextEditorAdapter; private monacoEditorContainerElement: HTMLElement; themeSubscription?: Subscription; models: MonacoEditorTextModel[] = []; @@ -63,6 +65,7 @@ export class MonacoEditorComponent implements OnInit, OnDestroy { }, }); this._editor.getModel()?.setEOL(monaco.editor.EndOfLineSequence.LF); + this.textEditorAdapter = new MonacoTextEditorAdapter(this._editor); renderer.appendChild(elementRef.nativeElement, this.monacoEditorContainerElement); } @@ -381,7 +384,7 @@ export class MonacoEditorComponent implements OnInit, OnDestroy { * @param action The action to register. */ registerAction(action: MonacoEditorAction): void { - action.register(this._editor, this.translateService); + action.register(this.textEditorAdapter, this.translateService); this.actions.push(action); } From e188a36dbff29488fd3e3fe017f1473eeb364bc2 Mon Sep 17 00:00:00 2001 From: Patrik Zander Date: Sat, 31 Aug 2024 12:37:59 +0200 Subject: [PATCH 15/27] Fix tests --- .../monaco-editor-communication-action.integration.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-communication-action.integration.spec.ts b/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-communication-action.integration.spec.ts index 8c3794a25513..ef3e3f8d09df 100644 --- a/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-communication-action.integration.spec.ts +++ b/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-communication-action.integration.spec.ts @@ -179,7 +179,7 @@ describe('MonacoEditorCommunicationActionIntegration', () => { registerActionWithCompletionProvider(action, triggerCharacter); const providerResult = await provider.provideCompletionItems(comp.models[0], new monaco.Position(1, column), {} as any, {} as any); expect(providerResult).toBeDefined(); - expect(providerResult!.incomplete).toBe(actionId === MonacoUserMentionAction.ID ? true : undefined); + expect(providerResult!.incomplete).toBe(actionId === MonacoUserMentionAction.ID); const suggestions = providerResult!.suggestions; switch (actionId) { case MonacoChannelReferenceAction.ID: From e78dbee6f01add39dc05403466d03ba92dada082 Mon Sep 17 00:00:00 2001 From: Patrik Zander Date: Sat, 31 Aug 2024 12:43:37 +0200 Subject: [PATCH 16/27] Remove unused types/functions --- .../actions/monaco-editor-action.model.ts | 31 +------------------ .../model/actions/monaco-editor.util.ts | 7 +---- 2 files changed, 2 insertions(+), 36 deletions(-) diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts index d07584481907..b42496343c94 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts @@ -2,19 +2,17 @@ import { IconDefinition } from '@fortawesome/fontawesome-svg-core'; import { TranslateService } from '@ngx-translate/core'; import * as monaco from 'monaco-editor'; import { enterFullscreen, exitFullscreen, isFullScreen } from 'app/shared/util/fullscreen.util'; -import { Disposable, EditorPosition, MonacoEditorTextModel, makeEditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { Disposable } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; import { TextEditorRange } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-range.model'; import { TextEditorPosition } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-position.model'; import { TextEditorCompletionItem } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-completion-item.model'; export abstract class MonacoEditorAction implements Disposable { - // IActionDescriptor id: string; label: string; translationKey: string; keybindings?: number[]; - icon?: IconDefinition; readonly hideInEditor: boolean; @@ -111,33 +109,6 @@ export abstract class MonacoEditorAction implements Disposable { }); } - /** - * Finds the sequence of characters that was typed between the trigger character and the current position. If no trigger character is provided, we assume the sequence starts at the beginning of the word (default Monaco behavior). - * @param model The model to find the typed sequence in. - * @param position The position until which to find the typed sequence. - * @param triggerCharacter The character that triggers the sequence. If not provided, the sequence is assumed to start at the beginning of the word. - * @param lengthLimit The maximum length of the sequence to find. Defaults to 25. - */ - findTypedSequenceUntilPosition(model: MonacoEditorTextModel, position: EditorPosition, triggerCharacter?: string, lengthLimit = 25): monaco.editor.IWordAtPosition | undefined { - // Find the sequence of characters that was typed between the trigger character and the current position. If no trigger character is provided, we assume the sequence starts at the beginning of the word. - if (!triggerCharacter) { - return model.getWordUntilPosition(position); - } - const scanColumn = Math.max(1, position.column - lengthLimit); - const scanRange = makeEditorRange(position.lineNumber, scanColumn, position.lineNumber, position.column); - const text = model.getValueInRange(scanRange); - const triggerIndex = text.lastIndexOf(triggerCharacter); - if (triggerIndex === -1) { - return undefined; - } - // The word not including the trigger character. - return { - word: text.slice(triggerIndex + 1), - startColumn: scanRange.startColumn + triggerIndex + 1, - endColumn: position.column, - }; - } - /** * Toggles the given delimiter around the current selection or inserts it at the current cursor position if there is no selection. * In the latter case, textToInsert is inserted between the delimiters. diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor.util.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor.util.ts index cefee33d7c48..b4de1c3c4030 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor.util.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor.util.ts @@ -5,7 +5,7 @@ import * as monaco from 'monaco-editor'; */ // Generic Monaco editor types -export type Disposable = monaco.IDisposable; +export type Disposable = { dispose(): void }; export type MonacoEditorWithActions = monaco.editor.ICodeEditor & { addAction: (action: monaco.editor.IActionDescriptor) => Disposable }; export type MonacoEditorTextModel = monaco.editor.ITextModel; export type EditorPosition = monaco.IPosition; @@ -26,11 +26,6 @@ export const GlyphMarginLane = monaco.editor.GlyphMarginLane; export const TrackedRangeStickiness = monaco.editor.TrackedRangeStickiness; export const KeyModifier = monaco.KeyMod; export const KeyCode = monaco.KeyCode; -export const CompletionItemKind = monaco.languages.CompletionItemKind; - -export function makeEditorPosition(lineNumber: number, column: number): EditorPosition { - return { lineNumber, column }; -} export function makeEditorRange(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number): EditorRange { return { startLineNumber, startColumn, endLineNumber, endColumn }; From 2be3d2d694e4763a2f02833270dfca3984bdb5ed Mon Sep 17 00:00:00 2001 From: Patrik Zander Date: Sat, 31 Aug 2024 13:38:18 +0200 Subject: [PATCH 17/27] Remove more type definitions --- .../model/actions/monaco-editor.util.ts | 17 --------------- .../model/monaco-code-editor-element.model.ts | 7 ++++--- .../monaco-editor-build-annotation.model.ts | 21 +++++++------------ ...monaco-editor-glyph-margin-widget.model.ts | 11 +++++----- .../monaco-editor-inline-widget.model.ts | 4 ++-- ...tor-line-decorations-hover-button.model.ts | 20 +++++++----------- .../monaco-editor-line-highlight.model.ts | 20 +++++++----------- .../monaco-editor-overlay-widget.model.ts | 9 +++++--- .../model/monaco-editor-view-zone.model.ts | 6 +++--- .../monaco-diff-editor.component.ts | 4 ++-- 10 files changed, 44 insertions(+), 75 deletions(-) diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor.util.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor.util.ts index b4de1c3c4030..9c8e6688324f 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor.util.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor.util.ts @@ -1,9 +1,4 @@ import * as monaco from 'monaco-editor'; - -/* - * This file contains type definitions and utility functions for the Monaco editor, which reduces the amount of imports needed in other files. - */ - // Generic Monaco editor types export type Disposable = { dispose(): void }; export type MonacoEditorWithActions = monaco.editor.ICodeEditor & { addAction: (action: monaco.editor.IActionDescriptor) => Disposable }; @@ -11,19 +6,7 @@ export type MonacoEditorTextModel = monaco.editor.ITextModel; export type EditorPosition = monaco.IPosition; export type EditorRange = monaco.IRange; export type EditorOptions = monaco.editor.IEditorOptions; -export type EditorMouseEvent = monaco.editor.IEditorMouseEvent; -// Types for elements in the editor -export type EditorDecorationsCollection = monaco.editor.IEditorDecorationsCollection; -export type ModelDeltaDecoration = monaco.editor.IModelDeltaDecoration; -export type GlyphMarginWidget = monaco.editor.IGlyphMarginWidget; -export type GlyphMarginLane = monaco.editor.GlyphMarginLane; -export type GlyphMarginPosition = monaco.editor.IGlyphMarginWidgetPosition; -export type OverlayWidget = monaco.editor.IOverlayWidget; -export type OverlayWidgetPosition = monaco.editor.IOverlayWidgetPosition | null; // null is used by the monaco editor API -export type ViewZone = monaco.editor.IViewZone; // Enums -export const GlyphMarginLane = monaco.editor.GlyphMarginLane; -export const TrackedRangeStickiness = monaco.editor.TrackedRangeStickiness; export const KeyModifier = monaco.KeyMod; export const KeyCode = monaco.KeyCode; diff --git a/src/main/webapp/app/shared/monaco-editor/model/monaco-code-editor-element.model.ts b/src/main/webapp/app/shared/monaco-editor/model/monaco-code-editor-element.model.ts index b67793e2fd39..564ea465fcd8 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/monaco-code-editor-element.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/monaco-code-editor-element.model.ts @@ -1,4 +1,5 @@ -import { Disposable, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { Disposable } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import * as monaco from 'monaco-editor'; /** * Abstract class representing an element in the Monaco editor, e.g. a line widget. @@ -8,13 +9,13 @@ export abstract class MonacoCodeEditorElement implements Disposable { private id: string | undefined; private visible = true; - protected readonly editor: MonacoEditorWithActions; + protected readonly editor: monaco.editor.IStandaloneCodeEditor; /** * @param editor The editor to render this element in. * @param id The id of this element if available, or undefined if not. If the ID is not available at construction time, it must be set using {@link setId}. */ - protected constructor(editor: MonacoEditorWithActions, id: string | undefined) { + protected constructor(editor: monaco.editor.IStandaloneCodeEditor, id: string | undefined) { this.editor = editor; this.id = id; } diff --git a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-build-annotation.model.ts b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-build-annotation.model.ts index 0e5588c2ca4d..63a93d1c4a2d 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-build-annotation.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-build-annotation.model.ts @@ -1,14 +1,7 @@ import { MonacoCodeEditorElement } from 'app/shared/monaco-editor/model/monaco-code-editor-element.model'; import { MonacoEditorGlyphMarginWidget } from 'app/shared/monaco-editor/model/monaco-editor-glyph-margin-widget.model'; -import { - Disposable, - EditorDecorationsCollection, - GlyphMarginLane, - ModelDeltaDecoration, - MonacoEditorWithActions, - TrackedRangeStickiness, - makeEditorRange, -} from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { Disposable, makeEditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import * as monaco from 'monaco-editor'; export enum MonacoEditorBuildAnnotationType { WARNING = 'warning', @@ -23,7 +16,7 @@ export enum MonacoEditorBuildAnnotationType { */ export class MonacoEditorBuildAnnotation extends MonacoCodeEditorElement { private glyphMarginWidget: MonacoEditorGlyphMarginWidget; - private decorationsCollection: EditorDecorationsCollection; + private decorationsCollection: monaco.editor.IEditorDecorationsCollection; private outdated: boolean; private hoverMessage: string; private type: MonacoEditorBuildAnnotationType; @@ -37,7 +30,7 @@ export class MonacoEditorBuildAnnotation extends MonacoCodeEditorElement { * @param type The type of this annotation: error or warning. * @param outdated Whether this annotation is outdated and should be grayed out. Defaults to false. */ - constructor(editor: MonacoEditorWithActions, id: string, lineNumber: number, hoverMessage: string, type: MonacoEditorBuildAnnotationType, outdated = false) { + constructor(editor: monaco.editor.IStandaloneCodeEditor, id: string, lineNumber: number, hoverMessage: string, type: MonacoEditorBuildAnnotationType, outdated = false) { super(editor, id); this.decorationsCollection = this.editor.createDecorationsCollection([]); this.hoverMessage = hoverMessage; @@ -46,7 +39,7 @@ export class MonacoEditorBuildAnnotation extends MonacoCodeEditorElement { const glyphMarginDomNode = document.createElement('div'); glyphMarginDomNode.id = `monaco-editor-glyph-margin-widget-${id}`; glyphMarginDomNode.className = `codicon codicon-${this.type}`; - this.glyphMarginWidget = new MonacoEditorGlyphMarginWidget(editor, id, glyphMarginDomNode, lineNumber, GlyphMarginLane.Center); + this.glyphMarginWidget = new MonacoEditorGlyphMarginWidget(editor, id, glyphMarginDomNode, lineNumber, monaco.editor.GlyphMarginLane.Center); this.setupListeners(); } @@ -54,7 +47,7 @@ export class MonacoEditorBuildAnnotation extends MonacoCodeEditorElement { * Returns an object (a delta decoration) detailing the position and styling of the annotation. * @private */ - private getAssociatedDeltaDecoration(): ModelDeltaDecoration { + private getAssociatedDeltaDecoration(): monaco.editor.IModelDeltaDecoration { const marginClassName = this.outdated ? 'monaco-annotation-outdated' : `monaco-annotation-${this.type}`; const lineNumber = this.getLineNumber(); return { @@ -62,7 +55,7 @@ export class MonacoEditorBuildAnnotation extends MonacoCodeEditorElement { options: { marginClassName, isWholeLine: true, - stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges, + stickiness: monaco.editor.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges, lineNumberHoverMessage: { value: this.hoverMessage }, glyphMarginHoverMessage: { value: this.hoverMessage }, }, diff --git a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-glyph-margin-widget.model.ts b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-glyph-margin-widget.model.ts index 719ddd90392e..a787fcbf997e 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-glyph-margin-widget.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-glyph-margin-widget.model.ts @@ -1,14 +1,15 @@ import { MonacoCodeEditorElement } from 'app/shared/monaco-editor/model/monaco-code-editor-element.model'; -import { GlyphMarginLane, GlyphMarginPosition, GlyphMarginWidget, MonacoEditorWithActions, makeEditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { makeEditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import * as monaco from 'monaco-editor'; /** * Class representing a glyph margin widget in the Monaco editor. * Glyph margin widgets refer to one line and can contain arbitrary DOM nodes. */ -export class MonacoEditorGlyphMarginWidget extends MonacoCodeEditorElement implements GlyphMarginWidget { +export class MonacoEditorGlyphMarginWidget extends MonacoCodeEditorElement implements monaco.editor.IGlyphMarginWidget { private readonly domNode: HTMLElement; private lineNumber: number; - private readonly lane: GlyphMarginLane; + private readonly lane: monaco.editor.GlyphMarginLane; /** * @param editor The editor to render this widget in. @@ -17,7 +18,7 @@ export class MonacoEditorGlyphMarginWidget extends MonacoCodeEditorElement imple * @param lineNumber The line to render this widget in. * @param lane The lane (left, center, or right) to render the widget in. */ - constructor(editor: MonacoEditorWithActions, id: string, domNode: HTMLElement, lineNumber: number, lane: GlyphMarginLane) { + constructor(editor: monaco.editor.IStandaloneCodeEditor, id: string, domNode: HTMLElement, lineNumber: number, lane: monaco.editor.GlyphMarginLane) { super(editor, id); this.domNode = domNode; this.lineNumber = lineNumber; @@ -28,7 +29,7 @@ export class MonacoEditorGlyphMarginWidget extends MonacoCodeEditorElement imple return this.domNode; } - getPosition(): GlyphMarginPosition { + getPosition(): monaco.editor.IGlyphMarginWidgetPosition { return { lane: this.lane, zIndex: 10, diff --git a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-inline-widget.model.ts b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-inline-widget.model.ts index 9b703446cf94..3377e4d924fc 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-inline-widget.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-inline-widget.model.ts @@ -1,7 +1,7 @@ import { MonacoCodeEditorElement } from 'app/shared/monaco-editor/model/monaco-code-editor-element.model'; import { MonacoEditorViewZone } from 'app/shared/monaco-editor/model/monaco-editor-view-zone.model'; import { MonacoEditorOverlayWidget } from 'app/shared/monaco-editor/model/monaco-editor-overlay-widget.model'; -import { MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import * as monaco from 'monaco-editor'; /** * Class representing a line widget. @@ -20,7 +20,7 @@ export class MonacoEditorLineWidget extends MonacoCodeEditorElement { * @param contentDomNode The content to render. * @param afterLineNumber The line after which this line widget should be rendered. */ - constructor(editor: MonacoEditorWithActions, overlayWidgetId: string, contentDomNode: HTMLElement, afterLineNumber: number) { + constructor(editor: monaco.editor.IStandaloneCodeEditor, overlayWidgetId: string, contentDomNode: HTMLElement, afterLineNumber: number) { super(editor, overlayWidgetId); this.overlayWidget = new MonacoEditorOverlayWidget( editor, diff --git a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-line-decorations-hover-button.model.ts b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-line-decorations-hover-button.model.ts index f743656c1c65..a3bbd8340247 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-line-decorations-hover-button.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-line-decorations-hover-button.model.ts @@ -1,12 +1,6 @@ import { MonacoCodeEditorElement } from 'app/shared/monaco-editor/model/monaco-code-editor-element.model'; -import { - Disposable, - EditorDecorationsCollection, - EditorMouseEvent, - ModelDeltaDecoration, - MonacoEditorWithActions, - makeEditorRange, -} from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { Disposable, makeEditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import * as monaco from 'monaco-editor'; /** * Class representing a hover button that is displayed on a specific line in the editor. @@ -15,7 +9,7 @@ import { export class MonacoEditorLineDecorationsHoverButton extends MonacoCodeEditorElement { private clickCallback: (lineNumber: number) => void; private currentLineNumber = 1; - private decorationsCollection: EditorDecorationsCollection; + private decorationsCollection: monaco.editor.IEditorDecorationsCollection; private readonly className: string; private mouseMoveListener?: Disposable; @@ -28,7 +22,7 @@ export class MonacoEditorLineDecorationsHoverButton extends MonacoCodeEditorElem * @param className The class name of the button. This is used to uniquely identify the button in the editor. * @param clickCallback The callback to be called when the button is clicked. The line number of the button is passed as an argument. */ - constructor(editor: MonacoEditorWithActions, id: string, className: string, clickCallback: (lineNumber: number) => void) { + constructor(editor: monaco.editor.IStandaloneCodeEditor, id: string, className: string, clickCallback: (lineNumber: number) => void) { super(editor, id); this.clickCallback = clickCallback; this.className = className; @@ -40,7 +34,7 @@ export class MonacoEditorLineDecorationsHoverButton extends MonacoCodeEditorElem protected setupListeners() { super.setupListeners(); - this.mouseMoveListener = this.editor.onMouseMove((editorMouseEvent: EditorMouseEvent) => { + this.mouseMoveListener = this.editor.onMouseMove((editorMouseEvent: monaco.editor.IEditorMouseEvent) => { // This is undefined e.g. when hovering over a line widget. const lineNumber = editorMouseEvent.target?.position?.lineNumber; this.moveAndUpdate(lineNumber); @@ -57,7 +51,7 @@ export class MonacoEditorLineDecorationsHoverButton extends MonacoCodeEditorElem * Checks if the button was clicked and calls the click callback with the line number as an argument. * @param editorMouseEvent The mouse event to react to. */ - onClick(editorMouseEvent: EditorMouseEvent): void { + onClick(editorMouseEvent: monaco.editor.IEditorMouseEvent): void { const lineNumber = editorMouseEvent.target?.position?.lineNumber; // We identify the button via the class name of the element. if (lineNumber && editorMouseEvent.target?.element?.classList?.contains(this.className)) { @@ -90,7 +84,7 @@ export class MonacoEditorLineDecorationsHoverButton extends MonacoCodeEditorElem this.decorationsCollection.set([this.getAssociatedDeltaDecoration()]); } - private getAssociatedDeltaDecoration(): ModelDeltaDecoration { + private getAssociatedDeltaDecoration(): monaco.editor.IModelDeltaDecoration { return { range: makeEditorRange(this.currentLineNumber, 1, this.currentLineNumber, 1), options: { diff --git a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-line-highlight.model.ts b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-line-highlight.model.ts index f8ca8ed7999e..39ae4970b4f3 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-line-highlight.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-line-highlight.model.ts @@ -1,22 +1,16 @@ import { MonacoCodeEditorElement } from 'app/shared/monaco-editor/model/monaco-code-editor-element.model'; -import { - EditorDecorationsCollection, - EditorRange, - ModelDeltaDecoration, - MonacoEditorWithActions, - TrackedRangeStickiness, - makeEditorRange, -} from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { makeEditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import * as monaco from 'monaco-editor'; /** * Class representing a highlighted range of lines in the Monaco editor. * The highlighted lines can have separate styles for the margin and the line. */ export class MonacoEditorLineHighlight extends MonacoCodeEditorElement { - private range: EditorRange; + private range: monaco.IRange; private className?: string; private marginClassName?: string; - private decorationsCollection: EditorDecorationsCollection; + private decorationsCollection: monaco.editor.IEditorDecorationsCollection; /** * @param editor The editor to highlight lines in. @@ -26,7 +20,7 @@ export class MonacoEditorLineHighlight extends MonacoCodeEditorElement { * @param className The class name to use for highlighting the line. If left out, no class will be applied. * @param marginClassName The class name to use for highlighting the margin. If left out, no class will be applied. */ - constructor(editor: MonacoEditorWithActions, id: string, startLine: number, endLine: number, className?: string, marginClassName?: string) { + constructor(editor: monaco.editor.IStandaloneCodeEditor, id: string, startLine: number, endLine: number, className?: string, marginClassName?: string) { super(editor, id); this.range = makeEditorRange(startLine, 0, endLine, 0); this.className = className; @@ -34,14 +28,14 @@ export class MonacoEditorLineHighlight extends MonacoCodeEditorElement { this.decorationsCollection = editor.createDecorationsCollection([]); } - private getAssociatedDeltaDecoration(): ModelDeltaDecoration { + private getAssociatedDeltaDecoration(): monaco.editor.IModelDeltaDecoration { return { range: this.range, options: { marginClassName: this.marginClassName, className: this.className, isWholeLine: true, - stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges, + stickiness: monaco.editor.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges, }, }; } diff --git a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-overlay-widget.model.ts b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-overlay-widget.model.ts index f6146a3deee3..3e49e82e66df 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-overlay-widget.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-overlay-widget.model.ts @@ -1,10 +1,13 @@ import { MonacoCodeEditorElement } from 'app/shared/monaco-editor/model/monaco-code-editor-element.model'; -import { MonacoEditorWithActions, OverlayWidget, OverlayWidgetPosition } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import * as monaco from 'monaco-editor'; + +// null is used by the Monaco api +type OverlayWidgetPosition = monaco.editor.IOverlayWidgetPosition | null; /** * Class representing an overlay widget floating above the editor content. */ -export class MonacoEditorOverlayWidget extends MonacoCodeEditorElement implements OverlayWidget { +export class MonacoEditorOverlayWidget extends MonacoCodeEditorElement implements monaco.editor.IOverlayWidget { private readonly domNode: HTMLElement; private readonly position: OverlayWidgetPosition; @@ -14,7 +17,7 @@ export class MonacoEditorOverlayWidget extends MonacoCodeEditorElement implement * @param domNode The content to render. The user will be able to interact with the widget. * @param position The position of the widget or null if the element is positioned by another element (e.g. a view zone). */ - constructor(editor: MonacoEditorWithActions, id: string, domNode: HTMLElement, position: OverlayWidgetPosition) { + constructor(editor: monaco.editor.IStandaloneCodeEditor, id: string, domNode: HTMLElement, position: OverlayWidgetPosition) { super(editor, id); this.domNode = domNode; // Ensure that the widget reaches its maximum width. diff --git a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-view-zone.model.ts b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-view-zone.model.ts index e7d6ab8fdbd1..a17454e92588 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-view-zone.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/monaco-editor-view-zone.model.ts @@ -1,10 +1,10 @@ import { MonacoCodeEditorElement } from 'app/shared/monaco-editor/model/monaco-code-editor-element.model'; -import { MonacoEditorWithActions, ViewZone } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import * as monaco from 'monaco-editor'; /** * Class representing a view zone (i.e., vertical space after a certain line) in the Monaco editor. */ -export class MonacoEditorViewZone extends MonacoCodeEditorElement implements ViewZone { +export class MonacoEditorViewZone extends MonacoCodeEditorElement implements monaco.editor.IViewZone { private linkedContentDomNode: HTMLElement; private resizeObserver: ResizeObserver; @@ -22,7 +22,7 @@ export class MonacoEditorViewZone extends MonacoCodeEditorElement implements Vie * @param linkedContentDomNode The content to which this view zone should be linked. When the linked content * resizes, so does this view zone. Note that the content must be rendered elsewhere, e.g. in an {@link MonacoEditorOverlayWidget}. */ - constructor(editor: MonacoEditorWithActions, afterLineNumber: number, linkedContentDomNode: HTMLElement) { + constructor(editor: monaco.editor.IStandaloneCodeEditor, afterLineNumber: number, linkedContentDomNode: HTMLElement) { // id is unavailable until the view zone is added to the editor. super(editor, undefined); this.afterLineNumber = afterLineNumber; diff --git a/src/main/webapp/app/shared/monaco-editor/monaco-diff-editor.component.ts b/src/main/webapp/app/shared/monaco-editor/monaco-diff-editor.component.ts index 1cfa742651d4..dd5b624d6554 100644 --- a/src/main/webapp/app/shared/monaco-editor/monaco-diff-editor.component.ts +++ b/src/main/webapp/app/shared/monaco-editor/monaco-diff-editor.component.ts @@ -3,7 +3,7 @@ import { Theme, ThemeService } from 'app/core/theme/theme.service'; import * as monaco from 'monaco-editor'; import { Subscription } from 'rxjs'; -import { Disposable, MonacoEditorWithActions } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; +import { Disposable } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; export type MonacoEditorDiffText = { original: string; modified: string }; @Component({ @@ -186,7 +186,7 @@ export class MonacoDiffEditorComponent implements OnInit, OnDestroy { * Returns the content height of the provided editor. * @param editor The editor whose content height should be retrieved. */ - getContentHeightOfEditor(editor: MonacoEditorWithActions): number { + getContentHeightOfEditor(editor: monaco.editor.IStandaloneCodeEditor): number { return editor.getContentHeight(); } From 726db040f4ec91484fccc82ffe4c68437e081ed6 Mon Sep 17 00:00:00 2001 From: Patrik Zander Date: Sat, 31 Aug 2024 13:59:24 +0200 Subject: [PATCH 18/27] Add Model for keybindings --- .../adapter/monaco-text-editor.adapter.ts | 17 +++++++++++- .../adapter/text-editor-keybinding.model.ts | 27 +++++++++++++++++++ .../model/actions/monaco-bold.action.ts | 4 +-- .../actions/monaco-editor-action.model.ts | 5 ++-- .../model/actions/monaco-italic.action.ts | 6 +++-- .../model/actions/monaco-underline.action.ts | 6 +++-- 6 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-keybinding.model.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts index 2486c089aa2f..f0239f619e49 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts @@ -6,15 +6,24 @@ import { TextEditorCompleter } from 'app/shared/monaco-editor/model/actions/adap import { TextEditorRange, makeTextEditorRange } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-range.model'; import { TextEditorPosition } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-position.model'; import { TextEditorCompletionItemKind } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-completion-item.model'; +import { TextEditorKeyCode, TextEditorKeyModifier, TextEditorKeybinding } from './text-editor-keybinding.model'; export class MonacoTextEditorAdapter implements TextEditor { + private static readonly KEY_CODE_MAP = new Map([ + [TextEditorKeyCode.KeyB, monaco.KeyCode.KeyB], + [TextEditorKeyCode.KeyI, monaco.KeyCode.KeyI], + [TextEditorKeyCode.KeyU, monaco.KeyCode.KeyU], + ]); + + private static readonly MODIFIER_MAP = new Map([[TextEditorKeyModifier.CtrlCmd, monaco.KeyMod.CtrlCmd]]); + constructor(private editor: monaco.editor.IStandaloneCodeEditor) {} addAction(action: MonacoEditorAction): Disposable { const actionDescriptor: monaco.editor.IActionDescriptor = { id: action.id, label: action.label, - keybindings: action.keybindings, + keybindings: action.keybindings?.map(this.toMonacoKeybinding), run: (_, args) => { action.run(this, args); }, @@ -207,4 +216,10 @@ export class MonacoTextEditorAdapter implements TextEditor { return monaco.languages.CompletionItemKind.Constant; } } + + private toMonacoKeybinding(keybinding: TextEditorKeybinding): number { + const keyCode = MonacoTextEditorAdapter.KEY_CODE_MAP.get(keybinding.getKey()) ?? monaco.KeyCode.Unknown; + const modifier = MonacoTextEditorAdapter.MODIFIER_MAP.get(keybinding.getModifier()) ?? 0; + return keyCode | modifier; + } } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-keybinding.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-keybinding.model.ts new file mode 100644 index 000000000000..59b4431f2d63 --- /dev/null +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-keybinding.model.ts @@ -0,0 +1,27 @@ +export enum TextEditorKeyCode { + KeyB, + KeyI, + KeyU, +} + +export enum TextEditorKeyModifier { + /** + * The Ctrl key on Windows and Linux, and the Cmd key on macOS. + */ + CtrlCmd, +} + +export class TextEditorKeybinding { + constructor( + private readonly key: TextEditorKeyCode, + private readonly modifier: TextEditorKeyModifier, + ) {} + + getKey(): TextEditorKeyCode { + return this.key; + } + + getModifier(): TextEditorKeyModifier { + return this.modifier; + } +} diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-bold.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-bold.action.ts index 1ada4ab2b86e..d3290e65fdb1 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-bold.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-bold.action.ts @@ -1,7 +1,7 @@ import { faBold } from '@fortawesome/free-solid-svg-icons'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; -import { KeyCode, KeyModifier } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; +import { TextEditorKeyCode, TextEditorKeyModifier, TextEditorKeybinding } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-keybinding.model'; const BOLD_DELIMITER = '**'; @@ -12,7 +12,7 @@ export class MonacoBoldAction extends MonacoEditorAction { static readonly ID = 'monaco-bold.action'; constructor() { - super(MonacoBoldAction.ID, 'artemisApp.multipleChoiceQuestion.editor.bold', faBold, [KeyModifier.CtrlCmd | KeyCode.KeyB]); + super(MonacoBoldAction.ID, 'artemisApp.multipleChoiceQuestion.editor.bold', faBold, [new TextEditorKeybinding(TextEditorKeyCode.KeyB, TextEditorKeyModifier.CtrlCmd)]); } /** diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts index b42496343c94..0941c2815eec 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts @@ -7,12 +7,13 @@ import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text- import { TextEditorRange } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-range.model'; import { TextEditorPosition } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-position.model'; import { TextEditorCompletionItem } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-completion-item.model'; +import { TextEditorKeybinding } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-keybinding.model'; export abstract class MonacoEditorAction implements Disposable { id: string; label: string; translationKey: string; - keybindings?: number[]; + keybindings?: TextEditorKeybinding[]; icon?: IconDefinition; readonly hideInEditor: boolean; @@ -34,7 +35,7 @@ export abstract class MonacoEditorAction implements Disposable { * @param keybindings The keybindings to trigger the action, if any. * @param hideInEditor Whether to hide the action in the editor toolbar. Defaults to false. */ - constructor(id: string, translationKey: string, icon?: IconDefinition, keybindings?: number[], hideInEditor?: boolean) { + constructor(id: string, translationKey: string, icon?: IconDefinition, keybindings?: TextEditorKeybinding[], hideInEditor?: boolean) { this.id = id; this.translationKey = translationKey; this.icon = icon; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-italic.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-italic.action.ts index 863826503cca..f121ccafbc57 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-italic.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-italic.action.ts @@ -1,7 +1,7 @@ import { faItalic } from '@fortawesome/free-solid-svg-icons'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; -import { KeyCode, KeyModifier } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; import { TextEditor } from './adapter/text-editor.interface'; +import { TextEditorKeyCode, TextEditorKeyModifier, TextEditorKeybinding } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-keybinding.model'; const ITALIC_DELIMITER = '*'; @@ -11,7 +11,9 @@ const ITALIC_DELIMITER = '*'; export class MonacoItalicAction extends MonacoEditorAction { static readonly ID = 'monaco-italic.action'; constructor() { - super(MonacoItalicAction.ID, 'artemisApp.multipleChoiceQuestion.editor.italic', faItalic, [KeyModifier.CtrlCmd | KeyCode.KeyI]); + super(MonacoItalicAction.ID, 'artemisApp.multipleChoiceQuestion.editor.italic', faItalic, [ + new TextEditorKeybinding(TextEditorKeyCode.KeyI, TextEditorKeyModifier.CtrlCmd), + ]); } /** diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-underline.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-underline.action.ts index ac62d1db136f..9136b9911dae 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-underline.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-underline.action.ts @@ -1,7 +1,7 @@ import { faUnderline } from '@fortawesome/free-solid-svg-icons'; import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; -import { KeyCode, KeyModifier } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; +import { TextEditorKeyCode, TextEditorKeyModifier, TextEditorKeybinding } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-keybinding.model'; const UNDERLINE_OPEN_DELIMITER = ''; const UNDERLINE_CLOSE_DELIMITER = ''; @@ -12,7 +12,9 @@ const UNDERLINE_CLOSE_DELIMITER = ''; export class MonacoUnderlineAction extends MonacoEditorAction { static readonly ID = 'monaco-underline.action'; constructor() { - super(MonacoUnderlineAction.ID, 'artemisApp.multipleChoiceQuestion.editor.underline', faUnderline, [KeyModifier.CtrlCmd | KeyCode.KeyU]); + super(MonacoUnderlineAction.ID, 'artemisApp.multipleChoiceQuestion.editor.underline', faUnderline, [ + new TextEditorKeybinding(TextEditorKeyCode.KeyU, TextEditorKeyModifier.CtrlCmd), + ]); } /** From 49f11682eb7fe5d85f2510ed979c9e1eab26d1a3 Mon Sep 17 00:00:00 2001 From: Patrik Zander Date: Sat, 31 Aug 2024 16:14:13 +0200 Subject: [PATCH 19/27] Delete text-editor-model.model.ts --- .../model/actions/adapter/text-editor-model.model.ts | 1 - 1 file changed, 1 deletion(-) delete mode 100644 src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-model.model.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-model.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-model.model.ts deleted file mode 100644 index 153e9cb29760..000000000000 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor-model.model.ts +++ /dev/null @@ -1 +0,0 @@ -export class TextEditorModel {} From 249e6b207bd32f5298d478d16c0159018533e838 Mon Sep 17 00:00:00 2001 From: Patrik Zander Date: Sat, 31 Aug 2024 19:43:48 +0200 Subject: [PATCH 20/27] Remove unused monaco import --- .../monaco-editor/model/actions/monaco-editor-action.model.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts index 0941c2815eec..ba57899f966a 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts @@ -1,6 +1,5 @@ import { IconDefinition } from '@fortawesome/fontawesome-svg-core'; import { TranslateService } from '@ngx-translate/core'; -import * as monaco from 'monaco-editor'; import { enterFullscreen, exitFullscreen, isFullScreen } from 'app/shared/util/fullscreen.util'; import { Disposable } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; @@ -101,7 +100,7 @@ export abstract class MonacoEditorAction implements Disposable { mapToCompletionItemFn: (item: ItemType, range: TextEditorRange) => TextEditorCompletionItem, triggerCharacter?: string, listIncomplete?: boolean, - ): monaco.IDisposable { + ): Disposable { return editor.addCompleter({ triggerCharacter, incomplete: listIncomplete ?? false, From 2606f9aa892ee06a03d7cc34dae71c8e2100af19 Mon Sep 17 00:00:00 2001 From: Patrik Zander Date: Sat, 31 Aug 2024 19:49:10 +0200 Subject: [PATCH 21/27] Remove resolved TODO --- .../markdown-editor/monaco/markdown-editor-monaco.component.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/webapp/app/shared/markdown-editor/monaco/markdown-editor-monaco.component.ts b/src/main/webapp/app/shared/markdown-editor/monaco/markdown-editor-monaco.component.ts index 7f9fe5ee75d4..753d788fa2f7 100644 --- a/src/main/webapp/app/shared/markdown-editor/monaco/markdown-editor-monaco.component.ts +++ b/src/main/webapp/app/shared/markdown-editor/monaco/markdown-editor-monaco.component.ts @@ -79,7 +79,6 @@ const EXTERNAL_HEIGHT = 'external'; const BORDER_WIDTH_OFFSET = 3; const BORDER_HEIGHT_OFFSET = 2; -// TODO: Once the old markdown editor is gone, remove the style url. @Component({ selector: 'jhi-markdown-editor-monaco', templateUrl: './markdown-editor-monaco.component.html', From 81bf417f988c94bf10590deb4b8f8af329fadfab Mon Sep 17 00:00:00 2001 From: Patrik Zander Date: Sat, 31 Aug 2024 20:14:21 +0200 Subject: [PATCH 22/27] MonacoEditorAction -> TextEditorAction --- .../short-answer-question-edit.component.ts | 4 ++-- .../monaco/markdown-editor-monaco.component.ts | 14 +++++++------- .../posting-markdown-editor.component.ts | 4 ++-- .../actions/adapter/monaco-text-editor.adapter.ts | 6 +++--- .../model/actions/adapter/text-editor.interface.ts | 6 +++--- .../monaco-channel-reference.action.ts | 4 ++-- .../monaco-lecture-attachment-reference.action.ts | 4 ++-- .../communication/monaco-user-mention.action.ts | 4 ++-- .../model/actions/monaco-attachment.action.ts | 4 ++-- .../model/actions/monaco-bold.action.ts | 4 ++-- .../model/actions/monaco-code-block.action.ts | 4 ++-- .../model/actions/monaco-code.action.ts | 4 ++-- .../model/actions/monaco-color.action.ts | 4 ++-- .../actions/monaco-editor-action-group.model.ts | 4 ++-- .../actions/monaco-editor-domain-action.model.ts | 4 ++-- .../model/actions/monaco-fullscreen.action.ts | 4 ++-- .../model/actions/monaco-heading.action.ts | 4 ++-- .../model/actions/monaco-italic.action.ts | 4 ++-- .../model/actions/monaco-ordered-list.action.ts | 4 ++-- .../model/actions/monaco-quote.action.ts | 4 ++-- .../model/actions/monaco-underline.action.ts | 4 ++-- .../model/actions/monaco-unordered-list.action.ts | 4 ++-- .../model/actions/monaco-url.action.ts | 4 ++-- .../monaco-insert-short-answer-option.action.ts | 4 ++-- .../quiz/monaco-insert-short-answer-spot.action.ts | 4 ++-- ...action.model.ts => text-editor-action.model.ts} | 2 +- .../monaco-editor/monaco-editor.component.ts | 6 +++--- .../monaco-editor-action.integration.spec.ts | 6 +++--- ...editor-communication-action.integration.spec.ts | 4 ++-- 29 files changed, 66 insertions(+), 66 deletions(-) rename src/main/webapp/app/shared/monaco-editor/model/actions/{monaco-editor-action.model.ts => text-editor-action.model.ts} (99%) diff --git a/src/main/webapp/app/exercises/quiz/manage/short-answer-question/short-answer-question-edit.component.ts b/src/main/webapp/app/exercises/quiz/manage/short-answer-question/short-answer-question-edit.component.ts index 86264112bb2d..9088d72f48fa 100644 --- a/src/main/webapp/app/exercises/quiz/manage/short-answer-question/short-answer-question-edit.component.ts +++ b/src/main/webapp/app/exercises/quiz/manage/short-answer-question/short-answer-question-edit.component.ts @@ -34,7 +34,7 @@ import { MonacoUrlAction } from 'app/shared/monaco-editor/model/actions/monaco-u import { MonacoUnorderedListAction } from 'app/shared/monaco-editor/model/actions/monaco-unordered-list.action'; import { MonacoOrderedListAction } from 'app/shared/monaco-editor/model/actions/monaco-ordered-list.action'; import { MonacoInsertShortAnswerSpotAction } from 'app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-spot.action'; -import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; import { MonacoInsertShortAnswerOptionAction } from 'app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-option.action'; import { SHORT_ANSWER_QUIZ_QUESTION_EDITOR_OPTIONS } from 'app/shared/monaco-editor/monaco-editor-option.helper'; @@ -52,7 +52,7 @@ export class ShortAnswerQuestionEditComponent implements OnInit, OnChanges, Afte @ViewChild('question', { static: false }) questionElement: ElementRef; - markdownActions: MonacoEditorAction[]; + markdownActions: TextEditorAction[]; insertShortAnswerOptionAction = new MonacoInsertShortAnswerOptionAction(); insertShortAnswerSpotAction = new MonacoInsertShortAnswerSpotAction(this.insertShortAnswerOptionAction); diff --git a/src/main/webapp/app/shared/markdown-editor/monaco/markdown-editor-monaco.component.ts b/src/main/webapp/app/shared/markdown-editor/monaco/markdown-editor-monaco.component.ts index 753d788fa2f7..d5f50ac5023f 100644 --- a/src/main/webapp/app/shared/markdown-editor/monaco/markdown-editor-monaco.component.ts +++ b/src/main/webapp/app/shared/markdown-editor/monaco/markdown-editor-monaco.component.ts @@ -14,7 +14,7 @@ import { } from '@angular/core'; import { MonacoEditorComponent } from 'app/shared/monaco-editor/monaco-editor.component'; import { NgbNavChangeEvent } from '@ng-bootstrap/ng-bootstrap'; -import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; import { MonacoBoldAction } from 'app/shared/monaco-editor/model/actions/monaco-bold.action'; import { MonacoItalicAction } from 'app/shared/monaco-editor/model/actions/monaco-italic.action'; import { MonacoUnderlineAction } from 'app/shared/monaco-editor/model/actions/monaco-underline.action'; @@ -55,7 +55,7 @@ export enum MarkdownEditorHeight { } interface MarkdownActionsByGroup { - standard: MonacoEditorAction[]; + standard: TextEditorAction[]; header: MonacoHeadingAction[]; color?: MonacoColorAction; domain: { @@ -64,7 +64,7 @@ interface MarkdownActionsByGroup { }; // Special case due to the complex structure of lectures, attachments, and their slides lecture?: MonacoLectureAttachmentReferenceAction; - meta: MonacoEditorAction[]; + meta: TextEditorAction[]; } export type TextWithDomainAction = { text: string; action?: MonacoEditorDomainAction }; @@ -143,7 +143,7 @@ export class MarkdownEditorMonacoComponent implements AfterContentInit, AfterVie resizableMinHeight = MarkdownEditorHeight.SMALL; @Input() - defaultActions: MonacoEditorAction[] = [ + defaultActions: TextEditorAction[] = [ new MonacoBoldAction(), new MonacoItalicAction(), new MonacoUnderlineAction(), @@ -173,7 +173,7 @@ export class MarkdownEditorMonacoComponent implements AfterContentInit, AfterVie domainActions: MonacoEditorDomainAction[] = []; @Input() - metaActions: MonacoEditorAction[] = [new MonacoFullscreenAction()]; + metaActions: TextEditorAction[] = [new MonacoFullscreenAction()]; @Output() markdownChange = new EventEmitter(); @@ -271,11 +271,11 @@ export class MarkdownEditorMonacoComponent implements AfterContentInit, AfterVie }; } - filterDisplayedActions(actions: T[]): T[] { + filterDisplayedActions(actions: T[]): T[] { return actions.filter((action) => !action.hideInEditor); } - filterDisplayedAction(action?: T): T | undefined { + filterDisplayedAction(action?: T): T | undefined { return action?.hideInEditor ? undefined : action; } diff --git a/src/main/webapp/app/shared/metis/posting-markdown-editor/posting-markdown-editor.component.ts b/src/main/webapp/app/shared/metis/posting-markdown-editor/posting-markdown-editor.component.ts index 567846a81e3b..a5d4bcf280b4 100644 --- a/src/main/webapp/app/shared/metis/posting-markdown-editor/posting-markdown-editor.component.ts +++ b/src/main/webapp/app/shared/metis/posting-markdown-editor/posting-markdown-editor.component.ts @@ -18,7 +18,7 @@ import { LectureService } from 'app/lecture/lecture.service'; import { CourseManagementService } from 'app/course/manage/course-management.service'; import { ChannelService } from 'app/shared/metis/conversations/channel.service'; import { isCommunicationEnabled } from 'app/entities/course.model'; -import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; import { MonacoBoldAction } from 'app/shared/monaco-editor/model/actions/monaco-bold.action'; import { MonacoItalicAction } from 'app/shared/monaco-editor/model/actions/monaco-italic.action'; import { MonacoUnderlineAction } from 'app/shared/monaco-editor/model/actions/monaco-underline.action'; @@ -53,7 +53,7 @@ export class PostingMarkdownEditorComponent implements OnInit, ControlValueAcces @Input() suppressNewlineOnEnter = true; @Output() valueChange = new EventEmitter(); lectureAttachmentReferenceAction: MonacoLectureAttachmentReferenceAction; - defaultActions: MonacoEditorAction[]; + defaultActions: TextEditorAction[]; content?: string; previewMode = false; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts index f0239f619e49..316f6c1b79b2 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts @@ -1,5 +1,5 @@ import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; -import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; import { Disposable, EditorPosition, MonacoEditorTextModel, makeEditorRange } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; import * as monaco from 'monaco-editor'; import { TextEditorCompleter } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-completer.model'; @@ -19,7 +19,7 @@ export class MonacoTextEditorAdapter implements TextEditor { constructor(private editor: monaco.editor.IStandaloneCodeEditor) {} - addAction(action: MonacoEditorAction): Disposable { + addAction(action: TextEditorAction): Disposable { const actionDescriptor: monaco.editor.IActionDescriptor = { id: action.id, label: action.label, @@ -31,7 +31,7 @@ export class MonacoTextEditorAdapter implements TextEditor { return this.editor.addAction(actionDescriptor); } - executeAction(action: MonacoEditorAction, args?: object): void { + executeAction(action: TextEditorAction, args?: object): void { this.editor.trigger('MonacoTextEditorAdapter::executeAction', action.id, args); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor.interface.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor.interface.ts index dfd4c67f5838..b3403c274b64 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor.interface.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor.interface.ts @@ -1,4 +1,4 @@ -import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; import { Disposable } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; import { TextEditorPosition } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-position.model'; import { TextEditorRange } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-range.model'; @@ -10,14 +10,14 @@ export interface TextEditor { * @param action The action to add to the editor. * @return A disposable that can be used to remove the action from the editor. */ - addAction(action: MonacoEditorAction): Disposable; + addAction(action: TextEditorAction): Disposable; /** * Executes the given action in the editor. It must be an action that has been added to the editor. * @param action The action to execute. * @param args Optional arguments to pass to the action. */ - executeAction(action: MonacoEditorAction, args?: object): void; + executeAction(action: TextEditorAction, args?: object): void; /** * Layouts the editor's content and dimensions, e.g. after a resize. diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts index e071d872f8c3..cdc08f485973 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts @@ -1,6 +1,6 @@ import { faHashtag } from '@fortawesome/free-solid-svg-icons'; import { TranslateService } from '@ngx-translate/core'; -import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; import { ChannelIdAndNameDTO } from 'app/entities/metis/conversation/channel.model'; import { MetisService } from 'app/shared/metis/metis.service'; import { ChannelService } from 'app/shared/metis/conversations/channel.service'; @@ -13,7 +13,7 @@ import { TextEditorCompletionItem, TextEditorCompletionItemKind } from 'app/shar /** * Action to insert a reference to a channel into the editor. Users that type a # will see a list of available channels to reference. */ -export class MonacoChannelReferenceAction extends MonacoEditorAction { +export class MonacoChannelReferenceAction extends TextEditorAction { static readonly ID = 'monaco-channel-reference.action'; static readonly DEFAULT_INSERT_TEXT = '#'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-lecture-attachment-reference.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-lecture-attachment-reference.action.ts index 4e0521f39197..8fcfcabae422 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-lecture-attachment-reference.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-lecture-attachment-reference.action.ts @@ -1,4 +1,4 @@ -import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; import { MetisService } from 'app/shared/metis/metis.service'; import { firstValueFrom } from 'rxjs'; import { LectureService } from 'app/lecture/lecture.service'; @@ -28,7 +28,7 @@ interface LectureAttachmentReferenceActionArgs { * Action to insert a reference to a lecture, attachment, slide, or attachment unit into the editor. * The specific format of the reference depends on the type of reference. */ -export class MonacoLectureAttachmentReferenceAction extends MonacoEditorAction { +export class MonacoLectureAttachmentReferenceAction extends TextEditorAction { static readonly ID = 'monaco-lecture-attachment-reference.action'; lecturesWithDetails: LectureWithDetails[] = []; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts index 10e32212f9b3..66e26840bfa4 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts @@ -1,6 +1,6 @@ import { faAt } from '@fortawesome/free-solid-svg-icons'; import { TranslateService } from '@ngx-translate/core'; -import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; import { CourseManagementService } from 'app/course/manage/course-management.service'; import { MetisService } from 'app/shared/metis/metis.service'; import { firstValueFrom } from 'rxjs'; @@ -14,7 +14,7 @@ import { TextEditorCompletionItem, TextEditorCompletionItemKind } from 'app/shar * Action to insert a user mention into the editor. Users that type a @ will see a list of available users to mention. * Users will be fetched repeatedly as the user types to provide up-to-date results. */ -export class MonacoUserMentionAction extends MonacoEditorAction { +export class MonacoUserMentionAction extends TextEditorAction { disposableCompletionProvider?: Disposable; static readonly ID = 'monaco-user-mention.action'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-attachment.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-attachment.action.ts index 1053ca210af5..0b8f7b96cb1e 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-attachment.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-attachment.action.ts @@ -1,5 +1,5 @@ import { faImage } from '@fortawesome/free-solid-svg-icons'; -import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; interface AttachmentArguments { @@ -10,7 +10,7 @@ interface AttachmentArguments { /** * Action to insert an attachment into the editor. They follow the format ![text](url). */ -export class MonacoAttachmentAction extends MonacoEditorAction { +export class MonacoAttachmentAction extends TextEditorAction { static readonly ID = 'monaco-attachment.action'; static readonly DEFAULT_INSERT_TEXT = '![](https://)'; constructor() { diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-bold.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-bold.action.ts index d3290e65fdb1..935c1b5f4d1d 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-bold.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-bold.action.ts @@ -1,5 +1,5 @@ import { faBold } from '@fortawesome/free-solid-svg-icons'; -import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; import { TextEditorKeyCode, TextEditorKeyModifier, TextEditorKeybinding } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-keybinding.model'; @@ -8,7 +8,7 @@ const BOLD_DELIMITER = '**'; /** * Action to toggle bold text in the editor. It wraps the selected text with the bold delimiter, e.g. switching between text and **text**. */ -export class MonacoBoldAction extends MonacoEditorAction { +export class MonacoBoldAction extends TextEditorAction { static readonly ID = 'monaco-bold.action'; constructor() { diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code-block.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code-block.action.ts index 75633a5754e8..8c9745caecdb 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code-block.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code-block.action.ts @@ -1,5 +1,5 @@ import { faFileCode } from '@fortawesome/free-solid-svg-icons'; -import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; const CODE_BLOCK_DELIMITER = '```'; @@ -7,7 +7,7 @@ const CODE_BLOCK_DELIMITER = '```'; /** * Action to toggle code block in the editor. It wraps the selected text with the code block delimiters and inserts newlines, e.g. for the default language java, switching between text and ```java\n text \n```. */ -export class MonacoCodeBlockAction extends MonacoEditorAction { +export class MonacoCodeBlockAction extends TextEditorAction { static readonly ID = 'monaco-code-block.action'; constructor(private readonly defaultLanguage?: string) { diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code.action.ts index 0d77197d8e8f..7e74cd979f05 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code.action.ts @@ -1,5 +1,5 @@ import { faCode } from '@fortawesome/free-solid-svg-icons'; -import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; const CODE_DELIMITER = '`'; @@ -7,7 +7,7 @@ const CODE_DELIMITER = '`'; /** * Action to toggle code text in the editor. It wraps the selected text with the code delimiter, e.g. switching between text and `text`. */ -export class MonacoCodeAction extends MonacoEditorAction { +export class MonacoCodeAction extends TextEditorAction { static readonly ID = 'monaco-code.action'; constructor() { super(MonacoCodeAction.ID, 'artemisApp.multipleChoiceQuestion.editor.code', faCode, undefined); diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-color.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-color.action.ts index beed508be135..21df3f944ade 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-color.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-color.action.ts @@ -1,4 +1,4 @@ -import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; interface ColorArguments { @@ -10,7 +10,7 @@ const CLOSE_DELIMITER = ''; /** * Action to toggle color text in the editor. It wraps the selected text with the color delimiter, e.g. switching between text and text. */ -export class MonacoColorAction extends MonacoEditorAction { +export class MonacoColorAction extends TextEditorAction { static readonly ID = 'monaco-color.action'; constructor() { diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action-group.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action-group.model.ts index 247756aabe3a..9d0de36af6f2 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action-group.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action-group.model.ts @@ -1,7 +1,7 @@ import { IconDefinition } from '@fortawesome/fontawesome-svg-core'; -import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; -export class MonacoEditorActionGroup { +export class MonacoEditorActionGroup { translationKey: string; actions: ActionType[]; icon?: IconDefinition; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model.ts index e2d7dd9daaf8..23b466019be5 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model.ts @@ -1,11 +1,11 @@ import { TextEditor } from './adapter/text-editor.interface'; -import { MonacoEditorAction } from './monaco-editor-action.model'; +import { TextEditorAction } from './text-editor-action.model'; import { makeTextEditorRange } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-range.model'; /** * Class representing domain actions for Artemis-specific use cases. */ -export abstract class MonacoEditorDomainAction extends MonacoEditorAction { +export abstract class MonacoEditorDomainAction extends TextEditorAction { abstract getOpeningIdentifier(): string; /** diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-fullscreen.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-fullscreen.action.ts index d75ff5404a29..2fdf51aa1461 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-fullscreen.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-fullscreen.action.ts @@ -1,4 +1,4 @@ -import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; import { faCompress } from '@fortawesome/free-solid-svg-icons'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; @@ -6,7 +6,7 @@ import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text- /** * Action to toggle fullscreen mode in the editor. */ -export class MonacoFullscreenAction extends MonacoEditorAction { +export class MonacoFullscreenAction extends TextEditorAction { static readonly ID = 'monaco-fullscreen.action'; element?: HTMLElement; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-heading.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-heading.action.ts index a1960e35f5f6..0849ecbfbc1b 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-heading.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-heading.action.ts @@ -1,4 +1,4 @@ -import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; import { faHeading } from '@fortawesome/free-solid-svg-icons'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; @@ -13,7 +13,7 @@ const HEADING_TEXT = 'Heading'; /** * Action to toggle heading text in the editor. It wraps the selected text with the heading delimiter, e.g. switching between text and # text for level 1. */ -export class MonacoHeadingAction extends MonacoEditorAction { +export class MonacoHeadingAction extends TextEditorAction { level: number; /** diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-italic.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-italic.action.ts index f121ccafbc57..596476efe93d 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-italic.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-italic.action.ts @@ -1,5 +1,5 @@ import { faItalic } from '@fortawesome/free-solid-svg-icons'; -import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; import { TextEditor } from './adapter/text-editor.interface'; import { TextEditorKeyCode, TextEditorKeyModifier, TextEditorKeybinding } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-keybinding.model'; @@ -8,7 +8,7 @@ const ITALIC_DELIMITER = '*'; /** * Action to toggle italic text in the editor. It wraps the selected text with the italic delimiter, e.g. switching between text and *text*. */ -export class MonacoItalicAction extends MonacoEditorAction { +export class MonacoItalicAction extends TextEditorAction { static readonly ID = 'monaco-italic.action'; constructor() { super(MonacoItalicAction.ID, 'artemisApp.multipleChoiceQuestion.editor.italic', faItalic, [ diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-ordered-list.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-ordered-list.action.ts index 5d56574e74af..8b77bbb2d1eb 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-ordered-list.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-ordered-list.action.ts @@ -1,4 +1,4 @@ -import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; import { faListOl } from '@fortawesome/free-solid-svg-icons'; import { TextEditor } from './adapter/text-editor.interface'; import { TextEditorPosition } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-position.model'; @@ -9,7 +9,7 @@ const NUMBER_REGEX = /^\d+\.\s.*/; /** * Action to toggle unordered list in the editor. It toggles the "1. ", "2. ", ... prefix for the entire selection. */ -export class MonacoOrderedListAction extends MonacoEditorAction { +export class MonacoOrderedListAction extends TextEditorAction { static readonly ID = 'monaco-ordered-list.action'; constructor() { super(MonacoOrderedListAction.ID, 'artemisApp.multipleChoiceQuestion.editor.orderedList', faListOl, undefined); diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-quote.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-quote.action.ts index e5190e8f6608..2c4b3d6464b1 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-quote.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-quote.action.ts @@ -1,5 +1,5 @@ import { faQuoteLeft } from '@fortawesome/free-solid-svg-icons'; -import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; const QUOTE_OPEN_DELIMITER = '> '; @@ -7,7 +7,7 @@ const QUOTE_OPEN_DELIMITER = '> '; /** * Action to toggle quote text in the editor. It wraps the selected text with the quote delimiter, e.g. switching between text and > text. */ -export class MonacoQuoteAction extends MonacoEditorAction { +export class MonacoQuoteAction extends TextEditorAction { static readonly ID = 'monaco-quote.action'; constructor() { super(MonacoQuoteAction.ID, 'artemisApp.multipleChoiceQuestion.editor.quote', faQuoteLeft, undefined); diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-underline.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-underline.action.ts index 9136b9911dae..a402bb3f37a6 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-underline.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-underline.action.ts @@ -1,5 +1,5 @@ import { faUnderline } from '@fortawesome/free-solid-svg-icons'; -import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; import { TextEditorKeyCode, TextEditorKeyModifier, TextEditorKeybinding } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-keybinding.model'; @@ -9,7 +9,7 @@ const UNDERLINE_CLOSE_DELIMITER = ''; /** * Action to toggle underline text in the editor. It wraps the selected text with the underline delimiter, e.g. switching between text and text. */ -export class MonacoUnderlineAction extends MonacoEditorAction { +export class MonacoUnderlineAction extends TextEditorAction { static readonly ID = 'monaco-underline.action'; constructor() { super(MonacoUnderlineAction.ID, 'artemisApp.multipleChoiceQuestion.editor.underline', faUnderline, [ diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-unordered-list.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-unordered-list.action.ts index f7aa8b4945b8..f34550a02891 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-unordered-list.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-unordered-list.action.ts @@ -1,4 +1,4 @@ -import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; import { faListUl } from '@fortawesome/free-solid-svg-icons'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; import { TextEditorPosition } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-position.model'; @@ -9,7 +9,7 @@ const LIST_BULLET = '- '; /** * Action to toggle unordered list in the editor. It toggles the "- " prefix for the entire selection. */ -export class MonacoUnorderedListAction extends MonacoEditorAction { +export class MonacoUnorderedListAction extends TextEditorAction { static readonly ID = 'monaco-unordered-list.action'; constructor() { super(MonacoUnorderedListAction.ID, 'artemisApp.multipleChoiceQuestion.editor.unorderedList', faListUl, undefined); diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-url.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-url.action.ts index 1650bedc20a5..6f66d3bcd0b5 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-url.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-url.action.ts @@ -1,5 +1,5 @@ import { faLink } from '@fortawesome/free-solid-svg-icons'; -import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; interface UrlArguments { @@ -10,7 +10,7 @@ interface UrlArguments { /** * Action to insert a URL into the editor. They follow the format [text](url). */ -export class MonacoUrlAction extends MonacoEditorAction { +export class MonacoUrlAction extends TextEditorAction { static readonly ID = 'monaco-url.action'; static readonly DEFAULT_INSERT_TEXT = '[](https://)'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-option.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-option.action.ts index 5f3311c185f6..4716143c6894 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-option.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-option.action.ts @@ -1,4 +1,4 @@ -import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; import { makeTextEditorRange } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-range.model'; @@ -10,7 +10,7 @@ interface InsertShortAnswerOptionArgs { /** * Action to insert a short answer option ([-option #] Option text) at the end of the editor. */ -export class MonacoInsertShortAnswerOptionAction extends MonacoEditorAction { +export class MonacoInsertShortAnswerOptionAction extends TextEditorAction { static readonly ID = 'monaco-insert-short-answer-option.action'; static readonly DEFAULT_TEXT = 'Enter an answer option here and ensure the spot number is correct.'; static readonly DEFAULT_TEXT_SHORT = 'Enter an answer option here.'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-spot.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-spot.action.ts index dcdd53a09115..895da9478dcc 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-spot.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-spot.action.ts @@ -1,4 +1,4 @@ -import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; import { MonacoInsertShortAnswerOptionAction } from 'app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-option.action'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; @@ -6,7 +6,7 @@ import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text- * Action to insert a short answer spot at the current cursor position. * After inserting the spot, this action also inserts an option linked to the spot. */ -export class MonacoInsertShortAnswerSpotAction extends MonacoEditorAction { +export class MonacoInsertShortAnswerSpotAction extends TextEditorAction { static readonly ID = 'monaco-insert-short-answer-spot.action'; spotNumber = 1; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/text-editor-action.model.ts similarity index 99% rename from src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/text-editor-action.model.ts index ba57899f966a..fd867b599d85 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/text-editor-action.model.ts @@ -8,7 +8,7 @@ import { TextEditorPosition } from 'app/shared/monaco-editor/model/actions/adapt import { TextEditorCompletionItem } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-completion-item.model'; import { TextEditorKeybinding } from 'app/shared/monaco-editor/model/actions/adapter/text-editor-keybinding.model'; -export abstract class MonacoEditorAction implements Disposable { +export abstract class TextEditorAction implements Disposable { id: string; label: string; translationKey: string; diff --git a/src/main/webapp/app/shared/monaco-editor/monaco-editor.component.ts b/src/main/webapp/app/shared/monaco-editor/monaco-editor.component.ts index 800a93c7f0cf..a0e28544e914 100644 --- a/src/main/webapp/app/shared/monaco-editor/monaco-editor.component.ts +++ b/src/main/webapp/app/shared/monaco-editor/monaco-editor.component.ts @@ -7,7 +7,7 @@ import { MonacoEditorBuildAnnotation, MonacoEditorBuildAnnotationType } from 'ap import { MonacoEditorLineHighlight } from 'app/shared/monaco-editor/model/monaco-editor-line-highlight.model'; import { Annotation } from 'app/exercises/programming/shared/code-editor/monaco/code-editor-monaco.component'; import { MonacoEditorLineDecorationsHoverButton } from './model/monaco-editor-line-decorations-hover-button.model'; -import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; import { TranslateService } from '@ngx-translate/core'; import { MonacoEditorOptionPreset } from 'app/shared/monaco-editor/model/monaco-editor-option-preset.model'; import { Disposable, EditorPosition, EditorRange, MonacoEditorTextModel } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; @@ -30,7 +30,7 @@ export class MonacoEditorComponent implements OnInit, OnDestroy { lineWidgets: MonacoEditorLineWidget[] = []; editorBuildAnnotations: MonacoEditorBuildAnnotation[] = []; lineHighlights: MonacoEditorLineHighlight[] = []; - actions: MonacoEditorAction[] = []; + actions: TextEditorAction[] = []; lineDecorationsHoverButton?: MonacoEditorLineDecorationsHoverButton; /** @@ -383,7 +383,7 @@ export class MonacoEditorComponent implements OnInit, OnDestroy { * Registers an action to be available in the editor. The action will be disposed when the editor is disposed. * @param action The action to register. */ - registerAction(action: MonacoEditorAction): void { + registerAction(action: TextEditorAction): void { action.register(this.textEditorAdapter, this.translateService); this.actions.push(action); } diff --git a/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-action.integration.spec.ts b/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-action.integration.spec.ts index ff11be7a94d1..5f358b7e5946 100644 --- a/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-action.integration.spec.ts +++ b/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-action.integration.spec.ts @@ -4,7 +4,7 @@ import { ArtemisTestModule } from '../../../test.module'; import { MonacoEditorModule } from 'app/shared/monaco-editor/monaco-editor.module'; import { MockResizeObserver } from '../../../helpers/mocks/service/mock-resize-observer'; import { MonacoBoldAction } from 'app/shared/monaco-editor/model/actions/monaco-bold.action'; -import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; import { MonacoItalicAction } from 'app/shared/monaco-editor/model/actions/monaco-italic.action'; import { MonacoCodeAction } from 'app/shared/monaco-editor/model/actions/monaco-code.action'; import { MonacoColorAction } from 'app/shared/monaco-editor/model/actions/monaco-color.action'; @@ -252,7 +252,7 @@ describe('MonacoEditorActionIntegration', () => { textToType, initialText, }: { - action: MonacoEditorAction; + action: TextEditorAction; textWithoutDelimiters: string; textWithDelimiters: string; actionArgs?: object; @@ -273,7 +273,7 @@ describe('MonacoEditorActionIntegration', () => { * @param initialText The initial text to expect after the action has been triggered without a selection. */ function testDelimiterAction( - action: MonacoEditorAction, + action: TextEditorAction, textWithoutDelimiters: string, textWithDelimiters: string, actionArgs?: object, diff --git a/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-communication-action.integration.spec.ts b/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-communication-action.integration.spec.ts index ef3e3f8d09df..db4fc86247d0 100644 --- a/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-communication-action.integration.spec.ts +++ b/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-communication-action.integration.spec.ts @@ -16,7 +16,7 @@ import { MonacoChannelReferenceAction } from 'app/shared/monaco-editor/model/act import { MonacoUserMentionAction } from 'app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action'; import { MonacoExerciseReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action'; import { metisExamChannelDTO, metisExerciseChannelDTO, metisGeneralChannelDTO, metisTutor, metisUser1, metisUser2 } from '../../../helpers/sample/metis-sample-data'; -import { MonacoEditorAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-action.model'; +import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; import * as monaco from 'monaco-editor'; import { MonacoEditorComponent } from 'app/shared/monaco-editor/monaco-editor.component'; import { ChannelIdAndNameDTO } from 'app/entities/metis/conversation/channel.model'; @@ -75,7 +75,7 @@ describe('MonacoEditorCommunicationActionIntegration', () => { jest.restoreAllMocks(); }); - const registerActionWithCompletionProvider = (action: MonacoEditorAction, triggerCharacter?: string) => { + const registerActionWithCompletionProvider = (action: TextEditorAction, triggerCharacter?: string) => { const registerCompletionProviderStub = jest.spyOn(monaco.languages, 'registerCompletionItemProvider').mockImplementation(); comp.registerAction(action); expect(registerCompletionProviderStub).toHaveBeenCalledOnce(); From a7c2e46dddb6df6b0db462049eb12a8261337c22 Mon Sep 17 00:00:00 2001 From: Patrik Zander Date: Sat, 31 Aug 2024 20:46:21 +0200 Subject: [PATCH 23/27] Rename action files --- ...ive-announcement-create-modal.component.ts | 12 +++---- .../file-upload-exercise-update.component.ts | 2 +- .../modeling-exercise-update.component.ts | 2 +- ...exercise-editable-instruction.component.ts | 6 ++-- .../drag-and-drop-question-edit.component.ts | 4 +-- ...multiple-choice-question-edit.component.ts | 8 ++--- ...uate-multiple-choice-question.component.ts | 4 +-- .../short-answer-question-edit.component.ts | 18 +++++------ .../manage/exercise-hint-update.component.ts | 2 +- .../grading-instructions-details.component.ts | 14 ++++---- .../text-exercise-update.component.ts | 2 +- .../app/lecture/lecture-update.component.ts | 2 +- .../lecture-wizard-title.component.ts | 2 +- .../markdown-editor-monaco.component.ts | 28 ++++++++-------- .../posting-markdown-editor.component.ts | 20 ++++++------ ...achment.action.ts => attachment.action.ts} | 0 .../{monaco-bold.action.ts => bold.action.ts} | 0 ...e-block.action.ts => code-block.action.ts} | 0 .../{monaco-code.action.ts => code.action.ts} | 0 ...monaco-color.action.ts => color.action.ts} | 0 ....action.ts => channel-reference.action.ts} | 0 ...action.ts => exercise-reference.action.ts} | 0 ...=> lecture-attachment-reference.action.ts} | 0 ...ntion.action.ts => user-mention.action.ts} | 0 ...co-formula.action.ts => formula.action.ts} | 0 ...lscreen.action.ts => fullscreen.action.ts} | 0 ...ts.action.ts => grading-credits.action.ts} | 0 ....action.ts => grading-criterion.action.ts} | 2 +- ...ction.ts => grading-description.action.ts} | 0 ...k.action.ts => grading-feedback.action.ts} | 0 ...ction.ts => grading-instruction.action.ts} | 10 +++--- ...cale.action.ts => grading-scale.action.ts} | 0 ...ction.ts => grading-usage-count.action.ts} | 0 ...co-heading.action.ts => heading.action.ts} | 0 ...naco-italic.action.ts => italic.action.ts} | 0 ...-list.action.ts => ordered-list.action.ts} | 0 ... correct-multiple-choice-answer.action.ts} | 0 ...s => insert-short-answer-option.action.ts} | 0 ....ts => insert-short-answer-spot.action.ts} | 2 +- ...n.action.ts => quiz-explanation.action.ts} | 0 ...uiz-hint.action.ts => quiz-hint.action.ts} | 0 ...=> wrong-multiple-choice-answer.action.ts} | 0 ...monaco-quote.action.ts => quote.action.ts} | 0 .../{monaco-task.action.ts => task.action.ts} | 0 ...est-case.action.ts => test-case.action.ts} | 0 ...nderline.action.ts => underline.action.ts} | 0 ...ist.action.ts => unordered-list.action.ts} | 0 .../{monaco-url.action.ts => url.action.ts} | 0 .../webapp/app/shared/util/markdown.util.ts | 4 +-- ...g-and-drop-question-edit.component.spec.ts | 4 +-- .../markdown-editor-monaco.component.spec.ts | 14 ++++---- .../markdown-editor-parsing.helper.spec.ts | 4 +-- ...ple-choice-question-edit.component.spec.ts | 10 +++--- ...ise-instruction-analysis.component.spec.ts | 2 +- ...ing-instructions-details.component.spec.ts | 14 ++++---- ...postings-markdown-editor.component.spec.ts | 20 ++++++------ ...aco-editor-action-quiz.integration.spec.ts | 12 +++---- .../monaco-editor-action.integration.spec.ts | 32 +++++++++---------- ...r-communication-action.integration.spec.ts | 8 ++--- ...r-grading-instructions.integration.spec.ts | 14 ++++---- 60 files changed, 139 insertions(+), 139 deletions(-) rename src/main/webapp/app/shared/monaco-editor/model/actions/{monaco-attachment.action.ts => attachment.action.ts} (100%) rename src/main/webapp/app/shared/monaco-editor/model/actions/{monaco-bold.action.ts => bold.action.ts} (100%) rename src/main/webapp/app/shared/monaco-editor/model/actions/{monaco-code-block.action.ts => code-block.action.ts} (100%) rename src/main/webapp/app/shared/monaco-editor/model/actions/{monaco-code.action.ts => code.action.ts} (100%) rename src/main/webapp/app/shared/monaco-editor/model/actions/{monaco-color.action.ts => color.action.ts} (100%) rename src/main/webapp/app/shared/monaco-editor/model/actions/communication/{monaco-channel-reference.action.ts => channel-reference.action.ts} (100%) rename src/main/webapp/app/shared/monaco-editor/model/actions/communication/{monaco-exercise-reference.action.ts => exercise-reference.action.ts} (100%) rename src/main/webapp/app/shared/monaco-editor/model/actions/communication/{monaco-lecture-attachment-reference.action.ts => lecture-attachment-reference.action.ts} (100%) rename src/main/webapp/app/shared/monaco-editor/model/actions/communication/{monaco-user-mention.action.ts => user-mention.action.ts} (100%) rename src/main/webapp/app/shared/monaco-editor/model/actions/{monaco-formula.action.ts => formula.action.ts} (100%) rename src/main/webapp/app/shared/monaco-editor/model/actions/{monaco-fullscreen.action.ts => fullscreen.action.ts} (100%) rename src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/{monaco-grading-credits.action.ts => grading-credits.action.ts} (100%) rename src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/{monaco-grading-criterion.action.ts => grading-criterion.action.ts} (91%) rename src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/{monaco-grading-description.action.ts => grading-description.action.ts} (100%) rename src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/{monaco-grading-feedback.action.ts => grading-feedback.action.ts} (100%) rename src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/{monaco-grading-instruction.action.ts => grading-instruction.action.ts} (81%) rename src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/{monaco-grading-scale.action.ts => grading-scale.action.ts} (100%) rename src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/{monaco-grading-usage-count.action.ts => grading-usage-count.action.ts} (100%) rename src/main/webapp/app/shared/monaco-editor/model/actions/{monaco-heading.action.ts => heading.action.ts} (100%) rename src/main/webapp/app/shared/monaco-editor/model/actions/{monaco-italic.action.ts => italic.action.ts} (100%) rename src/main/webapp/app/shared/monaco-editor/model/actions/{monaco-ordered-list.action.ts => ordered-list.action.ts} (100%) rename src/main/webapp/app/shared/monaco-editor/model/actions/quiz/{monaco-correct-multiple-choice-answer.action.ts => correct-multiple-choice-answer.action.ts} (100%) rename src/main/webapp/app/shared/monaco-editor/model/actions/quiz/{monaco-insert-short-answer-option.action.ts => insert-short-answer-option.action.ts} (100%) rename src/main/webapp/app/shared/monaco-editor/model/actions/quiz/{monaco-insert-short-answer-spot.action.ts => insert-short-answer-spot.action.ts} (96%) rename src/main/webapp/app/shared/monaco-editor/model/actions/quiz/{monaco-quiz-explanation.action.ts => quiz-explanation.action.ts} (100%) rename src/main/webapp/app/shared/monaco-editor/model/actions/quiz/{monaco-quiz-hint.action.ts => quiz-hint.action.ts} (100%) rename src/main/webapp/app/shared/monaco-editor/model/actions/quiz/{monaco-wrong-multiple-choice-answer.action.ts => wrong-multiple-choice-answer.action.ts} (100%) rename src/main/webapp/app/shared/monaco-editor/model/actions/{monaco-quote.action.ts => quote.action.ts} (100%) rename src/main/webapp/app/shared/monaco-editor/model/actions/{monaco-task.action.ts => task.action.ts} (100%) rename src/main/webapp/app/shared/monaco-editor/model/actions/{monaco-test-case.action.ts => test-case.action.ts} (100%) rename src/main/webapp/app/shared/monaco-editor/model/actions/{monaco-underline.action.ts => underline.action.ts} (100%) rename src/main/webapp/app/shared/monaco-editor/model/actions/{monaco-unordered-list.action.ts => unordered-list.action.ts} (100%) rename src/main/webapp/app/shared/monaco-editor/model/actions/{monaco-url.action.ts => url.action.ts} (100%) diff --git a/src/main/webapp/app/exam/manage/exams/exam-checklist-component/exam-announcement-dialog/exam-live-announcement-create-modal.component.ts b/src/main/webapp/app/exam/manage/exams/exam-checklist-component/exam-announcement-dialog/exam-live-announcement-create-modal.component.ts index fb9414672e52..09834f5e554e 100644 --- a/src/main/webapp/app/exam/manage/exams/exam-checklist-component/exam-announcement-dialog/exam-live-announcement-create-modal.component.ts +++ b/src/main/webapp/app/exam/manage/exams/exam-checklist-component/exam-announcement-dialog/exam-live-announcement-create-modal.component.ts @@ -6,12 +6,12 @@ import { ExamLiveEventType, ExamWideAnnouncementEvent } from 'app/exam/participa import { faCheckCircle, faSpinner } from '@fortawesome/free-solid-svg-icons'; import { AccountService } from 'app/core/auth/account.service'; import dayjs from 'dayjs/esm'; -import { MonacoBoldAction } from 'app/shared/monaco-editor/model/actions/monaco-bold.action'; -import { MonacoItalicAction } from 'app/shared/monaco-editor/model/actions/monaco-italic.action'; -import { MonacoUnderlineAction } from 'app/shared/monaco-editor/model/actions/monaco-underline.action'; -import { MonacoCodeAction } from 'app/shared/monaco-editor/model/actions/monaco-code.action'; -import { MonacoCodeBlockAction } from 'app/shared/monaco-editor/model/actions/monaco-code-block.action'; -import { MonacoOrderedListAction } from 'app/shared/monaco-editor/model/actions/monaco-ordered-list.action'; +import { MonacoBoldAction } from 'app/shared/monaco-editor/model/actions/bold.action'; +import { MonacoItalicAction } from 'app/shared/monaco-editor/model/actions/italic.action'; +import { MonacoUnderlineAction } from 'app/shared/monaco-editor/model/actions/underline.action'; +import { MonacoCodeAction } from 'app/shared/monaco-editor/model/actions/code.action'; +import { MonacoCodeBlockAction } from 'app/shared/monaco-editor/model/actions/code-block.action'; +import { MonacoOrderedListAction } from 'app/shared/monaco-editor/model/actions/ordered-list.action'; @Component({ selector: 'jhi-exam-live-announcement-create-modal', diff --git a/src/main/webapp/app/exercises/file-upload/manage/file-upload-exercise-update.component.ts b/src/main/webapp/app/exercises/file-upload/manage/file-upload-exercise-update.component.ts index 8cf0fe19dcb1..3484ad4dcf61 100644 --- a/src/main/webapp/app/exercises/file-upload/manage/file-upload-exercise-update.component.ts +++ b/src/main/webapp/app/exercises/file-upload/manage/file-upload-exercise-update.component.ts @@ -25,7 +25,7 @@ import { TeamConfigFormGroupComponent } from 'app/exercises/shared/team-config-f import { NgModel } from '@angular/forms'; import { Subscription } from 'rxjs'; import { FormSectionStatus } from 'app/forms/form-status-bar/form-status-bar.component'; -import { MonacoFormulaAction } from 'app/shared/monaco-editor/model/actions/monaco-formula.action'; +import { MonacoFormulaAction } from 'app/shared/monaco-editor/model/actions/formula.action'; @Component({ selector: 'jhi-file-upload-exercise-update', diff --git a/src/main/webapp/app/exercises/modeling/manage/modeling-exercise-update.component.ts b/src/main/webapp/app/exercises/modeling/manage/modeling-exercise-update.component.ts index 4a4488812450..45f06c41b410 100644 --- a/src/main/webapp/app/exercises/modeling/manage/modeling-exercise-update.component.ts +++ b/src/main/webapp/app/exercises/modeling/manage/modeling-exercise-update.component.ts @@ -30,7 +30,7 @@ import { NgModel } from '@angular/forms'; import { ExerciseUpdatePlagiarismComponent } from 'app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component'; import { TeamConfigFormGroupComponent } from 'app/exercises/shared/team-config-form-group/team-config-form-group.component'; import { FormDateTimePickerComponent } from 'app/shared/date-time-picker/date-time-picker.component'; -import { MonacoFormulaAction } from 'app/shared/monaco-editor/model/actions/monaco-formula.action'; +import { MonacoFormulaAction } from 'app/shared/monaco-editor/model/actions/formula.action'; @Component({ selector: 'jhi-modeling-exercise-update', diff --git a/src/main/webapp/app/exercises/programming/manage/instructions-editor/programming-exercise-editable-instruction.component.ts b/src/main/webapp/app/exercises/programming/manage/instructions-editor/programming-exercise-editable-instruction.component.ts index b20fb2d6e149..0f22b5d2bd11 100644 --- a/src/main/webapp/app/exercises/programming/manage/instructions-editor/programming-exercise-editable-instruction.component.ts +++ b/src/main/webapp/app/exercises/programming/manage/instructions-editor/programming-exercise-editable-instruction.component.ts @@ -14,9 +14,9 @@ import { Result } from 'app/entities/result.model'; import { faCheckCircle, faCircleNotch, faExclamationTriangle, faGripLines, faSave } from '@fortawesome/free-solid-svg-icons'; import { MarkdownEditorHeight, MarkdownEditorMonacoComponent } from 'app/shared/markdown-editor/monaco/markdown-editor-monaco.component'; import { Annotation } from 'app/exercises/programming/shared/code-editor/monaco/code-editor-monaco.component'; -import { MonacoFormulaAction } from 'app/shared/monaco-editor/model/actions/monaco-formula.action'; -import { MonacoTaskAction } from 'app/shared/monaco-editor/model/actions/monaco-task.action'; -import { MonacoTestCaseAction } from 'app/shared/monaco-editor/model/actions/monaco-test-case.action'; +import { MonacoFormulaAction } from 'app/shared/monaco-editor/model/actions/formula.action'; +import { MonacoTaskAction } from 'app/shared/monaco-editor/model/actions/task.action'; +import { MonacoTestCaseAction } from 'app/shared/monaco-editor/model/actions/test-case.action'; import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; @Component({ diff --git a/src/main/webapp/app/exercises/quiz/manage/drag-and-drop-question/drag-and-drop-question-edit.component.ts b/src/main/webapp/app/exercises/quiz/manage/drag-and-drop-question/drag-and-drop-question-edit.component.ts index 49e6017a3f2f..87bd8eb6275f 100644 --- a/src/main/webapp/app/exercises/quiz/manage/drag-and-drop-question/drag-and-drop-question-edit.component.ts +++ b/src/main/webapp/app/exercises/quiz/manage/drag-and-drop-question/drag-and-drop-question-edit.component.ts @@ -48,8 +48,8 @@ import { faFileImage } from '@fortawesome/free-regular-svg-icons'; import { CdkDragDrop } from '@angular/cdk/drag-drop'; import { MAX_QUIZ_QUESTION_POINTS } from 'app/shared/constants/input.constants'; import { FileService } from 'app/shared/http/file.service'; -import { MonacoQuizHintAction } from 'app/shared/monaco-editor/model/actions/quiz/monaco-quiz-hint.action'; -import { MonacoQuizExplanationAction } from 'app/shared/monaco-editor/model/actions/quiz/monaco-quiz-explanation.action'; +import { MonacoQuizHintAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-hint.action'; +import { MonacoQuizExplanationAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-explanation.action'; import { MarkdownEditorMonacoComponent, TextWithDomainAction } from 'app/shared/markdown-editor/monaco/markdown-editor-monaco.component'; @Component({ diff --git a/src/main/webapp/app/exercises/quiz/manage/multiple-choice-question/multiple-choice-question-edit.component.ts b/src/main/webapp/app/exercises/quiz/manage/multiple-choice-question/multiple-choice-question-edit.component.ts index be36aaedd0e7..acb5b0ae9ae7 100644 --- a/src/main/webapp/app/exercises/quiz/manage/multiple-choice-question/multiple-choice-question-edit.component.ts +++ b/src/main/webapp/app/exercises/quiz/manage/multiple-choice-question/multiple-choice-question-edit.component.ts @@ -8,10 +8,10 @@ import { generateExerciseHintExplanation } from 'app/shared/util/markdown.util'; import { faAngleDown, faAngleRight, faQuestionCircle, faTrash } from '@fortawesome/free-solid-svg-icons'; import { ScoringType } from 'app/entities/quiz/quiz-question.model'; import { MAX_QUIZ_QUESTION_POINTS } from 'app/shared/constants/input.constants'; -import { MonacoQuizHintAction } from 'app/shared/monaco-editor/model/actions/quiz/monaco-quiz-hint.action'; -import { MonacoWrongMultipleChoiceAnswerAction } from 'app/shared/monaco-editor/model/actions/quiz/monaco-wrong-multiple-choice-answer.action'; -import { MonacoCorrectMultipleChoiceAnswerAction } from 'app/shared/monaco-editor/model/actions/quiz/monaco-correct-multiple-choice-answer.action'; -import { MonacoQuizExplanationAction } from 'app/shared/monaco-editor/model/actions/quiz/monaco-quiz-explanation.action'; +import { MonacoQuizHintAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-hint.action'; +import { MonacoWrongMultipleChoiceAnswerAction } from 'app/shared/monaco-editor/model/actions/quiz/wrong-multiple-choice-answer.action'; +import { MonacoCorrectMultipleChoiceAnswerAction } from 'app/shared/monaco-editor/model/actions/quiz/correct-multiple-choice-answer.action'; +import { MonacoQuizExplanationAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-explanation.action'; import { MarkdownEditorMonacoComponent, TextWithDomainAction } from 'app/shared/markdown-editor/monaco/markdown-editor-monaco.component'; import { MultipleChoiceVisualQuestionComponent } from 'app/exercises/quiz/shared/questions/multiple-choice-question/multiple-choice-visual-question.component'; diff --git a/src/main/webapp/app/exercises/quiz/manage/re-evaluate/multiple-choice-question/re-evaluate-multiple-choice-question.component.ts b/src/main/webapp/app/exercises/quiz/manage/re-evaluate/multiple-choice-question/re-evaluate-multiple-choice-question.component.ts index 142869ee1ce8..fd2110ba114d 100644 --- a/src/main/webapp/app/exercises/quiz/manage/re-evaluate/multiple-choice-question/re-evaluate-multiple-choice-question.component.ts +++ b/src/main/webapp/app/exercises/quiz/manage/re-evaluate/multiple-choice-question/re-evaluate-multiple-choice-question.component.ts @@ -6,8 +6,8 @@ import { cloneDeep } from 'lodash-es'; import { generateExerciseHintExplanation, parseExerciseHintExplanation } from 'app/shared/util/markdown.util'; import { faAngleDown, faAngleRight, faArrowsAltV, faChevronDown, faChevronUp, faTrash, faUndo } from '@fortawesome/free-solid-svg-icons'; import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop'; -import { MonacoCorrectMultipleChoiceAnswerAction } from 'app/shared/monaco-editor/model/actions/quiz/monaco-correct-multiple-choice-answer.action'; -import { MonacoWrongMultipleChoiceAnswerAction } from 'app/shared/monaco-editor/model/actions/quiz/monaco-wrong-multiple-choice-answer.action'; +import { MonacoCorrectMultipleChoiceAnswerAction } from 'app/shared/monaco-editor/model/actions/quiz/correct-multiple-choice-answer.action'; +import { MonacoWrongMultipleChoiceAnswerAction } from 'app/shared/monaco-editor/model/actions/quiz/wrong-multiple-choice-answer.action'; @Component({ selector: 'jhi-re-evaluate-multiple-choice-question', diff --git a/src/main/webapp/app/exercises/quiz/manage/short-answer-question/short-answer-question-edit.component.ts b/src/main/webapp/app/exercises/quiz/manage/short-answer-question/short-answer-question-edit.component.ts index 9088d72f48fa..0bbc1cd4470c 100644 --- a/src/main/webapp/app/exercises/quiz/manage/short-answer-question/short-answer-question-edit.component.ts +++ b/src/main/webapp/app/exercises/quiz/manage/short-answer-question/short-answer-question-edit.component.ts @@ -26,16 +26,16 @@ import { generateExerciseHintExplanation, parseExerciseHintExplanation } from 'a import { faAngleDown, faAngleRight, faBan, faBars, faChevronDown, faChevronUp, faTrash, faUndo, faUnlink } from '@fortawesome/free-solid-svg-icons'; import { MAX_QUIZ_QUESTION_POINTS, MAX_QUIZ_SHORT_ANSWER_TEXT_LENGTH } from 'app/shared/constants/input.constants'; import { MarkdownEditorHeight, MarkdownEditorMonacoComponent } from 'app/shared/markdown-editor/monaco/markdown-editor-monaco.component'; -import { MonacoBoldAction } from 'app/shared/monaco-editor/model/actions/monaco-bold.action'; -import { MonacoItalicAction } from 'app/shared/monaco-editor/model/actions/monaco-italic.action'; -import { MonacoUnderlineAction } from 'app/shared/monaco-editor/model/actions/monaco-underline.action'; -import { MonacoCodeAction } from 'app/shared/monaco-editor/model/actions/monaco-code.action'; -import { MonacoUrlAction } from 'app/shared/monaco-editor/model/actions/monaco-url.action'; -import { MonacoUnorderedListAction } from 'app/shared/monaco-editor/model/actions/monaco-unordered-list.action'; -import { MonacoOrderedListAction } from 'app/shared/monaco-editor/model/actions/monaco-ordered-list.action'; -import { MonacoInsertShortAnswerSpotAction } from 'app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-spot.action'; +import { MonacoBoldAction } from 'app/shared/monaco-editor/model/actions/bold.action'; +import { MonacoItalicAction } from 'app/shared/monaco-editor/model/actions/italic.action'; +import { MonacoUnderlineAction } from 'app/shared/monaco-editor/model/actions/underline.action'; +import { MonacoCodeAction } from 'app/shared/monaco-editor/model/actions/code.action'; +import { MonacoUrlAction } from 'app/shared/monaco-editor/model/actions/url.action'; +import { MonacoUnorderedListAction } from 'app/shared/monaco-editor/model/actions/unordered-list.action'; +import { MonacoOrderedListAction } from 'app/shared/monaco-editor/model/actions/ordered-list.action'; +import { MonacoInsertShortAnswerSpotAction } from 'app/shared/monaco-editor/model/actions/quiz/insert-short-answer-spot.action'; import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; -import { MonacoInsertShortAnswerOptionAction } from 'app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-option.action'; +import { MonacoInsertShortAnswerOptionAction } from 'app/shared/monaco-editor/model/actions/quiz/insert-short-answer-option.action'; import { SHORT_ANSWER_QUIZ_QUESTION_EDITOR_OPTIONS } from 'app/shared/monaco-editor/monaco-editor-option.helper'; @Component({ diff --git a/src/main/webapp/app/exercises/shared/exercise-hint/manage/exercise-hint-update.component.ts b/src/main/webapp/app/exercises/shared/exercise-hint/manage/exercise-hint-update.component.ts index b734c1c628df..bd924a98ff59 100644 --- a/src/main/webapp/app/exercises/shared/exercise-hint/manage/exercise-hint-update.component.ts +++ b/src/main/webapp/app/exercises/shared/exercise-hint/manage/exercise-hint-update.component.ts @@ -21,7 +21,7 @@ import { IrisSettings } from 'app/entities/iris/settings/iris-settings.model'; import { ProfileService } from 'app/shared/layouts/profiles/profile.service'; import { ButtonType } from 'app/shared/components/button.component'; import { PROFILE_IRIS } from 'app/app.constants'; -import { MonacoFormulaAction } from 'app/shared/monaco-editor/model/actions/monaco-formula.action'; +import { MonacoFormulaAction } from 'app/shared/monaco-editor/model/actions/formula.action'; import { MarkdownEditorHeight } from 'app/shared/markdown-editor/monaco/markdown-editor-monaco.component'; const DEFAULT_DISPLAY_THRESHOLD = 3; diff --git a/src/main/webapp/app/exercises/shared/structured-grading-criterion/grading-instructions-details/grading-instructions-details.component.ts b/src/main/webapp/app/exercises/shared/structured-grading-criterion/grading-instructions-details/grading-instructions-details.component.ts index 7f6fa6f89ccd..f31cebfd1230 100644 --- a/src/main/webapp/app/exercises/shared/structured-grading-criterion/grading-instructions-details/grading-instructions-details.component.ts +++ b/src/main/webapp/app/exercises/shared/structured-grading-criterion/grading-instructions-details/grading-instructions-details.component.ts @@ -5,14 +5,14 @@ import { Exercise } from 'app/entities/exercise.model'; import { cloneDeep } from 'lodash-es'; import { faPlus, faTrash, faUndo } from '@fortawesome/free-solid-svg-icons'; import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; -import { MonacoGradingCreditsAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-credits.action'; -import { MonacoGradingScaleAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-scale.action'; -import { MonacoGradingDescriptionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-description.action'; -import { MonacoGradingFeedbackAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-feedback.action'; -import { MonacoGradingUsageCountAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-usage-count.action'; +import { MonacoGradingCreditsAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-credits.action'; +import { MonacoGradingScaleAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-scale.action'; +import { MonacoGradingDescriptionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-description.action'; +import { MonacoGradingFeedbackAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-feedback.action'; +import { MonacoGradingUsageCountAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-usage-count.action'; import { MarkdownEditorHeight, MarkdownEditorMonacoComponent, TextWithDomainAction } from 'app/shared/markdown-editor/monaco/markdown-editor-monaco.component'; -import { MonacoGradingCriterionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-criterion.action'; -import { MonacoGradingInstructionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-instruction.action'; +import { MonacoGradingCriterionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-criterion.action'; +import { MonacoGradingInstructionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-instruction.action'; @Component({ selector: 'jhi-grading-instructions-details', diff --git a/src/main/webapp/app/exercises/text/manage/text-exercise/text-exercise-update.component.ts b/src/main/webapp/app/exercises/text/manage/text-exercise/text-exercise-update.component.ts index e55e5fb28db2..8c703dab20fe 100644 --- a/src/main/webapp/app/exercises/text/manage/text-exercise/text-exercise-update.component.ts +++ b/src/main/webapp/app/exercises/text/manage/text-exercise/text-exercise-update.component.ts @@ -29,7 +29,7 @@ import { FormSectionStatus } from 'app/forms/form-status-bar/form-status-bar.com import { ExerciseUpdatePlagiarismComponent } from 'app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component'; import { TeamConfigFormGroupComponent } from 'app/exercises/shared/team-config-form-group/team-config-form-group.component'; import { FormDateTimePickerComponent } from 'app/shared/date-time-picker/date-time-picker.component'; -import { MonacoFormulaAction } from 'app/shared/monaco-editor/model/actions/monaco-formula.action'; +import { MonacoFormulaAction } from 'app/shared/monaco-editor/model/actions/formula.action'; @Component({ selector: 'jhi-text-exercise-update', diff --git a/src/main/webapp/app/lecture/lecture-update.component.ts b/src/main/webapp/app/lecture/lecture-update.component.ts index e0ac895d50ce..a3b06fc83047 100644 --- a/src/main/webapp/app/lecture/lecture-update.component.ts +++ b/src/main/webapp/app/lecture/lecture-update.component.ts @@ -13,7 +13,7 @@ import { DocumentationType } from 'app/shared/components/documentation-button/do import { faBan, faHandshakeAngle, faPuzzlePiece, faQuestionCircle, faSave } from '@fortawesome/free-solid-svg-icons'; import { LectureUpdateWizardComponent } from 'app/lecture/wizard-mode/lecture-update-wizard.component'; import { FILE_EXTENSIONS } from 'app/shared/constants/file-extensions.constants'; -import { MonacoFormulaAction } from 'app/shared/monaco-editor/model/actions/monaco-formula.action'; +import { MonacoFormulaAction } from 'app/shared/monaco-editor/model/actions/formula.action'; @Component({ selector: 'jhi-lecture-update', diff --git a/src/main/webapp/app/lecture/wizard-mode/lecture-wizard-title.component.ts b/src/main/webapp/app/lecture/wizard-mode/lecture-wizard-title.component.ts index c8b89b284ffb..9f626ef0b123 100644 --- a/src/main/webapp/app/lecture/wizard-mode/lecture-wizard-title.component.ts +++ b/src/main/webapp/app/lecture/wizard-mode/lecture-wizard-title.component.ts @@ -1,6 +1,6 @@ import { Component, Input } from '@angular/core'; import { Lecture } from 'app/entities/lecture.model'; -import { MonacoFormulaAction } from 'app/shared/monaco-editor/model/actions/monaco-formula.action'; +import { MonacoFormulaAction } from 'app/shared/monaco-editor/model/actions/formula.action'; @Component({ selector: 'jhi-lecture-update-wizard-title', diff --git a/src/main/webapp/app/shared/markdown-editor/monaco/markdown-editor-monaco.component.ts b/src/main/webapp/app/shared/markdown-editor/monaco/markdown-editor-monaco.component.ts index d5f50ac5023f..912788453c3b 100644 --- a/src/main/webapp/app/shared/markdown-editor/monaco/markdown-editor-monaco.component.ts +++ b/src/main/webapp/app/shared/markdown-editor/monaco/markdown-editor-monaco.component.ts @@ -15,29 +15,29 @@ import { import { MonacoEditorComponent } from 'app/shared/monaco-editor/monaco-editor.component'; import { NgbNavChangeEvent } from '@ng-bootstrap/ng-bootstrap'; import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; -import { MonacoBoldAction } from 'app/shared/monaco-editor/model/actions/monaco-bold.action'; -import { MonacoItalicAction } from 'app/shared/monaco-editor/model/actions/monaco-italic.action'; -import { MonacoUnderlineAction } from 'app/shared/monaco-editor/model/actions/monaco-underline.action'; -import { MonacoQuoteAction } from 'app/shared/monaco-editor/model/actions/monaco-quote.action'; -import { MonacoCodeAction } from 'app/shared/monaco-editor/model/actions/monaco-code.action'; -import { MonacoCodeBlockAction } from 'app/shared/monaco-editor/model/actions/monaco-code-block.action'; -import { MonacoUrlAction } from 'app/shared/monaco-editor/model/actions/monaco-url.action'; -import { MonacoAttachmentAction } from 'app/shared/monaco-editor/model/actions/monaco-attachment.action'; -import { MonacoUnorderedListAction } from 'app/shared/monaco-editor/model/actions/monaco-unordered-list.action'; -import { MonacoOrderedListAction } from 'app/shared/monaco-editor/model/actions/monaco-ordered-list.action'; +import { MonacoBoldAction } from 'app/shared/monaco-editor/model/actions/bold.action'; +import { MonacoItalicAction } from 'app/shared/monaco-editor/model/actions/italic.action'; +import { MonacoUnderlineAction } from 'app/shared/monaco-editor/model/actions/underline.action'; +import { MonacoQuoteAction } from 'app/shared/monaco-editor/model/actions/quote.action'; +import { MonacoCodeAction } from 'app/shared/monaco-editor/model/actions/code.action'; +import { MonacoCodeBlockAction } from 'app/shared/monaco-editor/model/actions/code-block.action'; +import { MonacoUrlAction } from 'app/shared/monaco-editor/model/actions/url.action'; +import { MonacoAttachmentAction } from 'app/shared/monaco-editor/model/actions/attachment.action'; +import { MonacoUnorderedListAction } from 'app/shared/monaco-editor/model/actions/unordered-list.action'; +import { MonacoOrderedListAction } from 'app/shared/monaco-editor/model/actions/ordered-list.action'; import { faAngleDown, faGripLines, faQuestionCircle } from '@fortawesome/free-solid-svg-icons'; import { v4 as uuid } from 'uuid'; import { FileUploaderService } from 'app/shared/http/file-uploader.service'; import { AlertService, AlertType } from 'app/core/util/alert.service'; import { MonacoEditorActionGroup } from 'app/shared/monaco-editor/model/actions/monaco-editor-action-group.model'; -import { MonacoHeadingAction } from 'app/shared/monaco-editor/model/actions/monaco-heading.action'; -import { MonacoFullscreenAction } from 'app/shared/monaco-editor/model/actions/monaco-fullscreen.action'; -import { MonacoColorAction } from 'app/shared/monaco-editor/model/actions/monaco-color.action'; +import { MonacoHeadingAction } from 'app/shared/monaco-editor/model/actions/heading.action'; +import { MonacoFullscreenAction } from 'app/shared/monaco-editor/model/actions/fullscreen.action'; +import { MonacoColorAction } from 'app/shared/monaco-editor/model/actions/color.action'; import { ColorSelectorComponent } from 'app/shared/color-selector/color-selector.component'; import { CdkDragMove, Point } from '@angular/cdk/drag-drop'; import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; import { MonacoEditorDomainActionWithOptions } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action-with-options.model'; -import { MonacoLectureAttachmentReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/monaco-lecture-attachment-reference.action'; +import { MonacoLectureAttachmentReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/lecture-attachment-reference.action'; import { LectureUnitType } from 'app/entities/lecture-unit/lectureUnit.model'; import { ReferenceType } from 'app/shared/metis/metis.util'; import { MonacoEditorOptionPreset } from 'app/shared/monaco-editor/model/monaco-editor-option-preset.model'; diff --git a/src/main/webapp/app/shared/metis/posting-markdown-editor/posting-markdown-editor.component.ts b/src/main/webapp/app/shared/metis/posting-markdown-editor/posting-markdown-editor.component.ts index a5d4bcf280b4..2f72a566a72d 100644 --- a/src/main/webapp/app/shared/metis/posting-markdown-editor/posting-markdown-editor.component.ts +++ b/src/main/webapp/app/shared/metis/posting-markdown-editor/posting-markdown-editor.component.ts @@ -19,17 +19,17 @@ import { CourseManagementService } from 'app/course/manage/course-management.ser import { ChannelService } from 'app/shared/metis/conversations/channel.service'; import { isCommunicationEnabled } from 'app/entities/course.model'; import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; -import { MonacoBoldAction } from 'app/shared/monaco-editor/model/actions/monaco-bold.action'; -import { MonacoItalicAction } from 'app/shared/monaco-editor/model/actions/monaco-italic.action'; -import { MonacoUnderlineAction } from 'app/shared/monaco-editor/model/actions/monaco-underline.action'; -import { MonacoQuoteAction } from 'app/shared/monaco-editor/model/actions/monaco-quote.action'; -import { MonacoCodeAction } from 'app/shared/monaco-editor/model/actions/monaco-code.action'; -import { MonacoCodeBlockAction } from 'app/shared/monaco-editor/model/actions/monaco-code-block.action'; +import { MonacoBoldAction } from 'app/shared/monaco-editor/model/actions/bold.action'; +import { MonacoItalicAction } from 'app/shared/monaco-editor/model/actions/italic.action'; +import { MonacoUnderlineAction } from 'app/shared/monaco-editor/model/actions/underline.action'; +import { MonacoQuoteAction } from 'app/shared/monaco-editor/model/actions/quote.action'; +import { MonacoCodeAction } from 'app/shared/monaco-editor/model/actions/code.action'; +import { MonacoCodeBlockAction } from 'app/shared/monaco-editor/model/actions/code-block.action'; import { MarkdownEditorHeight, MarkdownEditorMonacoComponent } from 'app/shared/markdown-editor/monaco/markdown-editor-monaco.component'; -import { MonacoChannelReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action'; -import { MonacoUserMentionAction } from 'app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action'; -import { MonacoExerciseReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action'; -import { MonacoLectureAttachmentReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/monaco-lecture-attachment-reference.action'; +import { MonacoChannelReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/channel-reference.action'; +import { MonacoUserMentionAction } from 'app/shared/monaco-editor/model/actions/communication/user-mention.action'; +import { MonacoExerciseReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/exercise-reference.action'; +import { MonacoLectureAttachmentReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/lecture-attachment-reference.action'; @Component({ selector: 'jhi-posting-markdown-editor', diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-attachment.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/attachment.action.ts similarity index 100% rename from src/main/webapp/app/shared/monaco-editor/model/actions/monaco-attachment.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/attachment.action.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-bold.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/bold.action.ts similarity index 100% rename from src/main/webapp/app/shared/monaco-editor/model/actions/monaco-bold.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/bold.action.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code-block.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/code-block.action.ts similarity index 100% rename from src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code-block.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/code-block.action.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/code.action.ts similarity index 100% rename from src/main/webapp/app/shared/monaco-editor/model/actions/monaco-code.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/code.action.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-color.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/color.action.ts similarity index 100% rename from src/main/webapp/app/shared/monaco-editor/model/actions/monaco-color.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/color.action.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/channel-reference.action.ts similarity index 100% rename from src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/communication/channel-reference.action.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/exercise-reference.action.ts similarity index 100% rename from src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/communication/exercise-reference.action.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-lecture-attachment-reference.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/lecture-attachment-reference.action.ts similarity index 100% rename from src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-lecture-attachment-reference.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/communication/lecture-attachment-reference.action.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/user-mention.action.ts similarity index 100% rename from src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/communication/user-mention.action.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-formula.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/formula.action.ts similarity index 100% rename from src/main/webapp/app/shared/monaco-editor/model/actions/monaco-formula.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/formula.action.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-fullscreen.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/fullscreen.action.ts similarity index 100% rename from src/main/webapp/app/shared/monaco-editor/model/actions/monaco-fullscreen.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/fullscreen.action.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-credits.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-credits.action.ts similarity index 100% rename from src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-credits.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-credits.action.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-criterion.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-criterion.action.ts similarity index 91% rename from src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-criterion.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-criterion.action.ts index 0881c3b0c711..e95d4389b19d 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-criterion.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-criterion.action.ts @@ -1,5 +1,5 @@ import { MonacoEditorDomainAction } from '../monaco-editor-domain-action.model'; -import { MonacoGradingInstructionAction } from './monaco-grading-instruction.action'; +import { MonacoGradingInstructionAction } from './grading-instruction.action'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; export class MonacoGradingCriterionAction extends MonacoEditorDomainAction { diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-description.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-description.action.ts similarity index 100% rename from src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-description.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-description.action.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-feedback.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-feedback.action.ts similarity index 100% rename from src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-feedback.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-feedback.action.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-instruction.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-instruction.action.ts similarity index 81% rename from src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-instruction.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-instruction.action.ts index 3012867e96c3..cb697e9a3157 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-instruction.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-instruction.action.ts @@ -1,9 +1,9 @@ import { MonacoEditorDomainAction } from '../monaco-editor-domain-action.model'; -import { MonacoGradingCreditsAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-credits.action'; -import { MonacoGradingScaleAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-scale.action'; -import { MonacoGradingDescriptionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-description.action'; -import { MonacoGradingFeedbackAction } from './monaco-grading-feedback.action'; -import { MonacoGradingUsageCountAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-usage-count.action'; +import { MonacoGradingCreditsAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-credits.action'; +import { MonacoGradingScaleAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-scale.action'; +import { MonacoGradingDescriptionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-description.action'; +import { MonacoGradingFeedbackAction } from './grading-feedback.action'; +import { MonacoGradingUsageCountAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-usage-count.action'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; export class MonacoGradingInstructionAction extends MonacoEditorDomainAction { diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-scale.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-scale.action.ts similarity index 100% rename from src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-scale.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-scale.action.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-usage-count.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-usage-count.action.ts similarity index 100% rename from src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-usage-count.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-usage-count.action.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-heading.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/heading.action.ts similarity index 100% rename from src/main/webapp/app/shared/monaco-editor/model/actions/monaco-heading.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/heading.action.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-italic.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/italic.action.ts similarity index 100% rename from src/main/webapp/app/shared/monaco-editor/model/actions/monaco-italic.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/italic.action.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-ordered-list.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/ordered-list.action.ts similarity index 100% rename from src/main/webapp/app/shared/monaco-editor/model/actions/monaco-ordered-list.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/ordered-list.action.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-correct-multiple-choice-answer.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/correct-multiple-choice-answer.action.ts similarity index 100% rename from src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-correct-multiple-choice-answer.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/quiz/correct-multiple-choice-answer.action.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-option.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/insert-short-answer-option.action.ts similarity index 100% rename from src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-option.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/quiz/insert-short-answer-option.action.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-spot.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/insert-short-answer-spot.action.ts similarity index 96% rename from src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-spot.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/quiz/insert-short-answer-spot.action.ts index 895da9478dcc..b6b2777a9f56 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-spot.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/insert-short-answer-spot.action.ts @@ -1,5 +1,5 @@ import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; -import { MonacoInsertShortAnswerOptionAction } from 'app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-option.action'; +import { MonacoInsertShortAnswerOptionAction } from 'app/shared/monaco-editor/model/actions/quiz/insert-short-answer-option.action'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; /** diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-quiz-explanation.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/quiz-explanation.action.ts similarity index 100% rename from src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-quiz-explanation.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/quiz/quiz-explanation.action.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-quiz-hint.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/quiz-hint.action.ts similarity index 100% rename from src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-quiz-hint.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/quiz/quiz-hint.action.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-wrong-multiple-choice-answer.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/wrong-multiple-choice-answer.action.ts similarity index 100% rename from src/main/webapp/app/shared/monaco-editor/model/actions/quiz/monaco-wrong-multiple-choice-answer.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/quiz/wrong-multiple-choice-answer.action.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-quote.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quote.action.ts similarity index 100% rename from src/main/webapp/app/shared/monaco-editor/model/actions/monaco-quote.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/quote.action.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-task.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/task.action.ts similarity index 100% rename from src/main/webapp/app/shared/monaco-editor/model/actions/monaco-task.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/task.action.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-test-case.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/test-case.action.ts similarity index 100% rename from src/main/webapp/app/shared/monaco-editor/model/actions/monaco-test-case.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/test-case.action.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-underline.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/underline.action.ts similarity index 100% rename from src/main/webapp/app/shared/monaco-editor/model/actions/monaco-underline.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/underline.action.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-unordered-list.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/unordered-list.action.ts similarity index 100% rename from src/main/webapp/app/shared/monaco-editor/model/actions/monaco-unordered-list.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/unordered-list.action.ts diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-url.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/url.action.ts similarity index 100% rename from src/main/webapp/app/shared/monaco-editor/model/actions/monaco-url.action.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/url.action.ts diff --git a/src/main/webapp/app/shared/util/markdown.util.ts b/src/main/webapp/app/shared/util/markdown.util.ts index 69de712ce3f8..a43274f88fc9 100644 --- a/src/main/webapp/app/shared/util/markdown.util.ts +++ b/src/main/webapp/app/shared/util/markdown.util.ts @@ -1,7 +1,7 @@ import { ExerciseHintExplanationInterface } from 'app/entities/quiz/quiz-question.model'; import { escapeStringForUseInRegex } from 'app/shared/util/global.utils'; -import { MonacoQuizExplanationAction } from 'app/shared/monaco-editor/model/actions/quiz/monaco-quiz-explanation.action'; -import { MonacoQuizHintAction } from 'app/shared/monaco-editor/model/actions/quiz/monaco-quiz-hint.action'; +import { MonacoQuizExplanationAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-explanation.action'; +import { MonacoQuizHintAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-hint.action'; const hintOrExpRegex = new RegExp( escapeStringForUseInRegex(`${MonacoQuizExplanationAction.IDENTIFIER}`) + '|' + escapeStringForUseInRegex(`${MonacoQuizHintAction.IDENTIFIER}`), diff --git a/src/test/javascript/spec/component/drag-and-drop-question/drag-and-drop-question-edit.component.spec.ts b/src/test/javascript/spec/component/drag-and-drop-question/drag-and-drop-question-edit.component.spec.ts index 2a5d9fde2bb3..e9abf208d3b9 100644 --- a/src/test/javascript/spec/component/drag-and-drop-question/drag-and-drop-question-edit.component.spec.ts +++ b/src/test/javascript/spec/component/drag-and-drop-question/drag-and-drop-question-edit.component.spec.ts @@ -23,8 +23,8 @@ import { DragAndDropQuestionUtil } from 'app/exercises/quiz/shared/drag-and-drop import { ChangeDetectorRef } from '@angular/core'; import { clone } from 'lodash-es'; import { CdkDragDrop, DragDropModule } from '@angular/cdk/drag-drop'; -import { MonacoQuizExplanationAction } from 'app/shared/monaco-editor/model/actions/quiz/monaco-quiz-explanation.action'; -import { MonacoQuizHintAction } from 'app/shared/monaco-editor/model/actions/quiz/monaco-quiz-hint.action'; +import { MonacoQuizExplanationAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-explanation.action'; +import { MonacoQuizHintAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-hint.action'; import { MarkdownEditorMonacoComponent, TextWithDomainAction } from 'app/shared/markdown-editor/monaco/markdown-editor-monaco.component'; describe('DragAndDropQuestionEditComponent', () => { diff --git a/src/test/javascript/spec/component/markdown-editor/markdown-editor-monaco.component.spec.ts b/src/test/javascript/spec/component/markdown-editor/markdown-editor-monaco.component.spec.ts index 3d1c671dab9a..617ffaae051d 100644 --- a/src/test/javascript/spec/component/markdown-editor/markdown-editor-monaco.component.spec.ts +++ b/src/test/javascript/spec/component/markdown-editor/markdown-editor-monaco.component.spec.ts @@ -9,16 +9,16 @@ import { NgbNavModule, NgbTooltip } from '@ng-bootstrap/ng-bootstrap'; import { MockComponent, MockDirective, MockPipe, MockProvider } from 'ng-mocks'; import { MarkdownEditorHeight, MarkdownEditorMonacoComponent } from 'app/shared/markdown-editor/monaco/markdown-editor-monaco.component'; import { MonacoEditorComponent } from 'app/shared/monaco-editor/monaco-editor.component'; -import { MonacoColorAction } from 'app/shared/monaco-editor/model/actions/monaco-color.action'; +import { MonacoColorAction } from 'app/shared/monaco-editor/model/actions/color.action'; import { MockResizeObserver } from '../../helpers/mocks/service/mock-resize-observer'; import { CdkDragMove, DragDropModule } from '@angular/cdk/drag-drop'; import { ArtemisSharedModule } from 'app/shared/shared.module'; -import { MonacoUrlAction } from 'app/shared/monaco-editor/model/actions/monaco-url.action'; -import { MonacoAttachmentAction } from 'app/shared/monaco-editor/model/actions/monaco-attachment.action'; -import { MonacoFormulaAction } from 'app/shared/monaco-editor/model/actions/monaco-formula.action'; -import { MonacoTestCaseAction } from 'app/shared/monaco-editor/model/actions/monaco-test-case.action'; -import { MonacoTaskAction } from 'app/shared/monaco-editor/model/actions/monaco-task.action'; -import { MonacoFullscreenAction } from 'app/shared/monaco-editor/model/actions/monaco-fullscreen.action'; +import { MonacoUrlAction } from 'app/shared/monaco-editor/model/actions/url.action'; +import { MonacoAttachmentAction } from 'app/shared/monaco-editor/model/actions/attachment.action'; +import { MonacoFormulaAction } from 'app/shared/monaco-editor/model/actions/formula.action'; +import { MonacoTestCaseAction } from 'app/shared/monaco-editor/model/actions/test-case.action'; +import { MonacoTaskAction } from 'app/shared/monaco-editor/model/actions/task.action'; +import { MonacoFullscreenAction } from 'app/shared/monaco-editor/model/actions/fullscreen.action'; import { MonacoEditorOptionPreset } from 'app/shared/monaco-editor/model/monaco-editor-option-preset.model'; import { COMMUNICATION_MARKDOWN_EDITOR_OPTIONS } from 'app/shared/monaco-editor/monaco-editor-option.helper'; diff --git a/src/test/javascript/spec/component/markdown-editor/markdown-editor-parsing.helper.spec.ts b/src/test/javascript/spec/component/markdown-editor/markdown-editor-parsing.helper.spec.ts index 99b9ec09559f..f388bc94b427 100644 --- a/src/test/javascript/spec/component/markdown-editor/markdown-editor-parsing.helper.spec.ts +++ b/src/test/javascript/spec/component/markdown-editor/markdown-editor-parsing.helper.spec.ts @@ -1,6 +1,6 @@ import { parseMarkdownForDomainActions } from 'app/shared/markdown-editor/monaco/markdown-editor-parsing.helper'; -import { MonacoGradingDescriptionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-description.action'; -import { MonacoGradingFeedbackAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-feedback.action'; +import { MonacoGradingDescriptionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-description.action'; +import { MonacoGradingFeedbackAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-feedback.action'; describe('MarkdownEditorParsingHelper', () => { it('should parse markdown without domain action identifiers', () => { diff --git a/src/test/javascript/spec/component/multiple-choice-question/multiple-choice-question-edit.component.spec.ts b/src/test/javascript/spec/component/multiple-choice-question/multiple-choice-question-edit.component.spec.ts index 763122daee76..5e1e1fd04b52 100644 --- a/src/test/javascript/spec/component/multiple-choice-question/multiple-choice-question-edit.component.spec.ts +++ b/src/test/javascript/spec/component/multiple-choice-question/multiple-choice-question-edit.component.spec.ts @@ -15,11 +15,11 @@ import { NgbCollapseMocksModule } from '../../helpers/mocks/directive/ngbCollaps import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'; import { MultipleChoiceVisualQuestionComponent } from 'app/exercises/quiz/shared/questions/multiple-choice-question/multiple-choice-visual-question.component'; import { ScoringType } from 'app/entities/quiz/quiz-question.model'; -import { MonacoQuizHintAction } from 'app/shared/monaco-editor/model/actions/quiz/monaco-quiz-hint.action'; -import { MonacoQuizExplanationAction } from 'app/shared/monaco-editor/model/actions/quiz/monaco-quiz-explanation.action'; -import { MonacoWrongMultipleChoiceAnswerAction } from 'app/shared/monaco-editor/model/actions/quiz/monaco-wrong-multiple-choice-answer.action'; -import { MonacoCorrectMultipleChoiceAnswerAction } from 'app/shared/monaco-editor/model/actions/quiz/monaco-correct-multiple-choice-answer.action'; -import { MonacoTestCaseAction } from 'app/shared/monaco-editor/model/actions/monaco-test-case.action'; +import { MonacoQuizHintAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-hint.action'; +import { MonacoQuizExplanationAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-explanation.action'; +import { MonacoWrongMultipleChoiceAnswerAction } from 'app/shared/monaco-editor/model/actions/quiz/wrong-multiple-choice-answer.action'; +import { MonacoCorrectMultipleChoiceAnswerAction } from 'app/shared/monaco-editor/model/actions/quiz/correct-multiple-choice-answer.action'; +import { MonacoTestCaseAction } from 'app/shared/monaco-editor/model/actions/test-case.action'; import { MarkdownEditorMonacoComponent } from 'app/shared/markdown-editor/monaco/markdown-editor-monaco.component'; describe('MultipleChoiceQuestionEditComponent', () => { diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction-analysis.component.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction-analysis.component.spec.ts index 32b0e6a0922f..771ea9652e93 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction-analysis.component.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction-analysis.component.spec.ts @@ -10,7 +10,7 @@ import { ArtemisTranslatePipe } from 'app/shared/pipes/artemis-translate.pipe'; import { FaIconComponent } from '@fortawesome/angular-fontawesome'; import { MockProgrammingExerciseInstructionAnalysisService } from '../../helpers/mocks/service/mock-programming-exericse-instruction-analysis.service'; import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'; -import { MonacoTaskAction } from 'app/shared/monaco-editor/model/actions/monaco-task.action'; +import { MonacoTaskAction } from 'app/shared/monaco-editor/model/actions/task.action'; describe('ProgrammingExerciseInstructionInstructorAnalysis', () => { let comp: ProgrammingExerciseInstructionAnalysisComponent; diff --git a/src/test/javascript/spec/component/shared/grading-instructions-details.component.spec.ts b/src/test/javascript/spec/component/shared/grading-instructions-details.component.spec.ts index ae00000ae4b6..b646456d895f 100644 --- a/src/test/javascript/spec/component/shared/grading-instructions-details.component.spec.ts +++ b/src/test/javascript/spec/component/shared/grading-instructions-details.component.spec.ts @@ -8,13 +8,13 @@ import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; import { MockTranslateService } from '../../helpers/mocks/service/mock-translate.service'; import { ArtemisTestModule } from '../../test.module'; -import { MonacoGradingInstructionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-instruction.action'; -import { MonacoGradingCreditsAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-credits.action'; -import { MonacoGradingScaleAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-scale.action'; -import { MonacoGradingDescriptionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-description.action'; -import { MonacoGradingFeedbackAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-feedback.action'; -import { MonacoGradingUsageCountAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-usage-count.action'; -import { MonacoGradingCriterionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-criterion.action'; +import { MonacoGradingInstructionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-instruction.action'; +import { MonacoGradingCreditsAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-credits.action'; +import { MonacoGradingScaleAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-scale.action'; +import { MonacoGradingDescriptionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-description.action'; +import { MonacoGradingFeedbackAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-feedback.action'; +import { MonacoGradingUsageCountAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-usage-count.action'; +import { MonacoGradingCriterionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-criterion.action'; import { TextWithDomainAction } from 'app/shared/markdown-editor/monaco/markdown-editor-monaco.component'; describe('GradingInstructionsDetailsComponent', () => { diff --git a/src/test/javascript/spec/component/shared/metis/postings-markdown-editor/postings-markdown-editor.component.spec.ts b/src/test/javascript/spec/component/shared/metis/postings-markdown-editor/postings-markdown-editor.component.spec.ts index 8be471cd4c29..90f211744cf7 100644 --- a/src/test/javascript/spec/component/shared/metis/postings-markdown-editor/postings-markdown-editor.component.spec.ts +++ b/src/test/javascript/spec/component/shared/metis/postings-markdown-editor/postings-markdown-editor.component.spec.ts @@ -14,16 +14,16 @@ import { CourseManagementService } from 'app/course/manage/course-management.ser import { ChannelService } from 'app/shared/metis/conversations/channel.service'; import * as CourseModel from 'app/entities/course.model'; import { MarkdownEditorMonacoComponent } from 'app/shared/markdown-editor/monaco/markdown-editor-monaco.component'; -import { MonacoChannelReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action'; -import { MonacoUserMentionAction } from 'app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action'; -import { MonacoBoldAction } from 'app/shared/monaco-editor/model/actions/monaco-bold.action'; -import { MonacoItalicAction } from 'app/shared/monaco-editor/model/actions/monaco-italic.action'; -import { MonacoUnderlineAction } from 'app/shared/monaco-editor/model/actions/monaco-underline.action'; -import { MonacoQuoteAction } from 'app/shared/monaco-editor/model/actions/monaco-quote.action'; -import { MonacoCodeAction } from 'app/shared/monaco-editor/model/actions/monaco-code.action'; -import { MonacoCodeBlockAction } from 'app/shared/monaco-editor/model/actions/monaco-code-block.action'; -import { MonacoExerciseReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action'; -import { MonacoLectureAttachmentReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/monaco-lecture-attachment-reference.action'; +import { MonacoChannelReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/channel-reference.action'; +import { MonacoUserMentionAction } from 'app/shared/monaco-editor/model/actions/communication/user-mention.action'; +import { MonacoBoldAction } from 'app/shared/monaco-editor/model/actions/bold.action'; +import { MonacoItalicAction } from 'app/shared/monaco-editor/model/actions/italic.action'; +import { MonacoUnderlineAction } from 'app/shared/monaco-editor/model/actions/underline.action'; +import { MonacoQuoteAction } from 'app/shared/monaco-editor/model/actions/quote.action'; +import { MonacoCodeAction } from 'app/shared/monaco-editor/model/actions/code.action'; +import { MonacoCodeBlockAction } from 'app/shared/monaco-editor/model/actions/code-block.action'; +import { MonacoExerciseReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/exercise-reference.action'; +import { MonacoLectureAttachmentReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/lecture-attachment-reference.action'; describe('PostingsMarkdownEditor', () => { let component: PostingMarkdownEditorComponent; diff --git a/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-action-quiz.integration.spec.ts b/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-action-quiz.integration.spec.ts index 482467968cdb..a83c623f1bc2 100644 --- a/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-action-quiz.integration.spec.ts +++ b/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-action-quiz.integration.spec.ts @@ -3,12 +3,12 @@ import { MonacoEditorComponent } from 'app/shared/monaco-editor/monaco-editor.co import { ArtemisTestModule } from '../../../test.module'; import { MonacoEditorModule } from 'app/shared/monaco-editor/monaco-editor.module'; import { MockResizeObserver } from '../../../helpers/mocks/service/mock-resize-observer'; -import { MonacoInsertShortAnswerOptionAction } from 'app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-option.action'; -import { MonacoInsertShortAnswerSpotAction } from 'app/shared/monaco-editor/model/actions/quiz/monaco-insert-short-answer-spot.action'; -import { MonacoWrongMultipleChoiceAnswerAction } from 'app/shared/monaco-editor/model/actions/quiz/monaco-wrong-multiple-choice-answer.action'; -import { MonacoCorrectMultipleChoiceAnswerAction } from 'app/shared/monaco-editor/model/actions/quiz/monaco-correct-multiple-choice-answer.action'; -import { MonacoQuizExplanationAction } from 'app/shared/monaco-editor/model/actions/quiz/monaco-quiz-explanation.action'; -import { MonacoQuizHintAction } from 'app/shared/monaco-editor/model/actions/quiz/monaco-quiz-hint.action'; +import { MonacoInsertShortAnswerOptionAction } from 'app/shared/monaco-editor/model/actions/quiz/insert-short-answer-option.action'; +import { MonacoInsertShortAnswerSpotAction } from 'app/shared/monaco-editor/model/actions/quiz/insert-short-answer-spot.action'; +import { MonacoWrongMultipleChoiceAnswerAction } from 'app/shared/monaco-editor/model/actions/quiz/wrong-multiple-choice-answer.action'; +import { MonacoCorrectMultipleChoiceAnswerAction } from 'app/shared/monaco-editor/model/actions/quiz/correct-multiple-choice-answer.action'; +import { MonacoQuizExplanationAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-explanation.action'; +import { MonacoQuizHintAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-hint.action'; describe('MonacoEditorActionQuizIntegration', () => { let fixture: ComponentFixture; diff --git a/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-action.integration.spec.ts b/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-action.integration.spec.ts index 5f358b7e5946..7f9ab0abc5fe 100644 --- a/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-action.integration.spec.ts +++ b/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-action.integration.spec.ts @@ -3,24 +3,24 @@ import { MonacoEditorComponent } from 'app/shared/monaco-editor/monaco-editor.co import { ArtemisTestModule } from '../../../test.module'; import { MonacoEditorModule } from 'app/shared/monaco-editor/monaco-editor.module'; import { MockResizeObserver } from '../../../helpers/mocks/service/mock-resize-observer'; -import { MonacoBoldAction } from 'app/shared/monaco-editor/model/actions/monaco-bold.action'; +import { MonacoBoldAction } from 'app/shared/monaco-editor/model/actions/bold.action'; import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; -import { MonacoItalicAction } from 'app/shared/monaco-editor/model/actions/monaco-italic.action'; -import { MonacoCodeAction } from 'app/shared/monaco-editor/model/actions/monaco-code.action'; -import { MonacoColorAction } from 'app/shared/monaco-editor/model/actions/monaco-color.action'; -import { MonacoUnderlineAction } from 'app/shared/monaco-editor/model/actions/monaco-underline.action'; -import { MonacoCodeBlockAction } from 'app/shared/monaco-editor/model/actions/monaco-code-block.action'; -import { MonacoFormulaAction } from 'app/shared/monaco-editor/model/actions/monaco-formula.action'; -import { MonacoQuoteAction } from 'app/shared/monaco-editor/model/actions/monaco-quote.action'; -import { MonacoFullscreenAction } from 'app/shared/monaco-editor/model/actions/monaco-fullscreen.action'; +import { MonacoItalicAction } from 'app/shared/monaco-editor/model/actions/italic.action'; +import { MonacoCodeAction } from 'app/shared/monaco-editor/model/actions/code.action'; +import { MonacoColorAction } from 'app/shared/monaco-editor/model/actions/color.action'; +import { MonacoUnderlineAction } from 'app/shared/monaco-editor/model/actions/underline.action'; +import { MonacoCodeBlockAction } from 'app/shared/monaco-editor/model/actions/code-block.action'; +import { MonacoFormulaAction } from 'app/shared/monaco-editor/model/actions/formula.action'; +import { MonacoQuoteAction } from 'app/shared/monaco-editor/model/actions/quote.action'; +import { MonacoFullscreenAction } from 'app/shared/monaco-editor/model/actions/fullscreen.action'; import * as FullscreenUtil from 'app/shared/util/fullscreen.util'; -import { MonacoTaskAction } from 'app/shared/monaco-editor/model/actions/monaco-task.action'; -import { MonacoTestCaseAction } from 'app/shared/monaco-editor/model/actions/monaco-test-case.action'; -import { MonacoHeadingAction } from 'app/shared/monaco-editor/model/actions/monaco-heading.action'; -import { MonacoUrlAction } from 'app/shared/monaco-editor/model/actions/monaco-url.action'; -import { MonacoAttachmentAction } from 'app/shared/monaco-editor/model/actions/monaco-attachment.action'; -import { MonacoOrderedListAction } from 'app/shared/monaco-editor/model/actions/monaco-ordered-list.action'; -import { MonacoUnorderedListAction } from 'app/shared/monaco-editor/model/actions/monaco-unordered-list.action'; +import { MonacoTaskAction } from 'app/shared/monaco-editor/model/actions/task.action'; +import { MonacoTestCaseAction } from 'app/shared/monaco-editor/model/actions/test-case.action'; +import { MonacoHeadingAction } from 'app/shared/monaco-editor/model/actions/heading.action'; +import { MonacoUrlAction } from 'app/shared/monaco-editor/model/actions/url.action'; +import { MonacoAttachmentAction } from 'app/shared/monaco-editor/model/actions/attachment.action'; +import { MonacoOrderedListAction } from 'app/shared/monaco-editor/model/actions/ordered-list.action'; +import { MonacoUnorderedListAction } from 'app/shared/monaco-editor/model/actions/unordered-list.action'; import * as monaco from 'monaco-editor'; describe('MonacoEditorActionIntegration', () => { diff --git a/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-communication-action.integration.spec.ts b/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-communication-action.integration.spec.ts index db4fc86247d0..74f4245d18ff 100644 --- a/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-communication-action.integration.spec.ts +++ b/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-communication-action.integration.spec.ts @@ -12,9 +12,9 @@ import { TranslateService } from '@ngx-translate/core'; import { MockLocalStorageService } from '../../../helpers/mocks/service/mock-local-storage.service'; import { LocalStorageService } from 'ngx-webstorage'; import { MockResizeObserver } from '../../../helpers/mocks/service/mock-resize-observer'; -import { MonacoChannelReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/monaco-channel-reference.action'; -import { MonacoUserMentionAction } from 'app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action'; -import { MonacoExerciseReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/monaco-exercise-reference.action'; +import { MonacoChannelReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/channel-reference.action'; +import { MonacoUserMentionAction } from 'app/shared/monaco-editor/model/actions/communication/user-mention.action'; +import { MonacoExerciseReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/exercise-reference.action'; import { metisExamChannelDTO, metisExerciseChannelDTO, metisGeneralChannelDTO, metisTutor, metisUser1, metisUser2 } from '../../../helpers/sample/metis-sample-data'; import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; import * as monaco from 'monaco-editor'; @@ -23,7 +23,7 @@ import { ChannelIdAndNameDTO } from 'app/entities/metis/conversation/channel.mod import { User } from 'app/core/user/user.model'; import { Exercise } from 'app/entities/exercise.model'; import { Lecture } from 'app/entities/lecture.model'; -import { MonacoLectureAttachmentReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/monaco-lecture-attachment-reference.action'; +import { MonacoLectureAttachmentReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/lecture-attachment-reference.action'; import { LectureUnitType } from 'app/entities/lecture-unit/lectureUnit.model'; import { ReferenceType } from 'app/shared/metis/metis.util'; diff --git a/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-grading-instructions.integration.spec.ts b/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-grading-instructions.integration.spec.ts index a5df872438f0..c0ce2132b130 100644 --- a/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-grading-instructions.integration.spec.ts +++ b/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-grading-instructions.integration.spec.ts @@ -3,13 +3,13 @@ import { ArtemisTestModule } from '../../../test.module'; import { MonacoEditorModule } from 'app/shared/monaco-editor/monaco-editor.module'; import { MockResizeObserver } from '../../../helpers/mocks/service/mock-resize-observer'; import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { MonacoGradingInstructionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-instruction.action'; -import { MonacoGradingCreditsAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-credits.action'; -import { MonacoGradingScaleAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-scale.action'; -import { MonacoGradingDescriptionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-description.action'; -import { MonacoGradingFeedbackAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-feedback.action'; -import { MonacoGradingUsageCountAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-usage-count.action'; -import { MonacoGradingCriterionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/monaco-grading-criterion.action'; +import { MonacoGradingInstructionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-instruction.action'; +import { MonacoGradingCreditsAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-credits.action'; +import { MonacoGradingScaleAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-scale.action'; +import { MonacoGradingDescriptionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-description.action'; +import { MonacoGradingFeedbackAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-feedback.action'; +import { MonacoGradingUsageCountAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-usage-count.action'; +import { MonacoGradingCriterionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-criterion.action'; describe('MonacoEditorActionGradingInstructionsIntegration', () => { let fixture: ComponentFixture; From eb3a288597e897705dcdb02c87fca8fca6ddbf97 Mon Sep 17 00:00:00 2001 From: Patrik Zander Date: Sat, 31 Aug 2024 20:51:27 +0200 Subject: [PATCH 24/27] Rename the remaining MonacoEditorAction files --- ...ng-exercise-editable-instruction.component.ts | 4 ++-- .../grading-instructions-details.component.ts | 4 ++-- .../monaco/markdown-editor-monaco.component.ts | 16 ++++++++-------- .../monaco/markdown-editor-parsing.helper.ts | 6 +++--- .../communication/exercise-reference.action.ts | 2 +- .../model/actions/formula.action.ts | 4 ++-- .../grading-criteria/grading-credits.action.ts | 4 ++-- .../grading-criteria/grading-criterion.action.ts | 4 ++-- .../grading-description.action.ts | 4 ++-- .../grading-criteria/grading-feedback.action.ts | 4 ++-- .../grading-instruction.action.ts | 4 ++-- .../grading-criteria/grading-scale.action.ts | 4 ++-- .../grading-usage-count.action.ts | 4 ++-- .../correct-multiple-choice-answer.action.ts | 4 ++-- .../actions/quiz/quiz-explanation.action.ts | 4 ++-- .../model/actions/quiz/quiz-hint.action.ts | 4 ++-- .../quiz/wrong-multiple-choice-answer.action.ts | 4 ++-- .../monaco-editor/model/actions/task.action.ts | 4 ++-- .../model/actions/test-case.action.ts | 2 +- ...odel.ts => text-editor-action-group.model.ts} | 2 +- ...t-editor-domain-action-with-options.model.ts} | 4 ++-- ...del.ts => text-editor-domain-action.model.ts} | 2 +- 22 files changed, 47 insertions(+), 47 deletions(-) rename src/main/webapp/app/shared/monaco-editor/model/actions/{monaco-editor-action-group.model.ts => text-editor-action-group.model.ts} (85%) rename src/main/webapp/app/shared/monaco-editor/model/actions/{monaco-editor-domain-action-with-options.model.ts => text-editor-domain-action-with-options.model.ts} (85%) rename src/main/webapp/app/shared/monaco-editor/model/actions/{monaco-editor-domain-action.model.ts => text-editor-domain-action.model.ts} (95%) diff --git a/src/main/webapp/app/exercises/programming/manage/instructions-editor/programming-exercise-editable-instruction.component.ts b/src/main/webapp/app/exercises/programming/manage/instructions-editor/programming-exercise-editable-instruction.component.ts index 0f22b5d2bd11..f02d98b20365 100644 --- a/src/main/webapp/app/exercises/programming/manage/instructions-editor/programming-exercise-editable-instruction.component.ts +++ b/src/main/webapp/app/exercises/programming/manage/instructions-editor/programming-exercise-editable-instruction.component.ts @@ -17,7 +17,7 @@ import { Annotation } from 'app/exercises/programming/shared/code-editor/monaco/ import { MonacoFormulaAction } from 'app/shared/monaco-editor/model/actions/formula.action'; import { MonacoTaskAction } from 'app/shared/monaco-editor/model/actions/task.action'; import { MonacoTestCaseAction } from 'app/shared/monaco-editor/model/actions/test-case.action'; -import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; +import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action.model'; @Component({ selector: 'jhi-programming-exercise-editable-instructions', @@ -33,7 +33,7 @@ export class ProgrammingExerciseEditableInstructionComponent implements AfterVie taskRegex = MonacoTaskAction.GLOBAL_TASK_REGEX; testCaseAction = new MonacoTestCaseAction(); - domainActions: MonacoEditorDomainAction[] = [new MonacoFormulaAction(), new MonacoTaskAction(), this.testCaseAction]; + domainActions: TextEditorDomainAction[] = [new MonacoFormulaAction(), new MonacoTaskAction(), this.testCaseAction]; savingInstructions = false; unsavedChangesValue = false; diff --git a/src/main/webapp/app/exercises/shared/structured-grading-criterion/grading-instructions-details/grading-instructions-details.component.ts b/src/main/webapp/app/exercises/shared/structured-grading-criterion/grading-instructions-details/grading-instructions-details.component.ts index f31cebfd1230..13f2dd715d68 100644 --- a/src/main/webapp/app/exercises/shared/structured-grading-criterion/grading-instructions-details/grading-instructions-details.component.ts +++ b/src/main/webapp/app/exercises/shared/structured-grading-criterion/grading-instructions-details/grading-instructions-details.component.ts @@ -4,7 +4,7 @@ import { GradingInstruction } from 'app/exercises/shared/structured-grading-crit import { Exercise } from 'app/entities/exercise.model'; import { cloneDeep } from 'lodash-es'; import { faPlus, faTrash, faUndo } from '@fortawesome/free-solid-svg-icons'; -import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; +import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action.model'; import { MonacoGradingCreditsAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-credits.action'; import { MonacoGradingScaleAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-scale.action'; import { MonacoGradingDescriptionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-description.action'; @@ -51,7 +51,7 @@ export class GradingInstructionsDetailsComponent implements OnInit, AfterContent this.gradingCriterionAction, ]; - domainActionsForGradingInstructionParsing: MonacoEditorDomainAction[] = [ + domainActionsForGradingInstructionParsing: TextEditorDomainAction[] = [ this.creditsAction, this.gradingScaleAction, this.descriptionAction, diff --git a/src/main/webapp/app/shared/markdown-editor/monaco/markdown-editor-monaco.component.ts b/src/main/webapp/app/shared/markdown-editor/monaco/markdown-editor-monaco.component.ts index 912788453c3b..3d8c6dc8590d 100644 --- a/src/main/webapp/app/shared/markdown-editor/monaco/markdown-editor-monaco.component.ts +++ b/src/main/webapp/app/shared/markdown-editor/monaco/markdown-editor-monaco.component.ts @@ -29,14 +29,14 @@ import { faAngleDown, faGripLines, faQuestionCircle } from '@fortawesome/free-so import { v4 as uuid } from 'uuid'; import { FileUploaderService } from 'app/shared/http/file-uploader.service'; import { AlertService, AlertType } from 'app/core/util/alert.service'; -import { MonacoEditorActionGroup } from 'app/shared/monaco-editor/model/actions/monaco-editor-action-group.model'; +import { TextEditorActionGroup } from 'app/shared/monaco-editor/model/actions/text-editor-action-group.model'; import { MonacoHeadingAction } from 'app/shared/monaco-editor/model/actions/heading.action'; import { MonacoFullscreenAction } from 'app/shared/monaco-editor/model/actions/fullscreen.action'; import { MonacoColorAction } from 'app/shared/monaco-editor/model/actions/color.action'; import { ColorSelectorComponent } from 'app/shared/color-selector/color-selector.component'; import { CdkDragMove, Point } from '@angular/cdk/drag-drop'; -import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; -import { MonacoEditorDomainActionWithOptions } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action-with-options.model'; +import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action.model'; +import { MonacoEditorDomainActionWithOptions } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action-with-options.model'; import { MonacoLectureAttachmentReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/lecture-attachment-reference.action'; import { LectureUnitType } from 'app/entities/lecture-unit/lectureUnit.model'; import { ReferenceType } from 'app/shared/metis/metis.util'; @@ -59,7 +59,7 @@ interface MarkdownActionsByGroup { header: MonacoHeadingAction[]; color?: MonacoColorAction; domain: { - withoutOptions: MonacoEditorDomainAction[]; + withoutOptions: TextEditorDomainAction[]; withOptions: MonacoEditorDomainActionWithOptions[]; }; // Special case due to the complex structure of lectures, attachments, and their slides @@ -67,7 +67,7 @@ interface MarkdownActionsByGroup { meta: TextEditorAction[]; } -export type TextWithDomainAction = { text: string; action?: MonacoEditorDomainAction }; +export type TextWithDomainAction = { text: string; action?: TextEditorDomainAction }; const EXTERNAL_HEIGHT = 'external'; @@ -157,7 +157,7 @@ export class MarkdownEditorMonacoComponent implements AfterContentInit, AfterVie ]; @Input() - headerActions?: MonacoEditorActionGroup = new MonacoEditorActionGroup( + headerActions?: TextEditorActionGroup = new TextEditorActionGroup( 'artemisApp.multipleChoiceQuestion.editor.style', [1, 2, 3].map((level) => new MonacoHeadingAction(level)), undefined, @@ -170,7 +170,7 @@ export class MarkdownEditorMonacoComponent implements AfterContentInit, AfterVie colorAction?: MonacoColorAction = new MonacoColorAction(); @Input() - domainActions: MonacoEditorDomainAction[] = []; + domainActions: TextEditorDomainAction[] = []; @Input() metaActions: TextEditorAction[] = [new MonacoFullscreenAction()]; @@ -425,7 +425,7 @@ export class MarkdownEditorMonacoComponent implements AfterContentInit, AfterVie } } - parseMarkdown(domainActionsToCheck: MonacoEditorDomainAction[] = this.domainActions): void { + parseMarkdown(domainActionsToCheck: TextEditorDomainAction[] = this.domainActions): void { if (this.showDefaultPreview) { this.defaultPreviewHtml = this.artemisMarkdown.safeHtmlForMarkdown(this._markdown); this.onDefaultPreviewHtmlChanged.emit(this.defaultPreviewHtml); diff --git a/src/main/webapp/app/shared/markdown-editor/monaco/markdown-editor-parsing.helper.ts b/src/main/webapp/app/shared/markdown-editor/monaco/markdown-editor-parsing.helper.ts index 058cacf8c2ba..2f63c2ac4b77 100644 --- a/src/main/webapp/app/shared/markdown-editor/monaco/markdown-editor-parsing.helper.ts +++ b/src/main/webapp/app/shared/markdown-editor/monaco/markdown-editor-parsing.helper.ts @@ -1,4 +1,4 @@ -import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; +import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action.model'; import { escapeStringForUseInRegex } from 'app/shared/util/global.utils'; import { TextWithDomainAction } from './markdown-editor-monaco.component'; @@ -8,7 +8,7 @@ import { TextWithDomainAction } from './markdown-editor-monaco.component'; * @param markdown The markdown text to parse * @param domainActions The domain actions to search for in the markdown */ -export function parseMarkdownForDomainActions(markdown: string, domainActions: MonacoEditorDomainAction[]): TextWithDomainAction[] { +export function parseMarkdownForDomainActions(markdown: string, domainActions: TextEditorDomainAction[]): TextWithDomainAction[] { let remainingText = markdown; const actionIdentifiersString = domainActions .map((action) => action.getOpeningIdentifier()) @@ -45,7 +45,7 @@ export function parseMarkdownForDomainActions(markdown: string, domainActions: M * @param text The text to parse * @param domainActions The domain actions to search for in the text */ -function parseLineForDomainAction(text: string, domainActions: MonacoEditorDomainAction[]): TextWithDomainAction { +function parseLineForDomainAction(text: string, domainActions: TextEditorDomainAction[]): TextWithDomainAction { for (const domainAction of domainActions) { const possibleOpeningIdentifiers = [ domainAction.getOpeningIdentifier(), diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/exercise-reference.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/exercise-reference.action.ts index b2119d0d6189..546474f9aa77 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/exercise-reference.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/exercise-reference.action.ts @@ -1,6 +1,6 @@ import { TranslateService } from '@ngx-translate/core'; import { MetisService } from 'app/shared/metis/metis.service'; -import { MonacoEditorDomainActionWithOptions } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action-with-options.model'; +import { MonacoEditorDomainActionWithOptions } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action-with-options.model'; import { ValueItem } from 'app/shared/markdown-editor/value-item.model'; import { Disposable } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/formula.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/formula.action.ts index 451015caded1..70a120476f00 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/formula.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/formula.action.ts @@ -1,4 +1,4 @@ -import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; +import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action.model'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; const FORMULA_OPEN_DELIMITER = '$$ '; @@ -7,7 +7,7 @@ const FORMULA_CLOSE_DELIMITER = ' $$'; /** * Action to toggle formula text in the editor. It wraps the selected text with the formula delimiter, e.g. switching between text and $$ text $$. */ -export class MonacoFormulaAction extends MonacoEditorDomainAction { +export class MonacoFormulaAction extends TextEditorDomainAction { static readonly ID = 'monaco-formula.action'; static readonly DEFAULT_FORMULA = 'e^{\\frac{1}{4} y^2}'; constructor() { diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-credits.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-credits.action.ts index 2a2e719f32fc..4a8c19394ef7 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-credits.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-credits.action.ts @@ -1,7 +1,7 @@ -import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; +import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action.model'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; -export class MonacoGradingCreditsAction extends MonacoEditorDomainAction { +export class MonacoGradingCreditsAction extends TextEditorDomainAction { static readonly ID = 'monaco-grading-credits.action'; static readonly IDENTIFIER = '[credits]'; static readonly TEXT = '0'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-criterion.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-criterion.action.ts index e95d4389b19d..579fb2ad0703 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-criterion.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-criterion.action.ts @@ -1,8 +1,8 @@ -import { MonacoEditorDomainAction } from '../monaco-editor-domain-action.model'; +import { TextEditorDomainAction } from '../text-editor-domain-action.model'; import { MonacoGradingInstructionAction } from './grading-instruction.action'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; -export class MonacoGradingCriterionAction extends MonacoEditorDomainAction { +export class MonacoGradingCriterionAction extends TextEditorDomainAction { static readonly ID = 'monaco-grading-criterion.action'; static readonly IDENTIFIER = '[criterion]'; static readonly TEXT = 'Add criterion title (only visible to tutors)'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-description.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-description.action.ts index c30c18f8c90d..57128d604ae4 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-description.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-description.action.ts @@ -1,7 +1,7 @@ -import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; +import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action.model'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; -export class MonacoGradingDescriptionAction extends MonacoEditorDomainAction { +export class MonacoGradingDescriptionAction extends TextEditorDomainAction { static readonly ID = 'monaco-grading-description.action'; static readonly IDENTIFIER = '[description]'; static readonly TEXT = 'Add grading instruction here (only visible for tutors)'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-feedback.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-feedback.action.ts index 7ba44a0d81f5..221e910d2c1c 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-feedback.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-feedback.action.ts @@ -1,7 +1,7 @@ -import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; +import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action.model'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; -export class MonacoGradingFeedbackAction extends MonacoEditorDomainAction { +export class MonacoGradingFeedbackAction extends TextEditorDomainAction { static readonly ID = 'monaco-grading-feedback.action'; static readonly IDENTIFIER = '[feedback]'; static readonly TEXT = 'Add feedback for students here (visible for students)'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-instruction.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-instruction.action.ts index cb697e9a3157..1ea93393c280 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-instruction.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-instruction.action.ts @@ -1,4 +1,4 @@ -import { MonacoEditorDomainAction } from '../monaco-editor-domain-action.model'; +import { TextEditorDomainAction } from '../text-editor-domain-action.model'; import { MonacoGradingCreditsAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-credits.action'; import { MonacoGradingScaleAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-scale.action'; import { MonacoGradingDescriptionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-description.action'; @@ -6,7 +6,7 @@ import { MonacoGradingFeedbackAction } from './grading-feedback.action'; import { MonacoGradingUsageCountAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-usage-count.action'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; -export class MonacoGradingInstructionAction extends MonacoEditorDomainAction { +export class MonacoGradingInstructionAction extends TextEditorDomainAction { static readonly ID = 'monaco-grading-instruction.action'; static readonly IDENTIFIER = '[instruction]'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-scale.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-scale.action.ts index 09e2b3c15bed..6315f6cf7373 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-scale.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-scale.action.ts @@ -1,7 +1,7 @@ -import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; +import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action.model'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; -export class MonacoGradingScaleAction extends MonacoEditorDomainAction { +export class MonacoGradingScaleAction extends TextEditorDomainAction { static readonly ID = 'monaco-grading-scale.action'; static readonly IDENTIFIER = '[gradingScale]'; static readonly TEXT = 'Add instruction grading scale here (only visible for tutors)'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-usage-count.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-usage-count.action.ts index 055fbe6d5a64..67eae36d2769 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-usage-count.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-usage-count.action.ts @@ -1,7 +1,7 @@ -import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; +import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action.model'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; -export class MonacoGradingUsageCountAction extends MonacoEditorDomainAction { +export class MonacoGradingUsageCountAction extends TextEditorDomainAction { static readonly ID = 'monaco-grading-usage-count.action'; static readonly IDENTIFIER = '[maxCountInScore]'; static readonly TEXT = '0'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/correct-multiple-choice-answer.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/correct-multiple-choice-answer.action.ts index 8cf6dfb49238..a6e206458ff1 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/correct-multiple-choice-answer.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/correct-multiple-choice-answer.action.ts @@ -1,7 +1,7 @@ -import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; +import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action.model'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; -export class MonacoCorrectMultipleChoiceAnswerAction extends MonacoEditorDomainAction { +export class MonacoCorrectMultipleChoiceAnswerAction extends TextEditorDomainAction { static readonly ID = 'artemisApp.multipleChoiceQuestion.editor.addCorrectAnswerOption'; static readonly IDENTIFIER = '[correct]'; static readonly TEXT = 'Enter a correct answer option here'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/quiz-explanation.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/quiz-explanation.action.ts index 4079de8736bf..d6d28b9e8304 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/quiz-explanation.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/quiz-explanation.action.ts @@ -1,7 +1,7 @@ -import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; +import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action.model'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; -export class MonacoQuizExplanationAction extends MonacoEditorDomainAction { +export class MonacoQuizExplanationAction extends TextEditorDomainAction { static readonly ID = 'monaco-quiz-explanation.action'; static readonly IDENTIFIER = '[exp]'; static readonly TEXT = 'Add an explanation here (only visible in feedback after quiz has ended)'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/quiz-hint.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/quiz-hint.action.ts index 734fe60ff7be..a31a59321579 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/quiz-hint.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/quiz-hint.action.ts @@ -1,7 +1,7 @@ -import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; +import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action.model'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; -export class MonacoQuizHintAction extends MonacoEditorDomainAction { +export class MonacoQuizHintAction extends TextEditorDomainAction { static readonly ID = 'monaco-quiz-hint.action'; static readonly IDENTIFIER = '[hint]'; static readonly TEXT = 'Add a hint here (visible during the quiz via ?-Button)'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/wrong-multiple-choice-answer.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/wrong-multiple-choice-answer.action.ts index 9f6946538af0..283fae9ae12f 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/wrong-multiple-choice-answer.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/wrong-multiple-choice-answer.action.ts @@ -1,7 +1,7 @@ -import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; +import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action.model'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; -export class MonacoWrongMultipleChoiceAnswerAction extends MonacoEditorDomainAction { +export class MonacoWrongMultipleChoiceAnswerAction extends TextEditorDomainAction { static readonly ID = 'monaco-incorrect-multiple-choice-answer.action'; static readonly IDENTIFIER = '[wrong]'; static readonly TEXT = 'Enter a wrong answer option here'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/task.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/task.action.ts index 9cc369b4addd..5970870a5899 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/task.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/task.action.ts @@ -1,11 +1,11 @@ -import { MonacoEditorDomainAction } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model'; +import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action.model'; import { escapeStringForUseInRegex } from 'app/shared/util/global.utils'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; /** * Action to insert a task into the editor. They follow the format [task][Task Short Description](testCaseName). */ -export class MonacoTaskAction extends MonacoEditorDomainAction { +export class MonacoTaskAction extends TextEditorDomainAction { static readonly ID = 'monaco-task.action'; static readonly TEXT = '[Task Short Description](testCaseName)\n'; static readonly IDENTIFIER = '[task]'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/test-case.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/test-case.action.ts index 9b855643f851..799bdbfdc4aa 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/test-case.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/test-case.action.ts @@ -1,5 +1,5 @@ import { TranslateService } from '@ngx-translate/core'; -import { DomainActionWithOptionsArguments, MonacoEditorDomainActionWithOptions } from 'app/shared/monaco-editor/model/actions/monaco-editor-domain-action-with-options.model'; +import { DomainActionWithOptionsArguments, MonacoEditorDomainActionWithOptions } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action-with-options.model'; import { Disposable } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; import { ValueItem } from 'app/shared/markdown-editor/value-item.model'; import { TextEditor } from './adapter/text-editor.interface'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action-group.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/text-editor-action-group.model.ts similarity index 85% rename from src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action-group.model.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/text-editor-action-group.model.ts index 9d0de36af6f2..de1880fcbc2c 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-action-group.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/text-editor-action-group.model.ts @@ -1,7 +1,7 @@ import { IconDefinition } from '@fortawesome/fontawesome-svg-core'; import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; -export class MonacoEditorActionGroup { +export class TextEditorActionGroup { translationKey: string; actions: ActionType[]; icon?: IconDefinition; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-domain-action-with-options.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/text-editor-domain-action-with-options.model.ts similarity index 85% rename from src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-domain-action-with-options.model.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/text-editor-domain-action-with-options.model.ts index 83969d07626d..0b8b787259cd 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-domain-action-with-options.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/text-editor-domain-action-with-options.model.ts @@ -1,4 +1,4 @@ -import { MonacoEditorDomainAction } from './monaco-editor-domain-action.model'; +import { TextEditorDomainAction } from './text-editor-domain-action.model'; import { ValueItem } from 'app/shared/markdown-editor/value-item.model'; export interface DomainActionWithOptionsArguments { @@ -8,7 +8,7 @@ export interface DomainActionWithOptionsArguments { /** * Class representing domain actions for Artemis-specific use cases with options. The user can select an item from a list of options. */ -export abstract class MonacoEditorDomainActionWithOptions extends MonacoEditorDomainAction { +export abstract class MonacoEditorDomainActionWithOptions extends TextEditorDomainAction { values: ValueItem[] = []; setValues(values: ValueItem[]) { diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/text-editor-domain-action.model.ts similarity index 95% rename from src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model.ts rename to src/main/webapp/app/shared/monaco-editor/model/actions/text-editor-domain-action.model.ts index 23b466019be5..9809d8c59d34 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/monaco-editor-domain-action.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/text-editor-domain-action.model.ts @@ -5,7 +5,7 @@ import { makeTextEditorRange } from 'app/shared/monaco-editor/model/actions/adap /** * Class representing domain actions for Artemis-specific use cases. */ -export abstract class MonacoEditorDomainAction extends TextEditorAction { +export abstract class TextEditorDomainAction extends TextEditorAction { abstract getOpeningIdentifier(): string; /** From edd7c9c87b9d244131de993a6ae9af5334a8b248 Mon Sep 17 00:00:00 2001 From: Patrik Zander Date: Sat, 31 Aug 2024 20:56:42 +0200 Subject: [PATCH 25/27] Rename action classes --- ...ive-announcement-create-modal.component.ts | 22 ++--- .../file-upload-exercise-update.component.ts | 6 +- .../modeling-exercise-update.component.ts | 6 +- ...exercise-editable-instruction.component.ts | 12 +-- .../drag-and-drop-question-edit.component.ts | 12 +-- ...multiple-choice-question-edit.component.ts | 24 ++--- ...uate-multiple-choice-question.component.ts | 16 ++-- .../short-answer-question-edit.component.ts | 38 ++++---- .../manage/exercise-hint-update.component.ts | 4 +- .../grading-instructions-details.component.ts | 76 +++++++-------- .../text-exercise-update.component.ts | 6 +- .../app/lecture/lecture-update.component.ts | 4 +- .../lecture-wizard-title.component.ts | 4 +- .../markdown-editor-monaco.component.ts | 70 +++++++------- .../posting-markdown-editor.component.ts | 40 ++++---- .../adapter/monaco-text-editor.adapter.ts | 2 +- .../model/actions/attachment.action.ts | 6 +- .../model/actions/bold.action.ts | 4 +- .../model/actions/code-block.action.ts | 4 +- .../model/actions/code.action.ts | 4 +- .../model/actions/color.action.ts | 4 +- .../communication/channel-reference.action.ts | 6 +- .../exercise-reference.action.ts | 6 +- .../lecture-attachment-reference.action.ts | 4 +- .../communication/user-mention.action.ts | 6 +- .../model/actions/formula.action.ts | 6 +- .../model/actions/fullscreen.action.ts | 4 +- .../grading-credits.action.ts | 8 +- .../grading-criterion.action.ts | 12 +-- .../grading-description.action.ts | 8 +- .../grading-feedback.action.ts | 8 +- .../grading-instruction.action.ts | 26 +++--- .../grading-criteria/grading-scale.action.ts | 8 +- .../grading-usage-count.action.ts | 8 +- .../model/actions/heading.action.ts | 2 +- .../model/actions/italic.action.ts | 6 +- .../model/actions/ordered-list.action.ts | 4 +- .../correct-multiple-choice-answer.action.ts | 8 +- .../quiz/insert-short-answer-option.action.ts | 12 +-- .../quiz/insert-short-answer-spot.action.ts | 8 +- .../actions/quiz/quiz-explanation.action.ts | 8 +- .../model/actions/quiz/quiz-hint.action.ts | 8 +- .../wrong-multiple-choice-answer.action.ts | 8 +- .../model/actions/quote.action.ts | 4 +- .../model/actions/task.action.ts | 10 +- .../model/actions/test-case.action.ts | 6 +- .../model/actions/underline.action.ts | 4 +- .../model/actions/unordered-list.action.ts | 4 +- .../monaco-editor/model/actions/url.action.ts | 6 +- .../webapp/app/shared/util/markdown.util.ts | 25 +++-- ...g-and-drop-question-edit.component.spec.ts | 8 +- .../markdown-editor-monaco.component.spec.ts | 26 +++--- .../markdown-editor-parsing.helper.spec.ts | 14 +-- ...ple-choice-question-edit.component.spec.ts | 30 +++--- ...ise-instruction-analysis.component.spec.ts | 4 +- ...ing-instructions-details.component.spec.ts | 30 +++--- ...postings-markdown-editor.component.spec.ts | 56 +++++------ ...aco-editor-action-quiz.integration.spec.ts | 42 ++++----- .../monaco-editor-action.integration.spec.ts | 92 +++++++++---------- ...r-communication-action.integration.spec.ts | 52 +++++------ ...r-grading-instructions.integration.spec.ts | 28 +++--- 61 files changed, 481 insertions(+), 498 deletions(-) diff --git a/src/main/webapp/app/exam/manage/exams/exam-checklist-component/exam-announcement-dialog/exam-live-announcement-create-modal.component.ts b/src/main/webapp/app/exam/manage/exams/exam-checklist-component/exam-announcement-dialog/exam-live-announcement-create-modal.component.ts index 09834f5e554e..371492f0bcfc 100644 --- a/src/main/webapp/app/exam/manage/exams/exam-checklist-component/exam-announcement-dialog/exam-live-announcement-create-modal.component.ts +++ b/src/main/webapp/app/exam/manage/exams/exam-checklist-component/exam-announcement-dialog/exam-live-announcement-create-modal.component.ts @@ -6,12 +6,12 @@ import { ExamLiveEventType, ExamWideAnnouncementEvent } from 'app/exam/participa import { faCheckCircle, faSpinner } from '@fortawesome/free-solid-svg-icons'; import { AccountService } from 'app/core/auth/account.service'; import dayjs from 'dayjs/esm'; -import { MonacoBoldAction } from 'app/shared/monaco-editor/model/actions/bold.action'; -import { MonacoItalicAction } from 'app/shared/monaco-editor/model/actions/italic.action'; -import { MonacoUnderlineAction } from 'app/shared/monaco-editor/model/actions/underline.action'; -import { MonacoCodeAction } from 'app/shared/monaco-editor/model/actions/code.action'; -import { MonacoCodeBlockAction } from 'app/shared/monaco-editor/model/actions/code-block.action'; -import { MonacoOrderedListAction } from 'app/shared/monaco-editor/model/actions/ordered-list.action'; +import { BoldAction } from 'app/shared/monaco-editor/model/actions/bold.action'; +import { ItalicAction } from 'app/shared/monaco-editor/model/actions/italic.action'; +import { UnderlineAction } from 'app/shared/monaco-editor/model/actions/underline.action'; +import { CodeAction } from 'app/shared/monaco-editor/model/actions/code.action'; +import { CodeBlockAction } from 'app/shared/monaco-editor/model/actions/code-block.action'; +import { OrderedListAction } from 'app/shared/monaco-editor/model/actions/ordered-list.action'; @Component({ selector: 'jhi-exam-live-announcement-create-modal', @@ -19,15 +19,7 @@ import { MonacoOrderedListAction } from 'app/shared/monaco-editor/model/actions/ styleUrls: ['./exam-live-announcement-create-modal.component.scss'], }) export class ExamLiveAnnouncementCreateModalComponent { - actions = [ - new MonacoBoldAction(), - new MonacoItalicAction(), - new MonacoUnderlineAction(), - new MonacoCodeAction(), - new MonacoCodeBlockAction(), - new MonacoOrderedListAction(), - new MonacoOrderedListAction(), - ]; + actions = [new BoldAction(), new ItalicAction(), new UnderlineAction(), new CodeAction(), new CodeBlockAction(), new OrderedListAction(), new OrderedListAction()]; courseId: number; examId: number; diff --git a/src/main/webapp/app/exercises/file-upload/manage/file-upload-exercise-update.component.ts b/src/main/webapp/app/exercises/file-upload/manage/file-upload-exercise-update.component.ts index 3484ad4dcf61..8fc4511e452e 100644 --- a/src/main/webapp/app/exercises/file-upload/manage/file-upload-exercise-update.component.ts +++ b/src/main/webapp/app/exercises/file-upload/manage/file-upload-exercise-update.component.ts @@ -25,7 +25,7 @@ import { TeamConfigFormGroupComponent } from 'app/exercises/shared/team-config-f import { NgModel } from '@angular/forms'; import { Subscription } from 'rxjs'; import { FormSectionStatus } from 'app/forms/form-status-bar/form-status-bar.component'; -import { MonacoFormulaAction } from 'app/shared/monaco-editor/model/actions/formula.action'; +import { FormulaAction } from 'app/shared/monaco-editor/model/actions/formula.action'; @Component({ selector: 'jhi-file-upload-exercise-update', @@ -54,8 +54,8 @@ export class FileUploadExerciseUpdateComponent implements AfterViewInit, OnDestr exerciseCategories: ExerciseCategory[]; existingCategories: ExerciseCategory[]; notificationText?: string; - domainActionsProblemStatement = [new MonacoFormulaAction()]; - domainActionsExampleSolution = [new MonacoFormulaAction()]; + domainActionsProblemStatement = [new FormulaAction()]; + domainActionsExampleSolution = [new FormulaAction()]; isImport: boolean; examCourseId?: number; diff --git a/src/main/webapp/app/exercises/modeling/manage/modeling-exercise-update.component.ts b/src/main/webapp/app/exercises/modeling/manage/modeling-exercise-update.component.ts index 45f06c41b410..89dbc288a125 100644 --- a/src/main/webapp/app/exercises/modeling/manage/modeling-exercise-update.component.ts +++ b/src/main/webapp/app/exercises/modeling/manage/modeling-exercise-update.component.ts @@ -30,7 +30,7 @@ import { NgModel } from '@angular/forms'; import { ExerciseUpdatePlagiarismComponent } from 'app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component'; import { TeamConfigFormGroupComponent } from 'app/exercises/shared/team-config-form-group/team-config-form-group.component'; import { FormDateTimePickerComponent } from 'app/shared/date-time-picker/date-time-picker.component'; -import { MonacoFormulaAction } from 'app/shared/monaco-editor/model/actions/formula.action'; +import { FormulaAction } from 'app/shared/monaco-editor/model/actions/formula.action'; @Component({ selector: 'jhi-modeling-exercise-update', @@ -64,8 +64,8 @@ export class ModelingExerciseUpdateComponent implements AfterViewInit, OnDestroy exerciseCategories: ExerciseCategory[]; existingCategories: ExerciseCategory[]; notificationText?: string; - domainActionsProblemStatement = [new MonacoFormulaAction()]; - domainActionsExampleSolution = [new MonacoFormulaAction()]; + domainActionsProblemStatement = [new FormulaAction()]; + domainActionsExampleSolution = [new FormulaAction()]; examCourseId?: number; isImport: boolean; isExamMode: boolean; diff --git a/src/main/webapp/app/exercises/programming/manage/instructions-editor/programming-exercise-editable-instruction.component.ts b/src/main/webapp/app/exercises/programming/manage/instructions-editor/programming-exercise-editable-instruction.component.ts index f02d98b20365..b50880b7e961 100644 --- a/src/main/webapp/app/exercises/programming/manage/instructions-editor/programming-exercise-editable-instruction.component.ts +++ b/src/main/webapp/app/exercises/programming/manage/instructions-editor/programming-exercise-editable-instruction.component.ts @@ -14,9 +14,9 @@ import { Result } from 'app/entities/result.model'; import { faCheckCircle, faCircleNotch, faExclamationTriangle, faGripLines, faSave } from '@fortawesome/free-solid-svg-icons'; import { MarkdownEditorHeight, MarkdownEditorMonacoComponent } from 'app/shared/markdown-editor/monaco/markdown-editor-monaco.component'; import { Annotation } from 'app/exercises/programming/shared/code-editor/monaco/code-editor-monaco.component'; -import { MonacoFormulaAction } from 'app/shared/monaco-editor/model/actions/formula.action'; -import { MonacoTaskAction } from 'app/shared/monaco-editor/model/actions/task.action'; -import { MonacoTestCaseAction } from 'app/shared/monaco-editor/model/actions/test-case.action'; +import { FormulaAction } from 'app/shared/monaco-editor/model/actions/formula.action'; +import { TaskAction } from 'app/shared/monaco-editor/model/actions/task.action'; +import { TestCaseAction } from 'app/shared/monaco-editor/model/actions/test-case.action'; import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action.model'; @Component({ @@ -31,9 +31,9 @@ export class ProgrammingExerciseEditableInstructionComponent implements AfterVie exerciseTestCases: string[] = []; - taskRegex = MonacoTaskAction.GLOBAL_TASK_REGEX; - testCaseAction = new MonacoTestCaseAction(); - domainActions: TextEditorDomainAction[] = [new MonacoFormulaAction(), new MonacoTaskAction(), this.testCaseAction]; + taskRegex = TaskAction.GLOBAL_TASK_REGEX; + testCaseAction = new TestCaseAction(); + domainActions: TextEditorDomainAction[] = [new FormulaAction(), new TaskAction(), this.testCaseAction]; savingInstructions = false; unsavedChangesValue = false; diff --git a/src/main/webapp/app/exercises/quiz/manage/drag-and-drop-question/drag-and-drop-question-edit.component.ts b/src/main/webapp/app/exercises/quiz/manage/drag-and-drop-question/drag-and-drop-question-edit.component.ts index 87bd8eb6275f..2ef3a60c0e44 100644 --- a/src/main/webapp/app/exercises/quiz/manage/drag-and-drop-question/drag-and-drop-question-edit.component.ts +++ b/src/main/webapp/app/exercises/quiz/manage/drag-and-drop-question/drag-and-drop-question-edit.component.ts @@ -48,8 +48,8 @@ import { faFileImage } from '@fortawesome/free-regular-svg-icons'; import { CdkDragDrop } from '@angular/cdk/drag-drop'; import { MAX_QUIZ_QUESTION_POINTS } from 'app/shared/constants/input.constants'; import { FileService } from 'app/shared/http/file.service'; -import { MonacoQuizHintAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-hint.action'; -import { MonacoQuizExplanationAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-explanation.action'; +import { QuizHintAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-hint.action'; +import { QuizExplanationAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-explanation.action'; import { MarkdownEditorMonacoComponent, TextWithDomainAction } from 'app/shared/markdown-editor/monaco/markdown-editor-monaco.component'; @Component({ @@ -104,8 +104,8 @@ export class DragAndDropQuestionEditComponent implements OnInit, OnChanges, Afte */ mouse: DragAndDropMouseEvent; - hintAction = new MonacoQuizHintAction(); - explanationAction = new MonacoQuizExplanationAction(); + hintAction = new QuizHintAction(); + explanationAction = new QuizExplanationAction(); dragAndDropDomainActions = [this.explanationAction, this.hintAction]; @@ -843,9 +843,9 @@ export class DragAndDropQuestionEditComponent implements OnInit, OnChanges, Afte if (action === undefined && text.length > 0) { this.question.text = text; } - if (action instanceof MonacoQuizExplanationAction) { + if (action instanceof QuizExplanationAction) { this.question.explanation = text; - } else if (action instanceof MonacoQuizHintAction) { + } else if (action instanceof QuizHintAction) { this.question.hint = text; } } diff --git a/src/main/webapp/app/exercises/quiz/manage/multiple-choice-question/multiple-choice-question-edit.component.ts b/src/main/webapp/app/exercises/quiz/manage/multiple-choice-question/multiple-choice-question-edit.component.ts index acb5b0ae9ae7..b477643b0d3d 100644 --- a/src/main/webapp/app/exercises/quiz/manage/multiple-choice-question/multiple-choice-question-edit.component.ts +++ b/src/main/webapp/app/exercises/quiz/manage/multiple-choice-question/multiple-choice-question-edit.component.ts @@ -8,10 +8,10 @@ import { generateExerciseHintExplanation } from 'app/shared/util/markdown.util'; import { faAngleDown, faAngleRight, faQuestionCircle, faTrash } from '@fortawesome/free-solid-svg-icons'; import { ScoringType } from 'app/entities/quiz/quiz-question.model'; import { MAX_QUIZ_QUESTION_POINTS } from 'app/shared/constants/input.constants'; -import { MonacoQuizHintAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-hint.action'; -import { MonacoWrongMultipleChoiceAnswerAction } from 'app/shared/monaco-editor/model/actions/quiz/wrong-multiple-choice-answer.action'; -import { MonacoCorrectMultipleChoiceAnswerAction } from 'app/shared/monaco-editor/model/actions/quiz/correct-multiple-choice-answer.action'; -import { MonacoQuizExplanationAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-explanation.action'; +import { QuizHintAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-hint.action'; +import { WrongMultipleChoiceAnswerAction } from 'app/shared/monaco-editor/model/actions/quiz/wrong-multiple-choice-answer.action'; +import { CorrectMultipleChoiceAnswerAction } from 'app/shared/monaco-editor/model/actions/quiz/correct-multiple-choice-answer.action'; +import { QuizExplanationAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-explanation.action'; import { MarkdownEditorMonacoComponent, TextWithDomainAction } from 'app/shared/markdown-editor/monaco/markdown-editor-monaco.component'; import { MultipleChoiceVisualQuestionComponent } from 'app/exercises/quiz/shared/questions/multiple-choice-question/multiple-choice-visual-question.component'; @@ -49,10 +49,10 @@ export class MultipleChoiceQuestionEditComponent implements OnInit, QuizQuestion showMultipleChoiceQuestionPreview = true; showMultipleChoiceQuestionVisual = true; - correctAction = new MonacoCorrectMultipleChoiceAnswerAction(); - wrongAction = new MonacoWrongMultipleChoiceAnswerAction(); - explanationAction = new MonacoQuizExplanationAction(); - hintAction = new MonacoQuizHintAction(); + correctAction = new CorrectMultipleChoiceAnswerAction(); + wrongAction = new WrongMultipleChoiceAnswerAction(); + explanationAction = new QuizExplanationAction(); + hintAction = new QuizHintAction(); multipleChoiceActions = [this.correctAction, this.wrongAction, this.explanationAction, this.hintAction]; @@ -170,18 +170,18 @@ export class MultipleChoiceQuestionEditComponent implements OnInit, QuizQuestion if (action === undefined && text.length > 0) { this.question.text = text; } - if (action instanceof MonacoCorrectMultipleChoiceAnswerAction || action instanceof MonacoWrongMultipleChoiceAnswerAction) { + if (action instanceof CorrectMultipleChoiceAnswerAction || action instanceof WrongMultipleChoiceAnswerAction) { currentAnswerOption = new AnswerOption(); - currentAnswerOption.isCorrect = action instanceof MonacoCorrectMultipleChoiceAnswerAction; + currentAnswerOption.isCorrect = action instanceof CorrectMultipleChoiceAnswerAction; currentAnswerOption.text = text; this.question.answerOptions!.push(currentAnswerOption); - } else if (action instanceof MonacoQuizExplanationAction) { + } else if (action instanceof QuizExplanationAction) { if (currentAnswerOption) { currentAnswerOption.explanation = text; } else { this.question.explanation = text; } - } else if (action instanceof MonacoQuizHintAction) { + } else if (action instanceof QuizHintAction) { if (currentAnswerOption) { currentAnswerOption.hint = text; } else { diff --git a/src/main/webapp/app/exercises/quiz/manage/re-evaluate/multiple-choice-question/re-evaluate-multiple-choice-question.component.ts b/src/main/webapp/app/exercises/quiz/manage/re-evaluate/multiple-choice-question/re-evaluate-multiple-choice-question.component.ts index fd2110ba114d..a9a0afae1077 100644 --- a/src/main/webapp/app/exercises/quiz/manage/re-evaluate/multiple-choice-question/re-evaluate-multiple-choice-question.component.ts +++ b/src/main/webapp/app/exercises/quiz/manage/re-evaluate/multiple-choice-question/re-evaluate-multiple-choice-question.component.ts @@ -6,8 +6,8 @@ import { cloneDeep } from 'lodash-es'; import { generateExerciseHintExplanation, parseExerciseHintExplanation } from 'app/shared/util/markdown.util'; import { faAngleDown, faAngleRight, faArrowsAltV, faChevronDown, faChevronUp, faTrash, faUndo } from '@fortawesome/free-solid-svg-icons'; import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop'; -import { MonacoCorrectMultipleChoiceAnswerAction } from 'app/shared/monaco-editor/model/actions/quiz/correct-multiple-choice-answer.action'; -import { MonacoWrongMultipleChoiceAnswerAction } from 'app/shared/monaco-editor/model/actions/quiz/wrong-multiple-choice-answer.action'; +import { CorrectMultipleChoiceAnswerAction } from 'app/shared/monaco-editor/model/actions/quiz/correct-multiple-choice-answer.action'; +import { WrongMultipleChoiceAnswerAction } from 'app/shared/monaco-editor/model/actions/quiz/wrong-multiple-choice-answer.action'; @Component({ selector: 'jhi-re-evaluate-multiple-choice-question', @@ -45,9 +45,7 @@ export class ReEvaluateMultipleChoiceQuestionComponent implements OnInit { for (const answer of this.question.answerOptions!) { this.markdownMap.set( answer.id!, - (answer.isCorrect ? MonacoCorrectMultipleChoiceAnswerAction.IDENTIFIER : MonacoWrongMultipleChoiceAnswerAction.IDENTIFIER) + - ' ' + - generateExerciseHintExplanation(answer), + (answer.isCorrect ? CorrectMultipleChoiceAnswerAction.IDENTIFIER : WrongMultipleChoiceAnswerAction.IDENTIFIER) + ' ' + generateExerciseHintExplanation(answer), ); } this.questionText = this.getQuestionText(this.question); @@ -104,9 +102,9 @@ export class ReEvaluateMultipleChoiceQuestionComponent implements OnInit { const startOfThisPart = text.indexOf(answerOptionText); const box = text.substring(0, startOfThisPart); // Check if box says this answer option is correct or not - if (box === MonacoCorrectMultipleChoiceAnswerAction.IDENTIFIER) { + if (box === CorrectMultipleChoiceAnswerAction.IDENTIFIER) { answer.isCorrect = true; - } else if (box === MonacoWrongMultipleChoiceAnswerAction.IDENTIFIER) { + } else if (box === WrongMultipleChoiceAnswerAction.IDENTIFIER) { answer.isCorrect = false; } else { answer.isCorrect = undefined; @@ -120,9 +118,7 @@ export class ReEvaluateMultipleChoiceQuestionComponent implements OnInit { */ private static splitByCorrectIncorrectTag(text: string): string[] { const stringForSplit = - escapeStringForUseInRegex(`${MonacoCorrectMultipleChoiceAnswerAction.IDENTIFIER}`) + - '|' + - escapeStringForUseInRegex(`${MonacoWrongMultipleChoiceAnswerAction.IDENTIFIER}`); + escapeStringForUseInRegex(`${CorrectMultipleChoiceAnswerAction.IDENTIFIER}`) + '|' + escapeStringForUseInRegex(`${WrongMultipleChoiceAnswerAction.IDENTIFIER}`); const splitRegExp = new RegExp(stringForSplit, 'g'); return text.split(splitRegExp); } diff --git a/src/main/webapp/app/exercises/quiz/manage/short-answer-question/short-answer-question-edit.component.ts b/src/main/webapp/app/exercises/quiz/manage/short-answer-question/short-answer-question-edit.component.ts index 0bbc1cd4470c..6e7ac7627281 100644 --- a/src/main/webapp/app/exercises/quiz/manage/short-answer-question/short-answer-question-edit.component.ts +++ b/src/main/webapp/app/exercises/quiz/manage/short-answer-question/short-answer-question-edit.component.ts @@ -26,16 +26,16 @@ import { generateExerciseHintExplanation, parseExerciseHintExplanation } from 'a import { faAngleDown, faAngleRight, faBan, faBars, faChevronDown, faChevronUp, faTrash, faUndo, faUnlink } from '@fortawesome/free-solid-svg-icons'; import { MAX_QUIZ_QUESTION_POINTS, MAX_QUIZ_SHORT_ANSWER_TEXT_LENGTH } from 'app/shared/constants/input.constants'; import { MarkdownEditorHeight, MarkdownEditorMonacoComponent } from 'app/shared/markdown-editor/monaco/markdown-editor-monaco.component'; -import { MonacoBoldAction } from 'app/shared/monaco-editor/model/actions/bold.action'; -import { MonacoItalicAction } from 'app/shared/monaco-editor/model/actions/italic.action'; -import { MonacoUnderlineAction } from 'app/shared/monaco-editor/model/actions/underline.action'; -import { MonacoCodeAction } from 'app/shared/monaco-editor/model/actions/code.action'; -import { MonacoUrlAction } from 'app/shared/monaco-editor/model/actions/url.action'; -import { MonacoUnorderedListAction } from 'app/shared/monaco-editor/model/actions/unordered-list.action'; -import { MonacoOrderedListAction } from 'app/shared/monaco-editor/model/actions/ordered-list.action'; -import { MonacoInsertShortAnswerSpotAction } from 'app/shared/monaco-editor/model/actions/quiz/insert-short-answer-spot.action'; +import { BoldAction } from 'app/shared/monaco-editor/model/actions/bold.action'; +import { ItalicAction } from 'app/shared/monaco-editor/model/actions/italic.action'; +import { UnderlineAction } from 'app/shared/monaco-editor/model/actions/underline.action'; +import { CodeAction } from 'app/shared/monaco-editor/model/actions/code.action'; +import { UrlAction } from 'app/shared/monaco-editor/model/actions/url.action'; +import { UnorderedListAction } from 'app/shared/monaco-editor/model/actions/unordered-list.action'; +import { OrderedListAction } from 'app/shared/monaco-editor/model/actions/ordered-list.action'; +import { InsertShortAnswerSpotAction } from 'app/shared/monaco-editor/model/actions/quiz/insert-short-answer-spot.action'; import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; -import { MonacoInsertShortAnswerOptionAction } from 'app/shared/monaco-editor/model/actions/quiz/insert-short-answer-option.action'; +import { InsertShortAnswerOptionAction } from 'app/shared/monaco-editor/model/actions/quiz/insert-short-answer-option.action'; import { SHORT_ANSWER_QUIZ_QUESTION_EDITOR_OPTIONS } from 'app/shared/monaco-editor/monaco-editor-option.helper'; @Component({ @@ -53,8 +53,8 @@ export class ShortAnswerQuestionEditComponent implements OnInit, OnChanges, Afte questionElement: ElementRef; markdownActions: TextEditorAction[]; - insertShortAnswerOptionAction = new MonacoInsertShortAnswerOptionAction(); - insertShortAnswerSpotAction = new MonacoInsertShortAnswerSpotAction(this.insertShortAnswerOptionAction); + insertShortAnswerOptionAction = new InsertShortAnswerOptionAction(); + insertShortAnswerSpotAction = new InsertShortAnswerSpotAction(this.insertShortAnswerOptionAction); shortAnswerQuestion: ShortAnswerQuestion; @@ -119,13 +119,13 @@ export class ShortAnswerQuestionEditComponent implements OnInit, OnChanges, Afte ngOnInit(): void { this.markdownActions = [ - new MonacoBoldAction(), - new MonacoItalicAction(), - new MonacoUnderlineAction(), - new MonacoCodeAction(), - new MonacoUrlAction(), - new MonacoUnorderedListAction(), - new MonacoOrderedListAction(), + new BoldAction(), + new ItalicAction(), + new UnderlineAction(), + new CodeAction(), + new UrlAction(), + new UnorderedListAction(), + new OrderedListAction(), this.insertShortAnswerSpotAction, this.insertShortAnswerOptionAction, ]; @@ -454,7 +454,7 @@ export class ShortAnswerQuestionEditComponent implements OnInit, OnChanges, Afte this.shortAnswerQuestion.solutions = []; } const solution = new ShortAnswerSolution(); - solution.text = MonacoInsertShortAnswerOptionAction.DEFAULT_TEXT_SHORT; + solution.text = InsertShortAnswerOptionAction.DEFAULT_TEXT_SHORT; this.insertShortAnswerOptionAction.executeInCurrentEditor({ optionText: solution.text }); this.questionUpdated.emit(); } diff --git a/src/main/webapp/app/exercises/shared/exercise-hint/manage/exercise-hint-update.component.ts b/src/main/webapp/app/exercises/shared/exercise-hint/manage/exercise-hint-update.component.ts index bd924a98ff59..eccefa8564b8 100644 --- a/src/main/webapp/app/exercises/shared/exercise-hint/manage/exercise-hint-update.component.ts +++ b/src/main/webapp/app/exercises/shared/exercise-hint/manage/exercise-hint-update.component.ts @@ -21,7 +21,7 @@ import { IrisSettings } from 'app/entities/iris/settings/iris-settings.model'; import { ProfileService } from 'app/shared/layouts/profiles/profile.service'; import { ButtonType } from 'app/shared/components/button.component'; import { PROFILE_IRIS } from 'app/app.constants'; -import { MonacoFormulaAction } from 'app/shared/monaco-editor/model/actions/formula.action'; +import { FormulaAction } from 'app/shared/monaco-editor/model/actions/formula.action'; import { MarkdownEditorHeight } from 'app/shared/markdown-editor/monaco/markdown-editor-monaco.component'; const DEFAULT_DISPLAY_THRESHOLD = 3; @@ -46,7 +46,7 @@ export class ExerciseHintUpdateComponent implements OnInit, OnDestroy { isGeneratingDescription: boolean; paramSub: Subscription; - domainActions = [new MonacoFormulaAction()]; + domainActions = [new FormulaAction()]; // Icons faCircleNotch = faCircleNotch; diff --git a/src/main/webapp/app/exercises/shared/structured-grading-criterion/grading-instructions-details/grading-instructions-details.component.ts b/src/main/webapp/app/exercises/shared/structured-grading-criterion/grading-instructions-details/grading-instructions-details.component.ts index 13f2dd715d68..0aee50798f6d 100644 --- a/src/main/webapp/app/exercises/shared/structured-grading-criterion/grading-instructions-details/grading-instructions-details.component.ts +++ b/src/main/webapp/app/exercises/shared/structured-grading-criterion/grading-instructions-details/grading-instructions-details.component.ts @@ -5,14 +5,14 @@ import { Exercise } from 'app/entities/exercise.model'; import { cloneDeep } from 'lodash-es'; import { faPlus, faTrash, faUndo } from '@fortawesome/free-solid-svg-icons'; import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action.model'; -import { MonacoGradingCreditsAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-credits.action'; -import { MonacoGradingScaleAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-scale.action'; -import { MonacoGradingDescriptionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-description.action'; -import { MonacoGradingFeedbackAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-feedback.action'; -import { MonacoGradingUsageCountAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-usage-count.action'; +import { GradingCreditsAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-credits.action'; +import { GradingScaleAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-scale.action'; +import { GradingDescriptionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-description.action'; +import { GradingFeedbackAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-feedback.action'; +import { GradingUsageCountAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-usage-count.action'; import { MarkdownEditorHeight, MarkdownEditorMonacoComponent, TextWithDomainAction } from 'app/shared/markdown-editor/monaco/markdown-editor-monaco.component'; -import { MonacoGradingCriterionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-criterion.action'; -import { MonacoGradingInstructionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-instruction.action'; +import { GradingCriterionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-criterion.action'; +import { GradingInstructionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-instruction.action'; @Component({ selector: 'jhi-grading-instructions-details', @@ -33,13 +33,13 @@ export class GradingInstructionsDetailsComponent implements OnInit, AfterContent markdownEditorText = ''; showEditMode: boolean; - creditsAction = new MonacoGradingCreditsAction(); - gradingScaleAction = new MonacoGradingScaleAction(); - descriptionAction = new MonacoGradingDescriptionAction(); - feedbackAction = new MonacoGradingFeedbackAction(); - usageCountAction = new MonacoGradingUsageCountAction(); - gradingInstructionAction = new MonacoGradingInstructionAction(this.creditsAction, this.gradingScaleAction, this.descriptionAction, this.feedbackAction, this.usageCountAction); - gradingCriterionAction = new MonacoGradingCriterionAction(this.gradingInstructionAction); + creditsAction = new GradingCreditsAction(); + gradingScaleAction = new GradingScaleAction(); + descriptionAction = new GradingDescriptionAction(); + feedbackAction = new GradingFeedbackAction(); + usageCountAction = new GradingUsageCountAction(); + gradingInstructionAction = new GradingInstructionAction(this.creditsAction, this.gradingScaleAction, this.descriptionAction, this.feedbackAction, this.usageCountAction); + gradingCriterionAction = new GradingCriterionAction(this.gradingInstructionAction); domainActionsForMainEditor = [ this.creditsAction, @@ -102,7 +102,7 @@ export class GradingInstructionsDetailsComponent implements OnInit, AfterContent // if it is a dummy criterion, leave out the action identifier markdownText += this.generateInstructionsMarkdown(criterion); } else { - markdownText += `${MonacoGradingCriterionAction.IDENTIFIER} ${criterion.title}\n\t${this.generateInstructionsMarkdown(criterion)}`; + markdownText += `${GradingCriterionAction.IDENTIFIER} ${criterion.title}\n\t${this.generateInstructionsMarkdown(criterion)}`; } } } @@ -130,7 +130,7 @@ export class GradingInstructionsDetailsComponent implements OnInit, AfterContent generateInstructionText(instruction: GradingInstruction): string { let markdownText = ''; markdownText = - MonacoGradingInstructionAction.IDENTIFIER + + GradingInstructionAction.IDENTIFIER + '\n' + '\t' + this.generateCreditsText(instruction) + @@ -152,8 +152,8 @@ export class GradingInstructionsDetailsComponent implements OnInit, AfterContent } generateCreditsText(instruction: GradingInstruction): string { - const creditsText = MonacoGradingCreditsAction.TEXT; - const creditsIdentifier = MonacoGradingCreditsAction.IDENTIFIER; + const creditsText = GradingCreditsAction.TEXT; + const creditsIdentifier = GradingCreditsAction.IDENTIFIER; if (instruction.credits == undefined) { instruction.credits = parseFloat(creditsText) || 0; } @@ -162,30 +162,30 @@ export class GradingInstructionsDetailsComponent implements OnInit, AfterContent generateGradingScaleText(instruction: GradingInstruction): string { if (instruction.gradingScale == undefined) { - instruction.gradingScale = MonacoGradingScaleAction.TEXT; + instruction.gradingScale = GradingScaleAction.TEXT; } - return `${MonacoGradingScaleAction.IDENTIFIER} ${instruction.gradingScale}`; + return `${GradingScaleAction.IDENTIFIER} ${instruction.gradingScale}`; } generateInstructionDescriptionText(instruction: GradingInstruction): string { if (instruction.instructionDescription == undefined) { - instruction.instructionDescription = MonacoGradingDescriptionAction.TEXT; + instruction.instructionDescription = GradingDescriptionAction.TEXT; } - return `${MonacoGradingDescriptionAction.IDENTIFIER} ${instruction.instructionDescription}`; + return `${GradingDescriptionAction.IDENTIFIER} ${instruction.instructionDescription}`; } generateInstructionFeedback(instruction: GradingInstruction): string { if (instruction.feedback == undefined) { - instruction.feedback = MonacoGradingFeedbackAction.TEXT; + instruction.feedback = GradingFeedbackAction.TEXT; } - return `${MonacoGradingFeedbackAction.IDENTIFIER} ${instruction.feedback}`; + return `${GradingFeedbackAction.IDENTIFIER} ${instruction.feedback}`; } generateUsageCount(instruction: GradingInstruction): string { if (instruction.usageCount == undefined) { - instruction.usageCount = parseInt(MonacoGradingUsageCountAction.TEXT, 10) || 0; + instruction.usageCount = parseInt(GradingUsageCountAction.TEXT, 10) || 0; } - return `${MonacoGradingUsageCountAction.IDENTIFIER} ${instruction.usageCount}`; + return `${GradingUsageCountAction.IDENTIFIER} ${instruction.usageCount}`; } initializeExerciseGradingInstructionText(): string { @@ -211,7 +211,7 @@ export class GradingInstructionsDetailsComponent implements OnInit, AfterContent } hasCriterionAction(textWithDomainActions: TextWithDomainAction[]): boolean { - return textWithDomainActions.some(({ action }) => action instanceof MonacoGradingCriterionAction); + return textWithDomainActions.some(({ action }) => action instanceof GradingCriterionAction); } /** @@ -228,7 +228,7 @@ export class GradingInstructionsDetailsComponent implements OnInit, AfterContent for (const { action } of textWithDomainActions) { endOfInstructionsAction++; this.setExerciseGradingInstructionText(textWithDomainActions); - if (action instanceof MonacoGradingCriterionAction) { + if (action instanceof GradingCriterionAction) { instructionActions = textWithDomainActions.slice(0, endOfInstructionsAction - 1); if (instructionActions.length !== 0) { this.setParentForInstructionsWithNoCriterion(instructionActions); @@ -251,7 +251,7 @@ export class GradingInstructionsDetailsComponent implements OnInit, AfterContent setParentForInstructionsWithNoCriterion(textWithDomainActions: TextWithDomainAction[]): void { for (const { action } of textWithDomainActions) { this.setExerciseGradingInstructionText(textWithDomainActions); - if (action instanceof MonacoGradingInstructionAction) { + if (action instanceof GradingInstructionAction) { const dummyCriterion = new GradingCriterion(); const newInstruction = new GradingInstruction(); dummyCriterion.structuredGradingInstructions = []; @@ -274,7 +274,7 @@ export class GradingInstructionsDetailsComponent implements OnInit, AfterContent this.exercise.gradingCriteria = []; } for (const { text, action } of textWithDomainActions) { - if (action instanceof MonacoGradingCriterionAction) { + if (action instanceof GradingCriterionAction) { const newCriterion = new GradingCriterion(); newCriterion.title = text; this.exercise.gradingCriteria.push(newCriterion); @@ -284,19 +284,19 @@ export class GradingInstructionsDetailsComponent implements OnInit, AfterContent for (const remainingTextWithDomainAction of arrayWithoutCriterion) { const instrAction = remainingTextWithDomainAction.action; endOfCriterion++; - if (instrAction instanceof MonacoGradingInstructionAction) { + if (instrAction instanceof GradingInstructionAction) { const newInstruction = new GradingInstruction(); // create instruction objects that belong to the above created criterion newCriterion.structuredGradingInstructions.push(newInstruction); this.instructions.push(newInstruction); } - if (instrAction instanceof MonacoGradingCriterionAction) { + if (instrAction instanceof GradingCriterionAction) { textWithDomainActions = textWithDomainActions.slice(endOfCriterion, textWithDomainActions.length); break; } } } } - this.setInstructionParameters(initialCriterionActions.filter(({ action }) => !(action instanceof MonacoGradingCriterionAction))); + this.setInstructionParameters(initialCriterionActions.filter(({ action }) => !(action instanceof GradingCriterionAction))); } /** @@ -309,15 +309,15 @@ export class GradingInstructionsDetailsComponent implements OnInit, AfterContent if (!this.instructions[index]) { break; } - if (action instanceof MonacoGradingCreditsAction) { + if (action instanceof GradingCreditsAction) { this.instructions[index].credits = parseFloat(text); - } else if (action instanceof MonacoGradingScaleAction) { + } else if (action instanceof GradingScaleAction) { this.instructions[index].gradingScale = text; - } else if (action instanceof MonacoGradingDescriptionAction) { + } else if (action instanceof GradingDescriptionAction) { this.instructions[index].instructionDescription = text; - } else if (action instanceof MonacoGradingFeedbackAction) { + } else if (action instanceof GradingFeedbackAction) { this.instructions[index].feedback = text; - } else if (action instanceof MonacoGradingUsageCountAction) { + } else if (action instanceof GradingUsageCountAction) { this.instructions[index].usageCount = parseInt(text, 10); index++; // index must be increased after the last parameter of the instruction to continue with the next instruction object } diff --git a/src/main/webapp/app/exercises/text/manage/text-exercise/text-exercise-update.component.ts b/src/main/webapp/app/exercises/text/manage/text-exercise/text-exercise-update.component.ts index 8c703dab20fe..765a9fe79413 100644 --- a/src/main/webapp/app/exercises/text/manage/text-exercise/text-exercise-update.component.ts +++ b/src/main/webapp/app/exercises/text/manage/text-exercise/text-exercise-update.component.ts @@ -29,7 +29,7 @@ import { FormSectionStatus } from 'app/forms/form-status-bar/form-status-bar.com import { ExerciseUpdatePlagiarismComponent } from 'app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component'; import { TeamConfigFormGroupComponent } from 'app/exercises/shared/team-config-form-group/team-config-form-group.component'; import { FormDateTimePickerComponent } from 'app/shared/date-time-picker/date-time-picker.component'; -import { MonacoFormulaAction } from 'app/shared/monaco-editor/model/actions/formula.action'; +import { FormulaAction } from 'app/shared/monaco-editor/model/actions/formula.action'; @Component({ selector: 'jhi-text-exercise-update', @@ -66,8 +66,8 @@ export class TextExerciseUpdateComponent implements OnInit, OnDestroy, AfterView existingCategories: ExerciseCategory[]; notificationText?: string; - domainActionsProblemStatement = [new MonacoFormulaAction()]; - domainActionsExampleSolution = [new MonacoFormulaAction()]; + domainActionsProblemStatement = [new FormulaAction()]; + domainActionsExampleSolution = [new FormulaAction()]; formSectionStatus: FormSectionStatus[]; diff --git a/src/main/webapp/app/lecture/lecture-update.component.ts b/src/main/webapp/app/lecture/lecture-update.component.ts index a3b06fc83047..c7aa37c23ffc 100644 --- a/src/main/webapp/app/lecture/lecture-update.component.ts +++ b/src/main/webapp/app/lecture/lecture-update.component.ts @@ -13,7 +13,7 @@ import { DocumentationType } from 'app/shared/components/documentation-button/do import { faBan, faHandshakeAngle, faPuzzlePiece, faQuestionCircle, faSave } from '@fortawesome/free-solid-svg-icons'; import { LectureUpdateWizardComponent } from 'app/lecture/wizard-mode/lecture-update-wizard.component'; import { FILE_EXTENSIONS } from 'app/shared/constants/file-extensions.constants'; -import { MonacoFormulaAction } from 'app/shared/monaco-editor/model/actions/formula.action'; +import { FormulaAction } from 'app/shared/monaco-editor/model/actions/formula.action'; @Component({ selector: 'jhi-lecture-update', @@ -33,7 +33,7 @@ export class LectureUpdateComponent implements OnInit { courses: Course[]; - domainActionsDescription = [new MonacoFormulaAction()]; + domainActionsDescription = [new FormulaAction()]; file: File; fileName: string; fileInputTouched = false; diff --git a/src/main/webapp/app/lecture/wizard-mode/lecture-wizard-title.component.ts b/src/main/webapp/app/lecture/wizard-mode/lecture-wizard-title.component.ts index 9f626ef0b123..2c456af3f0e7 100644 --- a/src/main/webapp/app/lecture/wizard-mode/lecture-wizard-title.component.ts +++ b/src/main/webapp/app/lecture/wizard-mode/lecture-wizard-title.component.ts @@ -1,6 +1,6 @@ import { Component, Input } from '@angular/core'; import { Lecture } from 'app/entities/lecture.model'; -import { MonacoFormulaAction } from 'app/shared/monaco-editor/model/actions/formula.action'; +import { FormulaAction } from 'app/shared/monaco-editor/model/actions/formula.action'; @Component({ selector: 'jhi-lecture-update-wizard-title', @@ -10,7 +10,7 @@ export class LectureUpdateWizardTitleComponent { @Input() currentStep: number; @Input() lecture: Lecture; - domainActionsDescription = [new MonacoFormulaAction()]; + domainActionsDescription = [new FormulaAction()]; constructor() {} } diff --git a/src/main/webapp/app/shared/markdown-editor/monaco/markdown-editor-monaco.component.ts b/src/main/webapp/app/shared/markdown-editor/monaco/markdown-editor-monaco.component.ts index 3d8c6dc8590d..48c33f338542 100644 --- a/src/main/webapp/app/shared/markdown-editor/monaco/markdown-editor-monaco.component.ts +++ b/src/main/webapp/app/shared/markdown-editor/monaco/markdown-editor-monaco.component.ts @@ -15,29 +15,29 @@ import { import { MonacoEditorComponent } from 'app/shared/monaco-editor/monaco-editor.component'; import { NgbNavChangeEvent } from '@ng-bootstrap/ng-bootstrap'; import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; -import { MonacoBoldAction } from 'app/shared/monaco-editor/model/actions/bold.action'; -import { MonacoItalicAction } from 'app/shared/monaco-editor/model/actions/italic.action'; -import { MonacoUnderlineAction } from 'app/shared/monaco-editor/model/actions/underline.action'; -import { MonacoQuoteAction } from 'app/shared/monaco-editor/model/actions/quote.action'; -import { MonacoCodeAction } from 'app/shared/monaco-editor/model/actions/code.action'; -import { MonacoCodeBlockAction } from 'app/shared/monaco-editor/model/actions/code-block.action'; -import { MonacoUrlAction } from 'app/shared/monaco-editor/model/actions/url.action'; -import { MonacoAttachmentAction } from 'app/shared/monaco-editor/model/actions/attachment.action'; -import { MonacoUnorderedListAction } from 'app/shared/monaco-editor/model/actions/unordered-list.action'; -import { MonacoOrderedListAction } from 'app/shared/monaco-editor/model/actions/ordered-list.action'; +import { BoldAction } from 'app/shared/monaco-editor/model/actions/bold.action'; +import { ItalicAction } from 'app/shared/monaco-editor/model/actions/italic.action'; +import { UnderlineAction } from 'app/shared/monaco-editor/model/actions/underline.action'; +import { QuoteAction } from 'app/shared/monaco-editor/model/actions/quote.action'; +import { CodeAction } from 'app/shared/monaco-editor/model/actions/code.action'; +import { CodeBlockAction } from 'app/shared/monaco-editor/model/actions/code-block.action'; +import { UrlAction } from 'app/shared/monaco-editor/model/actions/url.action'; +import { AttachmentAction } from 'app/shared/monaco-editor/model/actions/attachment.action'; +import { UnorderedListAction } from 'app/shared/monaco-editor/model/actions/unordered-list.action'; +import { OrderedListAction } from 'app/shared/monaco-editor/model/actions/ordered-list.action'; import { faAngleDown, faGripLines, faQuestionCircle } from '@fortawesome/free-solid-svg-icons'; import { v4 as uuid } from 'uuid'; import { FileUploaderService } from 'app/shared/http/file-uploader.service'; import { AlertService, AlertType } from 'app/core/util/alert.service'; import { TextEditorActionGroup } from 'app/shared/monaco-editor/model/actions/text-editor-action-group.model'; -import { MonacoHeadingAction } from 'app/shared/monaco-editor/model/actions/heading.action'; -import { MonacoFullscreenAction } from 'app/shared/monaco-editor/model/actions/fullscreen.action'; -import { MonacoColorAction } from 'app/shared/monaco-editor/model/actions/color.action'; +import { HeadingAction } from 'app/shared/monaco-editor/model/actions/heading.action'; +import { FullscreenAction } from 'app/shared/monaco-editor/model/actions/fullscreen.action'; +import { ColorAction } from 'app/shared/monaco-editor/model/actions/color.action'; import { ColorSelectorComponent } from 'app/shared/color-selector/color-selector.component'; import { CdkDragMove, Point } from '@angular/cdk/drag-drop'; import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action.model'; import { MonacoEditorDomainActionWithOptions } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action-with-options.model'; -import { MonacoLectureAttachmentReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/lecture-attachment-reference.action'; +import { LectureAttachmentReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/lecture-attachment-reference.action'; import { LectureUnitType } from 'app/entities/lecture-unit/lectureUnit.model'; import { ReferenceType } from 'app/shared/metis/metis.util'; import { MonacoEditorOptionPreset } from 'app/shared/monaco-editor/model/monaco-editor-option-preset.model'; @@ -56,14 +56,14 @@ export enum MarkdownEditorHeight { interface MarkdownActionsByGroup { standard: TextEditorAction[]; - header: MonacoHeadingAction[]; - color?: MonacoColorAction; + header: HeadingAction[]; + color?: ColorAction; domain: { withoutOptions: TextEditorDomainAction[]; withOptions: MonacoEditorDomainActionWithOptions[]; }; // Special case due to the complex structure of lectures, attachments, and their slides - lecture?: MonacoLectureAttachmentReferenceAction; + lecture?: LectureAttachmentReferenceAction; meta: TextEditorAction[]; } @@ -144,36 +144,36 @@ export class MarkdownEditorMonacoComponent implements AfterContentInit, AfterVie @Input() defaultActions: TextEditorAction[] = [ - new MonacoBoldAction(), - new MonacoItalicAction(), - new MonacoUnderlineAction(), - new MonacoQuoteAction(), - new MonacoCodeAction(), - new MonacoCodeBlockAction('java'), - new MonacoUrlAction(), - new MonacoAttachmentAction(), - new MonacoOrderedListAction(), - new MonacoUnorderedListAction(), + new BoldAction(), + new ItalicAction(), + new UnderlineAction(), + new QuoteAction(), + new CodeAction(), + new CodeBlockAction('java'), + new UrlAction(), + new AttachmentAction(), + new OrderedListAction(), + new UnorderedListAction(), ]; @Input() - headerActions?: TextEditorActionGroup = new TextEditorActionGroup( + headerActions?: TextEditorActionGroup = new TextEditorActionGroup( 'artemisApp.multipleChoiceQuestion.editor.style', - [1, 2, 3].map((level) => new MonacoHeadingAction(level)), + [1, 2, 3].map((level) => new HeadingAction(level)), undefined, ); @Input() - lectureReferenceAction?: MonacoLectureAttachmentReferenceAction = undefined; + lectureReferenceAction?: LectureAttachmentReferenceAction = undefined; @Input() - colorAction?: MonacoColorAction = new MonacoColorAction(); + colorAction?: ColorAction = new ColorAction(); @Input() domainActions: TextEditorDomainAction[] = []; @Input() - metaActions: TextEditorAction[] = [new MonacoFullscreenAction()]; + metaActions: TextEditorAction[] = [new FullscreenAction()]; @Output() markdownChange = new EventEmitter(); @@ -304,7 +304,7 @@ export class MarkdownEditorMonacoComponent implements AfterContentInit, AfterVie ] .flat() .forEach((action) => { - if (action instanceof MonacoFullscreenAction) { + if (action instanceof FullscreenAction) { // We include the full element if the initial height is set to 'external' so the editor is resized to fill the screen. action.element = this.isInitialHeightExternal() ? this.fullElement.nativeElement : this.wrapper.nativeElement; } @@ -467,8 +467,8 @@ export class MarkdownEditorMonacoComponent implements AfterContentInit, AfterVie (response) => { const extension = file.name.split('.').last()?.toLocaleLowerCase(); - const attachmentAction: MonacoAttachmentAction | undefined = this.defaultActions.find((action) => action instanceof MonacoAttachmentAction); - const urlAction: MonacoUrlAction | undefined = this.defaultActions.find((action) => action instanceof MonacoUrlAction); + const attachmentAction: AttachmentAction | undefined = this.defaultActions.find((action) => action instanceof AttachmentAction); + const urlAction: UrlAction | undefined = this.defaultActions.find((action) => action instanceof UrlAction); if (!attachmentAction || !urlAction || !response.path) { throw new Error('Cannot process file upload.'); } diff --git a/src/main/webapp/app/shared/metis/posting-markdown-editor/posting-markdown-editor.component.ts b/src/main/webapp/app/shared/metis/posting-markdown-editor/posting-markdown-editor.component.ts index 2f72a566a72d..2ccacb086850 100644 --- a/src/main/webapp/app/shared/metis/posting-markdown-editor/posting-markdown-editor.component.ts +++ b/src/main/webapp/app/shared/metis/posting-markdown-editor/posting-markdown-editor.component.ts @@ -19,17 +19,17 @@ import { CourseManagementService } from 'app/course/manage/course-management.ser import { ChannelService } from 'app/shared/metis/conversations/channel.service'; import { isCommunicationEnabled } from 'app/entities/course.model'; import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; -import { MonacoBoldAction } from 'app/shared/monaco-editor/model/actions/bold.action'; -import { MonacoItalicAction } from 'app/shared/monaco-editor/model/actions/italic.action'; -import { MonacoUnderlineAction } from 'app/shared/monaco-editor/model/actions/underline.action'; -import { MonacoQuoteAction } from 'app/shared/monaco-editor/model/actions/quote.action'; -import { MonacoCodeAction } from 'app/shared/monaco-editor/model/actions/code.action'; -import { MonacoCodeBlockAction } from 'app/shared/monaco-editor/model/actions/code-block.action'; +import { BoldAction } from 'app/shared/monaco-editor/model/actions/bold.action'; +import { ItalicAction } from 'app/shared/monaco-editor/model/actions/italic.action'; +import { UnderlineAction } from 'app/shared/monaco-editor/model/actions/underline.action'; +import { QuoteAction } from 'app/shared/monaco-editor/model/actions/quote.action'; +import { CodeAction } from 'app/shared/monaco-editor/model/actions/code.action'; +import { CodeBlockAction } from 'app/shared/monaco-editor/model/actions/code-block.action'; import { MarkdownEditorHeight, MarkdownEditorMonacoComponent } from 'app/shared/markdown-editor/monaco/markdown-editor-monaco.component'; -import { MonacoChannelReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/channel-reference.action'; -import { MonacoUserMentionAction } from 'app/shared/monaco-editor/model/actions/communication/user-mention.action'; -import { MonacoExerciseReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/exercise-reference.action'; -import { MonacoLectureAttachmentReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/lecture-attachment-reference.action'; +import { ChannelReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/channel-reference.action'; +import { UserMentionAction } from 'app/shared/monaco-editor/model/actions/communication/user-mention.action'; +import { ExerciseReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/exercise-reference.action'; +import { LectureAttachmentReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/lecture-attachment-reference.action'; @Component({ selector: 'jhi-posting-markdown-editor', @@ -52,7 +52,7 @@ export class PostingMarkdownEditorComponent implements OnInit, ControlValueAcces @Input() isInputLengthDisplayed = true; @Input() suppressNewlineOnEnter = true; @Output() valueChange = new EventEmitter(); - lectureAttachmentReferenceAction: MonacoLectureAttachmentReferenceAction; + lectureAttachmentReferenceAction: LectureAttachmentReferenceAction; defaultActions: TextEditorAction[]; content?: string; previewMode = false; @@ -72,21 +72,21 @@ export class PostingMarkdownEditorComponent implements OnInit, ControlValueAcces */ ngOnInit(): void { const messagingOnlyActions = isCommunicationEnabled(this.metisService.getCourse()) - ? [new MonacoUserMentionAction(this.courseManagementService, this.metisService), new MonacoChannelReferenceAction(this.metisService, this.channelService)] + ? [new UserMentionAction(this.courseManagementService, this.metisService), new ChannelReferenceAction(this.metisService, this.channelService)] : []; this.defaultActions = [ - new MonacoBoldAction(), - new MonacoItalicAction(), - new MonacoUnderlineAction(), - new MonacoQuoteAction(), - new MonacoCodeAction(), - new MonacoCodeBlockAction(), + new BoldAction(), + new ItalicAction(), + new UnderlineAction(), + new QuoteAction(), + new CodeAction(), + new CodeBlockAction(), ...messagingOnlyActions, - new MonacoExerciseReferenceAction(this.metisService), + new ExerciseReferenceAction(this.metisService), ]; - this.lectureAttachmentReferenceAction = new MonacoLectureAttachmentReferenceAction(this.metisService, this.lectureService); + this.lectureAttachmentReferenceAction = new LectureAttachmentReferenceAction(this.metisService, this.lectureService); } ngAfterViewInit(): void { diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts index 316f6c1b79b2..26568f827c7a 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts @@ -32,7 +32,7 @@ export class MonacoTextEditorAdapter implements TextEditor { } executeAction(action: TextEditorAction, args?: object): void { - this.editor.trigger('MonacoTextEditorAdapter::executeAction', action.id, args); + this.editor.trigger('TextEditorAdapter::executeAction', action.id, args); } addCompleter(completer: TextEditorCompleter): Disposable { diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/attachment.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/attachment.action.ts index 0b8f7b96cb1e..72c8a82a72d4 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/attachment.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/attachment.action.ts @@ -10,11 +10,11 @@ interface AttachmentArguments { /** * Action to insert an attachment into the editor. They follow the format ![text](url). */ -export class MonacoAttachmentAction extends TextEditorAction { +export class AttachmentAction extends TextEditorAction { static readonly ID = 'monaco-attachment.action'; static readonly DEFAULT_INSERT_TEXT = '![](https://)'; constructor() { - super(MonacoAttachmentAction.ID, 'artemisApp.multipleChoiceQuestion.editor.imageUpload', faImage, undefined); + super(AttachmentAction.ID, 'artemisApp.multipleChoiceQuestion.editor.imageUpload', faImage, undefined); } /** @@ -32,7 +32,7 @@ export class MonacoAttachmentAction extends TextEditorAction { */ run(editor: TextEditor, args?: AttachmentArguments): void { if (!args?.text || !args?.url) { - this.replaceTextAtCurrentSelection(editor, MonacoAttachmentAction.DEFAULT_INSERT_TEXT); + this.replaceTextAtCurrentSelection(editor, AttachmentAction.DEFAULT_INSERT_TEXT); } else { this.replaceTextAtCurrentSelection(editor, `![${args.text}](${args.url})`); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/bold.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/bold.action.ts index 935c1b5f4d1d..21abf6417b85 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/bold.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/bold.action.ts @@ -8,11 +8,11 @@ const BOLD_DELIMITER = '**'; /** * Action to toggle bold text in the editor. It wraps the selected text with the bold delimiter, e.g. switching between text and **text**. */ -export class MonacoBoldAction extends TextEditorAction { +export class BoldAction extends TextEditorAction { static readonly ID = 'monaco-bold.action'; constructor() { - super(MonacoBoldAction.ID, 'artemisApp.multipleChoiceQuestion.editor.bold', faBold, [new TextEditorKeybinding(TextEditorKeyCode.KeyB, TextEditorKeyModifier.CtrlCmd)]); + super(BoldAction.ID, 'artemisApp.multipleChoiceQuestion.editor.bold', faBold, [new TextEditorKeybinding(TextEditorKeyCode.KeyB, TextEditorKeyModifier.CtrlCmd)]); } /** diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/code-block.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/code-block.action.ts index 8c9745caecdb..887e885e8603 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/code-block.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/code-block.action.ts @@ -7,11 +7,11 @@ const CODE_BLOCK_DELIMITER = '```'; /** * Action to toggle code block in the editor. It wraps the selected text with the code block delimiters and inserts newlines, e.g. for the default language java, switching between text and ```java\n text \n```. */ -export class MonacoCodeBlockAction extends TextEditorAction { +export class CodeBlockAction extends TextEditorAction { static readonly ID = 'monaco-code-block.action'; constructor(private readonly defaultLanguage?: string) { - super(MonacoCodeBlockAction.ID, 'artemisApp.multipleChoiceQuestion.editor.codeBlock', faFileCode, undefined); + super(CodeBlockAction.ID, 'artemisApp.multipleChoiceQuestion.editor.codeBlock', faFileCode, undefined); } /** diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/code.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/code.action.ts index 7e74cd979f05..c3dac56953cd 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/code.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/code.action.ts @@ -7,10 +7,10 @@ const CODE_DELIMITER = '`'; /** * Action to toggle code text in the editor. It wraps the selected text with the code delimiter, e.g. switching between text and `text`. */ -export class MonacoCodeAction extends TextEditorAction { +export class CodeAction extends TextEditorAction { static readonly ID = 'monaco-code.action'; constructor() { - super(MonacoCodeAction.ID, 'artemisApp.multipleChoiceQuestion.editor.code', faCode, undefined); + super(CodeAction.ID, 'artemisApp.multipleChoiceQuestion.editor.code', faCode, undefined); } /** diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/color.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/color.action.ts index 21df3f944ade..de3546d693ed 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/color.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/color.action.ts @@ -10,11 +10,11 @@ const CLOSE_DELIMITER = ''; /** * Action to toggle color text in the editor. It wraps the selected text with the color delimiter, e.g. switching between text and text. */ -export class MonacoColorAction extends TextEditorAction { +export class ColorAction extends TextEditorAction { static readonly ID = 'monaco-color.action'; constructor() { - super(MonacoColorAction.ID, 'artemisApp.multipleChoiceQuestion.editor.color', undefined, undefined); + super(ColorAction.ID, 'artemisApp.multipleChoiceQuestion.editor.color', undefined, undefined); } /** diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/channel-reference.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/channel-reference.action.ts index cdc08f485973..add5f10791bd 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/channel-reference.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/channel-reference.action.ts @@ -13,7 +13,7 @@ import { TextEditorCompletionItem, TextEditorCompletionItemKind } from 'app/shar /** * Action to insert a reference to a channel into the editor. Users that type a # will see a list of available channels to reference. */ -export class MonacoChannelReferenceAction extends TextEditorAction { +export class ChannelReferenceAction extends TextEditorAction { static readonly ID = 'monaco-channel-reference.action'; static readonly DEFAULT_INSERT_TEXT = '#'; @@ -24,7 +24,7 @@ export class MonacoChannelReferenceAction extends TextEditorAction { private readonly metisService: MetisService, private readonly channelService: ChannelService, ) { - super(MonacoChannelReferenceAction.ID, 'artemisApp.metis.editor.channel', faHashtag); + super(ChannelReferenceAction.ID, 'artemisApp.metis.editor.channel', faHashtag); } /** @@ -48,7 +48,7 @@ export class MonacoChannelReferenceAction extends TextEditorAction { * @param editor The editor to type the text into. */ run(editor: TextEditor) { - this.typeText(editor, MonacoChannelReferenceAction.DEFAULT_INSERT_TEXT); + this.typeText(editor, ChannelReferenceAction.DEFAULT_INSERT_TEXT); editor.focus(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/exercise-reference.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/exercise-reference.action.ts index 546474f9aa77..e4d3005a6496 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/exercise-reference.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/exercise-reference.action.ts @@ -10,14 +10,14 @@ import { TextEditorRange } from 'app/shared/monaco-editor/model/actions/adapter/ /** * Action to insert a reference to an exercise into the editor. Users that type a / will see a list of available exercises to reference. */ -export class MonacoExerciseReferenceAction extends MonacoEditorDomainActionWithOptions { +export class ExerciseReferenceAction extends MonacoEditorDomainActionWithOptions { static readonly ID = 'monaco-exercise-reference.action'; static readonly DEFAULT_INSERT_TEXT = '/exercise'; disposableCompletionProvider?: Disposable; constructor(private readonly metisService: MetisService) { - super(MonacoExerciseReferenceAction.ID, 'artemisApp.metis.editor.exercise'); + super(ExerciseReferenceAction.ID, 'artemisApp.metis.editor.exercise'); } /** @@ -56,7 +56,7 @@ export class MonacoExerciseReferenceAction extends MonacoEditorDomainActionWithO * @param editor The editor to type the text into. */ run(editor: TextEditor): void { - this.typeText(editor, MonacoExerciseReferenceAction.DEFAULT_INSERT_TEXT); + this.typeText(editor, ExerciseReferenceAction.DEFAULT_INSERT_TEXT); editor.focus(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/lecture-attachment-reference.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/lecture-attachment-reference.action.ts index 8fcfcabae422..b6da28731e20 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/lecture-attachment-reference.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/lecture-attachment-reference.action.ts @@ -28,7 +28,7 @@ interface LectureAttachmentReferenceActionArgs { * Action to insert a reference to a lecture, attachment, slide, or attachment unit into the editor. * The specific format of the reference depends on the type of reference. */ -export class MonacoLectureAttachmentReferenceAction extends TextEditorAction { +export class LectureAttachmentReferenceAction extends TextEditorAction { static readonly ID = 'monaco-lecture-attachment-reference.action'; lecturesWithDetails: LectureWithDetails[] = []; @@ -37,7 +37,7 @@ export class MonacoLectureAttachmentReferenceAction extends TextEditorAction { private readonly metisService: MetisService, private readonly lectureService: LectureService, ) { - super(MonacoLectureAttachmentReferenceAction.ID, 'artemisApp.metis.editor.lecture'); + super(LectureAttachmentReferenceAction.ID, 'artemisApp.metis.editor.lecture'); firstValueFrom(this.lectureService.findAllByCourseIdWithSlides(this.metisService.getCourse().id!)).then((response) => { const lectures = response.body; if (lectures) { diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/user-mention.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/user-mention.action.ts index 66e26840bfa4..47e1afb69a3c 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/user-mention.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/user-mention.action.ts @@ -14,7 +14,7 @@ import { TextEditorCompletionItem, TextEditorCompletionItemKind } from 'app/shar * Action to insert a user mention into the editor. Users that type a @ will see a list of available users to mention. * Users will be fetched repeatedly as the user types to provide up-to-date results. */ -export class MonacoUserMentionAction extends TextEditorAction { +export class UserMentionAction extends TextEditorAction { disposableCompletionProvider?: Disposable; static readonly ID = 'monaco-user-mention.action'; @@ -24,7 +24,7 @@ export class MonacoUserMentionAction extends TextEditorAction { private readonly courseManagementService: CourseManagementService, private readonly metisService: MetisService, ) { - super(MonacoUserMentionAction.ID, 'artemisApp.metis.editor.user', faAt); + super(UserMentionAction.ID, 'artemisApp.metis.editor.user', faAt); } /** @@ -49,7 +49,7 @@ export class MonacoUserMentionAction extends TextEditorAction { * @param editor The editor to type the text into. */ run(editor: TextEditor) { - this.typeText(editor, MonacoUserMentionAction.DEFAULT_INSERT_TEXT); + this.typeText(editor, UserMentionAction.DEFAULT_INSERT_TEXT); editor.focus(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/formula.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/formula.action.ts index 70a120476f00..da32fa143041 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/formula.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/formula.action.ts @@ -7,11 +7,11 @@ const FORMULA_CLOSE_DELIMITER = ' $$'; /** * Action to toggle formula text in the editor. It wraps the selected text with the formula delimiter, e.g. switching between text and $$ text $$. */ -export class MonacoFormulaAction extends TextEditorDomainAction { +export class FormulaAction extends TextEditorDomainAction { static readonly ID = 'monaco-formula.action'; static readonly DEFAULT_FORMULA = 'e^{\\frac{1}{4} y^2}'; constructor() { - super(MonacoFormulaAction.ID, 'artemisApp.markdownEditor.commands.katex', undefined, undefined); + super(FormulaAction.ID, 'artemisApp.markdownEditor.commands.katex', undefined, undefined); } /** @@ -20,7 +20,7 @@ export class MonacoFormulaAction extends TextEditorDomainAction { * @param editor The editor in which to toggle formula text. */ run(editor: TextEditor) { - this.toggleDelimiterAroundSelection(editor, this.getOpeningIdentifier(), FORMULA_CLOSE_DELIMITER, MonacoFormulaAction.DEFAULT_FORMULA); + this.toggleDelimiterAroundSelection(editor, this.getOpeningIdentifier(), FORMULA_CLOSE_DELIMITER, FormulaAction.DEFAULT_FORMULA); editor.focus(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/fullscreen.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/fullscreen.action.ts index 2fdf51aa1461..b5f561dbb44a 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/fullscreen.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/fullscreen.action.ts @@ -6,13 +6,13 @@ import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text- /** * Action to toggle fullscreen mode in the editor. */ -export class MonacoFullscreenAction extends TextEditorAction { +export class FullscreenAction extends TextEditorAction { static readonly ID = 'monaco-fullscreen.action'; element?: HTMLElement; constructor() { - super(MonacoFullscreenAction.ID, 'artemisApp.markdownEditor.commands.fullscreen', faCompress); + super(FullscreenAction.ID, 'artemisApp.markdownEditor.commands.fullscreen', faCompress); } /** diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-credits.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-credits.action.ts index 4a8c19394ef7..0048fa3592ae 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-credits.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-credits.action.ts @@ -1,20 +1,20 @@ import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action.model'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; -export class MonacoGradingCreditsAction extends TextEditorDomainAction { +export class GradingCreditsAction extends TextEditorDomainAction { static readonly ID = 'monaco-grading-credits.action'; static readonly IDENTIFIER = '[credits]'; static readonly TEXT = '0'; constructor() { - super(MonacoGradingCreditsAction.ID, 'artemisApp.assessmentInstructions.instructions.editor.addCredits', undefined, undefined, true); + super(GradingCreditsAction.ID, 'artemisApp.assessmentInstructions.instructions.editor.addCredits', undefined, undefined, true); } run(editor: TextEditor): void { - this.addTextWithDomainActionIdentifier(editor, MonacoGradingCreditsAction.TEXT, true, false); + this.addTextWithDomainActionIdentifier(editor, GradingCreditsAction.TEXT, true, false); } getOpeningIdentifier(): string { - return MonacoGradingCreditsAction.IDENTIFIER; + return GradingCreditsAction.IDENTIFIER; } } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-criterion.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-criterion.action.ts index 579fb2ad0703..812814fceb09 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-criterion.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-criterion.action.ts @@ -1,22 +1,22 @@ import { TextEditorDomainAction } from '../text-editor-domain-action.model'; -import { MonacoGradingInstructionAction } from './grading-instruction.action'; +import { GradingInstructionAction } from './grading-instruction.action'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; -export class MonacoGradingCriterionAction extends TextEditorDomainAction { +export class GradingCriterionAction extends TextEditorDomainAction { static readonly ID = 'monaco-grading-criterion.action'; static readonly IDENTIFIER = '[criterion]'; static readonly TEXT = 'Add criterion title (only visible to tutors)'; - constructor(private readonly gradingInstructionAction: MonacoGradingInstructionAction) { - super(MonacoGradingCriterionAction.ID, 'artemisApp.assessmentInstructions.instructions.editor.addCriterion'); + constructor(private readonly gradingInstructionAction: GradingInstructionAction) { + super(GradingCriterionAction.ID, 'artemisApp.assessmentInstructions.instructions.editor.addCriterion'); } run(editor: TextEditor): void { - this.addTextWithDomainActionIdentifier(editor, MonacoGradingCriterionAction.TEXT, false, false); + this.addTextWithDomainActionIdentifier(editor, GradingCriterionAction.TEXT, false, false); this.gradingInstructionAction.executeInCurrentEditor(); } getOpeningIdentifier(): string { - return MonacoGradingCriterionAction.IDENTIFIER; + return GradingCriterionAction.IDENTIFIER; } } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-description.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-description.action.ts index 57128d604ae4..821973aa4e26 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-description.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-description.action.ts @@ -1,20 +1,20 @@ import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action.model'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; -export class MonacoGradingDescriptionAction extends TextEditorDomainAction { +export class GradingDescriptionAction extends TextEditorDomainAction { static readonly ID = 'monaco-grading-description.action'; static readonly IDENTIFIER = '[description]'; static readonly TEXT = 'Add grading instruction here (only visible for tutors)'; constructor() { - super(MonacoGradingDescriptionAction.ID, 'artemisApp.assessmentInstructions.instructions.editor.addDescription', undefined, undefined, true); + super(GradingDescriptionAction.ID, 'artemisApp.assessmentInstructions.instructions.editor.addDescription', undefined, undefined, true); } run(editor: TextEditor): void { - this.addTextWithDomainActionIdentifier(editor, MonacoGradingDescriptionAction.TEXT, true, false); + this.addTextWithDomainActionIdentifier(editor, GradingDescriptionAction.TEXT, true, false); } getOpeningIdentifier(): string { - return MonacoGradingDescriptionAction.IDENTIFIER; + return GradingDescriptionAction.IDENTIFIER; } } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-feedback.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-feedback.action.ts index 221e910d2c1c..c2b131717425 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-feedback.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-feedback.action.ts @@ -1,20 +1,20 @@ import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action.model'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; -export class MonacoGradingFeedbackAction extends TextEditorDomainAction { +export class GradingFeedbackAction extends TextEditorDomainAction { static readonly ID = 'monaco-grading-feedback.action'; static readonly IDENTIFIER = '[feedback]'; static readonly TEXT = 'Add feedback for students here (visible for students)'; constructor() { - super(MonacoGradingFeedbackAction.ID, 'artemisApp.assessmentInstructions.instructions.editor.addFeedback', undefined, undefined, true); + super(GradingFeedbackAction.ID, 'artemisApp.assessmentInstructions.instructions.editor.addFeedback', undefined, undefined, true); } run(editor: TextEditor): void { - this.addTextWithDomainActionIdentifier(editor, MonacoGradingFeedbackAction.TEXT, true, false); + this.addTextWithDomainActionIdentifier(editor, GradingFeedbackAction.TEXT, true, false); } getOpeningIdentifier(): string { - return MonacoGradingFeedbackAction.IDENTIFIER; + return GradingFeedbackAction.IDENTIFIER; } } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-instruction.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-instruction.action.ts index 1ea93393c280..bc4c3ed6b4e4 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-instruction.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-instruction.action.ts @@ -1,23 +1,23 @@ import { TextEditorDomainAction } from '../text-editor-domain-action.model'; -import { MonacoGradingCreditsAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-credits.action'; -import { MonacoGradingScaleAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-scale.action'; -import { MonacoGradingDescriptionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-description.action'; -import { MonacoGradingFeedbackAction } from './grading-feedback.action'; -import { MonacoGradingUsageCountAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-usage-count.action'; +import { GradingCreditsAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-credits.action'; +import { GradingScaleAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-scale.action'; +import { GradingDescriptionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-description.action'; +import { GradingFeedbackAction } from './grading-feedback.action'; +import { GradingUsageCountAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-usage-count.action'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; -export class MonacoGradingInstructionAction extends TextEditorDomainAction { +export class GradingInstructionAction extends TextEditorDomainAction { static readonly ID = 'monaco-grading-instruction.action'; static readonly IDENTIFIER = '[instruction]'; constructor( - private readonly creditsAction: MonacoGradingCreditsAction, - private readonly scaleAction: MonacoGradingScaleAction, - private readonly descriptionAction: MonacoGradingDescriptionAction, - private readonly feedbackAction: MonacoGradingFeedbackAction, - private readonly usageCountAction: MonacoGradingUsageCountAction, + private readonly creditsAction: GradingCreditsAction, + private readonly scaleAction: GradingScaleAction, + private readonly descriptionAction: GradingDescriptionAction, + private readonly feedbackAction: GradingFeedbackAction, + private readonly usageCountAction: GradingUsageCountAction, ) { - super(MonacoGradingInstructionAction.ID, 'artemisApp.assessmentInstructions.instructions.editor.addInstruction'); + super(GradingInstructionAction.ID, 'artemisApp.assessmentInstructions.instructions.editor.addInstruction'); } run(editor: TextEditor): void { @@ -30,6 +30,6 @@ export class MonacoGradingInstructionAction extends TextEditorDomainAction { } getOpeningIdentifier(): string { - return MonacoGradingInstructionAction.IDENTIFIER; + return GradingInstructionAction.IDENTIFIER; } } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-scale.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-scale.action.ts index 6315f6cf7373..352e223a30b2 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-scale.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-scale.action.ts @@ -1,20 +1,20 @@ import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action.model'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; -export class MonacoGradingScaleAction extends TextEditorDomainAction { +export class GradingScaleAction extends TextEditorDomainAction { static readonly ID = 'monaco-grading-scale.action'; static readonly IDENTIFIER = '[gradingScale]'; static readonly TEXT = 'Add instruction grading scale here (only visible for tutors)'; constructor() { - super(MonacoGradingScaleAction.ID, 'artemisApp.assessmentInstructions.instructions.editor.addScale', undefined, undefined, true); + super(GradingScaleAction.ID, 'artemisApp.assessmentInstructions.instructions.editor.addScale', undefined, undefined, true); } run(editor: TextEditor): void { - this.addTextWithDomainActionIdentifier(editor, MonacoGradingScaleAction.TEXT, true, false); + this.addTextWithDomainActionIdentifier(editor, GradingScaleAction.TEXT, true, false); } getOpeningIdentifier(): string { - return MonacoGradingScaleAction.IDENTIFIER; + return GradingScaleAction.IDENTIFIER; } } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-usage-count.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-usage-count.action.ts index 67eae36d2769..695e9061925b 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-usage-count.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-usage-count.action.ts @@ -1,20 +1,20 @@ import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action.model'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; -export class MonacoGradingUsageCountAction extends TextEditorDomainAction { +export class GradingUsageCountAction extends TextEditorDomainAction { static readonly ID = 'monaco-grading-usage-count.action'; static readonly IDENTIFIER = '[maxCountInScore]'; static readonly TEXT = '0'; constructor() { - super(MonacoGradingUsageCountAction.ID, 'artemisApp.assessmentInstructions.instructions.editor.addUsageCount', undefined, undefined, true); + super(GradingUsageCountAction.ID, 'artemisApp.assessmentInstructions.instructions.editor.addUsageCount', undefined, undefined, true); } run(editor: TextEditor): void { - this.addTextWithDomainActionIdentifier(editor, MonacoGradingUsageCountAction.TEXT, true, false); + this.addTextWithDomainActionIdentifier(editor, GradingUsageCountAction.TEXT, true, false); } getOpeningIdentifier(): string { - return MonacoGradingUsageCountAction.IDENTIFIER; + return GradingUsageCountAction.IDENTIFIER; } } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/heading.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/heading.action.ts index 0849ecbfbc1b..6a190e11effa 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/heading.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/heading.action.ts @@ -13,7 +13,7 @@ const HEADING_TEXT = 'Heading'; /** * Action to toggle heading text in the editor. It wraps the selected text with the heading delimiter, e.g. switching between text and # text for level 1. */ -export class MonacoHeadingAction extends TextEditorAction { +export class HeadingAction extends TextEditorAction { level: number; /** diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/italic.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/italic.action.ts index 596476efe93d..b7cce6906687 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/italic.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/italic.action.ts @@ -8,12 +8,10 @@ const ITALIC_DELIMITER = '*'; /** * Action to toggle italic text in the editor. It wraps the selected text with the italic delimiter, e.g. switching between text and *text*. */ -export class MonacoItalicAction extends TextEditorAction { +export class ItalicAction extends TextEditorAction { static readonly ID = 'monaco-italic.action'; constructor() { - super(MonacoItalicAction.ID, 'artemisApp.multipleChoiceQuestion.editor.italic', faItalic, [ - new TextEditorKeybinding(TextEditorKeyCode.KeyI, TextEditorKeyModifier.CtrlCmd), - ]); + super(ItalicAction.ID, 'artemisApp.multipleChoiceQuestion.editor.italic', faItalic, [new TextEditorKeybinding(TextEditorKeyCode.KeyI, TextEditorKeyModifier.CtrlCmd)]); } /** diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/ordered-list.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/ordered-list.action.ts index 8b77bbb2d1eb..a86ed80ad04c 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/ordered-list.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/ordered-list.action.ts @@ -9,10 +9,10 @@ const NUMBER_REGEX = /^\d+\.\s.*/; /** * Action to toggle unordered list in the editor. It toggles the "1. ", "2. ", ... prefix for the entire selection. */ -export class MonacoOrderedListAction extends TextEditorAction { +export class OrderedListAction extends TextEditorAction { static readonly ID = 'monaco-ordered-list.action'; constructor() { - super(MonacoOrderedListAction.ID, 'artemisApp.multipleChoiceQuestion.editor.orderedList', faListOl, undefined); + super(OrderedListAction.ID, 'artemisApp.multipleChoiceQuestion.editor.orderedList', faListOl, undefined); } /** diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/correct-multiple-choice-answer.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/correct-multiple-choice-answer.action.ts index a6e206458ff1..a491e9ee0115 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/correct-multiple-choice-answer.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/correct-multiple-choice-answer.action.ts @@ -1,20 +1,20 @@ import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action.model'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; -export class MonacoCorrectMultipleChoiceAnswerAction extends TextEditorDomainAction { +export class CorrectMultipleChoiceAnswerAction extends TextEditorDomainAction { static readonly ID = 'artemisApp.multipleChoiceQuestion.editor.addCorrectAnswerOption'; static readonly IDENTIFIER = '[correct]'; static readonly TEXT = 'Enter a correct answer option here'; constructor() { - super(MonacoCorrectMultipleChoiceAnswerAction.ID, 'artemisApp.multipleChoiceQuestion.editor.addCorrectAnswerOption'); + super(CorrectMultipleChoiceAnswerAction.ID, 'artemisApp.multipleChoiceQuestion.editor.addCorrectAnswerOption'); } run(editor: TextEditor): void { - this.addTextWithDomainActionIdentifier(editor, MonacoCorrectMultipleChoiceAnswerAction.TEXT); + this.addTextWithDomainActionIdentifier(editor, CorrectMultipleChoiceAnswerAction.TEXT); } getOpeningIdentifier(): string { - return MonacoCorrectMultipleChoiceAnswerAction.IDENTIFIER; + return CorrectMultipleChoiceAnswerAction.IDENTIFIER; } } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/insert-short-answer-option.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/insert-short-answer-option.action.ts index 4716143c6894..5e466229d360 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/insert-short-answer-option.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/insert-short-answer-option.action.ts @@ -10,14 +10,14 @@ interface InsertShortAnswerOptionArgs { /** * Action to insert a short answer option ([-option #] Option text) at the end of the editor. */ -export class MonacoInsertShortAnswerOptionAction extends TextEditorAction { +export class InsertShortAnswerOptionAction extends TextEditorAction { static readonly ID = 'monaco-insert-short-answer-option.action'; static readonly DEFAULT_TEXT = 'Enter an answer option here and ensure the spot number is correct.'; static readonly DEFAULT_TEXT_SHORT = 'Enter an answer option here.'; constructor() { - super(MonacoInsertShortAnswerOptionAction.ID, 'artemisApp.shortAnswerQuestion.editor.addOption', undefined); - this.id = MonacoInsertShortAnswerOptionAction.ID; + super(InsertShortAnswerOptionAction.ID, 'artemisApp.shortAnswerQuestion.editor.addOption', undefined); + this.id = InsertShortAnswerOptionAction.ID; this.translationKey = 'artemisApp.shortAnswerQuestion.editor.addOption'; } @@ -32,7 +32,7 @@ export class MonacoInsertShortAnswerOptionAction extends TextEditorAction { */ run(editor: TextEditor, args?: InsertShortAnswerOptionArgs): void { // Note that even if the optionText is provided, it may be blank. This is why we use || instead of ?? here. - const optionText = args?.optionText || MonacoInsertShortAnswerOptionAction.DEFAULT_TEXT; + const optionText = args?.optionText || InsertShortAnswerOptionAction.DEFAULT_TEXT; let insertedText: string; if (args?.spotNumber) { insertedText = `\n[-option ${args.spotNumber}] ${optionText}`; @@ -45,11 +45,11 @@ export class MonacoInsertShortAnswerOptionAction extends TextEditorAction { } this.insertTextAtPosition(editor, this.getEndPosition(editor), insertedText); // For convenience, we want to select the option text if it is the default text - if (optionText === MonacoInsertShortAnswerOptionAction.DEFAULT_TEXT) { + if (optionText === InsertShortAnswerOptionAction.DEFAULT_TEXT) { const newEndPosition = this.getEndPosition(editor); const selection = makeTextEditorRange( newEndPosition.getLineNumber(), - newEndPosition.getColumn() - MonacoInsertShortAnswerOptionAction.DEFAULT_TEXT.length, + newEndPosition.getColumn() - InsertShortAnswerOptionAction.DEFAULT_TEXT.length, newEndPosition.getLineNumber(), newEndPosition.getColumn(), ); diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/insert-short-answer-spot.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/insert-short-answer-spot.action.ts index b6b2777a9f56..2fe715ff76d7 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/insert-short-answer-spot.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/insert-short-answer-spot.action.ts @@ -1,20 +1,20 @@ import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; -import { MonacoInsertShortAnswerOptionAction } from 'app/shared/monaco-editor/model/actions/quiz/insert-short-answer-option.action'; +import { InsertShortAnswerOptionAction } from 'app/shared/monaco-editor/model/actions/quiz/insert-short-answer-option.action'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; /** * Action to insert a short answer spot at the current cursor position. * After inserting the spot, this action also inserts an option linked to the spot. */ -export class MonacoInsertShortAnswerSpotAction extends TextEditorAction { +export class InsertShortAnswerSpotAction extends TextEditorAction { static readonly ID = 'monaco-insert-short-answer-spot.action'; spotNumber = 1; /** * @param insertShortAnswerOptionAction The action to insert a short answer option. This action will be executed after inserting the spot. Must be registered in the same editor. */ - constructor(readonly insertShortAnswerOptionAction: MonacoInsertShortAnswerOptionAction) { - super(MonacoInsertShortAnswerSpotAction.ID, 'artemisApp.shortAnswerQuestion.editor.addSpot', undefined); + constructor(readonly insertShortAnswerOptionAction: InsertShortAnswerOptionAction) { + super(InsertShortAnswerSpotAction.ID, 'artemisApp.shortAnswerQuestion.editor.addSpot', undefined); } /** diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/quiz-explanation.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/quiz-explanation.action.ts index d6d28b9e8304..fad84bbfe34f 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/quiz-explanation.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/quiz-explanation.action.ts @@ -1,20 +1,20 @@ import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action.model'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; -export class MonacoQuizExplanationAction extends TextEditorDomainAction { +export class QuizExplanationAction extends TextEditorDomainAction { static readonly ID = 'monaco-quiz-explanation.action'; static readonly IDENTIFIER = '[exp]'; static readonly TEXT = 'Add an explanation here (only visible in feedback after quiz has ended)'; constructor() { - super(MonacoQuizExplanationAction.ID, 'artemisApp.multipleChoiceQuestion.editor.addExplanation'); + super(QuizExplanationAction.ID, 'artemisApp.multipleChoiceQuestion.editor.addExplanation'); } run(editor: TextEditor): void { - this.addTextWithDomainActionIdentifier(editor, MonacoQuizExplanationAction.TEXT, true); + this.addTextWithDomainActionIdentifier(editor, QuizExplanationAction.TEXT, true); } getOpeningIdentifier(): string { - return MonacoQuizExplanationAction.IDENTIFIER; + return QuizExplanationAction.IDENTIFIER; } } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/quiz-hint.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/quiz-hint.action.ts index a31a59321579..79981de58658 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/quiz-hint.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/quiz-hint.action.ts @@ -1,20 +1,20 @@ import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action.model'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; -export class MonacoQuizHintAction extends TextEditorDomainAction { +export class QuizHintAction extends TextEditorDomainAction { static readonly ID = 'monaco-quiz-hint.action'; static readonly IDENTIFIER = '[hint]'; static readonly TEXT = 'Add a hint here (visible during the quiz via ?-Button)'; constructor() { - super(MonacoQuizHintAction.ID, 'artemisApp.multipleChoiceQuestion.editor.addHint'); + super(QuizHintAction.ID, 'artemisApp.multipleChoiceQuestion.editor.addHint'); } run(editor: TextEditor): void { - this.addTextWithDomainActionIdentifier(editor, MonacoQuizHintAction.TEXT, true); + this.addTextWithDomainActionIdentifier(editor, QuizHintAction.TEXT, true); } getOpeningIdentifier(): string { - return MonacoQuizHintAction.IDENTIFIER; + return QuizHintAction.IDENTIFIER; } } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/wrong-multiple-choice-answer.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/wrong-multiple-choice-answer.action.ts index 283fae9ae12f..0c998678045b 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/wrong-multiple-choice-answer.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/wrong-multiple-choice-answer.action.ts @@ -1,20 +1,20 @@ import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action.model'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; -export class MonacoWrongMultipleChoiceAnswerAction extends TextEditorDomainAction { +export class WrongMultipleChoiceAnswerAction extends TextEditorDomainAction { static readonly ID = 'monaco-incorrect-multiple-choice-answer.action'; static readonly IDENTIFIER = '[wrong]'; static readonly TEXT = 'Enter a wrong answer option here'; constructor() { - super(MonacoWrongMultipleChoiceAnswerAction.ID, 'artemisApp.multipleChoiceQuestion.editor.addInCorrectAnswerOption'); + super(WrongMultipleChoiceAnswerAction.ID, 'artemisApp.multipleChoiceQuestion.editor.addInCorrectAnswerOption'); } run(editor: TextEditor): void { - this.addTextWithDomainActionIdentifier(editor, MonacoWrongMultipleChoiceAnswerAction.TEXT); + this.addTextWithDomainActionIdentifier(editor, WrongMultipleChoiceAnswerAction.TEXT); } getOpeningIdentifier(): string { - return MonacoWrongMultipleChoiceAnswerAction.IDENTIFIER; + return WrongMultipleChoiceAnswerAction.IDENTIFIER; } } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quote.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quote.action.ts index 2c4b3d6464b1..2fc396a308c2 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quote.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quote.action.ts @@ -7,10 +7,10 @@ const QUOTE_OPEN_DELIMITER = '> '; /** * Action to toggle quote text in the editor. It wraps the selected text with the quote delimiter, e.g. switching between text and > text. */ -export class MonacoQuoteAction extends TextEditorAction { +export class QuoteAction extends TextEditorAction { static readonly ID = 'monaco-quote.action'; constructor() { - super(MonacoQuoteAction.ID, 'artemisApp.multipleChoiceQuestion.editor.quote', faQuoteLeft, undefined); + super(QuoteAction.ID, 'artemisApp.multipleChoiceQuestion.editor.quote', faQuoteLeft, undefined); } /** diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/task.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/task.action.ts index 5970870a5899..7eb4bf98a51f 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/task.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/task.action.ts @@ -5,14 +5,14 @@ import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text- /** * Action to insert a task into the editor. They follow the format [task][Task Short Description](testCaseName). */ -export class MonacoTaskAction extends TextEditorDomainAction { +export class TaskAction extends TextEditorDomainAction { static readonly ID = 'monaco-task.action'; static readonly TEXT = '[Task Short Description](testCaseName)\n'; static readonly IDENTIFIER = '[task]'; - static readonly GLOBAL_TASK_REGEX = new RegExp(`${escapeStringForUseInRegex(MonacoTaskAction.IDENTIFIER)}(.*)`, 'g'); + static readonly GLOBAL_TASK_REGEX = new RegExp(`${escapeStringForUseInRegex(TaskAction.IDENTIFIER)}(.*)`, 'g'); constructor() { - super(MonacoTaskAction.ID, 'artemisApp.programmingExercise.problemStatement.taskCommand', undefined, undefined); + super(TaskAction.ID, 'artemisApp.programmingExercise.problemStatement.taskCommand', undefined, undefined); } /** @@ -20,11 +20,11 @@ export class MonacoTaskAction extends TextEditorDomainAction { * @param editor The editor in which to insert the task. */ run(editor: TextEditor): void { - this.replaceTextAtCurrentSelection(editor, `${this.getOpeningIdentifier()}${MonacoTaskAction.TEXT}`); + this.replaceTextAtCurrentSelection(editor, `${this.getOpeningIdentifier()}${TaskAction.TEXT}`); editor.focus(); } getOpeningIdentifier(): string { - return MonacoTaskAction.IDENTIFIER; + return TaskAction.IDENTIFIER; } } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/test-case.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/test-case.action.ts index 799bdbfdc4aa..808dd89ee33b 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/test-case.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/test-case.action.ts @@ -9,14 +9,14 @@ import { TextEditorCompletionItem, TextEditorCompletionItemKind } from 'app/shar /** * Action to insert a test case into the editor. It also registers a completion item provider offers all possible test cases as completion items to the user. */ -export class MonacoTestCaseAction extends MonacoEditorDomainActionWithOptions { +export class TestCaseAction extends MonacoEditorDomainActionWithOptions { disposableCompletionProvider?: Disposable; static readonly ID = 'monaco-test-case.action'; static readonly DEFAULT_INSERT_TEXT = 'testCaseName()'; constructor() { - super(MonacoTestCaseAction.ID, 'artemisApp.programmingExercise.problemStatement.testCaseCommand', undefined, undefined); + super(TestCaseAction.ID, 'artemisApp.programmingExercise.problemStatement.testCaseCommand', undefined, undefined); } /** @@ -48,7 +48,7 @@ export class MonacoTestCaseAction extends MonacoEditorDomainActionWithOptions { } run(editor: TextEditor, args?: DomainActionWithOptionsArguments) { - this.replaceTextAtCurrentSelection(editor, args?.selectedItem?.value ?? MonacoTestCaseAction.DEFAULT_INSERT_TEXT); + this.replaceTextAtCurrentSelection(editor, args?.selectedItem?.value ?? TestCaseAction.DEFAULT_INSERT_TEXT); editor.focus(); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/underline.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/underline.action.ts index a402bb3f37a6..5c1dab0993fc 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/underline.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/underline.action.ts @@ -9,10 +9,10 @@ const UNDERLINE_CLOSE_DELIMITER = ''; /** * Action to toggle underline text in the editor. It wraps the selected text with the underline delimiter, e.g. switching between text and text. */ -export class MonacoUnderlineAction extends TextEditorAction { +export class UnderlineAction extends TextEditorAction { static readonly ID = 'monaco-underline.action'; constructor() { - super(MonacoUnderlineAction.ID, 'artemisApp.multipleChoiceQuestion.editor.underline', faUnderline, [ + super(UnderlineAction.ID, 'artemisApp.multipleChoiceQuestion.editor.underline', faUnderline, [ new TextEditorKeybinding(TextEditorKeyCode.KeyU, TextEditorKeyModifier.CtrlCmd), ]); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/unordered-list.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/unordered-list.action.ts index f34550a02891..20f7cf40e019 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/unordered-list.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/unordered-list.action.ts @@ -9,10 +9,10 @@ const LIST_BULLET = '- '; /** * Action to toggle unordered list in the editor. It toggles the "- " prefix for the entire selection. */ -export class MonacoUnorderedListAction extends TextEditorAction { +export class UnorderedListAction extends TextEditorAction { static readonly ID = 'monaco-unordered-list.action'; constructor() { - super(MonacoUnorderedListAction.ID, 'artemisApp.multipleChoiceQuestion.editor.unorderedList', faListUl, undefined); + super(UnorderedListAction.ID, 'artemisApp.multipleChoiceQuestion.editor.unorderedList', faListUl, undefined); } /** diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/url.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/url.action.ts index 6f66d3bcd0b5..cd4edc477024 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/url.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/url.action.ts @@ -10,12 +10,12 @@ interface UrlArguments { /** * Action to insert a URL into the editor. They follow the format [text](url). */ -export class MonacoUrlAction extends TextEditorAction { +export class UrlAction extends TextEditorAction { static readonly ID = 'monaco-url.action'; static readonly DEFAULT_INSERT_TEXT = '[](https://)'; constructor() { - super(MonacoUrlAction.ID, 'artemisApp.multipleChoiceQuestion.editor.link', faLink, undefined); + super(UrlAction.ID, 'artemisApp.multipleChoiceQuestion.editor.link', faLink, undefined); } /** @@ -33,7 +33,7 @@ export class MonacoUrlAction extends TextEditorAction { */ run(editor: TextEditor, args?: UrlArguments): void { if (!args?.text || !args?.url) { - this.replaceTextAtCurrentSelection(editor, MonacoUrlAction.DEFAULT_INSERT_TEXT); + this.replaceTextAtCurrentSelection(editor, UrlAction.DEFAULT_INSERT_TEXT); } else { this.replaceTextAtCurrentSelection(editor, `[${args.text}](${args.url})`); } diff --git a/src/main/webapp/app/shared/util/markdown.util.ts b/src/main/webapp/app/shared/util/markdown.util.ts index a43274f88fc9..da53345a886d 100644 --- a/src/main/webapp/app/shared/util/markdown.util.ts +++ b/src/main/webapp/app/shared/util/markdown.util.ts @@ -1,18 +1,15 @@ import { ExerciseHintExplanationInterface } from 'app/entities/quiz/quiz-question.model'; import { escapeStringForUseInRegex } from 'app/shared/util/global.utils'; -import { MonacoQuizExplanationAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-explanation.action'; -import { MonacoQuizHintAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-hint.action'; +import { QuizExplanationAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-explanation.action'; +import { QuizHintAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-hint.action'; -const hintOrExpRegex = new RegExp( - escapeStringForUseInRegex(`${MonacoQuizExplanationAction.IDENTIFIER}`) + '|' + escapeStringForUseInRegex(`${MonacoQuizHintAction.IDENTIFIER}`), - 'g', -); +const hintOrExpRegex = new RegExp(escapeStringForUseInRegex(`${QuizExplanationAction.IDENTIFIER}`) + '|' + escapeStringForUseInRegex(`${QuizHintAction.IDENTIFIER}`), 'g'); /** * Parse the markdown text and apply the result to the target object's data * - * The markdown text is split at MonacoQuizHintAction.IDENTIFIER and MonacoQuizExplanationAction.IDENTIFIER tags. - * => First part is text. Everything after MonacoQuizHintAction.IDENTIFIER is Hint, anything after MonacoQuizExplanationAction.IDENTIFIER is explanation + * The markdown text is split at QuizHintAction.IDENTIFIER and QuizExplanationAction.IDENTIFIER tags. + * => First part is text. Everything after QuizHintAction.IDENTIFIER is Hint, anything after QuizExplanationAction.IDENTIFIER is explanation * * @param markdownText {string} the markdown text to parse * @param targetObject {object} the object that the result will be saved in. Fields modified are 'text', 'hint' and 'explanation'. @@ -24,18 +21,18 @@ export function parseExerciseHintExplanation(markdownText: string, targetObject: // split markdownText into main text, hint and explanation const markdownTextParts = markdownText.split(hintOrExpRegex); targetObject.text = markdownTextParts[0].trim(); - if (markdownText.indexOf(MonacoQuizHintAction.IDENTIFIER) !== -1 && markdownText.indexOf(MonacoQuizExplanationAction.IDENTIFIER) !== -1) { - if (markdownText.indexOf(MonacoQuizHintAction.IDENTIFIER) < markdownText.indexOf(MonacoQuizExplanationAction.IDENTIFIER)) { + if (markdownText.indexOf(QuizHintAction.IDENTIFIER) !== -1 && markdownText.indexOf(QuizExplanationAction.IDENTIFIER) !== -1) { + if (markdownText.indexOf(QuizHintAction.IDENTIFIER) < markdownText.indexOf(QuizExplanationAction.IDENTIFIER)) { targetObject.hint = markdownTextParts[1].trim(); targetObject.explanation = markdownTextParts[2].trim(); } else { targetObject.hint = markdownTextParts[2].trim(); targetObject.explanation = markdownTextParts[1].trim(); } - } else if (markdownText.indexOf(MonacoQuizHintAction.IDENTIFIER) !== -1) { + } else if (markdownText.indexOf(QuizHintAction.IDENTIFIER) !== -1) { targetObject.hint = markdownTextParts[1].trim(); targetObject.explanation = undefined; - } else if (markdownText.indexOf(MonacoQuizExplanationAction.IDENTIFIER) !== -1) { + } else if (markdownText.indexOf(QuizExplanationAction.IDENTIFIER) !== -1) { targetObject.hint = undefined; targetObject.explanation = markdownTextParts[1].trim(); } else { @@ -60,6 +57,6 @@ export function generateExerciseHintExplanation(sourceObject: ExerciseHintExplan return !sourceObject.text ? '' : sourceObject.text + - (sourceObject.hint ? '\n\t' + MonacoQuizHintAction.IDENTIFIER + ' ' + sourceObject.hint : '') + - (sourceObject.explanation ? '\n\t' + MonacoQuizExplanationAction.IDENTIFIER + ' ' + sourceObject.explanation : ''); + (sourceObject.hint ? '\n\t' + QuizHintAction.IDENTIFIER + ' ' + sourceObject.hint : '') + + (sourceObject.explanation ? '\n\t' + QuizExplanationAction.IDENTIFIER + ' ' + sourceObject.explanation : ''); } diff --git a/src/test/javascript/spec/component/drag-and-drop-question/drag-and-drop-question-edit.component.spec.ts b/src/test/javascript/spec/component/drag-and-drop-question/drag-and-drop-question-edit.component.spec.ts index e9abf208d3b9..4e630b4bf16c 100644 --- a/src/test/javascript/spec/component/drag-and-drop-question/drag-and-drop-question-edit.component.spec.ts +++ b/src/test/javascript/spec/component/drag-and-drop-question/drag-and-drop-question-edit.component.spec.ts @@ -23,8 +23,8 @@ import { DragAndDropQuestionUtil } from 'app/exercises/quiz/shared/drag-and-drop import { ChangeDetectorRef } from '@angular/core'; import { clone } from 'lodash-es'; import { CdkDragDrop, DragDropModule } from '@angular/cdk/drag-drop'; -import { MonacoQuizExplanationAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-explanation.action'; -import { MonacoQuizHintAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-hint.action'; +import { QuizExplanationAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-explanation.action'; +import { QuizHintAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-hint.action'; import { MarkdownEditorMonacoComponent, TextWithDomainAction } from 'app/shared/markdown-editor/monaco/markdown-editor-monaco.component'; describe('DragAndDropQuestionEditComponent', () => { @@ -608,7 +608,7 @@ describe('DragAndDropQuestionEditComponent', () => { let textWithDomainAction: TextWithDomainAction; // explanation - let action = new MonacoQuizExplanationAction(); + let action = new QuizExplanationAction(); let text = 'take this as an explanationCommand'; textWithDomainAction = { text, action }; @@ -617,7 +617,7 @@ describe('DragAndDropQuestionEditComponent', () => { expect(component.question.explanation).toBe(text); // hint - action = new MonacoQuizHintAction(); + action = new QuizHintAction(); text = 'take this as a hintCommand'; textWithDomainAction = { text, action }; diff --git a/src/test/javascript/spec/component/markdown-editor/markdown-editor-monaco.component.spec.ts b/src/test/javascript/spec/component/markdown-editor/markdown-editor-monaco.component.spec.ts index 617ffaae051d..d0c651b16f73 100644 --- a/src/test/javascript/spec/component/markdown-editor/markdown-editor-monaco.component.spec.ts +++ b/src/test/javascript/spec/component/markdown-editor/markdown-editor-monaco.component.spec.ts @@ -9,16 +9,16 @@ import { NgbNavModule, NgbTooltip } from '@ng-bootstrap/ng-bootstrap'; import { MockComponent, MockDirective, MockPipe, MockProvider } from 'ng-mocks'; import { MarkdownEditorHeight, MarkdownEditorMonacoComponent } from 'app/shared/markdown-editor/monaco/markdown-editor-monaco.component'; import { MonacoEditorComponent } from 'app/shared/monaco-editor/monaco-editor.component'; -import { MonacoColorAction } from 'app/shared/monaco-editor/model/actions/color.action'; +import { ColorAction } from 'app/shared/monaco-editor/model/actions/color.action'; import { MockResizeObserver } from '../../helpers/mocks/service/mock-resize-observer'; import { CdkDragMove, DragDropModule } from '@angular/cdk/drag-drop'; import { ArtemisSharedModule } from 'app/shared/shared.module'; -import { MonacoUrlAction } from 'app/shared/monaco-editor/model/actions/url.action'; -import { MonacoAttachmentAction } from 'app/shared/monaco-editor/model/actions/attachment.action'; -import { MonacoFormulaAction } from 'app/shared/monaco-editor/model/actions/formula.action'; -import { MonacoTestCaseAction } from 'app/shared/monaco-editor/model/actions/test-case.action'; -import { MonacoTaskAction } from 'app/shared/monaco-editor/model/actions/task.action'; -import { MonacoFullscreenAction } from 'app/shared/monaco-editor/model/actions/fullscreen.action'; +import { UrlAction } from 'app/shared/monaco-editor/model/actions/url.action'; +import { AttachmentAction } from 'app/shared/monaco-editor/model/actions/attachment.action'; +import { FormulaAction } from 'app/shared/monaco-editor/model/actions/formula.action'; +import { TestCaseAction } from 'app/shared/monaco-editor/model/actions/test-case.action'; +import { TaskAction } from 'app/shared/monaco-editor/model/actions/task.action'; +import { FullscreenAction } from 'app/shared/monaco-editor/model/actions/fullscreen.action'; import { MonacoEditorOptionPreset } from 'app/shared/monaco-editor/model/monaco-editor-option-preset.model'; import { COMMUNICATION_MARKDOWN_EDITOR_OPTIONS } from 'app/shared/monaco-editor/monaco-editor-option.helper'; @@ -45,7 +45,7 @@ describe('MarkdownEditorMonacoComponent', () => { fixture = TestBed.createComponent(MarkdownEditorMonacoComponent); comp = fixture.componentInstance; comp.initialEditorHeight = 'external'; - comp.domainActions = [new MonacoFormulaAction(), new MonacoTaskAction(), new MonacoTestCaseAction()]; + comp.domainActions = [new FormulaAction(), new TaskAction(), new TestCaseAction()]; fileUploaderService = fixture.debugElement.injector.get(FileUploaderService); }); @@ -152,9 +152,9 @@ describe('MarkdownEditorMonacoComponent', () => { })); it('should embed image and .pdf files', fakeAsync(() => { - const urlAction = new MonacoUrlAction(); + const urlAction = new UrlAction(); const urlStub = jest.spyOn(urlAction, 'executeInCurrentEditor').mockImplementation(); - const attachmentAction = new MonacoAttachmentAction(); + const attachmentAction = new AttachmentAction(); const attachmentStub = jest.spyOn(attachmentAction, 'executeInCurrentEditor').mockImplementation(); const fileInformation = [ { file: new File([''], 'test.png'), url: 'https://test.invalid/generated42.png' }, @@ -187,7 +187,7 @@ describe('MarkdownEditorMonacoComponent', () => { }); it('should pass the correct color as argument to the color action', () => { - comp.colorAction = new MonacoColorAction(); + comp.colorAction = new ColorAction(); fixture.detectChanges(); const executeInCurrentEditorStub = jest.spyOn(comp.colorAction, 'executeInCurrentEditor').mockImplementation(); const markdownColors = comp.colorSignal(); @@ -200,7 +200,7 @@ describe('MarkdownEditorMonacoComponent', () => { it('should pass the entire element to the fullscreen action for external height', () => { comp.initialEditorHeight = 'external'; - const fullscreenAction = new MonacoFullscreenAction(); + const fullscreenAction = new FullscreenAction(); comp.metaActions = [fullscreenAction]; fixture.detectChanges(); expect(fullscreenAction.element).toBe(comp.fullElement.nativeElement); @@ -208,7 +208,7 @@ describe('MarkdownEditorMonacoComponent', () => { it('should pass the wrapper element to the fullscreen action for a set initial height', () => { comp.initialEditorHeight = MarkdownEditorHeight.MEDIUM; - const fullscreenAction = new MonacoFullscreenAction(); + const fullscreenAction = new FullscreenAction(); comp.metaActions = [fullscreenAction]; fixture.detectChanges(); expect(fullscreenAction.element).toBe(comp.wrapper.nativeElement); diff --git a/src/test/javascript/spec/component/markdown-editor/markdown-editor-parsing.helper.spec.ts b/src/test/javascript/spec/component/markdown-editor/markdown-editor-parsing.helper.spec.ts index f388bc94b427..ae17164961ce 100644 --- a/src/test/javascript/spec/component/markdown-editor/markdown-editor-parsing.helper.spec.ts +++ b/src/test/javascript/spec/component/markdown-editor/markdown-editor-parsing.helper.spec.ts @@ -1,6 +1,6 @@ import { parseMarkdownForDomainActions } from 'app/shared/markdown-editor/monaco/markdown-editor-parsing.helper'; -import { MonacoGradingDescriptionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-description.action'; -import { MonacoGradingFeedbackAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-feedback.action'; +import { GradingDescriptionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-description.action'; +import { GradingFeedbackAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-feedback.action'; describe('MarkdownEditorParsingHelper', () => { it('should parse markdown without domain action identifiers', () => { @@ -10,7 +10,7 @@ describe('MarkdownEditorParsingHelper', () => { }); it('should parse single-line text with one domain action identifier', () => { - const action = new MonacoGradingDescriptionAction(); + const action = new GradingDescriptionAction(); const markdown = 'This is some text. [description] This is a description.'; const result = parseMarkdownForDomainActions(markdown, [action]); expect(result).toEqual([ @@ -20,8 +20,8 @@ describe('MarkdownEditorParsingHelper', () => { }); it('should parse single-line text with multiple domain action identifiers', () => { - const descriptionAction = new MonacoGradingDescriptionAction(); - const feedbackAction = new MonacoGradingFeedbackAction(); + const descriptionAction = new GradingDescriptionAction(); + const feedbackAction = new GradingFeedbackAction(); const markdown = 'This is some text. [description] This is a description. [feedback] This is some feedback.'; const result = parseMarkdownForDomainActions(markdown, [descriptionAction, feedbackAction]); expect(result).toEqual([ @@ -38,8 +38,8 @@ describe('MarkdownEditorParsingHelper', () => { }); it('should parse multi-line text with multiple domain action identifiers', () => { - const descriptionAction = new MonacoGradingDescriptionAction(); - const feedbackAction = new MonacoGradingFeedbackAction(); + const descriptionAction = new GradingDescriptionAction(); + const feedbackAction = new GradingFeedbackAction(); const markdown = 'This is some text. [description] This is a description.\n [feedback] This is some feedback.'; const result = parseMarkdownForDomainActions(markdown, [descriptionAction, feedbackAction]); expect(result).toEqual([ diff --git a/src/test/javascript/spec/component/multiple-choice-question/multiple-choice-question-edit.component.spec.ts b/src/test/javascript/spec/component/multiple-choice-question/multiple-choice-question-edit.component.spec.ts index 5e1e1fd04b52..5f3676dac748 100644 --- a/src/test/javascript/spec/component/multiple-choice-question/multiple-choice-question-edit.component.spec.ts +++ b/src/test/javascript/spec/component/multiple-choice-question/multiple-choice-question-edit.component.spec.ts @@ -15,11 +15,11 @@ import { NgbCollapseMocksModule } from '../../helpers/mocks/directive/ngbCollaps import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'; import { MultipleChoiceVisualQuestionComponent } from 'app/exercises/quiz/shared/questions/multiple-choice-question/multiple-choice-visual-question.component'; import { ScoringType } from 'app/entities/quiz/quiz-question.model'; -import { MonacoQuizHintAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-hint.action'; -import { MonacoQuizExplanationAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-explanation.action'; -import { MonacoWrongMultipleChoiceAnswerAction } from 'app/shared/monaco-editor/model/actions/quiz/wrong-multiple-choice-answer.action'; -import { MonacoCorrectMultipleChoiceAnswerAction } from 'app/shared/monaco-editor/model/actions/quiz/correct-multiple-choice-answer.action'; -import { MonacoTestCaseAction } from 'app/shared/monaco-editor/model/actions/test-case.action'; +import { QuizHintAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-hint.action'; +import { QuizExplanationAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-explanation.action'; +import { WrongMultipleChoiceAnswerAction } from 'app/shared/monaco-editor/model/actions/quiz/wrong-multiple-choice-answer.action'; +import { CorrectMultipleChoiceAnswerAction } from 'app/shared/monaco-editor/model/actions/quiz/correct-multiple-choice-answer.action'; +import { TestCaseAction } from 'app/shared/monaco-editor/model/actions/test-case.action'; import { MarkdownEditorMonacoComponent } from 'app/shared/markdown-editor/monaco/markdown-editor-monaco.component'; describe('MultipleChoiceQuestionEditComponent', () => { @@ -92,11 +92,11 @@ describe('MultipleChoiceQuestionEditComponent', () => { it('should parse answer options but not question titles', () => { component.domainActionsFound([ - { text: 'text1', action: new MonacoTestCaseAction() }, - { text: 'text2', action: new MonacoCorrectMultipleChoiceAnswerAction() }, - { text: 'text3', action: new MonacoWrongMultipleChoiceAnswerAction() }, - { text: 'text4', action: new MonacoQuizExplanationAction() }, - { text: 'text5', action: new MonacoQuizHintAction() }, + { text: 'text1', action: new TestCaseAction() }, + { text: 'text2', action: new CorrectMultipleChoiceAnswerAction() }, + { text: 'text3', action: new WrongMultipleChoiceAnswerAction() }, + { text: 'text4', action: new QuizExplanationAction() }, + { text: 'text5', action: new QuizHintAction() }, ]); const expected: MultipleChoiceQuestion = { @@ -130,11 +130,11 @@ describe('MultipleChoiceQuestionEditComponent', () => { it('should parse answer options with question titles', () => { component.domainActionsFound([ - { text: 'text1', action: new MonacoQuizExplanationAction() }, - { text: 'text2', action: new MonacoQuizHintAction() }, - { text: 'text3', action: new MonacoTestCaseAction() }, - { text: 'text4', action: new MonacoCorrectMultipleChoiceAnswerAction() }, - { text: 'text5', action: new MonacoWrongMultipleChoiceAnswerAction() }, + { text: 'text1', action: new QuizExplanationAction() }, + { text: 'text2', action: new QuizHintAction() }, + { text: 'text3', action: new TestCaseAction() }, + { text: 'text4', action: new CorrectMultipleChoiceAnswerAction() }, + { text: 'text5', action: new WrongMultipleChoiceAnswerAction() }, ]); const expected: MultipleChoiceQuestion = { diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction-analysis.component.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction-analysis.component.spec.ts index 771ea9652e93..1e9b1a1f751c 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction-analysis.component.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction-analysis.component.spec.ts @@ -10,7 +10,7 @@ import { ArtemisTranslatePipe } from 'app/shared/pipes/artemis-translate.pipe'; import { FaIconComponent } from '@fortawesome/angular-fontawesome'; import { MockProgrammingExerciseInstructionAnalysisService } from '../../helpers/mocks/service/mock-programming-exericse-instruction-analysis.service'; import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'; -import { MonacoTaskAction } from 'app/shared/monaco-editor/model/actions/task.action'; +import { TaskAction } from 'app/shared/monaco-editor/model/actions/task.action'; describe('ProgrammingExerciseInstructionInstructorAnalysis', () => { let comp: ProgrammingExerciseInstructionAnalysisComponent; @@ -20,7 +20,7 @@ describe('ProgrammingExerciseInstructionInstructorAnalysis', () => { const testCaseOkId = 'instruction_analysis_test-case-ok'; const testCaseIssuesId = 'instruction_analysis_test-case-issues'; - const taskRegex = MonacoTaskAction.GLOBAL_TASK_REGEX; + const taskRegex = TaskAction.GLOBAL_TASK_REGEX; const exerciseTestCases = ['test1', 'test2', 'test6', 'test7']; const problemStatement = '1. [task][SortStrategy Interface](test1,test2) \n 2. [task][SortStrategy Interface](test3) \n lorem ipsum \n lorem \n 3. [task][SortStrategy Interface](test2,test4)'; diff --git a/src/test/javascript/spec/component/shared/grading-instructions-details.component.spec.ts b/src/test/javascript/spec/component/shared/grading-instructions-details.component.spec.ts index b646456d895f..e5b3d7cb808d 100644 --- a/src/test/javascript/spec/component/shared/grading-instructions-details.component.spec.ts +++ b/src/test/javascript/spec/component/shared/grading-instructions-details.component.spec.ts @@ -8,13 +8,13 @@ import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; import { MockTranslateService } from '../../helpers/mocks/service/mock-translate.service'; import { ArtemisTestModule } from '../../test.module'; -import { MonacoGradingInstructionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-instruction.action'; -import { MonacoGradingCreditsAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-credits.action'; -import { MonacoGradingScaleAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-scale.action'; -import { MonacoGradingDescriptionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-description.action'; -import { MonacoGradingFeedbackAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-feedback.action'; -import { MonacoGradingUsageCountAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-usage-count.action'; -import { MonacoGradingCriterionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-criterion.action'; +import { GradingInstructionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-instruction.action'; +import { GradingCreditsAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-credits.action'; +import { GradingScaleAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-scale.action'; +import { GradingDescriptionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-description.action'; +import { GradingFeedbackAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-feedback.action'; +import { GradingUsageCountAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-usage-count.action'; +import { GradingCriterionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-criterion.action'; import { TextWithDomainAction } from 'app/shared/markdown-editor/monaco/markdown-editor-monaco.component'; describe('GradingInstructionsDetailsComponent', () => { @@ -137,7 +137,7 @@ describe('GradingInstructionsDetailsComponent', () => { it('should change grading instruction', () => { const newDescription = 'new text'; - const domainActions = [{ text: newDescription, action: new MonacoGradingDescriptionAction() }] as TextWithDomainAction[]; + const domainActions = [{ text: newDescription, action: new GradingDescriptionAction() }] as TextWithDomainAction[]; component.exercise.gradingCriteria = [gradingCriterion]; component.onInstructionChange(domainActions, gradingInstruction); @@ -165,13 +165,13 @@ describe('GradingInstructionsDetailsComponent', () => { }); const getDomainActionArray = () => { - const creditsAction = new MonacoGradingCreditsAction(); - const scaleAction = new MonacoGradingScaleAction(); - const descriptionAction = new MonacoGradingDescriptionAction(); - const feedbackAction = new MonacoGradingFeedbackAction(); - const usageCountAction = new MonacoGradingUsageCountAction(); - const instructionAction = new MonacoGradingInstructionAction(creditsAction, scaleAction, descriptionAction, feedbackAction, usageCountAction); - const criterionAction = new MonacoGradingCriterionAction(instructionAction); + const creditsAction = new GradingCreditsAction(); + const scaleAction = new GradingScaleAction(); + const descriptionAction = new GradingDescriptionAction(); + const feedbackAction = new GradingFeedbackAction(); + const usageCountAction = new GradingUsageCountAction(); + const instructionAction = new GradingInstructionAction(creditsAction, scaleAction, descriptionAction, feedbackAction, usageCountAction); + const criterionAction = new GradingCriterionAction(instructionAction); return [ { text: 'testCriteria', action: criterionAction }, diff --git a/src/test/javascript/spec/component/shared/metis/postings-markdown-editor/postings-markdown-editor.component.spec.ts b/src/test/javascript/spec/component/shared/metis/postings-markdown-editor/postings-markdown-editor.component.spec.ts index 90f211744cf7..d599aac5a13a 100644 --- a/src/test/javascript/spec/component/shared/metis/postings-markdown-editor/postings-markdown-editor.component.spec.ts +++ b/src/test/javascript/spec/component/shared/metis/postings-markdown-editor/postings-markdown-editor.component.spec.ts @@ -14,16 +14,16 @@ import { CourseManagementService } from 'app/course/manage/course-management.ser import { ChannelService } from 'app/shared/metis/conversations/channel.service'; import * as CourseModel from 'app/entities/course.model'; import { MarkdownEditorMonacoComponent } from 'app/shared/markdown-editor/monaco/markdown-editor-monaco.component'; -import { MonacoChannelReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/channel-reference.action'; -import { MonacoUserMentionAction } from 'app/shared/monaco-editor/model/actions/communication/user-mention.action'; -import { MonacoBoldAction } from 'app/shared/monaco-editor/model/actions/bold.action'; -import { MonacoItalicAction } from 'app/shared/monaco-editor/model/actions/italic.action'; -import { MonacoUnderlineAction } from 'app/shared/monaco-editor/model/actions/underline.action'; -import { MonacoQuoteAction } from 'app/shared/monaco-editor/model/actions/quote.action'; -import { MonacoCodeAction } from 'app/shared/monaco-editor/model/actions/code.action'; -import { MonacoCodeBlockAction } from 'app/shared/monaco-editor/model/actions/code-block.action'; -import { MonacoExerciseReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/exercise-reference.action'; -import { MonacoLectureAttachmentReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/lecture-attachment-reference.action'; +import { ChannelReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/channel-reference.action'; +import { UserMentionAction } from 'app/shared/monaco-editor/model/actions/communication/user-mention.action'; +import { BoldAction } from 'app/shared/monaco-editor/model/actions/bold.action'; +import { ItalicAction } from 'app/shared/monaco-editor/model/actions/italic.action'; +import { UnderlineAction } from 'app/shared/monaco-editor/model/actions/underline.action'; +import { QuoteAction } from 'app/shared/monaco-editor/model/actions/quote.action'; +import { CodeAction } from 'app/shared/monaco-editor/model/actions/code.action'; +import { CodeBlockAction } from 'app/shared/monaco-editor/model/actions/code-block.action'; +import { ExerciseReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/exercise-reference.action'; +import { LectureAttachmentReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/lecture-attachment-reference.action'; describe('PostingsMarkdownEditor', () => { let component: PostingMarkdownEditorComponent; @@ -64,18 +64,18 @@ describe('PostingsMarkdownEditor', () => { component.ngOnInit(); expect(component.defaultActions).toEqual([ - new MonacoBoldAction(), - new MonacoItalicAction(), - new MonacoUnderlineAction(), - new MonacoQuoteAction(), - new MonacoCodeAction(), - new MonacoCodeBlockAction(), - new MonacoUserMentionAction(courseManagementService, metisService), - new MonacoChannelReferenceAction(metisService, channelService), - new MonacoExerciseReferenceAction(metisService), + new BoldAction(), + new ItalicAction(), + new UnderlineAction(), + new QuoteAction(), + new CodeAction(), + new CodeBlockAction(), + new UserMentionAction(courseManagementService, metisService), + new ChannelReferenceAction(metisService, channelService), + new ExerciseReferenceAction(metisService), ]); - expect(component.lectureAttachmentReferenceAction).toEqual(new MonacoLectureAttachmentReferenceAction(metisService, lectureService)); + expect(component.lectureAttachmentReferenceAction).toEqual(new LectureAttachmentReferenceAction(metisService, lectureService)); }); it('should have set the correct default commands on init if communication and messaging and communication is disabled', () => { @@ -83,16 +83,16 @@ describe('PostingsMarkdownEditor', () => { component.ngOnInit(); expect(component.defaultActions).toEqual([ - new MonacoBoldAction(), - new MonacoItalicAction(), - new MonacoUnderlineAction(), - new MonacoQuoteAction(), - new MonacoCodeAction(), - new MonacoCodeBlockAction(), - new MonacoExerciseReferenceAction(metisService), + new BoldAction(), + new ItalicAction(), + new UnderlineAction(), + new QuoteAction(), + new CodeAction(), + new CodeBlockAction(), + new ExerciseReferenceAction(metisService), ]); - expect(component.lectureAttachmentReferenceAction).toEqual(new MonacoLectureAttachmentReferenceAction(metisService, lectureService)); + expect(component.lectureAttachmentReferenceAction).toEqual(new LectureAttachmentReferenceAction(metisService, lectureService)); }); it('should show the correct amount of characters below the markdown input', () => { diff --git a/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-action-quiz.integration.spec.ts b/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-action-quiz.integration.spec.ts index a83c623f1bc2..06d99f3ae996 100644 --- a/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-action-quiz.integration.spec.ts +++ b/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-action-quiz.integration.spec.ts @@ -3,20 +3,20 @@ import { MonacoEditorComponent } from 'app/shared/monaco-editor/monaco-editor.co import { ArtemisTestModule } from '../../../test.module'; import { MonacoEditorModule } from 'app/shared/monaco-editor/monaco-editor.module'; import { MockResizeObserver } from '../../../helpers/mocks/service/mock-resize-observer'; -import { MonacoInsertShortAnswerOptionAction } from 'app/shared/monaco-editor/model/actions/quiz/insert-short-answer-option.action'; -import { MonacoInsertShortAnswerSpotAction } from 'app/shared/monaco-editor/model/actions/quiz/insert-short-answer-spot.action'; -import { MonacoWrongMultipleChoiceAnswerAction } from 'app/shared/monaco-editor/model/actions/quiz/wrong-multiple-choice-answer.action'; -import { MonacoCorrectMultipleChoiceAnswerAction } from 'app/shared/monaco-editor/model/actions/quiz/correct-multiple-choice-answer.action'; -import { MonacoQuizExplanationAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-explanation.action'; -import { MonacoQuizHintAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-hint.action'; +import { InsertShortAnswerOptionAction } from 'app/shared/monaco-editor/model/actions/quiz/insert-short-answer-option.action'; +import { InsertShortAnswerSpotAction } from 'app/shared/monaco-editor/model/actions/quiz/insert-short-answer-spot.action'; +import { WrongMultipleChoiceAnswerAction } from 'app/shared/monaco-editor/model/actions/quiz/wrong-multiple-choice-answer.action'; +import { CorrectMultipleChoiceAnswerAction } from 'app/shared/monaco-editor/model/actions/quiz/correct-multiple-choice-answer.action'; +import { QuizExplanationAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-explanation.action'; +import { QuizHintAction } from 'app/shared/monaco-editor/model/actions/quiz/quiz-hint.action'; describe('MonacoEditorActionQuizIntegration', () => { let fixture: ComponentFixture; let comp: MonacoEditorComponent; // Actions - let insertShortAnswerOptionAction: MonacoInsertShortAnswerOptionAction; - let insertShortAnswerSpotAction: MonacoInsertShortAnswerSpotAction; + let insertShortAnswerOptionAction: InsertShortAnswerOptionAction; + let insertShortAnswerSpotAction: InsertShortAnswerSpotAction; beforeEach(() => { TestBed.configureTestingModule({ @@ -31,8 +31,8 @@ describe('MonacoEditorActionQuizIntegration', () => { global.ResizeObserver = jest.fn().mockImplementation((callback: ResizeObserverCallback) => { return new MockResizeObserver(callback); }); - insertShortAnswerOptionAction = new MonacoInsertShortAnswerOptionAction(); - insertShortAnswerSpotAction = new MonacoInsertShortAnswerSpotAction(insertShortAnswerOptionAction); + insertShortAnswerOptionAction = new InsertShortAnswerOptionAction(); + insertShortAnswerSpotAction = new InsertShortAnswerSpotAction(insertShortAnswerOptionAction); fixture.detectChanges(); comp.registerAction(insertShortAnswerOptionAction); comp.registerAction(insertShortAnswerSpotAction); @@ -49,7 +49,7 @@ describe('MonacoEditorActionQuizIntegration', () => { it('should insert text with the default answer option', () => { insertShortAnswerOptionAction.executeInCurrentEditor(); // Text must match - expect(getLastLine()).toBe(`[-option #] ${MonacoInsertShortAnswerOptionAction.DEFAULT_TEXT}`); + expect(getLastLine()).toBe(`[-option #] ${InsertShortAnswerOptionAction.DEFAULT_TEXT}`); // Also test if the selection works. Type the option text. comp.triggerKeySequence('This is an actual option!'); expect(getLastLine()).toBe('[-option #] This is an actual option!'); @@ -57,13 +57,13 @@ describe('MonacoEditorActionQuizIntegration', () => { it('should insert the default text for blank option texts', () => { insertShortAnswerOptionAction.executeInCurrentEditor({ optionText: '' }); - expect(getLastLine()).toBe(`[-option #] ${MonacoInsertShortAnswerOptionAction.DEFAULT_TEXT}`); + expect(getLastLine()).toBe(`[-option #] ${InsertShortAnswerOptionAction.DEFAULT_TEXT}`); }); it('should insert text with the specified spot number', () => { insertShortAnswerOptionAction.executeInCurrentEditor({ spotNumber: 5 }); // Text must match - expect(getLastLine()).toBe(`[-option 5] ${MonacoInsertShortAnswerOptionAction.DEFAULT_TEXT}`); + expect(getLastLine()).toBe(`[-option 5] ${InsertShortAnswerOptionAction.DEFAULT_TEXT}`); // Also test if the selection works. Type the option text. comp.triggerKeySequence('This is an actual option!'); expect(getLastLine()).toBe('[-option 5] This is an actual option!'); @@ -81,7 +81,7 @@ describe('MonacoEditorActionQuizIntegration', () => { it('should insert text after the last option', () => { const text = '[-option 1] Option 1\n[-option 2] Option 2\n[-option 3] Option 3'; - const expectedText = text + `\n[-option #] ${MonacoInsertShortAnswerOptionAction.DEFAULT_TEXT}`; + const expectedText = text + `\n[-option #] ${InsertShortAnswerOptionAction.DEFAULT_TEXT}`; comp.setText('[-option 1] Option 1\n[-option 2] Option 2\n[-option 3] Option 3'); insertShortAnswerOptionAction.executeInCurrentEditor(); expect(comp.getText()).toBe(expectedText); @@ -89,14 +89,14 @@ describe('MonacoEditorActionQuizIntegration', () => { it('should insert text with more space if the last line is not an option', () => { const text = 'Some question text\nof a question\nwith lines'; - const expectedText = text + `\n\n\n[-option #] ${MonacoInsertShortAnswerOptionAction.DEFAULT_TEXT}`; + const expectedText = text + `\n\n\n[-option #] ${InsertShortAnswerOptionAction.DEFAULT_TEXT}`; comp.setText(text); insertShortAnswerOptionAction.executeInCurrentEditor(); expect(comp.getText()).toBe(expectedText); }); }); - describe('MonacoEditorInsertShortAnswerSpotAction', () => { + describe('EditorInsertShortAnswerSpotAction', () => { let insertAnswerOptionActionExecuteStub: jest.SpyInstance; beforeEach(() => { @@ -136,14 +136,14 @@ describe('MonacoEditorActionQuizIntegration', () => { // Type the text so the cursor moves along comp.triggerKeySequence(questionText); insertShortAnswerSpotAction.executeInCurrentEditor(); - expect(comp.getText()).toBe(questionText + '[-spot 1]' + `\n\n\n[-option 1] ${MonacoInsertShortAnswerOptionAction.DEFAULT_TEXT}`); + expect(comp.getText()).toBe(questionText + '[-spot 1]' + `\n\n\n[-option 1] ${InsertShortAnswerOptionAction.DEFAULT_TEXT}`); }); }); describe('Multiple Choice answer options', () => { it('should insert a wrong MC option', () => { comp.triggerKeySequence('This is a question that needs some options.'); - const action = new MonacoWrongMultipleChoiceAnswerAction(); + const action = new WrongMultipleChoiceAnswerAction(); comp.registerAction(action); action.executeInCurrentEditor(); expect(comp.getText()).toBe('This is a question that needs some options.\n[wrong] Enter a wrong answer option here'); @@ -151,7 +151,7 @@ describe('MonacoEditorActionQuizIntegration', () => { it('should insert a correct MC option', () => { comp.triggerKeySequence('This is a question that needs some options.'); - const action = new MonacoCorrectMultipleChoiceAnswerAction(); + const action = new CorrectMultipleChoiceAnswerAction(); comp.registerAction(action); action.executeInCurrentEditor(); expect(comp.getText()).toBe('This is a question that needs some options.\n[correct] Enter a correct answer option here'); @@ -159,7 +159,7 @@ describe('MonacoEditorActionQuizIntegration', () => { it('should add an explanation to an answer option', () => { comp.triggerKeySequence('This is a question that has an option.\n[correct] Option 1'); - const action = new MonacoQuizExplanationAction(); + const action = new QuizExplanationAction(); comp.registerAction(action); action.executeInCurrentEditor(); expect(comp.getText()).toBe( @@ -169,7 +169,7 @@ describe('MonacoEditorActionQuizIntegration', () => { it('should add a hint to an answer option', () => { comp.triggerKeySequence('This is a question that has an option.\n[correct] Option 1'); - const action = new MonacoQuizHintAction(); + const action = new QuizHintAction(); comp.registerAction(action); action.executeInCurrentEditor(); expect(comp.getText()).toBe('This is a question that has an option.\n[correct] Option 1\n\t[hint] Add a hint here (visible during the quiz via ?-Button)'); diff --git a/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-action.integration.spec.ts b/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-action.integration.spec.ts index 7f9ab0abc5fe..730f84f110f1 100644 --- a/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-action.integration.spec.ts +++ b/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-action.integration.spec.ts @@ -3,24 +3,24 @@ import { MonacoEditorComponent } from 'app/shared/monaco-editor/monaco-editor.co import { ArtemisTestModule } from '../../../test.module'; import { MonacoEditorModule } from 'app/shared/monaco-editor/monaco-editor.module'; import { MockResizeObserver } from '../../../helpers/mocks/service/mock-resize-observer'; -import { MonacoBoldAction } from 'app/shared/monaco-editor/model/actions/bold.action'; +import { BoldAction } from 'app/shared/monaco-editor/model/actions/bold.action'; import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; -import { MonacoItalicAction } from 'app/shared/monaco-editor/model/actions/italic.action'; -import { MonacoCodeAction } from 'app/shared/monaco-editor/model/actions/code.action'; -import { MonacoColorAction } from 'app/shared/monaco-editor/model/actions/color.action'; -import { MonacoUnderlineAction } from 'app/shared/monaco-editor/model/actions/underline.action'; -import { MonacoCodeBlockAction } from 'app/shared/monaco-editor/model/actions/code-block.action'; -import { MonacoFormulaAction } from 'app/shared/monaco-editor/model/actions/formula.action'; -import { MonacoQuoteAction } from 'app/shared/monaco-editor/model/actions/quote.action'; -import { MonacoFullscreenAction } from 'app/shared/monaco-editor/model/actions/fullscreen.action'; +import { ItalicAction } from 'app/shared/monaco-editor/model/actions/italic.action'; +import { CodeAction } from 'app/shared/monaco-editor/model/actions/code.action'; +import { ColorAction } from 'app/shared/monaco-editor/model/actions/color.action'; +import { UnderlineAction } from 'app/shared/monaco-editor/model/actions/underline.action'; +import { CodeBlockAction } from 'app/shared/monaco-editor/model/actions/code-block.action'; +import { FormulaAction } from 'app/shared/monaco-editor/model/actions/formula.action'; +import { QuoteAction } from 'app/shared/monaco-editor/model/actions/quote.action'; +import { FullscreenAction } from 'app/shared/monaco-editor/model/actions/fullscreen.action'; import * as FullscreenUtil from 'app/shared/util/fullscreen.util'; -import { MonacoTaskAction } from 'app/shared/monaco-editor/model/actions/task.action'; -import { MonacoTestCaseAction } from 'app/shared/monaco-editor/model/actions/test-case.action'; -import { MonacoHeadingAction } from 'app/shared/monaco-editor/model/actions/heading.action'; -import { MonacoUrlAction } from 'app/shared/monaco-editor/model/actions/url.action'; -import { MonacoAttachmentAction } from 'app/shared/monaco-editor/model/actions/attachment.action'; -import { MonacoOrderedListAction } from 'app/shared/monaco-editor/model/actions/ordered-list.action'; -import { MonacoUnorderedListAction } from 'app/shared/monaco-editor/model/actions/unordered-list.action'; +import { TaskAction } from 'app/shared/monaco-editor/model/actions/task.action'; +import { TestCaseAction } from 'app/shared/monaco-editor/model/actions/test-case.action'; +import { HeadingAction } from 'app/shared/monaco-editor/model/actions/heading.action'; +import { UrlAction } from 'app/shared/monaco-editor/model/actions/url.action'; +import { AttachmentAction } from 'app/shared/monaco-editor/model/actions/attachment.action'; +import { OrderedListAction } from 'app/shared/monaco-editor/model/actions/ordered-list.action'; +import { UnorderedListAction } from 'app/shared/monaco-editor/model/actions/unordered-list.action'; import * as monaco from 'monaco-editor'; describe('MonacoEditorActionIntegration', () => { @@ -49,16 +49,16 @@ describe('MonacoEditorActionIntegration', () => { }); it('should throw when trying to register an action twice', () => { - const action = new MonacoBoldAction(); + const action = new BoldAction(); comp.registerAction(action); const registerAction = () => comp.registerAction(action); expect(registerAction).toThrow(Error); }); it.each([ - { action: new MonacoAttachmentAction(), text: 'Attachment', url: 'https://test.invalid/img.png', defaultText: MonacoAttachmentAction.DEFAULT_INSERT_TEXT }, - { action: new MonacoUrlAction(), text: 'Link', url: 'https://test.invalid/', defaultText: MonacoUrlAction.DEFAULT_INSERT_TEXT }, - ])('should insert $text', ({ action, text, url, defaultText }: { action: MonacoUrlAction | MonacoAttachmentAction; text: string; url: string; defaultText: string }) => { + { action: new AttachmentAction(), text: 'Attachment', url: 'https://test.invalid/img.png', defaultText: AttachmentAction.DEFAULT_INSERT_TEXT }, + { action: new UrlAction(), text: 'Link', url: 'https://test.invalid/', defaultText: UrlAction.DEFAULT_INSERT_TEXT }, + ])('should insert $text', ({ action, text, url, defaultText }: { action: UrlAction | AttachmentAction; text: string; url: string; defaultText: string }) => { const prefix = text === 'Attachment' ? '!' : ''; comp.registerAction(action); action.executeInCurrentEditor({ text, url }); @@ -70,14 +70,14 @@ describe('MonacoEditorActionIntegration', () => { }); it('should insert unordered list', () => { - const action = new MonacoUnorderedListAction(); + const action = new UnorderedListAction(); comp.registerAction(action); action.executeInCurrentEditor(); expect(comp.getText()).toBe('- '); }); it('should toggle unordered list, skipping empty lines', () => { - const action = new MonacoUnorderedListAction(); + const action = new UnorderedListAction(); comp.registerAction(action); const lines = ['One', '', 'Two', 'Three']; const bulletedLines = lines.map((line) => (line ? `- ${line}` : '')); @@ -92,14 +92,14 @@ describe('MonacoEditorActionIntegration', () => { }); it('should insert ordered list', () => { - const action = new MonacoOrderedListAction(); + const action = new OrderedListAction(); comp.registerAction(action); action.executeInCurrentEditor(); expect(comp.getText()).toBe('1. '); }); it('should toggle ordered list, skipping empty lines', () => { - const action = new MonacoOrderedListAction(); + const action = new OrderedListAction(); comp.registerAction(action); const lines = ['One', '', 'Two', 'Three']; const numberedLines = lines.map((line, index) => (line ? `${index + 1}. ${line}` : '')); @@ -114,7 +114,7 @@ describe('MonacoEditorActionIntegration', () => { }); it.each([1, 2, 3])('Should toggle heading %i on selected line', (headingLevel) => { - const action = new MonacoHeadingAction(headingLevel); + const action = new HeadingAction(headingLevel); comp.registerAction(action); // No selection -> insert heading action.executeInCurrentEditor(); @@ -128,7 +128,7 @@ describe('MonacoEditorActionIntegration', () => { }); it('should insert test case names', () => { - const action = new MonacoTestCaseAction(); + const action = new TestCaseAction(); const testCaseName = 'testCase()'; action.values = [{ value: testCaseName, id: '1' }]; // With specified test case @@ -138,11 +138,11 @@ describe('MonacoEditorActionIntegration', () => { // Without specified test case comp.setText(''); action.executeInCurrentEditor(); - expect(comp.getText()).toBe(MonacoTestCaseAction.DEFAULT_INSERT_TEXT); + expect(comp.getText()).toBe(TestCaseAction.DEFAULT_INSERT_TEXT); }); it('should throw when trying to register a completer without a model', () => { - const action = new MonacoTestCaseAction(); + const action = new TestCaseAction(); const registerAction = () => comp.registerAction(action); // Detach model (should not happen in practice) comp['_editor'].setModel(null); @@ -152,7 +152,7 @@ describe('MonacoEditorActionIntegration', () => { it('should provide test case completions', async () => { comp.changeModel('testCase', '', 'custom-md'); const model = comp.models[0]; - const action = new MonacoTestCaseAction(); + const action = new TestCaseAction(); action.values = [ { value: 'testCase1', id: '1' }, { value: 'testCase2', id: '2' }, @@ -177,14 +177,14 @@ describe('MonacoEditorActionIntegration', () => { }); it('should insert tasks', () => { - const action = new MonacoTaskAction(); + const action = new TaskAction(); comp.registerAction(action); action.executeInCurrentEditor(); - expect(comp.getText()).toBe(`[task]${MonacoTaskAction.TEXT}`); + expect(comp.getText()).toBe(`[task]${TaskAction.TEXT}`); }); it('should enter fullscreen', () => { - const action = new MonacoFullscreenAction(); + const action = new FullscreenAction(); comp.registerAction(action); const enterFullscreenStub = jest.spyOn(FullscreenUtil, 'enterFullscreen').mockImplementation(); jest.spyOn(FullscreenUtil, 'isFullScreen').mockReturnValue(false); @@ -202,7 +202,7 @@ describe('MonacoEditorActionIntegration', () => { }); it('should leave fullscreen', () => { - const action = new MonacoFullscreenAction(); + const action = new FullscreenAction(); comp.registerAction(action); const exitFullscreenStub = jest.spyOn(FullscreenUtil, 'exitFullscreen').mockImplementation(); jest.spyOn(FullscreenUtil, 'isFullScreen').mockReturnValue(true); @@ -211,36 +211,36 @@ describe('MonacoEditorActionIntegration', () => { }); it.each([ - { action: new MonacoBoldAction(), textWithoutDelimiters: 'Here is some bold text.', textWithDelimiters: '**Here is some bold text.**' }, - { action: new MonacoItalicAction(), textWithoutDelimiters: 'Here is some italic text.', textWithDelimiters: '*Here is some italic text.*' }, - { action: new MonacoUnderlineAction(), textWithoutDelimiters: 'Here is some underlined text.', textWithDelimiters: 'Here is some underlined text.' }, - { action: new MonacoCodeAction(), textWithoutDelimiters: 'Here is some code.', textWithDelimiters: '`Here is some code.`' }, + { action: new BoldAction(), textWithoutDelimiters: 'Here is some bold text.', textWithDelimiters: '**Here is some bold text.**' }, + { action: new ItalicAction(), textWithoutDelimiters: 'Here is some italic text.', textWithDelimiters: '*Here is some italic text.*' }, + { action: new UnderlineAction(), textWithoutDelimiters: 'Here is some underlined text.', textWithDelimiters: 'Here is some underlined text.' }, + { action: new CodeAction(), textWithoutDelimiters: 'Here is some code.', textWithDelimiters: '`Here is some code.`' }, { - action: new MonacoColorAction(), + action: new ColorAction(), textWithoutDelimiters: 'Here is some blue.', textWithDelimiters: 'Here is some blue.', actionArgs: { color: 'blue' }, }, { - action: new MonacoColorAction(), + action: new ColorAction(), textWithoutDelimiters: 'Here is some red.', textWithDelimiters: 'Here is some red.', // No argument -> default color is red }, - { action: new MonacoCodeBlockAction(), textWithoutDelimiters: 'public void main() { }', textWithDelimiters: '```\npublic void main() { }\n```' }, - { action: new MonacoCodeBlockAction('java'), textWithoutDelimiters: 'public void main() { }', textWithDelimiters: '```java\npublic void main() { }\n```' }, + { action: new CodeBlockAction(), textWithoutDelimiters: 'public void main() { }', textWithDelimiters: '```\npublic void main() { }\n```' }, + { action: new CodeBlockAction('java'), textWithoutDelimiters: 'public void main() { }', textWithDelimiters: '```java\npublic void main() { }\n```' }, { - action: new MonacoQuoteAction(), + action: new QuoteAction(), initialText: '> ', textToType: 'some quoted text', textWithDelimiters: '> some quoted text', textWithoutDelimiters: 'some quoted text', }, { - action: new MonacoFormulaAction(), - initialText: `$$ ${MonacoFormulaAction.DEFAULT_FORMULA} $$`, + action: new FormulaAction(), + initialText: `$$ ${FormulaAction.DEFAULT_FORMULA} $$`, textToType: '+ 42x', - textWithDelimiters: `$$ ${MonacoFormulaAction.DEFAULT_FORMULA}+ 42x $$`, - textWithoutDelimiters: `${MonacoFormulaAction.DEFAULT_FORMULA}+ 42x`, + textWithDelimiters: `$$ ${FormulaAction.DEFAULT_FORMULA}+ 42x $$`, + textWithoutDelimiters: `${FormulaAction.DEFAULT_FORMULA}+ 42x`, }, ])( 'Delimiter action ($action.id) should insert delimiters at position and toggle around selection', diff --git a/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-communication-action.integration.spec.ts b/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-communication-action.integration.spec.ts index 74f4245d18ff..9fa5c2b391c5 100644 --- a/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-communication-action.integration.spec.ts +++ b/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-communication-action.integration.spec.ts @@ -12,9 +12,9 @@ import { TranslateService } from '@ngx-translate/core'; import { MockLocalStorageService } from '../../../helpers/mocks/service/mock-local-storage.service'; import { LocalStorageService } from 'ngx-webstorage'; import { MockResizeObserver } from '../../../helpers/mocks/service/mock-resize-observer'; -import { MonacoChannelReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/channel-reference.action'; -import { MonacoUserMentionAction } from 'app/shared/monaco-editor/model/actions/communication/user-mention.action'; -import { MonacoExerciseReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/exercise-reference.action'; +import { ChannelReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/channel-reference.action'; +import { UserMentionAction } from 'app/shared/monaco-editor/model/actions/communication/user-mention.action'; +import { ExerciseReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/exercise-reference.action'; import { metisExamChannelDTO, metisExerciseChannelDTO, metisGeneralChannelDTO, metisTutor, metisUser1, metisUser2 } from '../../../helpers/sample/metis-sample-data'; import { TextEditorAction } from 'app/shared/monaco-editor/model/actions/text-editor-action.model'; import * as monaco from 'monaco-editor'; @@ -23,7 +23,7 @@ import { ChannelIdAndNameDTO } from 'app/entities/metis/conversation/channel.mod import { User } from 'app/core/user/user.model'; import { Exercise } from 'app/entities/exercise.model'; import { Lecture } from 'app/entities/lecture.model'; -import { MonacoLectureAttachmentReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/lecture-attachment-reference.action'; +import { LectureAttachmentReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/lecture-attachment-reference.action'; import { LectureUnitType } from 'app/entities/lecture-unit/lectureUnit.model'; import { ReferenceType } from 'app/shared/metis/metis.util'; @@ -37,9 +37,9 @@ describe('MonacoEditorCommunicationActionIntegration', () => { let provider: monaco.languages.CompletionItemProvider; // Actions - let channelReferenceAction: MonacoChannelReferenceAction; - let userMentionAction: MonacoUserMentionAction; - let exerciseReferenceAction: MonacoExerciseReferenceAction; + let channelReferenceAction: ChannelReferenceAction; + let userMentionAction: UserMentionAction; + let exerciseReferenceAction: ExerciseReferenceAction; beforeEach(() => { return TestBed.configureTestingModule({ @@ -65,9 +65,9 @@ describe('MonacoEditorCommunicationActionIntegration', () => { courseManagementService = TestBed.inject(CourseManagementService); lectureService = TestBed.inject(LectureService); channelService = TestBed.inject(ChannelService); - channelReferenceAction = new MonacoChannelReferenceAction(metisService, channelService); - userMentionAction = new MonacoUserMentionAction(courseManagementService, metisService); - exerciseReferenceAction = new MonacoExerciseReferenceAction(metisService); + channelReferenceAction = new ChannelReferenceAction(metisService, channelService); + userMentionAction = new UserMentionAction(courseManagementService, metisService); + exerciseReferenceAction = new ExerciseReferenceAction(metisService); }); }); @@ -88,11 +88,11 @@ describe('MonacoEditorCommunicationActionIntegration', () => { }; describe.each([ - { actionId: MonacoChannelReferenceAction.ID, defaultInsertText: '#', triggerCharacter: '#' }, - { actionId: MonacoUserMentionAction.ID, defaultInsertText: '@', triggerCharacter: '@' }, - { actionId: MonacoExerciseReferenceAction.ID, defaultInsertText: '/exercise', triggerCharacter: '/' }, + { actionId: ChannelReferenceAction.ID, defaultInsertText: '#', triggerCharacter: '#' }, + { actionId: UserMentionAction.ID, defaultInsertText: '@', triggerCharacter: '@' }, + { actionId: ExerciseReferenceAction.ID, defaultInsertText: '/exercise', triggerCharacter: '/' }, ])('Suggestions and default behavior for $actionId', ({ actionId, defaultInsertText, triggerCharacter }) => { - let action: MonacoChannelReferenceAction | MonacoUserMentionAction | MonacoExerciseReferenceAction; + let action: ChannelReferenceAction | UserMentionAction | ExerciseReferenceAction; let channels: ChannelIdAndNameDTO[]; let users: User[]; let exercises: Exercise[]; @@ -107,13 +107,13 @@ describe('MonacoEditorCommunicationActionIntegration', () => { exercises = metisService.getCourse().exercises!; switch (actionId) { - case MonacoChannelReferenceAction.ID: + case ChannelReferenceAction.ID: action = channelReferenceAction; break; - case MonacoUserMentionAction.ID: + case UserMentionAction.ID: action = userMentionAction; break; - case MonacoExerciseReferenceAction.ID: + case ExerciseReferenceAction.ID: action = exerciseReferenceAction; break; } @@ -179,23 +179,23 @@ describe('MonacoEditorCommunicationActionIntegration', () => { registerActionWithCompletionProvider(action, triggerCharacter); const providerResult = await provider.provideCompletionItems(comp.models[0], new monaco.Position(1, column), {} as any, {} as any); expect(providerResult).toBeDefined(); - expect(providerResult!.incomplete).toBe(actionId === MonacoUserMentionAction.ID); + expect(providerResult!.incomplete).toBe(actionId === UserMentionAction.ID); const suggestions = providerResult!.suggestions; switch (actionId) { - case MonacoChannelReferenceAction.ID: + case ChannelReferenceAction.ID: checkChannelSuggestions(suggestions, channels); break; - case MonacoUserMentionAction.ID: + case UserMentionAction.ID: checkUserSuggestions(suggestions, users); break; - case MonacoExerciseReferenceAction.ID: + case ExerciseReferenceAction.ID: checkExerciseSuggestions(suggestions, exercises); break; } }); }); - describe('MonacoChannelReferenceAction', () => { + describe('ChannelReferenceAction', () => { it('should use cached channels if available', async () => { const channels: ChannelIdAndNameDTO[] = [metisGeneralChannelDTO, metisExamChannelDTO, metisExerciseChannelDTO]; channelReferenceAction.cachedChannels = channels; @@ -224,7 +224,7 @@ describe('MonacoEditorCommunicationActionIntegration', () => { }); }); - describe('MonacoExerciseReferenceAction (edge cases)', () => { + describe('ExerciseReferenceAction (edge cases)', () => { it('should initialize with empty values if exercises are not available', () => { jest.spyOn(metisService, 'getCourse').mockReturnValue({ exercises: undefined } as any); fixture.detectChanges(); @@ -233,14 +233,14 @@ describe('MonacoEditorCommunicationActionIntegration', () => { }); }); - describe('MonacoLectureAttachmentReferenceAction', () => { + describe('LectureAttachmentReferenceAction', () => { let lectures: Lecture[]; - let lectureAttachmentReferenceAction: MonacoLectureAttachmentReferenceAction; + let lectureAttachmentReferenceAction: LectureAttachmentReferenceAction; beforeEach(() => { lectures = metisService.getCourse().lectures!; jest.spyOn(lectureService, 'findAllByCourseIdWithSlides').mockReturnValue(of(new HttpResponse({ body: lectures, status: 200 }))); - lectureAttachmentReferenceAction = new MonacoLectureAttachmentReferenceAction(metisService, lectureService); + lectureAttachmentReferenceAction = new LectureAttachmentReferenceAction(metisService, lectureService); }); afterEach(() => { diff --git a/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-grading-instructions.integration.spec.ts b/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-grading-instructions.integration.spec.ts index c0ce2132b130..8d608dc314b6 100644 --- a/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-grading-instructions.integration.spec.ts +++ b/src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-grading-instructions.integration.spec.ts @@ -3,13 +3,13 @@ import { ArtemisTestModule } from '../../../test.module'; import { MonacoEditorModule } from 'app/shared/monaco-editor/monaco-editor.module'; import { MockResizeObserver } from '../../../helpers/mocks/service/mock-resize-observer'; import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { MonacoGradingInstructionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-instruction.action'; -import { MonacoGradingCreditsAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-credits.action'; -import { MonacoGradingScaleAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-scale.action'; -import { MonacoGradingDescriptionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-description.action'; -import { MonacoGradingFeedbackAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-feedback.action'; -import { MonacoGradingUsageCountAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-usage-count.action'; -import { MonacoGradingCriterionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-criterion.action'; +import { GradingInstructionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-instruction.action'; +import { GradingCreditsAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-credits.action'; +import { GradingScaleAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-scale.action'; +import { GradingDescriptionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-description.action'; +import { GradingFeedbackAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-feedback.action'; +import { GradingUsageCountAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-usage-count.action'; +import { GradingCriterionAction } from 'app/shared/monaco-editor/model/actions/grading-criteria/grading-criterion.action'; describe('MonacoEditorActionGradingInstructionsIntegration', () => { let fixture: ComponentFixture; @@ -37,13 +37,13 @@ describe('MonacoEditorActionGradingInstructionsIntegration', () => { }); const setupActions = () => { - const creditsAction = new MonacoGradingCreditsAction(); - const scaleAction = new MonacoGradingScaleAction(); - const descriptionAction = new MonacoGradingDescriptionAction(); - const feedbackAction = new MonacoGradingFeedbackAction(); - const usageCountAction = new MonacoGradingUsageCountAction(); - const instructionAction = new MonacoGradingInstructionAction(creditsAction, scaleAction, descriptionAction, feedbackAction, usageCountAction); - const criterionAction = new MonacoGradingCriterionAction(instructionAction); + const creditsAction = new GradingCreditsAction(); + const scaleAction = new GradingScaleAction(); + const descriptionAction = new GradingDescriptionAction(); + const feedbackAction = new GradingFeedbackAction(); + const usageCountAction = new GradingUsageCountAction(); + const instructionAction = new GradingInstructionAction(creditsAction, scaleAction, descriptionAction, feedbackAction, usageCountAction); + const criterionAction = new GradingCriterionAction(instructionAction); [creditsAction, scaleAction, descriptionAction, feedbackAction, usageCountAction, instructionAction, criterionAction].forEach((action) => comp.registerAction(action)); return { creditsAction, scaleAction, descriptionAction, feedbackAction, usageCountAction, instructionAction, criterionAction }; }; From d401416c0e42ecb54bf0e814d8319c38e7df7f19 Mon Sep 17 00:00:00 2001 From: Patrik Zander Date: Sat, 31 Aug 2024 21:00:01 +0200 Subject: [PATCH 26/27] Rename action IDs --- .../app/shared/monaco-editor/model/actions/attachment.action.ts | 2 +- .../app/shared/monaco-editor/model/actions/bold.action.ts | 2 +- .../app/shared/monaco-editor/model/actions/code-block.action.ts | 2 +- .../app/shared/monaco-editor/model/actions/code.action.ts | 2 +- .../app/shared/monaco-editor/model/actions/color.action.ts | 2 +- .../model/actions/communication/channel-reference.action.ts | 2 +- .../model/actions/communication/exercise-reference.action.ts | 2 +- .../communication/lecture-attachment-reference.action.ts | 2 +- .../model/actions/communication/user-mention.action.ts | 2 +- .../app/shared/monaco-editor/model/actions/formula.action.ts | 2 +- .../app/shared/monaco-editor/model/actions/fullscreen.action.ts | 2 +- .../model/actions/grading-criteria/grading-credits.action.ts | 2 +- .../model/actions/grading-criteria/grading-criterion.action.ts | 2 +- .../actions/grading-criteria/grading-description.action.ts | 2 +- .../model/actions/grading-criteria/grading-feedback.action.ts | 2 +- .../actions/grading-criteria/grading-instruction.action.ts | 2 +- .../model/actions/grading-criteria/grading-scale.action.ts | 2 +- .../actions/grading-criteria/grading-usage-count.action.ts | 2 +- .../app/shared/monaco-editor/model/actions/heading.action.ts | 2 +- .../app/shared/monaco-editor/model/actions/italic.action.ts | 2 +- .../shared/monaco-editor/model/actions/ordered-list.action.ts | 2 +- .../model/actions/quiz/insert-short-answer-option.action.ts | 2 +- .../model/actions/quiz/insert-short-answer-spot.action.ts | 2 +- .../monaco-editor/model/actions/quiz/quiz-explanation.action.ts | 2 +- .../shared/monaco-editor/model/actions/quiz/quiz-hint.action.ts | 2 +- .../model/actions/quiz/wrong-multiple-choice-answer.action.ts | 2 +- .../app/shared/monaco-editor/model/actions/quote.action.ts | 2 +- .../app/shared/monaco-editor/model/actions/task.action.ts | 2 +- .../app/shared/monaco-editor/model/actions/test-case.action.ts | 2 +- .../app/shared/monaco-editor/model/actions/underline.action.ts | 2 +- .../shared/monaco-editor/model/actions/unordered-list.action.ts | 2 +- .../webapp/app/shared/monaco-editor/model/actions/url.action.ts | 2 +- 32 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/attachment.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/attachment.action.ts index 72c8a82a72d4..7d059f287359 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/attachment.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/attachment.action.ts @@ -11,7 +11,7 @@ interface AttachmentArguments { * Action to insert an attachment into the editor. They follow the format ![text](url). */ export class AttachmentAction extends TextEditorAction { - static readonly ID = 'monaco-attachment.action'; + static readonly ID = 'attachment.action'; static readonly DEFAULT_INSERT_TEXT = '![](https://)'; constructor() { super(AttachmentAction.ID, 'artemisApp.multipleChoiceQuestion.editor.imageUpload', faImage, undefined); diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/bold.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/bold.action.ts index 21abf6417b85..ccb84e0a6854 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/bold.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/bold.action.ts @@ -9,7 +9,7 @@ const BOLD_DELIMITER = '**'; * Action to toggle bold text in the editor. It wraps the selected text with the bold delimiter, e.g. switching between text and **text**. */ export class BoldAction extends TextEditorAction { - static readonly ID = 'monaco-bold.action'; + static readonly ID = 'bold.action'; constructor() { super(BoldAction.ID, 'artemisApp.multipleChoiceQuestion.editor.bold', faBold, [new TextEditorKeybinding(TextEditorKeyCode.KeyB, TextEditorKeyModifier.CtrlCmd)]); diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/code-block.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/code-block.action.ts index 887e885e8603..cf93c6a828cb 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/code-block.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/code-block.action.ts @@ -8,7 +8,7 @@ const CODE_BLOCK_DELIMITER = '```'; * Action to toggle code block in the editor. It wraps the selected text with the code block delimiters and inserts newlines, e.g. for the default language java, switching between text and ```java\n text \n```. */ export class CodeBlockAction extends TextEditorAction { - static readonly ID = 'monaco-code-block.action'; + static readonly ID = 'code-block.action'; constructor(private readonly defaultLanguage?: string) { super(CodeBlockAction.ID, 'artemisApp.multipleChoiceQuestion.editor.codeBlock', faFileCode, undefined); diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/code.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/code.action.ts index c3dac56953cd..17233b718b25 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/code.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/code.action.ts @@ -8,7 +8,7 @@ const CODE_DELIMITER = '`'; * Action to toggle code text in the editor. It wraps the selected text with the code delimiter, e.g. switching between text and `text`. */ export class CodeAction extends TextEditorAction { - static readonly ID = 'monaco-code.action'; + static readonly ID = 'code.action'; constructor() { super(CodeAction.ID, 'artemisApp.multipleChoiceQuestion.editor.code', faCode, undefined); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/color.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/color.action.ts index de3546d693ed..6c8454f1d520 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/color.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/color.action.ts @@ -11,7 +11,7 @@ const CLOSE_DELIMITER = ''; * Action to toggle color text in the editor. It wraps the selected text with the color delimiter, e.g. switching between text and text. */ export class ColorAction extends TextEditorAction { - static readonly ID = 'monaco-color.action'; + static readonly ID = 'color.action'; constructor() { super(ColorAction.ID, 'artemisApp.multipleChoiceQuestion.editor.color', undefined, undefined); diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/channel-reference.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/channel-reference.action.ts index add5f10791bd..f3bc053b43da 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/channel-reference.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/channel-reference.action.ts @@ -14,7 +14,7 @@ import { TextEditorCompletionItem, TextEditorCompletionItemKind } from 'app/shar * Action to insert a reference to a channel into the editor. Users that type a # will see a list of available channels to reference. */ export class ChannelReferenceAction extends TextEditorAction { - static readonly ID = 'monaco-channel-reference.action'; + static readonly ID = 'channel-reference.action'; static readonly DEFAULT_INSERT_TEXT = '#'; cachedChannels?: ChannelIdAndNameDTO[]; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/exercise-reference.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/exercise-reference.action.ts index e4d3005a6496..7515028babe3 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/exercise-reference.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/exercise-reference.action.ts @@ -11,7 +11,7 @@ import { TextEditorRange } from 'app/shared/monaco-editor/model/actions/adapter/ * Action to insert a reference to an exercise into the editor. Users that type a / will see a list of available exercises to reference. */ export class ExerciseReferenceAction extends MonacoEditorDomainActionWithOptions { - static readonly ID = 'monaco-exercise-reference.action'; + static readonly ID = 'exercise-reference.action'; static readonly DEFAULT_INSERT_TEXT = '/exercise'; disposableCompletionProvider?: Disposable; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/lecture-attachment-reference.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/lecture-attachment-reference.action.ts index b6da28731e20..89511c44c9e4 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/lecture-attachment-reference.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/lecture-attachment-reference.action.ts @@ -29,7 +29,7 @@ interface LectureAttachmentReferenceActionArgs { * The specific format of the reference depends on the type of reference. */ export class LectureAttachmentReferenceAction extends TextEditorAction { - static readonly ID = 'monaco-lecture-attachment-reference.action'; + static readonly ID = 'lecture-attachment-reference.action'; lecturesWithDetails: LectureWithDetails[] = []; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/user-mention.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/user-mention.action.ts index 47e1afb69a3c..e6fa9b208397 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/user-mention.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/user-mention.action.ts @@ -17,7 +17,7 @@ import { TextEditorCompletionItem, TextEditorCompletionItemKind } from 'app/shar export class UserMentionAction extends TextEditorAction { disposableCompletionProvider?: Disposable; - static readonly ID = 'monaco-user-mention.action'; + static readonly ID = 'user-mention.action'; static readonly DEFAULT_INSERT_TEXT = '@'; constructor( diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/formula.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/formula.action.ts index da32fa143041..0ab9e49aa711 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/formula.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/formula.action.ts @@ -8,7 +8,7 @@ const FORMULA_CLOSE_DELIMITER = ' $$'; * Action to toggle formula text in the editor. It wraps the selected text with the formula delimiter, e.g. switching between text and $$ text $$. */ export class FormulaAction extends TextEditorDomainAction { - static readonly ID = 'monaco-formula.action'; + static readonly ID = 'formula.action'; static readonly DEFAULT_FORMULA = 'e^{\\frac{1}{4} y^2}'; constructor() { super(FormulaAction.ID, 'artemisApp.markdownEditor.commands.katex', undefined, undefined); diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/fullscreen.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/fullscreen.action.ts index b5f561dbb44a..3a0106b3f3a1 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/fullscreen.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/fullscreen.action.ts @@ -7,7 +7,7 @@ import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text- * Action to toggle fullscreen mode in the editor. */ export class FullscreenAction extends TextEditorAction { - static readonly ID = 'monaco-fullscreen.action'; + static readonly ID = 'fullscreen.action'; element?: HTMLElement; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-credits.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-credits.action.ts index 0048fa3592ae..5132e188c2a5 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-credits.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-credits.action.ts @@ -2,7 +2,7 @@ import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/t import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; export class GradingCreditsAction extends TextEditorDomainAction { - static readonly ID = 'monaco-grading-credits.action'; + static readonly ID = 'grading-credits.action'; static readonly IDENTIFIER = '[credits]'; static readonly TEXT = '0'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-criterion.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-criterion.action.ts index 812814fceb09..1b9c4d01fcde 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-criterion.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-criterion.action.ts @@ -3,7 +3,7 @@ import { GradingInstructionAction } from './grading-instruction.action'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; export class GradingCriterionAction extends TextEditorDomainAction { - static readonly ID = 'monaco-grading-criterion.action'; + static readonly ID = 'grading-criterion.action'; static readonly IDENTIFIER = '[criterion]'; static readonly TEXT = 'Add criterion title (only visible to tutors)'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-description.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-description.action.ts index 821973aa4e26..c03c16043a93 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-description.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-description.action.ts @@ -2,7 +2,7 @@ import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/t import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; export class GradingDescriptionAction extends TextEditorDomainAction { - static readonly ID = 'monaco-grading-description.action'; + static readonly ID = 'grading-description.action'; static readonly IDENTIFIER = '[description]'; static readonly TEXT = 'Add grading instruction here (only visible for tutors)'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-feedback.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-feedback.action.ts index c2b131717425..4e6636a6f1a5 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-feedback.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-feedback.action.ts @@ -2,7 +2,7 @@ import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/t import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; export class GradingFeedbackAction extends TextEditorDomainAction { - static readonly ID = 'monaco-grading-feedback.action'; + static readonly ID = 'grading-feedback.action'; static readonly IDENTIFIER = '[feedback]'; static readonly TEXT = 'Add feedback for students here (visible for students)'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-instruction.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-instruction.action.ts index bc4c3ed6b4e4..20dc1605f3e4 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-instruction.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-instruction.action.ts @@ -7,7 +7,7 @@ import { GradingUsageCountAction } from 'app/shared/monaco-editor/model/actions/ import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; export class GradingInstructionAction extends TextEditorDomainAction { - static readonly ID = 'monaco-grading-instruction.action'; + static readonly ID = 'grading-instruction.action'; static readonly IDENTIFIER = '[instruction]'; constructor( diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-scale.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-scale.action.ts index 352e223a30b2..d5720026eb27 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-scale.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-scale.action.ts @@ -2,7 +2,7 @@ import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/t import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; export class GradingScaleAction extends TextEditorDomainAction { - static readonly ID = 'monaco-grading-scale.action'; + static readonly ID = 'grading-scale.action'; static readonly IDENTIFIER = '[gradingScale]'; static readonly TEXT = 'Add instruction grading scale here (only visible for tutors)'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-usage-count.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-usage-count.action.ts index 695e9061925b..aa6779d1c3aa 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-usage-count.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/grading-criteria/grading-usage-count.action.ts @@ -2,7 +2,7 @@ import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/t import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; export class GradingUsageCountAction extends TextEditorDomainAction { - static readonly ID = 'monaco-grading-usage-count.action'; + static readonly ID = 'grading-usage-count.action'; static readonly IDENTIFIER = '[maxCountInScore]'; static readonly TEXT = '0'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/heading.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/heading.action.ts index 6a190e11effa..5b5c975db09f 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/heading.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/heading.action.ts @@ -21,7 +21,7 @@ export class HeadingAction extends TextEditorAction { * @param level The level of the heading, e.g. 1 for "# Heading", 2 for "## Heading", ... */ constructor(level: number) { - super(`monaco-heading-${level}.action`, getTranslationKeyForLevel(level), faHeading); + super(`heading-${level}.action`, getTranslationKeyForLevel(level), faHeading); this.level = level; } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/italic.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/italic.action.ts index b7cce6906687..8c2f3a7217a7 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/italic.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/italic.action.ts @@ -9,7 +9,7 @@ const ITALIC_DELIMITER = '*'; * Action to toggle italic text in the editor. It wraps the selected text with the italic delimiter, e.g. switching between text and *text*. */ export class ItalicAction extends TextEditorAction { - static readonly ID = 'monaco-italic.action'; + static readonly ID = 'italic.action'; constructor() { super(ItalicAction.ID, 'artemisApp.multipleChoiceQuestion.editor.italic', faItalic, [new TextEditorKeybinding(TextEditorKeyCode.KeyI, TextEditorKeyModifier.CtrlCmd)]); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/ordered-list.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/ordered-list.action.ts index a86ed80ad04c..fb3e10bc01c7 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/ordered-list.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/ordered-list.action.ts @@ -10,7 +10,7 @@ const NUMBER_REGEX = /^\d+\.\s.*/; * Action to toggle unordered list in the editor. It toggles the "1. ", "2. ", ... prefix for the entire selection. */ export class OrderedListAction extends TextEditorAction { - static readonly ID = 'monaco-ordered-list.action'; + static readonly ID = 'ordered-list.action'; constructor() { super(OrderedListAction.ID, 'artemisApp.multipleChoiceQuestion.editor.orderedList', faListOl, undefined); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/insert-short-answer-option.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/insert-short-answer-option.action.ts index 5e466229d360..96fdff21a1a6 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/insert-short-answer-option.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/insert-short-answer-option.action.ts @@ -11,7 +11,7 @@ interface InsertShortAnswerOptionArgs { * Action to insert a short answer option ([-option #] Option text) at the end of the editor. */ export class InsertShortAnswerOptionAction extends TextEditorAction { - static readonly ID = 'monaco-insert-short-answer-option.action'; + static readonly ID = 'insert-short-answer-option.action'; static readonly DEFAULT_TEXT = 'Enter an answer option here and ensure the spot number is correct.'; static readonly DEFAULT_TEXT_SHORT = 'Enter an answer option here.'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/insert-short-answer-spot.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/insert-short-answer-spot.action.ts index 2fe715ff76d7..8e5608bba7e3 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/insert-short-answer-spot.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/insert-short-answer-spot.action.ts @@ -7,7 +7,7 @@ import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text- * After inserting the spot, this action also inserts an option linked to the spot. */ export class InsertShortAnswerSpotAction extends TextEditorAction { - static readonly ID = 'monaco-insert-short-answer-spot.action'; + static readonly ID = 'insert-short-answer-spot.action'; spotNumber = 1; /** diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/quiz-explanation.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/quiz-explanation.action.ts index fad84bbfe34f..5ed446727b4e 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/quiz-explanation.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/quiz-explanation.action.ts @@ -2,7 +2,7 @@ import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/t import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; export class QuizExplanationAction extends TextEditorDomainAction { - static readonly ID = 'monaco-quiz-explanation.action'; + static readonly ID = 'quiz-explanation.action'; static readonly IDENTIFIER = '[exp]'; static readonly TEXT = 'Add an explanation here (only visible in feedback after quiz has ended)'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/quiz-hint.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/quiz-hint.action.ts index 79981de58658..7c36dbdc2887 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/quiz-hint.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/quiz-hint.action.ts @@ -2,7 +2,7 @@ import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/t import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; export class QuizHintAction extends TextEditorDomainAction { - static readonly ID = 'monaco-quiz-hint.action'; + static readonly ID = 'quiz-hint.action'; static readonly IDENTIFIER = '[hint]'; static readonly TEXT = 'Add a hint here (visible during the quiz via ?-Button)'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/wrong-multiple-choice-answer.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/wrong-multiple-choice-answer.action.ts index 0c998678045b..4357cd970a47 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/wrong-multiple-choice-answer.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quiz/wrong-multiple-choice-answer.action.ts @@ -2,7 +2,7 @@ import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/t import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; export class WrongMultipleChoiceAnswerAction extends TextEditorDomainAction { - static readonly ID = 'monaco-incorrect-multiple-choice-answer.action'; + static readonly ID = 'incorrect-multiple-choice-answer.action'; static readonly IDENTIFIER = '[wrong]'; static readonly TEXT = 'Enter a wrong answer option here'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/quote.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/quote.action.ts index 2fc396a308c2..5d36d12c0817 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/quote.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/quote.action.ts @@ -8,7 +8,7 @@ const QUOTE_OPEN_DELIMITER = '> '; * Action to toggle quote text in the editor. It wraps the selected text with the quote delimiter, e.g. switching between text and > text. */ export class QuoteAction extends TextEditorAction { - static readonly ID = 'monaco-quote.action'; + static readonly ID = 'quote.action'; constructor() { super(QuoteAction.ID, 'artemisApp.multipleChoiceQuestion.editor.quote', faQuoteLeft, undefined); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/task.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/task.action.ts index 7eb4bf98a51f..4652f94dbd04 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/task.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/task.action.ts @@ -6,7 +6,7 @@ import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text- * Action to insert a task into the editor. They follow the format [task][Task Short Description](testCaseName). */ export class TaskAction extends TextEditorDomainAction { - static readonly ID = 'monaco-task.action'; + static readonly ID = 'task.action'; static readonly TEXT = '[Task Short Description](testCaseName)\n'; static readonly IDENTIFIER = '[task]'; static readonly GLOBAL_TASK_REGEX = new RegExp(`${escapeStringForUseInRegex(TaskAction.IDENTIFIER)}(.*)`, 'g'); diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/test-case.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/test-case.action.ts index 808dd89ee33b..b2a5f7fe1119 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/test-case.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/test-case.action.ts @@ -12,7 +12,7 @@ import { TextEditorCompletionItem, TextEditorCompletionItemKind } from 'app/shar export class TestCaseAction extends MonacoEditorDomainActionWithOptions { disposableCompletionProvider?: Disposable; - static readonly ID = 'monaco-test-case.action'; + static readonly ID = 'test-case.action'; static readonly DEFAULT_INSERT_TEXT = 'testCaseName()'; constructor() { diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/underline.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/underline.action.ts index 5c1dab0993fc..82020f4dc8a0 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/underline.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/underline.action.ts @@ -10,7 +10,7 @@ const UNDERLINE_CLOSE_DELIMITER = ''; * Action to toggle underline text in the editor. It wraps the selected text with the underline delimiter, e.g. switching between text and text. */ export class UnderlineAction extends TextEditorAction { - static readonly ID = 'monaco-underline.action'; + static readonly ID = 'underline.action'; constructor() { super(UnderlineAction.ID, 'artemisApp.multipleChoiceQuestion.editor.underline', faUnderline, [ new TextEditorKeybinding(TextEditorKeyCode.KeyU, TextEditorKeyModifier.CtrlCmd), diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/unordered-list.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/unordered-list.action.ts index 20f7cf40e019..3056ab061c55 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/unordered-list.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/unordered-list.action.ts @@ -10,7 +10,7 @@ const LIST_BULLET = '- '; * Action to toggle unordered list in the editor. It toggles the "- " prefix for the entire selection. */ export class UnorderedListAction extends TextEditorAction { - static readonly ID = 'monaco-unordered-list.action'; + static readonly ID = 'unordered-list.action'; constructor() { super(UnorderedListAction.ID, 'artemisApp.multipleChoiceQuestion.editor.unorderedList', faListUl, undefined); } diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/url.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/url.action.ts index cd4edc477024..5ef83d5e4169 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/url.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/url.action.ts @@ -11,7 +11,7 @@ interface UrlArguments { * Action to insert a URL into the editor. They follow the format [text](url). */ export class UrlAction extends TextEditorAction { - static readonly ID = 'monaco-url.action'; + static readonly ID = 'url.action'; static readonly DEFAULT_INSERT_TEXT = '[](https://)'; constructor() { From 9b18e28b50eac375c4bf2ea50ca1e26cea0d5d51 Mon Sep 17 00:00:00 2001 From: Patrik Zander Date: Sat, 31 Aug 2024 21:08:39 +0200 Subject: [PATCH 27/27] Rename another action class --- .../monaco/markdown-editor-monaco.component.ts | 8 ++++---- .../model/actions/adapter/monaco-text-editor.adapter.ts | 4 ++++ .../actions/communication/exercise-reference.action.ts | 4 ++-- .../monaco-editor/model/actions/test-case.action.ts | 4 ++-- .../model/actions/text-editor-action.model.ts | 4 ++-- .../text-editor-domain-action-with-options.model.ts | 2 +- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/main/webapp/app/shared/markdown-editor/monaco/markdown-editor-monaco.component.ts b/src/main/webapp/app/shared/markdown-editor/monaco/markdown-editor-monaco.component.ts index 48c33f338542..e6d39b34e260 100644 --- a/src/main/webapp/app/shared/markdown-editor/monaco/markdown-editor-monaco.component.ts +++ b/src/main/webapp/app/shared/markdown-editor/monaco/markdown-editor-monaco.component.ts @@ -36,7 +36,7 @@ import { ColorAction } from 'app/shared/monaco-editor/model/actions/color.action import { ColorSelectorComponent } from 'app/shared/color-selector/color-selector.component'; import { CdkDragMove, Point } from '@angular/cdk/drag-drop'; import { TextEditorDomainAction } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action.model'; -import { MonacoEditorDomainActionWithOptions } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action-with-options.model'; +import { TextEditorDomainActionWithOptions } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action-with-options.model'; import { LectureAttachmentReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/lecture-attachment-reference.action'; import { LectureUnitType } from 'app/entities/lecture-unit/lectureUnit.model'; import { ReferenceType } from 'app/shared/metis/metis.util'; @@ -60,7 +60,7 @@ interface MarkdownActionsByGroup { color?: ColorAction; domain: { withoutOptions: TextEditorDomainAction[]; - withOptions: MonacoEditorDomainActionWithOptions[]; + withOptions: TextEditorDomainActionWithOptions[]; }; // Special case due to the complex structure of lectures, attachments, and their slides lecture?: LectureAttachmentReferenceAction; @@ -263,8 +263,8 @@ export class MarkdownEditorMonacoComponent implements AfterContentInit, AfterVie header: this.filterDisplayedActions(this.headerActions?.actions ?? []), color: this.filterDisplayedAction(this.colorAction), domain: { - withoutOptions: this.filterDisplayedActions(this.domainActions.filter((action) => !(action instanceof MonacoEditorDomainActionWithOptions))), - withOptions: this.filterDisplayedActions(this.domainActions.filter((action) => action instanceof MonacoEditorDomainActionWithOptions)), + withoutOptions: this.filterDisplayedActions(this.domainActions.filter((action) => !(action instanceof TextEditorDomainActionWithOptions))), + withOptions: this.filterDisplayedActions(this.domainActions.filter((action) => action instanceof TextEditorDomainActionWithOptions)), }, lecture: this.filterDisplayedAction(this.lectureReferenceAction), meta: this.filterDisplayedActions(this.metaActions), diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts index 26568f827c7a..7bd630b7d479 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts @@ -35,6 +35,10 @@ export class MonacoTextEditorAdapter implements TextEditor { this.editor.trigger('TextEditorAdapter::executeAction', action.id, args); } + /** + * Adds a completer to the current model of the editor. This is useful to provide suggestions to the user for a specific editor, which is not supported by the Monaco API. + * @param completer The completer to add to the editor's current model. + */ addCompleter(completer: TextEditorCompleter): Disposable { const model = this.editor.getModel(); if (!model) { diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/exercise-reference.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/exercise-reference.action.ts index 7515028babe3..84fe668e955e 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/communication/exercise-reference.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/communication/exercise-reference.action.ts @@ -1,6 +1,6 @@ import { TranslateService } from '@ngx-translate/core'; import { MetisService } from 'app/shared/metis/metis.service'; -import { MonacoEditorDomainActionWithOptions } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action-with-options.model'; +import { TextEditorDomainActionWithOptions } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action-with-options.model'; import { ValueItem } from 'app/shared/markdown-editor/value-item.model'; import { Disposable } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; import { TextEditor } from 'app/shared/monaco-editor/model/actions/adapter/text-editor.interface'; @@ -10,7 +10,7 @@ import { TextEditorRange } from 'app/shared/monaco-editor/model/actions/adapter/ /** * Action to insert a reference to an exercise into the editor. Users that type a / will see a list of available exercises to reference. */ -export class ExerciseReferenceAction extends MonacoEditorDomainActionWithOptions { +export class ExerciseReferenceAction extends TextEditorDomainActionWithOptions { static readonly ID = 'exercise-reference.action'; static readonly DEFAULT_INSERT_TEXT = '/exercise'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/test-case.action.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/test-case.action.ts index b2a5f7fe1119..e07223f3804f 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/test-case.action.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/test-case.action.ts @@ -1,5 +1,5 @@ import { TranslateService } from '@ngx-translate/core'; -import { DomainActionWithOptionsArguments, MonacoEditorDomainActionWithOptions } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action-with-options.model'; +import { DomainActionWithOptionsArguments, TextEditorDomainActionWithOptions } from 'app/shared/monaco-editor/model/actions/text-editor-domain-action-with-options.model'; import { Disposable } from 'app/shared/monaco-editor/model/actions/monaco-editor.util'; import { ValueItem } from 'app/shared/markdown-editor/value-item.model'; import { TextEditor } from './adapter/text-editor.interface'; @@ -9,7 +9,7 @@ import { TextEditorCompletionItem, TextEditorCompletionItemKind } from 'app/shar /** * Action to insert a test case into the editor. It also registers a completion item provider offers all possible test cases as completion items to the user. */ -export class TestCaseAction extends MonacoEditorDomainActionWithOptions { +export class TestCaseAction extends TextEditorDomainActionWithOptions { disposableCompletionProvider?: Disposable; static readonly ID = 'test-case.action'; diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/text-editor-action.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/text-editor-action.model.ts index fd867b599d85..96a8e6549b9c 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/text-editor-action.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/text-editor-action.model.ts @@ -43,7 +43,7 @@ export abstract class TextEditorAction implements Disposable { } /** - * The actual implementation of the action. This method is called by Monaco when the action is triggered in the editor. + * The actual implementation of the action. This method is called when the action is triggered in the editor. * @param editor The editor in which the action was triggered. * @param args Optional arguments that can be passed to the action. To ensure this is an object, you can use {@link executeInCurrentEditor}. */ @@ -87,7 +87,7 @@ export abstract class TextEditorAction implements Disposable { } /** - * Registers a completion provider for the current model of the given editor. This is useful to provide completion items for a specific editor, which is not supported by the monaco API. + * Registers a completion provider for the current model of the given editor. * @param editor The editor whose model to register the completion provider for. * @param searchFn Function that returns all relevant items for the current search term. Note that Monaco also filters the items based on the user input. * @param mapToCompletionItemFn Function that maps an item to a Monaco completion suggestion. diff --git a/src/main/webapp/app/shared/monaco-editor/model/actions/text-editor-domain-action-with-options.model.ts b/src/main/webapp/app/shared/monaco-editor/model/actions/text-editor-domain-action-with-options.model.ts index 0b8b787259cd..7ef90a723677 100644 --- a/src/main/webapp/app/shared/monaco-editor/model/actions/text-editor-domain-action-with-options.model.ts +++ b/src/main/webapp/app/shared/monaco-editor/model/actions/text-editor-domain-action-with-options.model.ts @@ -8,7 +8,7 @@ export interface DomainActionWithOptionsArguments { /** * Class representing domain actions for Artemis-specific use cases with options. The user can select an item from a list of options. */ -export abstract class MonacoEditorDomainActionWithOptions extends TextEditorDomainAction { +export abstract class TextEditorDomainActionWithOptions extends TextEditorDomainAction { values: ValueItem[] = []; setValues(values: ValueItem[]) {