diff --git a/projects/common/app.module.ts b/projects/common/app.module.ts index 904e0217366890a2c5531990f0b711d167c497e8..355b7de0543e2c21a00b091efb10abdd172e5ffb 100644 --- a/projects/common/app.module.ts +++ b/projects/common/app.module.ts @@ -34,6 +34,7 @@ import { AudioComponent } from './element-components/audio.component'; import { SafeResourceUrlPipe } from './element-components/pipes/safe-resource-url.pipe'; import { InputBackgroundColorDirective } from './element-components/directives/input-background-color.directive'; import { ErrorTransformPipe } from './element-components/pipes/error-transform.pipe'; +import { SafeResourceHTMLPipe } from './element-components/pipes/safe-resource-html.pipe'; @NgModule({ imports: [ @@ -64,7 +65,8 @@ import { ErrorTransformPipe } from './element-components/pipes/error-transform.p DropdownComponent, SafeResourceUrlPipe, InputBackgroundColorDirective, - ErrorTransformPipe + ErrorTransformPipe, + SafeResourceHTMLPipe ], exports: [ CommonModule, @@ -97,7 +99,8 @@ import { ErrorTransformPipe } from './element-components/pipes/error-transform.p MatSnackBarModule, MatTooltipModule, MatDialogModule, - TranslateModule + TranslateModule, + SafeResourceHTMLPipe ] }) export class SharedModule { } diff --git a/projects/common/element-components/pipes/safe-resource-html.pipe.ts b/projects/common/element-components/pipes/safe-resource-html.pipe.ts new file mode 100644 index 0000000000000000000000000000000000000000..f7e63e0fbf8ab81520599c7f84d415feb7cc0de8 --- /dev/null +++ b/projects/common/element-components/pipes/safe-resource-html.pipe.ts @@ -0,0 +1,13 @@ +import { Pipe, PipeTransform } from '@angular/core'; +import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser'; + +@Pipe({ + name: 'safeResourceHTML' +}) +export class SafeResourceHTMLPipe implements PipeTransform { + constructor(private sanitizer: DomSanitizer) {} + + transform(resourceUrl: string): SafeResourceUrl { + return this.sanitizer.bypassSecurityTrustHtml(resourceUrl); + } +} diff --git a/projects/common/element-components/text.component.ts b/projects/common/element-components/text.component.ts index 829676bcfa42093036c1505b2ce7c1c5cd1e6f11..42a88a8dbf5df4335d1f1b883ce3554d16cc5717 100644 --- a/projects/common/element-components/text.component.ts +++ b/projects/common/element-components/text.component.ts @@ -34,7 +34,7 @@ import { ElementComponent } from '../element-component.directive'; [style.font-weight]="elementModel.bold ? 'bold' : ''" [style.font-style]="elementModel.italic ? 'italic' : ''" [style.text-decoration]="elementModel.underline ? 'underline' : ''" - [innerHTML]="sanitizer.bypassSecurityTrustHtml(elementModel.text)" + [innerHTML]="elementModel.text | safeResourceHTML" #container> </div> </div> diff --git a/projects/editor/src/app/components/unit-view/page-view/properties/element-properties.component.html b/projects/editor/src/app/components/unit-view/page-view/properties/element-properties.component.html index 52c15c332fb5da63f60243164b7a53364c7c4dce..448d959227c267295dea25b16ccf48b1ee10b0a5 100644 --- a/projects/editor/src/app/components/unit-view/page-view/properties/element-properties.component.html +++ b/projects/editor/src/app/components/unit-view/page-view/properties/element-properties.component.html @@ -20,7 +20,7 @@ <ng-container *ngIf="combinedProperties.text"> Text - <div class="text-text" [innerHTML]="sanitizer.bypassSecurityTrustHtml($any(combinedProperties.text))" + <div class="text-text" [innerHTML]="combinedProperties.text | safeResourceHTML" (click)="unitService.showDefaultEditDialog(selectedElements[0])"> </div> </ng-container>