angulariframewysiwyghtml-editor

Iframe doesn't work in kolkov angular editor


Kolkov angular editor doesn't support Iframe.

Package: https://www.npmjs.com/package/@kolkov/angular-editor

In the editor, it looks like it's working but the front panel is not showing anything In editor looks perfectGetting blank in front panel

Expected result is : enter image description here

Steps to Reproduce


Solution

  • For this you need to make changes in angular editor config : You need to set sanitize: false.

    config: AngularEditorConfig = {
        sanitize: false,
      .........................
      };
    

    Due to senetize:false chrome gives you an error in the front end like this :

    WARNING: sanitizing HTML stripped some content (see http://g.co/ng/security#xss).

    You can fix this error by creating custom pipe for sanitizing HTML :

    sanitize-html.pipe.ts

    import { Pipe, PipeTransform } from '@angular/core';
    import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
    
    @Pipe({
      name: 'sanitizeHtml'
    })
    export class SanitizeHtmlPipe implements PipeTransform {
    
      constructor(private _sanitizer: DomSanitizer) {
      }
    
      transform(v: string): SafeHtml {
        return this._sanitizer.bypassSecurityTrustHtml(v);
      }
    }
    

    In HTML

    <p *ngIf="appMessageData" [innerHTML]="appMessage | sanitizeHtml"></p>
    

    This will help you :)