Skip to content

Commit

Permalink
refact(editor): sanitize html content when write content.
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamAguera committed Oct 28, 2019
1 parent 79498cb commit feaf475
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions projects/truly-ui/src/components/editor/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {ToolbarConfigModel} from './model/toolbar-config.model';
import {ToolbarConfig} from './interfaces/toolbar-config';
import {I18nService} from '../i18n/i18n.service';
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';
import {DomSanitizer} from '@angular/platform-browser';

@Component({
selector: 'tl-editor',
Expand Down Expand Up @@ -133,7 +134,7 @@ export class TlEditor implements ControlValueAccessor, AfterContentInit, OnChang

private onTouched: any = () => {};

constructor(private i18n: I18nService, private renderer: Renderer2) {
constructor(private i18n: I18nService, private renderer: Renderer2, private sanitizer: DomSanitizer) {
this.fontCollection = [
{description: 'Arial', value: 'Arial'},
{description: 'Verdana', value: 'Verdana'},
Expand Down Expand Up @@ -464,7 +465,7 @@ export class TlEditor implements ControlValueAccessor, AfterContentInit, OnChang
}

writeValue(value: any): void {
this.content = value;
this.content = this.sanitizer.bypassSecurityTrustHtml(value);
}

registerOnChange(fn: any): void {
Expand Down

0 comments on commit feaf475

Please sign in to comment.