From 51d61fcc2235a4402f77c978e953d51e322d44ec Mon Sep 17 00:00:00 2001 From: rhenck <richard.henck@iqb.hu-berlin.de> Date: Tue, 18 Oct 2022 16:38:43 +0200 Subject: [PATCH] Refactor geometry element dependencies Move deps only used by geometry to the geometry class and out of the parent. DomSanitizer was a relict and no longer in use. --- .../common/components/geometry/geometry.component.ts | 9 ++++++++- .../common/directives/element-component.directive.ts | 5 +---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/projects/common/components/geometry/geometry.component.ts b/projects/common/components/geometry/geometry.component.ts index 7b832cb88..1bd788c59 100644 --- a/projects/common/components/geometry/geometry.component.ts +++ b/projects/common/components/geometry/geometry.component.ts @@ -1,9 +1,10 @@ import { - AfterViewInit, Component, EventEmitter, Input, Output + AfterViewInit, Component, ElementRef, EventEmitter, Input, Output, Renderer2 } from '@angular/core'; import { ElementComponent } from 'common/directives/element-component.directive'; import { GeometryElement } from 'common/models/elements/geometry/geometry'; import { ValueChangeElement } from 'common/models/elements/element'; +import { ExternalResourceService } from 'common/services/external-resource.service'; declare const GGBApplet: any; @@ -22,6 +23,12 @@ export class GeometryComponent extends ElementComponent implements AfterViewInit @Input() appDefinition!: string; @Output() elementValueChanged = new EventEmitter<ValueChangeElement>(); + constructor(public elementRef: ElementRef, + private renderer: Renderer2, + private externalResourceService: ExternalResourceService) { + super(elementRef); + } + ngAfterViewInit(): void { this.externalResourceService.initializeGeoGebra(this.renderer); this.externalResourceService.isGeoGebraLoaded().subscribe((isLoaded: boolean) => { diff --git a/projects/common/directives/element-component.directive.ts b/projects/common/directives/element-component.directive.ts index e0869b24f..392d416d9 100644 --- a/projects/common/directives/element-component.directive.ts +++ b/projects/common/directives/element-component.directive.ts @@ -11,10 +11,7 @@ export abstract class ElementComponent implements AfterContentChecked { abstract elementModel: UIElement; project!: 'player' | 'editor'; - constructor(public elementRef: ElementRef, - public sanitizer: DomSanitizer, - protected renderer: Renderer2, - protected externalResourceService: ExternalResourceService) {} + constructor(public elementRef: ElementRef) {} get domElement(): Element { return this.elementRef.nativeElement; -- GitLab