diff --git a/projects/angular-editor/src/lib/editor/angular-editor.component.ts b/projects/angular-editor/src/lib/editor/angular-editor.component.ts index f8d94ad2..89e270b4 100644 --- a/projects/angular-editor/src/lib/editor/angular-editor.component.ts +++ b/projects/angular-editor/src/lib/editor/angular-editor.component.ts @@ -353,11 +353,20 @@ export class AngularEditorComponent implements OnInit, ControlValueAccessor, Aft oCode.focus(); } else { if (this.doc.querySelectorAll) { + // if sanitize: true the html element, from preview to text, is sanitized according the sanitizer config. + if(this.config.sanitize !== false){ + editableElement.innerText = this.sanitizer.sanitize(SecurityContext.HTML, editableElement.innerText) + } this.r.setProperty(editableElement, 'innerHTML', editableElement.innerText); } else { oContent = this.doc.createRange(); oContent.selectNodeContents(editableElement.firstChild); - this.r.setProperty(editableElement, 'innerHTML', oContent.toString()); + let oContentString = oContent.toString() + // if sanitize: true the oContent is sanitized according the sanitizer config. + if(this.config.sanitize !== false){ + oContentString = this.sanitizer.sanitize(SecurityContext.HTML, oContentString) + } + this.r.setProperty(editableElement, 'innerHTML', oContentString); } this.r.setProperty(editableElement, 'contentEditable', true); this.modeVisual = true;