Clean unwanted elements and styles when copy paste from Microsoft Word

9 Oct 20172 minutes to read

While copy pasting content from MSWord document, the content will be processed in the paste action event.pasteCleanupSettings API can be used for removing unwanted elements.
This will convert an unformatted html element (MOS XML format) content to a proper html element.Table elements also will be converted with proper elements.

Options

Description

listConversion



List Conversion option convert the list elements into a proper format pasted from MSWord document to editor.

cleanCSS



Clean Css is used to clean the unwanted css in the elements pasted from MSWord document to editor

removeStyles



Remove styles will remove all styles in the elements pasted from MSWord document to editor.

cleanElements



Clean Elements is used to clean the unwanted elements pasted from MSWord document to editor.

  • HTML
  • <textarea ej-rte id="rteSample" rows="10" cols="30" [value]="val"  width=100% minWidth="100px" style="width: 740px; height: 440px" [pasteCleanupSettings]="pasteCleanupSettings">       
    </textarea>
  • TS
  • import {Component} from '@angular/core';
    
    @Component({
      selector: 'sd-home',
      templateUrl: 'app/components/rte/rte.component.html'
    })
    export class RTEComponent {
        val:any;
        pasteCleanupSettings: any;
    
        constructor() {
           this.val="The RichTextEditor (RTE) control enables you to edit the contents with insert table and images.It also provides a toolbar that helps to apply rich text formats to the content entered in the TextArea.";
           this.pasteCleanupSettings={
                   listConversion:true,
                   cleanCSS:true,
                   removeStyles:true,
                   cleanElements:true
               };
        }
        
    }

    Pasted Content before Cleanup:

    Pasted Content after Cleanup: